vanilla-intlayer 8.6.0 → 8.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-C91j1N6u.js`),t=require(`./renderIntlayerNode.cjs`);let n=require(`@intlayer/core/interpreter`),r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@intlayer/core/markdown`),a=require(`@intlayer/types/nodeType`);a=e.t(a);var o=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`),s=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),c={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:n,keyPath:i,dictionaryKey:a,...c})=>{if(r.default.editor.enabled){let e=String(n??``),r=JSON.stringify(i??[]),l=String(a??``),u=`<intlayer-content-selector-wrapper key-path="${o(r)}" dictionary-key="${o(l)}">${s(e)}</intlayer-content-selector-wrapper>`;return t.renderIntlayerNode({...c,value:n,children:u,keyPath:i,dictionaryKey:a,additionalProps:{toElement:()=>{let t=document.createElement(`intlayer-content-selector-wrapper`);return t.setAttribute(`key-path`,r),t.setAttribute(`dictionary-key`,l),t.textContent=e,t}}})}return t.renderIntlayerNode({...c,value:n,children:n})}},l={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.INSERTION,transform:(e,t,r)=>{let i=[...t.keyPath,{type:a.INSERTION}],o=e[a.INSERTION],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,r,i)=>{let a=i(e,{...r,children:e,plugins:(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)});return e=>{let o=(0,n.splitInsertionTemplate)(a,e),s=o.isSimple?o.parts:o.parts.join(``);return i(s,{...r,plugins:t.plugins,children:s})}}},c=r(o,{...t,children:o,keyPath:i,plugins:[s,...t.plugins??[]]});return typeof o==`object`&&o&&`nodeType`in o&&[a.ENUMERATION,a.CONDITION].includes(o.nodeType)?e=>t=>{let n=c(t);return typeof n==`function`?n(e):n}:c}},u={createElement:(e,t,...n)=>{let r=Object.entries(t||{}).filter(([e])=>e!==`children`&&e!==`key`&&e!==`_innerHTML`).map(([e,t])=>`${e}="${t}"`).join(` `),i=t?._innerHTML,a=i===void 0?n.flat(1/0).join(``):i;return`<${e}${r?` ${r}`:``}>${a}</${e}>`},normalizeProps:(e,t)=>{let n={};for(let[e,r]of Object.entries(t))e===`className`?n.class=r:e===`htmlFor`?n.for=r:e===`dangerouslySetInnerHTML`&&r?.__html?n._innerHTML=r.__html:n[e]=r;return n}},d={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let{plugins:a,...o}=n,s=r((0,i.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:e})}],dictionaryKey:o.dictionaryKey,keyPath:[]}),c=(t={})=>(0,i.compileWithOptions)(e,{...u,createElement:(e,n,...r)=>{let i=t[e];return typeof i==`function`?i({...n,children:r.join(``)}):u.createElement(e,n,...r)}},{});return t.renderIntlayerNode({...n,value:c(),children:e,additionalProps:{metadata:s,use:e=>c(e)}})}},f={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:a.MARKDOWN}],i=e[a.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[d,...t.plugins??[]]})}},p={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.HTML,transform:(e,r)=>{let i=e[a.HTML],o=(e={})=>{let t=(0,n.getHTML)(i,new Proxy(e,{get(e,t){if(typeof t==`string`&&t in e){let n=e[t];return e=>{let t=Array.isArray(e.children)?e.children.join(``):e.children;return n({...e,children:t})}}if(typeof t==`string`&&/^[a-z][a-z0-9]*$/.test(t))return e=>{let n=Object.entries(e).filter(([e])=>e!==`children`&&e!==`key`).map(([e,t])=>`${e}="${t}"`).join(` `),r=Array.isArray(e.children)?e.children.join(``):e.children;return`<${t}${n?` ${n}`:``}>${r}</${t}>`}}}));return Array.isArray(t)?t.join(``):t};return t.renderIntlayerNode({...r,value:o(),children:i,additionalProps:{use:e=>o(e)}})}},m=(e,t=!0)=>[(0,n.translationPlugin)(e??r.default.internationalization.defaultLocale,t?r.default.internationalization.defaultLocale:void 0),n.enumerationPlugin,n.conditionPlugin,(0,n.nestedPlugin)(e??r.default.internationalization.defaultLocale),n.filePlugin,n.genderPlugin,c,l,f,p];exports.getPlugins=m,exports.htmlPlugin=p,exports.insertionPlugin=l,exports.intlayerNodePlugins=c,exports.markdownPlugin=f,exports.markdownStringPlugin=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-C91j1N6u.js`),t=require(`./renderIntlayerNode.cjs`);let n=require(`@intlayer/core/interpreter`),r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@intlayer/core/markdown`),a=require(`@intlayer/types/nodeType`);a=e.t(a);var o=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`),s=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),c=process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE===`false`?n.fallbackPlugin:{id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:n,keyPath:i,dictionaryKey:a,...c})=>{if(r.default.editor.enabled){let e=String(n??``),r=JSON.stringify(i??[]),l=String(a??``),u=`<intlayer-content-selector-wrapper key-path="${o(r)}" dictionary-key="${o(l)}">${s(e)}</intlayer-content-selector-wrapper>`;return t.renderIntlayerNode({...c,value:n,children:u,keyPath:i,dictionaryKey:a,additionalProps:{toElement:()=>{let t=document.createElement(`intlayer-content-selector-wrapper`);return t.setAttribute(`key-path`,r),t.setAttribute(`dictionary-key`,l),t.textContent=e,t}}})}return t.renderIntlayerNode({...c,value:n,children:n})}},l=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?n.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.INSERTION,transform:(e,t,r)=>{let i=[...t.keyPath,{type:a.INSERTION}],o=e[a.INSERTION],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,r,i)=>{let a=i(e,{...r,children:e,plugins:(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)});return e=>{let o=(0,n.splitInsertionTemplate)(a,e),s=o.isSimple?o.parts:o.parts.join(``);return i(s,{...r,plugins:t.plugins,children:s})}}},c=r(o,{...t,children:o,keyPath:i,plugins:[s,...t.plugins??[]]});return typeof o==`object`&&o&&`nodeType`in o&&[a.ENUMERATION,a.CONDITION].includes(o.nodeType)?e=>t=>{let n=c(t);return typeof n==`function`?n(e):n}:c}},u={createElement:(e,t,...n)=>{let r=Object.entries(t||{}).filter(([e])=>e!==`children`&&e!==`key`&&e!==`_innerHTML`).map(([e,t])=>`${e}="${t}"`).join(` `),i=t?._innerHTML,a=i===void 0?n.flat(1/0).join(``):i;return`<${e}${r?` ${r}`:``}>${a}</${e}>`},normalizeProps:(e,t)=>{let n={};for(let[e,r]of Object.entries(t))e===`className`?n.class=r:e===`htmlFor`?n.for=r:e===`dangerouslySetInnerHTML`&&r?.__html?n._innerHTML=r.__html:n[e]=r;return n}},d=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?n.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let{plugins:a,...o}=n,s=r((0,i.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:e})}],dictionaryKey:o.dictionaryKey,keyPath:[]}),c=(t={})=>(0,i.compileWithOptions)(e,{...u,createElement:(e,n,...r)=>{let i=t[e];return typeof i==`function`?i({...n,children:r.join(``)}):u.createElement(e,n,...r)}},{});return t.renderIntlayerNode({...n,value:c(),children:e,additionalProps:{metadata:s,use:e=>c(e)}})}},f=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?n.fallbackPlugin:{id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:a.MARKDOWN}],i=e[a.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[d,...t.plugins??[]]})}},p=process.env.INTLAYER_NODE_TYPE_HTML===`false`?n.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===a.HTML,transform:(e,r)=>{let i=e[a.HTML],o=(e={})=>{let t=(0,n.getHTML)(i,new Proxy(e,{get(e,t){if(typeof t==`string`&&t in e){let n=e[t];return e=>{let t=Array.isArray(e.children)?e.children.join(``):e.children;return n({...e,children:t})}}if(typeof t==`string`&&/^[a-z][a-z0-9]*$/.test(t))return e=>{let n=Object.entries(e).filter(([e])=>e!==`children`&&e!==`key`).map(([e,t])=>`${e}="${t}"`).join(` `),r=Array.isArray(e.children)?e.children.join(``):e.children;return`<${t}${n?` ${n}`:``}>${r}</${t}>`}}}));return Array.isArray(t)?t.join(``):t};return t.renderIntlayerNode({...r,value:o(),children:i,additionalProps:{use:e=>o(e)}})}},m=(e,t=!0)=>[(0,n.translationPlugin)(e??r.default.internationalization.defaultLocale,t?r.default.internationalization.defaultLocale:void 0),n.enumerationPlugin,n.conditionPlugin,(0,n.nestedPlugin)(e??r.default.internationalization.defaultLocale),n.filePlugin,n.genderPlugin,c,l,f,p].filter(Boolean);exports.getPlugins=m,exports.htmlPlugin=p,exports.insertionPlugin=l,exports.intlayerNodePlugins=c,exports.markdownPlugin=f,exports.markdownStringPlugin=d;
@@ -1,15 +1,15 @@
1
1
  import { renderIntlayerNode as e } from "./renderIntlayerNode.mjs";
