angular-intlayer 9.0.0-canary.15 → 9.0.0-canary.17

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.
Files changed (43) hide show
  1. package/dist/cjs/analytics/exposureSink.cjs +27 -0
  2. package/dist/cjs/analytics/exposureSink.cjs.map +1 -0
  3. package/dist/cjs/analytics/index.cjs +9 -0
  4. package/dist/cjs/analytics/useAnalytics.cjs +85 -0
  5. package/dist/cjs/analytics/useAnalytics.cjs.map +1 -0
  6. package/dist/cjs/analytics/useConversion.cjs +37 -0
  7. package/dist/cjs/analytics/useConversion.cjs.map +1 -0
  8. package/dist/cjs/analytics/useExperiment.cjs +70 -0
  9. package/dist/cjs/analytics/useExperiment.cjs.map +1 -0
  10. package/dist/cjs/client/installIntlayer.cjs +9 -4
  11. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  12. package/dist/cjs/index.cjs +7 -0
  13. package/dist/cjs/plugins.cjs +21 -12
  14. package/dist/cjs/plugins.cjs.map +1 -1
  15. package/dist/esm/analytics/exposureSink.mjs +24 -0
  16. package/dist/esm/analytics/exposureSink.mjs.map +1 -0
  17. package/dist/esm/analytics/index.mjs +5 -0
  18. package/dist/esm/analytics/useAnalytics.mjs +82 -0
  19. package/dist/esm/analytics/useAnalytics.mjs.map +1 -0
  20. package/dist/esm/analytics/useConversion.mjs +35 -0
  21. package/dist/esm/analytics/useConversion.mjs.map +1 -0
  22. package/dist/esm/analytics/useExperiment.mjs +68 -0
  23. package/dist/esm/analytics/useExperiment.mjs.map +1 -0
  24. package/dist/esm/client/installIntlayer.mjs +9 -4
  25. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  26. package/dist/esm/index.mjs +4 -1
  27. package/dist/esm/plugins.mjs +21 -12
  28. package/dist/esm/plugins.mjs.map +1 -1
  29. package/dist/types/analytics/exposureSink.d.ts +33 -0
  30. package/dist/types/analytics/exposureSink.d.ts.map +1 -0
  31. package/dist/types/analytics/index.d.ts +4 -0
  32. package/dist/types/analytics/useAnalytics.d.ts +38 -0
  33. package/dist/types/analytics/useAnalytics.d.ts.map +1 -0
  34. package/dist/types/analytics/useConversion.d.ts +34 -0
  35. package/dist/types/analytics/useConversion.d.ts.map +1 -0
  36. package/dist/types/analytics/useExperiment.d.ts +48 -0
  37. package/dist/types/analytics/useExperiment.d.ts.map +1 -0
  38. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  39. package/dist/types/index.d.ts +4 -1
  40. package/dist/types/index.d.ts.map +1 -1
  41. package/dist/types/plugins.d.ts.map +1 -1
  42. package/dist/types/webpack/mergeConfig.d.ts +1 -1
  43. package/package.json +12 -9
