@i18n-micro/utils 1.0.15 → 1.0.21

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.
Files changed (44) hide show
  1. package/dist/accept-language.cjs +1 -1
  2. package/dist/active-locales.cjs +1 -1
  3. package/dist/app-path.cjs +1 -1
  4. package/dist/app-path.d.cts +12 -0
  5. package/dist/app-path.d.ts +12 -0
  6. package/dist/app-path.mjs +61 -4
  7. package/dist/auto-detect-path.cjs +1 -1
  8. package/dist/auto-detect-path.mjs +2 -4
  9. package/dist/build.cjs +1 -1
  10. package/dist/build.mjs +42 -42
  11. package/dist/cache-control.cjs +1 -1
  12. package/dist/cache-control.mjs +4 -6
  13. package/dist/cookie.cjs +1 -1
  14. package/dist/cookie.mjs +14 -14
  15. package/dist/deep-merge.cjs +1 -1
  16. package/dist/deep-merge.mjs +4 -1
  17. package/dist/merge-i18n-head.cjs +1 -1
  18. package/dist/merge-i18n-head.mjs +22 -16
  19. package/dist/merge-source.cjs +1 -1
  20. package/dist/merge-source.mjs +36 -33
  21. package/dist/normalize.cjs +1 -1
  22. package/dist/parse-path.cjs +1 -1
  23. package/dist/parse-path.mjs +15 -7
  24. package/dist/payload-config.cjs +1 -1
  25. package/dist/payload-config.mjs +20 -28
  26. package/dist/payload-fetch.cjs +1 -1
  27. package/dist/payload-stats.cjs +1 -1
  28. package/dist/payload-stats.mjs +26 -23
  29. package/dist/payload-url.cjs +1 -1
  30. package/dist/payload-url.mjs +17 -17
  31. package/dist/resolve-hreflang.cjs +1 -1
  32. package/dist/resolve-hreflang.mjs +20 -9
  33. package/dist/resolve-locale.cjs +1 -1
  34. package/dist/resolve-og-locale.cjs +1 -1
  35. package/dist/resolve-og-locale.mjs +3 -7
  36. package/dist/route-pattern.cjs +1 -1
  37. package/dist/route.cjs +1 -1
  38. package/dist/route.mjs +22 -26
  39. package/dist/runtime-config.cjs +1 -1
  40. package/dist/runtime-config.mjs +17 -17
  41. package/dist/source-loader.cjs +1 -1
  42. package/dist/split-locale-routes.cjs +1 -1
  43. package/dist/split-locale-routes.mjs +13 -10
  44. package/package.json +7 -7
@@ -1,21 +1,29 @@
1
1
  import { deepMergeTranslations as i } from "./deep-merge.mjs";
2
2
  function l(e) {
3
3
  const t = e.replace(/\\/g, "/");
4
- if (!t.endsWith(".json"))
5
- return { type: "ignore" };
4
+ if (!t.endsWith(".json")) return { type: "ignore" };
6
5
  if (t.startsWith("pages/")) {
7
6
  const n = t.match(/^pages\/(.+)\/([^/]+)\.json$/);
8
- if (!n?.[1] || !n[2])
9
- return { type: "ignore" };
7
+ if (!n?.[1] || !n[2]) return { type: "ignore" };
10
8
  const r = p(n[1].split("/"));
11
- return r ? { type: "page", pageName: r, locale: n[2] } : { type: "ignore" };
9
+ return r ? {
10
+ type: "page",
11
+ pageName: r,
12
+ locale: n[2]
13
+ } : { type: "ignore" };
12
14
  }
13
15
  const o = t.match(/^([^/]+)\.json$/);
14
- return o?.[1] ? { type: "root", locale: o[1] } : { type: "ignore" };
16
+ return o?.[1] ? {
17
+ type: "root",
18
+ locale: o[1]
19
+ } : { type: "ignore" };
15
20
  }
16
21
  function s(e, t = !1) {
17
22
  const o = l(e);
18
- return t && o.type === "page" ? { type: "root", locale: o.locale } : o;
23
+ return t && o.type === "page" ? {
24
+ type: "root",
25
+ locale: o.locale
26
+ } : o;
19
27
  }
