lit-intlayer 8.4.10 → 8.5.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.
Files changed (101) hide show
  1. package/dist/cjs/client/IntlayerBinding.cjs +1 -0
  2. package/dist/cjs/client/index.cjs +1 -1
  3. package/dist/cjs/client/installIntlayer.cjs +1 -1
  4. package/dist/cjs/client/useDictionary.cjs +1 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -0
  6. package/dist/cjs/client/useIntlayer.cjs +1 -1
  7. package/dist/cjs/client/useLocale.cjs +1 -1
  8. package/dist/cjs/client/useRewriteURL.cjs +1 -1
  9. package/dist/cjs/editor/useEditor.cjs +1 -1
  10. package/dist/cjs/format/index.cjs +1 -1
  11. package/dist/cjs/format/useCompact.cjs +1 -0
  12. package/dist/cjs/format/useCurrency.cjs +1 -0
  13. package/dist/cjs/format/useDate.cjs +1 -0
  14. package/dist/cjs/format/useIntl.cjs +1 -1
  15. package/dist/cjs/format/useList.cjs +1 -0
  16. package/dist/cjs/format/useNumber.cjs +1 -0
  17. package/dist/cjs/format/usePercentage.cjs +1 -0
  18. package/dist/cjs/format/useRelativeTime.cjs +1 -0
  19. package/dist/cjs/format/useUnit.cjs +1 -0
  20. package/dist/cjs/html/HTMLRenderer.cjs +1 -1
  21. package/dist/cjs/html/index.cjs +1 -1
  22. package/dist/cjs/html/installIntlayerHTML.cjs +1 -1
  23. package/dist/cjs/index.cjs +1 -1
  24. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
  25. package/dist/cjs/markdown/index.cjs +1 -1
  26. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
  27. package/dist/cjs/markdown/runtime.cjs +1 -1
  28. package/dist/cjs/plugins.cjs +1 -1
  29. package/dist/cjs/renderIntlayerNode.cjs +1 -1
  30. package/dist/esm/client/IntlayerBinding.mjs +21 -0
  31. package/dist/esm/client/index.mjs +9 -7
  32. package/dist/esm/client/installIntlayer.mjs +2 -25
  33. package/dist/esm/client/useDictionary.mjs +15 -39
  34. package/dist/esm/client/useDictionaryDynamic.mjs +47 -0
  35. package/dist/esm/client/useIntlayer.mjs +13 -40
  36. package/dist/esm/client/useLocale.mjs +1 -1
  37. package/dist/esm/client/useRewriteURL.mjs +1 -1
  38. package/dist/esm/editor/useEditor.mjs +2 -33
  39. package/dist/esm/format/index.mjs +10 -2
  40. package/dist/esm/format/useCompact.mjs +29 -0
  41. package/dist/esm/format/useCurrency.mjs +29 -0
  42. package/dist/esm/format/useDate.mjs +41 -0
  43. package/dist/esm/format/useIntl.mjs +1 -1
  44. package/dist/esm/format/useList.mjs +29 -0
  45. package/dist/esm/format/useNumber.mjs +29 -0
  46. package/dist/esm/format/usePercentage.mjs +29 -0
  47. package/dist/esm/format/useRelativeTime.mjs +29 -0
  48. package/dist/esm/format/useUnit.mjs +29 -0
  49. package/dist/esm/html/HTMLRenderer.mjs +4 -4
  50. package/dist/esm/html/index.mjs +3 -3
  51. package/dist/esm/html/installIntlayerHTML.mjs +2 -2
  52. package/dist/esm/index.mjs +9 -17
  53. package/dist/esm/markdown/MarkdownRenderer.mjs +5 -5
  54. package/dist/esm/markdown/index.mjs +4 -5
  55. package/dist/esm/markdown/installIntlayerMarkdown.mjs +2 -2
  56. package/dist/esm/markdown/runtime.mjs +1 -1
  57. package/dist/esm/plugins.mjs +66 -57
  58. package/dist/esm/renderIntlayerNode.mjs +1 -0
  59. package/dist/installIntlayer-3Fpy-rFd.mjs +71 -0
  60. package/dist/installIntlayer-CkFmSJJA.js +1 -0
  61. package/dist/types/client/IntlayerBinding.d.ts +40 -0
  62. package/dist/types/{src/client → client}/index.d.ts +2 -0
  63. package/dist/types/{src/client → client}/installIntlayer.d.ts +17 -1
  64. package/dist/types/client/useDictionary.d.ts +31 -0
  65. package/dist/types/client/useDictionaryDynamic.d.ts +36 -0
  66. package/dist/types/client/useIntlayer.d.ts +22 -0
  67. package/dist/types/editor/useEditor.d.ts +34 -0
  68. package/dist/types/format/index.d.ts +9 -0
  69. package/dist/types/format/useCompact.d.ts +12 -0
  70. package/dist/types/format/useCurrency.d.ts +12 -0
  71. package/dist/types/format/useDate.d.ts +18 -0
  72. package/dist/types/format/useList.d.ts +12 -0
  73. package/dist/types/format/useNumber.d.ts +18 -0
  74. package/dist/types/format/usePercentage.d.ts +12 -0
  75. package/dist/types/format/useRelativeTime.d.ts +12 -0
  76. package/dist/types/format/useUnit.d.ts +12 -0
  77. package/dist/types/html/index.d.ts +3 -0
  78. package/dist/types/{src/html → html}/installIntlayerHTML.d.ts +25 -0
  79. package/dist/types/{src/index.d.ts → index.d.ts} +0 -3
  80. package/dist/types/markdown/index.d.ts +3 -0
  81. package/dist/types/{src/markdown → markdown}/installIntlayerMarkdown.d.ts +25 -1
  82. package/dist/types/{src/plugins.d.ts → plugins.d.ts} +7 -5
  83. package/package.json +22 -14
  84. package/dist/types/src/client/useDictionary.d.ts +0 -30
  85. package/dist/types/src/client/useIntlayer.d.ts +0 -29
  86. package/dist/types/src/editor/useEditor.d.ts +0 -22
  87. package/dist/types/src/format/index.d.ts +0 -1
  88. package/dist/types/src/html/index.d.ts +0 -3
  89. package/dist/types/src/markdown/index.d.ts +0 -4
  90. /package/dist/types/{src/client → client}/useLocale.d.ts +0 -0
  91. /package/dist/types/{src/client → client}/useLocaleStorage.d.ts +0 -0
  92. /package/dist/types/{src/client → client}/useRewriteURL.d.ts +0 -0
  93. /package/dist/types/{src/format → format}/useIntl.d.ts +0 -0
  94. /package/dist/types/{src/getDictionary.d.ts → getDictionary.d.ts} +0 -0
  95. /package/dist/types/{src/getIntlayer.d.ts → getIntlayer.d.ts} +0 -0
  96. /package/dist/types/{src/html → html}/HTMLRenderer.d.ts +0 -0
  97. /package/dist/types/{src/html → html}/types.d.ts +0 -0
  98. /package/dist/types/{src/markdown → markdown}/MarkdownRenderer.d.ts +0 -0
  99. /package/dist/types/{src/markdown → markdown}/compiler.d.ts +0 -0
  100. /package/dist/types/{src/markdown → markdown}/runtime.d.ts +0 -0
  101. /package/dist/types/{src/renderIntlayerNode.d.ts → renderIntlayerNode.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { getIntlayerClient as e } from "../client/installIntlayer.mjs";
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
2
  import { bindIntl as t } from "@intlayer/core/utils";
3
3
  //#region src/format/useIntl.ts
4
4
  var n = class {
@@ -0,0 +1,29 @@
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
+ import { list as t } from "@intlayer/core/formatters";
3
+ //#region src/format/useList.ts
4
+ var n = class {
5
+ host;
6
+ _unsubscribe = null;
7
+ value;
8
+ constructor(n) {
9
+ this.host = n;
10
+ let r = e();
11
+ this.value = (...e) => t(e[0], {
12
+ ...e[1],
13
+ locale: e[1]?.locale ?? r.locale
14
+ }), n.addController(this);
15
+ }
16
+ hostConnected() {
17
+ this._unsubscribe = e().subscribe((e) => {
18
+ this.value = (...n) => t(n[0], {
19
+ ...n[1],
20
+ locale: n[1]?.locale ?? e
21
+ }), this.host.requestUpdate();
22
+ });
23
+ }
24
+ hostDisconnected() {
25
+ this._unsubscribe?.(), this._unsubscribe = null;
26
+ }
27
+ }, r = (e) => new n(e);
28
+ //#endregion
29
+ export { r as useList };
@@ -0,0 +1,29 @@
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
+ import { number as t } from "@intlayer/core/formatters";
3
+ //#region src/format/useNumber.ts
4
+ var n = class {
5
+ host;
6
+ _unsubscribe = null;
7
+ value;
8
+ constructor(n) {
9
+ this.host = n;
10
+ let r = e();
11
+ this.value = (...e) => t(e[0], {
12
+ ...e[1],
13
+ locale: e[1]?.locale ?? r.locale
14
+ }), n.addController(this);
15
+ }
16
+ hostConnected() {
17
+ this._unsubscribe = e().subscribe((e) => {
18
+ this.value = (...n) => t(n[0], {
19
+ ...n[1],
20
+ locale: n[1]?.locale ?? e
21
+ }), this.host.requestUpdate();
22
+ });
23
+ }
24
+ hostDisconnected() {
25
+ this._unsubscribe?.(), this._unsubscribe = null;
26
+ }
27
+ }, r = (e) => new n(e);
28
+ //#endregion
29
+ export { r as useNumber };
@@ -0,0 +1,29 @@
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
+ import { percentage as t } from "@intlayer/core/formatters";
3
+ //#region src/format/usePercentage.ts
4
+ var n = class {
5
+ host;
6
+ _unsubscribe = null;
7
+ value;
8
+ constructor(n) {
9
+ this.host = n;
10
+ let r = e();
11
+ this.value = (...e) => t(e[0], {
12
+ ...e[1],
13
+ locale: e[1]?.locale ?? r.locale
14
+ }), n.addController(this);
15
+ }
16
+ hostConnected() {
17
+ this._unsubscribe = e().subscribe((e) => {
18
+ this.value = (...n) => t(n[0], {
19
+ ...n[1],
20
+ locale: n[1]?.locale ?? e
21
+ }), this.host.requestUpdate();
22
+ });
23
+ }
24
+ hostDisconnected() {
25
+ this._unsubscribe?.(), this._unsubscribe = null;
26
+ }
27
+ }, r = (e) => new n(e);
28
+ //#endregion
29
+ export { r as usePercentage };
@@ -0,0 +1,29 @@
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
+ import { relativeTime as t } from "@intlayer/core/formatters";
3
+ //#region src/format/useRelativeTime.ts
4
+ var n = class {
5
+ host;
6
+ _unsubscribe = null;
7
+ value;
8
+ constructor(n) {
9
+ this.host = n;
10
+ let r = e();
11
+ this.value = (...e) => t(e[0], e[1], {
12
+ ...e[2],
13
+ locale: e[2]?.locale ?? r.locale
14
+ }), n.addController(this);
15
+ }
16
+ hostConnected() {
17
+ this._unsubscribe = e().subscribe((e) => {
18
+ this.value = (...n) => t(n[0], n[1], {
19
+ ...n[2],
20
+ locale: n[2]?.locale ?? e
21
+ }), this.host.requestUpdate();
22
+ });
23
+ }
24
+ hostDisconnected() {
25
+ this._unsubscribe?.(), this._unsubscribe = null;
26
+ }
27
+ }, r = (e) => new n(e);
28
+ //#endregion
29
+ export { r as useRelativeTime };
@@ -0,0 +1,29 @@
1
+ import { r as e } from "../../installIntlayer-3Fpy-rFd.mjs";
2
+ import { units as t } from "@intlayer/core/formatters";
3
+ //#region src/format/useUnit.ts
4
+ var n = class {
5
+ host;
6
+ _unsubscribe = null;
7
+ value;
8
+ constructor(n) {
9
+ this.host = n;
10
+ let r = e();
11
+ this.value = (...e) => t(e[0], {
12
+ ...e[1],
13
+ locale: e[1]?.locale ?? r.locale
14
+ }), n.addController(this);
15
+ }
16
+ hostConnected() {
17
+ this._unsubscribe = e().subscribe((e) => {
18
+ this.value = (...n) => t(n[0], {
19
+ ...n[1],
20
+ locale: n[1]?.locale ?? e
21
+ }), this.host.requestUpdate();
22
+ });
23
+ }
24
+ hostDisconnected() {
25
+ this._unsubscribe?.(), this._unsubscribe = null;
26
+ }
27
+ }, r = (e) => new n(e);
28
+ //#endregion
29
+ export { r as useUnit };
@@ -1,11 +1,11 @@
1
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";
2
+ import { unsafeHTML as t } from "lit/directives/unsafe-html.js";
3
+ import { LitElement as n, html as r, nothing as i } from "lit";
4
4
  //#region src/html/HTMLRenderer.ts
5
5
  var a = (e, t = {}) => e, o = ({ components: t } = {}) => {
6
6
  let n = e();
7
7
  return (e) => n.renderHTML(e, { components: t });
8
- }, s = class extends t {
8
+ }, s = class extends n {
9
9
  static properties = {
10
10
  content: { type: String },
11
11
  components: { attribute: !1 }
@@ -16,7 +16,7 @@ var a = (e, t = {}) => e, o = ({ components: t } = {}) => {
16
16
  return this;
17
17
  }
18
18
  render() {
19
- return this.content ? n`${i(o({ components: this.components })(this.content))}` : r;
19
+ return this.content ? r`${t(o({ components: this.components })(this.content))}` : i;
20
20
  }
21
21
  };
22
22
  customElements.get("intlayer-html-renderer") || customElements.define("intlayer-html-renderer", s);
@@ -1,3 +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 };
1
+ import { installIntlayerHTML as e, installIntlayerHTMLDynamic as t, useHTML as n } from "./installIntlayerHTML.mjs";
2
+ import { renderHTML as r, useHTMLRenderer as i } from "./HTMLRenderer.mjs";
3
+ export { e as installIntlayerHTML, t as installIntlayerHTMLDynamic, r as renderHTML, n as useHTML, i as useHTMLRenderer };
@@ -13,6 +13,6 @@ var e = null, t = (t) => e || (e = { renderHTML: t }, e), n = (e) => {
13
13
  });
14
14
  }
