solid-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/IntlayerNode.cjs +11 -1
- package/dist/cjs/LoadingBoundary.cjs +26 -1
- package/dist/cjs/analytics/AnalyticsProvider.cjs +12 -1
- package/dist/cjs/analytics/exposureSink.cjs +23 -1
- package/dist/cjs/analytics/index.cjs +9 -1
- package/dist/cjs/analytics/useAnalytics.cjs +59 -1
- package/dist/cjs/analytics/useConversion.cjs +25 -1
- package/dist/cjs/analytics/useExperiment.cjs +59 -1
- package/dist/cjs/client/IntlayerProvider.cjs +91 -1
- package/dist/cjs/client/contentProxy.cjs +32 -1
- package/dist/cjs/client/getBrowserLocale.cjs +115 -1
- package/dist/cjs/client/index.cjs +35 -1
- package/dist/cjs/client/t.cjs +16 -1
- package/dist/cjs/client/useContent.cjs +16 -1
- package/dist/cjs/client/useDictionary.cjs +51 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +19 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +82 -1
- package/dist/cjs/client/useIntlayer.cjs +50 -1
- package/dist/cjs/client/useLoadDynamic.cjs +140 -1
- package/dist/cjs/client/useLocale.cjs +52 -1
- package/dist/cjs/client/useLocaleBase.cjs +19 -1
- package/dist/cjs/client/useLocaleStorage.cjs +59 -1
- package/dist/cjs/client/usePathname.cjs +41 -1
- package/dist/cjs/client/useRewriteURL.cjs +21 -1
- package/dist/cjs/client/useTraduction.cjs +32 -1
- package/dist/cjs/editor/ContentSelector.cjs +20 -1
- package/dist/cjs/editor/EditorProvider.cjs +8 -1
- package/dist/cjs/editor/createEditedContentSource.cjs +32 -1
- package/dist/cjs/editor/useEditor.cjs +38 -1
- package/dist/cjs/format/index.cjs +19 -1
- package/dist/cjs/format/useCompact.cjs +15 -1
- package/dist/cjs/format/useCurrency.cjs +16 -1
- package/dist/cjs/format/useDate.cjs +25 -1
- package/dist/cjs/format/useIntl.cjs +31 -1
- package/dist/cjs/format/useList.cjs +15 -1
- package/dist/cjs/format/useNumber.cjs +19 -1
- package/dist/cjs/format/usePercentage.cjs +16 -1
- package/dist/cjs/format/useRelativeTime.cjs +16 -1
- package/dist/cjs/format/useUnit.cjs +15 -1
- package/dist/cjs/getDictionary.cjs +17 -1
- package/dist/cjs/getIntlayer.cjs +14 -1
- package/dist/cjs/html/HTMLProvider.cjs +24 -1
- package/dist/cjs/html/HTMLRenderer.cjs +49 -1
- package/dist/cjs/html/index.cjs +8 -1
- package/dist/cjs/html/types.cjs +1 -1
- package/dist/cjs/index.cjs +48 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +47 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +56 -1
- package/dist/cjs/markdown/compiler.cjs +64 -1
- package/dist/cjs/markdown/index.cjs +13 -1
- package/dist/cjs/markdown/runtime.cjs +48 -1
- package/dist/cjs/plugins.cjs +266 -1
- package/dist/cjs/proxyKeys.cjs +14 -1
- package/dist/cjs/server/index.cjs +3 -1
- package/dist/cjs/server/useDictionary.cjs +30 -1
- package/dist/cjs/solidCompat.cjs +167 -1
- package/dist/cjs/solidElement/renderSolidElement.cjs +34 -1
- package/dist/cjs/solidTypes.cjs +1 -1
- package/dist/esm/IntlayerNode.mjs +8 -6
- package/dist/esm/LoadingBoundary.mjs +19 -6
- package/dist/esm/analytics/AnalyticsProvider.mjs +10 -3
- package/dist/esm/analytics/exposureSink.mjs +19 -5
- package/dist/esm/analytics/index.mjs +5 -5
- package/dist/esm/analytics/useAnalytics.mjs +52 -25
- package/dist/esm/analytics/useConversion.mjs +22 -6
- package/dist/esm/analytics/useExperiment.mjs +50 -22
- package/dist/esm/client/IntlayerProvider.mjs +75 -28
- package/dist/esm/client/contentProxy.mjs +26 -12
- package/dist/esm/client/getBrowserLocale.mjs +106 -71
- package/dist/esm/client/index.mjs +14 -14
- package/dist/esm/client/t.mjs +13 -7
- package/dist/esm/client/useContent.mjs +11 -8
- package/dist/esm/client/useDictionary.mjs +47 -25
- package/dist/esm/client/useDictionaryAsync.mjs +16 -9
- package/dist/esm/client/useDictionaryDynamic.mjs +72 -43
- package/dist/esm/client/useIntlayer.mjs +45 -15
- package/dist/esm/client/useLoadDynamic.mjs +128 -49
- package/dist/esm/client/useLocale.mjs +47 -16
- package/dist/esm/client/useLocaleBase.mjs +14 -10
- package/dist/esm/client/useLocaleStorage.mjs +51 -10
- package/dist/esm/client/usePathname.mjs +37 -12
- package/dist/esm/client/useRewriteURL.mjs +17 -11
- package/dist/esm/client/useTraduction.mjs +29 -8
- package/dist/esm/editor/ContentSelector.mjs +18 -15
- package/dist/esm/editor/EditorProvider.mjs +6 -3
- package/dist/esm/editor/createEditedContentSource.mjs +28 -17
- package/dist/esm/editor/useEditor.mjs +32 -22
- package/dist/esm/format/index.mjs +10 -10
- package/dist/esm/format/useCompact.mjs +11 -8
- package/dist/esm/format/useCurrency.mjs +12 -9
- package/dist/esm/format/useDate.mjs +19 -13
- package/dist/esm/format/useIntl.mjs +27 -9
- package/dist/esm/format/useList.mjs +11 -8
- package/dist/esm/format/useNumber.mjs +15 -9
- package/dist/esm/format/usePercentage.mjs +12 -9
- package/dist/esm/format/useRelativeTime.mjs +12 -9
- package/dist/esm/format/useUnit.mjs +11 -8
- package/dist/esm/getDictionary.mjs +14 -6
- package/dist/esm/getIntlayer.mjs +11 -6
- package/dist/esm/html/HTMLProvider.mjs +21 -12
- package/dist/esm/html/HTMLRenderer.mjs +44 -17
- package/dist/esm/html/index.mjs +3 -3
- package/dist/esm/index.mjs +20 -20
- package/dist/esm/markdown/MarkdownProvider.mjs +31 -24
- package/dist/esm/markdown/MarkdownRenderer.mjs +48 -37
- package/dist/esm/markdown/compiler.mjs +59 -23
- package/dist/esm/markdown/index.mjs +4 -4
- package/dist/esm/markdown/runtime.mjs +40 -13
- package/dist/esm/plugins.mjs +205 -156
- package/dist/esm/proxyKeys.mjs +7 -2
- package/dist/esm/server/useDictionary.mjs +25 -7
- package/dist/esm/solidCompat.mjs +146 -39
- package/dist/esm/solidElement/renderSolidElement.mjs +22 -19
- package/dist/rolldown-runtime-CmQyd0Gu.js +27 -0
- package/dist/solid/analytics/useAnalytics.jsx +3 -3
- package/dist/solid/analytics/useConversion.js +2 -2
- package/dist/solid/analytics/useExperiment.js +3 -3
- package/package.json +7 -7
- package/dist/esm-YGODKOLP.js +0 -1
- package/dist/esm-bdKnuomJ.mjs +0 -256
- package/dist/isEnabled-CuTKz0YA.js +0 -1
- package/dist/isEnabled-DVKEZ2He.mjs +0 -18
- package/dist/rolldown-runtime-BocRIvOZ.js +0 -1
- package/dist/solid/esm-1cHk4dPd.js +0 -644
- package/dist/solid/isEnabled-C5NUhdhZ.js +0 -100
|
@@ -1 +1,19 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
3
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
4
|
+
let solid_js = require("solid-js");
|
|
5
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
6
|
+
const require_client_useDictionary = require("./useDictionary.cjs");
|
|
7
|
+
// src/client/useDictionaryAsync.ts
|
|
8
|
+
/**
|
|
9
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
10
|
+
*
|
|
11
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
12
|
+
*/
|
|
13
|
+
var useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
14
|
+
const { locale: currentLocale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
15
|
+
const localeTarget = locale ?? currentLocale() ?? (0, _intlayer_core_interpreter.resolveInterpreterLocale)();
|
|
16
|
+
const dictionary = await (0, _intlayer_core_dictionaryManipulator.loadDynamicDictionary)(dictionaryPromise, localeTarget);
|
|
17
|
+
return require_client_useDictionary.useDictionary(dictionary, localeTarget);
|
|
18
|
+
};
|
|
19
|
+
exports.useDictionaryAsync = useDictionaryAsync;
|
|
@@ -1 +1,82 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_getDictionary = require("../getDictionary.cjs");
|
|
5
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
6
|
+
const require_client_contentProxy = require("./contentProxy.cjs");
|
|
7
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
8
|
+
const require_client_useDictionary = require("./useDictionary.cjs");
|
|
9
|
+
const require_client_useLoadDynamic = require("./useLoadDynamic.cjs");
|
|
10
|
+
// src/client/useDictionaryDynamic.ts
|
|
11
|
+
/**
|
|
12
|
+
* Loaded chunks stay raw (serializable for hydration) and are interpreted
|
|
13
|
+
* inside the component owner. A collection's metadata is plain data, resolved
|
|
14
|
+
* right away — its index holds no dictionary to interpret anyway.
|
|
15
|
+
*/
|
|
16
|
+
var keepRawChunk = (dictionary) => dictionary;
|
|
17
|
+
var readChunkMetadata = (dictionary, argument) => require_getDictionary.getDictionary(dictionary, argument);
|
|
18
|
+
/**
|
|
19
|
+
* On the client side, Hook that lazily loads a dictionary and returns its
|
|
20
|
+
* reactive content.
|
|
21
|
+
*
|
|
22
|
+
* The locale, selector and chunk selection are resolved by the shared
|
|
23
|
+
* `resolveDictionaryRead` / `resolveDynamicContentAsync`; this hook only adds
|
|
24
|
+
* Solid's resources and owner-scoped interpretation.
|
|
25
|
+
*
|
|
26
|
+
* If the locale is not provided (directly or through the selector), it will
|
|
27
|
+
* use the locale from the client context.
|
|
28
|
+
*/
|
|
29
|
+
var useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
30
|
+
const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
31
|
+
const dictionaryKey = String(key);
|
|
32
|
+
const loaderMap = dictionaryPromise;
|
|
33
|
+
const { locale: callLocale, selector: callSelector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector) : {
|
|
34
|
+
locale: localeOrSelector,
|
|
35
|
+
selector: void 0
|
|
36
|
+
};
|
|
37
|
+
const readAccessor = () => (0, _intlayer_core_dictionaryManipulator.resolveDictionaryRead)({
|
|
38
|
+
localeOrSelector,
|
|
39
|
+
contextLocale: context.locale?.(),
|
|
40
|
+
contextVariant: context.variant?.(),
|
|
41
|
+
dictionaryKey
|
|
42
|
+
});
|
|
43
|
+
const sourceAccessor = () => {
|
|
44
|
+
const read = readAccessor();
|
|
45
|
+
const chunkSelectorId = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)({
|
|
46
|
+
...read.selector,
|
|
47
|
+
metadataOnly: void 0
|
|
48
|
+
}) : "";
|
|
49
|
+
return {
|
|
50
|
+
...read,
|
|
51
|
+
cacheKey: chunkSelectorId ? `${dictionaryKey}.${read.locale}.${chunkSelectorId}` : `${dictionaryKey}.${read.locale}`
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const loadContent = (read, transform) => (0, _intlayer_core_dictionaryManipulator.resolveDynamicContentAsync)({
|
|
55
|
+
loaderMap,
|
|
56
|
+
key: dictionaryKey,
|
|
57
|
+
...read,
|
|
58
|
+
transform
|
|
59
|
+
});
|
|
60
|
+
const chunkArgument = (0, _intlayer_core_dictionaryManipulator.getDynamicChunkArgument)(callLocale, callSelector);
|
|
61
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && (0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(loaderMap) && loaderMap[_intlayer_core_dictionaryManipulator.QUALIFIER_DYNAMIC_TYPES_KEY].includes("item") && callSelector?.item === void 0) {
|
|
62
|
+
const resolvedEntries = require_solidCompat.createAsyncValue(readAccessor, (read) => loadContent(read, callSelector?.metadataOnly ? readChunkMetadata : keepRawChunk));
|
|
63
|
+
const accessor = (0, solid_js.createMemo)(() => {
|
|
64
|
+
const resolved = resolvedEntries();
|
|
65
|
+
if (!Array.isArray(resolved)) return [];
|
|
66
|
+
if (callSelector?.metadataOnly) return resolved;
|
|
67
|
+
const { locale } = readAccessor();
|
|
68
|
+
return resolved.map((dictionary) => require_getDictionary.getDictionary(dictionary, locale));
|
|
69
|
+
});
|
|
70
|
+
require_solidCompat.trackAsyncValue(resolvedEntries);
|
|
71
|
+
return require_client_contentProxy.createContentProxy(accessor);
|
|
72
|
+
}
|
|
73
|
+
const initialSource = sourceAccessor();
|
|
74
|
+
const preloadedDictionary = (0, _intlayer_core_dictionaryManipulator.getPreloadedDictionary)(loaderMap, initialSource.locale);
|
|
75
|
+
if (preloadedDictionary) require_client_useLoadDynamic.seedDynamicValue(initialSource, preloadedDictionary);
|
|
76
|
+
const dictionary = require_client_useLoadDynamic.useLoadDynamic(sourceAccessor, (source) => loadContent(source, keepRawChunk).then((resolved) => {
|
|
77
|
+
if (resolved === null) throw new Error(`No dynamic dictionary chunk found for key "${dictionaryKey}" and locale "${source.locale}".`);
|
|
78
|
+
return resolved;
|
|
79
|
+
}));
|
|
80
|
+
return require_client_useDictionary.useDictionary(dictionary, chunkArgument);
|
|
81
|
+
};
|
|
82
|
+
exports.useDictionaryDynamic = useDictionaryDynamic;
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_getIntlayer = require("../getIntlayer.cjs");
|
|
5
|
+
const require_client_contentProxy = require("./contentProxy.cjs");
|
|
6
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
7
|
+
// src/client/useIntlayer.ts
|
|
8
|
+
/**
|
|
9
|
+
* Solid hook that picks one dictionary by its key and returns its reactive content.
|
|
10
|
+
*
|
|
11
|
+
* The second argument is either a locale or a selector object:
|
|
12
|
+
* - `{ item: 2 }` — collection item (omit `item` to get every item as array)
|
|
13
|
+
* - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
|
|
14
|
+
* - `locale` composes with any selector and overrides the context locale
|
|
15
|
+
*
|
|
16
|
+
* Supports both direct property access and the accessor call form:
|
|
17
|
+
* - `content.myField.value` — reactive when used inside JSX or other Solid reactive contexts
|
|
18
|
+
* - `content()` — backward-compatible accessor form
|
|
19
|
+
*
|
|
20
|
+
* @param key - The unique key of the dictionary to retrieve.
|
|
21
|
+
* @param localeOrSelector - Optional locale or selector.
|
|
22
|
+
* @returns Reactive content accessible via property access or function call.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { useIntlayer } from 'solid-intlayer';
|
|
27
|
+
*
|
|
28
|
+
* const MyComponent = () => {
|
|
29
|
+
* const content = useIntlayer('my-dictionary-key');
|
|
30
|
+
* const faq2 = useIntlayer('faq', { item: 2 });
|
|
31
|
+
*
|
|
32
|
+
* return <div>{content.myField.value}</div>;
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
var useIntlayer = (key, localeOrSelector) => {
|
|
37
|
+
const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
38
|
+
const accessor = (0, solid_js.createMemo)(() => {
|
|
39
|
+
const currentLocale = context?.locale?.();
|
|
40
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return require_getIntlayer.getIntlayer(key, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
41
|
+
localeOrSelector,
|
|
42
|
+
contextLocale: currentLocale,
|
|
43
|
+
contextVariant: context?.variant?.(),
|
|
44
|
+
dictionaryKey: key
|
|
45
|
+
}));
|
|
46
|
+
return require_getIntlayer.getIntlayer(key, localeOrSelector ?? currentLocale);
|
|
47
|
+
});
|
|
48
|
+
return require_client_contentProxy.createContentProxy(accessor);
|
|
49
|
+
};
|
|
50
|
+
exports.useIntlayer = useIntlayer;
|
|
@@ -1 +1,140 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let solid_js = require("solid-js");
|
|
3
|
+
const require_proxyKeys = require("../proxyKeys.cjs");
|
|
4
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
5
|
+
// src/client/useLoadDynamic.ts
|
|
6
|
+
var NO_PENDING_PRIMITIVE_FALLBACK = Symbol("NO_PENDING_PRIMITIVE_FALLBACK");
|
|
7
|
+
/**
|
|
8
|
+
* Property exposing the settled value behind a loadable proxy, or `undefined`
|
|
9
|
+
* while the chunk is still in flight. See {@link unwrapLoadable}.
|
|
10
|
+
*/
|
|
11
|
+
var LOADABLE_SETTLED_VALUE = Symbol("LOADABLE_SETTLED_VALUE");
|
|
12
|
+
/**
|
|
13
|
+
* Module-level cache to dedupe dynamic imports by key. Solid async primitives
|
|
14
|
+
* still own suspense, SSR serialization, hydration, and refetching on source
|
|
15
|
+
* change.
|
|
16
|
+
*/
|
|
17
|
+
var cache = /* @__PURE__ */ new Map();
|
|
18
|
+
var getDynamicSourceCacheKey = (source) => typeof source === "string" ? source : source.cacheKey;
|
|
19
|
+
var readValueAtPath = (value, path) => path.reduce((currentValue, property) => {
|
|
20
|
+
if (currentValue === null || currentValue === void 0) return void 0;
|
|
21
|
+
return Reflect.get(Object(currentValue), property);
|
|
22
|
+
}, value);
|
|
23
|
+
var resolveDynamicLoader = (loader, source) => typeof loader === "function" ? loader(source) : loader;
|
|
24
|
+
var loadDynamicValue = (source, loader) => {
|
|
25
|
+
const key = getDynamicSourceCacheKey(source);
|
|
26
|
+
const cachedEntry = cache.get(key);
|
|
27
|
+
if (cachedEntry?.status === "success") return cachedEntry.value;
|
|
28
|
+
if (cachedEntry?.status === "pending") return cachedEntry.promise;
|
|
29
|
+
const promise = resolveDynamicLoader(loader, source).then((value) => {
|
|
30
|
+
cache.set(key, {
|
|
31
|
+
status: "success",
|
|
32
|
+
value
|
|
33
|
+
});
|
|
34
|
+
return value;
|
|
35
|
+
}, (error) => {
|
|
36
|
+
cache.delete(key);
|
|
37
|
+
throw error;
|
|
38
|
+
});
|
|
39
|
+
cache.set(key, {
|
|
40
|
+
status: "pending",
|
|
41
|
+
promise
|
|
42
|
+
});
|
|
43
|
+
return promise;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Records a value that is already available, so the next
|
|
47
|
+
* {@link loadDynamicValue} for this key returns it synchronously.
|
|
48
|
+
*
|
|
49
|
+
* Used for dictionaries a build-tool plugin awaited while their entry point
|
|
50
|
+
* evaluated: the async value resolves without ever entering a pending state,
|
|
51
|
+
* so the loading boundary is not triggered and the first render already has the content.
|
|
52
|
+
*
|
|
53
|
+
* An existing entry is never replaced — an in-flight load owns its key.
|
|
54
|
+
*/
|
|
55
|
+
var seedDynamicValue = (source, value) => {
|
|
56
|
+
const key = getDynamicSourceCacheKey(source);
|
|
57
|
+
if (cache.has(key)) return;
|
|
58
|
+
cache.set(key, {
|
|
59
|
+
status: "success",
|
|
60
|
+
value
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var bindPropertyValue = (value, propertyValue) => typeof propertyValue === "function" ? propertyValue.bind(value) : propertyValue;
|
|
64
|
+
var createPendingPrimitiveFallback = (property) => {
|
|
65
|
+
if (property === Symbol.toPrimitive) return () => "";
|
|
66
|
+
if (property === Symbol.iterator) return () => ({ next: () => ({
|
|
67
|
+
done: true,
|
|
68
|
+
value: void 0
|
|
69
|
+
}) });
|
|
70
|
+
if (property === "length") return 0;
|
|
71
|
+
if (property === require_proxyKeys.PROXY_RESERVED_KEYS.toString) return () => "";
|
|
72
|
+
if (property === require_proxyKeys.PROXY_RESERVED_KEYS.valueOf) return () => void 0;
|
|
73
|
+
if (property === require_proxyKeys.PROXY_RESERVED_KEYS.value) return "";
|
|
74
|
+
return NO_PENDING_PRIMITIVE_FALLBACK;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Creates a stable callable proxy that re-reads the Solid async value on each
|
|
78
|
+
* property access. This keeps synchronous Intlayer access (`content.x.value`)
|
|
79
|
+
* safe while the Solid loading boundary owns the actual pending state.
|
|
80
|
+
*/
|
|
81
|
+
var createLoadableProxy = (read) => {
|
|
82
|
+
const createProxyAtPath = (path) => {
|
|
83
|
+
const target = () => void 0;
|
|
84
|
+
return new Proxy(target, {
|
|
85
|
+
get(_target, property) {
|
|
86
|
+
if (property === require_proxyKeys.PROXY_RESERVED_KEYS.promiseThen) return void 0;
|
|
87
|
+
const currentValue = readValueAtPath(read(), path);
|
|
88
|
+
if (property === LOADABLE_SETTLED_VALUE) return currentValue;
|
|
89
|
+
if (currentValue !== null && currentValue !== void 0) {
|
|
90
|
+
if (property === Symbol.toPrimitive) return () => currentValue;
|
|
91
|
+
return bindPropertyValue(currentValue, Reflect.get(Object(currentValue), property));
|
|
92
|
+
}
|
|
93
|
+
const primitiveFallback = createPendingPrimitiveFallback(property);
|
|
94
|
+
if (primitiveFallback !== NO_PENDING_PRIMITIVE_FALLBACK) return primitiveFallback;
|
|
95
|
+
return createProxyAtPath([...path, property]);
|
|
96
|
+
},
|
|
97
|
+
apply(_target, thisArgument, argumentsList) {
|
|
98
|
+
const currentValue = readValueAtPath(read(), path);
|
|
99
|
+
if (typeof currentValue !== "function") {
|
|
100
|
+
if (argumentsList.length === 0) return currentValue ?? "";
|
|
101
|
+
return createLoadableProxy(() => {
|
|
102
|
+
const resolvedValue = readValueAtPath(read(), path);
|
|
103
|
+
if (typeof resolvedValue !== "function") return void 0;
|
|
104
|
+
return (0, solid_js.untrack)(() => Reflect.apply(resolvedValue, thisArgument, argumentsList));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return Reflect.apply(currentValue, thisArgument, argumentsList);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return createProxyAtPath([]);
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Returns the settled value a loadable proxy stands for, or `undefined` while
|
|
115
|
+
* its chunk is in flight — and for any value that is not a loadable proxy.
|
|
116
|
+
*
|
|
117
|
+
* The read stays tracked, so a caller inside a reactive scope re-runs once the
|
|
118
|
+
* chunk lands. Interpreting the settled dictionary rather than the stand-in is
|
|
119
|
+
* what lets `getDictionary` memoize the transform: the stand-in is created per
|
|
120
|
+
* component and its content changes over time, while the settled dictionary is
|
|
121
|
+
* one shared object every component resolves to.
|
|
122
|
+
*
|
|
123
|
+
* @param value - A loadable proxy, or any other value.
|
|
124
|
+
*/
|
|
125
|
+
var unwrapLoadable = (value) => {
|
|
126
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
127
|
+
return value[LOADABLE_SETTLED_VALUE];
|
|
128
|
+
};
|
|
129
|
+
var useLoadDynamic = (key, loader) => {
|
|
130
|
+
const keyAccessor = () => typeof key === "function" ? key() : key;
|
|
131
|
+
const asyncValue = require_solidCompat.createAsyncValue(keyAccessor, (resolvedSource) => loadDynamicValue(resolvedSource, loader));
|
|
132
|
+
require_solidCompat.trackAsyncValue(asyncValue);
|
|
133
|
+
return createLoadableProxy(asyncValue);
|
|
134
|
+
};
|
|
135
|
+
exports.createLoadableProxy = createLoadableProxy;
|
|
136
|
+
exports.getDynamicSourceCacheKey = getDynamicSourceCacheKey;
|
|
137
|
+
exports.loadDynamicValue = loadDynamicValue;
|
|
138
|
+
exports.seedDynamicValue = seedDynamicValue;
|
|
139
|
+
exports.unwrapLoadable = unwrapLoadable;
|
|
140
|
+
exports.useLoadDynamic = useLoadDynamic;
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
5
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
6
|
+
const require_client_useLocaleStorage = require("./useLocaleStorage.cjs");
|
|
7
|
+
// src/client/useLocale.ts
|
|
8
|
+
var { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
|
|
9
|
+
/**
|
|
10
|
+
* Solid hook to manage the current locale and related functions.
|
|
11
|
+
*
|
|
12
|
+
* @param props - Optional configuration for locale management.
|
|
13
|
+
* @returns An object containing the current locale (accessor), default locale, available locales, and a function to update the locale.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { useLocale } from 'solid-intlayer';
|
|
18
|
+
*
|
|
19
|
+
* const LocaleSwitcher = () => {
|
|
20
|
+
* const { locale, setLocale, availableLocales } = useLocale();
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <select value={locale()} onChange={(e) => setLocale(e.target.value)}>
|
|
24
|
+
* <For each={availableLocales}>
|
|
25
|
+
* {(loc) => <option value={loc}>{loc}</option>}
|
|
26
|
+
* </For>
|
|
27
|
+
* </select>
|
|
28
|
+
* );
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
var useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
33
|
+
const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
34
|
+
const setLocale = (locale) => {
|
|
35
|
+
if (!availableLocales?.map(String).includes(locale)) {
|
|
36
|
+
console.error(`Locale ${locale} is not available`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
context?.setLocale(locale);
|
|
40
|
+
require_client_useLocaleStorage.setLocaleInStorage(locale, isCookieEnabled ?? context?.isCookieEnabled ?? true);
|
|
41
|
+
};
|
|
42
|
+
require_solidCompat.createChangeEffect(() => context?.locale?.(), (currentLocale) => {
|
|
43
|
+
if (onLocaleChange && currentLocale !== void 0) onLocaleChange(currentLocale);
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
locale: context?.locale,
|
|
47
|
+
defaultLocale,
|
|
48
|
+
availableLocales,
|
|
49
|
+
setLocale
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.useLocale = useLocale;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
5
|
+
// src/client/useLocaleBase.ts
|
|
6
|
+
var { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization;
|
|
7
|
+
/**
|
|
8
|
+
* On the client side, hook to get the current locale and all related fields
|
|
9
|
+
*/
|
|
10
|
+
var useLocaleBase = () => {
|
|
11
|
+
const { locale, setLocale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
12
|
+
return {
|
|
13
|
+
locale,
|
|
14
|
+
defaultLocale,
|
|
15
|
+
availableLocales,
|
|
16
|
+
setLocale
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.useLocaleBase = useLocaleBase;
|
|
@@ -1 +1,59 @@
|
|
|
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
|
+
let solid_js = require("solid-js");
|
|
4
|
+
// src/client/useLocaleStorage.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
7
|
+
*
|
|
8
|
+
* Unlike `localeInStorage`, read on first call rather than at import, then
|
|
9
|
+
* cached until the next `setLocaleInStorage`. Never cached on the server.
|
|
10
|
+
*/
|
|
11
|
+
var getLocaleInStorage = _intlayer_core_utils.getCachedLocaleFromStorageClient;
|
|
12
|
+
/**
|
|
13
|
+
* Get the locale cookie
|
|
14
|
+
*
|
|
15
|
+
* Read once at import time; marked pure so bundlers drop the read when nothing
|
|
16
|
+
* imports it.
|
|
17
|
+
*/
|
|
18
|
+
var localeInStorage = /* @__PURE__ */ (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_utils.localeStorageOptions);
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use localeInStorage instead
|
|
21
|
+
*
|
|
22
|
+
* Get the locale cookie
|
|
23
|
+
*/
|
|
24
|
+
var localeCookie = localeInStorage;
|
|
25
|
+
/**
|
|
26
|
+
* Set the locale cookie
|
|
27
|
+
*/
|
|
28
|
+
var setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorageClient)(locale, {
|
|
29
|
+
..._intlayer_core_utils.localeStorageOptions,
|
|
30
|
+
isCookieEnabled
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use setLocaleInStorage instead
|
|
34
|
+
*
|
|
35
|
+
* Set the locale cookie
|
|
36
|
+
*/
|
|
37
|
+
var setLocaleCookie = setLocaleInStorage;
|
|
38
|
+
/**
|
|
39
|
+
* Hook that provides the locale storage and a function to set it
|
|
40
|
+
*/
|
|
41
|
+
var useLocaleStorage = (isCookieEnabled) => (0, solid_js.createMemo)(() => (0, _intlayer_core_utils.LocaleStorageClient)({
|
|
42
|
+
..._intlayer_core_utils.localeStorageOptions,
|
|
43
|
+
isCookieEnabled
|
|
44
|
+
}));
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use useLocaleStorage instead
|
|
47
|
+
*
|
|
48
|
+
* For GDPR compliance, use useLocaleStorage instead
|
|
49
|
+
*
|
|
50
|
+
* Hook that provides the locale cookie and a function to set it
|
|
51
|
+
*/
|
|
52
|
+
var useLocaleCookie = useLocaleStorage;
|
|
53
|
+
exports.getLocaleInStorage = getLocaleInStorage;
|
|
54
|
+
exports.localeCookie = localeCookie;
|
|
55
|
+
exports.localeInStorage = localeInStorage;
|
|
56
|
+
exports.setLocaleCookie = setLocaleCookie;
|
|
57
|
+
exports.setLocaleInStorage = setLocaleInStorage;
|
|
58
|
+
exports.useLocaleCookie = useLocaleCookie;
|
|
59
|
+
exports.useLocaleStorage = useLocaleStorage;
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
5
|
+
// src/client/usePathname.ts
|
|
6
|
+
/**
|
|
7
|
+
* Solid hook that returns an accessor containing the current pathname with
|
|
8
|
+
* the locale segment removed.
|
|
9
|
+
*
|
|
10
|
+
* Reacts to browser back/forward navigation via the `popstate` event.
|
|
11
|
+
* Falls back to an empty string during server-side rendering.
|
|
12
|
+
*
|
|
13
|
+
* @returns An accessor containing the current pathname without the locale prefix.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { usePathname } from 'solid-intlayer';
|
|
18
|
+
*
|
|
19
|
+
* const NavItem = ({ href }: { href: string }) => {
|
|
20
|
+
* const pathname = usePathname();
|
|
21
|
+
* return (
|
|
22
|
+
* <a class={pathname() === href ? 'active' : ''} href={href}>
|
|
23
|
+
* {href}
|
|
24
|
+
* </a>
|
|
25
|
+
* );
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var usePathname = () => {
|
|
30
|
+
const [rawPathname, setRawPathname] = (0, solid_js.createSignal)(typeof window !== "undefined" ? window.location.pathname : "");
|
|
31
|
+
require_solidCompat.onMounted(() => {
|
|
32
|
+
if (typeof window === "undefined") return;
|
|
33
|
+
const handleLocationChange = () => {
|
|
34
|
+
setRawPathname(window.location.pathname);
|
|
35
|
+
};
|
|
36
|
+
window.addEventListener("popstate", handleLocationChange);
|
|
37
|
+
return () => window.removeEventListener("popstate", handleLocationChange);
|
|
38
|
+
});
|
|
39
|
+
return () => (0, _intlayer_core_localization.getPathWithoutLocale)(rawPathname());
|
|
40
|
+
};
|
|
41
|
+
exports.usePathname = usePathname;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
4
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
5
|
+
const require_client_useLocale = require("./useLocale.cjs");
|
|
6
|
+
// src/client/useRewriteURL.ts
|
|
7
|
+
/**
|
|
8
|
+
* Client-side hook to manage URL rewrites in Solid without triggering a router navigation.
|
|
9
|
+
* It uses `window.history.replaceState` to update the URL in the address bar.
|
|
10
|
+
*/
|
|
11
|
+
var useRewriteURL = () => {
|
|
12
|
+
const { locale } = require_client_useLocale.useLocale();
|
|
13
|
+
const rewrite = _intlayer_config_built.routing?.rewrite;
|
|
14
|
+
require_solidCompat.createWatchEffect(locale, (loc) => {
|
|
15
|
+
if (typeof window === "undefined" || !rewrite) return;
|
|
16
|
+
const pathname = window.location.pathname;
|
|
17
|
+
const targetPath = (0, _intlayer_core_localization.getRewritePath)(pathname, loc, rewrite);
|
|
18
|
+
if (targetPath && targetPath !== pathname) window.history.replaceState(window.history.state, "", targetPath + window.location.search + window.location.hash);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.useRewriteURL = useRewriteURL;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
4
|
+
let solid_js = require("solid-js");
|
|
5
|
+
const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
|
|
6
|
+
// src/client/useTraduction.ts
|
|
7
|
+
/**
|
|
8
|
+
* On the client side, Hook that picking one dictionary by its id and return the content.
|
|
9
|
+
*
|
|
10
|
+
* If not locale found, it will return the content related to the default locale.
|
|
11
|
+
*
|
|
12
|
+
* Return either the content editor, or the content itself depending on the configuration.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const content = useTranslation<string>({
|
|
18
|
+
* en: 'Hello',
|
|
19
|
+
* fr: 'Bonjour',
|
|
20
|
+
* }, 'fr');
|
|
21
|
+
* // 'Bonjour'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Using TypeScript:
|
|
25
|
+
* - this function will require each locale to be defined if defined in the project configuration.
|
|
26
|
+
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
27
|
+
*/
|
|
28
|
+
var useTranslation = (languageContent) => {
|
|
29
|
+
const { locale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
30
|
+
return (0, _intlayer_core_interpreter.getTranslation)(languageContent, locale?.() ?? _intlayer_config_built.internationalization.defaultLocale);
|
|
31
|
+
};
|
|
32
|
+
exports.useTranslation = useTranslation;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let solid_js_web = require("solid-js/web");
|
|
3
|
+
let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
4
|
+
// src/editor/ContentSelector.tsx
|
|
5
|
+
var ContentSelector = (props) => {
|
|
6
|
+
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return props.children;
|
|
7
|
+
return (0, solid_js_web.createComponent)(solid_js_web.Dynamic, {
|
|
8
|
+
component: "intlayer-content-selector-wrapper",
|
|
9
|
+
get ["attr:key-path"]() {
|
|
10
|
+
return JSON.stringify(props.keyPath);
|
|
11
|
+
},
|
|
12
|
+
get ["attr:dictionary-key"]() {
|
|
13
|
+
return props.dictionaryKey;
|
|
14
|
+
},
|
|
15
|
+
get children() {
|
|
16
|
+
return props.children;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.ContentSelector = ContentSelector;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_editor_useEditor = require("./useEditor.cjs");
|
|
3
|
+
// src/editor/EditorProvider.tsx
|
|
4
|
+
var EditorProvider = ({ children }) => {
|
|
5
|
+
require_editor_useEditor.useEditor();
|
|
6
|
+
return children;
|
|
7
|
+
};
|
|
8
|
+
exports.EditorProvider = EditorProvider;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
const require_solidCompat = require("../solidCompat.cjs");
|
|
5
|
+
// src/editor/createEditedContentSource.ts
|
|
6
|
+
/**
|
|
7
|
+
* Tracks the source string edited in the visual editor for a markdown / html
|
|
8
|
+
* node. The accessor returns `undefined` when the node is not edited (or the
|
|
9
|
+
* editor is off).
|
|
10
|
+
*/
|
|
11
|
+
var createEditedContentSource = (dictionaryKey, keyPath) => {
|
|
12
|
+
const [editedSource, setEditedSource] = (0, solid_js.createSignal)();
|
|
13
|
+
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return editedSource;
|
|
14
|
+
require_solidCompat.createWatchEffect(() => ({
|
|
15
|
+
currentDictionaryKey: dictionaryKey(),
|
|
16
|
+
keyPathJson: JSON.stringify(keyPath() ?? [])
|
|
17
|
+
}), ({ currentDictionaryKey, keyPathJson }) => {
|
|
18
|
+
if (!currentDictionaryKey) return;
|
|
19
|
+
let isStopped = false;
|
|
20
|
+
let unsubscribe = null;
|
|
21
|
+
import("@intlayer/editor").then(({ subscribeToEditedContentSource }) => {
|
|
22
|
+
if (isStopped) return;
|
|
23
|
+
unsubscribe = subscribeToEditedContentSource(currentDictionaryKey, JSON.parse(keyPathJson), (source) => setEditedSource(() => source));
|
|
24
|
+
}).catch(() => {});
|
|
25
|
+
return () => {
|
|
26
|
+
isStopped = true;
|
|
27
|
+
unsubscribe?.();
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return editedSource;
|
|
31
|
+
};
|
|
32
|
+
exports.createEditedContentSource = createEditedContentSource;
|