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
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,208 +1,257 @@
|
|
|
1
|
-
import { createComponent
|
|
2
|
-
import { editor
|
|
3
|
-
import { bindInsertedValues
|
|
4
|
-
import { getMarkdownMetadata
|
|
5
|
-
import * as
|
|
6
|
-
import { reportExposure
|
|
7
|
-
import { renderIntlayerNode
|
|
8
|
-
import { LoadingBoundary
|
|
9
|
-
import { lazyComponent
|
|
10
|
-
import { renderSolidElement
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
|
+
import { editor, internationalization } from "@intlayer/config/built";
|
|
3
|
+
import { bindInsertedValues, conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInterpreterLocale, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
|
|
4
|
+
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
5
|
+
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
6
|
+
import { reportExposure } from "./analytics/exposureSink.mjs";
|
|
7
|
+
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
8
|
+
import { LoadingBoundary } from "./LoadingBoundary.mjs";
|
|
9
|
+
import { lazyComponent } from "./solidCompat.mjs";
|
|
10
|
+
import { renderSolidElement } from "./solidElement/renderSolidElement.mjs";
|
|
11
11
|
// src/plugins.tsx
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
12
|
+
var LazyContentSelector = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : lazyComponent(() => import("./editor/ContentSelector.mjs").then((m) => ({ default: m.ContentSelector })));
|
|
13
|
+
var markdownRendererModulePromise = process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" ? import("./markdown/MarkdownRenderer.mjs").then((m) => ({
|
|
14
|
+
MarkdownRenderer: m.MarkdownRenderer,
|
|
15
|
+
MarkdownMetadataRenderer: m.MarkdownMetadataRenderer
|
|
16
|
+
})) : null;
|
|
17
|
+
var htmlRendererModulePromise = process.env.INTLAYER_NODE_TYPE_HTML !== "false" ? import("./html/HTMLRenderer.mjs").then((m) => m.HTMLRenderer) : null;
|
|
18
|
+
markdownRendererModulePromise?.catch(() => {});
|
|
19
|
+
htmlRendererModulePromise?.catch(() => {});
|
|
20
|
+
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
21
|
+
var intlayerNodePlugins = {
|
|
18
22
|
id: "intlayer-node-plugin",
|
|
19
|
-
canHandle: (
|
|
20
|
-
transform: (
|
|
21
|
-
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false"
|
|
22
|
-
dictionaryKey:
|
|
23
|
-
keyPath:
|
|
24
|
-
locale:
|
|
23
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
24
|
+
transform: (_node, props) => {
|
|
25
|
+
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
|
|
26
|
+
dictionaryKey: props.dictionaryKey,
|
|
27
|
+
keyPath: props.keyPath,
|
|
28
|
+
locale: props.locale,
|
|
25
29
|
nodeType: "text"
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
});
|
|
31
|
+
if (process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled) {
|
|
32
|
+
const { plugins, ...rest } = props;
|
|
33
|
+
return renderIntlayerNode({
|
|
34
|
+
value: rest.children,
|
|
35
|
+
children: createComponent(LoadingBoundary, {
|
|
31
36
|
get fallback() {
|
|
32
|
-
return
|
|
37
|
+
return rest.children;
|
|
33
38
|
},
|
|
34
39
|
get children() {
|
|
35
|
-
return
|
|
36
|
-
return
|
|
40
|
+
return createComponent(LazyContentSelector, mergeProps(rest, { get children() {
|
|
41
|
+
return rest.children;
|
|
37
42
|
} }));
|
|
38
43
|
}
|
|
39
44
|
})
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
|
-
return
|
|
43
|
-
value:
|
|
44
|
-
children:
|
|
47
|
+
return renderIntlayerNode({
|
|
48
|
+
value: props.children,
|
|
49
|
+
children: props.children
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
|
-
}
|
|
52
|
+
};
|
|
53
|
+
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
54
|
+
var solidNodePlugins = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? fallbackPlugin : {
|
|
48
55
|
id: "solid-node-plugin",
|
|
49
|
-
canHandle: (
|
|
50
|
-
transform: (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
56
|
+
canHandle: (node) => typeof node === "object" && node?.props !== void 0 || typeof Node !== "undefined" && node instanceof Node,
|
|
57
|
+
transform: (node, { plugins, ...rest }) => {
|
|
58
|
+
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
|
|
59
|
+
dictionaryKey: rest.dictionaryKey,
|
|
60
|
+
keyPath: rest.keyPath,
|
|
61
|
+
locale: rest.locale,
|
|
62
|
+
nodeType: "solid-node"
|
|
63
|
+
});
|
|
64
|
+
return renderIntlayerNode({
|
|
65
|
+
...rest,
|
|
66
|
+
value: "[[solid-element]]",
|
|
67
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? createComponent(LoadingBoundary, {
|
|
68
|
+
get fallback() {
|
|
69
|
+
return typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node);
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return createComponent(LazyContentSelector, mergeProps(rest, { get children() {
|
|
73
|
+
return typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node);
|
|
74
|
+
} }));
|
|
75
|
+
}
|
|
76
|
+
}) : typeof Node !== "undefined" && node instanceof Node ? node : renderSolidElement(node)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Split insertion string and join with JSX elements
|
|
82
|
+
*/
|
|
83
|
+
var splitAndJoinInsertion = (template, values) => {
|
|
84
|
+
const result = splitInsertionTemplate(template, values);
|
|
85
|
+
if (result.isSimple) return result.parts;
|
|
86
|
+
return result.parts;
|
|
87
|
+
};
|
|
88
|
+
/** Insertion plugin for Solid. Handles component/element insertion. */
|
|
89
|
+
var insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? fallbackPlugin : {
|
|
73
90
|
id: "insertion-plugin",
|
|
74
|
-
canHandle: (
|
|
75
|
-
transform: (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
92
|
+
transform: (node, props, deepTransformNode) => {
|
|
93
|
+
const newKeyPath = [...props.keyPath, { type: NodeTypes.INSERTION }];
|
|
94
|
+
const children = node[NodeTypes.INSERTION];
|
|
95
|
+
return (values) => {
|
|
96
|
+
/** Insertion string plugin. Replaces strings by injecting the values. */
|
|
97
|
+
const insertionStringPlugin = {
|
|
79
98
|
id: "insertion-string-plugin",
|
|
80
|
-
canHandle: (
|
|
81
|
-
transform: (n,
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
...
|
|
99
|
+
canHandle: (n) => typeof n === "string" || isInterpolableWrapperNode(n),
|
|
100
|
+
transform: (n, subProps, deepTransformNode) => {
|
|
101
|
+
if (isInterpolableWrapperNode(n)) return transformInterpolableNode(n, values, subProps, props.plugins, deepTransformNode);
|
|
102
|
+
const result = splitAndJoinInsertion(deepTransformNode(n, {
|
|
103
|
+
...subProps,
|
|
85
104
|
children: n,
|
|
86
|
-
plugins: (
|
|
87
|
-
}),
|
|
88
|
-
return
|
|
89
|
-
...
|
|
90
|
-
plugins:
|
|
91
|
-
children:
|
|
105
|
+
plugins: (props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")
|
|
106
|
+
}), values);
|
|
107
|
+
return deepTransformNode(result, {
|
|
108
|
+
...subProps,
|
|
109
|
+
plugins: props.plugins,
|
|
110
|
+
children: result
|
|
92
111
|
});
|
|
93
112
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
};
|
|
114
|
+
const result = deepTransformNode(children, {
|
|
115
|
+
...props,
|
|
116
|
+
children,
|
|
117
|
+
keyPath: newKeyPath,
|
|
118
|
+
plugins: [insertionStringPlugin, ...props.plugins ?? []]
|
|
99
119
|
});
|
|
100
|
-
return
|
|
120
|
+
return bindInsertedValues(children, result, values, true);
|
|
101
121
|
};
|
|
102
122
|
}
|
|
103
|
-
}
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Code-split renderers are loaded with `lazy` rather than read through
|
|
126
|
+
* `useLoadDynamic`'s value proxy. A component reached through that proxy gets
|
|
127
|
+
* re-invoked on every read, inside the caller's tracking scope — which leaks the
|
|
128
|
+
* component's own reactive reads upward and re-renders forever, rebuilding a
|
|
129
|
+
* fresh instance each pass. `lazy` keeps a single memoised instance and hands
|
|
130
|
+
* pending state to Suspense.
|
|
131
|
+
*/
|
|
132
|
+
var MarkdownSuspenseRenderer = lazyComponent(() => markdownRendererModulePromise.then((modules) => ({ default: modules.MarkdownRenderer })));
|
|
133
|
+
var MarkdownMetadataSuspenseRenderer = lazyComponent(() => markdownRendererModulePromise.then((modules) => ({ default: modules.MarkdownMetadataRenderer })));
|
|
134
|
+
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
135
|
+
var markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
104
136
|
id: "markdown-string-plugin",
|
|
105
|
-
canHandle: (
|
|
106
|
-
transform: (
|
|
107
|
-
|
|
137
|
+
canHandle: (node) => typeof node === "string",
|
|
138
|
+
transform: (node, props, deepTransformNode) => {
|
|
139
|
+
const { plugins, ...rest } = props;
|
|
140
|
+
const metadataNodes = deepTransformNode(getMarkdownMetadata(node) ?? {}, {
|
|
108
141
|
plugins: [{
|
|
109
142
|
id: "markdown-metadata-plugin",
|
|
110
|
-
canHandle: (
|
|
111
|
-
transform: (
|
|
112
|
-
...
|
|
113
|
-
value:
|
|
114
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
115
|
-
return
|
|
116
|
-
return
|
|
143
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
144
|
+
transform: (metadataNode, props) => renderIntlayerNode({
|
|
145
|
+
...props,
|
|
146
|
+
value: metadataNode,
|
|
147
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? createComponent(LoadingBoundary, { get children() {
|
|
148
|
+
return createComponent(LazyContentSelector, mergeProps(rest, { get children() {
|
|
149
|
+
return createComponent(MarkdownMetadataSuspenseRenderer, mergeProps(rest, {
|
|
117
150
|
get metadataKeyPath() {
|
|
118
|
-
return
|
|
151
|
+
return props.keyPath;
|
|
119
152
|
},
|
|
120
|
-
children:
|
|
153
|
+
children: node
|
|
121
154
|
}));
|
|
122
155
|
} }));
|
|
123
|
-
} }) :
|
|
156
|
+
} }) : createComponent(MarkdownMetadataSuspenseRenderer, mergeProps(rest, {
|
|
124
157
|
get metadataKeyPath() {
|
|
125
|
-
return
|
|
158
|
+
return props.keyPath;
|
|
126
159
|
},
|
|
127
|
-
children:
|
|
160
|
+
children: node
|
|
128
161
|
}))
|
|
129
162
|
})
|
|
130
163
|
}],
|
|
131
|
-
dictionaryKey:
|
|
164
|
+
dictionaryKey: rest.dictionaryKey,
|
|
132
165
|
keyPath: []
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
166
|
+
});
|
|
167
|
+
const render = (components) => renderIntlayerNode({
|
|
168
|
+
...props,
|
|
169
|
+
value: node,
|
|
170
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? createComponent(LoadingBoundary, { get children() {
|
|
171
|
+
return createComponent(LazyContentSelector, mergeProps(rest, { get children() {
|
|
172
|
+
return createComponent(MarkdownSuspenseRenderer, mergeProps(rest, {
|
|
173
|
+
components,
|
|
174
|
+
children: node
|
|
141
175
|
}));
|
|
142
176
|
} }));
|
|
143
|
-
} }) :
|
|
144
|
-
components
|
|
145
|
-
children:
|
|
177
|
+
} }) : createComponent(MarkdownSuspenseRenderer, mergeProps(rest, {
|
|
178
|
+
components,
|
|
179
|
+
children: node
|
|
146
180
|
})),
|
|
147
181
|
additionalProps: {
|
|
148
|
-
metadata:
|
|
149
|
-
use:
|
|
182
|
+
metadata: metadataNodes,
|
|
183
|
+
use: render
|
|
150
184
|
}
|
|
151
185
|
});
|
|
152
|
-
return
|
|
186
|
+
return render();
|
|
153
187
|
}
|
|
154
|
-
}
|
|
188
|
+
};
|
|
189
|
+
var markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
155
190
|
id: "markdown-plugin",
|
|
156
|
-
canHandle: (
|
|
157
|
-
transform: (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
191
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
|
|
192
|
+
transform: (node, props, deepTransformNode) => {
|
|
193
|
+
const newKeyPath = [...props.keyPath, { type: NodeTypes.MARKDOWN }];
|
|
194
|
+
const children = node[NodeTypes.MARKDOWN];
|
|
195
|
+
return deepTransformNode(children, {
|
|
196
|
+
...props,
|
|
197
|
+
children,
|
|
198
|
+
keyPath: newKeyPath,
|
|
199
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
164
200
|
});
|
|
165
201
|
}
|
|
166
|
-
}
|
|
202
|
+
};
|
|
203
|
+
var HTMLSuspenseRenderer = lazyComponent(() => htmlRendererModulePromise.then((HTMLRenderer) => ({ default: HTMLRenderer })));
|
|
204
|
+
/** HTML plugin. Replaces node with a function that takes components => SolidElement. */
|
|
205
|
+
var htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
|
|
167
206
|
id: "html-plugin",
|
|
168
|
-
canHandle: (
|
|
169
|
-
transform: (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
207
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
208
|
+
transform: (node, props) => {
|
|
209
|
+
const html = node[NodeTypes.HTML];
|
|
210
|
+
const { plugins, children: _nodeChildren, ...rest } = props;
|
|
211
|
+
const render = (userComponents) => renderIntlayerNode({
|
|
212
|
+
...rest,
|
|
213
|
+
value: html,
|
|
214
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? createComponent(LoadingBoundary, { get children() {
|
|
215
|
+
return createComponent(LazyContentSelector, mergeProps(rest, { get children() {
|
|
216
|
+
return createComponent(HTMLSuspenseRenderer, mergeProps(rest, {
|
|
217
|
+
html,
|
|
218
|
+
components: userComponents
|
|
178
219
|
}));
|
|
179
220
|
} }));
|
|
180
|
-
} }) :
|
|
181
|
-
html
|
|
182
|
-
components:
|
|
221
|
+
} }) : createComponent(HTMLSuspenseRenderer, mergeProps(rest, {
|
|
222
|
+
html,
|
|
223
|
+
components: userComponents
|
|
183
224
|
})),
|
|
184
|
-
additionalProps: { use:
|
|
225
|
+
additionalProps: { use: render }
|
|
185
226
|
});
|
|
186
|
-
return
|
|
227
|
+
return render();
|
|
187
228
|
}
|
|
188
|
-
}, R = /* @__PURE__ */ new Map(), z = (e, t = !0) => {
|
|
189
|
-
let n = p(e), i = `${n}_${t}`;
|
|
190
|
-
if (R.has(i)) return R.get(i);
|
|
191
|
-
let u = [
|
|
192
|
-
O,
|
|
193
|
-
_(n, t ? r.defaultLocale : void 0),
|
|
194
|
-
o,
|
|
195
|
-
f(n),
|
|
196
|
-
a,
|
|
197
|
-
d(n),
|
|
198
|
-
c,
|
|
199
|
-
l,
|
|
200
|
-
m,
|
|
201
|
-
k,
|
|
202
|
-
j,
|
|
203
|
-
F,
|
|
204
|
-
L
|
|
205
|
-
].filter((e) => e !== s);
|
|
206
|
-
return R.set(i, u), u;
|
|
207
229
|
};
|
|
208
|
-
|
|
230
|
+
var pluginsCache = /* @__PURE__ */ new Map();
|
|
231
|
+
/**
|
|
232
|
+
* Get the plugins array for Solid content transformation.
|
|
233
|
+
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
234
|
+
*/
|
|
235
|
+
var getPlugins = (locale, fallback = true) => {
|
|
236
|
+
const currentLocale = resolveInterpreterLocale(locale);
|
|
237
|
+
const cacheKey = `${currentLocale}_${fallback}`;
|
|
238
|
+
if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
|
|
239
|
+
const enabledPlugins = [
|
|
240
|
+
intlayerNodePlugins,
|
|
241
|
+
translationPlugin(currentLocale, fallback ? internationalization.defaultLocale : void 0),
|
|
242
|
+
enumerationPlugin,
|
|
243
|
+
pluralPlugin(currentLocale),
|
|
244
|
+
conditionPlugin,
|
|
245
|
+
nestedPlugin(currentLocale),
|
|
246
|
+
filePlugin,
|
|
247
|
+
genderPlugin,
|
|
248
|
+
selectPlugin,
|
|
249
|
+
solidNodePlugins,
|
|
250
|
+
insertionPlugin,
|
|
251
|
+
markdownPlugin,
|
|
252
|
+
htmlPlugin
|
|
253
|
+
].filter((plugin) => plugin !== fallbackPlugin);
|
|
254
|
+
pluginsCache.set(cacheKey, enabledPlugins);
|
|
255
|
+
return enabledPlugins;
|
|
256
|
+
};
|
|
257
|
+
export { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, solidNodePlugins };
|
package/dist/esm/proxyKeys.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// src/proxyKeys.ts
|
|
2
|
-
|
|
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 = {
|
|
3
8
|
promiseThen: "then",
|
|
4
9
|
toString: "toString",
|
|
5
10
|
valueOf: "valueOf",
|
|
6
11
|
value: "value"
|
|
7
12
|
};
|
|
8
|
-
export {
|
|
13
|
+
export { PROXY_RESERVED_KEYS };
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import { useDictionary as
|
|
2
|
-
import { createAsyncValue
|
|
1
|
+
import { useDictionary as useDictionary$1 } from "../client/useDictionary.mjs";
|
|
2
|
+
import { createAsyncValue, trackAsyncValue } from "../solidCompat.mjs";
|
|
3
3
|
// src/server/useDictionary.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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,
|
|
7
24
|
ssrLoadFrom: "initial"
|
|
8
25
|
});
|
|
9
|
-
|
|
26
|
+
trackAsyncValue(serverValue);
|
|
27
|
+
return useDictionary$1(dictionary, localeOrSelector);
|
|
10
28
|
};
|
|
11
|
-
export {
|
|
29
|
+
export { useDictionary };
|