angular-intlayer 9.5.2 → 9.5.3
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 +1 -1
- package/dist/cjs/client/intlayerToken.cjs +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/esbuild/hiddenDirectory.cjs +20 -0
- package/dist/cjs/esbuild/hiddenDirectory.cjs.map +1 -0
- package/dist/cjs/esbuild/plugin.cjs +66 -2
- package/dist/cjs/esbuild/plugin.cjs.map +1 -1
- package/dist/cjs/esbuild/resolvePackageExport.cjs +118 -0
- package/dist/cjs/esbuild/resolvePackageExport.cjs.map +1 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
- package/dist/cjs/plugins.cjs +34 -38
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/webpack/mergeConfig.cjs +1 -1
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/client/intlayerToken.mjs +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
- package/dist/esm/client/useLocale.mjs +1 -1
- package/dist/esm/esbuild/hiddenDirectory.mjs +19 -0
- package/dist/esm/esbuild/hiddenDirectory.mjs.map +1 -0
- package/dist/esm/esbuild/plugin.mjs +67 -4
- package/dist/esm/esbuild/plugin.mjs.map +1 -1
- package/dist/esm/esbuild/resolvePackageExport.mjs +115 -0
- package/dist/esm/esbuild/resolvePackageExport.mjs.map +1 -0
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
- package/dist/esm/plugins.mjs +34 -38
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/webpack/mergeConfig.mjs +1 -2
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +4 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/esbuild/hiddenDirectory.d.ts +15 -0
- package/dist/types/esbuild/hiddenDirectory.d.ts.map +1 -0
- package/dist/types/esbuild/index.d.ts +2 -2
- package/dist/types/esbuild/plugin.d.ts +34 -18
- package/dist/types/esbuild/plugin.d.ts.map +1 -1
- package/dist/types/esbuild/resolvePackageExport.d.ts +37 -0
- package/dist/types/esbuild/resolvePackageExport.d.ts.map +1 -0
- package/dist/types/format/useCompact.d.ts +1 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +1 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +1 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +1 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +1 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +1 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +1 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +1 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
- package/dist/types/intlayer/dist/types/index.d.ts +0 -14
package/dist/esm/plugins.mjs
CHANGED
|
@@ -2,15 +2,25 @@ import { renderIntlayerNode } from "./renderIntlayerNode.mjs";
|
|
|
2
2
|
import { reportExposure } from "./analytics/exposureSink.mjs";
|
|
3
3
|
import { ContentSelectorWrapperComponent } from "./editor/ContentSelector.component.mjs";
|
|
4
4
|
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, selectPlugin, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
|
|
5
|
+
import { signal, untracked } from "@angular/core";
|
|
5
6
|
import { editor, internationalization } from "@intlayer/config/built";
|
|
6
7
|
import { compile, getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
7
8
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
8
9
|
|
|
9
10
|
//#region src/plugins.ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Code-split markdown renderer, held in a signal.
|
|
13
|
+
*
|
|
14
|
+
* The chunk loads asynchronously, so the first dictionary evaluation may run
|
|
15
|
+
* before it lands. `getPlugins` reads this signal inside the `computed` of
|
|
16
|
+
* `useIntlayer`/`useDictionary`, which makes that computed depend on it: nodes
|
|
17
|
+
* stringify to their raw source until the module resolves, then the signal
|
|
18
|
+
* flip re-evaluates the dictionary and every binding re-renders with compiled
|
|
19
|
+
* HTML. This is the Angular counterpart of the `Suspense` boundary the React
|
|
20
|
+
* and Solid packages wrap their markdown renderer in.
|
|
21
|
+
*/
|
|
22
|
+
const markdownRendererModule = signal(null);
|
|
23
|
+
if (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" || process.env.INTLAYER_NODE_TYPE_HTML !== "false") import("./markdown/installIntlayerMarkdown.mjs").then((module) => markdownRendererModule.set(module)).catch(() => {});
|
|
14
24
|
/** ---------------------------------------------
|
|
15
25
|
* UTILS
|
|
16
26
|
* --------------------------------------------- */
|
|
@@ -34,6 +44,18 @@ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
|
|
|
34
44
|
return baseRuntime.createElement(tag, props, ...children);
|
|
35
45
|
}
|
|
36
46
|
});
|
|
47
|
+
/**
|
|
48
|
+
* Compiles a markdown/HTML source to an HTML string with the code-split
|
|
49
|
+
* runtime, or returns the raw source while the renderer chunk is still
|
|
50
|
+
* loading. Runs at stringify time, so a node kept outside any reactive
|
|
51
|
+
* context still picks the renderer up once it has landed.
|
|
52
|
+
*/
|
|
53
|
+
const compileToHtml = (source, components) => {
|
|
54
|
+
const rendererModule = untracked(markdownRendererModule);
|
|
55
|
+
if (!rendererModule) return source;
|
|
56
|
+
const runtime = components ? createRuntimeWithOverides(rendererModule.htmlRuntime, components) : rendererModule.htmlRuntime;
|
|
57
|
+
return compile(source, { runtime });
|
|
58
|
+
};
|
|
37
59
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
38
60
|
const intlayerNodePlugins = {
|
|
39
61
|
id: "intlayer-node-plugin",
|
|
@@ -78,41 +100,25 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
78
100
|
dictionaryKey: rest.dictionaryKey,
|
|
79
101
|
keyPath: []
|
|
80
102
|
});
|
|
103
|
+
const renderMarkdown = (components) => untracked(markdownRendererModule)?.useMarkdown().renderMarkdown(node, components) ?? node;
|
|
81
104
|
const render = (components) => renderIntlayerNode({
|
|
82
105
|
...rest,
|
|
83
106
|
value: node,
|
|
84
|
-
children: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? () => {
|
|
85
|
-
const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? { renderMarkdown: () => node };
|
|
86
|
-
return renderMarkdown(node, components);
|
|
87
|
-
} : () => ({
|
|
107
|
+
children: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? () => renderMarkdown(components) : () => ({
|
|
88
108
|
component: ContentSelectorWrapperComponent,
|
|
89
109
|
props: {
|
|
90
110
|
dictionaryKey: rest.dictionaryKey,
|
|
91
111
|
keyPath: rest.keyPath,
|
|
92
112
|
...components
|
|
93
113
|
},
|
|
94
|
-
children: () =>
|
|
95
|
-
const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? { renderMarkdown: () => node };
|
|
96
|
-
return renderMarkdown(node, components);
|
|
97
|
-
}
|
|
114
|
+
children: () => renderMarkdown(components)
|
|
98
115
|
}),
|
|
99
116
|
additionalProps: { metadata: metadataNodes }
|
|
100
117
|
});
|
|
101
118
|
const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
|
|
102
119
|
if (prop === "value") return node;
|
|
103
120
|
if (prop === "metadata") return metadataNodes;
|
|
104
|
-
if (prop === "toString") return () =>
|
|
105
|
-
const htmlRuntime = _markdownInstall?.htmlRuntime;
|
|
106
|
-
if (!htmlRuntime || !compile) return node;
|
|
107
|
-
const runtime = components ? createRuntimeWithOverides(htmlRuntime, components) : htmlRuntime;
|
|
108
|
-
return compile(node, { runtime });
|
|
109
|
-
};
|
|
110
|
-
if (prop === Symbol.toPrimitive) return () => {
|
|
111
|
-
const htmlRuntime = _markdownInstall?.htmlRuntime;
|
|
112
|
-
if (!htmlRuntime || !compile) return node;
|
|
113
|
-
const runtime = components ? createRuntimeWithOverides(htmlRuntime, components) : htmlRuntime;
|
|
114
|
-
return compile(node, { runtime });
|
|
115
|
-
};
|
|
121
|
+
if (prop === "toString" || prop === Symbol.toPrimitive) return () => compileToHtml(node, components);
|
|
116
122
|
if (prop === "use") return (newComponents) => {
|
|
117
123
|
const mergedComponents = {
|
|
118
124
|
...components,
|
|
@@ -161,19 +167,9 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
|
|
|
161
167
|
});
|
|
162
168
|
const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
|
|
163
169
|
if (prop === "value") return html;
|
|
164
|
-
if (prop === "toString") return () => {
|
|
165
|
-
if (!components ||
|
|
166
|
-
|
|
167
|
-
if (!htmlRuntime || !compile) return String(html);
|
|
168
|
-
const runtime = createRuntimeWithOverides(htmlRuntime, components);
|
|
169
|
-
return compile(html, { runtime });
|
|
170
|
-
};
|
|
171
|
-
if (prop === Symbol.toPrimitive) return () => {
|
|
172
|
-
if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
|
|
173
|
-
const htmlRuntime = _markdownInstall?.htmlRuntime;
|
|
174
|
-
if (!htmlRuntime || !compile) return String(html);
|
|
175
|
-
const runtime = createRuntimeWithOverides(htmlRuntime, components);
|
|
176
|
-
return compile(html, { runtime });
|
|
170
|
+
if (prop === "toString" || prop === Symbol.toPrimitive) return () => {
|
|
171
|
+
if (!components || Object.keys(components).length === 0) return String(html);
|
|
172
|
+
return compileToHtml(String(html), components);
|
|
177
173
|
};
|
|
178
174
|
if (prop === "use") return (userComponents) => {
|
|
179
175
|
const mergedComponents = {
|
|
@@ -214,7 +210,7 @@ const pluginsCache = /* @__PURE__ */ new Map();
|
|
|
214
210
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
215
211
|
*/
|
|
216
212
|
const getPlugins = (locale, fallback = true) => {
|
|
217
|
-
const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;
|
|
213
|
+
const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}_${markdownRendererModule() !== null}`;
|
|
218
214
|
if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
|
|
219
215
|
const plugins = [
|
|
220
216
|
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\nlet _markdownInstall: {\n htmlRuntime: any;\n useMarkdown: () => { renderMarkdown: (s: string, components?: any) => any };\n} | null = null;\nif (\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' ||\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n) {\n void import('./markdown/installIntlayerMarkdown')\n .then((m) => {\n _markdownInstall = m as any;\n })\n .catch(() => {});\n}\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\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 // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'text',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' || !editor.enabled\n ? children\n : ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\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 process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\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 const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n }\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...newComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? html\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...userComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const { plugins, ...rest } = props;\n const content = node[NodeTypes.INSERTION];\n\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run the\n // transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(content)) {\n return (args: Record<string, string | number> = {}) =>\n transformInterpolableNode(\n content,\n args,\n props,\n props.plugins,\n deepTransformNode\n );\n }\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = content as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n };\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<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 = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;AA+BA,IAAI,mBAGO;A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AAO;GACX,IAAI,MACF,OAAO,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;IAC7C,OAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,GAAG,GACpC,OAAO,KAAK,CACd;GACF,CAAC;GAEH,OAAO;EACT;EAEA,OAAO,mBAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;EACZ,CAAC;CACH;AACF;AA6BN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAGlC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import { signal, untracked } from '@angular/core';\nimport { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\ntype MarkdownRendererModule = Pick<\n typeof import('./markdown/installIntlayerMarkdown'),\n 'htmlRuntime' | 'useMarkdown'\n>;\n\n/**\n * Code-split markdown renderer, held in a signal.\n *\n * The chunk loads asynchronously, so the first dictionary evaluation may run\n * before it lands. `getPlugins` reads this signal inside the `computed` of\n * `useIntlayer`/`useDictionary`, which makes that computed depend on it: nodes\n * stringify to their raw source until the module resolves, then the signal\n * flip re-evaluates the dictionary and every binding re-renders with compiled\n * HTML. This is the Angular counterpart of the `Suspense` boundary the React\n * and Solid packages wrap their markdown renderer in.\n */\nconst markdownRendererModule = signal<MarkdownRendererModule | null>(null);\n\nif (\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' ||\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n) {\n void import('./markdown/installIntlayerMarkdown')\n .then((module) => markdownRendererModule.set(module))\n .catch(() => {});\n}\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/**\n * Compiles a markdown/HTML source to an HTML string with the code-split\n * runtime, or returns the raw source while the renderer chunk is still\n * loading. Runs at stringify time, so a node kept outside any reactive\n * context still picks the renderer up once it has landed.\n */\nconst compileToHtml = (\n source: string,\n components?: Record<string, unknown>\n): string => {\n const rendererModule = untracked(markdownRendererModule);\n\n if (!rendererModule) return source;\n\n const runtime = components\n ? createRuntimeWithOverides(rendererModule.htmlRuntime, components)\n : rendererModule.htmlRuntime;\n\n return compile(source, { runtime }) as string;\n};\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 // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'text',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' || !editor.enabled\n ? children\n : ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\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 process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\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 const renderMarkdown = (components?: any) =>\n untracked(markdownRendererModule)\n ?.useMarkdown()\n .renderMarkdown(node, components) ?? node;\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? () => renderMarkdown(components)\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => renderMarkdown(components),\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString' || prop === Symbol.toPrimitive) {\n return () => compileToHtml(node, components);\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...newComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? html\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString' || prop === Symbol.toPrimitive) {\n return () => {\n // Without component overrides the source is already HTML.\n if (!components || Object.keys(components).length === 0) {\n return String(html);\n }\n\n return compileToHtml(String(html), components);\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...userComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const { plugins, ...rest } = props;\n const content = node[NodeTypes.INSERTION];\n\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run the\n // transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(content)) {\n return (args: Record<string, string | number> = {}) =>\n transformInterpolableNode(\n content,\n args,\n props,\n props.plugins,\n deepTransformNode\n );\n }\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = content as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n };\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<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 = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n // Tracked read: called inside the dictionary `computed` of the hooks, so the\n // computed re-evaluates once the renderer chunk lands. The core interpreter\n // memoizes transformed content per plugin-array identity, and the transform\n // itself is lazy (property getters resolved from the template), so handing\n // out a fresh array is what discards the proxies built while pending and\n // gives every binding a new value to re-render.\n const isRendererLoaded = markdownRendererModule() !== null;\n const cacheKey = `${currentLocale}_${fallback}_${isRendererLoaded}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n intlayerNodePlugins,\n markdown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,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAGlC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
2
|
import { resolve } from "node:path";
|
|
4
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
@@ -7,7 +6,7 @@ import { IntlayerPlugin } from "@intlayer/webpack";
|
|
|
7
6
|
import { defu } from "defu";
|
|
8
7
|
|
|
9
8
|
//#region src/webpack/mergeConfig.ts
|
|
10
|
-
const _require =
|
|
9
|
+
const _require = createRequire(import.meta.url);
|
|
11
10
|
const mergeConfig = (baseConfig) => {
|
|
12
11
|
const intlayerConfig = getConfiguration();
|
|
13
12
|
const config = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeConfig.mjs","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n\
|
|
1
|
+
{"version":3,"file":"mergeConfig.mjs","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n\n// `import.meta.url` is shimmed to `__filename` in the CommonJS build, while a\n// `typeof require` guard would pick up the ESM build's `require` proxy.\nconst _require = createRequire(import.meta.url);\n\nexport const mergeConfig = (\n baseConfig: import('webpack').Configuration\n): import('webpack').Configuration => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\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 // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: _require.resolve('babel-loader'),\n options: {\n presets: [\n [\n _require.resolve('@babel/preset-env'),\n { modules: 'commonjs' },\n ],\n ],\n plugins: [\n [\n _require.resolve('@babel/plugin-syntax-import-attributes'),\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as import('webpack').Configuration;\n};\n"],"mappings":";;;;;;;;AASA,MAAM,WAAW,cAAc,YAAY,GAAG;AAE9C,MAAa,eACX,eACoC;CACpC,MAAM,iBAAiB,iBAAiB;CAExC,MAAM,SAAS;EACb,SAAS,EACP,OAAO,SAAS;GACd,eAAe;GACf,YAAY,UAAkB,QAAQ,KAAK;EAC7C,CAAC,EACH;EACA,WAAW;GACT,SAAS;GACT,QAAQ;GACR,IAAI;GACJ,UAAU;GACV,UAAU;EACZ;EACA,QAAQ,EACN,OAAO,CACL;GACE,MAAM;GACN,QAAQ;EACV,GAGA;GACE,MAAM;GACN,SAAS,CAAC,sBAAsB;GAChC,MAAM;GACN,SAAS;GACT,KAAK;IACH,QAAQ,SAAS,QAAQ,cAAc;IACvC,SAAS;KACP,SAAS,CACP,CACE,SAAS,QAAQ,mBAAmB,GACpC,EAAE,SAAS,WAAW,CACxB,CACF;KACA,SAAS,CACP,CACE,SAAS,QAAQ,wCAAwC,GACzD,EAAE,kBAAkB,KAAK,CAC3B,CACF;IACF;GACF;EACF,CACF,EACF;EACA,SAAS,CAAC,IAAI,eAAe,cAAc,CAAC;CAC9C;CAEA,OAAO,KAAK,QAAQ,UAAU;AAChC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
//#region src/client/useLocaleStorage.d.ts
|
|
4
3
|
/**
|
|
@@ -7,13 +6,13 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
7
6
|
/**
|
|
8
7
|
* Get the locale cookie
|
|
9
8
|
*/
|
|
10
|
-
export declare const localeInStorage: Locale;
|
|
9
|
+
export declare const localeInStorage: import("@intlayer/types").Locale;
|
|
11
10
|
/**
|
|
12
11
|
* @deprecated Use localeInStorage instead
|
|
13
12
|
*
|
|
14
13
|
* Get the locale cookie
|
|
15
14
|
*/
|
|
16
|
-
export declare const localeCookie: Locale;
|
|
15
|
+
export declare const localeCookie: import("@intlayer/types").Locale;
|
|
17
16
|
/**
|
|
18
17
|
* Set the locale cookie
|
|
19
18
|
*/
|
|
@@ -28,7 +27,7 @@ export declare const setLocaleCookie: typeof setLocaleInStorage;
|
|
|
28
27
|
* Hook that provides the locale storage and a function to set it
|
|
29
28
|
*/
|
|
30
29
|
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
31
|
-
getLocale: () => Locale;
|
|
30
|
+
getLocale: () => import("@intlayer/types").Locale;
|
|
32
31
|
setLocale: (locale: LocalesValues) => void;
|
|
33
32
|
};
|
|
34
33
|
/**
|
|
@@ -39,7 +38,7 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
39
38
|
* Hook that provides the locale cookie and a function to set it
|
|
40
39
|
*/
|
|
41
40
|
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
42
|
-
localeCookie: Locale;
|
|
41
|
+
localeCookie: import("@intlayer/types").Locale;
|
|
43
42
|
setLocaleCookie: (locale: LocalesValues) => void;
|
|
44
43
|
};
|
|
45
44
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;;qBAca,2CAAe;;;;;;qBAMf,wCAAY;;;;qBAKZ,qBAAkB,QACrB,eAAa;;;;;;qBAaV,wBAAe;;;;qBAKf,mBAAgB;;sBAAhB;;;;;;;;;qBAaA,kBAAe;EAIxB,wCAAY;EACZ,kBAAe,QAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/esbuild/hiddenDirectory.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `directory` sits under a dot-directory (`.intlayer/…`) of `baseDir`.
|
|
4
|
+
*
|
|
5
|
+
* Angular's esbuild dev server ignores `<workspace>/**\/.*\/**` in its file
|
|
6
|
+
* watcher, so generated files living there never invalidate its TypeScript
|
|
7
|
+
* source cache: a key added to a dictionary regenerates the types, but the
|
|
8
|
+
* template type-checker keeps the stale declaration until `ng serve` restarts.
|
|
9
|
+
*
|
|
10
|
+
* @param baseDir - Angular workspace root (the Intlayer `system.baseDir`).
|
|
11
|
+
* @param directory - Absolute directory to test.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isInHiddenDirectory: (baseDir: string, directory: string) => boolean;
|
|
14
|
+
//#endregion
|
|
15
|
+
//# sourceMappingURL=hiddenDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hiddenDirectory.d.ts","names":[],"sources":["../../../src/esbuild/hiddenDirectory.ts"],"mappings":";;;;;;;;;;;;qBAaa,sBAAmB,iBACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EsbuildPlugin, EsbuildPluginBuild, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin } from "./plugin.js";
|
|
2
|
-
export { EsbuildPlugin, EsbuildPluginBuild, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin };
|
|
1
|
+
import { EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildPluginBuild, EsbuildResolveArgs, EsbuildResolveResult, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin } from "./plugin.js";
|
|
2
|
+
export { EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildPluginBuild, EsbuildResolveArgs, EsbuildResolveResult, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin };
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
2
2
|
//#region src/esbuild/plugin.d.ts
|
|
3
|
+
export type EsbuildResolveArgs = {
|
|
4
|
+
path: string;
|
|
5
|
+
importer: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
resolveDir: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
pluginData?: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type EsbuildResolveResult = {
|
|
12
|
+
path?: string;
|
|
13
|
+
namespace?: string;
|
|
14
|
+
external?: boolean;
|
|
15
|
+
sideEffects?: boolean;
|
|
16
|
+
pluginData?: unknown;
|
|
17
|
+
errors?: unknown[];
|
|
18
|
+
warnings?: unknown[];
|
|
19
|
+
};
|
|
20
|
+
export type EsbuildLoadArgs = {
|
|
21
|
+
path: string;
|
|
22
|
+
namespace: string;
|
|
23
|
+
pluginData?: unknown;
|
|
24
|
+
};
|
|
25
|
+
export type EsbuildLoadResult = {
|
|
26
|
+
contents: string;
|
|
27
|
+
loader?: string;
|
|
28
|
+
/** Directory relative imports of `contents` resolve from. */
|
|
29
|
+
resolveDir?: string;
|
|
30
|
+
};
|
|
3
31
|
export interface EsbuildPluginBuild {
|
|
4
32
|
initialOptions: {
|
|
5
33
|
alias?: Record<string, string>;
|
|
@@ -14,29 +42,17 @@ export interface EsbuildPluginBuild {
|
|
|
14
42
|
onResolve(options: {
|
|
15
43
|
filter: RegExp;
|
|
16
44
|
namespace?: string;
|
|
17
|
-
}, callback: (args:
|
|
45
|
+
}, callback: (args: EsbuildResolveArgs) => EsbuildResolveResult | null | undefined | Promise<EsbuildResolveResult | null | undefined>): void;
|
|
46
|
+
/** Run the remaining resolution pipeline (other plugins, then esbuild). */
|
|
47
|
+
resolve(path: string, options: Partial<Omit<EsbuildResolveArgs, 'path'>>): Promise<EsbuildResolveResult & {
|
|
18
48
|
path: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
resolveDir: string;
|
|
22
|
-
}) => {
|
|
23
|
-
path: string;
|
|
24
|
-
namespace?: string;
|
|
25
|
-
} | null | undefined): void;
|
|
49
|
+
external: boolean;
|
|
50
|
+
}>;
|
|
26
51
|
/** Intercept module contents, so a resolved file can be rewritten. */
|
|
27
52
|
onLoad(options: {
|
|
28
53
|
filter: RegExp;
|
|
29
54
|
namespace?: string;
|
|
30
|
-
}, callback: (args:
|
|
31
|
-
path: string;
|
|
32
|
-
namespace: string;
|
|
33
|
-
}) => {
|
|
34
|
-
contents: string;
|
|
35
|
-
loader?: string;
|
|
36
|
-
} | null | undefined | Promise<{
|
|
37
|
-
contents: string;
|
|
38
|
-
loader?: string;
|
|
39
|
-
} | null | undefined>): void;
|
|
55
|
+
}, callback: (args: EsbuildLoadArgs) => EsbuildLoadResult | null | undefined | Promise<EsbuildLoadResult | null | undefined>): void;
|
|
40
56
|
}
|
|
41
57
|
export interface EsbuildPlugin {
|
|
42
58
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;YAgEY;EACV;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV;EACA;EACA;;YAGU;EACV;EACA;;EAEA;;iBAGe;EACf;IACE,QAAQ;IACR,SAAS;IACT;IACA;;IAEA;;EAEF,QAAQ,uBAAuB;;EAE/B,UACE;IAAW,QAAQ;IAAQ;KAC3B,WACE,MAAM,uBAEJ,0CAGA,QAAQ;;EAGd,QACE,cACA,SAAS,QAAQ,KAAK,+BACrB,QAAQ;IAAyB;IAAc;;;EAElD,OACE;IAAW,QAAQ;IAAQ;KAC3B,WACE,MAAM,oBAEJ,uCAGA,QAAQ;;iBAIC;EACf;EACA,MAAM,OAAO,4BAA4B;;YAG/B;EACV,gBAAgB;;;;;;;;EAQhB;;;;;;;;;;;;;;;;;;;;;;;;qBAqDW,wBAAqB,UACtB,iCACT"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/esbuild/resolvePackageExport.d.ts
|
|
2
|
+
export type ResolvedPackageExport = {
|
|
3
|
+
/** Absolute path of the file the specifier maps to. */
|
|
4
|
+
path: string;
|
|
5
|
+
/** `false` when the manifest declares the whole package side-effect free. */
|
|
6
|
+
sideEffects: false | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** Splits a bare specifier into its package name and `./`-prefixed subpath. */
|
|
9
|
+
export declare const parsePackageSpecifier: (specifier: string) => {
|
|
10
|
+
packageName: string;
|
|
11
|
+
subpath: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Locates `node_modules/<packageName>/package.json` the way Node does: from
|
|
15
|
+
* `startDir` upward, first hit wins.
|
|
16
|
+
*/
|
|
17
|
+
export declare const findPackageManifest: (packageName: string, startDir: string) => string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a bare specifier to an absolute file through the package manifest,
|
|
20
|
+
* without going through the bundler's own resolver.
|
|
21
|
+
*
|
|
22
|
+
* Needed inside Angular's dev server: its esbuild pipeline marks every file
|
|
23
|
+
* resolved under `node_modules` as external so Vite can pre-bundle it, and the
|
|
24
|
+
* pre-bundler neither runs the Intlayer plugin nor sees its aliases — the real
|
|
25
|
+
* `@intlayer/config/built` (a Node config loader) then lands in the browser.
|
|
26
|
+
* Resolving here and returning a plain path keeps the package inside the
|
|
27
|
+
* plugin-aware esbuild build.
|
|
28
|
+
*
|
|
29
|
+
* @param specifier - Bare specifier such as `@intlayer/core/interpreter`.
|
|
30
|
+
* @param resolveDir - Directory the import is issued from.
|
|
31
|
+
* @param conditions - Export conditions to honour, in addition to `default`.
|
|
32
|
+
* @returns The resolved file, or `undefined` when the manifest cannot be found
|
|
33
|
+
* or does not map the subpath — the caller then leaves the bundler to it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolvePackageExport: (specifier: string, resolveDir: string, conditions: readonly string[]) => ResolvedPackageExport | undefined;
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=resolvePackageExport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePackageExport.d.ts","names":[],"sources":["../../../src/esbuild/resolvePackageExport.ts"],"mappings":";YAqBY;;EAEV;;EAEA;;;qBAIW,wBAAqB;EAE7B;EAAqB;;;;;;qBAab,sBAAmB,qBACX;;;;;;;;;;;;;;;;;;qBA6HR,uBAAoB,mBACd,oBACC,kCAEjB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useCompact.d.ts
|
|
3
2
|
export declare const useCompact: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
}) => string>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=useCompact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";qBAIa,0CAAU,QAAA,wBAAA,UAAA,KAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useCurrency.d.ts
|
|
3
2
|
export declare const useCurrency: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
}) => string>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=useCurrency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";qBAIa,2CAAW,QAAA,wBAAA,UAAA,KAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useDate.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Angular client hook that provides a localized date/time formatter.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useDate: () => import("@angular/core").Signal<(date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
|
|
7
|
-
locale?: LocalesValues;
|
|
6
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
8
7
|
})) => string>;
|
|
9
8
|
//#endregion
|
|
10
9
|
//# sourceMappingURL=useDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;qBAOa,uCAAO,QAAA,wBAAA,MAAA,8CAAA,kBAAA,KAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useList.d.ts
|
|
3
2
|
export declare const useList: () => import("@angular/core").Signal<(values: (string | number)[], options?: import("@intlayer/core/formatters").ListFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
}) => string>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=useList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";qBAIa,uCAAO,QAAA,6BAAA,8CAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useNumber.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Angular client hook that provides a localized number formatter.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useNumber: () => import("@angular/core").Signal<(value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
7
|
-
locale?: LocalesValues;
|
|
6
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
8
7
|
}) => string>;
|
|
9
8
|
//#endregion
|
|
10
9
|
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;;;qBAOa,yCAAS,QAAA,wBAAA,SAAA,KAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/usePercentage.d.ts
|
|
3
2
|
export declare const usePercentage: () => import("@angular/core").Signal<(value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
}) => string>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=usePercentage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";qBAIa,6CAAa,QAAA,wBAAA,SAAA,KAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useRelativeTime.d.ts
|
|
3
2
|
export declare const useRelativeTime: () => import("@angular/core").Signal<(from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
6
5
|
}) => string>;
|
|
7
6
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";qBAIa,+CAAe,QAAA,wBAAA,MAAA,uBAAA,MAAA,UAAA,KAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useUnit.d.ts
|
|
3
2
|
export declare const useUnit: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
4
|
-
locale?: LocalesValues;
|
|
3
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
5
4
|
}) => string>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=useUnit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";qBAIa,uCAAO,QAAA,wBAAA,UAAA,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;YAgHY,iBAAiB,KAAK,4BAC9B,aAAa;iBAGA,aAAa,GAAG;EAC/B,OAAO;EACP;EACA,kBAAkB;;;qBAIP,qBAAqB;;;;YAwCtB,mBAAmB,KAAK,mBAChC;EAAuB,UAAU;;;qBAIxB,sBAAsB;YAkGvB,aAAa,GAAG,IAAI,WAAW,iBAAiB;EAC1D,UAAU;GACT,UAAU,iBAAiB;EAC5B,aAAa;EACb,iBAAiB;IAEf,aACE;EAEE,MAAM,aAAa,aAAa;EAChC,UAAU,qBAAqB;;qBAK1B,gBAAgB;;;;;;;;;;YAoCjB,eAAe,GAAG,IAAI,MAAM;EACtC,UAAU;GACT,UAAU,aAAa;EACxB,aAAa;IAEX,aACE;EAEE,MAAM,aAAa,aAAa;;;qBAM3B,YAAY;;;;;;;YA+Eb,oBAAoB,KAAK;EACnC,UAAU;GACT,UAAU,kBAAkB;KAE1B,MAAM;qBAGE,iBAAiB;iBA+Cb,0BAA0B,GAAG,GAAG,UAAU;EACzD,qBAAqB,iBAAiB;EACtC,iBAAiB,aAAa,GAAG,GAAG;EACpC,aAAa,eAAe,GAAG,GAAG;EAClC,kBAAkB,oBAAoB;;;;;;;YAQ5B,0BAA0B,KACpC;EAGA;EACA;EACA;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeConfig.d.ts","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"mergeConfig.d.ts","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"mappings":";qBAWa,cAAW,8BACQ,oCACX"}
|