Drop ios 12 support

This commit is contained in:
Chocobozzz 2024-11-04 10:25:17 +01:00
parent 3842a527f6
commit c2ff5c112b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 5 additions and 92 deletions

View File

@ -208,11 +208,7 @@
"is-plain-object", "is-plain-object",
"parse-srcset", "parse-srcset",
"deepmerge", "deepmerge",
"core-js/features/reflect", "core-js/features/reflect"
"@formatjs/intl-locale/polyfill",
"@formatjs/intl-locale/should-polyfill",
"@formatjs/intl-pluralrules/polyfill-force",
"@formatjs/intl-pluralrules/should-polyfill"
], ],
"scripts": [], "scripts": [],
"extractLicenses": false, "extractLicenses": false,

View File

@ -53,8 +53,6 @@
"@angular/platform-browser-dynamic": "^18.0.4", "@angular/platform-browser-dynamic": "^18.0.4",
"@angular/router": "^18.0.4", "@angular/router": "^18.0.4",
"@angular/service-worker": "^18.0.4", "@angular/service-worker": "^18.0.4",
"@formatjs/intl-locale": "^4.0.0",
"@formatjs/intl-pluralrules": "^5.2.2",
"@ng-bootstrap/ng-bootstrap": "^17.0.0", "@ng-bootstrap/ng-bootstrap": "^17.0.0",
"@ngx-loading-bar/core": "^6.0.0", "@ngx-loading-bar/core": "^6.0.0",
"@ngx-loading-bar/http-client": "^6.0.0", "@ngx-loading-bar/http-client": "^6.0.0",

View File

@ -1,57 +1,22 @@
import IntlMessageFormat from 'intl-messageformat'
import { shouldPolyfill as shouldPolyfillLocale } from '@formatjs/intl-locale/should-polyfill'
import { shouldPolyfill as shouldPolyfillPlural } from '@formatjs/intl-pluralrules/should-polyfill'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
import IntlMessageFormat from 'intl-messageformat'
import { environment } from '../../environments/environment' import { environment } from '../../environments/environment'
function isOnDevLocale () { export function isOnDevLocale () {
return environment.production === false && window.location.search === '?lang=fr' return environment.production === false && window.location.search === '?lang=fr'
} }
function getDevLocale () { export function getDevLocale () {
return 'fr-FR' return 'fr-FR'
} }
async function polyfillICU () {
// Important to be in this order, Plural needs Locale (https://formatjs.io/docs/polyfills/intl-pluralrules)
await polyfillICULocale()
await polyfillICUPlural()
}
async function polyfillICULocale () {
// This locale is supported
if (shouldPolyfillLocale()) {
// TODO: remove, it's only needed to support Plural polyfill and so iOS 12
console.log('Loading Intl Locale polyfill for ' + $localize.locale)
await import('@formatjs/intl-locale/polyfill')
}
}
async function polyfillICUPlural () {
const unsupportedLocale = shouldPolyfillPlural($localize.locale)
// This locale is supported
if (!unsupportedLocale) {
return
}
// TODO: remove, it's only needed to support iOS 12
console.log('Loading Intl Plural rules polyfill for ' + $localize.locale)
// Load the polyfill 1st BEFORE loading data
await import('@formatjs/intl-pluralrules/polyfill-force')
// Degraded mode, so only load the en local data
await import(`@formatjs/intl-pluralrules/locale-data/en.js`)
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const icuCache = new Map<string, IntlMessageFormat>() const icuCache = new Map<string, IntlMessageFormat>()
const icuWarnings = new Set<string>() const icuWarnings = new Set<string>()
const fallback = 'String translation error' const fallback = 'String translation error'
function formatICU (icu: string, context: { [id: string]: number | string }) { export function formatICU (icu: string, context: { [id: string]: number | string }) {
try { try {
let msg = icuCache.get(icu) let msg = icuCache.get(icu)
@ -70,10 +35,3 @@ function formatICU (icu: string, context: { [id: string]: number | string }) {
return fallback return fallback
} }
} }
export {
getDevLocale,
polyfillICU,
formatICU,
isOnDevLocale
}

View File

@ -23,7 +23,6 @@ import {
ServerService, ServerService,
getCoreProviders getCoreProviders
} from './app/core' } from './app/core'
import { polyfillICU } from './app/helpers'
import { getMainProviders } from './app/shared/shared-main/main-providers' import { getMainProviders } from './app/shared/shared-main/main-providers'
import { environment } from './environments/environment' import { environment } from './environments/environment'
import { logger } from './root-helpers' import { logger } from './root-helpers'
@ -95,11 +94,6 @@ const bootstrap = () => bootstrapApplication(AppComponent, {
useFactory: loadConfigFactory, useFactory: loadConfigFactory,
deps: [ ServerService, PluginService, RedirectService ], deps: [ ServerService, PluginService, RedirectService ],
multi: true multi: true
},
{
provide: APP_INITIALIZER,
useFactory: () => polyfillICU,
multi: true
} }
] ]
}) })

