angular-intlayer 9.3.2 → 9.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/esbuild/plugin.cjs +30 -2
- package/dist/cjs/esbuild/plugin.cjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/esbuild/plugin.mjs +31 -2
- package/dist/esm/esbuild/plugin.mjs.map +1 -1
- package/dist/esm/webpack/mergeConfig.mjs +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -4
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/esbuild/plugin.d.ts +14 -0
- package/dist/types/esbuild/plugin.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +2 -1
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +2 -1
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +2 -1
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +2 -1
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +2 -1
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +2 -1
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +2 -1
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +2 -1
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/intlayer/dist/types/index.d.ts +14 -0
- package/package.json +8 -8
|
@@ -43,7 +43,7 @@ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
|
43
43
|
}
|
|
44
44
|
const locale = typeof localeOrSelector === "string" ? localeOrSelector : void 0;
|
|
45
45
|
const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer?.locale() ?? _intlayer_config_built.internationalization.defaultLocale);
|
|
46
|
-
const dictionary = require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.());
|
|
46
|
+
const dictionary = (0, _intlayer_core_dictionaryManipulator.getPreloadedDictionary)(dictionaryPromise, localeTarget()) ?? require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.());
|
|
47
47
|
return require_client_useDictionary.useDictionary(dictionary, localeTarget());
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["inject","INTLAYER_TOKEN","isQualifiedDynamicLoaderMap","parseDictionarySelector","resolveDictionaryArgument","internationalization","signal","getDictionary","computed","useLoadDynamic","useDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: intlayer?.locale(),\n contextVariant: intlayer?.variant?.(),\n dictionaryKey: String(key),\n })\n );\n\n const localeTarget = selectorLocale ?? internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["inject","INTLAYER_TOKEN","isQualifiedDynamicLoaderMap","parseDictionarySelector","resolveDictionaryArgument","internationalization","signal","getDictionary","computed","getPreloadedDictionary","useLoadDynamic","useDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: intlayer?.locale(),\n contextVariant: intlayer?.variant?.(),\n dictionaryKey: String(key),\n })\n );\n\n const localeTarget = selectorLocale ?? internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Using it directly skips `useLoadDynamic`, whose signal\n // starts empty and only fills in on the promise callback — one frame of blank\n // content per dictionary, even when nothing has to be fetched.\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryPromise,\n localeTarget()\n );\n\n const dictionary =\n (preloadedDictionary as T | undefined) ??\n (useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n (dictionaryPromise as any)[localeTarget()]?.()\n ) as T);\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,eAAWA,sBAAyBC,2CAAc;CAExD,IACE,QAAQ,IAAI,iCAAiC,eAC7CC,kEAA4B,iBAAiB,GAC7C;EAGA,MAAM,EAAE,QAAQ,gBAAgB,iBAC9BC,kEACEC,gEAA0B;GACxB;GACA,eAAe,UAAU,OAAO;GAChC,gBAAgB,UAAU,UAAU;GACpC,eAAe,OAAO,GAAG;EAC3B,CAAC,CACH;EAEF,MAAM,eAAe,kBAAkBC,4CAAqB;EAE5D,MAAM,gBAAYC,sBAAgB,MAAS;EAE3C,8EAAoC;GAClC,WAAW;GACX,KAAK,OAAO,GAAG;GACf,QAAQ;GACR;GACA,YAAY,eAAeC,oCAAc,YAAY,YAAY;EACnE,CAAC,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,QAAQ,CAAC;EAE7C,WAAOC,8BAAe,UAAU,CAAQ;CAC1C;CAEA,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,mBAAeA,8BACb,UAAU,UAAU,OAAO,KAAKH,4CAAqB,aAC7D;CAWA,MAAM,iBALsBI,6DAC1B,mBACA,aAAa,CAIM,KAClBC,6CACC,GAAG,OAAO,GAAG,EAAE,GAAG,aAAa,KAC9B,kBAA0B,aAAa,EAAE,GAAG,CAC/C;CAEF,OAAOC,2CAAc,YAAY,aAAa,CAAQ;AACxD"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
let node_module = require("node:module");
|
|
2
4
|
let node_path = require("node:path");
|
|
3
|
-
let
|
|
4
|
-
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
5
|
+
let _intlayer_config_dictionaryPreload = require("@intlayer/config/dictionaryPreload");
|
|
5
6
|
let _intlayer_config_envVars = require("@intlayer/config/envVars");
|
|
6
7
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
8
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
9
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
7
10
|
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
8
11
|
let _intlayer_engine_build = require("@intlayer/engine/build");
|
|
9
12
|
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
@@ -11,6 +14,18 @@ let _intlayer_engine_watcher = require("@intlayer/engine/watcher");
|
|
|
11
14
|
|
|
12
15
|
//#region src/esbuild/plugin.ts
|
|
13
16
|
/**
|
|
17
|
+
* Absolute id of the locale resolver the injected preamble imports.
|
|
18
|
+
*
|
|
19
|
+
* Resolved from this package, which declares `@intlayer/core` as a dependency,
|
|
20
|
+
* rather than left bare in the emitted source: the importer is a generated
|
|
21
|
+
* entry point under the application's `.intlayer` directory, and an application
|
|
22
|
+
* only depends on `intlayer` and its framework binding, so the bare specifier
|
|
23
|
+
* would resolve from a tree that need not contain the package at all.
|
|
24
|
+
*
|
|
25
|
+
* This package ships both module formats, hence the `require` fallback.
|
|
26
|
+
*/
|
|
27
|
+
const preloadModuleId = (0, _intlayer_config_utils.normalizePath)((0, _intlayer_config_dictionaryPreload.resolvePreloadModuleId)(typeof require !== "undefined" ? require : (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)));
|
|
28
|
+
/**
|
|
14
29
|
* esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.
|
|
15
30
|
*
|
|
16
31
|
* Handles:
|
|
@@ -86,6 +101,19 @@ const intlayerEsbuildPlugin = (options) => {
|
|
|
86
101
|
const escapedFrom = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
87
102
|
build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({ path: to }));
|
|
88
103
|
}
|
|
104
|
+
if (config.build.dictionariesPreload) {
|
|
105
|
+
const dynamicDictionariesDir = (0, _intlayer_config_utils.normalizePath)(config.system.dynamicDictionariesDir);
|
|
106
|
+
build.onLoad({ filter: (0, _intlayer_config_dictionaryPreload.createDynamicEntryFilter)(dynamicDictionariesDir) }, async ({ path }) => {
|
|
107
|
+
if (!(0, _intlayer_config_utils.normalizePath)(path).startsWith(`${dynamicDictionariesDir}/`)) return null;
|
|
108
|
+
const code = await (0, node_fs_promises.readFile)(path, "utf-8");
|
|
109
|
+
const result = (0, _intlayer_config_dictionaryPreload.addDynamicEntryPreload)(code, preloadModuleId);
|
|
110
|
+
if (result.skipped) return null;
|
|
111
|
+
return {
|
|
112
|
+
contents: result.code,
|
|
113
|
+
loader: "js"
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
89
117
|
if (!preparePromise) preparePromise = (0, _intlayer_engine_build.prepareIntlayer)(config, {
|
|
90
118
|
clean: isProduction,
|
|
91
119
|
cacheTimeoutMs: isProduction ? 3e4 : 36e5,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["getConfiguration","getAlias","join","getAppLogger","getConfigEnvVars","getDictionaries","getUnusedNodeTypesAsync","formatNodeTypeToEnvVar","formatDictionarySelectorEnvVar","getHasDictionarySelector","prepareIntlayer","watch"],"sources":["../../../src/esbuild/plugin.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { watch } from '@intlayer/engine/watcher';\n\n// Minimal subset of the esbuild Plugin interface to avoid a hard dependency on\n// the `esbuild` package for type resolution. The shape is compatible with\n// esbuild >=0.17, `@angular-builders/custom-esbuild`, and NX esbuild builders.\nexport interface EsbuildPluginBuild {\n initialOptions: {\n alias?: Record<string, string>;\n define?: Record<string, string>;\n minify?: boolean;\n watch?: unknown;\n /** Absolute working directory of the esbuild context (set by Angular's builder). */\n absWorkingDir?: string;\n };\n onStart(callback: () => void | Promise<void>): void;\n /** Intercept module resolution — works even for imports inside node_modules. */\n onResolve(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n importer: string;\n namespace: string;\n resolveDir: string;\n }) => { path: string; namespace?: string } | null | undefined\n ): void;\n}\n\nexport interface EsbuildPlugin {\n name: string;\n setup(build: EsbuildPluginBuild): void | Promise<void>;\n}\n\nexport type IntlayerEsbuildPluginOptions = {\n configOptions?: GetConfigurationOptions;\n /**\n * Whether to start the Intlayer file watcher for dictionary regeneration.\n * - `true`: always start the watcher (useful for `ng serve`)\n * - `false`: never start the watcher (useful for `ng build`)\n * - `undefined` (default): auto-detect based on the build context\n * (skips the watcher when a production build is detected)\n */\n watch?: boolean;\n};\n\n/**\n * esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.\n *\n * Handles:\n * 1. Injecting `alias` entries so `@intlayer/dictionaries-entry` etc. resolve to\n * the generated files under `.intlayer/`.\n * 2. Defining `process.env.*` tree-shaking constants for production builds.\n * 3. Running `prepareIntlayer` (dictionary generation) before the first build.\n * 4. Starting the chokidar file-watcher in dev / serve mode.\n *\n * Compatible with:\n * - `@angular-builders/custom-esbuild` (`application` or `browser-esbuild` builder)\n * - NX `@nx/angular:browser-esbuild`\n * - Any raw esbuild setup that accepts the standard `Plugin` interface\n *\n * @example\n * ```ts\n * // esbuild.plugins.ts (referenced from angular.json \"plugins\" option)\n * import { intlayerEsbuildPlugin } from 'angular-intlayer/esbuild';\n * export default [intlayerEsbuildPlugin()];\n * ```\n */\nexport const intlayerEsbuildPlugin = (\n options?: IntlayerEsbuildPluginOptions\n): EsbuildPlugin => {\n // All Node.js-heavy initialization (getConfiguration, getAlias, …) is deferred\n // into setup() so it runs in esbuild's Node.js context, not at module-evaluation\n // time. @angular/build loads the plugin file through Vite's SSR module runner\n // (ESM) where CommonJS globals like __filename are undefined. Calling\n // getConfiguration() here would trigger: buildSync → worker threads →\n // __filename → ReferenceError, crashing the plugin before setup() ever runs.\n let config: ReturnType<typeof getConfiguration> | null = null;\n let alias: Record<string, string> | null = null;\n\n // Shared across parallel setup() calls (Angular spawns one per bundle context).\n let preparePromise: Promise<void> | null = null;\n let watcherStarted = false;\n // Once any esbuild context (browser or server) detects a production build,\n // suppress the watcher for all contexts so `ng build` can exit cleanly.\n let isBuildMode = false;\n\n return {\n name: 'intlayer',\n\n async setup(build) {\n if (!config) {\n const baseDir =\n build.initialOptions.absWorkingDir ??\n options?.configOptions?.baseDir ??\n process.cwd();\n\n config = getConfiguration({ baseDir, ...options?.configOptions });\n logConfigDetails({ baseDir, ...options?.configOptions });\n\n alias = getAlias({\n configuration: config,\n formatter: (value: string) => join(config!.system.baseDir, value),\n });\n }\n\n const appLogger = getAppLogger(config);\n const nodeEnvDefine =\n build.initialOptions.define?.['process.env.NODE_ENV'];\n\n // Angular's esbuild builder doesn't set `minify` or `process.env.NODE_ENV`\n // on initialOptions — it handles optimisation through its own pipeline.\n // Instead, Angular defines `ngDevMode` as `\"false\"` in production builds.\n const isProduction =\n nodeEnvDefine === '\"production\"' ||\n nodeEnvDefine === \"'production'\" ||\n build.initialOptions.minify === true ||\n build.initialOptions.define?.['ngDevMode'] === 'false';\n\n if (isProduction) {\n isBuildMode = true;\n }\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n const envVars: Record<string, string> = {\n // Catch-all so that any `process.env.*` read NOT covered by a specific\n // key below resolves to `undefined` instead of dereferencing a bare\n // `process`, which is not defined in browser bundles and throws\n // `process is not defined`. esbuild resolves the most specific define\n // first, so the keys below keep their tree-shaking effect.\n 'process.env': '{}',\n [wrapKey('INTLAYER')]: wrapValue('true'),\n [wrapKey('NODE_ENV')]: wrapValue(\n isProduction ? 'production' : 'development'\n ),\n // Tree shaking flags derived from the config (routing / storage /\n // editor). Emitted in every mode so behaviour is consistent in dev.\n ...getConfigEnvVars(config, wrapKey, wrapValue),\n };\n\n if (isProduction) {\n const dictionaries = getDictionaries(config);\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n Object.assign(\n envVars,\n // Tree shaking based on unused node types\n formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n )\n );\n }\n\n // Existing defines (Angular's own, or the user's angular.json `define`\n // block) take precedence over the Intlayer ones.\n build.initialOptions.define = {\n ...envVars,\n ...(build.initialOptions.define ?? {}),\n };\n\n build.initialOptions.alias = {\n ...alias,\n ...(build.initialOptions.alias ?? {}),\n };\n\n for (const [from, to] of Object.entries(alias!)) {\n const escapedFrom = from.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({\n path: to,\n }));\n }\n\n if (!preparePromise) {\n preparePromise = prepareIntlayer(config, {\n clean: isProduction,\n cacheTimeoutMs: isProduction ? 1000 * 30 : 1000 * 60 * 60,\n env: isProduction ? 'prod' : 'dev',\n });\n }\n\n await preparePromise;\n\n build.onStart(async () => {\n // Determine whether the watcher should run:\n // 1. Explicit option from the caller takes precedence\n // 2. If any esbuild context detected a production build, skip\n // 3. esbuild's own watch mode is a positive signal\n const shouldWatch = options?.watch ?? !isBuildMode;\n\n if (shouldWatch && !watcherStarted) {\n watcherStarted = true;\n\n await watch({ configuration: config! });\n }\n });\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAa,yBACX,YACkB;CAOlB,IAAI,SAAqD;CACzD,IAAI,QAAuC;CAG3C,IAAI,iBAAuC;CAC3C,IAAI,iBAAiB;CAGrB,IAAI,cAAc;CAElB,OAAO;EACL,MAAM;EAEN,MAAM,MAAM,OAAO;GACjB,IAAI,CAAC,QAAQ;IACX,MAAM,UACJ,MAAM,eAAe,iBACrB,SAAS,eAAe,WACxB,QAAQ,IAAI;IAEd,aAASA,wCAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAChE,2CAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAEvD,YAAQC,iCAAS;KACf,eAAe;KACf,YAAY,cAAkBC,gBAAK,OAAQ,OAAO,SAAS,KAAK;IAClE,CAAC;GACH;GAEA,MAAM,gBAAYC,sCAAa,MAAM;GACrC,MAAM,gBACJ,MAAM,eAAe,SAAS;GAKhC,MAAM,eACJ,kBAAkB,oBAClB,kBAAkB,kBAClB,MAAM,eAAe,WAAW,QAChC,MAAM,eAAe,SAAS,iBAAiB;GAEjD,IAAI,cACF,cAAc;GAGhB,MAAM,WAAW,QAAgB,eAAe;GAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;GAE/C,MAAM,UAAkC;IAMtC,eAAe;KACd,QAAQ,UAAU,IAAI,UAAU,MAAM;KACtC,QAAQ,UAAU,IAAI,UACrB,eAAe,eAAe,aAChC;IAGA,OAAGC,2CAAiB,QAAQ,SAAS,SAAS;GAChD;GAEA,IAAI,cAAc;IAChB,MAAM,mBAAeC,8CAAgB,MAAM;IAC3C,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;IAGH,MAAM,kBAAkB,UAAMC,gDAAwB,YAAY;IAClE,OAAO,OACL,aAEAC,iDAAuB,iBAAiB,SAAS,SAAS,OAG1DC,6DACEC,iDAAyB,YAAY,GACrC,SACA,SACF,CACF;GACF;GAIA,MAAM,eAAe,SAAS;IAC5B,GAAG;IACH,GAAI,MAAM,eAAe,UAAU,CAAC;GACtC;GAEA,MAAM,eAAe,QAAQ;IAC3B,GAAG;IACH,GAAI,MAAM,eAAe,SAAS,CAAC;GACrC;GAEA,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,KAAM,GAAG;IAC/C,MAAM,cAAc,KAAK,QAAQ,uBAAuB,MAAM;IAE9D,MAAM,UAAU,EAAE,QAAQ,IAAI,OAAO,IAAI,YAAY,EAAE,EAAE,UAAU,EACjE,MAAM,GACR,EAAE;GACJ;GAEA,IAAI,CAAC,gBACH,qBAAiBC,wCAAgB,QAAQ;IACvC,OAAO;IACP,gBAAgB,eAAe,MAAY;IAC3C,KAAK,eAAe,SAAS;GAC/B,CAAC;GAGH,MAAM;GAEN,MAAM,QAAQ,YAAY;IAOxB,KAFoB,SAAS,SAAS,CAAC,gBAEpB,CAAC,gBAAgB;KAClC,iBAAiB;KAEjB,UAAMC,gCAAM,EAAE,eAAe,OAAQ,CAAC;IACxC;GACF,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["normalizePath","resolvePreloadModuleId","createRequire","getConfiguration","getAlias","join","getAppLogger","getConfigEnvVars","getDictionaries","getUnusedNodeTypesAsync","formatNodeTypeToEnvVar","formatDictionarySelectorEnvVar","getHasDictionarySelector","createDynamicEntryFilter","readFile","addDynamicEntryPreload","prepareIntlayer","watch"],"sources":["../../../src/esbuild/plugin.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport {\n addDynamicEntryPreload,\n createDynamicEntryFilter,\n resolvePreloadModuleId,\n} from '@intlayer/config/dictionaryPreload';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { watch } from '@intlayer/engine/watcher';\n\n/**\n * Absolute id of the locale resolver the injected preamble imports.\n *\n * Resolved from this package, which declares `@intlayer/core` as a dependency,\n * rather than left bare in the emitted source: the importer is a generated\n * entry point under the application's `.intlayer` directory, and an application\n * only depends on `intlayer` and its framework binding, so the bare specifier\n * would resolve from a tree that need not contain the package at all.\n *\n * This package ships both module formats, hence the `require` fallback.\n */\nconst preloadModuleId = normalizePath(\n resolvePreloadModuleId(\n typeof require !== 'undefined' ? require : createRequire(import.meta.url)\n )\n);\n\n// Minimal subset of the esbuild Plugin interface to avoid a hard dependency on\n// the `esbuild` package for type resolution. The shape is compatible with\n// esbuild >=0.17, `@angular-builders/custom-esbuild`, and NX esbuild builders.\nexport interface EsbuildPluginBuild {\n initialOptions: {\n alias?: Record<string, string>;\n define?: Record<string, string>;\n minify?: boolean;\n watch?: unknown;\n /** Absolute working directory of the esbuild context (set by Angular's builder). */\n absWorkingDir?: string;\n };\n onStart(callback: () => void | Promise<void>): void;\n /** Intercept module resolution — works even for imports inside node_modules. */\n onResolve(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n importer: string;\n namespace: string;\n resolveDir: string;\n }) => { path: string; namespace?: string } | null | undefined\n ): void;\n /** Intercept module contents, so a resolved file can be rewritten. */\n onLoad(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n namespace: string;\n }) =>\n | { contents: string; loader?: string }\n | null\n | undefined\n | Promise<{ contents: string; loader?: string } | null | undefined>\n ): void;\n}\n\nexport interface EsbuildPlugin {\n name: string;\n setup(build: EsbuildPluginBuild): void | Promise<void>;\n}\n\nexport type IntlayerEsbuildPluginOptions = {\n configOptions?: GetConfigurationOptions;\n /**\n * Whether to start the Intlayer file watcher for dictionary regeneration.\n * - `true`: always start the watcher (useful for `ng serve`)\n * - `false`: never start the watcher (useful for `ng build`)\n * - `undefined` (default): auto-detect based on the build context\n * (skips the watcher when a production build is detected)\n */\n watch?: boolean;\n};\n\n/**\n * esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.\n *\n * Handles:\n * 1. Injecting `alias` entries so `@intlayer/dictionaries-entry` etc. resolve to\n * the generated files under `.intlayer/`.\n * 2. Defining `process.env.*` tree-shaking constants for production builds.\n * 3. Running `prepareIntlayer` (dictionary generation) before the first build.\n * 4. Starting the chokidar file-watcher in dev / serve mode.\n *\n * Compatible with:\n * - `@angular-builders/custom-esbuild` (`application` or `browser-esbuild` builder)\n * - NX `@nx/angular:browser-esbuild`\n * - Any raw esbuild setup that accepts the standard `Plugin` interface\n *\n * @example\n * ```ts\n * // esbuild.plugins.ts (referenced from angular.json \"plugins\" option)\n * import { intlayerEsbuildPlugin } from 'angular-intlayer/esbuild';\n * export default [intlayerEsbuildPlugin()];\n * ```\n */\nexport const intlayerEsbuildPlugin = (\n options?: IntlayerEsbuildPluginOptions\n): EsbuildPlugin => {\n // All Node.js-heavy initialization (getConfiguration, getAlias, …) is deferred\n // into setup() so it runs in esbuild's Node.js context, not at module-evaluation\n // time. @angular/build loads the plugin file through Vite's SSR module runner\n // (ESM) where CommonJS globals like __filename are undefined. Calling\n // getConfiguration() here would trigger: buildSync → worker threads →\n // __filename → ReferenceError, crashing the plugin before setup() ever runs.\n let config: ReturnType<typeof getConfiguration> | null = null;\n let alias: Record<string, string> | null = null;\n\n // Shared across parallel setup() calls (Angular spawns one per bundle context).\n let preparePromise: Promise<void> | null = null;\n let watcherStarted = false;\n // Once any esbuild context (browser or server) detects a production build,\n // suppress the watcher for all contexts so `ng build` can exit cleanly.\n let isBuildMode = false;\n\n return {\n name: 'intlayer',\n\n async setup(build) {\n if (!config) {\n const baseDir =\n build.initialOptions.absWorkingDir ??\n options?.configOptions?.baseDir ??\n process.cwd();\n\n config = getConfiguration({ baseDir, ...options?.configOptions });\n logConfigDetails({ baseDir, ...options?.configOptions });\n\n alias = getAlias({\n configuration: config,\n formatter: (value: string) => join(config!.system.baseDir, value),\n });\n }\n\n const appLogger = getAppLogger(config);\n const nodeEnvDefine =\n build.initialOptions.define?.['process.env.NODE_ENV'];\n\n // Angular's esbuild builder doesn't set `minify` or `process.env.NODE_ENV`\n // on initialOptions — it handles optimisation through its own pipeline.\n // Instead, Angular defines `ngDevMode` as `\"false\"` in production builds.\n const isProduction =\n nodeEnvDefine === '\"production\"' ||\n nodeEnvDefine === \"'production'\" ||\n build.initialOptions.minify === true ||\n build.initialOptions.define?.['ngDevMode'] === 'false';\n\n if (isProduction) {\n isBuildMode = true;\n }\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n const envVars: Record<string, string> = {\n // Catch-all so that any `process.env.*` read NOT covered by a specific\n // key below resolves to `undefined` instead of dereferencing a bare\n // `process`, which is not defined in browser bundles and throws\n // `process is not defined`. esbuild resolves the most specific define\n // first, so the keys below keep their tree-shaking effect.\n 'process.env': '{}',\n [wrapKey('INTLAYER')]: wrapValue('true'),\n [wrapKey('NODE_ENV')]: wrapValue(\n isProduction ? 'production' : 'development'\n ),\n // Tree shaking flags derived from the config (routing / storage /\n // editor). Emitted in every mode so behaviour is consistent in dev.\n ...getConfigEnvVars(config, wrapKey, wrapValue),\n };\n\n if (isProduction) {\n const dictionaries = getDictionaries(config);\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n Object.assign(\n envVars,\n // Tree shaking based on unused node types\n formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n )\n );\n }\n\n // Existing defines (Angular's own, or the user's angular.json `define`\n // block) take precedence over the Intlayer ones.\n build.initialOptions.define = {\n ...envVars,\n ...(build.initialOptions.define ?? {}),\n };\n\n build.initialOptions.alias = {\n ...alias,\n ...(build.initialOptions.alias ?? {}),\n };\n\n for (const [from, to] of Object.entries(alias!)) {\n const escapedFrom = from.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({\n path: to,\n }));\n }\n\n // Dictionaries load with the chunk that needs them rather than being\n // fetched once that chunk renders: the entry point starts the browsing\n // locale's load as it evaluates, so a lazily loaded route requests its\n // content on `import()` instead of on first render. Without it every\n // dictionary read renders an empty placeholder first and fills in a tick\n // later.\n //\n // Not gated on the configured `importMode`: a `.content` file can set\n // `importMode: 'dynamic'` on a single dictionary under a `static` or\n // `fetch` global mode, and that dictionary needs the preload just the\n // same. Only entry points the optimizer imported are ever loaded, so the\n // path check below is the accurate gate.\n if (config.build.dictionariesPreload) {\n const dynamicDictionariesDir = normalizePath(\n config.system.dynamicDictionariesDir\n );\n\n build.onLoad(\n { filter: createDynamicEntryFilter(dynamicDictionariesDir) },\n async ({ path }) => {\n const posixPath = normalizePath(path);\n if (!posixPath.startsWith(`${dynamicDictionariesDir}/`))\n return null;\n\n const code = await readFile(path, 'utf-8');\n const result = addDynamicEntryPreload(code, preloadModuleId);\n\n if (result.skipped) return null;\n\n return { contents: result.code, loader: 'js' };\n }\n );\n }\n\n if (!preparePromise) {\n preparePromise = prepareIntlayer(config, {\n clean: isProduction,\n cacheTimeoutMs: isProduction ? 1000 * 30 : 1000 * 60 * 60,\n env: isProduction ? 'prod' : 'dev',\n });\n }\n\n await preparePromise;\n\n build.onStart(async () => {\n // Determine whether the watcher should run:\n // 1. Explicit option from the caller takes precedence\n // 2. If any esbuild context detected a production build, skip\n // 3. esbuild's own watch mode is a positive signal\n const shouldWatch = options?.watch ?? !isBuildMode;\n\n if (shouldWatch && !watcherStarted) {\n watcherStarted = true;\n\n await watch({ configuration: config! });\n }\n });\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAkBA,0CACtBC,2DACE,OAAO,YAAY,cAAc,cAAUC,wEAA6B,CAC1E,CACF;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAa,yBACX,YACkB;CAOlB,IAAI,SAAqD;CACzD,IAAI,QAAuC;CAG3C,IAAI,iBAAuC;CAC3C,IAAI,iBAAiB;CAGrB,IAAI,cAAc;CAElB,OAAO;EACL,MAAM;EAEN,MAAM,MAAM,OAAO;GACjB,IAAI,CAAC,QAAQ;IACX,MAAM,UACJ,MAAM,eAAe,iBACrB,SAAS,eAAe,WACxB,QAAQ,IAAI;IAEd,aAASC,wCAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAChE,2CAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAEvD,YAAQC,iCAAS;KACf,eAAe;KACf,YAAY,cAAkBC,gBAAK,OAAQ,OAAO,SAAS,KAAK;IAClE,CAAC;GACH;GAEA,MAAM,gBAAYC,sCAAa,MAAM;GACrC,MAAM,gBACJ,MAAM,eAAe,SAAS;GAKhC,MAAM,eACJ,kBAAkB,oBAClB,kBAAkB,kBAClB,MAAM,eAAe,WAAW,QAChC,MAAM,eAAe,SAAS,iBAAiB;GAEjD,IAAI,cACF,cAAc;GAGhB,MAAM,WAAW,QAAgB,eAAe;GAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;GAE/C,MAAM,UAAkC;IAMtC,eAAe;KACd,QAAQ,UAAU,IAAI,UAAU,MAAM;KACtC,QAAQ,UAAU,IAAI,UACrB,eAAe,eAAe,aAChC;IAGA,OAAGC,2CAAiB,QAAQ,SAAS,SAAS;GAChD;GAEA,IAAI,cAAc;IAChB,MAAM,mBAAeC,8CAAgB,MAAM;IAC3C,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;IAGH,MAAM,kBAAkB,UAAMC,gDAAwB,YAAY;IAClE,OAAO,OACL,aAEAC,iDAAuB,iBAAiB,SAAS,SAAS,OAG1DC,6DACEC,iDAAyB,YAAY,GACrC,SACA,SACF,CACF;GACF;GAIA,MAAM,eAAe,SAAS;IAC5B,GAAG;IACH,GAAI,MAAM,eAAe,UAAU,CAAC;GACtC;GAEA,MAAM,eAAe,QAAQ;IAC3B,GAAG;IACH,GAAI,MAAM,eAAe,SAAS,CAAC;GACrC;GAEA,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,KAAM,GAAG;IAC/C,MAAM,cAAc,KAAK,QAAQ,uBAAuB,MAAM;IAE9D,MAAM,UAAU,EAAE,QAAQ,IAAI,OAAO,IAAI,YAAY,EAAE,EAAE,UAAU,EACjE,MAAM,GACR,EAAE;GACJ;GAcA,IAAI,OAAO,MAAM,qBAAqB;IACpC,MAAM,6BAAyBZ,sCAC7B,OAAO,OAAO,sBAChB;IAEA,MAAM,OACJ,EAAE,YAAQa,6DAAyB,sBAAsB,EAAE,GAC3D,OAAO,EAAE,WAAW;KAElB,IAAI,KADcb,sCAAc,IACnB,CAAC,CAAC,WAAW,GAAG,uBAAuB,EAAE,GACpD,OAAO;KAET,MAAM,OAAO,UAAMc,2BAAS,MAAM,OAAO;KACzC,MAAM,aAASC,2DAAuB,MAAM,eAAe;KAE3D,IAAI,OAAO,SAAS,OAAO;KAE3B,OAAO;MAAE,UAAU,OAAO;MAAM,QAAQ;KAAK;IAC/C,CACF;GACF;GAEA,IAAI,CAAC,gBACH,qBAAiBC,wCAAgB,QAAQ;IACvC,OAAO;IACP,gBAAgB,eAAe,MAAY;IAC3C,KAAK,eAAe,SAAS;GAC/B,CAAC;GAGH,MAAM;GAEN,MAAM,QAAQ,YAAY;IAOxB,KAFoB,SAAS,SAAS,CAAC,gBAEpB,CAAC,gBAAgB;KAClC,iBAAiB;KAEjB,UAAMC,gCAAM,EAAE,eAAe,OAAQ,CAAC;IACxC;GACF,CAAC;EACH;CACF;AACF"}
|
|
@@ -6,7 +6,7 @@ import { useDictionary } from "./useDictionary.mjs";
|
|
|
6
6
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
7
7
|
import { internationalization } from "@intlayer/config/built";
|
|
8
8
|
import { computed, inject, signal } from "@angular/core";
|
|
9
|
-
import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContentAsync } from "@intlayer/core/dictionaryManipulator";
|
|
9
|
+
import { getPreloadedDictionary, isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContentAsync } from "@intlayer/core/dictionaryManipulator";
|
|
10
10
|
|
|
11
11
|
//#region src/client/useDictionaryDynamic.ts
|
|
12
12
|
/**
|
|
@@ -42,7 +42,7 @@ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
|
42
42
|
}
|
|
43
43
|
const locale = typeof localeOrSelector === "string" ? localeOrSelector : void 0;
|
|
44
44
|
const localeTarget = computed(() => locale ?? intlayer?.locale() ?? internationalization.defaultLocale);
|
|
45
|
-
const dictionary = useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.());
|
|
45
|
+
const dictionary = getPreloadedDictionary(dictionaryPromise, localeTarget()) ?? useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.());
|
|
46
46
|
return useDictionary(dictionary, localeTarget());
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: intlayer?.locale(),\n contextVariant: intlayer?.variant?.(),\n dictionaryKey: String(key),\n })\n );\n\n const localeTarget = selectorLocale ?? internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: intlayer?.locale(),\n contextVariant: intlayer?.variant?.(),\n dictionaryKey: String(key),\n })\n );\n\n const localeTarget = selectorLocale ?? internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Using it directly skips `useLoadDynamic`, whose signal\n // starts empty and only fills in on the promise callback — one frame of blank\n // content per dictionary, even when nothing has to be fetched.\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryPromise,\n localeTarget()\n );\n\n const dictionary =\n (preloadedDictionary as T | undefined) ??\n (useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n (dictionaryPromise as any)[localeTarget()]?.()\n ) as T);\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,WAAW,OAAyB,cAAc;CAExD,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAC7C;EAGA,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,wBACE,0BAA0B;GACxB;GACA,eAAe,UAAU,OAAO;GAChC,gBAAgB,UAAU,UAAU;GACpC,eAAe,OAAO,GAAG;EAC3B,CAAC,CACH;EAEF,MAAM,eAAe,kBAAkB,qBAAqB;EAE5D,MAAM,YAAY,OAAgB,MAAS;EAE3C,oCAAoC;GAClC,WAAW;GACX,KAAK,OAAO,GAAG;GACf,QAAQ;GACR;GACA,YAAY,eAAe,cAAc,YAAY,YAAY;EACnE,CAAC,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,QAAQ,CAAC;EAE7C,OAAO,eAAe,UAAU,CAAQ;CAC1C;CAEA,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,eAAe,eACb,UAAU,UAAU,OAAO,KAAK,qBAAqB,aAC7D;CAWA,MAAM,aALsB,uBAC1B,mBACA,aAAa,CAIM,KAClB,eACC,GAAG,OAAO,GAAG,EAAE,GAAG,aAAa,KAC9B,kBAA0B,aAAa,EAAE,GAAG,CAC/C;CAEF,OAAO,cAAc,YAAY,aAAa,CAAQ;AACxD"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
1
3
|
import { join } from "node:path";
|
|
4
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
5
|
+
import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync, normalizePath } from "@intlayer/config/utils";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { addDynamicEntryPreload, createDynamicEntryFilter, resolvePreloadModuleId } from "@intlayer/config/dictionaryPreload";
|
|
2
8
|
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
3
9
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
4
|
-
import { getConfiguration } from "@intlayer/config/node";
|
|
5
|
-
import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
6
10
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
7
11
|
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
8
12
|
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
@@ -10,6 +14,18 @@ import { watch } from "@intlayer/engine/watcher";
|
|
|
10
14
|
|
|
11
15
|
//#region src/esbuild/plugin.ts
|
|
12
16
|
/**
|
|
17
|
+
* Absolute id of the locale resolver the injected preamble imports.
|
|
18
|
+
*
|
|
19
|
+
* Resolved from this package, which declares `@intlayer/core` as a dependency,
|
|
20
|
+
* rather than left bare in the emitted source: the importer is a generated
|
|
21
|
+
* entry point under the application's `.intlayer` directory, and an application
|
|
22
|
+
* only depends on `intlayer` and its framework binding, so the bare specifier
|
|
23
|
+
* would resolve from a tree that need not contain the package at all.
|
|
24
|
+
*
|
|
25
|
+
* This package ships both module formats, hence the `require` fallback.
|
|
26
|
+
*/
|
|
27
|
+
const preloadModuleId = normalizePath(resolvePreloadModuleId(typeof __require !== "undefined" ? __require : createRequire(import.meta.url)));
|
|
28
|
+
/**
|
|
13
29
|
* esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.
|
|
14
30
|
*
|
|
15
31
|
* Handles:
|
|
@@ -85,6 +101,19 @@ const intlayerEsbuildPlugin = (options) => {
|
|
|
85
101
|
const escapedFrom = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
86
102
|
build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({ path: to }));
|
|
87
103
|
}
|
|
104
|
+
if (config.build.dictionariesPreload) {
|
|
105
|
+
const dynamicDictionariesDir = normalizePath(config.system.dynamicDictionariesDir);
|
|
106
|
+
build.onLoad({ filter: createDynamicEntryFilter(dynamicDictionariesDir) }, async ({ path }) => {
|
|
107
|
+
if (!normalizePath(path).startsWith(`${dynamicDictionariesDir}/`)) return null;
|
|
108
|
+
const code = await readFile(path, "utf-8");
|
|
109
|
+
const result = addDynamicEntryPreload(code, preloadModuleId);
|
|
110
|
+
if (result.skipped) return null;
|
|
111
|
+
return {
|
|
112
|
+
contents: result.code,
|
|
113
|
+
loader: "js"
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
88
117
|
if (!preparePromise) preparePromise = prepareIntlayer(config, {
|
|
89
118
|
clean: isProduction,
|
|
90
119
|
cacheTimeoutMs: isProduction ? 3e4 : 36e5,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/esbuild/plugin.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { watch } from '@intlayer/engine/watcher';\n\n// Minimal subset of the esbuild Plugin interface to avoid a hard dependency on\n// the `esbuild` package for type resolution. The shape is compatible with\n// esbuild >=0.17, `@angular-builders/custom-esbuild`, and NX esbuild builders.\nexport interface EsbuildPluginBuild {\n initialOptions: {\n alias?: Record<string, string>;\n define?: Record<string, string>;\n minify?: boolean;\n watch?: unknown;\n /** Absolute working directory of the esbuild context (set by Angular's builder). */\n absWorkingDir?: string;\n };\n onStart(callback: () => void | Promise<void>): void;\n /** Intercept module resolution — works even for imports inside node_modules. */\n onResolve(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n importer: string;\n namespace: string;\n resolveDir: string;\n }) => { path: string; namespace?: string } | null | undefined\n ): void;\n}\n\nexport interface EsbuildPlugin {\n name: string;\n setup(build: EsbuildPluginBuild): void | Promise<void>;\n}\n\nexport type IntlayerEsbuildPluginOptions = {\n configOptions?: GetConfigurationOptions;\n /**\n * Whether to start the Intlayer file watcher for dictionary regeneration.\n * - `true`: always start the watcher (useful for `ng serve`)\n * - `false`: never start the watcher (useful for `ng build`)\n * - `undefined` (default): auto-detect based on the build context\n * (skips the watcher when a production build is detected)\n */\n watch?: boolean;\n};\n\n/**\n * esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.\n *\n * Handles:\n * 1. Injecting `alias` entries so `@intlayer/dictionaries-entry` etc. resolve to\n * the generated files under `.intlayer/`.\n * 2. Defining `process.env.*` tree-shaking constants for production builds.\n * 3. Running `prepareIntlayer` (dictionary generation) before the first build.\n * 4. Starting the chokidar file-watcher in dev / serve mode.\n *\n * Compatible with:\n * - `@angular-builders/custom-esbuild` (`application` or `browser-esbuild` builder)\n * - NX `@nx/angular:browser-esbuild`\n * - Any raw esbuild setup that accepts the standard `Plugin` interface\n *\n * @example\n * ```ts\n * // esbuild.plugins.ts (referenced from angular.json \"plugins\" option)\n * import { intlayerEsbuildPlugin } from 'angular-intlayer/esbuild';\n * export default [intlayerEsbuildPlugin()];\n * ```\n */\nexport const intlayerEsbuildPlugin = (\n options?: IntlayerEsbuildPluginOptions\n): EsbuildPlugin => {\n // All Node.js-heavy initialization (getConfiguration, getAlias, …) is deferred\n // into setup() so it runs in esbuild's Node.js context, not at module-evaluation\n // time. @angular/build loads the plugin file through Vite's SSR module runner\n // (ESM) where CommonJS globals like __filename are undefined. Calling\n // getConfiguration() here would trigger: buildSync → worker threads →\n // __filename → ReferenceError, crashing the plugin before setup() ever runs.\n let config: ReturnType<typeof getConfiguration> | null = null;\n let alias: Record<string, string> | null = null;\n\n // Shared across parallel setup() calls (Angular spawns one per bundle context).\n let preparePromise: Promise<void> | null = null;\n let watcherStarted = false;\n // Once any esbuild context (browser or server) detects a production build,\n // suppress the watcher for all contexts so `ng build` can exit cleanly.\n let isBuildMode = false;\n\n return {\n name: 'intlayer',\n\n async setup(build) {\n if (!config) {\n const baseDir =\n build.initialOptions.absWorkingDir ??\n options?.configOptions?.baseDir ??\n process.cwd();\n\n config = getConfiguration({ baseDir, ...options?.configOptions });\n logConfigDetails({ baseDir, ...options?.configOptions });\n\n alias = getAlias({\n configuration: config,\n formatter: (value: string) => join(config!.system.baseDir, value),\n });\n }\n\n const appLogger = getAppLogger(config);\n const nodeEnvDefine =\n build.initialOptions.define?.['process.env.NODE_ENV'];\n\n // Angular's esbuild builder doesn't set `minify` or `process.env.NODE_ENV`\n // on initialOptions — it handles optimisation through its own pipeline.\n // Instead, Angular defines `ngDevMode` as `\"false\"` in production builds.\n const isProduction =\n nodeEnvDefine === '\"production\"' ||\n nodeEnvDefine === \"'production'\" ||\n build.initialOptions.minify === true ||\n build.initialOptions.define?.['ngDevMode'] === 'false';\n\n if (isProduction) {\n isBuildMode = true;\n }\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n const envVars: Record<string, string> = {\n // Catch-all so that any `process.env.*` read NOT covered by a specific\n // key below resolves to `undefined` instead of dereferencing a bare\n // `process`, which is not defined in browser bundles and throws\n // `process is not defined`. esbuild resolves the most specific define\n // first, so the keys below keep their tree-shaking effect.\n 'process.env': '{}',\n [wrapKey('INTLAYER')]: wrapValue('true'),\n [wrapKey('NODE_ENV')]: wrapValue(\n isProduction ? 'production' : 'development'\n ),\n // Tree shaking flags derived from the config (routing / storage /\n // editor). Emitted in every mode so behaviour is consistent in dev.\n ...getConfigEnvVars(config, wrapKey, wrapValue),\n };\n\n if (isProduction) {\n const dictionaries = getDictionaries(config);\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n Object.assign(\n envVars,\n // Tree shaking based on unused node types\n formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n )\n );\n }\n\n // Existing defines (Angular's own, or the user's angular.json `define`\n // block) take precedence over the Intlayer ones.\n build.initialOptions.define = {\n ...envVars,\n ...(build.initialOptions.define ?? {}),\n };\n\n build.initialOptions.alias = {\n ...alias,\n ...(build.initialOptions.alias ?? {}),\n };\n\n for (const [from, to] of Object.entries(alias!)) {\n const escapedFrom = from.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({\n path: to,\n }));\n }\n\n if (!preparePromise) {\n preparePromise = prepareIntlayer(config, {\n clean: isProduction,\n cacheTimeoutMs: isProduction ? 1000 * 30 : 1000 * 60 * 60,\n env: isProduction ? 'prod' : 'dev',\n });\n }\n\n await preparePromise;\n\n build.onStart(async () => {\n // Determine whether the watcher should run:\n // 1. Explicit option from the caller takes precedence\n // 2. If any esbuild context detected a production build, skip\n // 3. esbuild's own watch mode is a positive signal\n const shouldWatch = options?.watch ?? !isBuildMode;\n\n if (shouldWatch && !watcherStarted) {\n watcherStarted = true;\n\n await watch({ configuration: config! });\n }\n });\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAa,yBACX,YACkB;CAOlB,IAAI,SAAqD;CACzD,IAAI,QAAuC;CAG3C,IAAI,iBAAuC;CAC3C,IAAI,iBAAiB;CAGrB,IAAI,cAAc;CAElB,OAAO;EACL,MAAM;EAEN,MAAM,MAAM,OAAO;GACjB,IAAI,CAAC,QAAQ;IACX,MAAM,UACJ,MAAM,eAAe,iBACrB,SAAS,eAAe,WACxB,QAAQ,IAAI;IAEd,SAAS,iBAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAChE,iBAAiB;KAAE;KAAS,GAAG,SAAS;IAAc,CAAC;IAEvD,QAAQ,SAAS;KACf,eAAe;KACf,YAAY,UAAkB,KAAK,OAAQ,OAAO,SAAS,KAAK;IAClE,CAAC;GACH;GAEA,MAAM,YAAY,aAAa,MAAM;GACrC,MAAM,gBACJ,MAAM,eAAe,SAAS;GAKhC,MAAM,eACJ,kBAAkB,oBAClB,kBAAkB,kBAClB,MAAM,eAAe,WAAW,QAChC,MAAM,eAAe,SAAS,iBAAiB;GAEjD,IAAI,cACF,cAAc;GAGhB,MAAM,WAAW,QAAgB,eAAe;GAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;GAE/C,MAAM,UAAkC;IAMtC,eAAe;KACd,QAAQ,UAAU,IAAI,UAAU,MAAM;KACtC,QAAQ,UAAU,IAAI,UACrB,eAAe,eAAe,aAChC;IAGA,GAAG,iBAAiB,QAAQ,SAAS,SAAS;GAChD;GAEA,IAAI,cAAc;IAChB,MAAM,eAAe,gBAAgB,MAAM;IAC3C,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;IAGH,MAAM,kBAAkB,MAAM,wBAAwB,YAAY;IAClE,OAAO,OACL,SAEA,uBAAuB,iBAAiB,SAAS,SAAS,GAG1D,+BACE,yBAAyB,YAAY,GACrC,SACA,SACF,CACF;GACF;GAIA,MAAM,eAAe,SAAS;IAC5B,GAAG;IACH,GAAI,MAAM,eAAe,UAAU,CAAC;GACtC;GAEA,MAAM,eAAe,QAAQ;IAC3B,GAAG;IACH,GAAI,MAAM,eAAe,SAAS,CAAC;GACrC;GAEA,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,KAAM,GAAG;IAC/C,MAAM,cAAc,KAAK,QAAQ,uBAAuB,MAAM;IAE9D,MAAM,UAAU,EAAE,QAAQ,IAAI,OAAO,IAAI,YAAY,EAAE,EAAE,UAAU,EACjE,MAAM,GACR,EAAE;GACJ;GAEA,IAAI,CAAC,gBACH,iBAAiB,gBAAgB,QAAQ;IACvC,OAAO;IACP,gBAAgB,eAAe,MAAY;IAC3C,KAAK,eAAe,SAAS;GAC/B,CAAC;GAGH,MAAM;GAEN,MAAM,QAAQ,YAAY;IAOxB,KAFoB,SAAS,SAAS,CAAC,gBAEpB,CAAC,gBAAgB;KAClC,iBAAiB;KAEjB,MAAM,MAAM,EAAE,eAAe,OAAQ,CAAC;IACxC;GACF,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/esbuild/plugin.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport {\n addDynamicEntryPreload,\n createDynamicEntryFilter,\n resolvePreloadModuleId,\n} from '@intlayer/config/dictionaryPreload';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { watch } from '@intlayer/engine/watcher';\n\n/**\n * Absolute id of the locale resolver the injected preamble imports.\n *\n * Resolved from this package, which declares `@intlayer/core` as a dependency,\n * rather than left bare in the emitted source: the importer is a generated\n * entry point under the application's `.intlayer` directory, and an application\n * only depends on `intlayer` and its framework binding, so the bare specifier\n * would resolve from a tree that need not contain the package at all.\n *\n * This package ships both module formats, hence the `require` fallback.\n */\nconst preloadModuleId = normalizePath(\n resolvePreloadModuleId(\n typeof require !== 'undefined' ? require : createRequire(import.meta.url)\n )\n);\n\n// Minimal subset of the esbuild Plugin interface to avoid a hard dependency on\n// the `esbuild` package for type resolution. The shape is compatible with\n// esbuild >=0.17, `@angular-builders/custom-esbuild`, and NX esbuild builders.\nexport interface EsbuildPluginBuild {\n initialOptions: {\n alias?: Record<string, string>;\n define?: Record<string, string>;\n minify?: boolean;\n watch?: unknown;\n /** Absolute working directory of the esbuild context (set by Angular's builder). */\n absWorkingDir?: string;\n };\n onStart(callback: () => void | Promise<void>): void;\n /** Intercept module resolution — works even for imports inside node_modules. */\n onResolve(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n importer: string;\n namespace: string;\n resolveDir: string;\n }) => { path: string; namespace?: string } | null | undefined\n ): void;\n /** Intercept module contents, so a resolved file can be rewritten. */\n onLoad(\n options: { filter: RegExp; namespace?: string },\n callback: (args: {\n path: string;\n namespace: string;\n }) =>\n | { contents: string; loader?: string }\n | null\n | undefined\n | Promise<{ contents: string; loader?: string } | null | undefined>\n ): void;\n}\n\nexport interface EsbuildPlugin {\n name: string;\n setup(build: EsbuildPluginBuild): void | Promise<void>;\n}\n\nexport type IntlayerEsbuildPluginOptions = {\n configOptions?: GetConfigurationOptions;\n /**\n * Whether to start the Intlayer file watcher for dictionary regeneration.\n * - `true`: always start the watcher (useful for `ng serve`)\n * - `false`: never start the watcher (useful for `ng build`)\n * - `undefined` (default): auto-detect based on the build context\n * (skips the watcher when a production build is detected)\n */\n watch?: boolean;\n};\n\n/**\n * esbuild plugin that integrates Intlayer into the Angular (or any esbuild-based) build process.\n *\n * Handles:\n * 1. Injecting `alias` entries so `@intlayer/dictionaries-entry` etc. resolve to\n * the generated files under `.intlayer/`.\n * 2. Defining `process.env.*` tree-shaking constants for production builds.\n * 3. Running `prepareIntlayer` (dictionary generation) before the first build.\n * 4. Starting the chokidar file-watcher in dev / serve mode.\n *\n * Compatible with:\n * - `@angular-builders/custom-esbuild` (`application` or `browser-esbuild` builder)\n * - NX `@nx/angular:browser-esbuild`\n * - Any raw esbuild setup that accepts the standard `Plugin` interface\n *\n * @example\n * ```ts\n * // esbuild.plugins.ts (referenced from angular.json \"plugins\" option)\n * import { intlayerEsbuildPlugin } from 'angular-intlayer/esbuild';\n * export default [intlayerEsbuildPlugin()];\n * ```\n */\nexport const intlayerEsbuildPlugin = (\n options?: IntlayerEsbuildPluginOptions\n): EsbuildPlugin => {\n // All Node.js-heavy initialization (getConfiguration, getAlias, …) is deferred\n // into setup() so it runs in esbuild's Node.js context, not at module-evaluation\n // time. @angular/build loads the plugin file through Vite's SSR module runner\n // (ESM) where CommonJS globals like __filename are undefined. Calling\n // getConfiguration() here would trigger: buildSync → worker threads →\n // __filename → ReferenceError, crashing the plugin before setup() ever runs.\n let config: ReturnType<typeof getConfiguration> | null = null;\n let alias: Record<string, string> | null = null;\n\n // Shared across parallel setup() calls (Angular spawns one per bundle context).\n let preparePromise: Promise<void> | null = null;\n let watcherStarted = false;\n // Once any esbuild context (browser or server) detects a production build,\n // suppress the watcher for all contexts so `ng build` can exit cleanly.\n let isBuildMode = false;\n\n return {\n name: 'intlayer',\n\n async setup(build) {\n if (!config) {\n const baseDir =\n build.initialOptions.absWorkingDir ??\n options?.configOptions?.baseDir ??\n process.cwd();\n\n config = getConfiguration({ baseDir, ...options?.configOptions });\n logConfigDetails({ baseDir, ...options?.configOptions });\n\n alias = getAlias({\n configuration: config,\n formatter: (value: string) => join(config!.system.baseDir, value),\n });\n }\n\n const appLogger = getAppLogger(config);\n const nodeEnvDefine =\n build.initialOptions.define?.['process.env.NODE_ENV'];\n\n // Angular's esbuild builder doesn't set `minify` or `process.env.NODE_ENV`\n // on initialOptions — it handles optimisation through its own pipeline.\n // Instead, Angular defines `ngDevMode` as `\"false\"` in production builds.\n const isProduction =\n nodeEnvDefine === '\"production\"' ||\n nodeEnvDefine === \"'production'\" ||\n build.initialOptions.minify === true ||\n build.initialOptions.define?.['ngDevMode'] === 'false';\n\n if (isProduction) {\n isBuildMode = true;\n }\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n const envVars: Record<string, string> = {\n // Catch-all so that any `process.env.*` read NOT covered by a specific\n // key below resolves to `undefined` instead of dereferencing a bare\n // `process`, which is not defined in browser bundles and throws\n // `process is not defined`. esbuild resolves the most specific define\n // first, so the keys below keep their tree-shaking effect.\n 'process.env': '{}',\n [wrapKey('INTLAYER')]: wrapValue('true'),\n [wrapKey('NODE_ENV')]: wrapValue(\n isProduction ? 'production' : 'development'\n ),\n // Tree shaking flags derived from the config (routing / storage /\n // editor). Emitted in every mode so behaviour is consistent in dev.\n ...getConfigEnvVars(config, wrapKey, wrapValue),\n };\n\n if (isProduction) {\n const dictionaries = getDictionaries(config);\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n Object.assign(\n envVars,\n // Tree shaking based on unused node types\n formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n )\n );\n }\n\n // Existing defines (Angular's own, or the user's angular.json `define`\n // block) take precedence over the Intlayer ones.\n build.initialOptions.define = {\n ...envVars,\n ...(build.initialOptions.define ?? {}),\n };\n\n build.initialOptions.alias = {\n ...alias,\n ...(build.initialOptions.alias ?? {}),\n };\n\n for (const [from, to] of Object.entries(alias!)) {\n const escapedFrom = from.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n build.onResolve({ filter: new RegExp(`^${escapedFrom}$`) }, () => ({\n path: to,\n }));\n }\n\n // Dictionaries load with the chunk that needs them rather than being\n // fetched once that chunk renders: the entry point starts the browsing\n // locale's load as it evaluates, so a lazily loaded route requests its\n // content on `import()` instead of on first render. Without it every\n // dictionary read renders an empty placeholder first and fills in a tick\n // later.\n //\n // Not gated on the configured `importMode`: a `.content` file can set\n // `importMode: 'dynamic'` on a single dictionary under a `static` or\n // `fetch` global mode, and that dictionary needs the preload just the\n // same. Only entry points the optimizer imported are ever loaded, so the\n // path check below is the accurate gate.\n if (config.build.dictionariesPreload) {\n const dynamicDictionariesDir = normalizePath(\n config.system.dynamicDictionariesDir\n );\n\n build.onLoad(\n { filter: createDynamicEntryFilter(dynamicDictionariesDir) },\n async ({ path }) => {\n const posixPath = normalizePath(path);\n if (!posixPath.startsWith(`${dynamicDictionariesDir}/`))\n return null;\n\n const code = await readFile(path, 'utf-8');\n const result = addDynamicEntryPreload(code, preloadModuleId);\n\n if (result.skipped) return null;\n\n return { contents: result.code, loader: 'js' };\n }\n );\n }\n\n if (!preparePromise) {\n preparePromise = prepareIntlayer(config, {\n clean: isProduction,\n cacheTimeoutMs: isProduction ? 1000 * 30 : 1000 * 60 * 60,\n env: isProduction ? 'prod' : 'dev',\n });\n }\n\n await preparePromise;\n\n build.onStart(async () => {\n // Determine whether the watcher should run:\n // 1. Explicit option from the caller takes precedence\n // 2. If any esbuild context detected a production build, skip\n // 3. esbuild's own watch mode is a positive signal\n const shouldWatch = options?.watch ?? !isBuildMode;\n\n if (shouldWatch && !watcherStarted) {\n watcherStarted = true;\n\n await watch({ configuration: config! });\n }\n });\n },\n };\n};\n"],"mappings":"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"}
|
|
@@ -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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;cAoCa,6BACL,UAAU,kBACV,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,mBAGzE,0BAA0B,QAAQ,MAClC,2BAAyB,KACxB,GAAC,mBACa,8BAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Locale } from "../intlayer/dist/types/index.js";
|
|
1
2
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
3
|
//#region src/client/useLocaleStorage.d.ts
|
|
3
4
|
/**
|
|
@@ -6,13 +7,13 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
6
7
|
/**
|
|
7
8
|
* Get the locale cookie
|
|
8
9
|
*/
|
|
9
|
-
declare const localeInStorage:
|
|
10
|
+
declare const localeInStorage: Locale;
|
|
10
11
|
/**
|
|
11
12
|
* @deprecated Use localeInStorage instead
|
|
12
13
|
*
|
|
13
14
|
* Get the locale cookie
|
|
14
15
|
*/
|
|
15
|
-
declare const localeCookie:
|
|
16
|
+
declare const localeCookie: Locale;
|
|
16
17
|
/**
|
|
17
18
|
* Set the locale cookie
|
|
18
19
|
*/
|
|
@@ -27,7 +28,7 @@ declare const setLocaleCookie: typeof setLocaleInStorage;
|
|
|
27
28
|
* Hook that provides the locale storage and a function to set it
|
|
28
29
|
*/
|
|
29
30
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
30
|
-
getLocale: () =>
|
|
31
|
+
getLocale: () => Locale;
|
|
31
32
|
setLocale: (locale: LocalesValues) => void;
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
@@ -38,7 +39,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
38
39
|
* Hook that provides the locale cookie and a function to set it
|
|
39
40
|
*/
|
|
40
41
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
41
|
-
localeCookie:
|
|
42
|
+
localeCookie: Locale;
|
|
42
43
|
setLocaleCookie: (locale: LocalesValues) => void;
|
|
43
44
|
};
|
|
44
45
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;;;cAca,iBAAA;;;;;;cAMA,cAAA;;;;cAKA,qBAAkB,QACrB,eAAa;;;;;;cAaV,wBAAe;;;;cAKf,mBAAgB;mBAAhB;sBAAA;;;;;;;;;cAaA,kBAAe;EAIxB,cAJS;EAKT,kBAAe,QAAA"}
|
|
@@ -23,6 +23,20 @@ interface EsbuildPluginBuild {
|
|
|
23
23
|
path: string;
|
|
24
24
|
namespace?: string;
|
|
25
25
|
} | null | undefined): void;
|
|
26
|
+
/** Intercept module contents, so a resolved file can be rewritten. */
|
|
27
|
+
onLoad(options: {
|
|
28
|
+
filter: RegExp;
|
|
29
|
+
namespace?: string;
|
|
30
|
+
}, callback: (args: {
|
|
31
|
+
path: string;
|
|
32
|
+
namespace: string;
|
|
33
|
+
}) => {
|
|
34
|
+
contents: string;
|
|
35
|
+
loader?: string;
|
|
36
|
+
} | null | undefined | Promise<{
|
|
37
|
+
contents: string;
|
|
38
|
+
loader?: string;
|
|
39
|
+
} | null | undefined>): void;
|
|
26
40
|
}
|
|
27
41
|
interface EsbuildPlugin {
|
|
28
42
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;UAiDiB;EACf;IACE,QAAQ;IACR,SAAS;IACT;IACA;;IAEA;;EAEF,QAAQ,uBAAuB;;EAE/B,UACE;IAAW,QAAQ;IAAQ;KAC3B,WAAW;IACT;IACA;IACA;IACA;;IACM;IAAc;;;EAGxB,OACE;IAAW,QAAQ;IAAQ;KAC3B,WAAW;IACT;IACA;;IAEI;IAAkB;yBAGpB;IAAU;IAAkB;;;UAInB;EACf;EACA,MAAM,OAAO,4BAA4B;;KAG/B;EACV,gBAAgB;;;;;;;;EAQhB;;;;;;;;;;;;;;;;;;;;;;;;cAyBW,wBAAqB,UACtB,iCACT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useCompact.d.ts
|
|
2
3
|
declare const useCompact: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
3
|
-
locale?:
|
|
4
|
+
locale?: LocalesValues;
|
|
4
5
|
}) => string>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";;cAIa,0CAAU,QAAA,wBAAA,UAAA,KAAA;WAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useCurrency.d.ts
|
|
2
3
|
declare const useCurrency: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
3
|
-
locale?:
|
|
4
|
+
locale?: LocalesValues;
|
|
4
5
|
}) => string>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";;cAIa,2CAAW,QAAA,wBAAA,UAAA,KAAA;WAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useDate.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Angular client hook that provides a localized date/time formatter.
|
|
4
5
|
*/
|
|
5
6
|
declare const useDate: () => import("@angular/core").Signal<(date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
|
|
6
|
-
locale?:
|
|
7
|
+
locale?: LocalesValues;
|
|
7
8
|
})) => string>;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { useDate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;;cAOa,uCAAO,QAAA,wBAAA,MAAA,8CAAA,kBAAA,KAAA;WAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useList.d.ts
|
|
2
3
|
declare const useList: () => import("@angular/core").Signal<(values: (string | number)[], options?: {
|
|
3
4
|
localeMatcher?: 'lookup' | 'best fit';
|
|
4
5
|
type?: 'conjunction' | 'disjunction' | 'unit';
|
|
5
6
|
style?: 'long' | 'short' | 'narrow';
|
|
6
7
|
} & {
|
|
7
|
-
locale?:
|
|
8
|
+
locale?: LocalesValues;
|
|
8
9
|
}) => string>;
|
|
9
10
|
//#endregion
|
|
10
11
|
export { useList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";;cAIa,uCAAO,QAAA,6BAAA;;;;;WAAP"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useNumber.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Angular client hook that provides a localized number formatter.
|
|
4
5
|
*/
|
|
5
6
|
declare const useNumber: () => import("@angular/core").Signal<(value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
6
|
-
locale?:
|
|
7
|
+
locale?: LocalesValues;
|
|
7
8
|
}) => string>;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { useNumber };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;;;;cAOa,yCAAS,QAAA,wBAAA,SAAA,KAAA;WAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/usePercentage.d.ts
|
|
2
3
|
declare const usePercentage: () => import("@angular/core").Signal<(value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
3
|
-
locale?:
|
|
4
|
+
locale?: LocalesValues;
|
|
4
5
|
}) => string>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { usePercentage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";;cAIa,6CAAa,QAAA,wBAAA,SAAA,KAAA;WAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useRelativeTime.d.ts
|
|
2
3
|
declare const useRelativeTime: () => import("@angular/core").Signal<(from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
3
|
-
locale?:
|
|
4
|
+
locale?: LocalesValues;
|
|
4
5
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
5
6
|
}) => string>;
|
|
6
7
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";;cAIa,+CAAe,QAAA,wBAAA,MAAA,uBAAA,MAAA,UAAA,KAAA;WAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
//#region src/format/useUnit.d.ts
|
|
2
3
|
declare const useUnit: () => import("@angular/core").Signal<(value: string | number, options?: Intl.NumberFormatOptions & {
|
|
3
|
-
locale?:
|
|
4
|
+
locale?: LocalesValues;
|
|
4
5
|
}) => string>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { useUnit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";;cAIa,uCAAO,QAAA,wBAAA,UAAA,KAAA;WAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LocalesValues as LocalesValues$1 } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
+
import "@intlayer/core/interpreter";
|
|
4
|
+
import "@intlayer/types/config";
|
|
5
|
+
import { Locale } from "@intlayer/types/allLocales";
|
|
6
|
+
import "@intlayer/types/locales";
|
|
7
|
+
import "@intlayer/config/built";
|
|
8
|
+
import "@intlayer/core/file";
|
|
9
|
+
import "@intlayer/core/formatters";
|
|
10
|
+
import "@intlayer/core/localization";
|
|
11
|
+
import "@intlayer/core/markdown";
|
|
12
|
+
import "@intlayer/core/transpiler";
|
|
13
|
+
import "@intlayer/core/utils";
|
|
14
|
+
export type { Locale, LocalesValues$1 as LocalesValues };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-intlayer",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -119,12 +119,12 @@
|
|
|
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.3.
|
|
123
|
-
"@intlayer/core": "9.3.
|
|
124
|
-
"@intlayer/dictionaries-entry": "9.3.
|
|
125
|
-
"@intlayer/editor": "9.3.
|
|
122
|
+
"@intlayer/config": "9.3.3",
|
|
123
|
+
"@intlayer/core": "9.3.3",
|
|
124
|
+
"@intlayer/dictionaries-entry": "9.3.3",
|
|
125
|
+
"@intlayer/editor": "9.3.3",
|
|
126
126
|
"@intlayer/engine": "9.3.2",
|
|
127
|
-
"@intlayer/types": "9.3.
|
|
127
|
+
"@intlayer/types": "9.3.3",
|
|
128
128
|
"@intlayer/webpack": "9.3.2",
|
|
129
129
|
"babel-loader": "10.1.1",
|
|
130
130
|
"defu": "6.1.7"
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"rimraf": "6.1.3",
|
|
142
142
|
"tsdown": "0.22.14",
|
|
143
143
|
"typescript": "7.0.2",
|
|
144
|
-
"vitest": "4.1.
|
|
144
|
+
"vitest": "4.1.11"
|
|
145
145
|
},
|
|
146
146
|
"peerDependencies": {
|
|
147
147
|
"@angular/common": ">=15",
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
"optionalDependencies": {
|
|
158
|
-
"@intlayer/analytics": "9.3.
|
|
158
|
+
"@intlayer/analytics": "9.3.3"
|
|
159
159
|
},
|
|
160
160
|
"engines": {
|
|
161
161
|
"node": ">=14.18"
|