angular-intlayer 9.0.0-canary.14 → 9.0.0-canary.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics/exposureSink.cjs +27 -0
- package/dist/cjs/analytics/exposureSink.cjs.map +1 -0
- package/dist/cjs/analytics/index.cjs +9 -0
- package/dist/cjs/analytics/useAnalytics.cjs +85 -0
- package/dist/cjs/analytics/useAnalytics.cjs.map +1 -0
- package/dist/cjs/analytics/useConversion.cjs +37 -0
- package/dist/cjs/analytics/useConversion.cjs.map +1 -0
- package/dist/cjs/analytics/useExperiment.cjs +70 -0
- package/dist/cjs/analytics/useExperiment.cjs.map +1 -0
- package/dist/cjs/client/installIntlayer.cjs +9 -4
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/plugins.cjs +21 -12
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/analytics/exposureSink.mjs +24 -0
- package/dist/esm/analytics/exposureSink.mjs.map +1 -0
- package/dist/esm/analytics/index.mjs +5 -0
- package/dist/esm/analytics/useAnalytics.mjs +82 -0
- package/dist/esm/analytics/useAnalytics.mjs.map +1 -0
- package/dist/esm/analytics/useConversion.mjs +35 -0
- package/dist/esm/analytics/useConversion.mjs.map +1 -0
- package/dist/esm/analytics/useExperiment.mjs +68 -0
- package/dist/esm/analytics/useExperiment.mjs.map +1 -0
- package/dist/esm/client/installIntlayer.mjs +9 -4
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/esbuild/plugin.mjs +2 -2
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/plugins.mjs +21 -12
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/webpack/mergeConfig.mjs +1 -1
- package/dist/types/analytics/exposureSink.d.ts +33 -0
- package/dist/types/analytics/exposureSink.d.ts.map +1 -0
- package/dist/types/analytics/index.d.ts +4 -0
- package/dist/types/analytics/useAnalytics.d.ts +38 -0
- package/dist/types/analytics/useAnalytics.d.ts.map +1 -0
- package/dist/types/analytics/useConversion.d.ts +34 -0
- package/dist/types/analytics/useConversion.d.ts.map +1 -0
- package/dist/types/analytics/useExperiment.d.ts +48 -0
- package/dist/types/analytics/useExperiment.d.ts.map +1 -0
- package/dist/types/client/installIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +2 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +2 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +2 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +2 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +2 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +2 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +2 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +2 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/packages/intlayer/dist/types/index.d.ts +4 -0
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/webpack/mergeConfig.d.ts +1 -1
- 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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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":"
|
|
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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
3
|
-
import { getAppLogger } from "@intlayer/config/logger";
|
|
4
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
5
3
|
import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
4
|
+
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
5
|
+
import { getAppLogger } from "@intlayer/config/logger";
|
|
6
6
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
7
7
|
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
8
8
|
import { logConfigDetails } from "@intlayer/engine/cli";
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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 };
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -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 }) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 : {
|
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 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 return plugins;\n};\n"],"mappings":";;;;;;;;AA2BA,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;I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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,QAC7C,gBAAe;GACb,eAAe,KAAK;GACpB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,UAAU;GACX,CAAC;AAGJ,SAAO,mBAAmB;GACxB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WACE,QAAQ,IAAI,4BAA4B,WAAW,CAAC,OAAO,UACvD,WACA;IACN,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACf;IACS;IACX;GACF,CAAC;;CAEL;;AAWD,MAAa,uBACX,QAAQ,IAAI,gCA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AI,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
5
|
import { getAlias } from "@intlayer/config/utils";
|
|
5
|
-
import { createRequire } from "node:module";
|
|
6
6
|
import { IntlayerPlugin } from "@intlayer/webpack";
|
|
7
7
|
import { defu } from "defu";
|
|
8
8
|
|
|
@@ -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":";;;;;;;
|
|
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,5 @@
|
|
|
1
|
+
import { Locale } from "../packages/intlayer/dist/types/index.js";
|
|
1
2
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useLocaleStorage.d.ts
|
|
5
5
|
/**
|
|
@@ -8,13 +8,13 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
8
8
|
/**
|
|
9
9
|
* Get the locale cookie
|
|
10
10
|
*/
|
|
11
|
-
declare const localeInStorage:
|
|
11
|
+
declare const localeInStorage: Locale;
|
|
12
12
|
/**
|
|
13
13
|
* @deprecated Use localeInStorage instead
|
|
14
14
|
*
|
|
15
15
|
* Get the locale cookie
|
|
16
16
|
*/
|
|
17
|
-
declare const localeCookie:
|
|
17
|
+
declare const localeCookie: Locale;
|
|
18
18
|
/**
|
|
19
19
|
* Set the locale cookie
|
|
20
20
|
*/
|
|
@@ -29,7 +29,7 @@ declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean)
|
|
|
29
29
|
* Hook that provides the locale storage and a function to set it
|
|
30
30
|
*/
|
|
31
31
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
32
|
-
getLocale: () =>
|
|
32
|
+
getLocale: () => Locale;
|
|
33
33
|
setLocale: (locale: LocalesValues) => void;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
@@ -40,7 +40,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
40
40
|
* Hook that provides the locale cookie and a function to set it
|
|
41
41
|
*/
|
|
42
42
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
43
|
-
localeCookie:
|
|
43
|
+
localeCookie: Locale;
|
|
44
44
|
setLocaleCookie: (locale: LocalesValues) => void;
|
|
45
45
|
};
|
|
46
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;AAcA;;;AAAA,cAAa,eAAA,EAAkE,
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;AAcA;;;AAAA,cAAa,eAAA,EAAkE,MAAA;;AAM/E;;;;cAAa,YAAA,EAA8B,MAAA;AAK3C;;;AAAA,cAAa,kBAAA,GACX,MAAA,EAAQ,aAAA,EACR,eAAA;;;;;;cAYW,eAAA,GAAe,MAAA,EAblB,aAAA,EAAa,eAAA;;;;cAkBV,gBAAA,GAAoB,eAAA;mBAI7B,MAAA;sBAAA,aAAA;AAAA;;AAJJ;;;;;;cAaa,eAAA,GAAmB,eAAA;gBAO/B,MAAA;4BAAA,aAAA;AAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { LocalesValues } from "../packages/intlayer/dist/types/index.js";
|
|
1
2
|
import * as _$_angular_core0 from "@angular/core";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/format/useCompact.d.ts
|
|
5
5
|
declare const useCompact: () => _$_angular_core0.Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
6
|
-
locale?:
|
|
6
|
+
locale?: LocalesValues;
|
|
7
7
|
}) => string>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";;;;cAIa,UAAA,yBAAU,MAAA,EAAA,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";;;;cAIa,UAAA,yBAAU,MAAA,EAAA,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,aAAA;AAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { LocalesValues } from "../packages/intlayer/dist/types/index.js";
|
|
1
2
|
import * as _$_angular_core0 from "@angular/core";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/format/useCurrency.d.ts
|
|
5
5
|
declare const useCurrency: () => _$_angular_core0.Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
6
|
-
locale?:
|
|
6
|
+
locale?: LocalesValues;
|
|
7
7
|
}) => string>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";;;;cAIa,WAAA,yBAAW,MAAA,EAAA,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";;;;cAIa,WAAA,yBAAW,MAAA,EAAA,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,aAAA;AAAA"}
|