15
15
  return t(n);
16
- }, r = () => e || { renderHTML: (e) => e };
16
+ }, r = () => e || { renderHTML: (e) => e }, i = async (t) => e || n(await t());
17
17
  //#endregion
18
- export { t as createIntlayerHTMLClient, n as installIntlayerHTML, r as useHTML };
18
+ export { t as createIntlayerHTMLClient, n as installIntlayerHTML, i as installIntlayerHTMLDynamic, r as useHTML };
@@ -1,21 +1,13 @@
1
1
  import { getPlugins as e, htmlPlugin as t, insertionPlugin as n, intlayerNodePlugins as r, markdownPlugin as i, markdownStringPlugin as a } from "./plugins.mjs";
2
2
  import { getDictionary as o } from "./getDictionary.mjs";
3
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";
4
+ import { a as c, i as l, n as u, r as d, t as f } from "../installIntlayer-3Fpy-rFd.mjs";
5
+ import { IntlayerBinding as p } from "./client/IntlayerBinding.mjs";
6
+ import { useDictionary as m } from "./client/useDictionary.mjs";
7
+ import { useDictionaryDynamic as h } from "./client/useDictionaryDynamic.mjs";
8
+ import { useIntlayer as g } from "./client/useIntlayer.mjs";
9
+ import { localeCookie as _, localeInStorage as v, setLocaleCookie as y, setLocaleInStorage as b, useLocaleCookie as x, useLocaleStorage as S } from "./client/useLocaleStorage.mjs";
10
+ import { LocaleController as C, useLocale as w } from "./client/useLocale.mjs";
11
+ import { useRewriteURL as T } from "./client/useRewriteURL.mjs";
10
12
  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 };
