lit-intlayer 8.4.10
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/README.md +290 -0
- package/dist/chunk-C91j1N6u.js +1 -0
- package/dist/cjs/client/index.cjs +1 -0
- package/dist/cjs/client/installIntlayer.cjs +1 -0
- package/dist/cjs/client/useDictionary.cjs +1 -0
- package/dist/cjs/client/useIntlayer.cjs +1 -0
- package/dist/cjs/client/useLocale.cjs +1 -0
- package/dist/cjs/client/useLocaleStorage.cjs +1 -0
- package/dist/cjs/client/useRewriteURL.cjs +1 -0
- package/dist/cjs/editor/useEditor.cjs +1 -0
- package/dist/cjs/format/index.cjs +1 -0
- package/dist/cjs/format/useIntl.cjs +1 -0
- package/dist/cjs/getDictionary.cjs +1 -0
- package/dist/cjs/getIntlayer.cjs +1 -0
- package/dist/cjs/html/HTMLRenderer.cjs +1 -0
- package/dist/cjs/html/index.cjs +1 -0
- package/dist/cjs/html/installIntlayerHTML.cjs +1 -0
- package/dist/cjs/html/types.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -0
- package/dist/cjs/markdown/compiler.cjs +1 -0
- package/dist/cjs/markdown/index.cjs +1 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -0
- package/dist/cjs/markdown/runtime.cjs +1 -0
- package/dist/cjs/plugins.cjs +1 -0
- package/dist/cjs/renderIntlayerNode.cjs +1 -0
- package/dist/esm/client/index.mjs +7 -0
- package/dist/esm/client/installIntlayer.mjs +25 -0
- package/dist/esm/client/useDictionary.mjs +44 -0
- package/dist/esm/client/useIntlayer.mjs +44 -0
- package/dist/esm/client/useLocale.mjs +36 -0
- package/dist/esm/client/useLocaleStorage.mjs +24 -0
- package/dist/esm/client/useRewriteURL.mjs +30 -0
- package/dist/esm/editor/useEditor.mjs +33 -0
- package/dist/esm/format/index.mjs +2 -0
- package/dist/esm/format/useIntl.mjs +24 -0
- package/dist/esm/getDictionary.mjs +6 -0
- package/dist/esm/getIntlayer.mjs +6 -0
- package/dist/esm/html/HTMLRenderer.mjs +24 -0
- package/dist/esm/html/index.mjs +3 -0
- package/dist/esm/html/installIntlayerHTML.mjs +18 -0
- package/dist/esm/html/types.mjs +0 -0
- package/dist/esm/index.mjs +21 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs +55 -0
- package/dist/esm/markdown/compiler.mjs +6 -0
- package/dist/esm/markdown/index.mjs +5 -0
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +31 -0
- package/dist/esm/markdown/runtime.mjs +51 -0
- package/dist/esm/plugins.mjs +109 -0
- package/dist/esm/renderIntlayerNode.mjs +25 -0
- package/dist/types/src/client/index.d.ts +6 -0
- package/dist/types/src/client/installIntlayer.d.ts +37 -0
- package/dist/types/src/client/useDictionary.d.ts +30 -0
- package/dist/types/src/client/useIntlayer.d.ts +29 -0
- package/dist/types/src/client/useLocale.d.ts +62 -0
- package/dist/types/src/client/useLocaleStorage.d.ts +31 -0
- package/dist/types/src/client/useRewriteURL.d.ts +2 -0
- package/dist/types/src/editor/useEditor.d.ts +22 -0
- package/dist/types/src/format/index.d.ts +1 -0
- package/dist/types/src/format/useIntl.d.ts +50 -0
- package/dist/types/src/getDictionary.d.ts +4 -0
- package/dist/types/src/getIntlayer.d.ts +3 -0
- package/dist/types/src/html/HTMLRenderer.d.ts +49 -0
- package/dist/types/src/html/index.d.ts +3 -0
- package/dist/types/src/html/installIntlayerHTML.d.ts +40 -0
- package/dist/types/src/html/types.d.ts +42 -0
- package/dist/types/src/index.d.ts +14 -0
- package/dist/types/src/markdown/MarkdownRenderer.d.ts +78 -0
- package/dist/types/src/markdown/compiler.d.ts +25 -0
- package/dist/types/src/markdown/index.d.ts +4 -0
- package/dist/types/src/markdown/installIntlayerMarkdown.d.ts +50 -0
- package/dist/types/src/markdown/runtime.d.ts +12 -0
- package/dist/types/src/plugins.d.ts +75 -0
- package/dist/types/src/renderIntlayerNode.d.ts +22 -0
- package/package.json +132 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { localeStorageOptions as e } from "@intlayer/core/localization";
|
|
2
|
+
import { LocaleStorage as t, getLocaleFromStorage as n, setLocaleInStorage as r } from "@intlayer/core/utils";
|
|
3
|
+
//#region src/client/useLocaleStorage.ts
|
|
4
|
+
var i = n(e), a = i, o = (t, n) => r(t, {
|
|
5
|
+
...e,
|
|
6
|
+
isCookieEnabled: n
|
|
7
|
+
}), s = o, c = (n) => {
|
|
8
|
+
let r = t({
|
|
9
|
+
...e,
|
|
10
|
+
isCookieEnabled: n
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
localeStorage: r.getLocale(),
|
|
14
|
+
setLocaleStorage: r.setLocale
|
|
15
|
+
};
|
|
16
|
+
}, l = (e) => {
|
|
17
|
+
let t = c(e);
|
|
18
|
+
return {
|
|
19
|
+
localeCookie: t.localeStorage,
|
|
20
|
+
setLocaleCookie: t.setLocaleStorage
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { a as localeCookie, i as localeInStorage, s as setLocaleCookie, o as setLocaleInStorage, l as useLocaleCookie, c as useLocaleStorage };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getIntlayerClient as e } from "./installIntlayer.mjs";
|
|
2
|
+
import t from "@intlayer/config/built";
|
|
3
|
+
import { getRewritePath as n } from "@intlayer/core/localization";
|
|
4
|
+
//#region src/client/useRewriteURL.ts
|
|
5
|
+
var r = class {
|
|
6
|
+
host;
|
|
7
|
+
_unsubscribe = null;
|
|
8
|
+
constructor(e) {
|
|
9
|
+
this.host = e, e.addController(this);
|
|
10
|
+
}
|
|
11
|
+
_rewrite(e) {
|
|
12
|
+
let r = t?.routing?.rewrite;
|
|
13
|
+
if (typeof window > "u" || !r) return;
|
|
14
|
+
let i = window.location.pathname, a = n(i, e, r);
|
|
15
|
+
a && a !== i && window.history.replaceState(window.history.state, "", a + window.location.search + window.location.hash);
|
|
16
|
+
}
|
|
17
|
+
hostConnected() {
|
|
18
|
+
let t = e();
|
|
19
|
+
this._rewrite(t.locale), this._unsubscribe = t.subscribe((e) => {
|
|
20
|
+
this._rewrite(e);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
hostDisconnected() {
|
|
24
|
+
this._unsubscribe?.(), this._unsubscribe = null;
|
|
25
|
+
}
|
|
26
|
+
}, i = (e) => {
|
|
27
|
+
new r(e);
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { i as useRewriteURL };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getIntlayerClient as e } from "../client/installIntlayer.mjs";
|
|
2
|
+
import { isEnabled as t } from "@intlayer/editor/isEnabled";
|
|
3
|
+
//#region src/editor/useEditor.ts
|
|
4
|
+
var n = (t) => {
|
|
5
|
+
let n = !1, r = null;
|
|
6
|
+
return import("@intlayer/editor").then(({ initEditorClient: i }) => {
|
|
7
|
+
if (n) return;
|
|
8
|
+
let a = i(), o = e();
|
|
9
|
+
a.currentLocale.set(t), r = o.subscribe((e) => {
|
|
10
|
+
a.currentLocale.set(e);
|
|
11
|
+
});
|
|
12
|
+
}), () => {
|
|
13
|
+
n = !0, r?.(), import("@intlayer/editor").then(({ stopEditorClient: e }) => {
|
|
14
|
+
e();
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}, r = class {
|
|
18
|
+
host;
|
|
19
|
+
_stopEditor = null;
|
|
20
|
+
constructor(e) {
|
|
21
|
+
this.host = e, e.addController(this);
|
|
22
|
+
}
|
|
23
|
+
hostConnected() {
|
|
24
|
+
this._stopEditor = n(e().locale);
|
|
25
|
+
}
|
|
26
|
+
hostDisconnected() {
|
|
27
|
+
this._stopEditor?.(), this._stopEditor = null;
|
|
28
|
+
}
|
|
29
|
+
}, i = (e) => {
|
|
30
|
+
process.env.INTLAYER_EDITOR_ENABLED === "false" || !t || new r(e);
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { i as useEditor };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getIntlayerClient as e } from "../client/installIntlayer.mjs";
|
|
2
|
+
import { bindIntl as t } from "@intlayer/core/utils";
|
|
3
|
+
//#region src/format/useIntl.ts
|
|
4
|
+
var n = class {
|
|
5
|
+
host;
|
|
6
|
+
_overrideLocale;
|
|
7
|
+
_unsubscribe = null;
|
|
8
|
+
value;
|
|
9
|
+
constructor(n, r) {
|
|
10
|
+
this.host = n, this._overrideLocale = r;
|
|
11
|
+
let i = e();
|
|
12
|
+
this.value = t(this._overrideLocale ?? i.locale), n.addController(this);
|
|
13
|
+
}
|
|
14
|
+
hostConnected() {
|
|
15
|
+
this._unsubscribe = e().subscribe((e) => {
|
|
16
|
+
this.value = t(this._overrideLocale ?? e), this.host.requestUpdate();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
hostDisconnected() {
|
|
20
|
+
this._unsubscribe?.(), this._unsubscribe = null;
|
|
21
|
+
}
|
|
22
|
+
}, r = (e, t) => new n(e, t);
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as useIntl };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useHTML as e } from "./installIntlayerHTML.mjs";
|
|
2
|
+
import { LitElement as t, html as n, nothing as r } from "lit";
|
|
3
|
+
import { unsafeHTML as i } from "lit/directives/unsafe-html.js";
|
|
4
|
+
//#region src/html/HTMLRenderer.ts
|
|
5
|
+
var a = (e, t = {}) => e, o = ({ components: t } = {}) => {
|
|
6
|
+
let n = e();
|
|
7
|
+
return (e) => n.renderHTML(e, { components: t });
|
|
8
|
+
}, s = class extends t {
|
|
9
|
+
static properties = {
|
|
10
|
+
content: { type: String },
|
|
11
|
+
components: { attribute: !1 }
|
|
12
|
+
};
|
|
13
|
+
content = "";
|
|
14
|
+
components;
|
|
15
|
+
createRenderRoot() {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
return this.content ? n`${i(o({ components: this.components })(this.content))}` : r;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
customElements.get("intlayer-html-renderer") || customElements.define("intlayer-html-renderer", s);
|
|
23
|
+
//#endregion
|
|
24
|
+
export { s as HTMLRenderer, a as renderHTML, o as useHTMLRenderer };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createIntlayerHTMLClient as e, installIntlayerHTML as t, useHTML as n } from "./installIntlayerHTML.mjs";
|
|
2
|
+
import { HTMLRenderer as r, renderHTML as i, useHTMLRenderer as a } from "./HTMLRenderer.mjs";
|
|
3
|
+
export { r as HTMLRenderer, e as createIntlayerHTMLClient, t as installIntlayerHTML, i as renderHTML, n as useHTML, a as useHTMLRenderer };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/html/installIntlayerHTML.ts
|
|
2
|
+
var e = null, t = (t) => e || (e = { renderHTML: t }, e), n = (e) => {
|
|
3
|
+
let n;
|
|
4
|
+
if (typeof e == "function") n = e;
|
|
5
|
+
else {
|
|
6
|
+
let { components: t, renderHTML: r } = e ?? {};
|
|
7
|
+
n = r || ((e, n) => {
|
|
8
|
+
let r = n && typeof n == "object" && "components" in n ? n.components : n, i = {
|
|
9
|
+
...t ?? {},
|
|
10
|
+
...r ?? {}
|
|
11
|
+
};
|
|
12
|
+
return Object.keys(i).length, e;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return t(n);
|
|
16
|
+
}, r = () => e || { renderHTML: (e) => e };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { t as createIntlayerHTMLClient, n as installIntlayerHTML, r as useHTML };
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getPlugins as e, htmlPlugin as t, insertionPlugin as n, intlayerNodePlugins as r, markdownPlugin as i, markdownStringPlugin as a } from "./plugins.mjs";
|
|
2
|
+
import { getDictionary as o } from "./getDictionary.mjs";
|
|
3
|
+
import { getIntlayer as s } from "./getIntlayer.mjs";
|
|
4
|
+
import { IntlayerClient as c, createIntlayerClient as l, getIntlayerClient as u, installIntlayer as d } from "./client/installIntlayer.mjs";
|
|
5
|
+
import { useDictionary as f } from "./client/useDictionary.mjs";
|
|
6
|
+
import { useIntlayer as p } from "./client/useIntlayer.mjs";
|
|
7
|
+
import { localeCookie as m, localeInStorage as h, setLocaleCookie as g, setLocaleInStorage as _, useLocaleCookie as v, useLocaleStorage as y } from "./client/useLocaleStorage.mjs";
|
|
8
|
+
import { LocaleController as b, useLocale as x } from "./client/useLocale.mjs";
|
|
9
|
+
import { useRewriteURL as S } from "./client/useRewriteURL.mjs";
|
|
10
|
+
import "./client/index.mjs";
|
|
11
|
+
import { useEditor as C } from "./editor/useEditor.mjs";
|
|
12
|
+
import { useIntl as w } from "./format/useIntl.mjs";
|
|
13
|
+
import { createIntlayerHTMLClient as T, installIntlayerHTML as E, useHTML as D } from "./html/installIntlayerHTML.mjs";
|
|
14
|
+
import { HTMLRenderer as O, renderHTML as k, useHTMLRenderer as A } from "./html/HTMLRenderer.mjs";
|
|
15
|
+
import "./html/index.mjs";
|
|
16
|
+
import j, { createLitRuntime as M } from "./markdown/runtime.mjs";
|
|
17
|
+
import { RuleType as N, compile as P, compileMarkdown as F, compiler as I, sanitizer as L, slugify as R } from "./markdown/compiler.mjs";
|
|
18
|
+
import { createIntlayerMarkdownClient as z, installIntlayerMarkdown as B, useMarkdown as V } from "./markdown/installIntlayerMarkdown.mjs";
|
|
19
|
+
import { MarkdownRenderer as H, renderMarkdown as U, useMarkdownRenderer as W } from "./markdown/MarkdownRenderer.mjs";
|
|
20
|
+
import "./markdown/index.mjs";
|
|
21
|
+
export { O as HTMLRenderer, c as IntlayerClient, b as LocaleController, H as MarkdownRenderer, N as RuleType, P as compile, F as compileMarkdown, I as compiler, l as createIntlayerClient, T as createIntlayerHTMLClient, z as createIntlayerMarkdownClient, M as createLitRuntime, o as getDictionary, s as getIntlayer, u as getIntlayerClient, e as getPlugins, t as htmlPlugin, n as insertionPlugin, d as installIntlayer, E as installIntlayerHTML, B as installIntlayerMarkdown, r as intlayerNodePlugins, j as litRuntime, m as localeCookie, h as localeInStorage, i as markdownPlugin, a as markdownStringPlugin, k as renderHTML, U as renderMarkdown, L as sanitizer, g as setLocaleCookie, _ as setLocaleInStorage, R as slugify, f as useDictionary, C as useEditor, D as useHTML, A as useHTMLRenderer, w as useIntl, p as useIntlayer, x as useLocale, v as useLocaleCookie, y as useLocaleStorage, V as useMarkdown, W as useMarkdownRenderer, S as useRewriteURL };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { compileMarkdown as e } from "./compiler.mjs";
|
|
2
|
+
import { useMarkdown as t } from "./installIntlayerMarkdown.mjs";
|
|
3
|
+
import { LitElement as n, html as r, nothing as i } from "lit";
|
|
4
|
+
import { unsafeHTML as a } from "lit/directives/unsafe-html.js";
|
|
5
|
+
//#region src/markdown/MarkdownRenderer.ts
|
|
6
|
+
var o = (t, { forceBlock: n, forceInline: r, preserveFrontmatter: i, tagfilter: a } = {}) => e(t, {
|
|
7
|
+
forceBlock: n,
|
|
8
|
+
forceInline: r,
|
|
9
|
+
preserveFrontmatter: i,
|
|
10
|
+
tagfilter: a
|
|
11
|
+
}), s = (e = {}) => {
|
|
12
|
+
let n = t();
|
|
13
|
+
return (t) => n.renderMarkdown(t, {
|
|
14
|
+
forceBlock: e.forceBlock,
|
|
15
|
+
forceInline: e.forceInline,
|
|
16
|
+
preserveFrontmatter: e.preserveFrontmatter,
|
|
17
|
+
tagfilter: e.tagfilter
|
|
18
|
+
}, e.components, e.wrapper);
|
|
19
|
+
}, c = class extends n {
|
|
20
|
+
static properties = {
|
|
21
|
+
content: { type: String },
|
|
22
|
+
forceBlock: { type: Boolean },
|
|
23
|
+
forceInline: { type: Boolean },
|
|
24
|
+
preserveFrontmatter: { type: Boolean },
|
|
25
|
+
tagfilter: { type: Boolean },
|
|
26
|
+
renderMarkdown: { attribute: !1 }
|
|
27
|
+
};
|
|
28
|
+
content = "";
|
|
29
|
+
forceBlock;
|
|
30
|
+
forceInline;
|
|
31
|
+
preserveFrontmatter;
|
|
32
|
+
tagfilter;
|
|
33
|
+
renderMarkdownFn;
|
|
34
|
+
createRenderRoot() {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
if (!this.content) return i;
|
|
39
|
+
let e;
|
|
40
|
+
return e = this.renderMarkdownFn ? this.renderMarkdownFn(this.content, {
|
|
41
|
+
forceBlock: this.forceBlock,
|
|
42
|
+
forceInline: this.forceInline,
|
|
43
|
+
preserveFrontmatter: this.preserveFrontmatter,
|
|
44
|
+
tagfilter: this.tagfilter
|
|
45
|
+
}, void 0, void 0) : s({
|
|
46
|
+
forceBlock: this.forceBlock,
|
|
47
|
+
forceInline: this.forceInline,
|
|
48
|
+
preserveFrontmatter: this.preserveFrontmatter,
|
|
49
|
+
tagfilter: this.tagfilter
|
|
50
|
+
})(this.content), r`${a(e)}`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
customElements.get("intlayer-markdown-renderer") || customElements.define("intlayer-markdown-renderer", c);
|
|
54
|
+
//#endregion
|
|
55
|
+
export { c as MarkdownRenderer, o as renderMarkdown, s as useMarkdownRenderer };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import e from "./runtime.mjs";
|
|
2
|
+
import { RuleType as t, compileWithOptions as n, sanitizer as r, slugify as i } from "@intlayer/core/markdown";
|
|
3
|
+
//#region src/markdown/compiler.ts
|
|
4
|
+
var a = (t = "", r = {}) => n(t, e, r), o = a, s = a;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { t as RuleType, s as compile, a as compileMarkdown, o as compiler, r as sanitizer, i as slugify };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import e, { createLitRuntime as t } from "./runtime.mjs";
|
|
2
|
+
import { RuleType as n, compile as r, compileMarkdown as i, compiler as a, sanitizer as o, slugify as s } from "./compiler.mjs";
|
|
3
|
+
import { createIntlayerMarkdownClient as c, installIntlayerMarkdown as l, useMarkdown as u } from "./installIntlayerMarkdown.mjs";
|
|
4
|
+
import { MarkdownRenderer as d, renderMarkdown as f, useMarkdownRenderer as p } from "./MarkdownRenderer.mjs";
|
|
5
|
+
export { d as MarkdownRenderer, n as RuleType, r as compile, i as compileMarkdown, a as compiler, c as createIntlayerMarkdownClient, t as createLitRuntime, l as installIntlayerMarkdown, e as litRuntime, f as renderMarkdown, o as sanitizer, s as slugify, u as useMarkdown, p as useMarkdownRenderer };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { compileMarkdown as e } from "./compiler.mjs";
|
|
2
|
+
//#region src/markdown/installIntlayerMarkdown.ts
|
|
3
|
+
var t = null, n = (e, n) => t || (t = {
|
|
4
|
+
components: n,
|
|
5
|
+
renderMarkdown: e
|
|
6
|
+
}, t), r = (t) => {
|
|
7
|
+
let r, i;
|
|
8
|
+
if (typeof t == "function") r = t;
|
|
9
|
+
else {
|
|
10
|
+
let { components: n, wrapper: a, forceBlock: o, forceInline: s, preserveFrontmatter: c, tagfilter: l, renderMarkdown: u } = t ?? {};
|
|
11
|
+
if (i = n, u) r = u;
|
|
12
|
+
else {
|
|
13
|
+
let t = {
|
|
14
|
+
forceBlock: o,
|
|
15
|
+
forceInline: s,
|
|
16
|
+
preserveFrontmatter: c,
|
|
17
|
+
tagfilter: l
|
|
18
|
+
};
|
|
19
|
+
r = (n, r, i, a) => e(n, {
|
|
20
|
+
...t,
|
|
21
|
+
forceBlock: r?.forceBlock ?? t.forceBlock,
|
|
22
|
+
forceInline: r?.forceInline ?? t.forceInline,
|
|
23
|
+
preserveFrontmatter: r?.preserveFrontmatter ?? t.preserveFrontmatter,
|
|
24
|
+
tagfilter: r?.tagfilter ?? t.tagfilter
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return n(r, i);
|
|
29
|
+
}, i = () => t || { renderMarkdown: (t) => e(t) };
|
|
30
|
+
//#endregion
|
|
31
|
+
export { n as createIntlayerMarkdownClient, r as installIntlayerMarkdown, i as useMarkdown };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/markdown/runtime.ts
|
|
2
|
+
var e = new Set([
|
|
3
|
+
"area",
|
|
4
|
+
"base",
|
|
5
|
+
"br",
|
|
6
|
+
"col",
|
|
7
|
+
"embed",
|
|
8
|
+
"hr",
|
|
9
|
+
"img",
|
|
10
|
+
"input",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
]), t = (e) => e ? Object.entries(e).filter(([, e]) => e != null).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
|
+
createElement: (r, i, ...a) => {
|
|
19
|
+
let o = a.flat(Infinity).join("");
|
|
20
|
+
if (r === n) return o;
|
|
21
|
+
if (typeof r == "string") {
|
|
22
|
+
let n = t(i), a = n ? ` ${n}` : "", s = i?._innerHTML;
|
|
23
|
+
return e.has(r) ? `<${r}${a}>` : s === void 0 ? `<${r}${a}>${o}</${r}>` : `<${r}${a}>${s}</${r}>`;
|
|
24
|
+
}
|
|
25
|
+
if (typeof r == "function") try {
|
|
26
|
+
let e = r({
|
|
27
|
+
...i,
|
|
28
|
+
children: o
|
|
29
|
+
});
|
|
30
|
+
return typeof e == "string" ? e : o;
|
|
31
|
+
} catch {
|
|
32
|
+
return o;
|
|
33
|
+
}
|
|
34
|
+
return o;
|
|
35
|
+
},
|
|
36
|
+
cloneElement: (e, t, ...n) => typeof e == "string" ? e : String(e ?? ""),
|
|
37
|
+
Fragment: n,
|
|
38
|
+
normalizeProps: (e, t) => {
|
|
39
|
+
let n = {};
|
|
40
|
+
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;
|
|
41
|
+
return n;
|
|
42
|
+
}
|
|
43
|
+
}, i = (e = {}) => {
|
|
44
|
+
let { onCreateElement: t } = e;
|
|
45
|
+
return t ? {
|
|
46
|
+
...r,
|
|
47
|
+
createElement: (e, n, ...r) => t(e, n, r)
|
|
48
|
+
} : r;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { i as createLitRuntime, r as default, r as litRuntime };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { renderIntlayerNode as e } from "./renderIntlayerNode.mjs";
|
|
2
|
+
import { conditionPlugin as t, enumerationPlugin as n, filePlugin as r, genderPlugin as i, nestedPlugin as a, splitInsertionTemplate as o, translationPlugin as s } from "@intlayer/core/interpreter";
|
|
3
|
+
import c from "@intlayer/config/built";
|
|
4
|
+
import { getMarkdownMetadata as l } from "@intlayer/core/markdown";
|
|
5
|
+
import * as u from "@intlayer/types/nodeType";
|
|
6
|
+
//#region src/plugins.ts
|
|
7
|
+
var d = {
|
|
8
|
+
id: "intlayer-node-plugin",
|
|
9
|
+
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
10
|
+
transform: (t, { children: n, ...r }) => e({
|
|
11
|
+
...r,
|
|
12
|
+
value: n,
|
|
13
|
+
children: n
|
|
14
|
+
})
|
|
15
|
+
}, f = {
|
|
16
|
+
id: "insertion-plugin",
|
|
17
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === u.INSERTION,
|
|
18
|
+
transform: (e, t, n) => {
|
|
19
|
+
let r = [...t.keyPath, { type: u.INSERTION }], i = e[u.INSERTION], a = {
|
|
20
|
+
id: "insertion-string-plugin",
|
|
21
|
+
canHandle: (e) => typeof e == "string",
|
|
22
|
+
transform: (e, n, r) => {
|
|
23
|
+
let i = r(e, {
|
|
24
|
+
...n,
|
|
25
|
+
children: e,
|
|
26
|
+
plugins: (t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")
|
|
27
|
+
});
|
|
28
|
+
return (e) => {
|
|
29
|
+
let a = o(i, e), s = a.isSimple ? a.parts : a.parts.join("");
|
|
30
|
+
return r(s, {
|
|
31
|
+
...n,
|
|
32
|
+
plugins: t.plugins,
|
|
33
|
+
children: s
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return n(i, {
|
|
39
|
+
...t,
|
|
40
|
+
children: i,
|
|
41
|
+
keyPath: r,
|
|
42
|
+
plugins: [a, ...t.plugins ?? []]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, p = {
|
|
46
|
+
id: "markdown-string-plugin",
|
|
47
|
+
canHandle: (e) => typeof e == "string",
|
|
48
|
+
transform: (t, n, r) => {
|
|
49
|
+
let { plugins: i, ...a } = n, o = r(l(t) ?? {}, {
|
|
50
|
+
plugins: [{
|
|
51
|
+
id: "markdown-metadata-plugin",
|
|
52
|
+
canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
|
|
53
|
+
transform: (n, r) => e({
|
|
54
|
+
...r,
|
|
55
|
+
value: n,
|
|
56
|
+
children: t
|
|
57
|
+
})
|
|
58
|
+
}],
|
|
59
|
+
dictionaryKey: a.dictionaryKey,
|
|
60
|
+
keyPath: []
|
|
61
|
+
});
|
|
62
|
+
return e({
|
|
63
|
+
...n,
|
|
64
|
+
value: t,
|
|
65
|
+
children: t,
|
|
66
|
+
additionalProps: {
|
|
67
|
+
metadata: o,
|
|
68
|
+
use: (e) => t
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, m = {
|
|
73
|
+
id: "markdown-plugin",
|
|
74
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === u.MARKDOWN,
|
|
75
|
+
transform: (e, t, n) => {
|
|
76
|
+
let r = [...t.keyPath, { type: u.MARKDOWN }], i = e[u.MARKDOWN];
|
|
77
|
+
return n(i, {
|
|
78
|
+
...t,
|
|
79
|
+
children: i,
|
|
80
|
+
keyPath: r,
|
|
81
|
+
plugins: [p, ...t.plugins ?? []]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, h = {
|
|
85
|
+
id: "html-plugin",
|
|
86
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === u.HTML,
|
|
87
|
+
transform: (t, n) => {
|
|
88
|
+
let r = t[u.HTML];
|
|
89
|
+
return e({
|
|
90
|
+
...n,
|
|
91
|
+
value: r,
|
|
92
|
+
children: r,
|
|
93
|
+
additionalProps: { use: (e) => r }
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}, g = (e, o = !0) => [
|
|
97
|
+
s(e ?? c.internationalization.defaultLocale, o ? c.internationalization.defaultLocale : void 0),
|
|
98
|
+
n,
|
|
99
|
+
t,
|
|
100
|
+
a(e ?? c.internationalization.defaultLocale),
|
|
101
|
+
r,
|
|
102
|
+
i,
|
|
103
|
+
d,
|
|
104
|
+
f,
|
|
105
|
+
m,
|
|
106
|
+
h
|
|
107
|
+
];
|
|
108
|
+
//#endregion
|
|
109
|
+
export { g as getPlugins, h as htmlPlugin, f as insertionPlugin, d as intlayerNodePlugins, m as markdownPlugin, p as markdownStringPlugin };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/renderIntlayerNode.ts
|
|
2
|
+
var e = ({ value: e, additionalProps: t = {} }) => {
|
|
3
|
+
let n = e, r = {
|
|
4
|
+
toString: () => String(n ?? ""),
|
|
5
|
+
valueOf: () => n,
|
|
6
|
+
[Symbol.toPrimitive]: () => n,
|
|
7
|
+
toJSON: () => n,
|
|
8
|
+
get raw() {
|
|
9
|
+
return n;
|
|
10
|
+
},
|
|
11
|
+
set raw(e) {
|
|
12
|
+
n = e;
|
|
13
|
+
},
|
|
14
|
+
get value() {
|
|
15
|
+
return n;
|
|
16
|
+
},
|
|
17
|
+
__update(e) {
|
|
18
|
+
n = e?.raw ?? e?.value ?? e;
|
|
19
|
+
},
|
|
20
|
+
...t
|
|
21
|
+
};
|
|
22
|
+
return Object.setPrototypeOf(r, String.prototype), r;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as renderIntlayerNode };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
+
type LocaleListener = (locale: LocalesValues) => void;
|
|
3
|
+
export declare class IntlayerClient {
|
|
4
|
+
private _locale;
|
|
5
|
+
private _listeners;
|
|
6
|
+
isCookieEnabled: boolean;
|
|
7
|
+
constructor(locale?: LocalesValues, isCookieEnabled?: boolean);
|
|
8
|
+
get locale(): LocalesValues;
|
|
9
|
+
setLocale(newLocale: LocalesValues): void;
|
|
10
|
+
subscribe(listener: LocaleListener): () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create and return a single IntlayerClient instance.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerClient;
|
|
16
|
+
/**
|
|
17
|
+
* Get the current IntlayerClient instance, creating one with defaults if needed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getIntlayerClient: () => IntlayerClient;
|
|
20
|
+
/**
|
|
21
|
+
* Install Intlayer into your Lit application.
|
|
22
|
+
*
|
|
23
|
+
* Call this once at application startup before any Lit elements are rendered.
|
|
24
|
+
*
|
|
25
|
+
* @param locale - Initial locale (defaults to config defaultLocale).
|
|
26
|
+
* @param isCookieEnabled - Whether to persist locale in cookies/localStorage.
|
|
27
|
+
* @returns The IntlayerClient singleton.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { installIntlayer } from 'lit-intlayer';
|
|
32
|
+
*
|
|
33
|
+
* installIntlayer('en');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const installIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerClient;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
+
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
+
import { ReactiveControllerHost } from 'lit';
|
|
4
|
+
import { DeepTransformContent } from '../plugins';
|
|
5
|
+
/**
|
|
6
|
+
* Reactive hook that returns the translated content for a raw dictionary object.
|
|
7
|
+
*
|
|
8
|
+
* Unlike `useIntlayer` (which takes a registered key), this hook accepts a
|
|
9
|
+
* dictionary object directly — useful for dictionaries loaded asynchronously
|
|
10
|
+
* or defined inline.
|
|
11
|
+
*
|
|
12
|
+
* @param host - The LitElement (or any ReactiveControllerHost).
|
|
13
|
+
* @param dictionary - The raw dictionary object.
|
|
14
|
+
* @param locale - Optional locale override.
|
|
15
|
+
* @returns A reactive proxy to the dictionary content.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import myDict from './myDictionary.content';
|
|
20
|
+
*
|
|
21
|
+
* class MyElement extends LitElement {
|
|
22
|
+
* private content = useDictionary(this, myDict);
|
|
23
|
+
*
|
|
24
|
+
* render() {
|
|
25
|
+
* return html`<p>${this.content.greeting.value}</p>`;
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(host: ReactiveControllerHost, dictionary: T, locale?: L) => DeepTransformContent<T["content"], L>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
+
import { ReactiveControllerHost } from 'lit';
|
|
3
|
+
import { DeepTransformContent } from '../plugins';
|
|
4
|
+
/**
|
|
5
|
+
* Reactive hook that returns the translated dictionary for the given key.
|
|
6
|
+
*
|
|
7
|
+
* Works as a Lit ReactiveController: the host element automatically
|
|
8
|
+
* re-renders whenever the locale changes.
|
|
9
|
+
*
|
|
10
|
+
* The returned value is a transparent proxy of the dictionary content.
|
|
11
|
+
* Access fields directly without an extra `.value` wrapper.
|
|
12
|
+
*
|
|
13
|
+
* @param host - The LitElement (or any ReactiveControllerHost) that owns this hook.
|
|
14
|
+
* @param key - The dictionary key registered in your intlayer content files.
|
|
15
|
+
* @param locale - Optional locale override (defaults to the current app locale).
|
|
16
|
+
* @returns A reactive proxy to the dictionary content.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* class MyElement extends LitElement {
|
|
21
|
+
* private content = useIntlayer(this, 'my-component');
|
|
22
|
+
*
|
|
23
|
+
* render() {
|
|
24
|
+
* return html`<h1>${this.content.title.value}</h1>`;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const useIntlayer: <T extends DictionaryKeys>(host: ReactiveControllerHost, key: T, locale?: LocalesValues) => DeepTransformContent<DictionaryRegistryContent<T>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
3
|
+
type UseLocaleProps = {
|
|
4
|
+
isCookieEnabled?: boolean;
|
|
5
|
+
onLocaleChange?: (locale: LocalesValues) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* ReactiveController that exposes the current locale and a `setLocale` setter.
|
|
9
|
+
* The host element re-renders whenever the locale changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare class LocaleController implements ReactiveController {
|
|
12
|
+
private readonly host;
|
|
13
|
+
private readonly _isCookieEnabled;
|
|
14
|
+
private readonly _onLocaleChange;
|
|
15
|
+
private _unsubscribe;
|
|
16
|
+
/** The currently active locale. */
|
|
17
|
+
locale: DeclaredLocales;
|
|
18
|
+
/** The application's default locale (from config). */
|
|
19
|
+
readonly defaultLocale: DeclaredLocales;
|
|
20
|
+
/** All available locales (from config). */
|
|
21
|
+
readonly availableLocales: DeclaredLocales[];
|
|
22
|
+
constructor(host: ReactiveControllerHost, props?: UseLocaleProps);
|
|
23
|
+
/**
|
|
24
|
+
* Change the application locale.
|
|
25
|
+
* Validates against `availableLocales`, persists to storage, and triggers a re-render.
|
|
26
|
+
*/
|
|
27
|
+
setLocale: (newLocale: LocalesValues) => void;
|
|
28
|
+
hostConnected(): void;
|
|
29
|
+
hostDisconnected(): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reactive hook that provides locale management.
|
|
33
|
+
*
|
|
34
|
+
* Returns a `LocaleController` with:
|
|
35
|
+
* - `locale` — the current locale (updates the host on change)
|
|
36
|
+
* - `defaultLocale` — the config default locale
|
|
37
|
+
* - `availableLocales` — all configured locales
|
|
38
|
+
* - `setLocale(locale)` — switches the app locale
|
|
39
|
+
*
|
|
40
|
+
* @param host - The LitElement (or any ReactiveControllerHost).
|
|
41
|
+
* @param props - Optional configuration.
|
|
42
|
+
* @returns A `LocaleController`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* class LocaleSwitcher extends LitElement {
|
|
47
|
+
* private locale = useLocale(this);
|
|
48
|
+
*
|
|
49
|
+
* render() {
|
|
50
|
+
* return html`
|
|
51
|
+
* <select @change=${(e: Event) => this.locale.setLocale((e.target as HTMLSelectElement).value as any)}>
|
|
52
|
+
* ${this.locale.availableLocales.map(
|
|
53
|
+
* (loc) => html`<option value=${loc} ?selected=${loc === this.locale.locale}>${loc}</option>`
|
|
54
|
+
* )}
|
|
55
|
+
* </select>
|
|
56
|
+
* `;
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const useLocale: (host: ReactiveControllerHost, props?: UseLocaleProps) => LocaleController;
|
|
62
|
+
export {};
|