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.
- package/dist/cjs/client/IntlayerBinding.cjs +93 -1
- package/dist/cjs/client/index.cjs +28 -1
- package/dist/cjs/client/installIntlayer.cjs +6 -1
- package/dist/cjs/client/useDictionary.cjs +24 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +47 -1
- package/dist/cjs/client/useIntlayer.cjs +30 -1
- package/dist/cjs/client/useLocale.cjs +90 -1
- package/dist/cjs/client/useLocaleStorage.cjs +56 -1
- package/dist/cjs/client/useRewriteURL.cjs +48 -1
- package/dist/cjs/editor/useEditor.cjs +3 -1
- package/dist/cjs/format/index.cjs +19 -1
- package/dist/cjs/format/useCompact.cjs +34 -1
- package/dist/cjs/format/useCurrency.cjs +34 -1
- package/dist/cjs/format/useDate.cjs +52 -1
- package/dist/cjs/format/useIntl.cjs +66 -1
- package/dist/cjs/format/useList.cjs +34 -1
- package/dist/cjs/format/useNumber.cjs +40 -1
- package/dist/cjs/format/usePercentage.cjs +34 -1
- package/dist/cjs/format/useRelativeTime.cjs +34 -1
- package/dist/cjs/format/useUnit.cjs +34 -1
- package/dist/cjs/getDictionary.cjs +14 -1
- package/dist/cjs/getIntlayer.cjs +14 -1
- package/dist/cjs/html/HTMLRenderer.cjs +53 -1
- package/dist/cjs/html/index.cjs +8 -1
- package/dist/cjs/html/installIntlayerHTML.cjs +90 -1
- package/dist/cjs/html/types.cjs +1 -1
- package/dist/cjs/index.cjs +41 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +97 -1
- package/dist/cjs/markdown/compiler.cjs +72 -1
- package/dist/cjs/markdown/index.cjs +12 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
- package/dist/cjs/markdown/runtime.cjs +86 -1
- package/dist/cjs/plugins.cjs +217 -3
- package/dist/cjs/renderIntlayerNode.cjs +29 -1
- package/dist/esm/client/IntlayerBinding.mjs +75 -33
- package/dist/esm/client/index.mjs +9 -9
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs +22 -10
- package/dist/esm/client/useDictionaryDynamic.mjs +44 -11
- package/dist/esm/client/useIntlayer.mjs +28 -10
- package/dist/esm/client/useLocale.mjs +71 -19
- package/dist/esm/client/useLocaleStorage.mjs +45 -12
- package/dist/esm/client/useRewriteURL.mjs +36 -18
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/format/index.mjs +10 -10
- package/dist/esm/format/useCompact.mjs +23 -19
- package/dist/esm/format/useCurrency.mjs +23 -19
- package/dist/esm/format/useDate.mjs +37 -27
- package/dist/esm/format/useIntl.mjs +54 -13
- package/dist/esm/format/useList.mjs +23 -19
- package/dist/esm/format/useNumber.mjs +29 -19
- package/dist/esm/format/usePercentage.mjs +23 -19
- package/dist/esm/format/useRelativeTime.mjs +23 -19
- package/dist/esm/format/useUnit.mjs +23 -19
- package/dist/esm/getDictionary.mjs +11 -6
- package/dist/esm/getIntlayer.mjs +11 -6
- package/dist/esm/html/HTMLRenderer.mjs +38 -13
- package/dist/esm/html/index.mjs +3 -3
- package/dist/esm/html/installIntlayerHTML.mjs +82 -13
- package/dist/esm/index.mjs +12 -12
- package/dist/esm/markdown/MarkdownRenderer.mjs +66 -26
- package/dist/esm/markdown/compiler.mjs +68 -22
- package/dist/esm/markdown/index.mjs +4 -4
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +87 -23
- package/dist/esm/markdown/runtime.mjs +58 -28
- package/dist/esm/plugins.mjs +156 -106
- package/dist/esm/renderIntlayerNode.mjs +17 -17
- package/dist/installIntlayer-CCMOc1XT.mjs +174 -0
- package/dist/installIntlayer-HB8aIQ-i.js +203 -0
- package/package.json +7 -7
- package/dist/installIntlayer-CFvvijL7.js +0 -1
- package/dist/installIntlayer-CTpPd7yz.mjs +0 -82
|
@@ -1 +1,66 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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;
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
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
|
|
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;
|
package/dist/cjs/html/index.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
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,
|
|
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;
|
package/dist/cjs/html/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1,41 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
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
|
|
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;
|