13
+ export { p as IntlayerBinding, f as IntlayerClient, C as LocaleController, u as createIntlayerClient, o as getDictionary, s as getIntlayer, d as getIntlayerClient, e as getPlugins, t as htmlPlugin, n as insertionPlugin, l as installIntlayer, r as intlayerNodePlugins, _ as localeCookie, v as localeInStorage, i as markdownPlugin, a as markdownStringPlugin, y as setLocaleCookie, b as setLocaleInStorage, m as useDictionary, h as useDictionaryDynamic, c as useEditor, g as useIntlayer, w as useLocale, x as useLocaleCookie, S as useLocaleStorage, T as useRewriteURL };
@@ -1,7 +1,7 @@
1
1
  import { compileMarkdown as e } from "./compiler.mjs";
2
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";
3
+ import { unsafeHTML as n } from "lit/directives/unsafe-html.js";
4
+ import { LitElement as r, html as i, nothing as a } from "lit";
5
5
  //#region src/markdown/MarkdownRenderer.ts
6
6
  var o = (t, { forceBlock: n, forceInline: r, preserveFrontmatter: i, tagfilter: a } = {}) => e(t, {
7
7
  forceBlock: n,
@@ -16,7 +16,7 @@ var o = (t, { forceBlock: n, forceInline: r, preserveFrontmatter: i, tagfilter:
16
16
  preserveFrontmatter: e.preserveFrontmatter,
17
17
  tagfilter: e.tagfilter
18
18
  }, e.components, e.wrapper);
19
- }, c = class extends n {
19
+ }, c = class extends r {
20
20
  static properties = {
21
21
  content: { type: String },
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 i;
38
+ if (!this.content) return a;
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), r`${a(e)}`;
50
+ })(this.content), i`${n(e)}`;
51
51
  }