20
28
  function p(e) {
21
29
  return e.length === 0 ? null : e.join("-");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("node:path"),s=500,n=10*1024*1024;function l(e){return e.translationPayloads?.mode==="source"?"source":"premerged"}function c(e){const a=l(e),r=a==="source";return{mode:a,serverAssets:e.translationPayloads?.serverAssets!==!1,serverHandler:e.translationPayloads?.serverHandler!==!1,publicAssets:r?e.translationPayloads?.publicAssets===!0:e.translationPayloads?.publicAssets!==!1,prerenderRoutes:e.translationPayloads?.prerenderRoutes===!0,publicDir:e.translationPayloads?.publicDir,warnFileCount:e.translationPayloads?.warnFileCount,warnSizeBytes:e.translationPayloads?.warnSizeBytes}}function o(e,a){const r=e.translationPayloads?.publicDir;return r!=null&&String(r).length>0?String(r).replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/")||"_locales":(a??e.apiBaseUrl??"_locales").replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/")||"_locales"}function y(e,a,r){return d.join(e??"./dist",o(a,r))}function P(e,a){return e.publicAssets?!0:a&&e.serverAssets}function p(e,a){return!a&&e.serverAssets}function A(e){return{warnFileCount:e?.warnFileCount??s,warnSizeBytes:e?.warnSizeBytes??n}}function i(e){return e.serverAssets||e.serverHandler||e.publicAssets||e.prerenderRoutes}function T(e){const a=[];return!e.translationPayloads.serverAssets&&!e.translationPayloads.publicAssets&&!e.apiBaseServerHost&&a.push("[nuxt-i18n-micro] translationPayloads.serverAssets and publicAssets are false and apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."),i(e.translationPayloads)||(e.apiBaseServerHost||a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."),e.apiBaseClientHost||a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseClientHost is not set. Client-side navigation may load empty translations unless you provide an external client payload host.")),a}function u(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function v(e,a){const r=a?.warnFileCount??s,t=a?.warnSizeBytes??n;return e.fileCount<r&&e.totalBytes<t?null:`[nuxt-i18n-micro] Generated translation payloads are large (${e.fileCount} files, ${u(e.totalBytes)}). Consider translationPayloads.mode: 'source' for public output, hosting payloads externally, or disabling unused public/prerender outputs.`}exports.DEFAULT_TRANSLATION_PAYLOAD_WARN_FILE_COUNT=s;exports.DEFAULT_TRANSLATION_PAYLOAD_WARN_SIZE_BYTES=n;exports.formatBytes=u;exports.getTranslationPayloadMisconfigurationWarnings=T;exports.getTranslationPayloadSizeWarning=v;exports.hasLocalTranslationPayloadOutput=i;exports.resolveTranslationPayloadMode=l;exports.resolveTranslationPayloadOptions=c;exports.resolveTranslationPayloadPublicDir=y;exports.resolveTranslationPayloadPublicRel=o;exports.resolveTranslationPayloadWarningThresholds=A;exports.shouldCopyTranslationPayloadsToPublic=P;exports.shouldRegisterNitroServerAssets=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let i=require("node:path");var u=500,d=10485760;function s(e){return e.translationPayloads?.mode==="source"?"source":"premerged"}function c(e){const a=s(e),r=a==="source";return{mode:a,serverAssets:e.translationPayloads?.serverAssets!==!1,serverHandler:e.translationPayloads?.serverHandler!==!1,publicAssets:r?e.translationPayloads?.publicAssets===!0:e.translationPayloads?.publicAssets!==!1,prerenderRoutes:e.translationPayloads?.prerenderRoutes===!0,publicDir:e.translationPayloads?.publicDir,warnFileCount:e.translationPayloads?.warnFileCount,warnSizeBytes:e.translationPayloads?.warnSizeBytes}}function n(e,a){const r=e.translationPayloads?.publicDir;return r!=null&&String(r).length>0?String(r).replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/")||"_locales":(a??e.apiBaseUrl??"_locales").replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/")||"_locales"}function y(e,a,r){return(0,i.join)(e??"./dist",n(a,r))}function P(e,a){return e.publicAssets?!0:a&&e.serverAssets}function p(e,a){return!a&&e.serverAssets}function A(e){return{warnFileCount:e?.warnFileCount??500,warnSizeBytes:e?.warnSizeBytes??10485760}}function l(e){return e.serverAssets||e.serverHandler||e.publicAssets||e.prerenderRoutes}function T(e){const a=[];return!e.translationPayloads.serverAssets&&!e.translationPayloads.publicAssets&&!e.apiBaseServerHost&&a.push("[nuxt-i18n-micro] translationPayloads.serverAssets and publicAssets are false and apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."),l(e.translationPayloads)||(e.apiBaseServerHost||a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."),e.apiBaseClientHost||a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseClientHost is not set. Client-side navigation may load empty translations unless you provide an external client payload host.")),a}function t(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function v(e,a){const r=a?.warnFileCount??500,o=a?.warnSizeBytes??10485760;return e.fileCount<r&&e.totalBytes<o?null:`[nuxt-i18n-micro] Generated translation payloads are large (${e.fileCount} files, ${t(e.totalBytes)}). Consider translationPayloads.mode: 'source' for public output, hosting payloads externally, or disabling unused public/prerender outputs.`}exports.DEFAULT_TRANSLATION_PAYLOAD_WARN_FILE_COUNT=u;exports.DEFAULT_TRANSLATION_PAYLOAD_WARN_SIZE_BYTES=d;exports.formatBytes=t;exports.getTranslationPayloadMisconfigurationWarnings=T;exports.getTranslationPayloadSizeWarning=v;exports.hasLocalTranslationPayloadOutput=l;exports.resolveTranslationPayloadMode=s;exports.resolveTranslationPayloadOptions=c;exports.resolveTranslationPayloadPublicDir=y;exports.resolveTranslationPayloadPublicRel=n;exports.resolveTranslationPayloadWarningThresholds=A;exports.shouldCopyTranslationPayloadsToPublic=P;exports.shouldRegisterNitroServerAssets=p;
@@ -1,29 +1,27 @@
1
- import { join as l } from "node:path";
2
- const n = 500, t = 10 * 1024 * 1024;
3
- function o(e) {
1
+ import { join as n } from "node:path";
2
+ var d = 500, c = 10485760;
3
+ function t(e) {
4
4
  return e.translationPayloads?.mode === "source" ? "source" : "premerged";
5
5
  }
6
6
  function y(e) {
7
- const a = o(e), r = a === "source";
7
+ const a = t(e), r = a === "source";
8
8
  return {
9
9
  mode: a,
10
10
  serverAssets: e.translationPayloads?.serverAssets !== !1,
11
11
  serverHandler: e.translationPayloads?.serverHandler !== !1,
12
12
  publicAssets: r ? e.translationPayloads?.publicAssets === !0 : e.translationPayloads?.publicAssets !== !1,
13
- // Off by default: prerendering `/_locales` without a live handler writes empty public stubs.
14
- // Opt in when you need static `/{apiBaseUrl}/.../data.json` and payloads are already available.
15
13
  prerenderRoutes: e.translationPayloads?.prerenderRoutes === !0,
16
14
  publicDir: e.translationPayloads?.publicDir,
17
15
  warnFileCount: e.translationPayloads?.warnFileCount,
18
16
  warnSizeBytes: e.translationPayloads?.warnSizeBytes
19
17
  };
20
18
  }
21
- function i(e, a) {
19
+ function l(e, a) {
22
20
  const r = e.translationPayloads?.publicDir;
23
21
  return r != null && String(r).length > 0 ? String(r).replace(/^\/+|\/+$/g, "").replace(/\/{2,}/g, "/") || "_locales" : (a ?? e.apiBaseUrl ?? "_locales").replace(/^\/+|\/+$/g, "").replace(/\/{2,}/g, "/") || "_locales";
24
22
  }
25
23
  function p(e, a, r) {
26
- return l(e ?? "./dist", i(a, r));
24
+ return n(e ?? "./dist", l(a, r));
27
25
  }
28
26
  function f(e, a) {
29
27
  return e.publicAssets ? !0 : a && e.serverAssets;
@@ -33,41 +31,35 @@ function v(e, a) {
33
31
  }
34
32
  function A(e) {
35
33
  return {
36
- warnFileCount: e?.warnFileCount ?? n,
37
- warnSizeBytes: e?.warnSizeBytes ?? t
34
+ warnFileCount: e?.warnFileCount ?? 500,
35
+ warnSizeBytes: e?.warnSizeBytes ?? 10485760
38
36
  };
39
37
  }
40
- function u(e) {
38
+ function o(e) {
41
39
  return e.serverAssets || e.serverHandler || e.publicAssets || e.prerenderRoutes;
42
40
  }
43
41
  function P(e) {
44
42
  const a = [];
45
- return !e.translationPayloads.serverAssets && !e.translationPayloads.publicAssets && !e.apiBaseServerHost && a.push(
46
- "[nuxt-i18n-micro] translationPayloads.serverAssets and publicAssets are false and apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."
47
- ), u(e.translationPayloads) || (e.apiBaseServerHost || a.push(
48
- "[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."
49
- ), e.apiBaseClientHost || a.push(
50
- "[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseClientHost is not set. Client-side navigation may load empty translations unless you provide an external client payload host."
51
- )), a;
43
+ return !e.translationPayloads.serverAssets && !e.translationPayloads.publicAssets && !e.apiBaseServerHost && a.push("[nuxt-i18n-micro] translationPayloads.serverAssets and publicAssets are false and apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."), o(e.translationPayloads) || (e.apiBaseServerHost || a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseServerHost is not set. SSR will load empty translations unless you provide an external server payload host."), e.apiBaseClientHost || a.push("[nuxt-i18n-micro] translationPayloads disabled all local outputs but apiBaseClientHost is not set. Client-side navigation may load empty translations unless you provide an external client payload host.")), a;
52
44
  }
53
- function d(e) {
54
- return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : e >= 1024 ? `${(e / 1024).toFixed(1)} KB` : `${e} B`;
45
+ function i(e) {
46
+ return e >= 1048576 ? `${(e / 1048576).toFixed(1)} MB` : e >= 1024 ? `${(e / 1024).toFixed(1)} KB` : `${e} B`;
55
47
  }
56
48
  function S(e, a) {
57
- const r = a?.warnFileCount ?? n, s = a?.warnSizeBytes ?? t;
58
- return e.fileCount < r && e.totalBytes < s ? null : `[nuxt-i18n-micro] Generated translation payloads are large (${e.fileCount} files, ${d(e.totalBytes)}). Consider translationPayloads.mode: 'source' for public output, hosting payloads externally, or disabling unused public/prerender outputs.`;
49
+ const r = a?.warnFileCount ?? 500, s = a?.warnSizeBytes ?? 10485760;
50
+ return e.fileCount < r && e.totalBytes < s ? null : `[nuxt-i18n-micro] Generated translation payloads are large (${e.fileCount} files, ${i(e.totalBytes)}). Consider translationPayloads.mode: 'source' for public output, hosting payloads externally, or disabling unused public/prerender outputs.`;
59
51
  }
60
52
  export {
61
- n as DEFAULT_TRANSLATION_PAYLOAD_WARN_FILE_COUNT,
62
- t as DEFAULT_TRANSLATION_PAYLOAD_WARN_SIZE_BYTES,
63
- d as formatBytes,
53
+ d as DEFAULT_TRANSLATION_PAYLOAD_WARN_FILE_COUNT,
54
+ c as DEFAULT_TRANSLATION_PAYLOAD_WARN_SIZE_BYTES,
55
+ i as formatBytes,
64
56
  P as getTranslationPayloadMisconfigurationWarnings,
65
57
  S as getTranslationPayloadSizeWarning,
66
- u as hasLocalTranslationPayloadOutput,
67
- o as resolveTranslationPayloadMode,
58
+ o as hasLocalTranslationPayloadOutput,
59
+ t as resolveTranslationPayloadMode,
68
60
  y as resolveTranslationPayloadOptions,
69
61
  p as resolveTranslationPayloadPublicDir,
70
- i as resolveTranslationPayloadPublicRel,
62
+ l as resolveTranslationPayloadPublicRel,
71
63
  A as resolveTranslationPayloadWarningThresholds,
72
64
  f as shouldCopyTranslationPayloadsToPublic,
73
65
  v as shouldRegisterNitroServerAssets
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./normalize.cjs"),i=require("./payload-url.cjs");async function n(a,r,t,s){if(!a.apiBaseServerHost)return{};const e=i.buildTranslationPayloadFetchRequest({apiBaseUrl:a.apiBaseUrl??"_locales",routeName:t,locale:r,isServer:!0,baseURL:a.apiBaseServerHost,apiBaseServerHost:a.apiBaseServerHost,dateBuild:a.dateBuild});try{const o=await s(e.path,{baseURL:e.baseURL,params:e.params});return l.toTranslations(o)}catch{return{}}}exports.fetchTranslationPayloadFromHost=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./normalize.cjs"),l=require("./payload-url.cjs");async function u(e,r,t,s){if(!e.apiBaseServerHost)return{};const a=l.buildTranslationPayloadFetchRequest({apiBaseUrl:e.apiBaseUrl??"_locales",routeName:t,locale:r,isServer:!0,baseURL:e.apiBaseServerHost,apiBaseServerHost:e.apiBaseServerHost,dateBuild:e.dateBuild});try{const o=await s(a.path,{baseURL:a.baseURL,params:a.params});return i.toTranslations(o)}catch{return{}}}exports.fetchTranslationPayloadFromHost=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:crypto"),o=require("node:fs"),l=require("node:zlib"),u=require("node:path");function f(n,t){for(const e of o.readdirSync(n,{withFileTypes:!0})){const s=u.join(n,e.name);e.isDirectory()?f(s,t):e.name.endsWith(".json")&&t.push(s)}}function S(n){const t={fileCount:0,totalBytes:0};if(!o.existsSync(n))return t;const e=[];f(n,e);for(const s of e)t.fileCount+=1,t.totalBytes+=o.statSync(s).size;return t}function d(n,t){const e=y.createHash("sha256");let s=0;for(const c of n){const a=u.join(c,t);if(!o.existsSync(a))continue;const r=[];f(a,r),r.sort();for(const i of r)e.update(u.relative(a,i)),e.update("\0"),e.update(o.readFileSync(i)),s+=1}return s>0?e.digest("hex").slice(0,16):null}const h=1024;function T(n,t){if(!t||!o.existsSync(n))return 0;const e=t===!0||t.gzip!==!1,s=t===!0||t.brotli!==!1;if(!e&&!s)return 0;const c=[];f(n,c);let a=0;for(const r of c){const i=o.readFileSync(r);i.length<h||(e&&o.writeFileSync(`${r}.gz`,l.gzipSync(i,{level:9})),s&&o.writeFileSync(`${r}.br`,l.brotliCompressSync(i,{params:{[l.constants.BROTLI_PARAM_QUALITY]:11,[l.constants.BROTLI_PARAM_SIZE_HINT]:i.length}})),a+=1)}return a}exports.compressTranslationPayloads=T;exports.hashTranslationSources=d;exports.scanTranslationPayloadDirectory=S;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let u=require("node:path"),y=require("node:crypto"),s=require("node:fs"),c=require("node:zlib");function f(n,e){for(const t of(0,s.readdirSync)(n,{withFileTypes:!0})){const o=(0,u.join)(n,t.name);t.isDirectory()?f(o,e):t.name.endsWith(".json")&&e.push(o)}}function S(n){const e={fileCount:0,totalBytes:0};if(!(0,s.existsSync)(n))return e;const t=[];f(n,t);for(const o of t)e.fileCount+=1,e.totalBytes+=(0,s.statSync)(o).size;return e}function d(n,e){const t=(0,y.createHash)("sha256");let o=0;for(const a of n){const l=(0,u.join)(a,e);if(!(0,s.existsSync)(l))continue;const r=[];f(l,r),r.sort();for(const i of r)t.update((0,u.relative)(l,i)),t.update("\0"),t.update((0,s.readFileSync)(i)),o+=1}return o>0?t.digest("hex").slice(0,16):null}var h=1024;function T(n,e){if(!e||!(0,s.existsSync)(n))return 0;const t=e===!0||e.gzip!==!1,o=e===!0||e.brotli!==!1;if(!t&&!o)return 0;const a=[];f(n,a);let l=0;for(const r of a){const i=(0,s.readFileSync)(r);i.length<h||(t&&(0,s.writeFileSync)(`${r}.gz`,(0,c.gzipSync)(i,{level:9})),o&&(0,s.writeFileSync)(`${r}.br`,(0,c.brotliCompressSync)(i,{params:{[c.constants.BROTLI_PARAM_QUALITY]:11,[c.constants.BROTLI_PARAM_SIZE_HINT]:i.length}})),l+=1)}return l}exports.compressTranslationPayloads=T;exports.hashTranslationSources=d;exports.scanTranslationPayloadDirectory=S;
@@ -1,49 +1,52 @@
1
- import { createHash as p } from "node:crypto";
2
- import { existsSync as c, readFileSync as y, writeFileSync as a, statSync as S, readdirSync as m } from "node:fs";
3
- import { gzipSync as T, brotliCompressSync as d, constants as u } from "node:zlib";
4
- import { join as h, relative as _ } from "node:path";
1
+ import { join as y, relative as p } from "node:path";
2
+ import { createHash as S } from "node:crypto";
3
+ import { existsSync as a, readFileSync as h, readdirSync as m, statSync as T, writeFileSync as c } from "node:fs";
4
+ import { brotliCompressSync as d, constants as u, gzipSync as _ } from "node:zlib";
5
5
  function f(n, t) {
6
6
  for (const e of m(n, { withFileTypes: !0 })) {
7
- const o = h(n, e.name);
7
+ const o = y(n, e.name);
8
8
  e.isDirectory() ? f(o, t) : e.name.endsWith(".json") && t.push(o);
9
9
  }
10
10
  }
11
11
  function A(n) {
12
- const t = { fileCount: 0, totalBytes: 0 };
13
- if (!c(n)) return t;
12
+ const t = {
13
+ fileCount: 0,
14
+ totalBytes: 0
15
+ };
16
+ if (!a(n)) return t;
14
17
  const e = [];
15
18
  f(n, e);
16
19
  for (const o of e)
17
- t.fileCount += 1, t.totalBytes += S(o).size;
20
+ t.fileCount += 1, t.totalBytes += T(o).size;
18
21
  return t;
19
22
  }
20
23
  function B(n, t) {
21
- const e = p("sha256");
24
+ const e = S("sha256");
22
25
  let o = 0;
23
26
  for (const l of n) {
24
- const i = h(l, t);
25
- if (!c(i)) continue;
26
- const s = [];
27
- f(i, s), s.sort();
28
- for (const r of s)
29
- e.update(_(i, r)), e.update("\0"), e.update(y(r)), o += 1;
27
+ const i = y(l, t);
28
+ if (!a(i)) continue;
29
+ const r = [];
30
+ f(i, r), r.sort();
31
+ for (const s of r)
32
+ e.update(p(i, s)), e.update("\0"), e.update(h(s)), o += 1;
30
33
  }
31
34
  return o > 0 ? e.digest("hex").slice(0, 16) : null;
32
35
  }
33
- const g = 1024;
36
+ var g = 1024;
34
37
  function b(n, t) {
35
- if (!t || !c(n)) return 0;
38
+ if (!t || !a(n)) return 0;
36
39
  const e = t === !0 || t.gzip !== !1, o = t === !0 || t.brotli !== !1;
37
40
  if (!e && !o) return 0;
38
41
  const l = [];
39
42
  f(n, l);
40
43
  let i = 0;
41
- for (const s of l) {
42
- const r = y(s);
43
- r.length < g || (e && a(`${s}.gz`, T(r, { level: 9 })), o && a(
44
- `${s}.br`,
45
- d(r, { params: { [u.BROTLI_PARAM_QUALITY]: 11, [u.BROTLI_PARAM_SIZE_HINT]: r.length } })
46
- ), i += 1);
44
+ for (const r of l) {
45
+ const s = h(r);
46
+ s.length < g || (e && c(`${r}.gz`, _(s, { level: 9 })), o && c(`${r}.br`, d(s, { params: {
47
+ [u.BROTLI_PARAM_QUALITY]: 11,
48
+ [u.BROTLI_PARAM_SIZE_HINT]: s.length
49
+ } })), i += 1);
47
50
  }
48
51
  return i;
49
52
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(a,e){const l=a||"index";return e?.[l]??l}function t(a,e,l){return`/${a.replace(/^\/+|\/+$/g,"")}/${e}/${l}/data.json`.replace(/\/{2,}/g,"/")}function n(a){return(a.isServer?a.apiBaseServerHost:a.apiBaseClientHost)??a.baseURL}function o(a){const e=r(a.routeName,a.routesLocaleLinks);return{path:t(a.apiBaseUrl,e,a.locale),baseURL:n(a),params:a.dateBuild?{v:a.dateBuild}:void 0}}function s(a,e=!0){const l=Math.floor(a??0);return!Number.isSafeInteger(l)||l<=0?null:e?`public, max-age=${l}, immutable`:"public, max-age=0, must-revalidate"}exports.buildTranslationPayloadCacheControl=s;exports.buildTranslationPayloadFetchRequest=o;exports.buildTranslationPayloadPath=t;exports.resolveTranslationPayloadBaseURL=n;exports.resolveTranslationPayloadPage=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(a,l){const e=a||"index";return l?.[e]??e}function o(a,l,e){return`/${a.replace(/^\/+|\/+$/g,"")}/${l}/${e}/data.json`.replace(/\/{2,}/g,"/")}function t(a){return(a.isServer?a.apiBaseServerHost:a.apiBaseClientHost)??a.baseURL}function n(a){const l=r(a.routeName,a.routesLocaleLinks);return{path:o(a.apiBaseUrl,l,a.locale),baseURL:t(a),params:a.dateBuild?{v:a.dateBuild}:void 0}}function i(a,l=!0){const e=Math.floor(a??0);return!Number.isSafeInteger(e)||e<=0?null:l?`public, max-age=${e}, immutable`:"public, max-age=0, must-revalidate"}exports.buildTranslationPayloadCacheControl=i;exports.buildTranslationPayloadFetchRequest=n;exports.buildTranslationPayloadPath=o;exports.resolveTranslationPayloadBaseURL=t;exports.resolveTranslationPayloadPage=r;
@@ -1,29 +1,29 @@
1
- function l(a, e) {
2
- const r = a || "index";
3
- return e?.[r] ?? r;
1
+ function l(a, r) {
2
+ const e = a || "index";
3
+ return r?.[e] ?? e;
4
4
  }
5
- function n(a, e, r) {
6
- return `/${a.replace(/^\/+|\/+$/g, "")}/${e}/${r}/data.json`.replace(/\/{2,}/g, "/");
5
+ function t(a, r, e) {
6
+ return `/${a.replace(/^\/+|\/+$/g, "")}/${r}/${e}/data.json`.replace(/\/{2,}/g, "/");
7
7
  }
8
- function t(a) {
8
+ function n(a) {
9
9
  return (a.isServer ? a.apiBaseServerHost : a.apiBaseClientHost) ?? a.baseURL;
10
10
  }
11
- function s(a) {
12
- const e = l(a.routeName, a.routesLocaleLinks);
11
+ function o(a) {
12
+ const r = l(a.routeName, a.routesLocaleLinks);
13
13
  return {
14
- path: n(a.apiBaseUrl, e, a.locale),
15
- baseURL: t(a),
14
+ path: t(a.apiBaseUrl, r, a.locale),
15
+ baseURL: n(a),
16
16
  params: a.dateBuild ? { v: a.dateBuild } : void 0
17
17
  };
18
18
  }
19
- function i(a, e = !0) {
20
- const r = Math.floor(a ?? 0);
21
- return !Number.isSafeInteger(r) || r <= 0 ? null : e ? `public, max-age=${r}, immutable` : "public, max-age=0, must-revalidate";
19
+ function s(a, r = !0) {
20
+ const e = Math.floor(a ?? 0);
21
+ return !Number.isSafeInteger(e) || e <= 0 ? null : r ? `public, max-age=${e}, immutable` : "public, max-age=0, must-revalidate";
22
22
  }
23
23
  export {
24
- i as buildTranslationPayloadCacheControl,
25
- s as buildTranslationPayloadFetchRequest,
26
- n as buildTranslationPayloadPath,
27
- t as resolveTranslationPayloadBaseURL,
24
+ s as buildTranslationPayloadCacheControl,
25
+ o as buildTranslationPayloadFetchRequest,
26
+ t as buildTranslationPayloadPath,
27
+ n as resolveTranslationPayloadBaseURL,
28
28
  l as resolveTranslationPayloadPage
29
29
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(e){return e.iso?.trim()||String(e.code)}function u(e){const r=e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);return r?{language:r[1],region:r[2]}:{language:e}}function d(e,r={}){const{hreflangBaseLanguage:f=!1}=r;if(!f)return e.map(t=>{const o=String(t.code);return{hreflang:l(t),localeCode:o}});const s=new Map;for(const t of e){const o=String(t.code),a=l(t),{language:n,region:i}=u(a);n&&i&&!s.has(n)&&s.set(n,o),s.set(a,o)}const g=new Set,c=[];for(const t of e){const o=String(t.code),a=l(t),{language:n,region:i}=u(a);n&&i&&s.get(n)===o&&!g.has(n)&&(g.add(n),c.push({hreflang:n,localeCode:o})),g.has(a)||(g.add(a),c.push({hreflang:a,localeCode:o}))}return c}exports.resolveHreflangAlternates=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(e){return e.iso?.trim()||String(e.code)}function u(e){const r=e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);return r?{language:r[1],region:r[2]}:{language:e}}function d(e,r={}){const{hreflangBaseLanguage:f=!1}=r;if(!f)return e.map(t=>{const o=String(t.code);return{hreflang:i(t),localeCode:o}});const g=new Map;for(const t of e){const o=String(t.code),a=i(t),{language:n,region:l}=u(a);n&&l&&!g.has(n)&&g.set(n,o),g.set(a,o)}const c=new Set,s=[];for(const t of e){const o=String(t.code),a=i(t),{language:n,region:l}=u(a);n&&l&&g.get(n)===o&&!c.has(n)&&(c.add(n),s.push({hreflang:n,localeCode:o})),c.has(a)||(c.add(a),s.push({hreflang:a,localeCode:o}))}return s}exports.resolveHreflangAlternates=d;
@@ -3,26 +3,37 @@ function u(n) {
3
3
  }
4
4
  function f(n) {
5
5
  const r = n.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
6
- return r ? { language: r[1], region: r[2] } : { language: n };
6
+ return r ? {
7
+ language: r[1],
8
+ region: r[2]
9
+ } : { language: n };
7
10
  }
8
11
  function d(n, r = {}) {
9
12
  const { hreflangBaseLanguage: l = !1 } = r;
10
- if (!l)
11
- return n.map((o) => {
12
- const t = String(o.code);
13
- return { hreflang: u(o), localeCode: t };
14
- });
13
+ if (!l) return n.map((o) => {
14
+ const t = String(o.code);
15
+ return {
16
+ hreflang: u(o),
17
+ localeCode: t
18
+ };
19
+ });
15
20
  const g = /* @__PURE__ */ new Map();
16
21
  for (const o of n) {
17
22
  const t = String(o.code), a = u(o), { language: e, region: i } = f(a);
18
23
  e && i && !g.has(e) && g.set(e, t), g.set(a, t);
19
24
  }
20
- const s = /* @__PURE__ */ new Set(), c = [];
25
+ const c = /* @__PURE__ */ new Set(), s = [];
21
26
  for (const o of n) {
22
27
  const t = String(o.code), a = u(o), { language: e, region: i } = f(a);
23
- e && i && g.get(e) === t && !s.has(e) && (s.add(e), c.push({ hreflang: e, localeCode: t })), s.has(a) || (s.add(a), c.push({ hreflang: a, localeCode: t }));
28
+ e && i && g.get(e) === t && !c.has(e) && (c.add(e), s.push({
29
+ hreflang: e,
30
+ localeCode: t
31
+ })), c.has(a) || (c.add(a), s.push({
32
+ hreflang: a,
33
+ localeCode: t
34
+ }));
24
35
  }
25
- return c;
36
+ return s;
26
37
  }
27
38
  export {
28
39
  d as resolveHreflangAlternates
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./accept-language.cjs");function d(i){const{defaultLocale:n,validLocales:e,autoDetectLanguage:s,hasLocaleInUrl:c,urlLocale:l,queryLocale:t,cookieLocale:r,acceptLanguageHeader:o}=i;let a=n,u=!1;return c&&l&&e.includes(l)?(a=l,u=!0):t&&e.includes(t)?(a=t,u=!0):r&&e.includes(r)&&(a=r,u=!0),L.applyAutoDetectLanguage(a,u,s,o??void 0,e)}function f(i){const{defaultLocale:n,validLocales:e,autoDetectLanguage:s,stateLocale:c,cookieLocale:l,acceptLanguageHeader:t,ignoreStateLocale:r=!1}=i;let o=n,a=!1;return!r&&c&&e.includes(c)?(o=c,a=!0):l&&e.includes(l)&&(o=l,a=!0),L.applyAutoDetectLanguage(o,a,s,t??void 0,e)}exports.resolvePreferredLocale=f;exports.resolveServerLocale=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./accept-language.cjs");function d(i){const{defaultLocale:n,validLocales:e,autoDetectLanguage:s,hasLocaleInUrl:c,urlLocale:l,queryLocale:r,cookieLocale:t,acceptLanguageHeader:o}=i;let a=n,u=!1;return c&&l&&e.includes(l)?(a=l,u=!0):r&&e.includes(r)?(a=r,u=!0):t&&e.includes(t)&&(a=t,u=!0),L.applyAutoDetectLanguage(a,u,s,o??void 0,e)}function f(i){const{defaultLocale:n,validLocales:e,autoDetectLanguage:s,stateLocale:c,cookieLocale:l,acceptLanguageHeader:r,ignoreStateLocale:t=!1}=i;let o=n,a=!1;return!t&&c&&e.includes(c)?(o=c,a=!0):l&&e.includes(l)&&(o=l,a=!0),L.applyAutoDetectLanguage(o,a,s,r??void 0,e)}exports.resolvePreferredLocale=f;exports.resolveServerLocale=d;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(n){const t=n.og?.trim();if(t)return t;const e=n.iso?.trim();if(!e)return null;const r=e.indexOf("_");if(r>0){const s=e.slice(0,r),o=e.slice(r+1);if(s.length>=2&&o.length===2)return`${s.toLowerCase()}_${o.toUpperCase()}`}const i=e.indexOf("-");if(i>0){const s=e.slice(0,i),o=e.slice(i+1);if(s.length>=2&&o.length===2&&/^[A-Za-z]{2}$/.test(o))return`${s.toLowerCase()}_${o.toUpperCase()}`}return null}function l(n,t={}){if(c(n)!==null||t.missingWarn===!1||process.env.NODE_ENV==="production")return;const e=t.tag??"og:locale",r=String(n.code??"unknown"),i=n.iso?`, iso: '${n.iso}'`:"";console.warn(`[i18n] Cannot derive ${e} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`)}exports.resolveOgLocale=c;exports.warnUnresolvedOgLocale=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(n){const t=n.og?.trim();if(t)return t;const e=n.iso?.trim();if(!e)return null;const r=e.indexOf("_");if(r>0){const s=e.slice(0,r),o=e.slice(r+1);if(s.length>=2&&o.length===2)return`${s.toLowerCase()}_${o.toUpperCase()}`}const i=e.indexOf("-");if(i>0){const s=e.slice(0,i),o=e.slice(i+1);if(s.length>=2&&o.length===2&&/^[A-Za-z]{2}$/.test(o))return`${s.toLowerCase()}_${o.toUpperCase()}`}return null}function c(n,t={}){if(l(n)!==null||t.missingWarn===!1||process.env.NODE_ENV==="production")return;const e=t.tag??"og:locale",r=String(n.code??"unknown"),i=n.iso?`, iso: '${n.iso}'`:"";console.warn(`[i18n] Cannot derive ${e} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`)}exports.resolveOgLocale=l;exports.warnUnresolvedOgLocale=c;
@@ -6,23 +6,19 @@ function c(n) {
6
6
  const r = e.indexOf("_");
7
7
  if (r > 0) {
8
8
  const s = e.slice(0, r), o = e.slice(r + 1);
9
- if (s.length >= 2 && o.length === 2)
10
- return `${s.toLowerCase()}_${o.toUpperCase()}`;
9
+ if (s.length >= 2 && o.length === 2) return `${s.toLowerCase()}_${o.toUpperCase()}`;
11
10
  }
12
11
  const i = e.indexOf("-");
13
12
  if (i > 0) {
14
13
  const s = e.slice(0, i), o = e.slice(i + 1);
15
- if (s.length >= 2 && o.length === 2 && /^[A-Za-z]{2}$/.test(o))
16
- return `${s.toLowerCase()}_${o.toUpperCase()}`;
14
+ if (s.length >= 2 && o.length === 2 && /^[A-Za-z]{2}$/.test(o)) return `${s.toLowerCase()}_${o.toUpperCase()}`;
17
15
  }
18
16
  return null;
19
17
  }
20
18
  function l(n, t = {}) {
21
19
  if (c(n) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
22
20
  const e = t.tag ?? "og:locale", r = String(n.code ?? "unknown"), i = n.iso ? `, iso: '${n.iso}'` : "";
23
- console.warn(
24
- `[i18n] Cannot derive ${e} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
25
- );
21
+ console.warn(`[i18n] Cannot derive ${e} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`);
26
22
  }
27
23
  export {
28
24
  c as resolveOgLocale,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(e){return e.replace(/\/:locale\([^)]+\)/g,"").replace(/\/:([^()]+)\(\)/g,"/[$1]").replace(/\/:([^()]+)/g,"/[$1]")}function i(e,r="localized-"){if(!e)return;const t=e.replace(r,"");return t.length>0?t:void 0}function o(e){return e?`/${e}`:void 0}function n(e){return e.replace(/^\//,"")}exports.extractBaseRoutePattern=a;exports.routeNameToPath=o;exports.stripLeadingSlash=n;exports.stripLocalizedRouteNamePrefix=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(e){return e.replace(/\/:locale\([^)]+\)/g,"").replace(/\/:([^()]+)\(\)/g,"/[$1]").replace(/\/:([^()]+)/g,"/[$1]")}function o(e,r="localized-"){if(!e)return;const t=e.replace(r,"");return t.length>0?t:void 0}function i(e){return e?`/${e}`:void 0}function n(e){return e.replace(/^\//,"")}exports.extractBaseRoutePattern=a;exports.routeNameToPath=i;exports.stripLeadingSlash=n;exports.stripLocalizedRouteNamePrefix=o;
package/dist/route.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./route-pattern.cjs");function u(e,t,h="localized-",d){const f=e.path,o=e.name?.toString(),r=a.stripLocalizedRouteNamePrefix(o,h),s=a.routeNameToPath(r);let i=o&&t?.[o]||r&&t?.[r]||s&&t?.[s]||s&&t?.[a.stripLeadingSlash(s)]||t?.[f]||f&&t?.[a.stripLeadingSlash(f)];if(!i&&t&&d?.length){const n=f.split("/").filter(Boolean),c=n[0];if(c&&d.includes(c)&&n.length>1){const l=`/${n.slice(1).join("/")}`,m=l==="/"?"/":a.stripLeadingSlash(l);i=t[l]??t[m]??void 0}}if(!i&&e.matched&&e.matched.length>0){const n=e.matched[0];if(!n)return null;const c=a.extractBaseRoutePattern(n.path);t?.[c]&&(i=t[c])}return i||null}function R(e,t,h,d="localized-"){if(!t)return!1;const f=e.path,o=e.name?.toString(),r=a.stripLocalizedRouteNamePrefix(o,d),s=a.routeNameToPath(r),i=n=>n===void 0?!1:typeof n=="boolean"?n:Array.isArray(n)&&h?n.includes(h):!1;if(i(t[f])||o&&i(t[o])||r&&i(t[r])||s&&i(t[s]))return!0;if(e.matched&&e.matched.length>0){const n=e.matched[0];if(!n)return!1;const c=a.extractBaseRoutePattern(n.path);if(i(t[c]))return!0}return!1}exports.findAllowedLocalesForRoute=u;exports.isMetaDisabledForRoute=R;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./route-pattern.cjs");function u(e,t,h="localized-",d){const s=e.path,r=e.name?.toString(),o=a.stripLocalizedRouteNamePrefix(r,h),c=a.routeNameToPath(o);let i=r&&t?.[r]||o&&t?.[o]||c&&t?.[c]||c&&t?.[a.stripLeadingSlash(c)]||t?.[s]||s&&t?.[a.stripLeadingSlash(s)];if(!i&&t&&d?.length){const n=s.split("/").filter(Boolean),f=n[0];if(f&&d.includes(f)&&n.length>1){const l=`/${n.slice(1).join("/")}`,m=l==="/"?"/":a.stripLeadingSlash(l);i=t[l]??t[m]??void 0}}if(!i&&e.matched&&e.matched.length>0){const n=e.matched[0];if(!n)return null;const f=a.extractBaseRoutePattern(n.path);t?.[f]&&(i=t[f])}return i||null}function p(e,t,h,d="localized-"){if(!t)return!1;const s=e.path,r=e.name?.toString(),o=a.stripLocalizedRouteNamePrefix(r,d),c=a.routeNameToPath(o),i=n=>n===void 0?!1:typeof n=="boolean"?n:Array.isArray(n)&&h?n.includes(h):!1;if(i(t[s])||r&&i(t[r])||o&&i(t[o])||c&&i(t[c]))return!0;if(e.matched&&e.matched.length>0){const n=e.matched[0];if(!n)return!1;if(i(t[a.extractBaseRoutePattern(n.path)]))return!0}return!1}exports.findAllowedLocalesForRoute=u;exports.isMetaDisabledForRoute=p;
package/dist/route.mjs CHANGED
@@ -1,38 +1,34 @@
1
- import { stripLocalizedRouteNamePrefix as l, stripLeadingSlash as d, extractBaseRoutePattern as p, routeNameToPath as R } from "./route-pattern.mjs";
2
- function g(e, t, h = "localized-", m) {
3
- const c = e.path, o = e.name?.toString(), r = l(o, h), a = R(r);
4
- let i = o && t?.[o] || r && t?.[r] || a && t?.[a] || a && t?.[d(a)] || t?.[c] || c && t?.[d(c)];
5
- if (!i && t && m?.length) {
6
- const n = c.split("/").filter(Boolean), f = n[0];
7
- if (f && m.includes(f) && n.length > 1) {
8
- const s = `/${n.slice(1).join("/")}`, u = s === "/" ? "/" : d(s);
9
- i = t[s] ?? t[u] ?? void 0;
1
+ import { extractBaseRoutePattern as l, routeNameToPath as p, stripLeadingSlash as d, stripLocalizedRouteNamePrefix as R } from "./route-pattern.mjs";
2
+ function P(i, t, c = "localized-", m) {
3
+ const h = i.path, f = i.name?.toString(), o = R(f, c), r = p(o);
4
+ let e = f && t?.[f] || o && t?.[o] || r && t?.[r] || r && t?.[d(r)] || t?.[h] || h && t?.[d(h)];
5
+ if (!e && t && m?.length) {
6
+ const n = h.split("/").filter(Boolean), a = n[0];
7
+ if (a && m.includes(a) && n.length > 1) {
8
+ const s = `/${n.slice(1).join("/")}`, g = s === "/" ? "/" : d(s);
9
+ e = t[s] ?? t[g] ?? void 0;
10
10
  }
11
11
  }
12
- if (!i && e.matched && e.matched.length > 0) {
13
- const n = e.matched[0];
12
+ if (!e && i.matched && i.matched.length > 0) {
13
+ const n = i.matched[0];
14
14
  if (!n) return null;
15
- const f = p(n.path);
16
- t?.[f] && (i = t[f]);
15
+ const a = l(n.path);
16
+ t?.[a] && (e = t[a]);
17
17
  }
18
- return i || null;
18
+ return e || null;
19
19
  }
20
- function z(e, t, h, m = "localized-") {
21
- if (!t)
22
- return !1;
23
- const c = e.path, o = e.name?.toString(), r = l(o, m), a = R(r), i = (n) => n === void 0 ? !1 : typeof n == "boolean" ? n : Array.isArray(n) && h ? n.includes(h) : !1;
24
- if (i(t[c]) || o && i(t[o]) || r && i(t[r]) || a && i(t[a]))
25
- return !0;
26
- if (e.matched && e.matched.length > 0) {
27
- const n = e.matched[0];
20
+ function z(i, t, c, m = "localized-") {
21
+ if (!t) return !1;
22
+ const h = i.path, f = i.name?.toString(), o = R(f, m), r = p(o), e = (n) => n === void 0 ? !1 : typeof n == "boolean" ? n : Array.isArray(n) && c ? n.includes(c) : !1;
23
+ if (e(t[h]) || f && e(t[f]) || o && e(t[o]) || r && e(t[r])) return !0;
24
+ if (i.matched && i.matched.length > 0) {
25
+ const n = i.matched[0];
28
26
  if (!n) return !1;
29
- const f = p(n.path);
30
- if (i(t[f]))
31
- return !0;
27
+ if (e(t[l(n.path)])) return !0;
32
28
  }
33
29
  return !1;
34
30
  }
35
31
  export {
36
- g as findAllowedLocalesForRoute,
32
+ P as findAllowedLocalesForRoute,
37
33
  z as isMetaDisabledForRoute
38
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function L(e){if(Array.isArray(e)){const t=e.map(l=>o(l)).filter(l=>!!l);return t.length>0?t:void 0}if(typeof e=="string"){const t=e.split(",").map(l=>l.trim()).filter(l=>l.length>0);return t.length>0?t:void 0}}function m(){return{defaultLocale:o(process.env.NUXT_I18N_DEFAULT_LOCALE)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_DEFAULT_LOCALE),fallbackLocale:o(process.env.NUXT_I18N_FALLBACK_LOCALE)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_FALLBACK_LOCALE),disabledLocales:L(process.env.NUXT_I18N_DISABLED_LOCALES)??L(process.env.NUXT_PUBLIC_I18N_RUNTIME_DISABLED_LOCALES),strategy:o(process.env.NUXT_I18N_STRATEGY)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_STRATEGY)}}function g(e){const t=e?.i18nRuntime;if(!t||typeof t!="object")return{};const l=t;return{defaultLocale:o(l.defaultLocale),fallbackLocale:o(l.fallbackLocale),disabledLocales:L(l.disabledLocales),strategy:o(l.strategy)}}function v(e){return Object.assign({},e)}function b(e){return e.map(t=>v(t))}function y(e){const t=m(),l=g(e);return{defaultLocale:l.defaultLocale??t.defaultLocale,fallbackLocale:l.fallbackLocale??t.fallbackLocale,disabledLocales:l.disabledLocales??t.disabledLocales,strategy:l.strategy??t.strategy}}function p(e,t,l=a=>console.warn(a)){const a=y(t),n=b(e.locales??[]);if(a.strategy&&a.strategy!==e.strategy&&l(`[nuxt-i18n-micro] runtime i18n strategy override is ignored: "${a.strategy}" (build strategy: "${e.strategy}"). Build a separate artifact for each strategy.`),a.disabledLocales&&a.disabledLocales.length>0){const r=new Set(a.disabledLocales);for(const u of n)u.disabled=r.has(u.code)}const i=n.filter(r=>!r.disabled);if(i.length===0)return a.disabledLocales&&a.disabledLocales.length>0&&l("[nuxt-i18n-micro] runtime disabledLocales override would disable all locales; override ignored."),{...e,locales:b(e.locales??[])};const _=new Set(n.map(r=>r.code));let c=a.defaultLocale??e.defaultLocale,s=a.fallbackLocale??e.fallbackLocale;s&&!_.has(s)&&(l(`[nuxt-i18n-micro] runtime fallbackLocale "${s}" is not defined in locales; override ignored.`),s=e.fallbackLocale);const f=new Set(i.map(r=>r.code)),d=i[0]?.code??e.defaultLocale??"en";return(!c||!f.has(c))&&(a.defaultLocale?l(`[nuxt-i18n-micro] runtime defaultLocale "${a.defaultLocale}" is not enabled; falling back to "${d}".`):c&&!f.has(c)&&l(`[nuxt-i18n-micro] defaultLocale "${c}" is disabled by runtime overrides; falling back to "${d}".`),c=d),{...e,locales:n,defaultLocale:c,fallbackLocale:s}}exports.resolveI18nConfigWithRuntimeOverrides=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function L(e){if(Array.isArray(e)){const t=e.map(l=>o(l)).filter(l=>!!l);return t.length>0?t:void 0}if(typeof e=="string"){const t=e.split(",").map(l=>l.trim()).filter(l=>l.length>0);return t.length>0?t:void 0}}function m(){return{defaultLocale:o(process.env.NUXT_I18N_DEFAULT_LOCALE)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_DEFAULT_LOCALE),fallbackLocale:o(process.env.NUXT_I18N_FALLBACK_LOCALE)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_FALLBACK_LOCALE),disabledLocales:L(process.env.NUXT_I18N_DISABLED_LOCALES)??L(process.env.NUXT_PUBLIC_I18N_RUNTIME_DISABLED_LOCALES),strategy:o(process.env.NUXT_I18N_STRATEGY)??o(process.env.NUXT_PUBLIC_I18N_RUNTIME_STRATEGY)}}function g(e){const t=e?.i18nRuntime;if(!t||typeof t!="object")return{};const l=t;return{defaultLocale:o(l.defaultLocale),fallbackLocale:o(l.fallbackLocale),disabledLocales:L(l.disabledLocales),strategy:o(l.strategy)}}function v(e){return Object.assign({},e)}function b(e){return e.map(t=>v(t))}function y(e){const t=m(),l=g(e);return{defaultLocale:l.defaultLocale??t.defaultLocale,fallbackLocale:l.fallbackLocale??t.fallbackLocale,disabledLocales:l.disabledLocales??t.disabledLocales,strategy:l.strategy??t.strategy}}function p(e,t,l=a=>console.warn(a)){const a=y(t),n=b(e.locales??[]);if(a.strategy&&a.strategy!==e.strategy&&l(`[nuxt-i18n-micro] runtime i18n strategy override is ignored: "${a.strategy}" (build strategy: "${e.strategy}"). Build a separate artifact for each strategy.`),a.disabledLocales&&a.disabledLocales.length>0){const r=new Set(a.disabledLocales);for(const u of n)u.disabled=r.has(u.code)}const i=n.filter(r=>!r.disabled);if(i.length===0)return a.disabledLocales&&a.disabledLocales.length>0&&l("[nuxt-i18n-micro] runtime disabledLocales override would disable all locales; override ignored."),{...e,locales:b(e.locales??[])};const _=new Set(n.map(r=>r.code));let c=a.defaultLocale??e.defaultLocale,s=a.fallbackLocale??e.fallbackLocale;s&&!_.has(s)&&(l(`[nuxt-i18n-micro] runtime fallbackLocale "${s}" is not defined in locales; override ignored.`),s=e.fallbackLocale);const f=new Set(i.map(r=>r.code)),d=i[0]?.code??e.defaultLocale??"en";return(!c||!f.has(c))&&(a.defaultLocale?l(`[nuxt-i18n-micro] runtime defaultLocale "${a.defaultLocale}" is not enabled; falling back to "${d}".`):c&&!f.has(c)&&l(`[nuxt-i18n-micro] defaultLocale "${c}" is disabled by runtime overrides; falling back to "${d}".`),c=d),{...e,locales:n,defaultLocale:c,fallbackLocale:s}}exports.resolveI18nConfigWithRuntimeOverrides=p;
@@ -32,13 +32,13 @@ function g(e) {
32
32
  strategy: o(l.strategy)
33
33
  };
34
34
  }
35
- function v(e) {
35
+ function p(e) {
36
36
  return Object.assign({}, e);
37
37
  }
38
38
  function _(e) {
39
- return e.map((a) => v(a));
39
+ return e.map((a) => p(a));
40
40
  }
41
- function p(e) {
41
+ function v(e) {
42
42
  const a = m(), l = g(e);
43
43
  return {
44
44
  defaultLocale: l.defaultLocale ?? a.defaultLocale,
@@ -48,26 +48,26 @@ function p(e) {
48
48
  };
49
49
  }
50
50
  function y(e, a, l = (t) => console.warn(t)) {
51
- const t = p(a), n = _(e.locales ?? []);
52
- if (t.strategy && t.strategy !== e.strategy && l(
53
- `[nuxt-i18n-micro] runtime i18n strategy override is ignored: "${t.strategy}" (build strategy: "${e.strategy}"). Build a separate artifact for each strategy.`
54
- ), t.disabledLocales && t.disabledLocales.length > 0) {
55
- const r = new Set(t.disabledLocales);
56
- for (const u of n)
57
- u.disabled = r.has(u.code);
51
+ const t = v(a), n = _(e.locales ?? []);
52
+ if (t.strategy && t.strategy !== e.strategy && l(`[nuxt-i18n-micro] runtime i18n strategy override is ignored: "${t.strategy}" (build strategy: "${e.strategy}"). Build a separate artifact for each strategy.`), t.disabledLocales && t.disabledLocales.length > 0) {
53
+ const s = new Set(t.disabledLocales);
54
+ for (const u of n) u.disabled = s.has(u.code);
58
55
  }
59
- const i = n.filter((r) => !r.disabled);
56
+ const i = n.filter((s) => !s.disabled);
60
57
  if (i.length === 0)
61
- return t.disabledLocales && t.disabledLocales.length > 0 && l("[nuxt-i18n-micro] runtime disabledLocales override would disable all locales; override ignored."), { ...e, locales: _(e.locales ?? []) };
62
- const b = new Set(n.map((r) => r.code));
63
- let c = t.defaultLocale ?? e.defaultLocale, s = t.fallbackLocale ?? e.fallbackLocale;
64
- s && !b.has(s) && (l(`[nuxt-i18n-micro] runtime fallbackLocale "${s}" is not defined in locales; override ignored.`), s = e.fallbackLocale);
65
- const f = new Set(i.map((r) => r.code)), d = i[0]?.code ?? e.defaultLocale ?? "en";
58
+ return t.disabledLocales && t.disabledLocales.length > 0 && l("[nuxt-i18n-micro] runtime disabledLocales override would disable all locales; override ignored."), {
59
+ ...e,
60
+ locales: _(e.locales ?? [])
61
+ };
62
+ const b = new Set(n.map((s) => s.code));
63
+ let c = t.defaultLocale ?? e.defaultLocale, r = t.fallbackLocale ?? e.fallbackLocale;
64
+ r && !b.has(r) && (l(`[nuxt-i18n-micro] runtime fallbackLocale "${r}" is not defined in locales; override ignored.`), r = e.fallbackLocale);
65
+ const f = new Set(i.map((s) => s.code)), d = i[0]?.code ?? e.defaultLocale ?? "en";
66
66
  return (!c || !f.has(c)) && (t.defaultLocale ? l(`[nuxt-i18n-micro] runtime defaultLocale "${t.defaultLocale}" is not enabled; falling back to "${d}".`) : c && !f.has(c) && l(`[nuxt-i18n-micro] defaultLocale "${c}" is disabled by runtime overrides; falling back to "${d}".`), c = d), {
67
67
  ...e,
68
68
  locales: n,
69
69
  defaultLocale: c,
70
- fallbackLocale: s
70
+ fallbackLocale: r
71
71
  };
72
72
  }
73
73
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./merge-source.cjs"),n=require("./normalize.cjs");async function c(r,o){return e.mergeSourceTranslations({...o,readLocaleFile:async t=>{const a=await r.getItem(e.toSourceStorageKey(t));return n.toTranslationRecord(a)}})}exports.loadSourceTranslationsFromStorage=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./merge-source.cjs"),n=require("./normalize.cjs");async function c(r,o){return e.mergeSourceTranslations({...o,readLocaleFile:async a=>{const t=await r.getItem(e.toSourceStorageKey(a));return n.toTranslationRecord(t)}})}exports.loadSourceTranslationsFromStorage=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(s){const o=[],n={},r=new Set;for(const t of s){const e=t.name?.trim();if(!e)throw new Error("[splitLocaleRoutes] each entry needs a non-empty `name`");if(!t.path)throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`path\``);if(!t.file)throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`file\``);if(r.has(e))throw new Error(`[splitLocaleRoutes] duplicate route name "${e}"`);r.add(e),o.push({name:e,path:t.path,file:t.file}),t.paths!==void 0&&(n[e]=t.paths)}return{pages:o,globalLocaleRoutes:n}}exports.splitLocaleRoutes=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(r){const o=[],n={},a=new Set;for(const t of r){const e=t.name?.trim();if(!e)throw new Error("[splitLocaleRoutes] each entry needs a non-empty `name`");if(!t.path)throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`path\``);if(!t.file)throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`file\``);if(a.has(e))throw new Error(`[splitLocaleRoutes] duplicate route name "${e}"`);a.add(e),o.push({name:e,path:t.path,file:t.file}),t.paths!==void 0&&(n[e]=t.paths)}return{pages:o,globalLocaleRoutes:n}}exports.splitLocaleRoutes=s;
@@ -2,17 +2,20 @@ function s(a) {
2
2
  const o = [], n = {}, r = /* @__PURE__ */ new Set();
3
3
  for (const t of a) {
4
4
  const e = t.name?.trim();
5
- if (!e)
6
- throw new Error("[splitLocaleRoutes] each entry needs a non-empty `name`");
7
- if (!t.path)
8
- throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`path\``);
9
- if (!t.file)
10
- throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`file\``);
11
- if (r.has(e))
12
- throw new Error(`[splitLocaleRoutes] duplicate route name "${e}"`);
13
- r.add(e), o.push({ name: e, path: t.path, file: t.file }), t.paths !== void 0 && (n[e] = t.paths);
5
+ if (!e) throw new Error("[splitLocaleRoutes] each entry needs a non-empty `name`");
6
+ if (!t.path) throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`path\``);
7
+ if (!t.file) throw new Error(`[splitLocaleRoutes] entry "${e}" needs a \`file\``);
8
+ if (r.has(e)) throw new Error(`[splitLocaleRoutes] duplicate route name "${e}"`);
9
+ r.add(e), o.push({
10
+ name: e,
11
+ path: t.path,
12
+ file: t.file
13
+ }), t.paths !== void 0 && (n[e] = t.paths);
14
14
  }
15
- return { pages: o, globalLocaleRoutes: n };
15
+ return {
16
+ pages: o,
17
+ globalLocaleRoutes: n
18
+ };
16
19
  }
17
20
  export {
18
21
  s as splitLocaleRoutes