lit-intlayer 9.9.3 → 9.9.4

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 (72) hide show
  1. package/dist/cjs/client/IntlayerBinding.cjs +93 -1
  2. package/dist/cjs/client/index.cjs +28 -1
  3. package/dist/cjs/client/installIntlayer.cjs +6 -1
  4. package/dist/cjs/client/useDictionary.cjs +24 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +47 -1
  6. package/dist/cjs/client/useIntlayer.cjs +30 -1
  7. package/dist/cjs/client/useLocale.cjs +90 -1
  8. package/dist/cjs/client/useLocaleStorage.cjs +56 -1
  9. package/dist/cjs/client/useRewriteURL.cjs +48 -1
  10. package/dist/cjs/editor/useEditor.cjs +3 -1
  11. package/dist/cjs/format/index.cjs +19 -1
  12. package/dist/cjs/format/useCompact.cjs +34 -1
  13. package/dist/cjs/format/useCurrency.cjs +34 -1
  14. package/dist/cjs/format/useDate.cjs +52 -1
  15. package/dist/cjs/format/useIntl.cjs +66 -1
  16. package/dist/cjs/format/useList.cjs +34 -1
  17. package/dist/cjs/format/useNumber.cjs +40 -1
  18. package/dist/cjs/format/usePercentage.cjs +34 -1
  19. package/dist/cjs/format/useRelativeTime.cjs +34 -1
  20. package/dist/cjs/format/useUnit.cjs +34 -1
  21. package/dist/cjs/getDictionary.cjs +14 -1
  22. package/dist/cjs/getIntlayer.cjs +14 -1
  23. package/dist/cjs/html/HTMLRenderer.cjs +53 -1
  24. package/dist/cjs/html/index.cjs +8 -1
  25. package/dist/cjs/html/installIntlayerHTML.cjs +90 -1
  26. package/dist/cjs/html/types.cjs +1 -1
  27. package/dist/cjs/index.cjs +41 -1
  28. package/dist/cjs/markdown/MarkdownRenderer.cjs +97 -1
  29. package/dist/cjs/markdown/compiler.cjs +72 -1
  30. package/dist/cjs/markdown/index.cjs +12 -1
  31. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
  32. package/dist/cjs/markdown/runtime.cjs +86 -1
  33. package/dist/cjs/plugins.cjs +217 -3
  34. package/dist/cjs/renderIntlayerNode.cjs +29 -1
  35. package/dist/esm/client/IntlayerBinding.mjs +75 -33
  36. package/dist/esm/client/index.mjs +9 -9
  37. package/dist/esm/client/installIntlayer.mjs +1 -1
  38. package/dist/esm/client/useDictionary.mjs +22 -10
  39. package/dist/esm/client/useDictionaryDynamic.mjs +44 -11
  40. package/dist/esm/client/useIntlayer.mjs +28 -10
  41. package/dist/esm/client/useLocale.mjs +71 -19
  42. package/dist/esm/client/useLocaleStorage.mjs +45 -12
  43. package/dist/esm/client/useRewriteURL.mjs +36 -18
  44. package/dist/esm/editor/useEditor.mjs +1 -1
  45. package/dist/esm/format/index.mjs +10 -10
  46. package/dist/esm/format/useCompact.mjs +23 -19
  47. package/dist/esm/format/useCurrency.mjs +23 -19
  48. package/dist/esm/format/useDate.mjs +37 -27
  49. package/dist/esm/format/useIntl.mjs +54 -13
  50. package/dist/esm/format/useList.mjs +23 -19
  51. package/dist/esm/format/useNumber.mjs +29 -19
  52. package/dist/esm/format/usePercentage.mjs +23 -19
  53. package/dist/esm/format/useRelativeTime.mjs +23 -19
  54. package/dist/esm/format/useUnit.mjs +23 -19
  55. package/dist/esm/getDictionary.mjs +11 -6
  56. package/dist/esm/getIntlayer.mjs +11 -6
  57. package/dist/esm/html/HTMLRenderer.mjs +38 -13
  58. package/dist/esm/html/index.mjs +3 -3
  59. package/dist/esm/html/installIntlayerHTML.mjs +82 -13
  60. package/dist/esm/index.mjs +12 -12
  61. package/dist/esm/markdown/MarkdownRenderer.mjs +66 -26
  62. package/dist/esm/markdown/compiler.mjs +68 -22
  63. package/dist/esm/markdown/index.mjs +4 -4
  64. package/dist/esm/markdown/installIntlayerMarkdown.mjs +87 -23
  65. package/dist/esm/markdown/runtime.mjs +58 -28
  66. package/dist/esm/plugins.mjs +156 -106
  67. package/dist/esm/renderIntlayerNode.mjs +17 -17
  68. package/dist/installIntlayer-CCMOc1XT.mjs +174 -0
  69. package/dist/installIntlayer-HB8aIQ-i.js +203 -0
  70. package/package.json +7 -7
  71. package/dist/installIntlayer-CFvvijL7.js +0 -1
  72. package/dist/installIntlayer-CTpPd7yz.mjs +0 -82