52
52
  };
53
53
  customElements.get("intlayer-markdown-renderer") || customElements.define("intlayer-markdown-renderer", c);
@@ -1,5 +1,4 @@
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 };
1
+ import { compileMarkdown as e } from "./compiler.mjs";
2
+ import { installIntlayerMarkdown as t, installIntlayerMarkdownDynamic as n, useMarkdown as r } from "./installIntlayerMarkdown.mjs";
3
+ import { renderMarkdown as i, useMarkdownRenderer as a } from "./MarkdownRenderer.mjs";
4
+ export { e as compileMarkdown, t as installIntlayerMarkdown, n as installIntlayerMarkdownDynamic, i as renderMarkdown, r as useMarkdown, a as useMarkdownRenderer };
@@ -26,6 +26,6 @@ var t = null, n = (e, n) => t || (t = {
26
26
  }
27
27
  }
28
28
  return n(r, i);
29
- }, i = () => t || { renderMarkdown: (t) => e(t) };
29
+ }, i = () => t || { renderMarkdown: (t) => e(t) }, a = async (e) => t || r(await e());
30
30
  //#endregion
31
- export { n as createIntlayerMarkdownClient, r as installIntlayerMarkdown, i as useMarkdown };
31
+ export { n as createIntlayerMarkdownClient, r as installIntlayerMarkdown, a as installIntlayerMarkdownDynamic, i as useMarkdown };
@@ -14,7 +14,7 @@ var e = new Set([
14
14
  "source",
15
15
  "track",
16
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 = {
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
19
  let o = a.flat(Infinity).join("");
20
20
  if (r === n) return o;
@@ -1,22 +1,38 @@
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";
1
+ import e from "./markdown/runtime.mjs";
2
+ import { renderIntlayerNode as t } from "./renderIntlayerNode.mjs";
3
+ import { conditionPlugin as n, enumerationPlugin as r, filePlugin as i, genderPlugin as a, nestedPlugin as o, splitInsertionTemplate as s, translationPlugin as c } from "@intlayer/core/interpreter";
4
+ import l from "@intlayer/config/built";
5
+ import { compileWithOptions as u, getMarkdownMetadata as d } from "@intlayer/core/markdown";
6
+ import { isEnabled as f } from "@intlayer/editor/isEnabled";
7
+ import * as p from "@intlayer/types/nodeType";
8
+ import { unsafeHTML as m } from "lit/directives/unsafe-html.js";
6
9
  //#region src/plugins.ts
7
- var d = {
10
+ var h = (t = "", n = {}) => u(t, e, n), g = (e, t = e, n = {}) => {
11
+ let r = m(e);
12
+ return new Proxy(r, { get(e, r, i) {
13
+ if (r === "value" || r === "raw") return t;
14
+ if (r === "toString" || r === Symbol.toPrimitive) return () => t;
15
+ if (r !== Symbol.iterator) return r === "__update" ? () => {} : Object.hasOwn(n, r) ? n[r] : Reflect.get(e, r, i);
16
+ } });
17
+ }, _ = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;"), v = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), y = {
8
18
  id: "intlayer-node-plugin",
9
19
  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 = {
20
+ transform: (e, { children: n, keyPath: r, dictionaryKey: i, ...a }) => {
21
+ if (f) {
22
+ let e = String(n ?? "");
23
+ return g(`<intlayer-content-selector-wrapper key-path="${_(JSON.stringify(r ?? []))}" dictionary-key="${_(String(i ?? ""))}">${v(e)}</intlayer-content-selector-wrapper>`, e);
24
+ }
25
+ return t({
26
+ ...a,
27
+ value: n,
28
+ children: n
29
+ });
30
+ }
31
+ }, b = {
16
32
  id: "insertion-plugin",
17
- canHandle: (e) => typeof e == "object" && e?.nodeType === u.INSERTION,
33
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.INSERTION,
18
34
  transform: (e, t, n) => {
19
- let r = [...t.keyPath, { type: u.INSERTION }], i = e[u.INSERTION], a = {
35
+ let r = [...t.keyPath, { type: p.INSERTION }], i = e[p.INSERTION], a = {
20
36
  id: "insertion-string-plugin",
21
37
  canHandle: (e) => typeof e == "string",
22
38
  transform: (e, n, r) => {
@@ -26,84 +42,77 @@ var d = {
26
42
  plugins: (t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")
27
43
  });
28
44
  return (e) => {
29
- let a = o(i, e), s = a.isSimple ? a.parts : a.parts.join("");
30
- return r(s, {
45
+ let a = s(i, e), o = a.isSimple ? a.parts : a.parts.join("");
46
+ return r(o, {
31
47
  ...n,
32
48
  plugins: t.plugins,
33
- children: s
49
+ children: o
34
50
  });
35
51
  };
36
52
  }
37
- };
38
- return n(i, {
53
+ }, o = n(i, {
39
54
  ...t,
40
55
  children: i,
41
56
  keyPath: r,
42
57
  plugins: [a, ...t.plugins ?? []]
43
58
  });
59
+ return typeof i == "object" && i && "nodeType" in i && [p.ENUMERATION, p.CONDITION].includes(i.nodeType) ? (e) => (t) => {
60
+ let n = o(t);
61
+ return typeof n == "function" ? n(e) : n;
62
+ } : o;
44
63
  }
45
- }, p = {
64
+ }, x = {
46
65
  id: "markdown-string-plugin",
47
66
  canHandle: (e) => typeof e == "string",
48
- transform: (t, n, r) => {
49
- let { plugins: i, ...a } = n, o = r(l(t) ?? {}, {
67
+ transform: (e, n, r) => {
68
+ let { plugins: i, ...a } = n, o = r(d(e) ?? {}, {
50
69
  plugins: [{
51
70
  id: "markdown-metadata-plugin",
52
71
  canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
53
- transform: (n, r) => e({
72
+ transform: (n, r) => t({
54
73
  ...r,
55
74
  value: n,
56
- children: t
75
+ children: e
57
76
  })
58
77
  }],
59
78
  dictionaryKey: a.dictionaryKey,
60
79
  keyPath: []
61
- });
62
- return e({
63
- ...n,
64
- value: t,
65
- children: t,
66
- additionalProps: {
67
- metadata: o,
68
- use: (e) => t
69
- }
80
+ }), s = h(e);
81
+ return g(s, e, {
82
+ metadata: o,
83
+ use: (e) => s
70
84
  });
71
85
  }
72
- }, m = {
86
+ }, S = {
73
87
  id: "markdown-plugin",
74
- canHandle: (e) => typeof e == "object" && e?.nodeType === u.MARKDOWN,
88
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.MARKDOWN,
75
89
  transform: (e, t, n) => {
76
- let r = [...t.keyPath, { type: u.MARKDOWN }], i = e[u.MARKDOWN];
90
+ let r = [...t.keyPath, { type: p.MARKDOWN }], i = e[p.MARKDOWN];
77
91
  return n(i, {
78
92
  ...t,
79
93
  children: i,
80
94
  keyPath: r,
81
- plugins: [p, ...t.plugins ?? []]
95
+ plugins: [x, ...t.plugins ?? []]
82
96
  });
83
97
  }
84
- }, h = {
98
+ }, C = {
85
99
  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
- });
100
+ canHandle: (e) => typeof e == "object" && e?.nodeType === p.HTML,
101
+ transform: (e) => {
102
+ let t = e[p.HTML];
103
+ return g(t, t, { use: (e) => t });
95
104
  }
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),
105
+ }, w = (e, t = !0) => [
106
+ c(e ?? l.internationalization.defaultLocale, t ? l.internationalization.defaultLocale : void 0),
101
107
  r,
108
+ n,
109
+ o(e ?? l.internationalization.defaultLocale),
102
110
  i,
103
- d,
104
- f,
105
- m,
106
- h
111
+ a,
112
+ y,
113
+ b,
114
+ S,
115
+ C
107
116
  ];
108
117
  //#endregion
109
- export { g as getPlugins, h as htmlPlugin, f as insertionPlugin, d as intlayerNodePlugins, m as markdownPlugin, p as markdownStringPlugin };
118
+ export { w as getPlugins, C as htmlPlugin, b as insertionPlugin, y as intlayerNodePlugins, S as markdownPlugin, x as markdownStringPlugin };
@@ -4,6 +4,7 @@ var e = ({ value: e, additionalProps: t = {} }) => {
4
4
  toString: () => String(n ?? ""),
5
5
  valueOf: () => n,
6
6
  [Symbol.toPrimitive]: () => n,
7
+ [Symbol.iterator]: void 0,
7
8
  toJSON: () => n,
8
9
  get raw() {
9
10
  return n;
@@ -0,0 +1,71 @@
1
+ import e from "@intlayer/config/built";
2
+ import { isEnabled as t } from "@intlayer/editor/isEnabled";
3
+ //#region src/editor/useEditor.ts
4
+ var n = class {
5
+ host;
6
+ _stopped = !1;
7
+ _unsubscribeLocale = null;
8
+ constructor(e) {
9
+ this.host = e, e.addController(this);
10
+ }
11
+ hostConnected() {
12
+ this._stopped = !1, t && import("@intlayer/editor").then(({ initEditorClient: e }) => {
13
+ if (this._stopped) return;
14
+ let t = e(), n = s();
15
+ t.currentLocale.set(n.locale), this._unsubscribeLocale = n.subscribe((e) => {
16
+ t.currentLocale.set(e);
17
+ });
18
+ });
19
+ }
20
+ hostDisconnected() {
21
+ this._stopped = !0, this._unsubscribeLocale?.(), this._unsubscribeLocale = null, import("@intlayer/editor").then(({ stopEditorClient: e }) => {
22
+ e();
23
+ });
24
+ }
25
+ };
26
+ function r(e) {
27
+ if (!t) return e ? void 0 : () => {};
28
+ if (!e) {
29
+ let e = !1, t = null;
30
+ return import("@intlayer/editor").then(({ initEditorClient: n }) => {
31
+ if (e) return;
32
+ let r = n(), i = s();
33
+ r.currentLocale.set(i.locale), t = i.subscribe((e) => {
34
+ r.currentLocale.set(e);
35
+ });
36
+ }), () => {
37
+ e = !0, t?.(), import("@intlayer/editor").then(({ stopEditorClient: e }) => {
38
+ e();
39
+ });
40
+ };
41
+ }
42
+ new n(e);
43
+ }
44
+ //#endregion
45
+ //#region src/client/installIntlayer.ts
46
+ var i = class {
47
+ _locale;
48
+ _listeners = /* @__PURE__ */ new Set();
49
+ isCookieEnabled;
50
+ constructor(t, n = !0) {
51
+ let { defaultLocale: r } = e.internationalization ?? {};
52
+ this._locale = t ?? r, this.isCookieEnabled = n;
53
+ }
54
+ get locale() {
55
+ return this._locale;
56
+ }
57
+ setLocale(e) {
58
+ this._locale = e;
59
+ for (let t of this._listeners) t(e);
60
+ }
61
+ subscribe(e) {
62
+ return this._listeners.add(e), () => {
63
+ this._listeners.delete(e);
64
+ };
65
+ }
66
+ }, a = null, o = (e, t = !0) => a || (a = new i(e, t), a), s = () => (a ||= new i(), a), c = ({ locale: e, isCookieEnabled: t } = {}) => {
67
+ let n = o(e, t);
68
+ return r(), n;
69
+ };
70
+ //#endregion
71
+ export { r as a, c as i, o as n, s as r, i as t };
@@ -0,0 +1 @@
1
+ const e=require(`./chunk-C91j1N6u.js`);let t=require(`@intlayer/config/built`);t=e.t(t);let n=require(`@intlayer/editor/isEnabled`);var r=class{host;_stopped=!1;_unsubscribeLocale=null;constructor(e){this.host=e,e.addController(this)}hostConnected(){this._stopped=!1,n.isEnabled&&import(`@intlayer/editor`).then(({initEditorClient:e})=>{if(this._stopped)return;let t=e(),n=c();t.currentLocale.set(n.locale),this._unsubscribeLocale=n.subscribe(e=>{t.currentLocale.set(e)})})}hostDisconnected(){this._stopped=!0,this._unsubscribeLocale?.(),this._unsubscribeLocale=null,import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}};function i(e){if(!n.isEnabled)return e?void 0:()=>{};if(!e){let e=!1,t=null;return import(`@intlayer/editor`).then(({initEditorClient:n})=>{if(e)return;let r=n(),i=c();r.currentLocale.set(i.locale),t=i.subscribe(e=>{r.currentLocale.set(e)})}),()=>{e=!0,t?.(),import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}}new r(e)}var a=class{_locale;_listeners=new Set;isCookieEnabled;constructor(e,n=!0){let{defaultLocale:r}=t.default.internationalization??{};this._locale=e??r,this.isCookieEnabled=n}get locale(){return this._locale}setLocale(e){this._locale=e;for(let t of this._listeners)t(e)}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}},o=null,s=(e,t=!0)=>o||(o=new a(e,t),o),c=()=>(o||=new a,o),l=({locale:e,isCookieEnabled:t}={})=>{let n=s(e,t);return i(),n};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
@@ -0,0 +1,40 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ /**
3
+ * Proxy type returned by every `use*` hook in `lit-intlayer`.
4
+ *
5
+ * Wraps the translated content object with a reactive `.observe()` method so
6
+ * Lit elements participate in the reactive update cycle via a
7
+ * {@link IntlayerBinding} `ReactiveController`.
8
+ *
9
+ * ```ts
10
+ * private content = useIntlayer('app').observe(this);
11
+ * private content = useDictionary(_hash).observe(this);
12
+ * private content = useDictionaryDynamic(_dyn, 'app').observe(this);
13
+ * ```
14
+ */
15
+ export type IntlayerLitProxy<T> = T & {
16
+ observe: (host: ReactiveControllerHost) => IntlayerLitProxy<T>;
17
+ };
18
+ /**
19
+ * `ReactiveController` that keeps a Lit element in sync with Intlayer locale
20
+ * changes and, optionally, async dictionary load events.
21
+ *
22
+ * Registered automatically by `.observe(this)` — you should never need to
23
+ * instantiate it directly.
24
+ *
25
+ * @param host - The Lit element to update.
26
+ * @param onConnect - Called inside `hostConnected` (after locale subscription
27
+ * is set up). Useful for triggering an immediate update
28
+ * when the dictionary is already cached.
29
+ * @param onDisconnect - Called inside `hostDisconnected`. Useful for removing
30
+ * the host from a dictionary's update-host registry.
31
+ */
32
+ export declare class IntlayerBinding implements ReactiveController {
33
+ private host;
34
+ private unsubscribeLocale;
35
+ private readonly onConnect?;
36
+ private readonly onDisconnect?;
37
+ constructor(host: ReactiveControllerHost, onConnect?: () => void, onDisconnect?: () => void);
38
+ hostConnected(): void;
39
+ hostDisconnected(): void;
40
+ }
@@ -1,5 +1,7 @@
1
+ export * from './IntlayerBinding';
1
2
  export * from './installIntlayer';
2
3
  export * from './useDictionary';
4
+ export * from './useDictionaryDynamic';
3
5
  export * from './useIntlayer';
4
6
  export * from './useLocale';
5
7
  export * from './useLocaleStorage';
@@ -22,16 +22,32 @@ export declare const getIntlayerClient: () => IntlayerClient;
22
22
  *
23
23
  * Call this once at application startup before any Lit elements are rendered.
24
24
  *
25
+ * When called with a `config` argument, `window.INTLAYER_CONFIG` is set so
26
+ * that `@intlayer/config/built` resolves the correct values in the browser
27
+ * without requiring module aliasing in the bundler configuration.
28
+ *
25
29
  * @param locale - Initial locale (defaults to config defaultLocale).
26
30
  * @param isCookieEnabled - Whether to persist locale in cookies/localStorage.
31
+ * @param config - Optional Intlayer configuration. When provided, sets
32
+ * `window.INTLAYER_CONFIG` with the browser-safe subset of the config so
33
+ * the application works without a Vite/webpack plugin alias.
27
34
  * @returns The IntlayerClient singleton.
28
35
  *
29
36
  * @example
30
37
  * ```ts
31
38
  * import { installIntlayer } from 'lit-intlayer';
32
39
  *
40
+ * // With explicit config (no build plugin alias needed):
41
+ * installIntlayer('en', true, {
42
+ * internationalization: { locales: ['en', 'fr'], defaultLocale: 'en' },
43
+ * });
44
+ *
45
+ * // With build plugin (alias handles config automatically):
33
46
  * installIntlayer('en');
34
47
  * ```
35
48
  */
36
- export declare const installIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerClient;
49
+ export declare const installIntlayer: ({ locale, isCookieEnabled, }?: {
50
+ locale?: LocalesValues;
51
+ isCookieEnabled?: boolean;
52
+ }) => IntlayerClient;
37
53
  export {};