solid-intlayer 9.8.1 → 9.8.2
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/LoadingBoundary.cjs +1 -0
- package/dist/cjs/analytics/useAnalytics.cjs +1 -1
- package/dist/cjs/analytics/useExperiment.cjs +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs +1 -1
- package/dist/cjs/client/getBrowserLocale.cjs +1 -1
- package/dist/cjs/client/t.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -1
- package/dist/cjs/client/usePathname.cjs +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +1 -1
- package/dist/cjs/client/useTraduction.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/getDictionary.cjs +1 -1
- package/dist/cjs/html/HTMLProvider.cjs +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
- package/dist/cjs/markdown/runtime.cjs +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/cjs/server/useDictionary.cjs +1 -1
- package/dist/cjs/solidCompat.cjs +1 -0
- package/dist/cjs/solidElement/renderSolidElement.cjs +1 -1
- package/dist/esm/LoadingBoundary.mjs +12 -0
- package/dist/esm/analytics/useAnalytics.mjs +14 -11
- package/dist/esm/analytics/useExperiment.mjs +5 -4
- package/dist/esm/client/IntlayerProvider.mjs +28 -28
- package/dist/esm/client/getBrowserLocale.mjs +21 -21
- package/dist/esm/client/t.mjs +4 -4
- package/dist/esm/client/useDictionary.mjs +22 -14
- package/dist/esm/client/useDictionaryAsync.mjs +3 -3
- package/dist/esm/client/useDictionaryDynamic.mjs +26 -23
- package/dist/esm/client/useLoadDynamic.mjs +4 -5
- package/dist/esm/client/useLocale.mjs +15 -14
- package/dist/esm/client/useLocaleStorage.mjs +7 -7
- package/dist/esm/client/usePathname.mjs +9 -8
- package/dist/esm/client/useRewriteURL.mjs +6 -6
- package/dist/esm/client/useTraduction.mjs +5 -5
- package/dist/esm/editor/useEditor.mjs +11 -11
- package/dist/esm/getDictionary.mjs +3 -3
- package/dist/esm/html/HTMLProvider.mjs +5 -4
- package/dist/esm/html/HTMLRenderer.mjs +6 -6
- package/dist/esm/markdown/MarkdownProvider.mjs +20 -19
- package/dist/esm/markdown/MarkdownRenderer.mjs +27 -25
- package/dist/esm/markdown/runtime.mjs +8 -13
- package/dist/esm/plugins.mjs +76 -75
- package/dist/esm/server/useDictionary.mjs +9 -6
- package/dist/esm/solidCompat.mjs +48 -0
- package/dist/esm/solidElement/renderSolidElement.mjs +14 -16
- package/dist/rolldown-runtime-BocRIvOZ.js +1 -0
- package/dist/solid/IntlayerNode.jsx +10 -0
- package/dist/solid/LoadingBoundary.jsx +10 -0
- package/dist/solid/analytics/AnalyticsProvider.jsx +11 -0
- package/dist/solid/analytics/exposureSink.js +21 -0
- package/dist/solid/analytics/index.js +5 -0
- package/dist/solid/analytics/useAnalytics.jsx +58 -0
- package/dist/solid/analytics/useConversion.js +24 -0
- package/dist/solid/analytics/useExperiment.js +58 -0
- package/dist/solid/client/IntlayerProvider.jsx +81 -0
- package/dist/solid/client/getBrowserLocale.jsx +113 -0
- package/dist/solid/client/index.js +14 -0
- package/dist/solid/client/t.js +15 -0
- package/dist/solid/client/useContent.js +15 -0
- package/dist/solid/client/useDictionary.js +56 -0
- package/dist/solid/client/useDictionaryAsync.js +17 -0
- package/dist/solid/client/useDictionaryDynamic.js +105 -0
- package/dist/solid/client/useIntlayer.js +55 -0
- package/dist/solid/client/useLoadDynamic.js +134 -0
- package/dist/solid/client/useLocale.js +51 -0
- package/dist/solid/client/useLocaleBase.js +18 -0
- package/dist/solid/client/useLocaleStorage.js +52 -0
- package/dist/solid/client/usePathname.js +40 -0
- package/dist/solid/client/useRewriteURL.js +20 -0
- package/dist/solid/client/useTraduction.js +31 -0
- package/dist/solid/editor/ContentSelector.jsx +9 -0
- package/dist/solid/editor/EditorProvider.jsx +7 -0
- package/dist/solid/editor/useEditor.jsx +37 -0
- package/dist/solid/esm-BS5TZIsL.js +644 -0
- package/dist/solid/format/index.js +10 -0
- package/dist/solid/format/useCompact.js +14 -0
- package/dist/solid/format/useCurrency.js +15 -0
- package/dist/solid/format/useDate.js +24 -0
- package/dist/solid/format/useIntl.js +30 -0
- package/dist/solid/format/useList.js +14 -0
- package/dist/solid/format/useNumber.js +18 -0
- package/dist/solid/format/usePercentage.js +15 -0
- package/dist/solid/format/useRelativeTime.js +15 -0
- package/dist/solid/format/useUnit.js +14 -0
- package/dist/solid/getDictionary.js +16 -0
- package/dist/solid/getIntlayer.js +13 -0
- package/dist/solid/html/HTMLProvider.jsx +16 -0
- package/dist/solid/html/HTMLRenderer.jsx +45 -0
- package/dist/solid/html/index.js +3 -0
- package/dist/solid/html/types.js +0 -0
- package/dist/solid/index.js +21 -0
- package/dist/solid/isEnabled-C5NUhdhZ.js +100 -0
- package/dist/solid/markdown/MarkdownProvider.jsx +38 -0
- package/dist/solid/markdown/MarkdownRenderer.jsx +47 -0
- package/dist/solid/markdown/compiler.jsx +62 -0
- package/dist/solid/markdown/index.js +4 -0
- package/dist/solid/markdown/runtime.jsx +42 -0
- package/dist/solid/plugins.jsx +230 -0
- package/dist/solid/proxyKeys.js +13 -0
- package/dist/solid/server/index.js +1 -0
- package/dist/solid/server/useDictionary.js +29 -0
- package/dist/solid/solidCompat.js +155 -0
- package/dist/solid/solidElement/renderSolidElement.jsx +32 -0
- package/dist/types/LoadingBoundary.d.ts +12 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +4 -4
- package/dist/types/client/useLocaleStorage.d.ts +2 -2
- package/dist/types/format/useIntl.d.ts +1 -1
- package/dist/types/getDictionary.d.ts +5 -1
- package/dist/types/html/HTMLProvider.d.ts +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +5 -1
- package/dist/types/server/useDictionary.d.ts +6 -6
- package/dist/types/solidCompat.d.ts +92 -0
- package/dist/types/solidElement/renderSolidElement.d.ts +1 -1
- package/package.json +25 -18
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { reportExposure } from "./analytics/exposureSink.js";
|
|
2
|
+
import { renderIntlayerNode } from "./IntlayerNode.jsx";
|
|
3
|
+
import { LoadingBoundary } from "./LoadingBoundary.jsx";
|
|
4
|
+
import { lazyComponent } from "./solidCompat.js";
|
|
5
|
+
import { renderSolidElement } from "./solidElement/renderSolidElement.jsx";
|
|
6
|
+
import { bindInsertedValues, conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInterpreterLocale, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
|
|
7
|
+
import { editor, internationalization } from "@intlayer/config/built";
|
|
8
|
+
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
9
|
+
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
10
|
+
// src/plugins.tsx
|
|
11
|
+
var LazyContentSelector = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : lazyComponent(() => import("./editor/ContentSelector.jsx").then((m) => ({ default: m.ContentSelector })));
|
|
12
|
+
var markdownRendererModulePromise = process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" ? import("./markdown/MarkdownRenderer.jsx").then((m) => ({
|
|
13
|
+
MarkdownRenderer: m.MarkdownRenderer,
|
|
14
|
+
MarkdownMetadataRenderer: m.MarkdownMetadataRenderer
|
|
15
|
+
})) : null;
|
|
16
|
+
var htmlRendererModulePromise = process.env.INTLAYER_NODE_TYPE_HTML !== "false" ? import("./html/HTMLRenderer.jsx").then((m) => m.HTMLRenderer) : null;
|
|
17
|
+
markdownRendererModulePromise?.catch(() => {});
|
|
18
|
+
htmlRendererModulePromise?.catch(() => {});
|
|
19
|
+
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
20
|
+
var intlayerNodePlugins = {
|
|
21
|
+
id: "intlayer-node-plugin",
|
|
22
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
23
|
+
transform: (_node, props) => {
|
|
24
|
+
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
|
|
25
|
+
dictionaryKey: props.dictionaryKey,
|
|
26
|
+
keyPath: props.keyPath,
|
|
27
|
+
locale: props.locale,
|
|
28
|
+
nodeType: "text"
|
|
29
|
+
});
|
|
30
|
+
if (process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled) {
|
|
31
|
+
const { plugins, ...rest } = props;
|
|
32
|
+
return renderIntlayerNode({
|
|
33
|
+
value: rest.children,
|
|
34
|
+
children: <LoadingBoundary fallback={rest.children}>
|
|
35
|
+
<LazyContentSelector {...rest}>{rest.children}</LazyContentSelector>
|
|
36
|
+
</LoadingBoundary>
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return renderIntlayerNode({
|
|
40
|
+
value: props.children,
|
|
41
|
+
children: props.children
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
46
|
+
var solidNodePlugins = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? fallbackPlugin : {
|
|
47
|
+
id: "solid-node-plugin",
|
|
48
|
+
canHandle: (node) => typeof node === "object" && node?.props !== void 0 || typeof Node !== "undefined" && node instanceof Node,
|
|
49
|
+
transform: (node, { plugins, ...rest }) => {
|
|
50
|
+
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
|
|
51
|
+
dictionaryKey: rest.dictionaryKey,
|
|
52
|
+
keyPath: rest.keyPath,
|
|
53
|
+
locale: rest.locale,
|
|
54
|
+
nodeType: "solid-node"
|
|
55
|
+
});
|
|
56
|
+
return renderIntlayerNode({
|
|
57
|
+
...rest,
|
|
58
|
+
value: "[[solid-element]]",
|
|
59
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? <LoadingBoundary fallback={typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node)}>
|
|
60
|
+
<LazyContentSelector {...rest}>
|
|
61
|
+
{typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node)}
|
|
62
|
+
</LazyContentSelector>
|
|
63
|
+
</LoadingBoundary> : typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Split insertion string and join with JSX elements
|
|
69
|
+
*/
|
|
70
|
+
var splitAndJoinInsertion = (template, values) => {
|
|
71
|
+
const result = splitInsertionTemplate(template, values);
|
|
72
|
+
if (result.isSimple) return result.parts;
|
|
73
|
+
return result.parts;
|
|
74
|
+
};
|
|
75
|
+
/** Insertion plugin for Solid. Handles component/element insertion. */
|
|
76
|
+
var insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? fallbackPlugin : {
|
|
77
|
+
id: "insertion-plugin",
|
|
78
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
79
|
+
transform: (node, props, deepTransformNode) => {
|
|
80
|
+
const newKeyPath = [...props.keyPath, { type: NodeTypes.INSERTION }];
|
|
81
|
+
const children = node[NodeTypes.INSERTION];
|
|
82
|
+
return (values) => {
|
|
83
|
+
/** Insertion string plugin. Replaces strings by injecting the values. */
|
|
84
|
+
const insertionStringPlugin = {
|
|
85
|
+
id: "insertion-string-plugin",
|
|
86
|
+
canHandle: (n) => typeof n === "string" || isInterpolableWrapperNode(n),
|
|
87
|
+
transform: (n, subProps, deepTransformNode) => {
|
|
88
|
+
if (isInterpolableWrapperNode(n)) return transformInterpolableNode(n, values, subProps, props.plugins, deepTransformNode);
|
|
89
|
+
const result = splitAndJoinInsertion(deepTransformNode(n, {
|
|
90
|
+
...subProps,
|
|
91
|
+
children: n,
|
|
92
|
+
plugins: (props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")
|
|
93
|
+
}), values);
|
|
94
|
+
return deepTransformNode(result, {
|
|
95
|
+
...subProps,
|
|
96
|
+
plugins: props.plugins,
|
|
97
|
+
children: result
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const result = deepTransformNode(children, {
|
|
102
|
+
...props,
|
|
103
|
+
children,
|
|
104
|
+
keyPath: newKeyPath,
|
|
105
|
+
plugins: [insertionStringPlugin, ...props.plugins ?? []]
|
|
106
|
+
});
|
|
107
|
+
return bindInsertedValues(children, result, values, true);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Code-split renderers are loaded with `lazy` rather than read through
|
|
113
|
+
* `useLoadDynamic`'s value proxy. A component reached through that proxy gets
|
|
114
|
+
* re-invoked on every read, inside the caller's tracking scope — which leaks the
|
|
115
|
+
* component's own reactive reads upward and re-renders forever, rebuilding a
|
|
116
|
+
* fresh instance each pass. `lazy` keeps a single memoised instance and hands
|
|
117
|
+
* pending state to Suspense.
|
|
118
|
+
*/
|
|
119
|
+
var MarkdownSuspenseRenderer = lazyComponent(() => markdownRendererModulePromise.then((modules) => ({ default: modules.MarkdownRenderer })));
|
|
120
|
+
var MarkdownMetadataSuspenseRenderer = lazyComponent(() => markdownRendererModulePromise.then((modules) => ({ default: modules.MarkdownMetadataRenderer })));
|
|
121
|
+
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
122
|
+
var markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
123
|
+
id: "markdown-string-plugin",
|
|
124
|
+
canHandle: (node) => typeof node === "string",
|
|
125
|
+
transform: (node, props, deepTransformNode) => {
|
|
126
|
+
const { plugins, ...rest } = props;
|
|
127
|
+
const metadataNodes = deepTransformNode(getMarkdownMetadata(node) ?? {}, {
|
|
128
|
+
plugins: [{
|
|
129
|
+
id: "markdown-metadata-plugin",
|
|
130
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
131
|
+
transform: (metadataNode, props) => renderIntlayerNode({
|
|
132
|
+
...props,
|
|
133
|
+
value: metadataNode,
|
|
134
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? <LoadingBoundary>
|
|
135
|
+
<LazyContentSelector {...rest}>
|
|
136
|
+
<MarkdownMetadataSuspenseRenderer {...rest} metadataKeyPath={props.keyPath}>
|
|
137
|
+
{node}
|
|
138
|
+
</MarkdownMetadataSuspenseRenderer>
|
|
139
|
+
</LazyContentSelector>
|
|
140
|
+
</LoadingBoundary> : <MarkdownMetadataSuspenseRenderer {...rest} metadataKeyPath={props.keyPath}>
|
|
141
|
+
{node}
|
|
142
|
+
</MarkdownMetadataSuspenseRenderer>
|
|
143
|
+
})
|
|
144
|
+
}],
|
|
145
|
+
dictionaryKey: rest.dictionaryKey,
|
|
146
|
+
keyPath: []
|
|
147
|
+
});
|
|
148
|
+
const render = (components) => renderIntlayerNode({
|
|
149
|
+
...props,
|
|
150
|
+
value: node,
|
|
151
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? <LoadingBoundary>
|
|
152
|
+
<LazyContentSelector {...rest}>
|
|
153
|
+
<MarkdownSuspenseRenderer {...rest} components={components}>
|
|
154
|
+
{node}
|
|
155
|
+
</MarkdownSuspenseRenderer>
|
|
156
|
+
</LazyContentSelector>
|
|
157
|
+
</LoadingBoundary> : <MarkdownSuspenseRenderer {...rest} components={components}>
|
|
158
|
+
{node}
|
|
159
|
+
</MarkdownSuspenseRenderer>,
|
|
160
|
+
additionalProps: {
|
|
161
|
+
metadata: metadataNodes,
|
|
162
|
+
use: render
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return render();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
169
|
+
id: "markdown-plugin",
|
|
170
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
|
|
171
|
+
transform: (node, props, deepTransformNode) => {
|
|
172
|
+
const newKeyPath = [...props.keyPath, { type: NodeTypes.MARKDOWN }];
|
|
173
|
+
const children = node[NodeTypes.MARKDOWN];
|
|
174
|
+
return deepTransformNode(children, {
|
|
175
|
+
...props,
|
|
176
|
+
children,
|
|
177
|
+
keyPath: newKeyPath,
|
|
178
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var HTMLSuspenseRenderer = lazyComponent(() => htmlRendererModulePromise.then((HTMLRenderer) => ({ default: HTMLRenderer })));
|
|
183
|
+
/** HTML plugin. Replaces node with a function that takes components => JSX.Element. */
|
|
184
|
+
var htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
|
|
185
|
+
id: "html-plugin",
|
|
186
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
187
|
+
transform: (node, props) => {
|
|
188
|
+
const html = node[NodeTypes.HTML];
|
|
189
|
+
const { plugins, children: _nodeChildren, ...rest } = props;
|
|
190
|
+
const render = (userComponents) => renderIntlayerNode({
|
|
191
|
+
...rest,
|
|
192
|
+
value: html,
|
|
193
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? <LoadingBoundary>
|
|
194
|
+
<LazyContentSelector {...rest}>
|
|
195
|
+
<HTMLSuspenseRenderer {...rest} html={html} components={userComponents} />
|
|
196
|
+
</LazyContentSelector>
|
|
197
|
+
</LoadingBoundary> : <HTMLSuspenseRenderer {...rest} html={html} components={userComponents} />,
|
|
198
|
+
additionalProps: { use: render }
|
|
199
|
+
});
|
|
200
|
+
return render();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var pluginsCache = /* @__PURE__ */ new Map();
|
|
204
|
+
/**
|
|
205
|
+
* Get the plugins array for Solid content transformation.
|
|
206
|
+
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
207
|
+
*/
|
|
208
|
+
var getPlugins = (locale, fallback = true) => {
|
|
209
|
+
const currentLocale = resolveInterpreterLocale(locale);
|
|
210
|
+
const cacheKey = `${currentLocale}_${fallback}`;
|
|
211
|
+
if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
|
|
212
|
+
const enabledPlugins = [
|
|
213
|
+
intlayerNodePlugins,
|
|
214
|
+
translationPlugin(currentLocale, fallback ? internationalization.defaultLocale : void 0),
|
|
215
|
+
enumerationPlugin,
|
|
216
|
+
pluralPlugin(currentLocale),
|
|
217
|
+
conditionPlugin,
|
|
218
|
+
nestedPlugin(currentLocale),
|
|
219
|
+
filePlugin,
|
|
220
|
+
genderPlugin,
|
|
221
|
+
selectPlugin,
|
|
222
|
+
solidNodePlugins,
|
|
223
|
+
insertionPlugin,
|
|
224
|
+
markdownPlugin,
|
|
225
|
+
htmlPlugin
|
|
226
|
+
].filter((plugin) => plugin !== fallbackPlugin);
|
|
227
|
+
pluginsCache.set(cacheKey, enabledPlugins);
|
|
228
|
+
return enabledPlugins;
|
|
229
|
+
};
|
|
230
|
+
export { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, solidNodePlugins };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/proxyKeys.ts
|
|
2
|
+
/**
|
|
3
|
+
* String property keys the dynamic-loading stand-in proxy special-cases instead
|
|
4
|
+
* of delegating to the loaded value. `Symbol.toPrimitive` is also reserved but,
|
|
5
|
+
* being a symbol, is handled inline.
|
|
6
|
+
*/
|
|
7
|
+
var PROXY_RESERVED_KEYS = {
|
|
8
|
+
promiseThen: "then",
|
|
9
|
+
toString: "toString",
|
|
10
|
+
valueOf: "valueOf",
|
|
11
|
+
value: "value"
|
|
12
|
+
};
|
|
13
|
+
export { PROXY_RESERVED_KEYS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useDictionary } from "./useDictionary.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useDictionary as useDictionary$1 } from "../client/useDictionary.js";
|
|
2
|
+
import { createAsyncValue, trackAsyncValue } from "../solidCompat.js";
|
|
3
|
+
// src/server/useDictionary.ts
|
|
4
|
+
/**
|
|
5
|
+
* Server-rendering counterpart of `useDictionaryDynamic`, emitted by the
|
|
6
|
+
* optimizer in the server bundle so dynamic-mode dictionaries render
|
|
7
|
+
* synchronously from static JSON.
|
|
8
|
+
*
|
|
9
|
+
* The second argument is either a locale or a selector object
|
|
10
|
+
* (`{ item }`, `{ variant }`, optionally with `locale`),
|
|
11
|
+
* forwarded to the client `useDictionary`.
|
|
12
|
+
*
|
|
13
|
+
* The discarded async value is load-bearing: Solid assigns hydration ids from
|
|
14
|
+
* a positional counter shared by async primitives and element `data-hk` keys,
|
|
15
|
+
* and the client bundle creates the same primitives per call (see
|
|
16
|
+
* `useLoadDynamic`) — without the matching slots here, every subsequent
|
|
17
|
+
* hydration key shifts and event bindings are silently lost.
|
|
18
|
+
* `ssrLoadFrom: 'initial'` keeps the dictionary out of the Solid 1 SSR
|
|
19
|
+
* serialization payload, so it is not shipped twice in the HTML.
|
|
20
|
+
*/
|
|
21
|
+
var useDictionary = (dictionary, localeOrSelector) => {
|
|
22
|
+
const serverValue = createAsyncValue(() => dictionary, (resolvedDictionary) => resolvedDictionary, {
|
|
23
|
+
initialValue: dictionary,
|
|
24
|
+
ssrLoadFrom: "initial"
|
|
25
|
+
});
|
|
26
|
+
trackAsyncValue(serverValue);
|
|
27
|
+
return useDictionary$1(dictionary, localeOrSelector);
|
|
28
|
+
};
|
|
29
|
+
export { useDictionary };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as Solid from "solid-js";
|
|
2
|
+
// src/solidCompat.ts
|
|
3
|
+
/**
|
|
4
|
+
* Version bridge between Solid 1.x and Solid 2.x.
|
|
5
|
+
*
|
|
6
|
+
* Solid 2 removed or reshaped several primitives this package relies on
|
|
7
|
+
* (`createResource`, `onMount`, `Suspense`, `createComputed`, `on`,
|
|
8
|
+
* `startTransition`, single-argument effects, `Context.Provider`). Every
|
|
9
|
+
* version-sensitive call goes through this module (and `LoadingBoundary`),
|
|
10
|
+
* which feature-detects the installed runtime, so one build of
|
|
11
|
+
* `solid-intlayer` runs on both.
|
|
12
|
+
*
|
|
13
|
+
* Types are written against the Solid 1 declarations (the dev dependency);
|
|
14
|
+
* Solid 2 call shapes are described by {@link SolidTwoRuntime}.
|
|
15
|
+
*
|
|
16
|
+
* Members are read directly on the namespace, never through a computed key or
|
|
17
|
+
* an alias of it, so bundlers can still tree-shake `solid-js`. The only
|
|
18
|
+
* members missing from one major are `createResource` and `startTransition`
|
|
19
|
+
* (Solid 1 only), which a Solid 2 build reports as always-undefined imports.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Whether the installed `solid-js` is a 2.x runtime. `createResource` was
|
|
23
|
+
* removed in Solid 2, which makes it a reliable discriminant.
|
|
24
|
+
*
|
|
25
|
+
* A static member read on purpose: `'createResource' in Solid` makes bundlers
|
|
26
|
+
* materialize the whole namespace and keep every `solid-js` export (+2.4 KB
|
|
27
|
+
* gzip in a lean app).
|
|
28
|
+
*/
|
|
29
|
+
var isSolidTwo = typeof Solid.createResource !== "function";
|
|
30
|
+
/**
|
|
31
|
+
* Side effect split into a tracked `compute` and an untracked `effect`, the
|
|
32
|
+
* shape Solid 2 requires. `effect` may return a cleanup, which runs before the
|
|
33
|
+
* next execution and on disposal.
|
|
34
|
+
*/
|
|
35
|
+
var createWatchEffect = (compute, effect) => {
|
|
36
|
+
if (isSolidTwo) {
|
|
37
|
+
Solid.createEffect(compute, effect);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let previous;
|
|
41
|
+
Solid.createEffect(() => {
|
|
42
|
+
const value = compute();
|
|
43
|
+
const cleanup = Solid.untrack(() => effect(value, previous));
|
|
44
|
+
previous = value;
|
|
45
|
+
if (typeof cleanup === "function") Solid.onCleanup(cleanup);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Runs `callback` once, after the component has mounted. A returned function
|
|
50
|
+
* runs on disposal.
|
|
51
|
+
*/
|
|
52
|
+
var onMounted = (callback) => createWatchEffect(() => void 0, () => callback());
|
|
53
|
+
/**
|
|
54
|
+
* Like {@link createWatchEffect}, but skips the initial run: `effect` only
|
|
55
|
+
* fires when `compute` produces a value after the first one.
|
|
56
|
+
*/
|
|
57
|
+
var createChangeEffect = (compute, effect) => {
|
|
58
|
+
let isInitialRun = true;
|
|
59
|
+
createWatchEffect(compute, (value, previous) => {
|
|
60
|
+
if (isInitialRun) {
|
|
61
|
+
isInitialRun = false;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
return effect(value, previous);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Signal whose value `compute` re-derives whenever its tracked reads change,
|
|
69
|
+
* and that can also be written in between; the latest of the two wins. Reads
|
|
70
|
+
* are always consistent, so nothing renders against a stale value
|
|
71
|
+
* (`createSignal(fn)` in Solid 2, two memos ordered by a write clock in
|
|
72
|
+
* Solid 1).
|
|
73
|
+
*/
|
|
74
|
+
var createWritableMemo = (compute) => {
|
|
75
|
+
if (isSolidTwo) return Solid.createSignal(compute);
|
|
76
|
+
let clock = 0;
|
|
77
|
+
let currentValue;
|
|
78
|
+
const [written, setWritten] = Solid.createSignal(void 0);
|
|
79
|
+
const derived = Solid.createMemo(() => ({
|
|
80
|
+
value: compute(currentValue),
|
|
81
|
+
order: clock += 1
|
|
82
|
+
}));
|
|
83
|
+
const value = Solid.createMemo(() => {
|
|
84
|
+
const derivedValue = derived();
|
|
85
|
+
const writtenValue = written();
|
|
86
|
+
currentValue = writtenValue && writtenValue.order > derivedValue.order ? writtenValue.value : derivedValue.value;
|
|
87
|
+
return currentValue;
|
|
88
|
+
});
|
|
89
|
+
const setValue = (nextValue) => {
|
|
90
|
+
setWritten({
|
|
91
|
+
value: nextValue,
|
|
92
|
+
order: clock += 1
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
return [value, setValue];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Runs `update` inside a transition where the runtime offers one. Solid 2
|
|
99
|
+
* holds pending async reads on its own, so `update` runs directly.
|
|
100
|
+
*/
|
|
101
|
+
var runInTransition = (update) => {
|
|
102
|
+
if (isSolidTwo) {
|
|
103
|
+
update();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
Solid.startTransition(update);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Async value derived from a reactive `source` (`createResource` in Solid 1,
|
|
110
|
+
* an async `createMemo` in Solid 2).
|
|
111
|
+
*
|
|
112
|
+
* Reading the returned accessor under a `LoadingBoundary` holds the boundary
|
|
113
|
+
* while the fetch is pending. Outside a boundary, Solid 1 reads `undefined`
|
|
114
|
+
* until it settles, while Solid 2 defers the mount instead.
|
|
115
|
+
*
|
|
116
|
+
* A `source` yielding `false`, `null` or `undefined` skips the fetch and
|
|
117
|
+
* exposes `initialValue`, as `createResource` does.
|
|
118
|
+
*/
|
|
119
|
+
var createAsyncValue = (source, fetcher, options = {}) => {
|
|
120
|
+
if (isSolidTwo) return Solid.createMemo(() => {
|
|
121
|
+
const resolvedSource = source();
|
|
122
|
+
if (resolvedSource === false || resolvedSource === null || resolvedSource === void 0) return options.initialValue;
|
|
123
|
+
return fetcher(resolvedSource);
|
|
124
|
+
});
|
|
125
|
+
const [resource] = Solid.createResource(source, (resolvedSource) => fetcher(resolvedSource), options);
|
|
126
|
+
return resource;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Subscribes the enclosing Solid 1 `Suspense` to `accessor`, so it waits for
|
|
130
|
+
* the value without aborting the component body.
|
|
131
|
+
*
|
|
132
|
+
* A no-op on Solid 2: reads there suspend the boundary they render under, and
|
|
133
|
+
* an extra read from the component body would hold the boundary above the
|
|
134
|
+
* component instead — or defer the whole root mount when there is none.
|
|
135
|
+
*/
|
|
136
|
+
var trackAsyncValue = (accessor) => {
|
|
137
|
+
if (isSolidTwo) return;
|
|
138
|
+
Solid.createRenderEffect(() => {
|
|
139
|
+
accessor();
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* `lazy` from `solid-js`. SolidStart's server build rewrites any
|
|
144
|
+
* `import { lazy } from 'solid-js'` in JSX modules — dependencies included — to
|
|
145
|
+
* `@solidjs/start/server`, which this package cannot resolve under strict
|
|
146
|
+
* installs. Reading it here keeps that rewrite away; the lazily loaded
|
|
147
|
+
* renderers carry no CSS for SolidStart to collect.
|
|
148
|
+
*/
|
|
149
|
+
var lazyComponent = (load) => Solid.lazy(load);
|
|
150
|
+
/**
|
|
151
|
+
* Provider component of a context: `Context.Provider` in Solid 1, the context
|
|
152
|
+
* object itself in Solid 2.
|
|
153
|
+
*/
|
|
154
|
+
var getContextProvider = (context) => context.Provider ?? context;
|
|
155
|
+
export { createAsyncValue, createChangeEffect, createWatchEffect, createWritableMemo, getContextProvider, isSolidTwo, lazyComponent, onMounted, runInTransition, trackAsyncValue };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/solidElement/renderSolidElement.tsx
|
|
2
|
+
var renderSolidElement = (element) => {
|
|
3
|
+
if (typeof element === "string") return element;
|
|
4
|
+
const convertChildrenAsArray = (element) => {
|
|
5
|
+
if (element?.props && typeof element.props.children === "object") {
|
|
6
|
+
const childrenResult = [];
|
|
7
|
+
const { children } = element.props;
|
|
8
|
+
Object.keys(children ?? {}).forEach((key) => {
|
|
9
|
+
childrenResult.push(renderSolidElement(children?.[key]));
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
...element,
|
|
13
|
+
props: {
|
|
14
|
+
...element.props,
|
|
15
|
+
children: childrenResult
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...element,
|
|
21
|
+
props: {
|
|
22
|
+
...element.props,
|
|
23
|
+
children: element.props?.children ?? []
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const { type, props } = convertChildrenAsArray(element);
|
|
28
|
+
return <Dynamic component={type ?? "span"} {...props}>
|
|
29
|
+
{props.children}
|
|
30
|
+
</Dynamic>;
|
|
31
|
+
};
|
|
32
|
+
export { renderSolidElement };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component, JSX } from 'solid-js';
|
|
2
|
+
export type LoadingBoundaryProps = {
|
|
3
|
+
fallback?: JSX.Element;
|
|
4
|
+
children: JSX.Element;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Shows `fallback` while async reads below it are pending: `Suspense` in
|
|
8
|
+
* Solid 1, `Loading` in Solid 2. Both are compiler built-ins, auto-imported
|
|
9
|
+
* from the app's own web runtime; only the branch of the installed version is
|
|
10
|
+
* ever evaluated.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LoadingBoundary: Component<LoadingBoundaryProps>;
|
|
@@ -14,4 +14,4 @@ import { DeepTransformContent } from '../plugins';
|
|
|
14
14
|
* If the locale is not provided (directly or through the selector), it will
|
|
15
15
|
* use the locale from the client context.
|
|
16
16
|
*/
|
|
17
|
-
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => DeepTransformContent<T["content"]> | import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, (string & {}) | "tr" | "th" | "hr" | "
|
|
17
|
+
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => DeepTransformContent<T["content"]> | import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, (string & {}) | "tr" | "th" | "hr" | "id" | "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ms" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi" | "mi-NZ" | "mr" | "mr-IN" | "mn" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA">, import('../plugins').IInterpreterPluginState, (string & {}) | "tr" | "th" | "hr" | "id" | "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ms" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi" | "mi-NZ" | "mr" | "mr-IN" | "mn" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA">;
|
|
@@ -10,16 +10,16 @@ export declare const loadDynamicValue: <T, Source extends DynamicSource>(source:
|
|
|
10
10
|
* {@link loadDynamicValue} for this key returns it synchronously.
|
|
11
11
|
*
|
|
12
12
|
* Used for dictionaries a build-tool plugin awaited while their entry point
|
|
13
|
-
* evaluated:
|
|
14
|
-
* so
|
|
13
|
+
* evaluated: the async value resolves without ever entering a pending state,
|
|
14
|
+
* so the loading boundary is not triggered and the first render already has the content.
|
|
15
15
|
*
|
|
16
16
|
* An existing entry is never replaced — an in-flight load owns its key.
|
|
17
17
|
*/
|
|
18
18
|
export declare const seedDynamicValue: <T>(source: DynamicSource, value: T) => void;
|
|
19
19
|
/**
|
|
20
|
-
* Creates a stable callable proxy that re-reads the Solid
|
|
20
|
+
* Creates a stable callable proxy that re-reads the Solid async value on each
|
|
21
21
|
* property access. This keeps synchronous Intlayer access (`content.x.value`)
|
|
22
|
-
* safe while Solid
|
|
22
|
+
* safe while the Solid loading boundary owns the actual pending state.
|
|
23
23
|
*/
|
|
24
24
|
export declare const createLoadableProxy: <T>(read: () => T | undefined) => T;
|
|
25
25
|
/**
|
|
@@ -32,7 +32,7 @@ export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled?:
|
|
|
32
32
|
/**
|
|
33
33
|
* Hook that provides the locale storage and a function to set it
|
|
34
34
|
*/
|
|
35
|
-
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('solid-js').
|
|
35
|
+
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('solid-js').SourceAccessor<{
|
|
36
36
|
getLocale: () => import('@intlayer/types').Locale;
|
|
37
37
|
setLocale: (locale: LocalesValues) => void;
|
|
38
38
|
}>;
|
|
@@ -43,7 +43,7 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('so
|
|
|
43
43
|
*
|
|
44
44
|
* Hook that provides the locale cookie and a function to set it
|
|
45
45
|
*/
|
|
46
|
-
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => import('solid-js').
|
|
46
|
+
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => import('solid-js').SourceAccessor<{
|
|
47
47
|
getLocale: () => import('@intlayer/types').Locale;
|
|
48
48
|
setLocale: (locale: LocalesValues) => void;
|
|
49
49
|
}>;
|
|
@@ -18,4 +18,4 @@ import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
18
18
|
* }).format(123.45);
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare const useIntl: (locale?: LocalesValues) => import('solid-js').
|
|
21
|
+
export declare const useIntl: (locale?: LocalesValues) => import('solid-js').SourceAccessor<WrappedIntl>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Plugins } from '@intlayer/core/interpreter';
|
|
1
2
|
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from '@intlayer/types/dictionary';
|
|
2
3
|
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
4
|
import { DeepTransformContent } from './plugins';
|
|
@@ -5,5 +6,8 @@ import { DeepTransformContent } from './plugins';
|
|
|
5
6
|
* Transforms a dictionary (or qualified dictionary group) and returns its
|
|
6
7
|
* content for the given locale or selector (`{ item }`, `{ variant }`,
|
|
7
8
|
* optionally combined with `locale`).
|
|
9
|
+
*
|
|
10
|
+
* `getPluginsForLocale` picks the plugin set; transforms are cached per plugin
|
|
11
|
+
* set, so a dedicated set keeps the result from being shared.
|
|
8
12
|
*/
|
|
9
|
-
export declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
13
|
+
export declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A, getPluginsForLocale?: (locale?: LocalesValues) => Plugins[]) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -3,7 +3,7 @@ import { HTMLComponents } from './types';
|
|
|
3
3
|
type HTMLProviderValue = {
|
|
4
4
|
components?: HTMLComponents<'permissive', {}>;
|
|
5
5
|
};
|
|
6
|
-
export declare const useHTMLContext: () => HTMLProviderValue |
|
|
6
|
+
export declare const useHTMLContext: () => HTMLProviderValue | null;
|
|
7
7
|
export type HTMLProviderProps = ParentProps<{
|
|
8
8
|
components?: HTMLComponents<'permissive', {}>;
|
|
9
9
|
}>;
|
|
@@ -13,7 +13,11 @@ type MarkdownProviderValue = {
|
|
|
13
13
|
components?: HTMLComponents<'permissive', {}>;
|
|
14
14
|
renderMarkdown: (content: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ValidComponent) => JSXElement | Promise<JSXElement>;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* `null` outside a provider. An explicit default keeps `useContext` from
|
|
18
|
+
* throwing on Solid 2, where default-less contexts require a provider.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MarkdownContext: import('solid-js').Context<MarkdownProviderValue | null>;
|
|
17
21
|
export type MarkdownProviderProps = ParentProps<{
|
|
18
22
|
components?: HTMLComponents<'permissive', {}>;
|
|
19
23
|
wrapper?: ValidComponent;
|
|
@@ -9,12 +9,12 @@ import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentat
|
|
|
9
9
|
* (`{ item }`, `{ variant }`, optionally with `locale`),
|
|
10
10
|
* forwarded to the client `useDictionary`.
|
|
11
11
|
*
|
|
12
|
-
* The discarded
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `useLoadDynamic`) — without the matching
|
|
12
|
+
* The discarded async value is load-bearing: Solid assigns hydration ids from
|
|
13
|
+
* a positional counter shared by async primitives and element `data-hk` keys,
|
|
14
|
+
* and the client bundle creates the same primitives per call (see
|
|
15
|
+
* `useLoadDynamic`) — without the matching slots here, every subsequent
|
|
16
16
|
* hydration key shifts and event bindings are silently lost.
|
|
17
|
-
* `ssrLoadFrom: 'initial'` keeps the dictionary out of the SSR
|
|
18
|
-
* payload, so it is not shipped twice in the HTML.
|
|
17
|
+
* `ssrLoadFrom: 'initial'` keeps the dictionary out of the Solid 1 SSR
|
|
18
|
+
* serialization payload, so it is not shipped twice in the HTML.
|
|
19
19
|
*/
|
|
20
20
|
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, A>, import('../plugins').IInterpreterPluginState, import('@intlayer/types').ExtractSelectorLocale<A>>;
|