View File

@ -1634,30 +1634,6 @@
"@formatjs/ecma402-abstract" "2.0.0" "@formatjs/ecma402-abstract" "2.0.0"
tslib "^2.4.0" tslib "^2.4.0"
"@formatjs/intl-enumerator@1.4.7":
version "1.4.7"
resolved "https://registry.yarnpkg.com/@formatjs/intl-enumerator/-/intl-enumerator-1.4.7.tgz#6ab697f3f8f18cf0cc6a6b028cb9c40db6001f3d"
integrity sha512-03RHnFqfpB4H/jwCwlzC+wkTDk2Fi24JmVIY2PVGvTUpikN2bSr9+8oTXfOC+y7B7VxjCArUnqWXVoctkmy85w==
dependencies:
tslib "^2.4.0"
"@formatjs/intl-getcanonicallocales@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@formatjs/intl-getcanonicallocales/-/intl-getcanonicallocales-2.3.0.tgz#b6c6fa1c664e30a61f27fa6399a76159d82a5842"
integrity sha512-BOXbLwqQ7nKua/l7tKqDLRN84WupDXFDhGJQMFvsMVA2dKuOdRaWTxWpL3cJ7qPkoNw11Jf+Xpj4OSPBBvW0eQ==
dependencies:
tslib "^2.4.0"
"@formatjs/intl-locale@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@formatjs/intl-locale/-/intl-locale-4.0.0.tgz#c111a33078413eba2011e82140466261eb1d67cd"
integrity sha512-+4dbMEGsp1bvB3JB3UHH6YTjMnFTifnfdaHp4ROrCCu50NedA69RBsDCG3eivcZkbj57X9ehGhMWjLxlP+gyVw==
dependencies:
"@formatjs/ecma402-abstract" "2.0.0"
"@formatjs/intl-enumerator" "1.4.7"
"@formatjs/intl-getcanonicallocales" "2.3.0"
tslib "^2.4.0"
"@formatjs/intl-localematcher@0.5.4": "@formatjs/intl-localematcher@0.5.4":
version "0.5.4" version "0.5.4"
resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz#caa71f2e40d93e37d58be35cfffe57865f2b366f" resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz#caa71f2e40d93e37d58be35cfffe57865f2b366f"
@ -1665,15 +1641,6 @@
dependencies: dependencies:
tslib "^2.4.0" tslib "^2.4.0"
"@formatjs/intl-pluralrules@^5.2.2":
version "5.2.14"
resolved "https://registry.yarnpkg.com/@formatjs/intl-pluralrules/-/intl-pluralrules-5.2.14.tgz#7477bd2aa9bfde9e543d839707eff5460eb08026"
integrity sha512-l6Ev7aOGXJSh5EPDEqzsbyufdCCKXZk993QXRQebLsB0TXRhIyF4alqjdMEatLwIigK/Mka8kiVIOLeFP5Cj9Q==
dependencies:
"@formatjs/ecma402-abstract" "2.0.0"
"@formatjs/intl-localematcher" "0.5.4"
tslib "^2.4.0"
"@humanwhocodes/config-array@^0.11.14": "@humanwhocodes/config-array@^0.11.14":
version "0.11.14" version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"