@lionrapid/core 0.6.0 → 0.6.1

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.
@@ -2766,6 +2766,7 @@ var __lionrapidAutoExports = (() => {
2766
2766
  // 🔥 EMBEDDED: Core integration maps
2767
2767
  __publicField(this, "formatters", /* @__PURE__ */ new Map());
2768
2768
  __publicField(this, "processors", /* @__PURE__ */ new Map());
2769
+ __publicField(this, "warnedNoInterpolate", false);
2769
2770
  // 📡 EVENT-DRIVEN: Just track for cleanup
2770
2771
  __publicField(this, "eventPlugins", /* @__PURE__ */ new Set());
2771
2772
  // 📦 CONTENT: Parser and serializer for ContentUnit processing
@@ -3058,6 +3059,11 @@ var __lionrapidAutoExports = (() => {
3058
3059
  resolvedLocale,
3059
3060
  resolvedKey
3060
3061
  );
3062
+ } else if (!this.warnedNoInterpolate && params && Object.keys(params).length > 0 && processedValue.includes("{")) {
3063
+ this.warnedNoInterpolate = true;
3064
+ console.warn(
3065
+ "[LionRapid] Translation params were passed but no interpolate formatter is registered \u2014 {placeholders} render literally. Install @lionrapid/formatters and add .use(coreFormattersPlugin) to the builder."
3066
+ );
3061
3067
  }
3062
3068
  if (this.processors.size > 0) {
3063
3069
  for (const [name, processor] of this.processors.entries()) {
@@ -6013,7 +6019,7 @@ var __lionrapidAutoExports = (() => {
6013
6019
  function readLocaleCookie(availableLanguages) {
6014
6020
  if (typeof document === "undefined") return null;
6015
6021
  const match = document.cookie.match(
6016
- /lionrapid_locale=([a-z]{2,3}(?:-[a-z0-9]{2,4})*)/i
6022
+ /(?:^|;\s*)lionrapid_locale=([a-z]{2,3}(?:-[a-z0-9]{2,4})*)/i
6017
6023
  );
6018
6024
  if (!match) return null;
6019
6025
  return matchLocale([match[1]], availableLanguages, "") || null;
@@ -6059,9 +6065,21 @@ var __lionrapidAutoExports = (() => {
6059
6065
  document.documentElement.dir = localeDir(locale);
6060
6066
  }
6061
6067
  }
6062
- async function autoInit() {
6068
+ function findConfigScript() {
6069
+ const current = document.currentScript;
6070
+ if (current instanceof HTMLScriptElement && current.dataset.apiKey) {
6071
+ return current;
6072
+ }
6063
6073
  const scripts = document.querySelectorAll("script[data-api-key]");
6064
- const script = scripts[scripts.length - 1];
6074
+ if (scripts.length > 1) {
6075
+ console.warn(
6076
+ `[LionRapid] ${scripts.length} script tags with data-api-key found; using the last one`
6077
+ );
6078
+ }
6079
+ return scripts[scripts.length - 1];
6080
+ }
6081
+ async function autoInit() {
6082
+ const script = findConfigScript();
6065
6083
  if (!script) {
6066
6084
  console.warn("[LionRapid] No script tag with data-api-key found");
6067
6085
  return;