2
- import { conditionPlugin as t, enumerationPlugin as n, filePlugin as r, genderPlugin as i, getHTML as a, nestedPlugin as o, splitInsertionTemplate as s, translationPlugin as c } from "@intlayer/core/interpreter";
3
- import l from "@intlayer/config/built";
4
- import { compileWithOptions as u, getMarkdownMetadata as d } from "@intlayer/core/markdown";
5
- import * as f from "@intlayer/types/nodeType";
2
+ import { conditionPlugin as t, enumerationPlugin as n, fallbackPlugin as r, filePlugin as i, genderPlugin as a, getHTML as o, nestedPlugin as s, splitInsertionTemplate as c, translationPlugin as l } from "@intlayer/core/interpreter";
3
+ import u from "@intlayer/config/built";
4
+ import { compileWithOptions as d, getMarkdownMetadata as f } from "@intlayer/core/markdown";
5
+ import * as p from "@intlayer/types/nodeType";
6
6
  //#region src/plugins.ts
7
- var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), h = {
7
+ var m = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), h = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), g = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? r : {
8
8
  id: "intlayer-node-plugin",
9
9
  canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
10
10
  transform: (t, { children: n, keyPath: r, dictionaryKey: i, ...a }) => {
11
- if (l.editor.enabled) {
12
- let t = String(n ?? ""), o = JSON.stringify(r ?? []), s = String(i ?? ""), c = `<intlayer-content-selector-wrapper key-path="${p(o)}" dictionary-key="${p(s)}">${m(t)}</intlayer-content-selector-wrapper>`;
11
+ if (u.editor.enabled) {
12
+ let t = String(n ?? ""), o = JSON.stringify(r ?? []), s = String(i ?? ""), c = `<intlayer-content-selector-wrapper key-path="${m(o)}" dictionary-key="${m(s)}">${h(t)}</intlayer-content-selector-wrapper>`;
13
13
  return e({
14
14
  ...a,
15
15
  value: n,
@@ -28,11 +28,11 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
28
28
  children: n
29
29
  });
30
30
  }
31
- }, g = {
31
+ }, _ = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? r : {
32
32
  id: "insertion-plugin",
33
- canHandle: (e) => typeof e == "object" && e?.nodeType === f.INSERTION,
33
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.INSERTION,
34
34
  transform: (e, t, n) => {
35
- let r = [...t.keyPath, { type: f.INSERTION }], i = e[f.INSERTION], a = {
35
+ let r = [...t.keyPath, { type: p.INSERTION }], i = e[p.INSERTION], a = {
36
36
  id: "insertion-string-plugin",
37
37
  canHandle: (e) => typeof e == "string",
38
38
  transform: (e, n, r) => {
@@ -42,7 +42,7 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
42
42
  plugins: (t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")
43
43
  });
44
44
  return (e) => {
45
- let a = s(i, e), o = a.isSimple ? a.parts : a.parts.join("");
45
+ let a = c(i, e), o = a.isSimple ? a.parts : a.parts.join("");
46
46
  return r(o, {
47
47
  ...n,
48
48
  plugins: t.plugins,
@@ -56,12 +56,12 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
56
56
  keyPath: r,
57
57
  plugins: [a, ...t.plugins ?? []]
58
58
  });
59
- return typeof i == "object" && i && "nodeType" in i && [f.ENUMERATION, f.CONDITION].includes(i.nodeType) ? (e) => (t) => {
59
+ return typeof i == "object" && i && "nodeType" in i && [p.ENUMERATION, p.CONDITION].includes(i.nodeType) ? (e) => (t) => {
60
60
  let n = o(t);
61
61
  return typeof n == "function" ? n(e) : n;
62
62
  } : o;
63
63
  }
64
- }, _ = {
64
+ }, v = {
65
65
  createElement: (e, t, ...n) => {
66
66
  let r = Object.entries(t || {}).filter(([e]) => e !== "children" && e !== "key" && e !== "_innerHTML").map(([e, t]) => `${e}="${t}"`).join(" "), i = t?._innerHTML, a = i === void 0 ? n.flat(Infinity).join("") : i;
67
67
  return `<${e}${r ? ` ${r}` : ""}>${a}</${e}>`;
@@ -71,11 +71,11 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
71
71
  for (let [e, r] of Object.entries(t)) e === "className" ? n.class = r : e === "htmlFor" ? n.for = r : e === "dangerouslySetInnerHTML" && r?.__html ? n._innerHTML = r.__html : n[e] = r;
72
72
  return n;
73
73
  }
74
- }, v = {
74
+ }, y = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? r : {
75
75
  id: "markdown-string-plugin",
76
76
  canHandle: (e) => typeof e == "string",
77
77
  transform: (t, n, r) => {
78
- let { plugins: i, ...a } = n, o = r(d(t) ?? {}, {
78
+ let { plugins: i, ...a } = n, o = r(f(t) ?? {}, {
79
79
  plugins: [{
80
80
  id: "markdown-metadata-plugin",
81
81
  canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
@@ -87,14 +87,14 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
87
87
  }],
88
88
  dictionaryKey: a.dictionaryKey,
89
89
  keyPath: []
90
- }), s = (e = {}) => u(t, {
91
- ..._,
90
+ }), s = (e = {}) => d(t, {
91
+ ...v,
92
92
  createElement: (t, n, ...r) => {
93
93
  let i = e[t];
94
94
  return typeof i == "function" ? i({
95
95
  ...n,
96
96
  children: r.join("")
97
- }) : _.createElement(t, n, ...r);
97
+ }) : v.createElement(t, n, ...r);
98
98
  }
99
99
  }, {});
100
100
  return e({
@@ -107,24 +107,24 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
107
107
  }
108
108
  });
109
109
  }
110
- }, y = {
110
+ }, b = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? r : {
111
111
  id: "markdown-plugin",
112
- canHandle: (e) => typeof e == "object" && e?.nodeType === f.MARKDOWN,
112
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.MARKDOWN,
113
113
  transform: (e, t, n) => {
114
- let r = [...t.keyPath, { type: f.MARKDOWN }], i = e[f.MARKDOWN];
114
+ let r = [...t.keyPath, { type: p.MARKDOWN }], i = e[p.MARKDOWN];
115
115
  return n(i, {
116
116
  ...t,
117
117
  children: i,
118
118
  keyPath: r,
119
- plugins: [v, ...t.plugins ?? []]
119
+ plugins: [y, ...t.plugins ?? []]
120
120
  });
121
121
  }
122
- }, b = {
122
+ }, x = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? r : {
123
123
  id: "html-plugin",
124
- canHandle: (e) => typeof e == "object" && e?.nodeType === f.HTML,
124
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.HTML,
125
125
  transform: (t, n) => {
126
- let r = t[f.HTML], i = (e = {}) => {
127
- let t = a(r, new Proxy(e, { get(e, t) {
126
+ let r = t[p.HTML], i = (e = {}) => {
127
+ let t = o(r, new Proxy(e, { get(e, t) {
128
128
  if (typeof t == "string" && t in e) {
129
129
  let n = e[t];
130
130
  return (e) => {
@@ -149,17 +149,17 @@ var p = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), m = (e) => e.re
149
149
  additionalProps: { use: (e) => i(e) }
150
150
  });
151
151
  }
152
- }, x = (e, a = !0) => [
153
- c(e ?? l.internationalization.defaultLocale, a ? l.internationalization.defaultLocale : void 0),
152
+ }, S = (e, r = !0) => [
153
+ l(e ?? u.internationalization.defaultLocale, r ? u.internationalization.defaultLocale : void 0),
154
154
  n,
155
155
  t,
156
- o(e ?? l.internationalization.defaultLocale),
157
- r,
156
+ s(e ?? u.internationalization.defaultLocale),
158
157
  i,
159
- h,
158
+ a,
160
159
  g,
161
- y,
162
- b
163
- ];
160
+ _,
161
+ b,
162
+ x
163
+ ].filter(Boolean);
164
164
  //#endregion
165
- export { x as getPlugins, b as htmlPlugin, g as insertionPlugin, h as intlayerNodePlugins, y as markdownPlugin, v as markdownStringPlugin };
165
+ export { S as getPlugins, x as htmlPlugin, _ as insertionPlugin, g as intlayerNodePlugins, b as markdownPlugin, y as markdownStringPlugin };
@@ -64,4 +64,8 @@ export type IInterpreterPluginState = Omit<IInterpreterPluginStateCore, 'inserti
64
64
  vanillaHtml: true;
65
65
  };
66
66
  export type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContentCore<T, IInterpreterPluginState, L>;
67
+ /**
68
+ * Get the plugins array for Vanilla content transformation.
69
+ * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
70
+ */
67
71
  export declare const getPlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-intlayer",
3
- "version": "8.6.0",
3
+ "version": "8.6.1",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vanilla JS, HTML, and PHP applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -101,11 +101,11 @@
101
101
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
102
102
  },
103
103
  "dependencies": {
104
- "@intlayer/api": "8.6.0",
105
- "@intlayer/config": "8.6.0",
106
- "@intlayer/core": "8.6.0",
107
- "@intlayer/editor": "8.6.0",
108
- "@intlayer/types": "8.6.0"
104
+ "@intlayer/api": "8.6.1",
105
+ "@intlayer/config": "8.6.1",
106
+ "@intlayer/core": "8.6.1",
107
+ "@intlayer/editor": "8.6.1",
108
+ "@intlayer/types": "8.6.1"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@types/node": "25.5.0",
@@ -121,7 +121,7 @@
121
121
  "vitest": "4.1.2"
122
122
  },
123
123
  "peerDependencies": {
124
- "intlayer": "8.6.0"
124
+ "intlayer": "8.6.1"
125
125
  },
126
126
  "peerDependenciesMeta": {
127
127
  "intlayer": {