langsys-js-typescript 0.2.1 → 0.2.2

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 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,18 @@ 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
+ }
445
457
  /**
446
458
  * React to a user-locale change. Fetches translations if we haven't
447
459
  * loaded this locale within the last 60s (or if forced).
@@ -656,12 +668,14 @@ var LangsysAppClass = class {
656
668
  this.debug.log("Populated sTranslations with initial data for locale:", initialTranslationsLocale);
657
669
  }
658
670
  this.Translations.setup(this.config);
671
+ if (initialTranslations2 && initialTranslationsLocale) {
672
+ this.Translations.markLoaded(initialTranslationsLocale);
673
+ }
659
674
  this.config.sUserLocale.subscribe((locale) => {
660
675
  if (!validateResponse.status) return;
661
676
  this.getLocalesData(locale);
662
677
  this.debug.log("SUBSCRIBING TO USER LOCALE STORE");
663
- const skipFetch = initialTranslationsLocale === locale && !!initialTranslations2;
664
- this.translationsLoadingPromise = this.Translations.change(locale, false, skipFetch);
678
+ this.translationsLoadingPromise = this.Translations.change(locale, false);
665
679
  });
666
680
  return validateResponse;
667
681
  }