angular-intlayer 5.5.8 → 5.5.10
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/README.md +42 -9
- package/dist/cjs/UI/ContentSelector.component.cjs +141 -0
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +13 -27
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/installIntlayer.cjs +72 -0
- package/dist/cjs/client/installIntlayer.cjs.map +1 -0
- package/dist/cjs/client/{getDictionary.cjs → useDictionary.cjs} +15 -19
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs +42 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/client/{getBrowserLocale.cjs → useIntlayer.cjs} +17 -11
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/{intlayer.service.cjs → useLoadDynamic.cjs} +21 -19
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -0
- package/dist/cjs/client/useLocale.cjs +69 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useLocaleCookie.cjs +60 -0
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +73 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -0
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +77 -0
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -0
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +58 -0
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -0
- package/dist/cjs/editor/changedContent.cjs +62 -0
- package/dist/cjs/editor/changedContent.cjs.map +1 -0
- package/dist/cjs/editor/communicator.cjs +82 -0
- package/dist/cjs/editor/communicator.cjs.map +1 -0
- package/dist/cjs/editor/configuration.cjs +57 -0
- package/dist/cjs/editor/configuration.cjs.map +1 -0
- package/dist/cjs/editor/createSharedComposable.cjs +68 -0
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -0
- package/dist/cjs/editor/dictionariesRecord.cjs +83 -0
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -0
- package/dist/cjs/editor/editedContent.cjs +77 -0
- package/dist/cjs/editor/editedContent.cjs.map +1 -0
- package/dist/cjs/editor/editorEnabled.cjs +76 -0
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -0
- package/dist/cjs/editor/editorLocale.cjs +47 -0
- package/dist/cjs/editor/editorLocale.cjs.map +1 -0
- package/dist/cjs/editor/focusDictionary.cjs +80 -0
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -0
- package/dist/cjs/editor/index.cjs +38 -0
- package/dist/cjs/editor/index.cjs.map +1 -0
- package/dist/cjs/editor/installIntlayerEditor.cjs +72 -0
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +83 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameState.cjs +95 -0
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs +72 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs +58 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
- package/dist/cjs/editor/useEditor.cjs +46 -0
- package/dist/cjs/editor/useEditor.cjs.map +1 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +62 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +15 -2
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +9 -2
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +3 -16
- package/dist/cjs/markdown/index.cjs.map +1 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +66 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +27 -18
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +58 -0
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -0
- package/dist/cjs/{client/getLocale.cjs → webpack/index.cjs} +6 -14
- package/dist/cjs/webpack/index.cjs.map +1 -0
- package/dist/cjs/webpack/mergeConfig.cjs +83 -0
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -0
- package/dist/esm/UI/ContentSelector.component.mjs +126 -0
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -0
- package/dist/esm/client/index.mjs +6 -16
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/installIntlayer.mjs +35 -0
- package/dist/esm/client/installIntlayer.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +15 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useDictionaryDynamic.mjs +18 -0
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +15 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useLoadDynamic.mjs +21 -0
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -0
- package/dist/esm/client/useLocale.mjs +35 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.mjs +24 -0
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +49 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -0
- package/dist/esm/editor/EditedContentRenderer.component.mjs +53 -0
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -0
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +34 -0
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -0
- package/dist/esm/editor/changedContent.mjs +36 -0
- package/dist/esm/editor/changedContent.mjs.map +1 -0
- package/dist/esm/editor/communicator.mjs +46 -0
- package/dist/esm/editor/communicator.mjs.map +1 -0
- package/dist/esm/editor/configuration.mjs +23 -0
- package/dist/esm/editor/configuration.mjs.map +1 -0
- package/dist/esm/editor/createSharedComposable.mjs +43 -0
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -0
- package/dist/esm/editor/dictionariesRecord.mjs +47 -0
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -0
- package/dist/esm/editor/editedContent.mjs +51 -0
- package/dist/esm/editor/editedContent.mjs.map +1 -0
- package/dist/esm/editor/editorEnabled.mjs +50 -0
- package/dist/esm/editor/editorEnabled.mjs.map +1 -0
- package/dist/esm/editor/editorLocale.mjs +23 -0
- package/dist/esm/editor/editorLocale.mjs.map +1 -0
- package/dist/esm/editor/focusDictionary.mjs +54 -0
- package/dist/esm/editor/focusDictionary.mjs.map +1 -0
- package/dist/esm/editor/index.mjs +10 -0
- package/dist/esm/editor/index.mjs.map +1 -0
- package/dist/esm/editor/installIntlayerEditor.mjs +38 -0
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +59 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameState.mjs +71 -0
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
- package/dist/esm/editor/useCrossURLPathState.mjs +47 -0
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs +37 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
- package/dist/esm/editor/useEditor.mjs +22 -0
- package/dist/esm/editor/useEditor.mjs.map +1 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs +37 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +19 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +14 -2
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -10
- package/dist/esm/markdown/index.mjs.map +1 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +39 -0
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -0
- package/dist/esm/plugins.mjs +27 -17
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +34 -0
- package/dist/esm/renderIntlayerNode.mjs.map +1 -0
- package/dist/esm/webpack/index.mjs +2 -0
- package/dist/esm/webpack/index.mjs.map +1 -0
- package/dist/esm/webpack/mergeConfig.mjs +49 -0
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -0
- package/dist/types/UI/ContentSelector.component.d.ts +32 -0
- package/dist/types/UI/ContentSelector.component.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +6 -7
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/installIntlayer.d.ts +17 -0
- package/dist/types/client/installIntlayer.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +5 -0
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -0
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +10 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useLoadDynamic.d.ts +8 -0
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +15 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useLocaleCookie.d.ts +17 -0
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +19 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -0
- package/dist/types/editor/EditedContentRenderer.component.d.ts +19 -0
- package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -0
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +13 -0
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -0
- package/dist/types/editor/changedContent.d.ts +14 -0
- package/dist/types/editor/changedContent.d.ts.map +1 -0
- package/dist/types/editor/communicator.d.ts +28 -0
- package/dist/types/editor/communicator.d.ts.map +1 -0
- package/dist/types/editor/configuration.d.ts +2 -0
- package/dist/types/editor/configuration.d.ts.map +1 -0
- package/dist/types/editor/createSharedComposable.d.ts +14 -0
- package/dist/types/editor/createSharedComposable.d.ts.map +1 -0
- package/dist/types/editor/dictionariesRecord.d.ts +16 -0
- package/dist/types/editor/dictionariesRecord.d.ts.map +1 -0
- package/dist/types/editor/editedContent.d.ts +19 -0
- package/dist/types/editor/editedContent.d.ts.map +1 -0
- package/dist/types/editor/editorEnabled.d.ts +16 -0
- package/dist/types/editor/editorEnabled.d.ts.map +1 -0
- package/dist/types/editor/editorLocale.d.ts +3 -0
- package/dist/types/editor/editorLocale.d.ts.map +1 -0
- package/dist/types/editor/focusDictionary.d.ts +24 -0
- package/dist/types/editor/focusDictionary.d.ts.map +1 -0
- package/dist/types/editor/index.d.ts +5 -0
- package/dist/types/editor/index.d.ts.map +1 -0
- package/dist/types/editor/installIntlayerEditor.d.ts +18 -0
- package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +11 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameState.d.ts +24 -0
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -0
- package/dist/types/editor/useCrossURLPathState.d.ts +16 -0
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts +17 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
- package/dist/types/editor/useEditor.d.ts +2 -0
- package/dist/types/editor/useEditor.d.ts.map +1 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts +11 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +4 -1
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +4 -6
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +1 -4
- package/dist/types/markdown/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +26 -0
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +0 -9
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/renderIntlayerNode.d.ts +13 -0
- package/dist/types/renderIntlayerNode.d.ts.map +1 -0
- package/dist/types/webpack/index.d.ts +2 -0
- package/dist/types/webpack/index.d.ts.map +1 -0
- package/dist/types/webpack/mergeConfig.d.ts +3 -0
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
- package/package.json +23 -9
- package/dist/cjs/client/dictionary.service.cjs +0 -70
- package/dist/cjs/client/dictionary.service.cjs.map +0 -1
- package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
- package/dist/cjs/client/getDictionary.cjs.map +0 -1
- package/dist/cjs/client/getLocale.cjs.map +0 -1
- package/dist/cjs/client/intlayer.service.cjs.map +0 -1
- package/dist/cjs/client/locale.service.cjs +0 -66
- package/dist/cjs/client/locale.service.cjs.map +0 -1
- package/dist/cjs/client/t.cjs +0 -32
- package/dist/cjs/client/t.cjs.map +0 -1
- package/dist/esm/client/dictionary.service.mjs +0 -46
- package/dist/esm/client/dictionary.service.mjs.map +0 -1
- package/dist/esm/client/getBrowserLocale.mjs +0 -10
- package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
- package/dist/esm/client/getDictionary.mjs +0 -25
- package/dist/esm/client/getDictionary.mjs.map +0 -1
- package/dist/esm/client/getLocale.mjs +0 -7
- package/dist/esm/client/getLocale.mjs.map +0 -1
- package/dist/esm/client/intlayer.service.mjs +0 -19
- package/dist/esm/client/intlayer.service.mjs.map +0 -1
- package/dist/esm/client/locale.service.mjs +0 -42
- package/dist/esm/client/locale.service.mjs.map +0 -1
- package/dist/esm/client/t.mjs +0 -8
- package/dist/esm/client/t.mjs.map +0 -1
- package/dist/types/client/dictionary.service.d.ts +0 -21
- package/dist/types/client/dictionary.service.d.ts.map +0 -1
- package/dist/types/client/getBrowserLocale.d.ts +0 -6
- package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/client/getDictionary.d.ts +0 -8
- package/dist/types/client/getDictionary.d.ts.map +0 -1
- package/dist/types/client/getLocale.d.ts +0 -7
- package/dist/types/client/getLocale.d.ts.map +0 -1
- package/dist/types/client/intlayer.service.d.ts +0 -8
- package/dist/types/client/intlayer.service.d.ts.map +0 -1
- package/dist/types/client/locale.service.d.ts +0 -12
- package/dist/types/client/locale.service.d.ts.map +0 -1
- package/dist/types/client/t.d.ts +0 -8
- package/dist/types/client/t.d.ts.map +0 -1
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -18,29 +18,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var plugins_exports = {};
|
|
20
20
|
__export(plugins_exports, {
|
|
21
|
-
angularTemplatePlugin: () => angularTemplatePlugin,
|
|
22
21
|
intlayerNodePlugins: () => intlayerNodePlugins,
|
|
23
22
|
markdownPlugin: () => markdownPlugin,
|
|
24
23
|
markdownStringPlugin: () => markdownStringPlugin
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(plugins_exports);
|
|
27
26
|
var import_core = require("@intlayer/core");
|
|
27
|
+
var import_editor = require('./editor/index.cjs');
|
|
28
|
+
var import_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
|
|
29
|
+
var import_renderIntlayerNode = require('./renderIntlayerNode.cjs');
|
|
28
30
|
const intlayerNodePlugins = {
|
|
29
31
|
id: "intlayer-node-plugin",
|
|
30
32
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
31
|
-
transform: (_node, { children, ...rest }) => ({
|
|
33
|
+
transform: (_node, { children, ...rest }) => (0, import_renderIntlayerNode.renderIntlayerNode)({
|
|
32
34
|
...rest,
|
|
33
35
|
value: children,
|
|
34
|
-
children
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
value: "[[angular-template]]",
|
|
43
|
-
children: node
|
|
36
|
+
children: () => ({
|
|
37
|
+
component: import_editor.ContentSelectorWrapperComponent,
|
|
38
|
+
props: {
|
|
39
|
+
dictionaryKey: rest.dictionaryKey,
|
|
40
|
+
keyPath: rest.keyPath
|
|
41
|
+
},
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
44
|
})
|
|
45
45
|
};
|
|
46
46
|
const markdownStringPlugin = {
|
|
@@ -49,14 +49,14 @@ const markdownStringPlugin = {
|
|
|
49
49
|
transform: (node, props, deepTransformNode) => {
|
|
50
50
|
const {
|
|
51
51
|
plugins,
|
|
52
|
-
// Removed to avoid
|
|
52
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
53
53
|
...rest
|
|
54
54
|
} = props;
|
|
55
55
|
const metadata = (0, import_core.getMarkdownMetadata)(node);
|
|
56
56
|
const metadataPlugins = {
|
|
57
57
|
id: "markdown-metadata-plugin",
|
|
58
58
|
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
59
|
-
transform: (metadataNode, props2) => ({
|
|
59
|
+
transform: (metadataNode, props2) => (0, import_renderIntlayerNode.renderIntlayerNode)({
|
|
60
60
|
...props2,
|
|
61
61
|
value: metadataNode,
|
|
62
62
|
children: node
|
|
@@ -67,14 +67,24 @@ const markdownStringPlugin = {
|
|
|
67
67
|
dictionaryKey: rest.dictionaryKey,
|
|
68
68
|
keyPath: []
|
|
69
69
|
});
|
|
70
|
-
return {
|
|
70
|
+
return (0, import_renderIntlayerNode.renderIntlayerNode)({
|
|
71
71
|
...props,
|
|
72
72
|
value: node,
|
|
73
|
-
children:
|
|
73
|
+
children: () => ({
|
|
74
|
+
component: import_editor.ContentSelectorWrapperComponent,
|
|
75
|
+
props: {
|
|
76
|
+
dictionaryKey: rest.dictionaryKey,
|
|
77
|
+
keyPath: rest.keyPath
|
|
78
|
+
},
|
|
79
|
+
children: () => {
|
|
80
|
+
const { renderMarkdown } = (0, import_installIntlayerMarkdown.useMarkdown)();
|
|
81
|
+
return renderMarkdown(node);
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
74
84
|
additionalProps: {
|
|
75
85
|
metadata: metadataNodes
|
|
76
86
|
}
|
|
77
|
-
};
|
|
87
|
+
});
|
|
78
88
|
}
|
|
79
89
|
};
|
|
80
90
|
const markdownPlugin = {
|
|
@@ -98,7 +108,6 @@ const markdownPlugin = {
|
|
|
98
108
|
};
|
|
99
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
100
110
|
0 && (module.exports = {
|
|
101
|
-
angularTemplatePlugin,
|
|
102
111
|
intlayerNodePlugins,
|
|
103
112
|
markdownPlugin,
|
|
104
113
|
markdownStringPlugin
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n getMarkdownMetadata,\n KeyPath,\n MarkdownContent,\n NodeType,\n type DeepTransformContent as DeepTransformContentCore,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n} from '@intlayer/core';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginAngular<T> {\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAQO;AACP,oBAAgD;AAChD,qCAA4B;AAC5B,gCAAmC;AAiB5B,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,KAAK,UACrC,8CAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU,OAAO;AAAA,MACf,WAAW;AAAA,MACX,OAAO;AAAA,QACL,eAAe,KAAK;AAAA,QACpB,SAAS,KAAK;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAWO,MAAM,uBAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAc,OAAO,sBAAsB;AACrD,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,eAAW,iCAAoB,IAAI;AAEzC,UAAM,kBAA2B;AAAA,MAC/B,IAAI;AAAA,MACJ,WAAW,CAAC,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;AAAA,MACH,WAAW,CAAC,cAAcA,eACxB,8CAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UAAU;AAAA,MACZ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,eAAO,8CAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UAAU,OAAO;AAAA,QACf,WAAW;AAAA,QACX,OAAO;AAAA,UACL,eAAe,KAAK;AAAA,UACpB,SAAS,KAAK;AAAA,QAChB;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,EAAE,eAAe,QAAI,4CAAY;AACvC,iBAAO,eAAe,IAAI;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,qBAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,qBAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["props"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var renderIntlayerNode_exports = {};
|
|
20
|
+
__export(renderIntlayerNode_exports, {
|
|
21
|
+
renderIntlayerNode: () => renderIntlayerNode
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(renderIntlayerNode_exports);
|
|
24
|
+
const renderIntlayerNode = ({
|
|
25
|
+
children,
|
|
26
|
+
value,
|
|
27
|
+
additionalProps = {}
|
|
28
|
+
}) => {
|
|
29
|
+
if (children == null) {
|
|
30
|
+
return new Proxy({}, {
|
|
31
|
+
get(target, prop, receiver) {
|
|
32
|
+
if (prop === "value") {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (additionalProps && Object.keys(additionalProps).includes(prop)) {
|
|
36
|
+
return additionalProps[prop];
|
|
37
|
+
}
|
|
38
|
+
return Reflect.get(target, prop, receiver);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return new Proxy(children, {
|
|
43
|
+
get(target, prop, receiver) {
|
|
44
|
+
if (prop === "value") {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (additionalProps && Object.keys(additionalProps).includes(prop)) {
|
|
48
|
+
return additionalProps[prop];
|
|
49
|
+
}
|
|
50
|
+
return Reflect.get(target, prop, receiver);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
renderIntlayerNode
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=renderIntlayerNode.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,qBAAqB,CAEhC;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB,CAAC;AACrB,MAAmD;AAEjD,MAAI,YAAY,MAAM;AACpB,WAAO,IAAI,MAAM,CAAC,GAAU;AAAA,MAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,YAAI,SAAS,SAAS;AACpB,iBAAO;AAAA,QACT;AAEA,YACE,mBACA,OAAO,KAAK,eAAe,EAAE,SAAS,IAAc,GACpD;AACA,iBAAO,gBAAgB,IAAoC;AAAA,QAC7D;AAEA,eAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,MAC3C;AAAA,IACF,CAAC;AAAA,EACH;AAIA,SAAO,IAAI,MAAM,UAAU;AAAA,IACzB,IAAI,QAAQ,MAAM,UAAU;AAC1B,UAAI,SAAS,SAAS;AACpB,eAAO;AAAA,MACT;AAEA,UACE,mBACA,OAAO,KAAK,eAAe,EAAE,SAAS,IAAc,GACpD;AACA,eAAO,gBAAgB,IAAoC;AAAA,MAC7D;AAEA,aAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,IAC3C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,17 +11,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(getLocale_exports);
|
|
24
|
-
const getLocale = () => {
|
|
25
|
-
return "en";
|
|
26
|
-
};
|
|
16
|
+
var webpack_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(webpack_exports);
|
|
18
|
+
__reExport(webpack_exports, require('./mergeConfig.cjs'), module.exports);
|
|
27
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
20
|
0 && (module.exports = {
|
|
29
|
-
|
|
21
|
+
...require('./mergeConfig.cjs')
|
|
30
22
|
});
|
|
31
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/webpack/index.ts"],"sourcesContent":["export * from './mergeConfig';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,0BAAd;","names":[]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var mergeConfig_exports = {};
|
|
30
|
+
__export(mergeConfig_exports, {
|
|
31
|
+
mergeConfig: () => mergeConfig
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(mergeConfig_exports);
|
|
34
|
+
var import_config = require("@intlayer/config");
|
|
35
|
+
var import_webpack = require("@intlayer/webpack");
|
|
36
|
+
var import_deepmerge = __toESM(require("deepmerge"));
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
const mergeConfig = (baseConfig) => {
|
|
39
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
40
|
+
const { mainDir, configDir, baseDir } = intlayerConfig.content;
|
|
41
|
+
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
42
|
+
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
43
|
+
const unmergedDictionariesPath = (0, import_path.join)(mainDir, "unmerged_dictionaries.mjs");
|
|
44
|
+
const relativeUnmergedDictionariesPath = (0, import_path.relative)(
|
|
45
|
+
baseDir,
|
|
46
|
+
unmergedDictionariesPath
|
|
47
|
+
);
|
|
48
|
+
const configurationPath = (0, import_path.join)(configDir, "configuration.json");
|
|
49
|
+
const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
|
|
50
|
+
const config = {
|
|
51
|
+
resolve: {
|
|
52
|
+
alias: {
|
|
53
|
+
"@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath),
|
|
54
|
+
"@intlayer/unmerged-dictionaries-entry": (0, import_path.resolve)(
|
|
55
|
+
relativeUnmergedDictionariesPath
|
|
56
|
+
),
|
|
57
|
+
"@intlayer/config/built": (0, import_path.resolve)(relativeConfigurationPath)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
externals: {
|
|
61
|
+
esbuild: "esbuild",
|
|
62
|
+
module: "module",
|
|
63
|
+
fs: "fs",
|
|
64
|
+
chokidar: "chokidar",
|
|
65
|
+
fsevents: "fsevents"
|
|
66
|
+
},
|
|
67
|
+
module: {
|
|
68
|
+
rules: [
|
|
69
|
+
{
|
|
70
|
+
test: /\.node$/,
|
|
71
|
+
loader: "node-loader"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
plugins: [new import_webpack.IntlayerPlugin()]
|
|
76
|
+
};
|
|
77
|
+
return (0, import_deepmerge.default)(baseConfig, config);
|
|
78
|
+
};
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
mergeConfig
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=mergeConfig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport merge from 'deepmerge';\nimport { join, relative, resolve } from 'path';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n const config = {\n resolve: {\n alias: {\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n },\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n ],\n },\n plugins: [new IntlayerPlugin()],\n };\n\n return merge(baseConfig, config);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,qBAA+B;AAC/B,uBAAkB;AAClB,kBAAwC;AAGjC,MAAM,cAAc,CAAC,eAA6C;AACvE,QAAM,qBAAiB,gCAAiB;AAGxC,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,eAAe;AAEvD,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,QAAM,+BAA2B,kBAAK,SAAS,2BAA2B;AAC1E,QAAM,uCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,QAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAErE,QAAM,SAAS;AAAA,IACb,SAAS;AAAA,MACP,OAAO;AAAA,QACL,oCAAgC,qBAAQ,wBAAwB;AAAA,QAChE,6CAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,8BAA0B,qBAAQ,yBAAyB;AAAA,MAC7D;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS,CAAC,IAAI,8BAAe,CAAC;AAAA,EAChC;AAEA,aAAO,iBAAAA,SAAM,YAAY,MAAM;AACjC;","names":["merge"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
HostListener,
|
|
7
|
+
Input,
|
|
8
|
+
Output,
|
|
9
|
+
signal,
|
|
10
|
+
ViewChild
|
|
11
|
+
} from "@angular/core";
|
|
12
|
+
const DEFAULT_PRESS_DETECT_DURATION = 250;
|
|
13
|
+
@Component({
|
|
14
|
+
selector: "app-content-selector",
|
|
15
|
+
template: `
|
|
16
|
+
<span
|
|
17
|
+
#containerRef
|
|
18
|
+
role="button"
|
|
19
|
+
tabindex="0"
|
|
20
|
+
(click)="handleClick($event)"
|
|
21
|
+
(mousedown)="handleMouseDown()"
|
|
22
|
+
(mouseup)="handleMouseUp()"
|
|
23
|
+
(mouseleave)="handleMouseUp()"
|
|
24
|
+
(touchstart)="handleMouseDown()"
|
|
25
|
+
(touchend)="handleMouseUp()"
|
|
26
|
+
(touchcancel)="handleMouseUp()"
|
|
27
|
+
(blur)="handleBlur()"
|
|
28
|
+
(mouseenter)="onMouseEnter()"
|
|
29
|
+
[ngStyle]="getContainerStyle()"
|
|
30
|
+
>
|
|
31
|
+
<ng-content></ng-content>
|
|
32
|
+
</span>
|
|
33
|
+
`,
|
|
34
|
+
standalone: true,
|
|
35
|
+
imports: [CommonModule]
|
|
36
|
+
})
|
|
37
|
+
class ContentSelectorComponent {
|
|
38
|
+
constructor(cdr) {
|
|
39
|
+
this.cdr = cdr;
|
|
40
|
+
}
|
|
41
|
+
@Input() onClickOutside;
|
|
42
|
+
@Input() pressDuration;
|
|
43
|
+
@Input() isSelecting;
|
|
44
|
+
@Output() click = new EventEmitter();
|
|
45
|
+
@Output() press = new EventEmitter();
|
|
46
|
+
@ViewChild("containerRef", { static: true })
|
|
47
|
+
containerRef;
|
|
48
|
+
isHovered = signal(false);
|
|
49
|
+
isSelectingState = signal(false);
|
|
50
|
+
pressTimerRef = null;
|
|
51
|
+
isSelectingComputed = computed(
|
|
52
|
+
() => this.isSelecting ?? this.isSelectingState()
|
|
53
|
+
);
|
|
54
|
+
isStringSlot = computed(() => {
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
ngOnInit() {
|
|
58
|
+
this.isSelectingState.set(this.isSelecting ?? false);
|
|
59
|
+
}
|
|
60
|
+
ngOnDestroy() {
|
|
61
|
+
this.clearPressTimer();
|
|
62
|
+
}
|
|
63
|
+
@HostListener("document:mousedown", ["$event"])
|
|
64
|
+
onDocumentMouseDown(event) {
|
|
65
|
+
this.handleClickOutside(event);
|
|
66
|
+
}
|
|
67
|
+
handleOnLongPress() {
|
|
68
|
+
this.isSelectingState.set(true);
|
|
69
|
+
this.press.emit();
|
|
70
|
+
}
|
|
71
|
+
startPressTimer() {
|
|
72
|
+
this.pressTimerRef = setTimeout(() => {
|
|
73
|
+
this.handleOnLongPress();
|
|
74
|
+
}, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);
|
|
75
|
+
}
|
|
76
|
+
clearPressTimer() {
|
|
77
|
+
if (this.pressTimerRef) {
|
|
78
|
+
clearTimeout(this.pressTimerRef);
|
|
79
|
+
this.pressTimerRef = null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
handleMouseDown() {
|
|
83
|
+
this.clearPressTimer();
|
|
84
|
+
this.startPressTimer();
|
|
85
|
+
}
|
|
86
|
+
handleMouseUp() {
|
|
87
|
+
this.isHovered.set(false);
|
|
88
|
+
this.clearPressTimer();
|
|
89
|
+
}
|
|
90
|
+
handleClickOutside(event) {
|
|
91
|
+
if (this.containerRef?.nativeElement && !this.containerRef.nativeElement.contains(event.target)) {
|
|
92
|
+
this.isSelectingState.set(false);
|
|
93
|
+
this.onClickOutside?.();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
handleClick(e) {
|
|
97
|
+
if (this.isSelectingComputed()) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
}
|
|
101
|
+
this.click.emit(e);
|
|
102
|
+
}
|
|
103
|
+
handleBlur() {
|
|
104
|
+
this.isSelectingState.set(false);
|
|
105
|
+
}
|
|
106
|
+
onMouseEnter() {
|
|
107
|
+
this.isHovered.set(true);
|
|
108
|
+
}
|
|
109
|
+
getContainerStyle() {
|
|
110
|
+
return {
|
|
111
|
+
display: this.isStringSlot() ? "inline" : "inline-block",
|
|
112
|
+
cursor: "pointer",
|
|
113
|
+
userSelect: "none",
|
|
114
|
+
borderRadius: "0.375rem",
|
|
115
|
+
outlineWidth: "2px",
|
|
116
|
+
outlineOffset: "4px",
|
|
117
|
+
outlineStyle: "solid",
|
|
118
|
+
outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
|
|
119
|
+
transition: "all 100ms 50ms ease-in-out"
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
ContentSelectorComponent
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=ContentSelector.component.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n ChangeDetectorRef,\n Component,\n computed,\n ElementRef,\n EventEmitter,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n constructor(private cdr: ChangeDetectorRef) {}\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,gCAAgC;AAEtC,CAAC,UAAU;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBV,YAAY;AAAA,EACZ,SAAS,CAAC,YAAY;AACxB,CAAC;AACM,MAAM,yBAAsD;AAAA,EAyBjE,YAAoB,KAAwB;AAAxB;AAAA,EAAyB;AAxB7C,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AAET,GAAC,OAAO,EAAE,QAAQ,IAAI,aAAyB;AAC/C,GAAC,OAAO,EAAE,QAAQ,IAAI,aAAmB;AAEzC,GAAC,UAAU,gBAAgB,EAAE,QAAQ,KAAK,CAAC;AAAA,EAC3C;AAAA,EAEQ,YAAY,OAAO,KAAK;AAAA,EACxB,mBAAmB,OAAO,KAAK;AAAA,EAC/B,gBAAsD;AAAA,EAE7C,sBAAsB;AAAA,IACrC,MAAM,KAAK,eAAe,KAAK,iBAAiB;AAAA,EAClD;AAAA,EAEiB,eAAe,SAAS,MAAM;AAG7C,WAAO;AAAA,EACT,CAAC;AAAA,EAID,WAAiB;AACf,SAAK,iBAAiB,IAAI,KAAK,eAAe,KAAK;AAAA,EACrD;AAAA,EAEA,cAAoB;AAClB,SAAK,gBAAgB;AAAA,EACvB;AAEA,GAAC,aAAa,sBAAsB,CAAC,QAAQ,CAAC;AAAA,EAC9C,oBAAoB,OAAyB;AAC3C,SAAK,mBAAmB,KAAK;AAAA,EAC/B;AAAA,EAEQ,oBAA0B;AAChC,SAAK,iBAAiB,IAAI,IAAI;AAC9B,SAAK,MAAM,KAAK;AAAA,EAClB;AAAA,EAEQ,kBAAwB;AAC9B,SAAK,gBAAgB,WAAW,MAAM;AACpC,WAAK,kBAAkB;AAAA,IACzB,GAAG,KAAK,iBAAiB,6BAA6B;AAAA,EACxD;AAAA,EAEQ,kBAAwB;AAC9B,QAAI,KAAK,eAAe;AACtB,mBAAa,KAAK,aAAa;AAC/B,WAAK,gBAAgB;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,kBAAwB;AACtB,SAAK,gBAAgB;AACrB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,gBAAsB;AACpB,SAAK,UAAU,IAAI,KAAK;AACxB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEQ,mBAAmB,OAAyB;AAClD,QACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,MAAc,GAC9D;AACA,WAAK,iBAAiB,IAAI,KAAK;AAC/B,WAAK,iBAAiB;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,YAAY,GAAqB;AAC/B,QAAI,KAAK,oBAAoB,GAAG;AAC9B,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AACA,SAAK,MAAM,KAAK,CAAC;AAAA,EACnB;AAAA,EAEA,aAAmB;AACjB,SAAK,iBAAiB,IAAI,KAAK;AAAA,EACjC;AAAA,EAEA,eAAqB;AACnB,SAAK,UAAU,IAAI,IAAI;AAAA,EACzB;AAAA,EAEA,oBAA4C;AAC1C,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,IAAI,WAAW;AAAA,MAC1C,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cACE,KAAK,oBAAoB,KAAK,KAAK,UAAU,IACzC,YACA;AAAA,MACN,YAAY;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { t } from "./t.mjs";
|
|
8
|
-
export {
|
|
9
|
-
DictionaryService,
|
|
10
|
-
IntlayerService,
|
|
11
|
-
LocaleService,
|
|
12
|
-
getBrowserLocale,
|
|
13
|
-
getDictionary,
|
|
14
|
-
getLocale,
|
|
15
|
-
t
|
|
16
|
-
};
|
|
1
|
+
export * from "./installIntlayer.mjs";
|
|
2
|
+
export * from "./useDictionary.mjs";
|
|
3
|
+
export * from "./useDictionaryDynamic.mjs";
|
|
4
|
+
export * from "./useIntlayer.mjs";
|
|
5
|
+
export * from "./useLoadDynamic.mjs";
|
|
6
|
+
export * from "./useLocale.mjs";
|
|
17
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export * from './installIntlayer';\nexport * from './useDictionary';\nexport * from './useDictionaryDynamic';\nexport * from './useIntlayer';\nexport * from './useLoadDynamic';\nexport * from './useLocale';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Injectable, InjectionToken, signal } from "@angular/core";
|
|
2
|
+
import configuration from "@intlayer/config/built";
|
|
3
|
+
const INTLAYER_TOKEN = new InjectionToken("intlayer");
|
|
4
|
+
let instance = null;
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: "root"
|
|
7
|
+
})
|
|
8
|
+
class IntlayerProvider {
|
|
9
|
+
_locale = signal(
|
|
10
|
+
configuration.internationalization?.defaultLocale
|
|
11
|
+
);
|
|
12
|
+
locale = this._locale.asReadonly();
|
|
13
|
+
setLocale = (locale) => {
|
|
14
|
+
this._locale.set(locale);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const createIntlayerClient = (locale) => {
|
|
18
|
+
if (instance) return instance;
|
|
19
|
+
instance = new IntlayerProvider();
|
|
20
|
+
if (locale) {
|
|
21
|
+
instance.setLocale(locale);
|
|
22
|
+
}
|
|
23
|
+
return instance;
|
|
24
|
+
};
|
|
25
|
+
const installIntlayer = (locale) => {
|
|
26
|
+
const client = createIntlayerClient(locale);
|
|
27
|
+
return client;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
INTLAYER_TOKEN,
|
|
31
|
+
IntlayerProvider,
|
|
32
|
+
createIntlayerClient,
|
|
33
|
+
installIntlayer
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=installIntlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, signal, Signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n private _locale = signal<Locales>(\n configuration.internationalization?.defaultLocale as Locales\n );\n\n readonly locale: Signal<Locales> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale as Locales);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider\n */\nexport const installIntlayer = (locale?: LocalesValues) => {\n const client = createIntlayerClient(locale);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"AAAA,SAAS,YAAY,gBAAgB,cAAsB;AAC3D,OAAO,mBAAmB;AAGnB,MAAM,iBAAiB,IAAI,eAAiC,UAAU;AAK7E,IAAI,WAAoC;AAExC,CAAC,WAAW;AAAA,EACV,YAAY;AACd,CAAC;AACM,MAAM,iBAAiB;AAAA,EACpB,UAAU;AAAA,IAChB,cAAc,sBAAsB;AAAA,EACtC;AAAA,EAES,SAA0B,KAAK,QAAQ,WAAW;AAAA,EAE3D,YAAY,CAAC,WAA0B;AACrC,SAAK,QAAQ,IAAI,MAAiB;AAAA,EACpC;AACF;AAKO,MAAM,uBAAuB,CAClC,WACqB;AACrB,MAAI,SAAU,QAAO;AAErB,aAAW,IAAI,iBAAiB;AAEhC,MAAI,QAAQ;AACV,aAAS,UAAU,MAAM;AAAA,EAC3B;AAEA,SAAO;AACT;AAKO,MAAM,kBAAkB,CAAC,WAA2B;AACzD,QAAM,SAAS,qBAAqB,MAAM;AAK1C,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { computed, inject } from "@angular/core";
|
|
2
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
3
|
+
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
4
|
+
const useDictionary = (dictionary, locale) => {
|
|
5
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
6
|
+
const localeTarget = computed(() => locale ?? intlayer?.locale());
|
|
7
|
+
const content = computed(
|
|
8
|
+
() => getDictionary(dictionary, localeTarget())
|
|
9
|
+
);
|
|
10
|
+
return content();
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useDictionary
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { getDictionary } from '../getDictionary';\nimport { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): DeepTransformContent<T['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity\n};\n"],"mappings":"AAAA,SAAS,UAAU,cAAc;AAGjC,SAAS,qBAAqB;AAE9B,SAAS,sBAAwC;AAE1C,MAAM,gBAAgB,CAC3B,YACA,WACuC;AACvC,QAAM,WAAW,OAAyB,cAAc;AAExD,QAAM,eAAe,SAAS,MAAM,UAAU,UAAU,OAAO,CAAC;AAGhE,QAAM,UAAU;AAAA,IAAS,MACvB,cAAgC,YAAY,aAAa,CAAC;AAAA,EAC5D;AAEA,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
4
|
+
import { useDictionary } from "./useDictionary.mjs";
|
|
5
|
+
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
6
|
+
const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
const localeTarget = computed(() => locale ?? intlayer?.locale());
|
|
9
|
+
const dictionary = useLoadDynamic(
|
|
10
|
+
`${String(key)}.${localeTarget()}`,
|
|
11
|
+
dictionaryPromise[localeTarget()]()
|
|
12
|
+
);
|
|
13
|
+
return useDictionary(dictionary, localeTarget());
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useDictionaryDynamic
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useDictionaryDynamic.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]!()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";AAEA,SAAS,UAAU,cAAc;AAOjC,SAAS,sBAAwC;AACjD,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAOxB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACG;AACH,QAAM,WAAW,OAAyB,cAAc;AAExD,QAAM,eAAe,SAAS,MAAM,UAAU,UAAU,OAAO,CAAC;AAEhE,QAAM,aAAa;AAAA,IACjB,GAAG,OAAO,GAAG,CAAC,IAAI,aAAa,CAAC;AAAA,IAChC,kBAAkB,aAAa,CAAC,EAAG;AAAA,EACrC;AAEA,SAAO,cAAc,YAAY,aAAa,CAAQ;AACxD;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { computed, inject } from "@angular/core";
|
|
2
|
+
import { getIntlayer } from "../getIntlayer.mjs";
|
|
3
|
+
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
4
|
+
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
5
|
+
const useIntlayer = (key, locale) => {
|
|
6
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
7
|
+
const localeTarget = computed(() => locale ?? intlayer.locale());
|
|
8
|
+
const content = computed(() => getIntlayer(key, localeTarget()));
|
|
9
|
+
return content();
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
isUpdatableNode,
|
|
13
|
+
useIntlayer
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useIntlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\n\n/** guard utility — true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => getIntlayer(key, localeTarget()));\n\n return content() as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >; // all consumers keep full reactivity\n};\n"],"mappings":"AAAA,SAAS,UAAU,cAAc;AAKjC,SAAS,mBAAmB;AAE5B,SAAS,sBAAwC;AAG1C,MAAM,kBAAkB,CAC7B,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAE5B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,WAAW,OAAyB,cAAc;AAGxD,QAAM,eAAe,SAAS,MAAM,UAAU,SAAS,OAAO,CAAC;AAG/D,QAAM,UAAU,SAAS,MAAM,YAAY,KAAK,aAAa,CAAC,CAAC;AAE/D,SAAO,QAAQ;AAGjB;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { signal } from "@angular/core";
|
|
2
|
+
const useLoadDynamic = (key, promise) => {
|
|
3
|
+
const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
|
|
4
|
+
const container = signal({});
|
|
5
|
+
if (!cache.has(key)) {
|
|
6
|
+
const p = promise.then((real) => {
|
|
7
|
+
container.set(real);
|
|
8
|
+
return real;
|
|
9
|
+
});
|
|
10
|
+
cache.set(key, p);
|
|
11
|
+
} else {
|
|
12
|
+
cache.get(key).then((real) => {
|
|
13
|
+
container.set(real);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return container();
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useLoadDynamic
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useLoadDynamic.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)!.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"AAAA,SAAS,cAAc;AAQhB,MAAM,iBAAiB,CAC5B,KACA,YACM;AAEN,QAAM,QAAkC,eAAuB,WAC7D,eAAuB,SAAS,oBAAI,IAAI;AAI1C,QAAM,YAAY,OAAO,CAAC,CAAM;AAEhC,MAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AAEnB,UAAM,IAAI,QAAQ,KAAK,CAAC,SAAS;AAE/B,gBAAU,IAAI,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,KAAK,CAAC;AAAA,EAClB,OAAO;AAEL,UAAM,IAAI,GAAG,EAAG,KAAK,CAAC,SAAS;AAC7B,gBAAU,IAAI,IAAI;AAAA,IACpB,CAAC;AAAA,EACH;AAGA,SAAO,UAAU;AACnB;","names":[]}
|