vue-intlayer 9.5.8 → 9.5.9-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/esm/plugins.mjs +35 -35
- package/package.json +1 -1
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./analytics/exposureSink.cjs"),l=require("./html/HTMLRenderer.cjs"),u=require("./markdown/installIntlayerMarkdown.cjs"),d=require("./renderIntlayerNode.cjs");let f=require("@intlayer/config/built"),p=require("vue"),m=require("@intlayer/core/interpreter"),h=require("@intlayer/core/markdown"),g=require("@intlayer/types/nodeType");g=s(g);var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,p.defineAsyncComponent)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs"))),v={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:t,...n})=>{process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&c.reportExposure({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath,locale:n.locale,nodeType:`text`});let r=e=>d.renderIntlayerNode({...n,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?()=>(0,p.h)(_,{dictionaryKey:n.dictionaryKey,keyPath:n.keyPath},{default:()=>typeof e==`function`?e():e}):e}),i=r(t);if(typeof t!=`function`)return i;let a=(...e)=>{let n=t(...e);return r(n)};Object.setPrototypeOf(a,Object.getPrototypeOf(i));for(let e of Object.getOwnPropertyNames(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}for(let e of Object.getOwnPropertySymbols(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}return(0,p.markRaw)(a)}},y=(e,t)=>{let n=new Map,r={};for(let[e,i]of Object.entries(t))typeof i==`string`||typeof i==`number`?r[e]=i:(n.set(e,i),r[e]=`__VNODE_${e}__`);let i=(0,m.splitInsertionTemplate)(e,r);if(n.size>0){let e=[];if(i.isSimple){let t=i.parts,r=0;for(let[i]of n){let a=`__VNODE_${i}__`,o=t.indexOf(a);o!==-1&&(o>r&&e.push(t.substring(r,o)),e.push(n.get(i)),r=o+a.length)}return r<t.length&&e.push(t.substring(r)),(0,p.h)(p.Fragment,null,...e)}return i.parts.forEach(t=>{if(typeof t==`string`){let r=t;for(let[t]of n){let i=`__VNODE_${t}__`,a=r.indexOf(i);a!==-1&&(a>0&&e.push(r.substring(0,a)),e.push(n.get(t)),r=r.substring(a+i.length))}r.length>0&&e.push(r)}else e.push(t)}),(0,p.h)(p.Fragment,null,...e)}return i.isSimple?i.parts:(0,p.h)(p.Fragment,null,i.parts)},b=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?m.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.INSERTION,transform:(e,t,n)=>{let r=[...t.keyPath,{type:g.INSERTION}],i=e[g.INSERTION],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`||(0,m.isInterpolableWrapperNode)(e),transform:(e,n,r)=>{if((0,m.isInterpolableWrapperNode)(e))return i=>(0,m.transformInterpolableNode)(e,i,n,t.plugins,r);let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=y(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./analytics/exposureSink.cjs"),l=require("./html/HTMLRenderer.cjs"),u=require("./markdown/installIntlayerMarkdown.cjs"),d=require("./renderIntlayerNode.cjs");let f=require("@intlayer/config/built"),p=require("vue"),m=require("@intlayer/core/interpreter"),h=require("@intlayer/core/markdown"),g=require("@intlayer/types/nodeType");g=s(g);var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,p.defineAsyncComponent)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs"))),v={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:t,...n})=>{process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&c.reportExposure({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath,locale:n.locale,nodeType:`text`});let r=e=>d.renderIntlayerNode({...n,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?()=>(0,p.h)(_,{dictionaryKey:n.dictionaryKey,keyPath:n.keyPath},{default:()=>typeof e==`function`?e():e}):e}),i=r(t);if(typeof t!=`function`)return i;let a=(...e)=>{let n=t(...e);return r(n)};Object.setPrototypeOf(a,Object.getPrototypeOf(i));for(let e of Object.getOwnPropertyNames(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}for(let e of Object.getOwnPropertySymbols(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}return(0,p.markRaw)(a)}},y=(e,t)=>{let n=new Map,r={};for(let[e,i]of Object.entries(t))typeof i==`string`||typeof i==`number`?r[e]=i:(n.set(e,i),r[e]=`__VNODE_${e}__`);let i=(0,m.splitInsertionTemplate)(e,r);if(n.size>0){let e=[];if(i.isSimple){let t=i.parts,r=0;for(let[i]of n){let a=`__VNODE_${i}__`,o=t.indexOf(a);o!==-1&&(o>r&&e.push(t.substring(r,o)),e.push(n.get(i)),r=o+a.length)}return r<t.length&&e.push(t.substring(r)),(0,p.h)(p.Fragment,null,...e)}return i.parts.forEach(t=>{if(typeof t==`string`){let r=t;for(let[t]of n){let i=`__VNODE_${t}__`,a=r.indexOf(i);a!==-1&&(a>0&&e.push(r.substring(0,a)),e.push(n.get(t)),r=r.substring(a+i.length))}r.length>0&&e.push(r)}else e.push(t)}),(0,p.h)(p.Fragment,null,...e)}return i.isSimple?i.parts:(0,p.h)(p.Fragment,null,i.parts)},b=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?m.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.INSERTION,transform:(e,t,n)=>{let r=[...t.keyPath,{type:g.INSERTION}],i=e[g.INSERTION],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`||(0,m.isInterpolableWrapperNode)(e),transform:(e,n,r)=>{if((0,m.isInterpolableWrapperNode)(e))return i=>(0,m.transformInterpolableNode)(e,i,n,t.plugins,r);let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=y(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return(0,m.resolveInsertedSelector)(i,o)}},x=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?m.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,t,n)=>{let{plugins:r,...i}=t,a=n((0,h.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>d.renderIntlayerNode({...n,value:t,children:e})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>d.renderIntlayerNode({...t,value:e,children:()=>{let{renderMarkdown:t,components:r}=u.useMarkdown(),a=t(e,void 0,{...r??{},...n??{}});return process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,p.h)(_,{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},{default:()=>a}):a},additionalProps:{metadata:a,use:e=>o(e)}});return o()}},S=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?m.fallbackPlugin:{id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:g.MARKDOWN}],i=e[g.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[x,...t.plugins??[]]})}},C=process.env.INTLAYER_NODE_TYPE_HTML===`false`?m.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.HTML,transform:(e,t)=>{let n=e[g.HTML];e.tags;let r=(e={})=>{let i=l.renderHTML(n,{components:e});return d.renderIntlayerNode({...t,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?()=>(0,p.h)(_,{dictionaryKey:t.dictionaryKey,keyPath:t.keyPath,...e},{default:()=>i}):i,additionalProps:{use:e=>r(e)}})};return r()}},w=new Map,T=(e,t=!0)=>{let n=`${e??f.internationalization.defaultLocale}_${t}`;if(w.has(n))return w.get(n);let r=[(0,m.translationPlugin)(e??f.internationalization.defaultLocale,t?f.internationalization.defaultLocale:void 0),m.enumerationPlugin,(0,m.pluralPlugin)(e??f.internationalization.defaultLocale),m.conditionPlugin,(0,m.nestedPlugin)(e??f.internationalization.defaultLocale),m.filePlugin,m.genderPlugin,m.selectPlugin,v,b,S,C];return w.set(n,r),r};exports.getPlugins=T,exports.htmlPlugin=C,exports.insertionPlugin=b,exports.intlayerNodePlugins=v,exports.markdownPlugin=S,exports.markdownStringPlugin=x;
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -4,11 +4,11 @@ import { useMarkdown as n } from "./markdown/installIntlayerMarkdown.mjs";
|
|
|
4
4
|
import { renderIntlayerNode as r } from "./renderIntlayerNode.mjs";
|
|
5
5
|
import { editor as i, internationalization as a } from "@intlayer/config/built";
|
|
6
6
|
import { Fragment as o, defineAsyncComponent as s, h as c, markRaw as l } from "vue";
|
|
7
|
-
import { conditionPlugin as u, enumerationPlugin as d, fallbackPlugin as f, filePlugin as p, genderPlugin as m, isInterpolableWrapperNode as h, nestedPlugin as g, pluralPlugin as _,
|
|
8
|
-
import { getMarkdownMetadata as
|
|
9
|
-
import * as
|
|
7
|
+
import { conditionPlugin as u, enumerationPlugin as d, fallbackPlugin as f, filePlugin as p, genderPlugin as m, isInterpolableWrapperNode as h, nestedPlugin as g, pluralPlugin as _, resolveInsertedSelector as v, selectPlugin as y, splitInsertionTemplate as b, transformInterpolableNode as x, translationPlugin as S } from "@intlayer/core/interpreter";
|
|
8
|
+
import { getMarkdownMetadata as C } from "@intlayer/core/markdown";
|
|
9
|
+
import * as w from "@intlayer/types/nodeType";
|
|
10
10
|
//#region src/plugins.ts
|
|
11
|
-
var
|
|
11
|
+
var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import("./editor/ContentSelector.mjs")), E = {
|
|
12
12
|
id: "intlayer-node-plugin",
|
|
13
13
|
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
14
14
|
transform: (t, { children: n, ...a }) => {
|
|
@@ -21,7 +21,7 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
21
21
|
let o = (e) => r({
|
|
22
22
|
...a,
|
|
23
23
|
value: e,
|
|
24
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? () => c(
|
|
24
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? () => c(T, {
|
|
25
25
|
dictionaryKey: a.dictionaryKey,
|
|
26
26
|
keyPath: a.keyPath
|
|
27
27
|
}, { default: () => typeof e == "function" ? e() : e }) : e
|
|
@@ -42,10 +42,10 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
42
42
|
}
|
|
43
43
|
return l(u);
|
|
44
44
|
}
|
|
45
|
-
},
|
|
45
|
+
}, D = (e, t) => {
|
|
46
46
|
let n = /* @__PURE__ */ new Map(), r = {};
|
|
47
47
|
for (let [e, i] of Object.entries(t)) typeof i == "string" || typeof i == "number" ? r[e] = i : (n.set(e, i), r[e] = `__VNODE_${e}__`);
|
|
48
|
-
let i =
|
|
48
|
+
let i = b(e, r);
|
|
49
49
|
if (n.size > 0) {
|
|
50
50
|
let e = [];
|
|
51
51
|
if (i.isSimple) {
|
|
@@ -68,22 +68,22 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
68
68
|
}), c(o, null, ...e);
|
|
69
69
|
}
|
|
70
70
|
return i.isSimple ? i.parts : c(o, null, i.parts);
|
|
71
|
-
},
|
|
71
|
+
}, O = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? f : {
|
|
72
72
|
id: "insertion-plugin",
|
|
73
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
73
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === w.INSERTION,
|
|
74
74
|
transform: (e, t, n) => {
|
|
75
|
-
let r = [...t.keyPath, { type:
|
|
75
|
+
let r = [...t.keyPath, { type: w.INSERTION }], i = e[w.INSERTION], a = {
|
|
76
76
|
id: "insertion-string-plugin",
|
|
77
77
|
canHandle: (e) => typeof e == "string" || h(e),
|
|
78
78
|
transform: (e, n, r) => {
|
|
79
|
-
if (h(e)) return (i) =>
|
|
79
|
+
if (h(e)) return (i) => x(e, i, n, t.plugins, r);
|
|
80
80
|
let i = r(e, {
|
|
81
81
|
...n,
|
|
82
82
|
children: e,
|
|
83
83
|
plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
|
|
84
84
|
});
|
|
85
85
|
return (e) => {
|
|
86
|
-
let a =
|
|
86
|
+
let a = D(i, e);
|
|
87
87
|
return r(a, {
|
|
88
88
|
...n,
|
|
89
89
|
plugins: t.plugins,
|
|
@@ -91,19 +91,19 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
}
|
|
95
|
-
return n(i, {
|
|
94
|
+
}, o = n(i, {
|
|
96
95
|
...t,
|
|
97
96
|
children: i,
|
|
98
97
|
keyPath: r,
|
|
99
98
|
plugins: [a, ...t.plugins ?? []]
|
|
100
99
|
});
|
|
100
|
+
return v(i, o);
|
|
101
101
|
}
|
|
102
|
-
},
|
|
102
|
+
}, k = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? f : {
|
|
103
103
|
id: "markdown-string-plugin",
|
|
104
104
|
canHandle: (e) => typeof e == "string",
|
|
105
105
|
transform: (e, t, a) => {
|
|
106
|
-
let { plugins: o, ...s } = t, l = a(
|
|
106
|
+
let { plugins: o, ...s } = t, l = a(C(e) ?? {}, {
|
|
107
107
|
plugins: [{
|
|
108
108
|
id: "markdown-metadata-plugin",
|
|
109
109
|
canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
|
|
@@ -123,7 +123,7 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
123
123
|
...r ?? {},
|
|
124
124
|
...a ?? {}
|
|
125
125
|
});
|
|
126
|
-
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? c(
|
|
126
|
+
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? c(T, {
|
|
127
127
|
dictionaryKey: s.dictionaryKey,
|
|
128
128
|
keyPath: s.keyPath
|
|
129
129
|
}, { default: () => o }) : o;
|
|
@@ -135,30 +135,30 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
135
135
|
});
|
|
136
136
|
return u();
|
|
137
137
|
}
|
|
138
|
-
},
|
|
138
|
+
}, A = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? f : {
|
|
139
139
|
id: "markdown-plugin",
|
|
140
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
140
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === w.MARKDOWN,
|
|
141
141
|
transform: (e, t, n) => {
|
|
142
|
-
let r = [...t.keyPath, { type:
|
|
142
|
+
let r = [...t.keyPath, { type: w.MARKDOWN }], i = e[w.MARKDOWN];
|
|
143
143
|
return n(i, {
|
|
144
144
|
...t,
|
|
145
145
|
children: i,
|
|
146
146
|
keyPath: r,
|
|
147
|
-
plugins: [
|
|
147
|
+
plugins: [k, ...t.plugins ?? []]
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, j = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? f : {
|
|
151
151
|
id: "html-plugin",
|
|
152
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
152
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === w.HTML,
|
|
153
153
|
transform: (e, n) => {
|
|
154
|
-
let a = e[
|
|
154
|
+
let a = e[w.HTML];
|
|
155
155
|
e.tags;
|
|
156
156
|
let o = (e = {}) => {
|
|
157
157
|
let s = t(a, { components: e });
|
|
158
158
|
return r({
|
|
159
159
|
...n,
|
|
160
160
|
value: a,
|
|
161
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? () => c(
|
|
161
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && i.enabled ? () => c(T, {
|
|
162
162
|
dictionaryKey: n.dictionaryKey,
|
|
163
163
|
keyPath: n.keyPath,
|
|
164
164
|
...e
|
|
@@ -168,24 +168,24 @@ var w = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : s(() => import(
|
|
|
168
168
|
};
|
|
169
169
|
return o();
|
|
170
170
|
}
|
|
171
|
-
},
|
|
171
|
+
}, M = /* @__PURE__ */ new Map(), N = (e, t = !0) => {
|
|
172
172
|
let n = `${e ?? a.defaultLocale}_${t}`;
|
|
173
|
-
if (
|
|
173
|
+
if (M.has(n)) return M.get(n);
|
|
174
174
|
let r = [
|
|
175
|
-
|
|
175
|
+
S(e ?? a.defaultLocale, t ? a.defaultLocale : void 0),
|
|
176
176
|
d,
|
|
177
177
|
_(e ?? a.defaultLocale),
|
|
178
178
|
u,
|
|
179
179
|
g(e ?? a.defaultLocale),
|
|
180
180
|
p,
|
|
181
181
|
m,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
y,
|
|
183
|
+
E,
|
|
184
|
+
O,
|
|
185
|
+
A,
|
|
186
|
+
j
|
|
187
187
|
];
|
|
188
|
-
return
|
|
188
|
+
return M.set(n, r), r;
|
|
189
189
|
};
|
|
190
190
|
//#endregion
|
|
191
|
-
export {
|
|
191
|
+
export { N as getPlugins, j as htmlPlugin, O as insertionPlugin, E as intlayerNodePlugins, A as markdownPlugin, k as markdownStringPlugin };
|