@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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){return e?e.split(",").map(t=>{const[n]=t.split(";");return(n??"").trim()}).filter(t=>t.length>0):[]}function g(e,t){const n=c(e);for(const r of n){const a=r.toLowerCase(),s=a.split("-")[0],o=t.find(u=>u.toLowerCase()===a||u.toLowerCase()===s);if(o)return o}return null}function i(e,t,n,r,a){return!n||t?e:g(r,a)??e}exports.applyAutoDetectLanguage=i;exports.detectLocaleFromAcceptLanguage=g;exports.parseAcceptLanguage=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){return e?e.split(",").map(t=>{const[n]=t.split(";");return(n??"").trim()}).filter(t=>t.length>0):[]}function g(e,t){const n=c(e);for(const r of n){const a=r.toLowerCase(),p=a.split("-")[0],o=t.find(u=>u.toLowerCase()===a||u.toLowerCase()===p);if(o)return o}return null}function s(e,t,n,r,a){return!n||t?e:g(r,a)??e}exports.applyAutoDetectLanguage=s;exports.detectLocaleFromAcceptLanguage=g;exports.parseAcceptLanguage=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(e){return(e??[]).filter(o=>!o.disabled)}function t(e){return l(e).map(o=>o.code)}function a(e,o){return l(e).some(n=>n.code===o)}exports.getEnabledLocaleCodes=t;exports.getEnabledLocales=l;exports.isEnabledLocale=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(e){return(e??[]).filter(o=>!o.disabled)}function a(e){return l(e).map(o=>o.code)}function t(e,o){return l(e).some(n=>n.code===o)}exports.getEnabledLocaleCodes=a;exports.getEnabledLocales=l;exports.isEnabledLocale=t;
package/dist/app-path.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t,i){if(!i||i==="/")return t;const r=i.endsWith("/")?i.slice(0,-1):i;return!r||r==="/"?t:t===r||t===`${r}/`?"/":t.startsWith(`${r}/`)?t.slice(r.length)||"/":t}exports.withoutAppBaseURL=e;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(t,r){if(!r||r==="/")return t;const n=r.endsWith("/")?r.slice(0,-1):r;return!n||n==="/"?t:t===n||t===`${n}/`?"/":t.startsWith(`${n}/`)?t.slice(n.length)||"/":t}var f=/\.(xml|txt|ico|json|js|css|png|jpg|jpeg|gif|svg|webp|avif|pdf|wasm|map|mp4|webm|mp3|zip|gz|woff|woff2|ttf|eot)$/i;function i(t){if(!t||t.endsWith(".html")||t.endsWith(".htm"))return!1;const r=t.split("/").filter(Boolean).pop()??"";return f.test(r)}var l=["/api","/_nuxt","/_locales"],u=[/^\/sitemap.*\.xml$/,/^\/sitemap\.xml$/,/^\/robots\.txt$/,/^\/favicon\.ico$/,/^\/apple-touch-icon.*\.png$/,/^\/manifest\.json$/,/^\/sw\.js$/,/^\/workbox-.*\.js$/];function c(t,r){for(const e of l)if(t===e||t.startsWith(`${e}/`))return!0;if(/(?:^|\/)__/.test(t))return!0;const n=t.length>1?t.replace(/\/+$/,""):t;for(const e of u)if(e.test(n))return!0;if(i(t))return!0;if(r){for(const e of r)if(typeof e=="string"){if(e.includes("*")||e.includes("?")){if(new RegExp(e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")).test(t))return!0}else if(t===e||t.startsWith(e))return!0}else if(e instanceof RegExp){e.lastIndex=0;const s=e.test(t);if(e.lastIndex=0,s)return!0}}return!1}function a(t){const r=t.replace(/\\/g,"/").replace(/^\/+/,"");if(!r||r.includes("\0"))return null;const n=[];for(const e of r.split("/"))if(!(!e||e===".")){if(e===".."){if(n.length===0)return null;n.pop();continue}n.push(e)}return n.length===0?null:n.join("/")}exports.isInternalPath=c;exports.isStaticAssetPathname=i;exports.resolveContainedRelPath=a;exports.withoutAppBaseURL=o;
@@ -3,3 +3,15 @@
3
3
  * `getRequestURL(event).pathname` includes baseURL; Vue Router paths do not.
4
4
  */
5
5
  export declare function withoutAppBaseURL(pathname: string, baseURL?: string | null): string;
6
+ export declare function isStaticAssetPathname(pathname: string): boolean;
7
+ /**
8
+ * True for Nuxt/i18n internals, Content `__` routes, and static assets that must
9
+ * skip locale detection / redirects. Lives in utils so client middleware can import
10
+ * it without pulling `@nuxt/schema` (via route-strategy) into the browser bundle.
11
+ */
12
+ export declare function isInternalPath(path: string, excludePatterns?: (string | RegExp | object)[]): boolean;
13
+ /**
14
+ * Normalize a payload-relative path and reject any walk out of the payload root.
15
+ * Callers must use the returned string (or skip the read when this returns `null`).
16
+ */
17
+ export declare function resolveContainedRelPath(relPath: string): string | null;
@@ -3,3 +3,15 @@
3
3
  * `getRequestURL(event).pathname` includes baseURL; Vue Router paths do not.
4
4
  */
5
5
  export declare function withoutAppBaseURL(pathname: string, baseURL?: string | null): string;
6
+ export declare function isStaticAssetPathname(pathname: string): boolean;
7
+ /**
8
+ * True for Nuxt/i18n internals, Content `__` routes, and static assets that must
9
+ * skip locale detection / redirects. Lives in utils so client middleware can import
10
+ * it without pulling `@nuxt/schema` (via route-strategy) into the browser bundle.
11
+ */
12
+ export declare function isInternalPath(path: string, excludePatterns?: (string | RegExp | object)[]): boolean;
13
+ /**
14
+ * Normalize a payload-relative path and reject any walk out of the payload root.
15
+ * Callers must use the returned string (or skip the read when this returns `null`).
16
+ */
17
+ export declare function resolveContainedRelPath(relPath: string): string | null;
package/dist/app-path.mjs CHANGED
@@ -1,8 +1,65 @@
1
- function u(r, t) {
2
- if (!t || t === "/") return r;
3
- const i = t.endsWith("/") ? t.slice(0, -1) : t;
4
- return !i || i === "/" ? r : r === i || r === `${i}/` ? "/" : r.startsWith(`${i}/`) ? r.slice(i.length) || "/" : r;
1
+ function u(t, r) {
2
+ if (!r || r === "/") return t;
3
+ const n = r.endsWith("/") ? r.slice(0, -1) : r;
4
+ return !n || n === "/" ? t : t === n || t === `${n}/` ? "/" : t.startsWith(`${n}/`) ? t.slice(n.length) || "/" : t;
5
+ }
6
+ var s = /\.(xml|txt|ico|json|js|css|png|jpg|jpeg|gif|svg|webp|avif|pdf|wasm|map|mp4|webm|mp3|zip|gz|woff|woff2|ttf|eot)$/i;
7
+ function o(t) {
8
+ if (!t || t.endsWith(".html") || t.endsWith(".htm")) return !1;
9
+ const r = t.split("/").filter(Boolean).pop() ?? "";
10
+ return s.test(r);
11
+ }
12
+ var f = [
13
+ "/api",
14
+ "/_nuxt",
15
+ "/_locales"
16
+ ], l = [
17
+ /^\/sitemap.*\.xml$/,
18
+ /^\/sitemap\.xml$/,
19
+ /^\/robots\.txt$/,
20
+ /^\/favicon\.ico$/,
21
+ /^\/apple-touch-icon.*\.png$/,
22
+ /^\/manifest\.json$/,
23
+ /^\/sw\.js$/,
24
+ /^\/workbox-.*\.js$/
25
+ ];
26
+ function c(t, r) {
27
+ for (const e of f) if (t === e || t.startsWith(`${e}/`)) return !0;
28
+ if (/(?:^|\/)__/.test(t)) return !0;
29
+ const n = t.length > 1 ? t.replace(/\/+$/, "") : t;
30
+ for (const e of l) if (e.test(n)) return !0;
31
+ if (o(t)) return !0;
32
+ if (r) {
33
+ for (const e of r) if (typeof e == "string") {
34
+ if (e.includes("*") || e.includes("?")) {
35
+ if (new RegExp(e.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".")).test(t)) return !0;
36
+ } else if (t === e || t.startsWith(e)) return !0;
37
+ } else if (e instanceof RegExp) {
38
+ e.lastIndex = 0;
39
+ const i = e.test(t);
40
+ if (e.lastIndex = 0, i) return !0;
41
+ }
42
+ }
43
+ return !1;
44
+ }
45
+ function p(t) {
46
+ const r = t.replace(/\\/g, "/").replace(/^\/+/, "");
47
+ if (!r || r.includes("\0")) return null;
48
+ const n = [];
49
+ for (const e of r.split("/"))
50
+ if (!(!e || e === ".")) {
51
+ if (e === "..") {
52
+ if (n.length === 0) return null;
53
+ n.pop();
54
+ continue;
55
+ }
56
+ n.push(e);
57
+ }
58
+ return n.length === 0 ? null : n.join("/");
5
59
  }
6
60
  export {
61
+ c as isInternalPath,
62
+ o as isStaticAssetPathname,
63
+ p as resolveContainedRelPath,
7
64
  u as withoutAppBaseURL
8
65
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(e,o={}){const t=o.autoDetectPath??"/",r=!e||e===""?"/":e;if(t==="*")return!0;if(t==="no_prefix")return!o.hasLocalePrefix;if(t==="/"||t==="")return r==="/";const c=t.startsWith("/")?t:`/${t}`;return r===c||r===`${c}/`}exports.shouldAttemptLocaleRedirect=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t,o={}){const e=o.autoDetectPath??"/",r=!t||t===""?"/":t;if(e==="*")return!0;if(e==="no_prefix")return!o.hasLocalePrefix;if(e==="/"||e==="")return r==="/";const n=e.startsWith("/")?e:`/${e}`;return r===n||r===`${n}/`}exports.shouldAttemptLocaleRedirect=c;
@@ -1,10 +1,8 @@
1
1
  function c(e, n = {}) {
2
2
  const t = n.autoDetectPath ?? "/", r = !e || e === "" ? "/" : e;
3
3
  if (t === "*") return !0;
4
- if (t === "no_prefix")
5
- return !n.hasLocalePrefix;
6
- if (t === "/" || t === "")
7
- return r === "/";
4
+ if (t === "no_prefix") return !n.hasLocalePrefix;
5
+ if (t === "/" || t === "") return r === "/";
8
6
  const o = t.startsWith("/") ? t : `/${t}`;
9
7
  return r === o || r === `${o}/`;
10
8
  }
package/dist/build.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("node:fs"),r=require("node:path"),j=require("globby"),M=require("./deep-merge.cjs");async function P(m,h,a,p,S,w){n.existsSync(a)&&n.rmSync(a,{recursive:!0,force:!0}),n.mkdirSync(a,{recursive:!0});const c=m.map(e=>r.join(e,h)),i=new Set,g=await Promise.all(c.filter(e=>n.existsSync(e)).map(e=>j.globby("**/*.json",{cwd:e})));for(const e of g)e.forEach(o=>i.add(o));const u=new Map;for(const e of i){let o={};for(const t of c){const s=r.join(t,e);if(n.existsSync(s))try{o=M.deepMergeTranslationsRecursive(o,JSON.parse(n.readFileSync(s,"utf-8")))}catch{}}u.set(e,o)}const d=new Map,l=new Map;for(const[e,o]of u){const t=r.dirname(e),s=e.slice(e.lastIndexOf("/")+1).replace(".json","");t==="."?d.set(s,o):(l.has(t)||l.set(t,new Map),l.get(t).set(s,o))}const b=new Set(p.map(e=>e.code)),x=e=>{for(const o of p){const t=[S,o.fallbackLocale,o.code].filter(f=>!!f&&b.has(f)).filter((f,y,v)=>v.indexOf(f)===y);if(t.length<=1)continue;let s={};for(const f of t){const y=e.get(f);y&&(s=M.deepMergeTranslationsRecursive(s,y))}e.set(o.code,s)}};x(d);for(const e of l.values())x(e);if(w||l.size===0){const e=new Map;for(const[o,t]of d)e.set(o,{...t});l.set("pages/index",e)}else for(const[,e]of l)for(const[o,t]of d){const s=e.get(o);e.set(o,s?M.deepMergeTranslations(t,s):{...t})}for(const[e,o]of l){const t=e.replace(/^pages\/?/,"")||"index";for(const[s,f]of o){if(!b.has(s))continue;const y=r.join(a,t,s,"data.json");n.mkdirSync(r.dirname(y),{recursive:!0}),n.writeFileSync(y,JSON.stringify(f))}}}async function k(m,h,a){n.existsSync(a)&&n.rmSync(a,{recursive:!0,force:!0}),n.mkdirSync(a,{recursive:!0});const p=m.map(c=>r.join(c,h)),S=new Set,w=await Promise.all(p.filter(c=>n.existsSync(c)).map(c=>j.globby("**/*.json",{cwd:c})));for(const c of w)c.forEach(i=>S.add(i));for(const c of S){let i={};for(const u of p){const d=r.join(u,c);if(n.existsSync(d))try{i=M.deepMergeTranslationsRecursive(i,JSON.parse(n.readFileSync(d,"utf-8")))}catch{}}const g=r.join(a,c);n.mkdirSync(r.dirname(g),{recursive:!0}),n.writeFileSync(g,JSON.stringify(i))}}exports.buildTranslationSourceLayers=k;exports.preMergeLocales=P;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x=Object.create,P=Object.defineProperty,F=Object.getOwnPropertyDescriptor,L=Object.getOwnPropertyNames,T=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,N=(o,i,a,p)=>{if(i&&typeof i=="object"||typeof i=="function")for(var u=L(i),g=0,c=u.length,s;g<c;g++)s=u[g],!h.call(o,s)&&s!==a&&P(o,s,{get:(_=>i[_]).bind(null,s),enumerable:!(p=F(i,s))||p.enumerable});return o},q=(o,i,a)=>(a=o!=null?x(T(o)):{},N(i||!o||!o.__esModule||!h.call(o,"default")?P(a,"default",{value:o,enumerable:!0}):a,o));const w=require("./deep-merge.cjs");let f=require("node:path"),n=require("node:fs");n=q(n,1);let j=require("globby");async function J(o,i,a,p,u,g){(0,n.existsSync)(a)&&n.default.rmSync(a,{recursive:!0,force:!0}),(0,n.mkdirSync)(a,{recursive:!0});const c=o.map(e=>(0,f.join)(e,i)),s=new Set,_=await Promise.all(c.filter(e=>(0,n.existsSync)(e)).map(e=>(0,j.globby)("**/*.json",{cwd:e})));for(const e of _)e.forEach(t=>s.add(t));const v=new Map;for(const e of s){let t={};for(const r of c){const l=(0,f.join)(r,e);if((0,n.existsSync)(l))try{t=w.deepMergeTranslationsRecursive(t,JSON.parse((0,n.readFileSync)(l,"utf-8")))}catch{}}v.set(e,t)}const S=new Map,d=new Map;for(const[e,t]of v){const r=(0,f.dirname)(e),l=e.slice(e.lastIndexOf("/")+1).replace(".json","");r==="."?S.set(l,t):(d.has(r)||d.set(r,new Map),d.get(r).set(l,t))}const O=new Set(p.map(e=>e.code)),M=e=>{for(const t of p){const r=[u,t.fallbackLocale,t.code].filter(y=>!!y&&O.has(y)).filter((y,b,m)=>m.indexOf(y)===b);if(r.length<=1)continue;let l={};for(const y of r){const b=e.get(y);b&&(l=w.deepMergeTranslationsRecursive(l,b))}e.set(t.code,l)}};M(S);for(const e of d.values())M(e);if(g||d.size===0){const e=new Map;for(const[t,r]of S)e.set(t,{...r});d.set("pages/index",e)}else for(const[,e]of d)for(const[t,r]of S){const l=e.get(t);e.set(t,l?w.deepMergeTranslations(r,l):{...r})}for(const[e,t]of d){const r=e.replace(/^pages\/?/,"")||"index";for(const[l,y]of t){if(!O.has(l))continue;const b=(0,f.join)(a,r,l,"data.json");(0,n.mkdirSync)((0,f.dirname)(b),{recursive:!0}),(0,n.writeFileSync)(b,JSON.stringify(y))}}}async function E(o,i,a){(0,n.existsSync)(a)&&n.default.rmSync(a,{recursive:!0,force:!0}),(0,n.mkdirSync)(a,{recursive:!0});const p=o.map(c=>(0,f.join)(c,i)),u=new Set,g=await Promise.all(p.filter(c=>(0,n.existsSync)(c)).map(c=>(0,j.globby)("**/*.json",{cwd:c})));for(const c of g)c.forEach(s=>u.add(s));for(const c of u){let s={};for(const v of p){const S=(0,f.join)(v,c);if((0,n.existsSync)(S))try{s=w.deepMergeTranslationsRecursive(s,JSON.parse((0,n.readFileSync)(S,"utf-8")))}catch{}}const _=(0,f.join)(a,c);(0,n.mkdirSync)((0,f.dirname)(_),{recursive:!0}),(0,n.writeFileSync)(_,JSON.stringify(s))}}exports.buildTranslationSourceLayers=E;exports.preMergeLocales=J;
package/dist/build.mjs CHANGED
@@ -1,84 +1,84 @@
1
- import b, { existsSync as p, mkdirSync as w, readFileSync as j, writeFileSync as F } from "node:fs";
2
- import { join as d, dirname as v } from "node:path";
1
+ import { deepMergeTranslations as J, deepMergeTranslationsRecursive as v } from "./deep-merge.mjs";
2
+ import { dirname as x, join as p } from "node:path";
3
+ import b, { existsSync as d, mkdirSync as w, readFileSync as j, writeFileSync as F } from "node:fs";
3
4
  import { globby as L } from "globby";
4
- import { deepMergeTranslationsRecursive as x, deepMergeTranslations as J } from "./deep-merge.mjs";
5
5
  async function z(M, S, n, y, m, u) {
6
- p(n) && b.rmSync(n, { recursive: !0, force: !0 }), w(n, { recursive: !0 });
7
- const s = M.map((e) => d(e, S)), c = /* @__PURE__ */ new Set(), g = await Promise.all(s.filter((e) => p(e)).map((e) => L("**/*.json", { cwd: e })));
8
- for (const e of g)
9
- e.forEach((o) => c.add(o));
6
+ d(n) && b.rmSync(n, {
7
+ recursive: !0,
8
+ force: !0
9
+ }), w(n, { recursive: !0 });
10
+ const s = M.map((e) => p(e, S)), c = /* @__PURE__ */ new Set(), g = await Promise.all(s.filter((e) => d(e)).map((e) => L("**/*.json", { cwd: e })));
11
+ for (const e of g) e.forEach((o) => c.add(o));
10
12
  const h = /* @__PURE__ */ new Map();
11
13
  for (const e of c) {
12
14
  let o = {};
13
15
  for (const t of s) {
14
- const a = d(t, e);
15
- if (p(a))
16
- try {
17
- o = x(o, JSON.parse(j(a, "utf-8")));
18
- } catch {
19
- }
16
+ const a = p(t, e);
17
+ if (d(a)) try {
18
+ o = v(o, JSON.parse(j(a, "utf-8")));
19
+ } catch {
20
+ }
20
21
  }
21
22
  h.set(e, o);
22
23
  }
23
24
  const l = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
24
25
  for (const [e, o] of h) {
25
- const t = v(e), a = e.slice(e.lastIndexOf("/") + 1).replace(".json", "");
26
+ const t = x(e), a = e.slice(e.lastIndexOf("/") + 1).replace(".json", "");
26
27
  t === "." ? l.set(a, o) : (r.has(t) || r.set(t, /* @__PURE__ */ new Map()), r.get(t).set(a, o));
27
28
  }
28
29
  const P = new Set(y.map((e) => e.code)), O = (e) => {
29
30
  for (const o of y) {
30
- const t = [m, o.fallbackLocale, o.code].filter((f) => !!f && P.has(f)).filter((f, i, k) => k.indexOf(f) === i);
31
+ const t = [
32
+ m,
33
+ o.fallbackLocale,
34
+ o.code
35
+ ].filter((f) => !!f && P.has(f)).filter((f, i, k) => k.indexOf(f) === i);
31
36
  if (t.length <= 1) continue;
32
37
  let a = {};
33
38
  for (const f of t) {
34
39
  const i = e.get(f);
35
- i && (a = x(a, i));
40
+ i && (a = v(a, i));
36
41
  }
37
42
  e.set(o.code, a);
38
43
  }
39
44
  };
40
45
  O(l);
41
- for (const e of r.values())
42
- O(e);
46
+ for (const e of r.values()) O(e);
43
47
  if (u || r.size === 0) {
44
48
  const e = /* @__PURE__ */ new Map();
45
- for (const [o, t] of l)
46
- e.set(o, { ...t });
49
+ for (const [o, t] of l) e.set(o, { ...t });
47
50
  r.set("pages/index", e);
48
- } else
49
- for (const [, e] of r)
50
- for (const [o, t] of l) {
51
- const a = e.get(o);
52
- e.set(o, a ? J(t, a) : { ...t });
53
- }
51
+ } else for (const [, e] of r) for (const [o, t] of l) {
52
+ const a = e.get(o);
53
+ e.set(o, a ? J(t, a) : { ...t });
54
+ }
54
55
  for (const [e, o] of r) {
55
56
  const t = e.replace(/^pages\/?/, "") || "index";
56
57
  for (const [a, f] of o) {
57
58
  if (!P.has(a)) continue;
58
- const i = d(n, t, a, "data.json");
59
- w(v(i), { recursive: !0 }), F(i, JSON.stringify(f));
59
+ const i = p(n, t, a, "data.json");
60
+ w(x(i), { recursive: !0 }), F(i, JSON.stringify(f));
60
61
  }
61
62
  }
62
63
  }
63
64
  async function C(M, S, n) {
64
- p(n) && b.rmSync(n, { recursive: !0, force: !0 }), w(n, { recursive: !0 });
65
- const y = M.map((s) => d(s, S)), m = /* @__PURE__ */ new Set(), u = await Promise.all(
66
- y.filter((s) => p(s)).map((s) => L("**/*.json", { cwd: s }))
67
- );
68
- for (const s of u)
69
- s.forEach((c) => m.add(c));
65
+ d(n) && b.rmSync(n, {
66
+ recursive: !0,
67
+ force: !0
68
+ }), w(n, { recursive: !0 });
69
+ const y = M.map((s) => p(s, S)), m = /* @__PURE__ */ new Set(), u = await Promise.all(y.filter((s) => d(s)).map((s) => L("**/*.json", { cwd: s })));
70
+ for (const s of u) s.forEach((c) => m.add(c));
70
71
  for (const s of m) {
71
72
  let c = {};
72
73
  for (const h of y) {
73
- const l = d(h, s);
74
- if (p(l))
75
- try {
76
- c = x(c, JSON.parse(j(l, "utf-8")));
77
- } catch {
78
- }
74
+ const l = p(h, s);
75
+ if (d(l)) try {
76
+ c = v(c, JSON.parse(j(l, "utf-8")));
77
+ } catch {
78
+ }
79
79
  }
80
- const g = d(n, s);
81
- w(v(g), { recursive: !0 }), F(g, JSON.stringify(c));
80
+ const g = p(n, s);
81
+ w(x(g), { recursive: !0 }), F(g, JSON.stringify(c));
82
82
  }
83
83
  }
84
84
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{constructor(t){this.cache=new Map,this.expiry=new Map,this.maxSize=0,this.ttlMs=0,t&&this.configure(t)}configure(t){this.maxSize=t.maxSize??0,this.ttlMs=(t.ttl??0)*1e3,this.ttlMs===0&&this.expiry.clear()}get(t){const e=this.cache.get(t);if(e!==void 0){if(this.ttlMs>0){const i=this.expiry.get(t);if(i&&Date.now()>i){this.delete(t);return}this.expiry.set(t,Date.now()+this.ttlMs)}return this.maxSize>0&&(this.cache.delete(t),this.cache.set(t,e)),e}}has(t){if(!this.cache.has(t))return!1;if(this.ttlMs>0){const e=this.expiry.get(t);if(e&&Date.now()>e)return this.delete(t),!1}return!0}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.maxSize>0&&this.cache.size>=this.maxSize){const i=this.cache.keys().next().value;i!==void 0&&this.delete(i)}this.cache.set(t,e),this.ttlMs>0&&this.expiry.set(t,Date.now()+this.ttlMs)}delete(t){return this.expiry.delete(t),this.cache.delete(t)}clear(){this.cache.clear(),this.expiry.clear()}keys(){return this.cache.keys()}get size(){return this.cache.size}}exports.CacheControl=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s=class{constructor(t){this.cache=new Map,this.expiry=new Map,this.maxSize=0,this.ttlMs=0,t&&this.configure(t)}configure(t){this.maxSize=t.maxSize??0,this.ttlMs=(t.ttl??0)*1e3,this.ttlMs===0&&this.expiry.clear()}get(t){const e=this.cache.get(t);if(e!==void 0){if(this.ttlMs>0){const i=this.expiry.get(t);if(i&&Date.now()>i){this.delete(t);return}this.expiry.set(t,Date.now()+this.ttlMs)}return this.maxSize>0&&(this.cache.delete(t),this.cache.set(t,e)),e}}has(t){if(!this.cache.has(t))return!1;if(this.ttlMs>0){const e=this.expiry.get(t);if(e&&Date.now()>e)return this.delete(t),!1}return!0}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.maxSize>0&&this.cache.size>=this.maxSize){const i=this.cache.keys().next().value;i!==void 0&&this.delete(i)}this.cache.set(t,e),this.ttlMs>0&&this.expiry.set(t,Date.now()+this.ttlMs)}delete(t){return this.expiry.delete(t),this.cache.delete(t)}clear(){this.cache.clear(),this.expiry.clear()}keys(){return this.cache.keys()}get size(){return this.cache.size}};exports.CacheControl=s;
@@ -1,8 +1,7 @@
1
- class h {
1
+ var s = class {
2
2
  constructor(t) {
3
3
  this.cache = /* @__PURE__ */ new Map(), this.expiry = /* @__PURE__ */ new Map(), this.maxSize = 0, this.ttlMs = 0, t && this.configure(t);
4
4
  }
5
- /** Update limits at runtime. Last call wins. */
6
5
  configure(t) {
7
6
  this.maxSize = t.maxSize ?? 0, this.ttlMs = (t.ttl ?? 0) * 1e3, this.ttlMs === 0 && this.expiry.clear();
8
7
  }
@@ -30,8 +29,7 @@ class h {
30
29
  return !0;
31
30
  }
32
31
  set(t, e) {
33
- if (this.cache.has(t))
34
- this.cache.delete(t);
32
+ if (this.cache.has(t)) this.cache.delete(t);
35
33
  else if (this.maxSize > 0 && this.cache.size >= this.maxSize) {
36
34
  const i = this.cache.keys().next().value;
37
35
  i !== void 0 && this.delete(i);
@@ -50,7 +48,7 @@ class h {
50
48
  get size() {
51
49
  return this.cache.size;
52
50
  }
53
- }
51
+ };
54
52
  export {
55
- h as CacheControl
53
+ s as CacheControl
56
54
  };
package/dist/cookie.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t="user-locale",a="hash-locale",o=3600*24*365;function l(e){return e.localeCookie===null?null:e.localeCookie||t}function n(e){return e.hashMode?a:null}function i(){const e=new Date;return e.setTime(e.getTime()+o*1e3),{expires:e,maxAge:o,path:"/",watch:!0,sameSite:"lax"}}exports.DEFAULT_COOKIE_MAX_AGE=o;exports.DEFAULT_COOKIE_NAME=t;exports.DEFAULT_HASH_COOKIE_NAME=a;exports.getHashCookieName=n;exports.getLocaleCookieName=l;exports.getLocaleCookieOptions=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t="user-locale",a="hash-locale",o=31536e3;function l(e){return e.localeCookie===null?null:e.localeCookie||"user-locale"}function i(e){return e.hashMode?a:null}function r(){const e=new Date;return e.setTime(e.getTime()+o*1e3),{expires:e,maxAge:o,path:"/",watch:!0,sameSite:"lax"}}exports.DEFAULT_COOKIE_MAX_AGE=o;exports.DEFAULT_COOKIE_NAME=t;exports.DEFAULT_HASH_COOKIE_NAME=a;exports.getHashCookieName=i;exports.getLocaleCookieName=l;exports.getLocaleCookieOptions=r;
package/dist/cookie.mjs CHANGED
@@ -1,25 +1,25 @@
1
- const o = "user-locale", t = "hash-locale", n = 31536e3;
2
- function a(e) {
3
- return e.localeCookie === null ? null : e.localeCookie || o;
4
- }
1
+ var t = "user-locale", a = "hash-locale", o = 31536e3;
5
2
  function l(e) {
6
- return e.hashMode ? t : null;
3
+ return e.localeCookie === null ? null : e.localeCookie || "user-locale";
4
+ }
5
+ function r(e) {
6
+ return e.hashMode ? a : null;
7
7
  }
8
- function A() {
8
+ function n() {
9
9
  const e = /* @__PURE__ */ new Date();
10
- return e.setTime(e.getTime() + 31536e3 * 1e3), {
10
+ return e.setTime(e.getTime() + o * 1e3), {
11
11
  expires: e,
12
- maxAge: 31536e3,
12
+ maxAge: o,
13
13
  path: "/",
14
14
  watch: !0,
15
15
  sameSite: "lax"
16
16
  };
17
17
  }
18
18
  export {
19
- n as DEFAULT_COOKIE_MAX_AGE,
20
- o as DEFAULT_COOKIE_NAME,
21
- t as DEFAULT_HASH_COOKIE_NAME,
22
- l as getHashCookieName,
23
- a as getLocaleCookieName,
24
- A as getLocaleCookieOptions
19
+ o as DEFAULT_COOKIE_MAX_AGE,
20
+ t as DEFAULT_COOKIE_NAME,
21
+ a as DEFAULT_HASH_COOKIE_NAME,
22
+ r as getHashCookieName,
23
+ l as getLocaleCookieName,
24
+ n as getLocaleCookieOptions
25
25
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(s,n){const r={...s};for(const e of Object.keys(n)){if(e==="__proto__")continue;const t=n[e],o=r[e];t!==null&&typeof t=="object"&&!Array.isArray(t)&&o!==null&&typeof o=="object"&&!Array.isArray(o)?r[e]={...o,...t}:r[e]=t}return r}function c(s,n){if(!s||Object.keys(s).length===0)return{...n};const r={...s};for(const e of Object.keys(n)){if(e==="__proto__")continue;const t=n[e],o=r[e];t&&typeof t=="object"&&!Array.isArray(t)&&o&&typeof o=="object"&&!Array.isArray(o)?r[e]=c(o,t):r[e]=t}return r}exports.deepMergeTranslations=i;exports.deepMergeTranslationsRecursive=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(s,n){const r={...s};for(const e of Object.keys(n)){if(e==="__proto__")continue;const t=n[e],o=r[e];t!==null&&typeof t=="object"&&!Array.isArray(t)&&o!==null&&typeof o=="object"&&!Array.isArray(o)?r[e]={...o,...t}:r[e]=t}return r}function c(s,n){if(!s||Object.keys(s).length===0)return{...n};const r={...s};for(const e of Object.keys(n)){if(e==="__proto__")continue;const t=n[e],o=r[e];t&&typeof t=="object"&&!Array.isArray(t)&&o&&typeof o=="object"&&!Array.isArray(o)?r[e]=c(o,t):r[e]=t}return r}exports.deepMergeTranslations=i;exports.deepMergeTranslationsRecursive=c;
@@ -3,7 +3,10 @@ function y(s, n) {
3
3
  for (const e of Object.keys(n)) {
4
4
  if (e === "__proto__") continue;
5
5
  const t = n[e], o = r[e];
6
- t !== null && typeof t == "object" && !Array.isArray(t) && o !== null && typeof o == "object" && !Array.isArray(o) ? r[e] = { ...o, ...t } : r[e] = t;
6
+ t !== null && typeof t == "object" && !Array.isArray(t) && o !== null && typeof o == "object" && !Array.isArray(o) ? r[e] = {
7
+ ...o,
8
+ ...t
9
+ } : r[e] = t;
7
10
  }
8
11
  return r;
9
12
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./resolve-og-locale.cjs");function u(e){return e.rel==="alternate"}function s(e){return e.rel==="alternate"&&e.hreflang==="x-default"}function m(e){return e.rel==="alternate"&&e.hreflang!=="x-default"}function g(e,t){const n=e[t];return n?`id:${n}`:e.property?`property:${e.property}`:e.name?`name:${e.name}`:`meta:${JSON.stringify(e)}`}function A(e,t){const n=e[t];return n?`id:${n}`:`link:${e.rel}:${e.hreflang??""}`}function p(e,t){const n=new Set([A(e,t)]);return e.rel==="alternate"&&e.hreflang&&n.add(`link:${e.rel}:${e.hreflang}`),e.rel==="canonical"&&n.add("link:canonical:"),[...n]}function $(e,t,n){if(g(e,n)===g(t,n)||t.property&&e.property===t.property||t.name&&e.name===t.name)return!0;const o=t[n];return!!(o&&e[n]===o)}function L(e,t,n){const o=e.filter(i=>!$(i,t,n));return o.push(t),o}function k(e,t,n){const o=new Set(p(t,n)),i=e.filter(c=>!p(c,n).some(l=>o.has(l)));return i.push(t),i}function x(e,t,n){let o=!1;const i=e.map(c=>c.rel!=="canonical"?c:(o=!0,{...c,href:t}));return o||i.unshift({[n]:"i18n-can",rel:"canonical",href:t}),i}function h(e,t,n,o,i){const c=e.filter(l=>l.property!==t);return c.push({[o]:t==="og:locale"?"i18n-og":t==="og:url"?"i18n-og-url":`i18n-page-${t}`,property:t,content:n}),c}function S(e,t,n,o){const i=[];for(const c of e){if(n&&c===n)continue;const l=t.find(f=>f.code===c);if(!l)continue;const a=d.resolveOgLocale(l);a&&i.push({[o]:`i18n-og-alt-${a}`,property:"og:locale:alternate",content:a})}return i}function M(e,t,n={}){if(!t)return{htmlAttrs:{...e.htmlAttrs},meta:[...e.meta],link:[...e.link]};const o=n.identifierAttribute??"id",i=new Set(t.disable??[]);let c={...e.htmlAttrs},l=[...e.meta],a=[...e.link];i.has("html")&&(c={}),i.has("hreflang")&&(a=a.filter(r=>!m(r))),i.has("x-default")&&(a=a.filter(r=>!s(r))),i.has("canonical")&&(a=a.filter(r=>r.rel!=="canonical")),i.has("og")&&(l=l.filter(r=>r.property!=="og:locale"&&r.property!=="og:url")),i.has("og-alternates")&&(l=l.filter(r=>r.property!=="og:locale:alternate"));const f=t.replace;if(f){if(f.canonical===!1?a=a.filter(r=>r.rel!=="canonical"):typeof f.canonical=="string"&&(a=x(a,f.canonical,o)),f.hreflang===!1?a=a.filter(r=>!u(r)):Array.isArray(f.hreflang)&&(a=a.filter(r=>!u(r)),a.push(...f.hreflang)),f.xDefault===!1?a=a.filter(r=>!s(r)):f.xDefault&&(a=a.filter(r=>!s(r)),a.push(f.xDefault)),f.ogLocale===!1?l=l.filter(r=>r.property!=="og:locale"):typeof f.ogLocale=="string"&&(l=h(l,"og:locale",f.ogLocale,o)),f.ogUrl===!1?l=l.filter(r=>r.property!=="og:url"):typeof f.ogUrl=="string"&&(l=h(l,"og:url",f.ogUrl,o)),f.ogAlternates===!1)l=l.filter(r=>r.property!=="og:locale:alternate");else if(Array.isArray(f.ogAlternates)){l=l.filter(y=>y.property!=="og:locale:alternate");const r=n.locales??[];l.push(...S(f.ogAlternates,r,n.currentLocale,o))}}t.htmlAttrs&&(c={...c,...t.htmlAttrs});for(const r of t.meta??[])l=L(l,r,o);for(const r of t.link??[])a=k(a,r,o);return{htmlAttrs:c,meta:l,link:a}}exports.mergeI18nHead=M;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./resolve-og-locale.cjs");function u(e){return e.rel==="alternate"}function s(e){return e.rel==="alternate"&&e.hreflang==="x-default"}function m(e){return e.rel==="alternate"&&e.hreflang!=="x-default"}function g(e,t){const n=e[t];return n?`id:${n}`:e.property?`property:${e.property}`:e.name?`name:${e.name}`:`meta:${JSON.stringify(e)}`}function A(e,t){const n=e[t];return n?`id:${n}`:`link:${e.rel}:${e.hreflang??""}`}function p(e,t){const n=new Set([A(e,t)]);return e.rel==="alternate"&&e.hreflang&&n.add(`link:${e.rel}:${e.hreflang}`),e.rel==="canonical"&&n.add("link:canonical:"),[...n]}function $(e,t,n){if(g(e,n)===g(t,n)||t.property&&e.property===t.property||t.name&&e.name===t.name)return!0;const o=t[n];return!!(o&&e[n]===o)}function L(e,t,n){const o=e.filter(i=>!$(i,t,n));return o.push(t),o}function k(e,t,n){const o=new Set(p(t,n)),i=e.filter(c=>!p(c,n).some(l=>o.has(l)));return i.push(t),i}function x(e,t,n){let o=!1;const i=e.map(c=>c.rel!=="canonical"?c:(o=!0,{...c,href:t}));return o||i.unshift({[n]:"i18n-can",rel:"canonical",href:t}),i}function h(e,t,n,o,i){const c=e.filter(l=>l.property!==t);return c.push({[o]:i??(t==="og:locale"?"i18n-og":t==="og:url"?"i18n-og-url":`i18n-page-${t}`),property:t,content:n}),c}function S(e,t,n,o){const i=[];for(const c of e){if(n&&c===n)continue;const l=t.find(f=>f.code===c);if(!l)continue;const a=d.resolveOgLocale(l);a&&i.push({[o]:`i18n-og-alt-${a}`,property:"og:locale:alternate",content:a})}return i}function M(e,t,n={}){if(!t)return{htmlAttrs:{...e.htmlAttrs},meta:[...e.meta],link:[...e.link]};const o=n.identifierAttribute??"id",i=new Set(t.disable??[]);let c={...e.htmlAttrs},l=[...e.meta],a=[...e.link];i.has("html")&&(c={}),i.has("hreflang")&&(a=a.filter(r=>!m(r))),i.has("x-default")&&(a=a.filter(r=>!s(r))),i.has("canonical")&&(a=a.filter(r=>r.rel!=="canonical")),i.has("og")&&(l=l.filter(r=>r.property!=="og:locale"&&r.property!=="og:url")),i.has("og-alternates")&&(l=l.filter(r=>r.property!=="og:locale:alternate"));const f=t.replace;if(f){if(f.canonical===!1?a=a.filter(r=>r.rel!=="canonical"):typeof f.canonical=="string"&&(a=x(a,f.canonical,o)),f.hreflang===!1?a=a.filter(r=>!u(r)):Array.isArray(f.hreflang)&&(a=a.filter(r=>!u(r)),a.push(...f.hreflang)),f.xDefault===!1?a=a.filter(r=>!s(r)):f.xDefault&&(a=a.filter(r=>!s(r)),a.push(f.xDefault)),f.ogLocale===!1?l=l.filter(r=>r.property!=="og:locale"):typeof f.ogLocale=="string"&&(l=h(l,"og:locale",f.ogLocale,o)),f.ogUrl===!1?l=l.filter(r=>r.property!=="og:url"):typeof f.ogUrl=="string"&&(l=h(l,"og:url",f.ogUrl,o)),f.ogAlternates===!1)l=l.filter(r=>r.property!=="og:locale:alternate");else if(Array.isArray(f.ogAlternates)){l=l.filter(y=>y.property!=="og:locale:alternate");const r=n.locales??[];l.push(...S(f.ogAlternates,r,n.currentLocale,o))}}t.htmlAttrs&&(c={...c,...t.htmlAttrs});for(const r of t.meta??[])l=L(l,r,o);for(const r of t.link??[])a=k(a,r,o);return{htmlAttrs:c,meta:l,link:a}}exports.mergeI18nHead=M;
@@ -35,7 +35,10 @@ function x(e, t, n) {
35
35
  }
36
36
  function k(e, t, n) {
37
37
  let o = !1;
38
- const i = e.map((c) => c.rel !== "canonical" ? c : (o = !0, { ...c, href: t }));
38
+ const i = e.map((c) => c.rel !== "canonical" ? c : (o = !0, {
39
+ ...c,
40
+ href: t
41
+ }));
39
42
  return o || i.unshift({
40
43
  [n]: "i18n-can",
41
44
  rel: "canonical",
@@ -45,7 +48,7 @@ function k(e, t, n) {
45
48
  function h(e, t, n, o, i) {
46
49
  const c = e.filter((l) => l.property !== t);
47
50
  return c.push({
48
- [o]: t === "og:locale" ? "i18n-og" : t === "og:url" ? "i18n-og-url" : `i18n-page-${t}`,
51
+ [o]: i ?? (t === "og:locale" ? "i18n-og" : t === "og:url" ? "i18n-og-url" : `i18n-page-${t}`),
49
52
  property: t,
50
53
  content: n
51
54
  }), c;
@@ -66,31 +69,34 @@ function D(e, t, n, o) {
66
69
  return i;
67
70
  }
68
71
  function S(e, t, n = {}) {
69
- if (!t)
70
- return {
71
- htmlAttrs: { ...e.htmlAttrs },
72
- meta: [...e.meta],
73
- link: [...e.link]
74
- };
72
+ if (!t) return {
73
+ htmlAttrs: { ...e.htmlAttrs },
74
+ meta: [...e.meta],
75
+ link: [...e.link]
76
+ };
75
77
  const o = n.identifierAttribute ?? "id", i = new Set(t.disable ?? []);
76
78
  let c = { ...e.htmlAttrs }, l = [...e.meta], a = [...e.link];
77
79
  i.has("html") && (c = {}), i.has("hreflang") && (a = a.filter((r) => !m(r))), i.has("x-default") && (a = a.filter((r) => !s(r))), i.has("canonical") && (a = a.filter((r) => r.rel !== "canonical")), i.has("og") && (l = l.filter((r) => r.property !== "og:locale" && r.property !== "og:url")), i.has("og-alternates") && (l = l.filter((r) => r.property !== "og:locale:alternate"));
78
80
  const f = t.replace;
79
81
  if (f) {
80
- if (f.canonical === !1 ? a = a.filter((r) => r.rel !== "canonical") : typeof f.canonical == "string" && (a = k(a, f.canonical, o)), f.hreflang === !1 ? a = a.filter((r) => !u(r)) : Array.isArray(f.hreflang) && (a = a.filter((r) => !u(r)), a.push(...f.hreflang)), f.xDefault === !1 ? a = a.filter((r) => !s(r)) : f.xDefault && (a = a.filter((r) => !s(r)), a.push(f.xDefault)), f.ogLocale === !1 ? l = l.filter((r) => r.property !== "og:locale") : typeof f.ogLocale == "string" && (l = h(l, "og:locale", f.ogLocale, o)), f.ogUrl === !1 ? l = l.filter((r) => r.property !== "og:url") : typeof f.ogUrl == "string" && (l = h(l, "og:url", f.ogUrl, o)), f.ogAlternates === !1)
81
- l = l.filter((r) => r.property !== "og:locale:alternate");
82
+ if (f.canonical === !1 ? a = a.filter((r) => r.rel !== "canonical") : typeof f.canonical == "string" && (a = k(a, f.canonical, o)), f.hreflang === !1 ? a = a.filter((r) => !u(r)) : Array.isArray(f.hreflang) && (a = a.filter((r) => !u(r)), a.push(...f.hreflang)), f.xDefault === !1 ? a = a.filter((r) => !s(r)) : f.xDefault && (a = a.filter((r) => !s(r)), a.push(f.xDefault)), f.ogLocale === !1 ? l = l.filter((r) => r.property !== "og:locale") : typeof f.ogLocale == "string" && (l = h(l, "og:locale", f.ogLocale, o)), f.ogUrl === !1 ? l = l.filter((r) => r.property !== "og:url") : typeof f.ogUrl == "string" && (l = h(l, "og:url", f.ogUrl, o)), f.ogAlternates === !1) l = l.filter((r) => r.property !== "og:locale:alternate");
82
83
  else if (Array.isArray(f.ogAlternates)) {
83
84
  l = l.filter((y) => y.property !== "og:locale:alternate");
84
85
  const r = n.locales ?? [];
85
86
  l.push(...D(f.ogAlternates, r, n.currentLocale, o));
86
87
  }
87
88
  }
88
- t.htmlAttrs && (c = { ...c, ...t.htmlAttrs });
89
- for (const r of t.meta ?? [])
90
- l = L(l, r, o);
91
- for (const r of t.link ?? [])
92
- a = x(a, r, o);
93
- return { htmlAttrs: c, meta: l, link: a };
89
+ t.htmlAttrs && (c = {
90
+ ...c,
91
+ ...t.htmlAttrs
92
+ });
93
+ for (const r of t.meta ?? []) l = L(l, r, o);
94
+ for (const r of t.link ?? []) a = x(a, r, o);
95
+ return {
96
+ htmlAttrs: c,
97
+ meta: l,
98
+ link: a
99
+ };
94
100
  }
95
101
  export {
96
102
  S as mergeI18nHead
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./deep-merge.cjs");function s(e,a,r){const c=new Set(a.map(o=>o.code)),n=a.find(o=>o.code===e);return[r,n?.fallbackLocale,e].filter(o=>!!o&&c.has(o)).filter((o,f,m)=>m.indexOf(o)===f)}function b(e,a,r){let c={};for(const n of e)c=l.deepMergeTranslations(c,a(r(n)));return c}async function t(e,a,r){return(await Promise.all(e.map(n=>a(r(n))))).reduce((n,o)=>l.deepMergeTranslations(n,o),{})}function i(e,a){return a?"index":e||"index"}function u(e){return`${e}.json`}function g(e,a){return`pages/${i(e)}/${a}.json`}function d(e){return e.replace(/^\/+/,"").replace(/\\/g,"/")}function S(e,a){const r=e.replace(/^\/+|\/+$/g,"")||"index";return d(`${r}/${a}/data.json`)}async function h(e){const a=i(e.pageName,e.disablePageLocales),r=s(e.locale,e.locales,e.globalFallbackLocale),c=await t(r,e.readLocaleFile,u),n=await t(r,e.readLocaleFile,o=>g(a,o));return l.deepMergeTranslations(c,n)}function k(e){return(e??[]).map(a=>typeof a=="string"?{code:a}:{code:a.code,fallbackLocale:a.fallbackLocale})}exports.buildFallbackLocaleChain=s;exports.buildSourcePagePath=g;exports.buildSourceRootPath=u;exports.mergeSourceTranslations=h;exports.mergeTranslationsFromFallbackChain=b;exports.mergeTranslationsFromFallbackChainAsync=t;exports.normalizeConfiguredLocales=k;exports.resolveSourcePageName=i;exports.toPremergedStorageKey=S;exports.toSourceStorageKey=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./deep-merge.cjs");function s(e,a,n){const o=new Set(a.map(r=>r.code));return[n,a.find(r=>r.code===e)?.fallbackLocale,e].filter(r=>!!r&&o.has(r)).filter((r,l,f)=>f.indexOf(r)===l)}function m(e,a,n){let o={};for(const r of e)o=c.deepMergeTranslations(o,a(n(r)));return o}async function t(e,a,n){return(await Promise.all(e.map(o=>a(n(o))))).reduce((o,r)=>c.deepMergeTranslations(o,r),{})}function i(e,a){return a?"index":e||"index"}function u(e){return`${e}.json`}function g(e,a){return`pages/${i(e)}/${a}.json`}function d(e){return e.replace(/^\/+/,"").replace(/\\/g,"/")}function b(e,a){return d(`${e.replace(/^\/+|\/+$/g,"")||"index"}/${a}/data.json`)}async function S(e){const a=i(e.pageName,e.disablePageLocales),n=s(e.locale,e.locales,e.globalFallbackLocale),o=await t(n,e.readLocaleFile,u),r=await t(n,e.readLocaleFile,l=>g(a,l));return c.deepMergeTranslations(o,r)}function F(e){return(e??[]).map(a=>typeof a=="string"?{code:a}:{code:a.code,fallbackLocale:a.fallbackLocale})}exports.buildFallbackLocaleChain=s;exports.buildSourcePagePath=g;exports.buildSourceRootPath=u;exports.mergeSourceTranslations=S;exports.mergeTranslationsFromFallbackChain=m;exports.mergeTranslationsFromFallbackChainAsync=t;exports.normalizeConfiguredLocales=F;exports.resolveSourcePageName=i;exports.toPremergedStorageKey=b;exports.toSourceStorageKey=d;
@@ -1,51 +1,54 @@
1
1
  import { deepMergeTranslations as t } from "./deep-merge.mjs";
2
- function f(e, a, n) {
3
- const c = new Set(a.map((o) => o.code)), r = a.find((o) => o.code === e);
4
- return [n, r?.fallbackLocale, e].filter((o) => !!o && c.has(o)).filter((o, s, u) => u.indexOf(o) === s);
5
- }
6
- function k(e, a, n) {
7
- let c = {};
8
- for (const r of e)
9
- c = t(c, a(n(r)));
10
- return c;
11
- }
12
- async function l(e, a, n) {
13
- return (await Promise.all(e.map((r) => a(n(r))))).reduce((r, o) => t(r, o), {});
2
+ function u(e, a, r) {
3
+ const n = new Set(a.map((o) => o.code));
4
+ return [
5
+ r,
6
+ a.find((o) => o.code === e)?.fallbackLocale,
7
+ e
8
+ ].filter((o) => !!o && n.has(o)).filter((o, c, s) => s.indexOf(o) === c);
9
+ }
10
+ function b(e, a, r) {
11
+ let n = {};
12
+ for (const o of e) n = t(n, a(r(o)));
13
+ return n;
14
+ }
15
+ async function l(e, a, r) {
16
+ return (await Promise.all(e.map((n) => a(r(n))))).reduce((n, o) => t(n, o), {});
14
17
  }
15
18
  function i(e, a) {
16
19
  return a ? "index" : e || "index";
17
20
  }
18
- function d(e) {
21
+ function f(e) {
19
22
  return `${e}.json`;
20
23
  }
21
- function g(e, a) {
24
+ function d(e, a) {
22
25
  return `pages/${i(e)}/${a}.json`;
23
26
  }
24
- function m(e) {
27
+ function g(e) {
25
28
  return e.replace(/^\/+/, "").replace(/\\/g, "/");
26
29
  }
27
- function h(e, a) {
28
- const n = e.replace(/^\/+|\/+$/g, "") || "index";
29
- return m(`${n}/${a}/data.json`);
30
+ function L(e, a) {
31
+ return g(`${e.replace(/^\/+|\/+$/g, "") || "index"}/${a}/data.json`);
30
32
  }
31
- async function p(e) {
32
- const a = i(e.pageName, e.disablePageLocales), n = f(e.locale, e.locales, e.globalFallbackLocale), c = await l(n, e.readLocaleFile, d), r = await l(n, e.readLocaleFile, (o) => g(a, o));
33
- return t(c, r);
33
+ async function k(e) {
34
+ const a = i(e.pageName, e.disablePageLocales), r = u(e.locale, e.locales, e.globalFallbackLocale), n = await l(r, e.readLocaleFile, f), o = await l(r, e.readLocaleFile, (c) => d(a, c));
35
+ return t(n, o);
34
36
  }
35
- function L(e) {
36
- return (e ?? []).map(
37
- (a) => typeof a == "string" ? { code: a } : { code: a.code, fallbackLocale: a.fallbackLocale }
38
- );
37
+ function p(e) {
38
+ return (e ?? []).map((a) => typeof a == "string" ? { code: a } : {
39
+ code: a.code,
40
+ fallbackLocale: a.fallbackLocale
41
+ });
39
42
  }
40
43
  export {
41
- f as buildFallbackLocaleChain,
42
- g as buildSourcePagePath,
43
- d as buildSourceRootPath,
44
- p as mergeSourceTranslations,
45
- k as mergeTranslationsFromFallbackChain,
44
+ u as buildFallbackLocaleChain,
45
+ d as buildSourcePagePath,
46
+ f as buildSourceRootPath,
47
+ k as mergeSourceTranslations,
48
+ b as mergeTranslationsFromFallbackChain,
46
49
  l as mergeTranslationsFromFallbackChainAsync,
47
- L as normalizeConfiguredLocales,
50
+ p as normalizeConfiguredLocales,
48
51
  i as resolveSourcePageName,
49
- h as toPremergedStorageKey,
50
- m as toSourceStorageKey
52
+ L as toPremergedStorageKey,
53
+ g as toSourceStorageKey
51
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(r){return r?typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{}:{}}function o(r){return n(r)}exports.toTranslationRecord=o;exports.toTranslations=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(r){return r?typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{}:{}}function o(r){return n(r)}exports.toTranslationRecord=o;exports.toTranslations=n;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./deep-merge.cjs");function n(e){const t=e.replace(/\\/g,"/");if(!t.endsWith(".json"))return{type:"ignore"};if(t.startsWith("pages/")){const r=t.match(/^pages\/(.+)\/([^/]+)\.json$/);if(!r?.[1]||!r[2])return{type:"ignore"};const o=s(r[1].split("/"));return o?{type:"page",pageName:o,locale:r[2]}:{type:"ignore"}}const a=t.match(/^([^/]+)\.json$/);return a?.[1]?{type:"root",locale:a[1]}:{type:"ignore"}}function i(e,t=!1){const a=n(e);return t&&a.type==="page"?{type:"root",locale:a.locale}:a}function s(e){return e.length===0?null:e.join("-")}function u(e,t,a,r=!1){const o=i(t,r);if(o.type==="page"){const l=e.routes[o.pageName]??(e.routes[o.pageName]={});l[o.locale]=a;return}o.type==="root"&&(e.root[o.locale]=a)}function c(e,t){return p.deepMergeTranslations(e??{},t)}exports.classifyTranslationRelativePath=i;exports.mergeRouteTranslationsWithRoot=c;exports.pagePathSegmentsToRouteName=s;exports.parseTranslationRelativePath=n;exports.storeLoadedTranslationFile=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./deep-merge.cjs");function n(e){const t=e.replace(/\\/g,"/");if(!t.endsWith(".json"))return{type:"ignore"};if(t.startsWith("pages/")){const r=t.match(/^pages\/(.+)\/([^/]+)\.json$/);if(!r?.[1]||!r[2])return{type:"ignore"};const o=l(r[1].split("/"));return o?{type:"page",pageName:o,locale:r[2]}:{type:"ignore"}}const a=t.match(/^([^/]+)\.json$/);return a?.[1]?{type:"root",locale:a[1]}:{type:"ignore"}}function i(e,t=!1){const a=n(e);return t&&a.type==="page"?{type:"root",locale:a.locale}:a}function l(e){return e.length===0?null:e.join("-")}function u(e,t,a,r=!1){const o=i(t,r);if(o.type==="page"){const s=e.routes[o.pageName]??(e.routes[o.pageName]={});s[o.locale]=a;return}o.type==="root"&&(e.root[o.locale]=a)}function c(e,t){return p.deepMergeTranslations(e??{},t)}exports.classifyTranslationRelativePath=i;exports.mergeRouteTranslationsWithRoot=c;exports.pagePathSegmentsToRouteName=l;exports.parseTranslationRelativePath=n;exports.storeLoadedTranslationFile=u;