@@ -0,0 +1,35 @@
1
+ import { isEnabled } from "@intlayer/analytics/isEnabled";
2
+
3
+ //#region src/analytics/useConversion.ts
4
+ /**
5
+ * Returns a `trackConversion` callback for content A/B testing. Safe to call
6
+ * from any component: it resolves to a no-op when analytics is disabled or the
7
+ * client has not been initialized yet.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * export class CtaComponent {
12
+ * trackConversion = useConversion();
13
+ *
14
+ * onClick() {
15
+ * this.trackConversion({
16
+ * experimentKey: 'homepage-hero',
17
+ * variant: 'b',
18
+ * goal: 'cta_click',
19
+ * });
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ const useConversion = () => {
25
+ return (params) => {
26
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
27
+ import("@intlayer/analytics").then(({ getGlobalAnalyticsClient }) => {
28
+ getGlobalAnalyticsClient()?.trackConversion(params);
29
+ }).catch(() => {});
30
+ };
31
+ };
32
+
33
+ //#endregion
34
+ export { useConversion };
35
+ //# sourceMappingURL=useConversion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversion.mjs","names":[],"sources":["../../../src/analytics/useConversion.ts"],"sourcesContent":["import { isEnabled } from '@intlayer/analytics/isEnabled';\n\n/**\n * Parameters describing a conversion to record.\n */\nexport type ConversionParams = {\n /** The experiment this conversion is attributed to. */\n experimentKey: string;\n /** The variant the session was assigned. */\n variant: string;\n /** The goal reached (e.g. `\"signup\"`, `\"cta_click\"`). */\n goal: string;\n /** Optional numeric value (e.g. revenue). */\n value?: number;\n};\n\n/**\n * Returns a `trackConversion` callback for content A/B testing. Safe to call\n * from any component: it resolves to a no-op when analytics is disabled or the\n * client has not been initialized yet.\n *\n * @example\n * ```ts\n * export class CtaComponent {\n * trackConversion = useConversion();\n *\n * onClick() {\n * this.trackConversion({\n * experimentKey: 'homepage-hero',\n * variant: 'b',\n * goal: 'cta_click',\n * });\n * }\n * }\n * ```\n */\nexport const useConversion = () => {\n return (params: ConversionParams): void => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n import('@intlayer/analytics')\n .then(({ getGlobalAnalyticsClient }) => {\n getGlobalAnalyticsClient()?.trackConversion(params);\n })\n .catch(() => {});\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,sBAAsB;AACjC,SAAQ,WAAmC;AACzC,MAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,UACzD;AAGF,SAAO,uBACJ,MAAM,EAAE,+BAA+B;AACtC,6BAA0B,EAAE,gBAAgB,OAAO;IACnD,CACD,YAAY,GAAG"}
@@ -0,0 +1,68 @@
1
+ import { DestroyRef, inject, signal } from "@angular/core";
2
+ import { isEnabled } from "@intlayer/analytics/isEnabled";
3
+
4
+ //#region src/analytics/useExperiment.ts
5
+ /**
6
+ * Assigns this session to a variant of an A/B experiment and records the
7
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
8
+ * conversion rates against `useConversion` events.
9
+ *
10
+ * Assignment is deterministic per session (no server round-trip, stable across
11
+ * re-mounts). The exposure is recorded once per call.
12
+ *
13
+ * Must be called inside an Angular injection context (e.g. a component
14
+ * constructor or field initializer).
15
+ *
16
+ * @param experimentKey - Unique key identifying the experiment.
17
+ * @param variants - The candidate variant names; the first one is the control.
18
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
19
+ * @returns The {@link ExperimentState} for this session.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * export class HeroComponent {
24
+ * experiment = useExperiment('homepage-hero', ['a', 'b']);
25
+ * content = useIntlayer('hero');
26
+ * }
27
+ * ```
28
+ */
29
+ const useExperiment = (experimentKey, variants, weights) => {
30
+ const variant = signal(variants[0] ?? "");
31
+ const isAssigned = signal(false);
32
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return {
33
+ variant: variant.asReadonly(),
34
+ isAssigned: isAssigned.asReadonly()
35
+ };
36
+ const destroyRef = inject(DestroyRef, { optional: true });
37
+ let cancelled = false;
38
+ let initialized = false;
39
+ import("@intlayer/analytics").then(({ initAnalyticsClient }) => {
40
+ if (cancelled) return;
41
+ const client = initAnalyticsClient();
42
+ initialized = true;
43
+ const assigned = client.getVariant(experimentKey, variants, weights);
44
+ variant.set(assigned);
45
+ isAssigned.set(true);
46
+ client.trackContentExposure({
47
+ dictionaryKey: experimentKey,
48
+ keyPath: "",
49
+ nodeType: "experiment",
50
+ experimentKey,
51
+ variant: assigned
52
+ });
53
+ }).catch(() => {});
54
+ destroyRef?.onDestroy(() => {
55
+ cancelled = true;
56
+ import("@intlayer/analytics").then(({ stopAnalyticsClient }) => {
57
+ if (initialized) stopAnalyticsClient();
58
+ }).catch(() => {});
59
+ });
60
+ return {
61
+ variant: variant.asReadonly(),
62
+ isAssigned: isAssigned.asReadonly()
63
+ };
64
+ };
65
+
66
+ //#endregion
67
+ export { useExperiment };
68
+ //# sourceMappingURL=useExperiment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExperiment.mjs","names":[],"sources":["../../../src/analytics/useExperiment.ts"],"sourcesContent":["import { DestroyRef, inject, type Signal, signal } from '@angular/core';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\n\n/**\n * The state of an A/B experiment for the current session.\n */\nexport type ExperimentState = {\n /**\n * The variant assigned to this session. Until assignment resolves (and on\n * the server, or when analytics is disabled), this is the first variant —\n * treat the first variant as the control.\n */\n variant: Signal<string>;\n /**\n * `true` once the variant has been deterministically assigned and its\n * exposure recorded. Useful to defer rendering when a flash of the control\n * variant is not acceptable.\n */\n isAssigned: Signal<boolean>;\n};\n\n/**\n * Assigns this session to a variant of an A/B experiment and records the\n * exposure, scoped to `experimentKey`, so the backend can compute per-variant\n * conversion rates against `useConversion` events.\n *\n * Assignment is deterministic per session (no server round-trip, stable across\n * re-mounts). The exposure is recorded once per call.\n *\n * Must be called inside an Angular injection context (e.g. a component\n * constructor or field initializer).\n *\n * @param experimentKey - Unique key identifying the experiment.\n * @param variants - The candidate variant names; the first one is the control.\n * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).\n * @returns The {@link ExperimentState} for this session.\n *\n * @example\n * ```ts\n * export class HeroComponent {\n * experiment = useExperiment('homepage-hero', ['a', 'b']);\n * content = useIntlayer('hero');\n * }\n * ```\n */\nexport const useExperiment = (\n experimentKey: string,\n variants: string[],\n weights?: number[]\n): ExperimentState => {\n const variant = signal(variants[0] ?? '');\n const isAssigned = signal(false);\n\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return {\n variant: variant.asReadonly(),\n isAssigned: isAssigned.asReadonly(),\n };\n }\n\n const destroyRef = inject(DestroyRef, { optional: true });\n\n let cancelled = false;\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient }) => {\n if (cancelled) return;\n\n // Ref-counted: guarantees a live client even when this call's import\n // resolves before the provider's. Balanced by stop on destroy.\n const client = initAnalyticsClient();\n initialized = true;\n\n const assigned = client.getVariant(experimentKey, variants, weights);\n variant.set(assigned);\n isAssigned.set(true);\n\n // Experiment-level exposure — the denominator of the conversion rate.\n client.trackContentExposure({\n dictionaryKey: experimentKey,\n keyPath: '',\n nodeType: 'experiment',\n experimentKey,\n variant: assigned,\n });\n })\n .catch(() => {\n /* chunk failed to load — control variant stays in place */\n });\n\n destroyRef?.onDestroy(() => {\n cancelled = true;\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n });\n\n return { variant: variant.asReadonly(), isAssigned: isAssigned.asReadonly() };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,iBACX,eACA,UACA,YACoB;CACpB,MAAM,UAAU,OAAO,SAAS,MAAM,GAAG;CACzC,MAAM,aAAa,OAAO,MAAM;AAEhC,KAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,UACzD,QAAO;EACL,SAAS,QAAQ,YAAY;EAC7B,YAAY,WAAW,YAAY;EACpC;CAGH,MAAM,aAAa,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC;CAEzD,IAAI,YAAY;CAChB,IAAI,cAAc;AAElB,QAAO,uBACJ,MAAM,EAAE,0BAA0B;AACjC,MAAI,UAAW;EAIf,MAAM,SAAS,qBAAqB;AACpC,gBAAc;EAEd,MAAM,WAAW,OAAO,WAAW,eAAe,UAAU,QAAQ;AACpE,UAAQ,IAAI,SAAS;AACrB,aAAW,IAAI,KAAK;AAGpB,SAAO,qBAAqB;GAC1B,eAAe;GACf,SAAS;GACT,UAAU;GACV;GACA,SAAS;GACV,CAAC;GACF,CACD,YAAY,GAEX;AAEJ,aAAY,gBAAgB;AAC1B,cAAY;AACZ,SAAO,uBACJ,MAAM,EAAE,0BAA0B;AACjC,OAAI,YAAa,sBAAqB;IACtC,CACD,YAAY,GAAG;GAClB;AAEF,QAAO;EAAE,SAAS,QAAQ,YAAY;EAAE,YAAY,WAAW,YAAY;EAAE"}
@@ -1,4 +1,5 @@
1
1
  import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./intlayerToken.mjs";
2
+ import { provideIntlayerAnalytics } from "../analytics/useAnalytics.mjs";
2
3
  import { provideIntlayerEditor } from "../editor/useEditor.mjs";
3
4
 
4
5
  //#region src/client/installIntlayer.ts
@@ -27,10 +28,14 @@ import { provideIntlayerEditor } from "../editor/useEditor.mjs";
27
28
  */
28
29
  const provideIntlayer = (locale, isCookieEnabled = true) => {
29
30
  const client = installIntlayer(locale, isCookieEnabled);
30
- return [{
31
- provide: INTLAYER_TOKEN,
32
- useValue: client
33
- }, provideIntlayerEditor(client)];
31
+ return [
32
+ {
33
+ provide: INTLAYER_TOKEN,
34
+ useValue: client
35
+ },
36
+ provideIntlayerEditor(client),
37
+ provideIntlayerAnalytics(client)
38
+ ];
34
39
  };
35
40
  /**
36
41
  * Helper to install the Intlayer provider.
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { provideIntlayerEditor } from '../editor/useEditor';\nimport {\n createIntlayerClient,\n INTLAYER_TOKEN,\n IntlayerProvider,\n} from './intlayerToken';\n\nexport { createIntlayerClient, INTLAYER_TOKEN, IntlayerProvider };\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * Registers the Intlayer locale token **and** automatically starts the Intlayer\n * editor client (when the editor is enabled) via `provideAppInitializer`.\n *\n * This is the recommended way to set up Intlayer in `app.config.ts`.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns An array of Angular providers for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [provideIntlayer()],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = installIntlayer(locale, isCookieEnabled);\n\n return [\n { provide: INTLAYER_TOKEN, useValue: client },\n provideIntlayerEditor(client),\n ];\n};\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n return createIntlayerClient(locale, isCookieEnabled);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,MAAM,SAAS,gBAAgB,QAAQ,gBAAgB;AAEvD,QAAO,CACL;EAAE,SAAS;EAAgB,UAAU;EAAQ,EAC7C,sBAAsB,OAAO,CAC9B;;;;;AAMH,MAAa,mBACX,QACA,kBAAkB,SACf;AACH,QAAO,qBAAqB,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { provideIntlayerAnalytics } from '../analytics/useAnalytics';\nimport { provideIntlayerEditor } from '../editor/useEditor';\nimport {\n createIntlayerClient,\n INTLAYER_TOKEN,\n IntlayerProvider,\n} from './intlayerToken';\n\nexport { createIntlayerClient, INTLAYER_TOKEN, IntlayerProvider };\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * Registers the Intlayer locale token **and** automatically starts the Intlayer\n * editor client (when the editor is enabled) via `provideAppInitializer`.\n *\n * This is the recommended way to set up Intlayer in `app.config.ts`.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns An array of Angular providers for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [provideIntlayer()],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = installIntlayer(locale, isCookieEnabled);\n\n return [\n { provide: INTLAYER_TOKEN, useValue: client },\n provideIntlayerEditor(client),\n provideIntlayerAnalytics(client),\n ];\n};\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n return createIntlayerClient(locale, isCookieEnabled);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,MAAM,SAAS,gBAAgB,QAAQ,gBAAgB;AAEvD,QAAO;EACL;GAAE,SAAS;GAAgB,UAAU;GAAQ;EAC7C,sBAAsB,OAAO;EAC7B,yBAAyB,OAAO;EACjC;;;;;AAMH,MAAa,mBACX,QACA,kBAAkB,SACf;AACH,QAAO,qBAAqB,QAAQ,gBAAgB"}
@@ -2,6 +2,9 @@ import { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownP
2
2
  import { getIntlayer } from "./getIntlayer.mjs";
3
3
  import { getDictionary } from "./getDictionary.mjs";
4
4
  import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./client/intlayerToken.mjs";
5
+ import { provideIntlayerAnalytics, useAnalytics } from "./analytics/useAnalytics.mjs";
6
+ import { useConversion } from "./analytics/useConversion.mjs";
7
+ import { useExperiment } from "./analytics/useExperiment.mjs";
5
8
  import { installIntlayer, provideIntlayer } from "./client/installIntlayer.mjs";
6
9
  import { useDictionary } from "./client/useDictionary.mjs";
7
10
  import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
@@ -12,4 +15,4 @@ import { useLocale } from "./client/useLocale.mjs";
12
15
  import { usePathname } from "./client/usePathname.mjs";
13
16
  import { IntlayerNodeComponent } from "./UI/IntlayerNode.component.mjs";
14
17
 
15
- export { INTLAYER_TOKEN, IntlayerNodeComponent, IntlayerProvider, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale, usePathname };
18
+ export { INTLAYER_TOKEN, IntlayerNodeComponent, IntlayerProvider, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, provideIntlayerAnalytics, useAnalytics, useConversion, useDictionary, useDictionaryAsync, useDictionaryDynamic, useExperiment, useIntlayer, useLoadDynamic, useLocale, usePathname };
@@ -1,4 +1,5 @@
1
1
  import { renderIntlayerNode } from "./renderIntlayerNode.mjs";
2
+ import { reportExposure } from "./analytics/exposureSink.mjs";
2
3
  import { ContentSelectorWrapperComponent } from "./editor/ContentSelector.component.mjs";
3
4
  import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, pluralPlugin, translationPlugin } from "@intlayer/core/interpreter";
4
5
  import { editor, internationalization } from "@intlayer/config/built";
@@ -37,18 +38,26 @@ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
37
38
  const intlayerNodePlugins = {
38
39
  id: "intlayer-node-plugin",
39
40
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
40
- transform: (_node, { children, ...rest }) => renderIntlayerNode({
41
- ...rest,
42
- value: children,
43
- children: () => ({
44
- component: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? children : ContentSelectorWrapperComponent,
45
- props: {
46
- dictionaryKey: rest.dictionaryKey,
47
- keyPath: rest.keyPath
48
- },
49
- children
50
- })
51
- })
41
+ transform: (_node, { children, ...rest }) => {
42
+ if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
43
+ dictionaryKey: rest.dictionaryKey,
44
+ keyPath: rest.keyPath,
45
+ locale: rest.locale,
46
+ nodeType: "text"
47
+ });
48
+ return renderIntlayerNode({
49
+ ...rest,
50
+ value: children,
51
+ children: () => ({
52
+ component: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? children : ContentSelectorWrapperComponent,
53
+ props: {
54
+ dictionaryKey: rest.dictionaryKey,
55
+ keyPath: rest.keyPath
56
+ },
57
+ children
58
+ })
59
+ });
60
+ }
52
61
  };
53
62
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
54
63
  const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
@@ -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 nestedPlugin,\n type Plugins,\n pluralPlugin,\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 { 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').then((m) => {\n _markdownInstall = m as any;\n });\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 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 * 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) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node[NodeTypes.INSERTION] 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 intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n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GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
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 nestedPlugin,\n type Plugins,\n pluralPlugin,\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').then((m) => {\n _markdownInstall = m as any;\n });\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) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node[NodeTypes.INSERTION] 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 intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;AA4BA,IAAI,mBAGO;AACX,IACE,QAAQ,IAAI,gCAAgC,WAC5C,QAAQ,IAAI,4BAA4B,QAExC,CAAK,OAAO,0CAAsC,MAAM,MAAM;AAC5D,oBAAmB;EACnB;;;;AAOJ,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GAAG;AACrC,aAAS,YAAY;;AAGvB,UAAO,YAAY,cAAc,KAAK,UAAU,GAAG,SAAS;;AAG9D,SAAO,YAAY,cAAc,KAAK,OAAO,GAAG,SAAS;;CAE5D;;AAiBD,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAAW;AAG3C,MAAI,QAAQ,IAAI,+BAA+B,QAC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C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAwB,UAAU;EAC5C,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,OAAwC,EAAE,KAAK;GAC7D,IAAI,OAAO,KAAK,UAAU;AAC1B,OAAI,KACF,QAAO,QAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,WAAW;AAC7C,WAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,IAAI,EACrC,OAAO,MAAM,CACd;KACD;AAEJ,UAAO;;AAGT,SAAO,mBAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;GACX,CAAC;;CAEL;AA6BP,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
@@ -0,0 +1,33 @@
1
+ import { KeyPath } from "@intlayer/types/keyPath";
2
+
3
+ //#region src/analytics/exposureSink.d.ts
4
+ /**
5
+ * Node metadata reported for a content exposure. Kept dependency-free (types
6
+ * only) so the interpreter hot path in `plugins.ts` never statically imports
7
+ * `@intlayer/analytics` — the package stays optional and tree-shakeable.
8
+ */
9
+ type ExposureInput = {
10
+ dictionaryKey: string;
11
+ keyPath: KeyPath[];
12
+ locale?: string;
13
+ nodeType?: string;
14
+ };
15
+ /** Consumer of exposure reports, installed by `useAnalytics` after init. */
16
+ type ExposureSink = (input: ExposureInput) => void;
17
+ /**
18
+ * Installs (or clears) the exposure sink. `useAnalytics` sets this once the
19
+ * analytics client has loaded, and clears it on unmount.
20
+ *
21
+ * @param next - The sink to install, or `null` to clear.
22
+ */
23
+ declare const setExposureSink: (next: ExposureSink | null) => void;
24
+ /**
25
+ * Forwards a content exposure to the installed sink. A cheap null-check when
26
+ * analytics is not running, so it is safe to call from every node resolution.
27
+ *
28
+ * @param input - The node metadata to report.
29
+ */
30
+ declare const reportExposure: (input: ExposureInput) => void;
31
+ //#endregion
32
+ export { ExposureInput, ExposureSink, reportExposure, setExposureSink };
33
+ //# sourceMappingURL=exposureSink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":";;;;;AAOA;;;KAAY,aAAA;EACV,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA;EACA,QAAA;AAAA;;KAIU,YAAA,IAAgB,KAAA,EAAO,aAAA;AAAnC;;;;;AAUA;AAVA,cAUa,eAAA,GAAmB,IAAA,EAAM,YAAA;;;;AAUtC;;;cAAa,cAAA,GAAkB,KAAA,EAAO,aAAA"}
@@ -0,0 +1,4 @@
1
+ import { provideIntlayerAnalytics, useAnalytics } from "./useAnalytics.js";
2
+ import { ConversionParams, useConversion } from "./useConversion.js";
3
+ import { ExperimentState, useExperiment } from "./useExperiment.js";
4
+ export { ConversionParams, ExperimentState, provideIntlayerAnalytics, useAnalytics, useConversion, useExperiment };
@@ -0,0 +1,38 @@
1
+ import { IntlayerProvider } from "../client/intlayerToken.js";
2
+ import * as _$_angular_core0 from "@angular/core";
3
+
4
+ //#region src/analytics/useAnalytics.d.ts
5
+ /**
6
+ * Initializes the Intlayer analytics client singleton when analytics is
7
+ * enabled (mirrors {@link useEditor}). Records an initial page view, keeps the
8
+ * client aware of the current locale, and wires node-level content exposures.
9
+ *
10
+ * Must be called inside an Angular injection context (e.g. a component
11
+ * constructor, `provideAppInitializer`, or `runInInjectionContext`).
12
+ *
13
+ * @param client - The IntlayerProvider instance to sync locale from.
14
+ * When omitted the function injects `INTLAYER_TOKEN` from the DI tree,
15
+ * so it still works when called directly from a component.
16
+ */
17
+ declare const useAnalytics: (client?: IntlayerProvider | null) => void;
18
+ /**
19
+ * Angular provider that wires `useAnalytics` into the application
20
+ * initialisation phase via `provideAppInitializer`.
21
+ *
22
+ * `provideIntlayer()` already calls this internally, so you only need this
23
+ * function when you want to manage providers individually.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * // app.config.ts
28
+ * import { provideIntlayer, provideIntlayerAnalytics } from 'angular-intlayer';
29
+ *
30
+ * export const appConfig: ApplicationConfig = {
31
+ * providers: [provideIntlayer(), provideIntlayerAnalytics()],
32
+ * };
33
+ * ```
34
+ */
35
+ declare const provideIntlayerAnalytics: (client?: IntlayerProvider | null) => _$_angular_core0.EnvironmentProviders;
36
+ //#endregion
37
+ export { provideIntlayerAnalytics, useAnalytics };
38
+ //# sourceMappingURL=useAnalytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.ts"],"mappings":";;;;;;;AA4BA;;;;;AAkGA;;;;cAlGa,YAAA,GAAgB,MAAA,GAAS,gBAAA;;;;;;;;;;;;;;;;;;cAkGzB,wBAAA,GAA4B,MAAA,GAAS,gBAAA,YAAgB,gBAAA,CAAO,oBAAA"}
@@ -0,0 +1,34 @@
1
+ //#region src/analytics/useConversion.d.ts
2
+ /**
3
+ * Parameters describing a conversion to record.
4
+ */
5
+ type ConversionParams = {
6
+ /** The experiment this conversion is attributed to. */experimentKey: string; /** The variant the session was assigned. */
7
+ variant: string; /** The goal reached (e.g. `"signup"`, `"cta_click"`). */
8
+ goal: string; /** Optional numeric value (e.g. revenue). */
9
+ value?: number;
10
+ };
11
+ /**
12
+ * Returns a `trackConversion` callback for content A/B testing. Safe to call
13
+ * from any component: it resolves to a no-op when analytics is disabled or the
14
+ * client has not been initialized yet.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * export class CtaComponent {
19
+ * trackConversion = useConversion();
20
+ *
21
+ * onClick() {
22
+ * this.trackConversion({
23
+ * experimentKey: 'homepage-hero',
24
+ * variant: 'b',
25
+ * goal: 'cta_click',
26
+ * });
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ declare const useConversion: () => (params: ConversionParams) => void;
32
+ //#endregion
33
+ export { ConversionParams, useConversion };
34
+ //# sourceMappingURL=useConversion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.ts"],"mappings":";;AAKA;;KAAY,gBAAA;EAAgB,uDAE1B,aAAA,UAEA;EAAA,OAAA,UAIA;EAFA,IAAA,UAEK;EAAL,KAAA;AAAA;;;;;;;;;;;;;;;;;;;;;cAuBW,aAAA,SACH,MAAA,EAAQ,gBAAA"}
@@ -0,0 +1,48 @@
1
+ import { Signal } from "@angular/core";
2
+
3
+ //#region src/analytics/useExperiment.d.ts
4
+ /**
5
+ * The state of an A/B experiment for the current session.
6
+ */
7
+ type ExperimentState = {
8
+ /**
9
+ * The variant assigned to this session. Until assignment resolves (and on
10
+ * the server, or when analytics is disabled), this is the first variant —
11
+ * treat the first variant as the control.
12
+ */
13
+ variant: Signal<string>;
14
+ /**
15
+ * `true` once the variant has been deterministically assigned and its
16
+ * exposure recorded. Useful to defer rendering when a flash of the control
17
+ * variant is not acceptable.
18
+ */
19
+ isAssigned: Signal<boolean>;
20
+ };
21
+ /**
22
+ * Assigns this session to a variant of an A/B experiment and records the
23
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
24
+ * conversion rates against `useConversion` events.
25
+ *
26
+ * Assignment is deterministic per session (no server round-trip, stable across
27
+ * re-mounts). The exposure is recorded once per call.
28
+ *
29
+ * Must be called inside an Angular injection context (e.g. a component
30
+ * constructor or field initializer).
31
+ *
32
+ * @param experimentKey - Unique key identifying the experiment.
33
+ * @param variants - The candidate variant names; the first one is the control.
34
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
35
+ * @returns The {@link ExperimentState} for this session.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * export class HeroComponent {
40
+ * experiment = useExperiment('homepage-hero', ['a', 'b']);
41
+ * content = useIntlayer('hero');
42
+ * }
43
+ * ```
44
+ */
45
+ declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
46
+ //#endregion
47
+ export { ExperimentState, useExperiment };
48
+ //# sourceMappingURL=useExperiment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.ts"],"mappings":";;;;;AAMA;KAAY,eAAA;;;;;;EAMV,OAAA,EAAS,MAAA;EAMS;;AA2BpB;;;EA3BE,UAAA,EAAY,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;cA2BD,aAAA,GACX,aAAA,UACA,QAAA,YACA,OAAA,gBACC,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"mappings":";;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;;;cAAa,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,gBADsB,gBAAA,CACA,oBAAA;;;;;;;cAaX,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,eAAsB,gBAAA"}
1
+ {"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"mappings":";;;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;cAAa,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,gBADsB,gBAAA,CACA,oBAAA;;;;;;;cAcX,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,eAAsB,gBAAA"}
@@ -1,5 +1,8 @@
1
1
  import { IntlayerNodeComponent } from "./UI/IntlayerNode.component.js";
2
2
  import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./client/intlayerToken.js";
3
+ import { provideIntlayerAnalytics, useAnalytics } from "./analytics/useAnalytics.js";
4
+ import { ConversionParams, useConversion } from "./analytics/useConversion.js";
5
+ import { ExperimentState, useExperiment } from "./analytics/useExperiment.js";
3
6
  import { installIntlayer, provideIntlayer } from "./client/installIntlayer.js";
4
7
  import { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, InsertionPluginCond, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.js";
5
8
  import { useDictionary } from "./client/useDictionary.js";
@@ -18,5 +21,5 @@ declare module '@intlayer/core/interpreter' {
18
21
  interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginAngular<T, S, L> {}
19
22
  }
20
23
  //#endregion
21
- export { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_TOKEN, InsertionPluginCond, IntlayerNode, IntlayerNodeComponent, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, UseLocaleProps, UseLocaleResult, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale, usePathname };
24
+ export { ConversionParams, DeepTransformContent, ExperimentState, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_TOKEN, InsertionPluginCond, IntlayerNode, IntlayerNodeComponent, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, UseLocaleProps, UseLocaleResult, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, provideIntlayerAnalytics, useAnalytics, useConversion, useDictionary, useDictionaryAsync, useDictionaryDynamic, useExperiment, useIntlayer, useLoadDynamic, useLocale, usePathname };
22
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,yBAAA,CAA0B,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,yBAAA,CAA0B,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;AAwEA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;AAAA,UAGA,YAAA;EACf,KAAA,EAAO,CAAA;EACP,QAAA;EACA,eAAA,GAAkB,CAAA;AAAA;;cAIP,mBAAA,EAAqB,OAAA;;;;KA4BtB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAAuB,QAAA,EAAU,oBAAA;AAAA;;cAIxB,oBAAA,EAAsB,OAAA;AAAA,KA2HvB,YAAA,mBAA+B,aAAA,IAAiB,CAAA;EAC1D,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,QAAA;EACX,IAAA;EACA,QAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,MAAA,OAAa,CAAA;EAChC,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAK1B,cAAA,EAAgB,OAAA;AA3K7B;;;;;AA4BA;;;;KAmLY,cAAA,cAA4B,CAAA;EACtC,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IA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AA;EACA,QAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,MAAA,OAAa,CAAA;EAChC,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAK1B,cAAA,EAAgB,OAAA;AAvL7B;;;;;AAwCA;;;;KAmLY,cAAA,cAA4B,CAAA;EACtC,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,MAAA,OAAa,CAAA;AAAA;;cAM3B,UAAA,EAAY,OAAA;;;AA5LzB;;;;KAsSY,mBAAA,MAAyB,CAAA;EACnC,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,SAAA;AAAA,KAER,IAAA,EAAM,MAAA;AAAA,cAGE,eAAA,EAAiB,OAAA;AAAA,UAgCb,yBAAA,iBAA0C,aAAA;EACzD,mBAAA,EAAqB,gBAAA,CAAiB,CAAA;EACtC,eAAA,EAAiB,YAAA,CAAa,CAAA,EAAG,CAAA,EAAG,CAAA;EACpC,WAAA,EAAa,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EAClC,gBAAA,EAAkB,mBAAA,CAAoB,CAAA;AAAA;;;;;;KAQ5B,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,mBAAA;EACA,eAAA;EACA,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAQ5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
@@ -1,4 +1,4 @@
1
- import * as _$webpack from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@types+webpack@5.28.5+9e3c06e9a1a2edab/node_modules/@types/webpack/index.js";
1
+ import * as _$webpack from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@types+webpack@5.28.5+347853244a8d2414/node_modules/@types/webpack/index.js";
2
2
 
3
3
  //#region src/webpack/mergeConfig.d.ts
4
4
  declare const mergeConfig: (baseConfig: _$webpack.Configuration) => _$webpack.Configuration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-intlayer",
3
- "version": "9.0.0-canary.15",
3
+ "version": "9.0.0-canary.17",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -119,13 +119,13 @@
119
119
  "@babel/core": "^7.26.9",
120
120
  "@babel/plugin-syntax-import-attributes": "7.28.6",
121
121
  "@babel/preset-env": "7.29.2",
122
- "@intlayer/config": "9.0.0-canary.15",
123
- "@intlayer/core": "9.0.0-canary.15",
124
- "@intlayer/dictionaries-entry": "9.0.0-canary.15",
125
- "@intlayer/editor": "9.0.0-canary.15",
126
- "@intlayer/engine": "9.0.0-canary.15",
127
- "@intlayer/types": "9.0.0-canary.15",
128
- "@intlayer/webpack": "9.0.0-canary.15",
122
+ "@intlayer/config": "9.0.0-canary.17",
123
+ "@intlayer/core": "9.0.0-canary.17",
124
+ "@intlayer/dictionaries-entry": "9.0.0-canary.17",
125
+ "@intlayer/editor": "9.0.0-canary.17",
126
+ "@intlayer/engine": "9.0.0-canary.17",
127
+ "@intlayer/types": "9.0.0-canary.17",
128
+ "@intlayer/webpack": "9.0.0-canary.17",
129
129
  "babel-loader": "10.1.1",
130
130
  "defu": "6.1.7"
131
131
  },
@@ -141,7 +141,7 @@
141
141
  "rimraf": "6.1.3",
142
142
  "tsdown": "0.21.10",
143
143
  "typescript": "6.0.3",
144
- "vitest": "4.1.9"
144
+ "vitest": "4.1.10"
145
145
  },
146
146
  "peerDependencies": {
147
147
  "@angular/common": ">=15",
@@ -154,6 +154,9 @@
154
154
  "optional": true
155
155
  }
156
156
  },
157
+ "optionalDependencies": {
158
+ "@intlayer/analytics": "9.0.0-canary.17"
159
+ },
157
160
  "engines": {
158
161
  "node": ">=14.18"
159
162
  },