langsys-js-typescript 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -239,6 +239,14 @@ declare class Translations {
|
|
|
239
239
|
private missingToken;
|
|
240
240
|
private scheduleTokenFlush;
|
|
241
241
|
setup(config: iLangsysConfig): void;
|
|
242
|
+
/**
|
|
243
|
+
* Record that a locale's catalog is already present without fetching —
|
|
244
|
+
* e.g. after an SSR handoff seeds `sTranslations` + `currentlyLoadedLocale`.
|
|
245
|
+
* This primes the same `lastLoaded` cache `change()` consults, so the first
|
|
246
|
+
* settle for that locale is a cache hit (no redundant fetch) while every
|
|
247
|
+
* later switch *to* it still flows through `change()` normally.
|
|
248
|
+
*/
|
|
249
|
+
markLoaded(locale: string): void;
|
|
242
250
|
/**
|
|
243
251
|
* React to a user-locale change. Fetches translations if we haven't
|
|
244
252
|
* loaded this locale within the last 60s (or if forced).
|
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,14 @@ declare class Translations {
|
|
|
239
239
|
private missingToken;
|
|
240
240
|
private scheduleTokenFlush;
|
|
241
241
|
setup(config: iLangsysConfig): void;
|
|
242
|
+
/**
|
|
243
|
+
* Record that a locale's catalog is already present without fetching —
|
|
244
|
+
* e.g. after an SSR handoff seeds `sTranslations` + `currentlyLoadedLocale`.
|
|
245
|
+
* This primes the same `lastLoaded` cache `change()` consults, so the first
|
|
246
|
+
* settle for that locale is a cache hit (no redundant fetch) while every
|
|
247
|
+
* later switch *to* it still flows through `change()` normally.
|
|
248
|
+
*/
|
|
249
|
+
markLoaded(locale: string): void;
|
|
242
250
|
/**
|
|
243
251
|
* React to a user-locale change. Fetches translations if we haven't
|
|
244
252
|
* loaded this locale within the last 60s (or if forced).
|
package/dist/index.js
CHANGED
|
@@ -442,6 +442,19 @@ var Translations = class {
|
|
|
442
442
|
this.debug.log(`SSR environment detected - using '${strategy}' token strategy`);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* Record that a locale's catalog is already present without fetching —
|
|
447
|
+
* e.g. after an SSR handoff seeds `sTranslations` + `currentlyLoadedLocale`.
|
|
448
|
+
* This primes the same `lastLoaded` cache `change()` consults, so the first
|
|
449
|
+
* settle for that locale is a cache hit (no redundant fetch) while every
|
|
450
|
+
* later switch *to* it still flows through `change()` normally.
|
|
451
|
+
*/
|
|
452
|
+
markLoaded(locale) {
|
|
453
|
+
if (!locale) return;
|
|
454
|
+
this.locale = locale;
|
|
455
|
+
this.lastLoaded[locale] = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
456
|
+
this.readyResolve();
|
|
457
|
+
}
|
|
445
458
|
/**
|
|
446
459
|
* React to a user-locale change. Fetches translations if we haven't
|
|
447
460
|
* loaded this locale within the last 60s (or if forced).
|
|
@@ -453,6 +466,7 @@ var Translations = class {
|
|
|
453
466
|
this.debug.log("Using pre-fetched translations for locale", locale);
|
|
454
467
|
this.locale = locale;
|
|
455
468
|
this.lastLoaded[locale] = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
469
|
+
this.readyResolve();
|
|
456
470
|
return true;
|
|
457
471
|
}
|
|
458
472
|
const now = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
@@ -656,12 +670,14 @@ var LangsysAppClass = class {
|
|
|
656
670
|
this.debug.log("Populated sTranslations with initial data for locale:", initialTranslationsLocale);
|
|
657
671
|
}
|
|
658
672
|
this.Translations.setup(this.config);
|
|
673
|
+
if (initialTranslations2 && initialTranslationsLocale) {
|
|
674
|
+
this.Translations.markLoaded(initialTranslationsLocale);
|
|
675
|
+
}
|
|
659
676
|
this.config.sUserLocale.subscribe((locale) => {
|
|
660
677
|
if (!validateResponse.status) return;
|
|
661
678
|
this.getLocalesData(locale);
|
|
662
679
|
this.debug.log("SUBSCRIBING TO USER LOCALE STORE");
|
|
663
|
-
|
|
664
|
-
this.translationsLoadingPromise = this.Translations.change(locale, false, skipFetch);
|
|
680
|
+
this.translationsLoadingPromise = this.Translations.change(locale, false);
|
|
665
681
|
});
|
|
666
682
|
return validateResponse;
|
|
667
683
|
}
|