lit-intlayer 9.9.1 → 9.9.2
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/client/IntlayerBinding.cjs +1 -1
- package/dist/cjs/client/index.cjs +1 -1
- package/dist/cjs/client/installIntlayer.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/format/useCompact.cjs +1 -1
- package/dist/cjs/format/useCurrency.cjs +1 -1
- package/dist/cjs/format/useDate.cjs +1 -1
- package/dist/cjs/format/useIntl.cjs +1 -1
- package/dist/cjs/format/useList.cjs +1 -1
- package/dist/cjs/format/useNumber.cjs +1 -1
- package/dist/cjs/format/usePercentage.cjs +1 -1
- package/dist/cjs/format/useRelativeTime.cjs +1 -1
- package/dist/cjs/format/useUnit.cjs +1 -1
- package/dist/cjs/getDictionary.cjs +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
- package/dist/cjs/markdown/compiler.cjs +1 -1
- package/dist/cjs/plugins.cjs +3 -3
- package/dist/esm/client/IntlayerBinding.mjs +7 -7
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs +5 -5
- package/dist/esm/client/useDictionaryDynamic.mjs +6 -6
- package/dist/esm/client/useIntlayer.mjs +5 -5
- package/dist/esm/client/useLocale.mjs +14 -14
- package/dist/esm/client/useRewriteURL.mjs +8 -8
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/format/useCompact.mjs +10 -10
- package/dist/esm/format/useCurrency.mjs +10 -10
- package/dist/esm/format/useDate.mjs +15 -15
- package/dist/esm/format/useIntl.mjs +7 -7
- package/dist/esm/format/useList.mjs +10 -10
- package/dist/esm/format/useNumber.mjs +10 -10
- package/dist/esm/format/usePercentage.mjs +10 -10
- package/dist/esm/format/useRelativeTime.mjs +10 -10
- package/dist/esm/format/useUnit.mjs +10 -10
- package/dist/esm/getDictionary.mjs +3 -3
- package/dist/esm/getIntlayer.mjs +3 -3
- package/dist/esm/html/HTMLRenderer.mjs +9 -9
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +13 -13
- package/dist/esm/markdown/compiler.mjs +10 -10
- package/dist/esm/markdown/runtime.mjs +1 -1
- package/dist/esm/plugins.mjs +62 -62
- package/dist/{installIntlayer-Btnci_ES.js → installIntlayer-CFvvijL7.js} +1 -1
- package/dist/{installIntlayer-Dvl7Prhw.mjs → installIntlayer-CTpPd7yz.mjs} +15 -15
- package/package.json +9 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { number as e } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
|
|
3
3
|
// src/format/useNumber.ts
|
|
4
4
|
var n = class {
|
|
5
5
|
host;
|
|
@@ -7,18 +7,18 @@ var n = class {
|
|
|
7
7
|
value;
|
|
8
8
|
constructor(n) {
|
|
9
9
|
this.host = n;
|
|
10
|
-
let r =
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
10
|
+
let r = t();
|
|
11
|
+
this.value = (...t) => e(t[0], {
|
|
12
|
+
...t[1],
|
|
13
|
+
locale: t[1]?.locale ?? r.locale
|
|
14
14
|
}), n.addController(this);
|
|
15
15
|
}
|
|
16
16
|
hostConnected() {
|
|
17
|
-
let n =
|
|
18
|
-
this._unsubscribe = n.subscribe((
|
|
19
|
-
this.value = (...n) =>
|
|
17
|
+
let n = t();
|
|
18
|
+
this._unsubscribe = n.subscribe((t) => {
|
|
19
|
+
this.value = (...n) => e(n[0], {
|
|
20
20
|
...n[1],
|
|
21
|
-
locale: n[1]?.locale ??
|
|
21
|
+
locale: n[1]?.locale ?? t
|
|
22
22
|
}), this.host.requestUpdate();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { percentage as e } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
|
|
3
3
|
// src/format/usePercentage.ts
|
|
4
4
|
var n = class {
|
|
5
5
|
host;
|
|
@@ -7,18 +7,18 @@ var n = class {
|
|
|
7
7
|
value;
|
|
8
8
|
constructor(n) {
|
|
9
9
|
this.host = n;
|
|
10
|
-
let r =
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
10
|
+
let r = t();
|
|
11
|
+
this.value = (...t) => e(t[0], {
|
|
12
|
+
...t[1],
|
|
13
|
+
locale: t[1]?.locale ?? r.locale
|
|
14
14
|
}), n.addController(this);
|
|
15
15
|
}
|
|
16
16
|
hostConnected() {
|
|
17
|
-
let n =
|
|
18
|
-
this._unsubscribe = n.subscribe((
|
|
19
|
-
this.value = (...n) =>
|
|
17
|
+
let n = t();
|
|
18
|
+
this._unsubscribe = n.subscribe((t) => {
|
|
19
|
+
this.value = (...n) => e(n[0], {
|
|
20
20
|
...n[1],
|
|
21
|
-
locale: n[1]?.locale ??
|
|
21
|
+
locale: n[1]?.locale ?? t
|
|
22
22
|
}), this.host.requestUpdate();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { relativeTime as e } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
|
|
3
3
|
// src/format/useRelativeTime.ts
|
|
4
4
|
var n = class {
|
|
5
5
|
host;
|
|
@@ -7,18 +7,18 @@ var n = class {
|
|
|
7
7
|
value;
|
|
8
8
|
constructor(n) {
|
|
9
9
|
this.host = n;
|
|
10
|
-
let r =
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
10
|
+
let r = t();
|
|
11
|
+
this.value = (...t) => e(t[0], t[1], {
|
|
12
|
+
...t[2],
|
|
13
|
+
locale: t[2]?.locale ?? r.locale
|
|
14
14
|
}), n.addController(this);
|
|
15
15
|
}
|
|
16
16
|
hostConnected() {
|
|
17
|
-
let n =
|
|
18
|
-
this._unsubscribe = n.subscribe((
|
|
19
|
-
this.value = (...n) =>
|
|
17
|
+
let n = t();
|
|
18
|
+
this._unsubscribe = n.subscribe((t) => {
|
|
19
|
+
this.value = (...n) => e(n[0], n[1], {
|
|
20
20
|
...n[2],
|
|
21
|
-
locale: n[2]?.locale ??
|
|
21
|
+
locale: n[2]?.locale ?? t
|
|
22
22
|
}), this.host.requestUpdate();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { units as e } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
|
|
3
3
|
// src/format/useUnit.ts
|
|
4
4
|
var n = class {
|
|
5
5
|
host;
|
|
@@ -7,18 +7,18 @@ var n = class {
|
|
|
7
7
|
value;
|
|
8
8
|
constructor(n) {
|
|
9
9
|
this.host = n;
|
|
10
|
-
let r =
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
10
|
+
let r = t();
|
|
11
|
+
this.value = (...t) => e(t[0], {
|
|
12
|
+
...t[1],
|
|
13
|
+
locale: t[1]?.locale ?? r.locale
|
|
14
14
|
}), n.addController(this);
|
|
15
15
|
}
|
|
16
16
|
hostConnected() {
|
|
17
|
-
let n =
|
|
18
|
-
this._unsubscribe = n.subscribe((
|
|
19
|
-
this.value = (...n) =>
|
|
17
|
+
let n = t();
|
|
18
|
+
this._unsubscribe = n.subscribe((t) => {
|
|
19
|
+
this.value = (...n) => e(n[0], {
|
|
20
20
|
...n[1],
|
|
21
|
-
locale: n[1]?.locale ??
|
|
21
|
+
locale: n[1]?.locale ?? t
|
|
22
22
|
}), this.host.requestUpdate();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getDictionary as e } from "@intlayer/core/interpreter";
|
|
2
|
+
import { getPlugins as t } from "./plugins.mjs";
|
|
3
3
|
// src/getDictionary.ts
|
|
4
4
|
var n = (n, r) => {
|
|
5
5
|
let i = typeof r == "object" && r ? r.locale : r;
|
|
6
|
-
return
|
|
6
|
+
return e(n, r, t(i));
|
|
7
7
|
};
|
|
8
8
|
export { n as getDictionary };
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getIntlayer as e } from "@intlayer/core/interpreter";
|
|
2
|
+
import { getPlugins as t } from "./plugins.mjs";
|
|
3
3
|
// src/getIntlayer.ts
|
|
4
4
|
var n = (n, r) => {
|
|
5
5
|
let i = typeof r == "object" && r ? r.locale : r;
|
|
6
|
-
return
|
|
6
|
+
return e(n, r, t(i));
|
|
7
7
|
};
|
|
8
8
|
export { n as getIntlayer };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { unsafeHTML as
|
|
3
|
-
import {
|
|
1
|
+
import { LitElement as e, html as t, nothing as n } from "lit";
|
|
2
|
+
import { unsafeHTML as r } from "lit/directives/unsafe-html.js";
|
|
3
|
+
import { useHTML as i } from "./installIntlayerHTML.mjs";
|
|
4
4
|
// src/html/HTMLRenderer.ts
|
|
5
|
-
var a = (e, t = {}) => e, o = ({ components:
|
|
6
|
-
let
|
|
7
|
-
return (
|
|
8
|
-
}, s = class extends
|
|
5
|
+
var a = (e, t = {}) => e, o = ({ components: e } = {}) => {
|
|
6
|
+
let t = i();
|
|
7
|
+
return (n) => t.renderHTML(n, { components: e });
|
|
8
|
+
}, s = class extends e {
|
|
9
9
|
static properties = {
|
|
10
10
|
content: { type: String },
|
|
11
11
|
components: { attribute: !1 }
|
|
@@ -16,9 +16,9 @@ var a = (e, t = {}) => e, o = ({ components: t } = {}) => {
|
|
|
16
16
|
return this;
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
if (!this.content) return
|
|
19
|
+
if (!this.content) return n;
|
|
20
20
|
let e = o({ components: this.components });
|
|
21
|
-
return
|
|
21
|
+
return t`${r(e(this.content))}`;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
customElements.get("intlayer-html-renderer") || customElements.define("intlayer-html-renderer", s);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocaleInStorage as e, localeCookie as t, localeInStorage as n, setLocaleCookie as r, setLocaleInStorage as i, useLocaleCookie as a, useLocaleStorage as o } from "./client/useLocaleStorage.mjs";
|
|
2
|
-
import { a as s, i as c, n as l, r as u, t as d } from "../installIntlayer-
|
|
2
|
+
import { a as s, i as c, n as l, r as u, t as d } from "../installIntlayer-CTpPd7yz.mjs";
|
|
3
3
|
import { getDictionary as f } from "./getDictionary.mjs";
|
|
4
4
|
import { getIntlayer as p } from "./getIntlayer.mjs";
|
|
5
5
|
import { IntlayerBinding as m, createContentProxy as h } from "./client/IntlayerBinding.mjs";
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { LitElement as e, html as t, nothing as n } from "lit";
|
|
2
|
+
import { unsafeHTML as r } from "lit/directives/unsafe-html.js";
|
|
3
|
+
import { compileMarkdown as i } from "./compiler.mjs";
|
|
4
|
+
import { useMarkdown as a } from "./installIntlayerMarkdown.mjs";
|
|
5
5
|
// src/markdown/MarkdownRenderer.ts
|
|
6
|
-
var o = (
|
|
7
|
-
forceBlock:
|
|
8
|
-
forceInline:
|
|
9
|
-
preserveFrontmatter:
|
|
6
|
+
var o = (e, { forceBlock: t, forceInline: n, preserveFrontmatter: r, tagfilter: a } = {}) => i(e, {
|
|
7
|
+
forceBlock: t,
|
|
8
|
+
forceInline: n,
|
|
9
|
+
preserveFrontmatter: r,
|
|
10
10
|
tagfilter: a
|
|
11
11
|
}), s = (e = {}) => {
|
|
12
|
-
let
|
|
13
|
-
return (
|
|
12
|
+
let t = a();
|
|
13
|
+
return (n) => t.renderMarkdown(n, {
|
|
14
14
|
forceBlock: e.forceBlock,
|
|
15
15
|
forceInline: e.forceInline,
|
|
16
16
|
preserveFrontmatter: e.preserveFrontmatter,
|
|
17
17
|
tagfilter: e.tagfilter
|
|
18
18
|
}, e.components, e.wrapper);
|
|
19
|
-
}, c = class extends
|
|
19
|
+
}, c = class extends e {
|
|
20
20
|
static properties = {
|
|
21
21
|
content: { type: [String, Object] },
|
|
22
22
|
forceBlock: { type: Boolean },
|
|
@@ -35,7 +35,7 @@ var o = (t, { forceBlock: n, forceInline: r, preserveFrontmatter: i, tagfilter:
|
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
if (!this.content) return
|
|
38
|
+
if (!this.content) return n;
|
|
39
39
|
let e;
|
|
40
40
|
return e = this.renderMarkdownFn ? this.renderMarkdownFn(this.content, {
|
|
41
41
|
forceBlock: this.forceBlock,
|
|
@@ -47,7 +47,7 @@ var o = (t, { forceBlock: n, forceInline: r, preserveFrontmatter: i, tagfilter:
|
|
|
47
47
|
forceInline: this.forceInline,
|
|
48
48
|
preserveFrontmatter: this.preserveFrontmatter,
|
|
49
49
|
tagfilter: this.tagfilter
|
|
50
|
-
})(this.content),
|
|
50
|
+
})(this.content), t`${r(e)}`;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
customElements.get("intlayer-markdown-renderer") || customElements.define("intlayer-markdown-renderer", c);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
1
|
+
import { compileWithOptions as e, parseMarkdown as t, renderMarkdownAst as n } from "@intlayer/core/markdown";
|
|
2
|
+
import r from "./runtime.mjs";
|
|
3
3
|
// src/markdown/compiler.ts
|
|
4
|
-
var i = (
|
|
5
|
-
let { components: i, namedCodesToUnicode: a, sanitizer: o, slugify: s, ...c } =
|
|
6
|
-
return
|
|
7
|
-
runtime:
|
|
4
|
+
var i = (e = "", n = {}) => {
|
|
5
|
+
let { components: i, namedCodesToUnicode: a, sanitizer: o, slugify: s, ...c } = n;
|
|
6
|
+
return t(e, {
|
|
7
|
+
runtime: r,
|
|
8
8
|
components: i,
|
|
9
9
|
namedCodesToUnicode: a,
|
|
10
10
|
sanitizer: o,
|
|
11
11
|
slugify: s
|
|
12
12
|
}, c);
|
|
13
|
-
}, a = (
|
|
14
|
-
if (typeof
|
|
13
|
+
}, a = (t = "", i = {}) => {
|
|
14
|
+
if (typeof t == "string") return e(t, r, i);
|
|
15
15
|
let { components: a, namedCodesToUnicode: o, sanitizer: s, slugify: c, ...l } = i;
|
|
16
|
-
return
|
|
17
|
-
runtime:
|
|
16
|
+
return n(t, {
|
|
17
|
+
runtime: r,
|
|
18
18
|
components: a,
|
|
19
19
|
namedCodesToUnicode: o,
|
|
20
20
|
sanitizer: s,
|
|
@@ -16,7 +16,7 @@ var e = /* @__PURE__ */ new Set([
|
|
|
16
16
|
"wbr"
|
|
17
17
|
]), t = (e) => e ? Object.entries(e).filter(([e, t]) => t != null && e !== "key").map(([e, t]) => typeof t == "boolean" ? t ? e : "" : e === "_innerHTML" ? "" : `${e}="${String(t).replace(/&/g, "&").replace(/"/g, """)}"`).filter(Boolean).join(" ") : "", n = "__lit_fragment__", r = {
|
|
18
18
|
createElement: (r, i, ...a) => {
|
|
19
|
-
let o = a.flat(
|
|
19
|
+
let o = a.flat(1e400).join("");
|
|
20
20
|
if (r === n) return o;
|
|
21
21
|
if (typeof r == "string") {
|
|
22
22
|
let n = t(i), a = n ? ` ${n}` : "", s = i?._innerHTML;
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
1
|
+
import { editor as e, internationalization as t } from "@intlayer/config/built";
|
|
2
|
+
import { conditionPlugin as n, enumerationPlugin as r, fallbackPlugin as i, filePlugin as a, genderPlugin as o, getHTML as s, isInterpolableWrapperNode as c, nestedPlugin as l, pluralPlugin as u, resolveInsertedSelector as d, resolveInterpreterLocale as f, selectPlugin as p, splitInsertionTemplate as m, transformInterpolableNode as h, translationPlugin as g } from "@intlayer/core/interpreter";
|
|
3
|
+
import { compileWithOptions as _, getMarkdownMetadata as v } from "@intlayer/core/markdown";
|
|
4
|
+
import { getIntlayerNodePrototype as y } from "@intlayer/core/utils";
|
|
5
|
+
import * as b from "@intlayer/types/nodeType";
|
|
6
|
+
import { unsafeHTML as x } from "lit/directives/unsafe-html.js";
|
|
7
|
+
import { html as S, unsafeStatic as C } from "lit/static-html.js";
|
|
8
|
+
import { r as w } from "../installIntlayer-CTpPd7yz.mjs";
|
|
9
|
+
import T from "./markdown/runtime.mjs";
|
|
10
|
+
import { renderIntlayerNode as E } from "./renderIntlayerNode.mjs";
|
|
11
11
|
// src/plugins.ts
|
|
12
|
-
var D = (e = "",
|
|
13
|
-
let r = typeof e == "string" ?
|
|
12
|
+
var D = (e = "", t = {}) => _(e, T, t), O = (e, t, n = {}) => {
|
|
13
|
+
let r = typeof e == "string" ? x(e) : e, i = Array.isArray(r), a = Object.assign(i ? [...r] : { ...r }, n, {
|
|
14
14
|
value: t,
|
|
15
15
|
raw: t,
|
|
16
16
|
[Symbol.iterator]: void 0,
|
|
17
17
|
__update: () => {},
|
|
18
18
|
isJSX: !0
|
|
19
19
|
});
|
|
20
|
-
return Object.setPrototypeOf(a,
|
|
20
|
+
return Object.setPrototypeOf(a, y(t, i ? Array.prototype : Object.prototype));
|
|
21
21
|
}, k = (e) => e.replace(/&/g, "&").replace(/"/g, """), A = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), j = {
|
|
22
22
|
id: "intlayer-node-plugin",
|
|
23
23
|
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
24
|
-
transform: (
|
|
25
|
-
if (process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
26
|
-
let e = String(
|
|
24
|
+
transform: (t, { children: n, keyPath: r, dictionaryKey: i }) => {
|
|
25
|
+
if (process.env.INTLAYER_EDITOR_ENABLED !== "false" && e.enabled) {
|
|
26
|
+
let e = String(n ?? "");
|
|
27
27
|
return O(`<intlayer-content-selector-wrapper key-path="${k(JSON.stringify(r ?? []))}" dictionary-key="${k(String(i ?? ""))}">${A(e)}</intlayer-content-selector-wrapper>`, e);
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
value:
|
|
31
|
-
children:
|
|
29
|
+
return E({
|
|
30
|
+
value: n,
|
|
31
|
+
children: n
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
}, M = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ?
|
|
34
|
+
}, M = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? i : {
|
|
35
35
|
id: "insertion-plugin",
|
|
36
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
36
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === b.INSERTION,
|
|
37
37
|
transform: (e, t, n) => {
|
|
38
|
-
let r = [...t.keyPath, { type:
|
|
38
|
+
let r = [...t.keyPath, { type: b.INSERTION }], i = e[b.INSERTION], a = {
|
|
39
39
|
id: "insertion-string-plugin",
|
|
40
|
-
canHandle: (e) => typeof e == "string" ||
|
|
40
|
+
canHandle: (e) => typeof e == "string" || c(e),
|
|
41
41
|
transform: (e, n, r) => {
|
|
42
|
-
if (
|
|
42
|
+
if (c(e)) return (i) => h(e, i, n, t.plugins, r);
|
|
43
43
|
let i = r(e, {
|
|
44
44
|
...n,
|
|
45
45
|
children: e,
|
|
46
46
|
plugins: (t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")
|
|
47
47
|
});
|
|
48
48
|
return (e) => {
|
|
49
|
-
let a =
|
|
49
|
+
let a = m(i, e), o = a.isSimple ? a.parts : a.parts.join("");
|
|
50
50
|
return r(o, {
|
|
51
51
|
...n,
|
|
52
52
|
plugins: t.plugins,
|
|
@@ -60,41 +60,41 @@ var D = (e = "", n = {}) => b(e, t, n), O = (e, t, n = {}) => {
|
|
|
60
60
|
keyPath: r,
|
|
61
61
|
plugins: [a, ...t.plugins ?? []]
|
|
62
62
|
});
|
|
63
|
-
return
|
|
63
|
+
return d(i, o);
|
|
64
64
|
}
|
|
65
|
-
}, N = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ?
|
|
65
|
+
}, N = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? i : {
|
|
66
66
|
id: "markdown-string-plugin",
|
|
67
67
|
canHandle: (e) => typeof e == "string",
|
|
68
|
-
transform: (
|
|
69
|
-
let { plugins: i, ...a } =
|
|
68
|
+
transform: (t, n, r) => {
|
|
69
|
+
let { plugins: i, ...a } = n, { keyPath: o, dictionaryKey: s } = a, c = r(v(t) ?? {}, {
|
|
70
70
|
plugins: [{
|
|
71
71
|
id: "markdown-metadata-plugin",
|
|
72
72
|
canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
|
|
73
|
-
transform: (
|
|
74
|
-
...
|
|
75
|
-
value:
|
|
76
|
-
children:
|
|
73
|
+
transform: (e, n) => E({
|
|
74
|
+
...n,
|
|
75
|
+
value: e,
|
|
76
|
+
children: t
|
|
77
77
|
})
|
|
78
78
|
}],
|
|
79
79
|
dictionaryKey: a.dictionaryKey,
|
|
80
80
|
keyPath: []
|
|
81
|
-
}), l = D(
|
|
82
|
-
let
|
|
83
|
-
return process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
81
|
+
}), l = D(t), u = (n) => {
|
|
82
|
+
let r = D(t, { components: n });
|
|
83
|
+
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && e.enabled ? O(`<intlayer-content-selector-wrapper key-path="${k(JSON.stringify(o ?? []))}" dictionary-key="${k(String(s ?? ""))}">${r}</intlayer-content-selector-wrapper>`, t) : O(r, t);
|
|
84
84
|
};
|
|
85
|
-
return process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
85
|
+
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && e.enabled ? O(`<intlayer-content-selector-wrapper key-path="${k(JSON.stringify(o ?? []))}" dictionary-key="${k(String(s ?? ""))}">${l}</intlayer-content-selector-wrapper>`, t, {
|
|
86
86
|
metadata: c,
|
|
87
87
|
use: u
|
|
88
|
-
}) : O(l,
|
|
88
|
+
}) : O(l, t, {
|
|
89
89
|
metadata: c,
|
|
90
90
|
use: u
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
}, P = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ?
|
|
93
|
+
}, P = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? i : {
|
|
94
94
|
id: "markdown-plugin",
|
|
95
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
95
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === b.MARKDOWN,
|
|
96
96
|
transform: (e, t, n) => {
|
|
97
|
-
let r = [...t.keyPath, { type:
|
|
97
|
+
let r = [...t.keyPath, { type: b.MARKDOWN }], i = e[b.MARKDOWN];
|
|
98
98
|
return n(i, {
|
|
99
99
|
...t,
|
|
100
100
|
children: i,
|
|
@@ -102,38 +102,38 @@ var D = (e = "", n = {}) => b(e, t, n), O = (e, t, n = {}) => {
|
|
|
102
102
|
plugins: [N, ...t.plugins ?? []]
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
}, F = process.env.INTLAYER_NODE_TYPE_HTML === "false" ?
|
|
105
|
+
}, F = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? i : {
|
|
106
106
|
id: "html-plugin",
|
|
107
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
108
|
-
transform: (
|
|
109
|
-
let
|
|
110
|
-
let
|
|
107
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === b.HTML,
|
|
108
|
+
transform: (t, n) => {
|
|
109
|
+
let r = t[b.HTML], { keyPath: i, dictionaryKey: a } = n, o = (t = {}) => {
|
|
110
|
+
let n = Object.fromEntries(Object.entries(t).filter(([, e]) => e).map(([e, t]) => [e, (e) => t(e)])), o = new Proxy(n, { get(e, t) {
|
|
111
111
|
if (typeof t == "string" && t in e) return e[t];
|
|
112
|
-
if (typeof t == "string" && /^[a-z][a-z0-9]*$/.test(t)) return (e) =>
|
|
113
|
-
>${e.children}</${
|
|
112
|
+
if (typeof t == "string" && /^[a-z][a-z0-9]*$/.test(t)) return (e) => S`<${C(t)} ...${e}
|
|
113
|
+
>${e.children}</${C(t)}
|
|
114
114
|
>`;
|
|
115
|
-
} }),
|
|
116
|
-
return process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
115
|
+
} }), c = s(r, o);
|
|
116
|
+
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && e.enabled ? O(`<intlayer-content-selector-wrapper key-path="${k(JSON.stringify(i ?? []))}" dictionary-key="${k(String(a ?? ""))}">${c}</intlayer-content-selector-wrapper>`, r) : O(c, r);
|
|
117
117
|
};
|
|
118
|
-
return process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
118
|
+
return process.env.INTLAYER_EDITOR_ENABLED !== "false" && e.enabled ? O(`<intlayer-content-selector-wrapper key-path="${k(JSON.stringify(i ?? []))}" dictionary-key="${k(String(a ?? ""))}">${r}</intlayer-content-selector-wrapper>`, r, { use: o }) : O(r, r, { use: o });
|
|
119
119
|
}
|
|
120
|
-
}, I = /* @__PURE__ */ new Map(), L = (
|
|
121
|
-
let c =
|
|
122
|
-
if (I.has(
|
|
123
|
-
let
|
|
120
|
+
}, I = /* @__PURE__ */ new Map(), L = (e, s = !0) => {
|
|
121
|
+
let c = e ?? (typeof window < "u" && w()?.locale) ?? f(), d = `${c}_${s}`;
|
|
122
|
+
if (I.has(d)) return I.get(d);
|
|
123
|
+
let m = [
|
|
124
124
|
j,
|
|
125
|
-
|
|
126
|
-
i,
|
|
127
|
-
d(c),
|
|
125
|
+
g(c, s ? t.defaultLocale : void 0),
|
|
128
126
|
r,
|
|
129
127
|
u(c),
|
|
128
|
+
n,
|
|
129
|
+
l(c),
|
|
130
|
+
a,
|
|
130
131
|
o,
|
|
131
|
-
|
|
132
|
-
m,
|
|
132
|
+
p,
|
|
133
133
|
M,
|
|
134
134
|
P,
|
|
135
135
|
F
|
|
136
|
-
].filter((e) => e !==
|
|
137
|
-
return I.set(
|
|
136
|
+
].filter((e) => e !== i);
|
|
137
|
+
return I.set(d, m), m;
|
|
138
138
|
};
|
|
139
139
|
export { L as getPlugins, F as htmlPlugin, M as insertionPlugin, j as intlayerNodePlugins, P as markdownPlugin, N as markdownStringPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@intlayer/config/built"),t=require("@intlayer/config/client"),n=require("@intlayer/editor/isEnabled");const r=require("./cjs/client/useLocaleStorage.cjs");var i=e=>{let t=u();e.currentLocale.set(t.locale);let n=t.subscribe(t=>{e.currentLocale.set(t)}),i=e.onLocaleChangeRequested(e=>{t.setLocale(e),r.setLocaleInStorage(e,t.isCookieEnabled)});return()=>{n(),i()}},a=class{host;_stopped=!1;_unsubscribeLocale=null;constructor(e){this.host=e,e.addController(this)}hostConnected(){this._stopped=!1,process.env.INTLAYER_EDITOR_ENABLED!==`false`&&n.isEnabled&&import(`@intlayer/editor`).then(({initEditorClient:e})=>{this._stopped||(this._unsubscribeLocale=i(e()))}).catch(()=>{})}hostDisconnected(){this._stopped=!0,this._unsubscribeLocale?.(),this._unsubscribeLocale=null,import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()}).catch(()=>{})}};function o(e){if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return e?void 0:()=>{};if(!e){let e=!1,t=null;return import(`@intlayer/editor`).then(({initEditorClient:n})=>{e||(t=i(n()))}).catch(()=>{}),()=>{e=!0,t?.(),import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()}).catch(()=>{})}}new a(e)}var s=class{_locale;_variant;_listeners=new Set;isCookieEnabled;constructor(n,i=!0,a){let{defaultLocale:o}=e.internationalization??{};(0,t.setIntlayerIdentifier)(),this._locale=n??r.getLocaleInStorage()??o,this._variant=a,this.isCookieEnabled=i}get locale(){return this._locale}get variant(){return this._variant}setLocale(e){this._locale=e;for(let t of this._listeners)t(e)}setVariant(e){this._variant=e;for(let e of this._listeners)e(this._locale)}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}},c=null,l=(e,t=!0,n)=>c||(c=new s(e,t,n),c),u=()=>(c||=new s,c),d=({locale:e,isCookieEnabled:t,variant:n}={})=>{let r=l(e,t,n);return o(),r};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { internationalization as e } from "@intlayer/config/built";
|
|
2
|
+
import { setIntlayerIdentifier as t } from "@intlayer/config/client";
|
|
3
|
+
import { isEnabled as n } from "@intlayer/editor/isEnabled";
|
|
4
|
+
import { getLocaleInStorage as r, setLocaleInStorage as i } from "./esm/client/useLocaleStorage.mjs";
|
|
5
5
|
// src/editor/useEditor.ts
|
|
6
6
|
var a = (e) => {
|
|
7
|
-
let
|
|
8
|
-
e.currentLocale.set(
|
|
9
|
-
let
|
|
7
|
+
let t = d();
|
|
8
|
+
e.currentLocale.set(t.locale);
|
|
9
|
+
let n = t.subscribe((t) => {
|
|
10
10
|
e.currentLocale.set(t);
|
|
11
|
-
}),
|
|
12
|
-
|
|
11
|
+
}), r = e.onLocaleChangeRequested((e) => {
|
|
12
|
+
t.setLocale(e), i(e, t.isCookieEnabled);
|
|
13
13
|
});
|
|
14
14
|
return () => {
|
|
15
|
-
|
|
15
|
+
n(), r();
|
|
16
16
|
};
|
|
17
17
|
}, o = class {
|
|
18
18
|
host;
|
|
@@ -22,7 +22,7 @@ var a = (e) => {
|
|
|
22
22
|
this.host = e, e.addController(this);
|
|
23
23
|
}
|
|
24
24
|
hostConnected() {
|
|
25
|
-
this._stopped = !1, process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
25
|
+
this._stopped = !1, process.env.INTLAYER_EDITOR_ENABLED !== "false" && n && import("@intlayer/editor").then(({ initEditorClient: e }) => {
|
|
26
26
|
this._stopped || (this._unsubscribeLocale = a(e()));
|
|
27
27
|
}).catch(() => {});
|
|
28
28
|
}
|
|
@@ -33,7 +33,7 @@ var a = (e) => {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
function s(e) {
|
|
36
|
-
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !
|
|
36
|
+
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !n) return e ? void 0 : () => {};
|
|
37
37
|
if (!e) {
|
|
38
38
|
let e = !1, t = null;
|
|
39
39
|
return import("@intlayer/editor").then(({ initEditorClient: n }) => {
|
|
@@ -52,9 +52,9 @@ var c = class {
|
|
|
52
52
|
_variant;
|
|
53
53
|
_listeners = /* @__PURE__ */ new Set();
|
|
54
54
|
isCookieEnabled;
|
|
55
|
-
constructor(
|
|
56
|
-
let { defaultLocale: o } =
|
|
57
|
-
|
|
55
|
+
constructor(n, i = !0, a) {
|
|
56
|
+
let { defaultLocale: o } = e ?? {};
|
|
57
|
+
t(), this._locale = n ?? r() ?? o, this._variant = a, this.isCookieEnabled = i;
|
|
58
58
|
}
|
|
59
59
|
get locale() {
|
|
60
60
|
return this._locale;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lit-intlayer",
|
|
3
|
-
"version": "9.9.
|
|
3
|
+
"version": "9.9.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Lit applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -97,18 +97,18 @@
|
|
|
97
97
|
"prepublish": "cp -f ../../README.md ./README.md",
|
|
98
98
|
"publish": "bun publish || true",
|
|
99
99
|
"publish:canary": "bun publish --access public --tag canary || true",
|
|
100
|
-
"publish:ci": "bun ../../scripts/publish-package.
|
|
100
|
+
"publish:ci": "bun ../../scripts/publish-package.ts",
|
|
101
101
|
"publish:latest": "bun publish --access public --tag latest || true",
|
|
102
102
|
"test": "bun --bun vitest run",
|
|
103
103
|
"test:watch": "bun --bun vitest",
|
|
104
104
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@intlayer/api": "9.9.
|
|
108
|
-
"@intlayer/config": "9.9.
|
|
109
|
-
"@intlayer/core": "9.9.
|
|
110
|
-
"@intlayer/editor": "9.9.
|
|
111
|
-
"@intlayer/types": "9.9.
|
|
107
|
+
"@intlayer/api": "9.9.2",
|
|
108
|
+
"@intlayer/config": "9.9.2",
|
|
109
|
+
"@intlayer/core": "9.9.2",
|
|
110
|
+
"@intlayer/editor": "9.9.2",
|
|
111
|
+
"@intlayer/types": "9.9.2"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@types/node": "^26",
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
"rimraf": "6.1.4",
|
|
121
121
|
"tsdown": "0.23.7",
|
|
122
122
|
"typescript": "7.0.2",
|
|
123
|
-
"vite": "8.
|
|
123
|
+
"vite": "8.4.0",
|
|
124
124
|
"vite-plugin-dts": "5.1.2",
|
|
125
125
|
"vitest": "5.1.2"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
|
-
"intlayer": "9.9.
|
|
128
|
+
"intlayer": "9.9.2",
|
|
129
129
|
"lit": ">=3.0.0"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|