@@ -1 +1,66 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/utils");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_overrideLocale;_unsubscribe=null;value;constructor(n,r){this.host=n,this._overrideLocale=r;let i=t.r();this.value=(0,e.bindIntl)(this._overrideLocale??i.locale),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(0,e.bindIntl)(this._overrideLocale??t),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=(e,t)=>new n(e,t);exports.useIntl=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_utils = require("@intlayer/core/utils");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useIntl.ts
5
+ /**
6
+ * ReactiveController that provides a locale-bound `Intl` object.
7
+ *
8
+ * Acts exactly like the native `Intl` namespace but automatically uses the
9
+ * current application locale, updating the host whenever the locale changes.
10
+ *
11
+ * @internal
12
+ */
13
+ var IntlController = class {
14
+ host;
15
+ _overrideLocale;
16
+ _unsubscribe = null;
17
+ /** The locale-bound Intl object. */
18
+ value;
19
+ constructor(host, locale) {
20
+ this.host = host;
21
+ this._overrideLocale = locale;
22
+ const client = require_installIntlayer.getIntlayerClient();
23
+ this.value = (0, _intlayer_core_utils.bindIntl)(this._overrideLocale ?? client.locale);
24
+ host.addController(this);
25
+ }
26
+ hostConnected() {
27
+ const client = require_installIntlayer.getIntlayerClient();
28
+ this._unsubscribe = client.subscribe((newLocale) => {
29
+ this.value = (0, _intlayer_core_utils.bindIntl)(this._overrideLocale ?? newLocale);
30
+ this.host.requestUpdate();
31
+ });
32
+ }
33
+ hostDisconnected() {
34
+ this._unsubscribe?.();
35
+ this._unsubscribe = null;
36
+ }
37
+ };
38
+ /**
39
+ * Reactive hook that provides a locale-bound `Intl` object.
40
+ *
41
+ * The returned controller's `.value` property gives access to locale-aware
42
+ * `NumberFormat`, `DateTimeFormat`, `RelativeTimeFormat`, etc. without
43
+ * needing to pass the current locale manually.
44
+ *
45
+ * @param host - The LitElement (or any ReactiveControllerHost).
46
+ * @param locale - Optional locale override.
47
+ * @returns An `IntlController` with a `.value: WrappedIntl` property.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * class PriceTag extends LitElement {
52
+ * private intl = useIntl(this);
53
+ *
54
+ * render() {
55
+ * const formatted = new this.intl.value.NumberFormat({
56
+ * style: 'currency',
57
+ * currency: 'USD',
58
+ * }).format(9.99);
59
+ *
60
+ * return html`<span>${formatted}</span>`;
61
+ * }
62
+ * }
63
+ * ```
64
+ */
65
+ var useIntl = (host, locale) => new IntlController(host, locale);
66
+ exports.useIntl = useIntl;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.list)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.list)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useList=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useList.ts
5
+ var ListController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.list)(args[0], {
13
+ ...args[1],
14
+ locale: args[1]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.list)(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var useList = (host) => new ListController(host);
34
+ exports.useList = useList;
@@ -1 +1,40 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.number)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.number)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useNumber=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useNumber.ts
5
+ /**
6
+ * ReactiveController that provides a locale-bound number formatter.
7
+ */
8
+ var NumberController = class {
9
+ host;
10
+ _unsubscribe = null;
11
+ value;
12
+ constructor(host) {
13
+ this.host = host;
14
+ const client = require_installIntlayer.getIntlayerClient();
15
+ this.value = (...args) => (0, _intlayer_core_formatters.number)(args[0], {
16
+ ...args[1],
17
+ locale: args[1]?.locale ?? client.locale
18
+ });
19
+ host.addController(this);
20
+ }
21
+ hostConnected() {
22
+ const client = require_installIntlayer.getIntlayerClient();
23
+ this._unsubscribe = client.subscribe((newLocale) => {
24
+ this.value = (...args) => (0, _intlayer_core_formatters.number)(args[0], {
25
+ ...args[1],
26
+ locale: args[1]?.locale ?? newLocale
27
+ });
28
+ this.host.requestUpdate();
29
+ });
30
+ }
31
+ hostDisconnected() {
32
+ this._unsubscribe?.();
33
+ this._unsubscribe = null;
34
+ }
35
+ };
36
+ /**
37
+ * Reactive hook that provides a locale-bound number formatter.
38
+ */
39
+ var useNumber = (host) => new NumberController(host);
40
+ exports.useNumber = useNumber;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.percentage)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.percentage)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.usePercentage=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/usePercentage.ts
5
+ var PercentageController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.percentage)(args[0], {
13
+ ...args[1],
14
+ locale: args[1]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.percentage)(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var usePercentage = (host) => new PercentageController(host);
34
+ exports.usePercentage = usePercentage;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.relativeTime)(t[0],t[1],{...t[2],locale:t[2]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.relativeTime)(n[0],n[1],{...n[2],locale:n[2]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useRelativeTime=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useRelativeTime.ts
5
+ var RelativeTimeController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.relativeTime)(args[0], args[1], {
13
+ ...args[2],
14
+ locale: args[2]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.relativeTime)(args[0], args[1], {
22
+ ...args[2],
23
+ locale: args[2]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var useRelativeTime = (host) => new RelativeTimeController(host);
34
+ exports.useRelativeTime = useRelativeTime;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.units)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.units)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useUnit=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useUnit.ts
5
+ var UnitController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.units)(args[0], {
13
+ ...args[1],
14
+ locale: args[1]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.units)(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var useUnit = (host) => new UnitController(host);
34
+ exports.useUnit = useUnit;
@@ -1 +1,14 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/interpreter");const t=require("./plugins.cjs");var n=(n,r)=>{let i=typeof r==`object`&&r?r.locale:r;return(0,e.getDictionary)(n,r,t.getPlugins(i))};exports.getDictionary=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
3
+ const require_plugins = require("./plugins.cjs");
4
+ // src/getDictionary.ts
5
+ /**
6
+ * Transforms a dictionary (or qualified dictionary group) and returns its
7
+ * content for the given locale or selector (`{ item }`, `{ variant }`,
8
+ * optionally combined with `locale`).
9
+ */
10
+ var getDictionary = (dictionary, localeOrSelector) => {
11
+ const locale = typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector;
12
+ return (0, _intlayer_core_interpreter.getDictionary)(dictionary, localeOrSelector, require_plugins.getPlugins(locale));
13
+ };
14
+ exports.getDictionary = getDictionary;
@@ -1 +1,14 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/interpreter");const t=require("./plugins.cjs");var n=(n,r)=>{let i=typeof r==`object`&&r?r.locale:r;return(0,e.getIntlayer)(n,r,t.getPlugins(i))};exports.getIntlayer=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
3
+ const require_plugins = require("./plugins.cjs");
4
+ // src/getIntlayer.ts
5
+ /**
6
+ * Picks one dictionary by its key and returns its content for the given
7
+ * locale or selector (`{ item }`, `{ variant }`,
8
+ * optionally combined with `locale`).
9
+ */
10
+ var getIntlayer = (key, localeOrSelector) => {
11
+ const locale = typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector;
12
+ return (0, _intlayer_core_interpreter.getIntlayer)(key, localeOrSelector, require_plugins.getPlugins(locale));
13
+ };
14
+ exports.getIntlayer = getIntlayer;
@@ -1 +1,53 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("lit"),t=require("lit/directives/unsafe-html.js");const n=require("./installIntlayerHTML.cjs");var r=(e,t={})=>e,i=({components:e}={})=>{let t=n.useHTML();return n=>t.renderHTML(n,{components:e})},a=class extends e.LitElement{static properties={content:{type:String},components:{attribute:!1}};content=``;components;createRenderRoot(){return this}render(){if(!this.content)return e.nothing;let n=i({components:this.components});return e.html`${(0,t.unsafeHTML)(n(this.content))}`}};customElements.get(`intlayer-html-renderer`)||customElements.define(`intlayer-html-renderer`,a),exports.HTMLRenderer=a,exports.renderHTML=r,exports.useHTMLRenderer=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let lit = require("lit");
3
+ let lit_directives_unsafe_html_js = require("lit/directives/unsafe-html.js");
4
+ const require_html_installIntlayerHTML = require("./installIntlayerHTML.cjs");
5
+ // src/html/HTMLRenderer.ts
6
+ /**
7
+ * Renders an HTML string directly, without a global provider.
8
+ * Returns the raw string; pass to `unsafeHTML()` in a Lit template.
9
+ */
10
+ var renderHTML = (content, _props = {}) => content;
11
+ /**
12
+ * Returns a render function that uses the global provider's configuration
13
+ * (installed via `installIntlayerHTML`), falling back to identity.
14
+ */
15
+ var useHTMLRenderer = ({ components } = {}) => {
16
+ const context = require_html_installIntlayerHTML.useHTML();
17
+ return (content) => context.renderHTML(content, { components });
18
+ };
19
+ /**
20
+ * `<intlayer-html-renderer>` — renders an HTML string into the light DOM.
21
+ *
22
+ * Uses the globally installed HTML renderer when available
23
+ * (see `installIntlayerHTML`), or falls back to `unsafeHTML` with the raw string.
24
+ *
25
+ * @example
26
+ * ```html
27
+ * <intlayer-html-renderer content="<strong>Hello</strong> World">
28
+ * </intlayer-html-renderer>
29
+ * ```
30
+ */
31
+ var HTMLRenderer = class extends lit.LitElement {
32
+ static properties = {
33
+ content: { type: String },
34
+ components: { attribute: false }
35
+ };
36
+ /** The HTML string to render. */
37
+ content = "";
38
+ /** Optional component overrides for HTML tags. */
39
+ components;
40
+ /** Render into light DOM so host-page CSS can style the output. */
41
+ createRenderRoot() {
42
+ return this;
43
+ }
44
+ render() {
45
+ if (!this.content) return lit.nothing;
46
+ const renderer = useHTMLRenderer({ components: this.components });
47
+ return lit.html`${(0, lit_directives_unsafe_html_js.unsafeHTML)(renderer(this.content))}`;
48
+ }
49
+ };
50
+ if (!customElements.get("intlayer-html-renderer")) customElements.define("intlayer-html-renderer", HTMLRenderer);
51
+ exports.HTMLRenderer = HTMLRenderer;
52
+ exports.renderHTML = renderHTML;
53
+ exports.useHTMLRenderer = useHTMLRenderer;
@@ -1 +1,8 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./HTMLRenderer.cjs"),t=require("./installIntlayerHTML.cjs");exports.installIntlayerHTML=t.installIntlayerHTML,exports.installIntlayerHTMLDynamic=t.installIntlayerHTMLDynamic,exports.renderHTML=e.renderHTML,exports.useHTML=t.useHTML,exports.useHTMLRenderer=e.useHTMLRenderer;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_html_HTMLRenderer = require("./HTMLRenderer.cjs");
3
+ const require_html_installIntlayerHTML = require("./installIntlayerHTML.cjs");
4
+ exports.installIntlayerHTML = require_html_installIntlayerHTML.installIntlayerHTML;
5
+ exports.installIntlayerHTMLDynamic = require_html_installIntlayerHTML.installIntlayerHTMLDynamic;
6
+ exports.renderHTML = require_html_HTMLRenderer.renderHTML;
7
+ exports.useHTML = require_html_installIntlayerHTML.useHTML;
8
+ exports.useHTMLRenderer = require_html_HTMLRenderer.useHTMLRenderer;
@@ -1 +1,90 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=null,t=t=>e||(e={renderHTML:t},e),n=e=>{let n;if(typeof e==`function`)n=e;else{let{components:t,renderHTML:r}=e??{};n=r||((e,n)=>{let r=n&&typeof n==`object`&&`components`in n?n.components:n,i={...t??{},...r??{}};return Object.keys(i).length,e})}return t(n)},r=()=>e||{renderHTML:e=>e},i=async t=>e||n(await t());exports.createIntlayerHTMLClient=t,exports.installIntlayerHTML=n,exports.installIntlayerHTMLDynamic=i,exports.useHTML=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/html/installIntlayerHTML.ts
3
+ /**
4
+ * Singleton instance
5
+ */
6
+ var instance = null;
7
+ /**
8
+ * Create and return a single IntlayerHTMLProvider instance.
9
+ */
10
+ var createIntlayerHTMLClient = (renderHTML) => {
11
+ if (instance) return instance;
12
+ instance = { renderHTML };
13
+ return instance;
14
+ };
15
+ /**
16
+ * Install the Intlayer HTML provider for your Lit application.
17
+ *
18
+ * The installed renderer is used by `<intlayer-html-renderer>` and
19
+ * `useHTMLRenderer()`.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { installIntlayerHTML } from 'lit-intlayer';
24
+ *
25
+ * installIntlayerHTML({
26
+ * components: {
27
+ * a: ({ href, children }) => `<a class="styled-link" href="${href}">${children}</a>`,
28
+ * },
29
+ * });
30
+ * ```
31
+ */
32
+ var installIntlayerHTML = (pluginOptions) => {
33
+ let renderHTML;
34
+ if (typeof pluginOptions === "function") renderHTML = pluginOptions;
35
+ else {
36
+ const { components, renderHTML: customRender } = pluginOptions ?? {};
37
+ if (customRender) renderHTML = customRender;
38
+ else renderHTML = (rawHTML, overrides) => {
39
+ const overrideComponents = overrides && typeof overrides === "object" && "components" in overrides ? overrides.components : overrides;
40
+ const mergedComponents = {
41
+ ...components ?? {},
42
+ ...overrideComponents ?? {}
43
+ };
44
+ if (!Object.keys(mergedComponents).length) return rawHTML;
45
+ return rawHTML;
46
+ };
47
+ }
48
+ return createIntlayerHTMLClient(renderHTML);
49
+ };
50
+ /**
51
+ * Access the installed IntlayerHTMLProvider.
52
+ * Returns a fallback renderer that outputs the raw HTML string if no
53
+ * provider has been installed.
54
+ */
55
+ var useHTML = () => {
56
+ if (instance) return instance;
57
+ return { renderHTML: (rawHTML) => rawHTML };
58
+ };
59
+ /**
60
+ * Asynchronously install an HTML renderer whose implementation is loaded
61
+ * via a dynamic `import()`.
62
+ *
63
+ * Use this to keep a heavy HTML sanitiser / component renderer out of the
64
+ * initial bundle — the loader is only called the first time this function
65
+ * is executed.
66
+ *
67
+ * The returned promise resolves once the provider is ready. Any calls to
68
+ * `useHTML()` before the promise resolves will use the fallback (identity)
69
+ * renderer.
70
+ *
71
+ * @param loader - A zero-argument async function that resolves to either a
72
+ * `RenderHTMLFunction` or an `IntlayerHTMLPluginOptions` object.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * // Load a custom HTML sanitiser only when needed
77
+ * await installIntlayerHTMLDynamic(async () => {
78
+ * const DOMPurify = await import('dompurify');
79
+ * return (html) => DOMPurify.sanitize(html);
80
+ * });
81
+ * ```
82
+ */
83
+ var installIntlayerHTMLDynamic = async (loader) => {
84
+ if (instance) return instance;
85
+ return installIntlayerHTML(await loader());
86
+ };
87
+ exports.createIntlayerHTMLClient = createIntlayerHTMLClient;
88
+ exports.installIntlayerHTML = installIntlayerHTML;
89
+ exports.installIntlayerHTMLDynamic = installIntlayerHTMLDynamic;
90
+ exports.useHTML = useHTML;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1 +1,41 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./client/useLocaleStorage.cjs"),t=require("../installIntlayer-CFvvijL7.js"),n=require("./getDictionary.cjs"),r=require("./getIntlayer.cjs"),i=require("./client/IntlayerBinding.cjs"),a=require("./plugins.cjs"),o=require("./client/useDictionary.cjs"),s=require("./client/useDictionaryDynamic.cjs"),c=require("./client/useIntlayer.cjs"),l=require("./client/useLocale.cjs"),u=require("./client/useRewriteURL.cjs");require("./client/index.cjs"),exports.IntlayerBinding=i.IntlayerBinding,exports.IntlayerClient=t.t,exports.LocaleController=l.LocaleController,exports.createContentProxy=i.createContentProxy,exports.createIntlayerClient=t.n,exports.getDictionary=n.getDictionary,exports.getIntlayer=r.getIntlayer,exports.getIntlayerClient=t.r,exports.getLocaleInStorage=e.getLocaleInStorage,exports.getPlugins=a.getPlugins,exports.htmlPlugin=a.htmlPlugin,exports.insertionPlugin=a.insertionPlugin,exports.installIntlayer=t.i,exports.intlayerNodePlugins=a.intlayerNodePlugins,exports.localeCookie=e.localeCookie,exports.localeInStorage=e.localeInStorage,exports.markdownPlugin=a.markdownPlugin,exports.markdownStringPlugin=a.markdownStringPlugin,exports.setLocaleCookie=e.setLocaleCookie,exports.setLocaleInStorage=e.setLocaleInStorage,exports.useDictionary=o.useDictionary,exports.useDictionaryDynamic=s.useDictionaryDynamic,exports.useEditor=t.a,exports.useIntlayer=c.useIntlayer,exports.useLocale=l.useLocale,exports.useLocaleCookie=e.useLocaleCookie,exports.useLocaleStorage=e.useLocaleStorage,exports.useRewriteURL=u.useRewriteURL;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_client_useLocaleStorage = require("./client/useLocaleStorage.cjs");
3
+ const require_installIntlayer = require("../installIntlayer-HB8aIQ-i.js");
4
+ const require_getDictionary = require("./getDictionary.cjs");
5
+ const require_getIntlayer = require("./getIntlayer.cjs");
6
+ const require_client_IntlayerBinding = require("./client/IntlayerBinding.cjs");
7
+ const require_client_useDictionary = require("./client/useDictionary.cjs");
8
+ const require_client_useDictionaryDynamic = require("./client/useDictionaryDynamic.cjs");
9
+ const require_plugins = require("./plugins.cjs");
10
+ const require_client_useIntlayer = require("./client/useIntlayer.cjs");
11
+ const require_client_useLocale = require("./client/useLocale.cjs");
12
+ const require_client_useRewriteURL = require("./client/useRewriteURL.cjs");
13
+ require("./client/index.cjs");
14
+ exports.IntlayerBinding = require_client_IntlayerBinding.IntlayerBinding;
15
+ exports.IntlayerClient = require_installIntlayer.IntlayerClient;
16
+ exports.LocaleController = require_client_useLocale.LocaleController;
17
+ exports.createContentProxy = require_client_IntlayerBinding.createContentProxy;
18
+ exports.createIntlayerClient = require_installIntlayer.createIntlayerClient;
19
+ exports.getDictionary = require_getDictionary.getDictionary;
20
+ exports.getIntlayer = require_getIntlayer.getIntlayer;
21
+ exports.getIntlayerClient = require_installIntlayer.getIntlayerClient;
22
+ exports.getLocaleInStorage = require_client_useLocaleStorage.getLocaleInStorage;
23
+ exports.getPlugins = require_plugins.getPlugins;
24
+ exports.htmlPlugin = require_plugins.htmlPlugin;
25
+ exports.insertionPlugin = require_plugins.insertionPlugin;
26
+ exports.installIntlayer = require_installIntlayer.installIntlayer;
27
+ exports.intlayerNodePlugins = require_plugins.intlayerNodePlugins;
28
+ exports.localeCookie = require_client_useLocaleStorage.localeCookie;
29
+ exports.localeInStorage = require_client_useLocaleStorage.localeInStorage;
30
+ exports.markdownPlugin = require_plugins.markdownPlugin;
31
+ exports.markdownStringPlugin = require_plugins.markdownStringPlugin;
32
+ exports.setLocaleCookie = require_client_useLocaleStorage.setLocaleCookie;
33
+ exports.setLocaleInStorage = require_client_useLocaleStorage.setLocaleInStorage;
34
+ exports.useDictionary = require_client_useDictionary.useDictionary;
35
+ exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
36
+ exports.useEditor = require_installIntlayer.useEditor;
37
+ exports.useIntlayer = require_client_useIntlayer.useIntlayer;
38
+ exports.useLocale = require_client_useLocale.useLocale;
39
+ exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
40
+ exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
41
+ exports.useRewriteURL = require_client_useRewriteURL.useRewriteURL;
@@ -1 +1,97 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("lit"),t=require("lit/directives/unsafe-html.js");const n=require("./compiler.cjs"),r=require("./installIntlayerMarkdown.cjs");var i=(e,{forceBlock:t,forceInline:r,preserveFrontmatter:i,tagfilter:a}={})=>n.compileMarkdown(e,{forceBlock:t,forceInline:r,preserveFrontmatter:i,tagfilter:a}),a=(e={})=>{let t=r.useMarkdown();return n=>t.renderMarkdown(n,{forceBlock:e.forceBlock,forceInline:e.forceInline,preserveFrontmatter:e.preserveFrontmatter,tagfilter:e.tagfilter},e.components,e.wrapper)},o=class extends e.LitElement{static properties={content:{type:[String,Object]},forceBlock:{type:Boolean},forceInline:{type:Boolean},preserveFrontmatter:{type:Boolean},tagfilter:{type:Boolean},renderMarkdown:{attribute:!1}};content=``;forceBlock;forceInline;preserveFrontmatter;tagfilter;renderMarkdownFn;createRenderRoot(){return this}render(){if(!this.content)return e.nothing;let n;return n=this.renderMarkdownFn?this.renderMarkdownFn(this.content,{forceBlock:this.forceBlock,forceInline:this.forceInline,preserveFrontmatter:this.preserveFrontmatter,tagfilter:this.tagfilter},void 0,void 0):a({forceBlock:this.forceBlock,forceInline:this.forceInline,preserveFrontmatter:this.preserveFrontmatter,tagfilter:this.tagfilter})(this.content),e.html`${(0,t.unsafeHTML)(n)}`}};customElements.get(`intlayer-markdown-renderer`)||customElements.define(`intlayer-markdown-renderer`,o),exports.MarkdownRenderer=o,exports.renderMarkdown=i,exports.useMarkdownRenderer=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let lit = require("lit");
3
+ let lit_directives_unsafe_html_js = require("lit/directives/unsafe-html.js");
4
+ const require_markdown_compiler = require("./compiler.cjs");
5
+ const require_markdown_installIntlayerMarkdown = require("./installIntlayerMarkdown.cjs");
6
+ // src/markdown/MarkdownRenderer.ts
7
+ /**
8
+ * Renders markdown to an HTML string without using the global provider.
9
+ * Pass the result to `unsafeHTML()` in a Lit template.
10
+ */
11
+ var renderMarkdown = (content, { forceBlock, forceInline, preserveFrontmatter, tagfilter } = {}) => {
12
+ return require_markdown_compiler.compileMarkdown(content, {
13
+ forceBlock,
14
+ forceInline,
15
+ preserveFrontmatter,
16
+ tagfilter
17
+ });
18
+ };
19
+ /**
20
+ * Returns a render function that uses the global provider's configuration
21
+ * (installed via `installIntlayerMarkdown`), falling back to `compileMarkdown`.
22
+ */
23
+ var useMarkdownRenderer = (props = {}) => {
24
+ const provider = require_markdown_installIntlayerMarkdown.useMarkdown();
25
+ return (content) => provider.renderMarkdown(content, {
26
+ forceBlock: props.forceBlock,
27
+ forceInline: props.forceInline,
28
+ preserveFrontmatter: props.preserveFrontmatter,
29
+ tagfilter: props.tagfilter
30
+ }, props.components, props.wrapper);
31
+ };
32
+ /**
33
+ * `<intlayer-markdown-renderer>` — renders a markdown string as HTML.
34
+ *
35
+ * Renders into the light DOM (no shadow root) so that the host page's CSS
36
+ * can style the generated markup.
37
+ *
38
+ * Uses the globally installed markdown renderer when available
39
+ * (see `installIntlayerMarkdown`), or falls back to the default compiler.
40
+ *
41
+ * @example
42
+ * ```html
43
+ * <intlayer-markdown-renderer content="# Hello **World**">
44
+ * </intlayer-markdown-renderer>
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { html } from 'lit';
50
+ * import 'lit-intlayer/markdown'; // registers the element
51
+ *
52
+ * html`<intlayer-markdown-renderer .content=${myMarkdown}></intlayer-markdown-renderer>`
53
+ * ```
54
+ */
55
+ var MarkdownRenderer = class extends lit.LitElement {
56
+ static properties = {
57
+ content: { type: [String, Object] },
58
+ forceBlock: { type: Boolean },
59
+ forceInline: { type: Boolean },
60
+ preserveFrontmatter: { type: Boolean },
61
+ tagfilter: { type: Boolean },
62
+ renderMarkdown: { attribute: false }
63
+ };
64
+ /** The markdown string to compile and render. */
65
+ content = "";
66
+ forceBlock;
67
+ forceInline;
68
+ preserveFrontmatter;
69
+ tagfilter;
70
+ /** Optional custom render function — overrides the global provider. */
71
+ renderMarkdownFn;
72
+ /** Render into light DOM so host-page CSS can style the output. */
73
+ createRenderRoot() {
74
+ return this;
75
+ }
76
+ render() {
77
+ if (!this.content) return lit.nothing;
78
+ let compiled;
79
+ if (this.renderMarkdownFn) compiled = this.renderMarkdownFn(this.content, {
80
+ forceBlock: this.forceBlock,
81
+ forceInline: this.forceInline,
82
+ preserveFrontmatter: this.preserveFrontmatter,
83
+ tagfilter: this.tagfilter
84
+ }, void 0, void 0);
85
+ else compiled = useMarkdownRenderer({
86
+ forceBlock: this.forceBlock,
87
+ forceInline: this.forceInline,
88
+ preserveFrontmatter: this.preserveFrontmatter,
89
+ tagfilter: this.tagfilter
90
+ })(this.content);
91
+ return lit.html`${(0, lit_directives_unsafe_html_js.unsafeHTML)(compiled)}`;
92
+ }
93
+ };
94
+ if (!customElements.get("intlayer-markdown-renderer")) customElements.define("intlayer-markdown-renderer", MarkdownRenderer);
95
+ exports.MarkdownRenderer = MarkdownRenderer;
96
+ exports.renderMarkdown = renderMarkdown;
97
+ exports.useMarkdownRenderer = useMarkdownRenderer;