@intlayer/chokidar 8.5.2 → 8.6.0
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/assets/initConfig/templates/cjs.txt +11 -0
- package/dist/assets/initConfig/templates/json.txt +56 -12
- package/dist/assets/initConfig/templates/mjs.txt +11 -0
- package/dist/assets/initConfig/templates/ts.txt +11 -0
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +21 -33
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/utils/getUsedNodeTypes.cjs +88 -0
- package/dist/cjs/utils/getUsedNodeTypes.cjs.map +1 -0
- package/dist/cjs/utils/index.cjs +5 -0
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +23 -36
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/utils/getUsedNodeTypes.mjs +83 -0
- package/dist/esm/utils/getUsedNodeTypes.mjs.map +1 -0
- package/dist/esm/utils/index.mjs +2 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/formatDictionary.d.ts +23 -23
- package/dist/types/formatDictionary.d.ts.map +1 -1
- package/dist/types/listDictionariesPath.d.ts +2 -2
- package/dist/types/listDictionariesPath.d.ts.map +1 -1
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +0 -3
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/utils/getUsedNodeTypes.d.ts +54 -0
- package/dist/types/utils/getUsedNodeTypes.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/watcher.d.ts +2 -2
- package/dist/types/watcher.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -85,6 +85,17 @@ const config = {
|
|
|
85
85
|
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
86
86
|
* }
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* Variable list:
|
|
90
|
+
* - `fileName`: The name of the file.
|
|
91
|
+
* - `key`: The key of the content.
|
|
92
|
+
* - `locale`: The locale of the content.
|
|
93
|
+
* - `extension`: The extension of the file.
|
|
94
|
+
* - `componentFileName`: The name of the component file.
|
|
95
|
+
* - `componentExtension`: The extension of the component file.
|
|
96
|
+
* - `format`: The format of the dictionary.
|
|
97
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
98
|
+
* - `componentDirPath`: The directory path of the component.
|
|
88
99
|
*/
|
|
89
100
|
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
90
101
|
|
|
@@ -1,28 +1,72 @@
|
|
|
1
1
|
{
|
|
2
|
+
/**
|
|
3
|
+
* Intlayer configuration file documentation
|
|
4
|
+
* @see https://intlayer.org/doc/concept/configuration
|
|
5
|
+
*/
|
|
2
6
|
"internationalization": {
|
|
3
7
|
"locales": ["en"],
|
|
8
|
+
/**
|
|
9
|
+
* Default locale used as a fallback if the requested locale is not found.
|
|
10
|
+
*/
|
|
4
11
|
"defaultLocale": "en"
|
|
5
12
|
},
|
|
6
13
|
"routing": {
|
|
14
|
+
/**
|
|
15
|
+
* Locale routing strategy.
|
|
16
|
+
* - "prefix-no-default": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
|
|
17
|
+
* - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
|
|
18
|
+
* - "no-prefix": No locale in the URL.
|
|
19
|
+
* - "search-params": Use ?locale=...
|
|
20
|
+
* Default: "prefix-no-default"
|
|
21
|
+
*/
|
|
7
22
|
"mode": "prefix-no-default"
|
|
8
23
|
},
|
|
9
24
|
"editor": {
|
|
25
|
+
/**
|
|
26
|
+
* Whether the visual editor is enabled.
|
|
27
|
+
*/
|
|
10
28
|
"enabled": false,
|
|
11
|
-
|
|
29
|
+
/**
|
|
30
|
+
* URL of your application for origin validation.
|
|
31
|
+
*/
|
|
32
|
+
"applicationURL": "http://localhost:3000"
|
|
12
33
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
34
|
+
"build": {
|
|
35
|
+
/**
|
|
36
|
+
* Controls how dictionaries are imported.
|
|
37
|
+
* - "static": Statically imported at build time.
|
|
38
|
+
* - "dynamic": Dynamically imported using Suspense.
|
|
39
|
+
* - "fetch": Fetched dynamically via the live sync API.
|
|
40
|
+
*/
|
|
41
|
+
"importMode": "static"
|
|
15
42
|
},
|
|
16
43
|
"ai": {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
/**
|
|
45
|
+
* AI provider to use.
|
|
46
|
+
* Options: "openai", "anthropic", "mistral", "deepseek", "gemini", "ollama", etc.
|
|
47
|
+
*/
|
|
48
|
+
"provider": "openai",
|
|
49
|
+
"model": "gpt-4o",
|
|
50
|
+
/**
|
|
51
|
+
* API Key. Note: JSON does not support process.env.
|
|
52
|
+
* This value should be provided as a string or handled by your loader.
|
|
53
|
+
*/
|
|
54
|
+
"apiKey": "",
|
|
55
|
+
/**
|
|
56
|
+
* Additional context for the translations.
|
|
57
|
+
*/
|
|
58
|
+
"applicationContext": ""
|
|
21
59
|
},
|
|
22
60
|
"compiler": {
|
|
23
61
|
"enabled": true,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Defines the output files path for autogenerated content.
|
|
64
|
+
* Example: "./{{fileName}}.content.ts"
|
|
65
|
+
*/
|
|
66
|
+
"output": "./{{fileName}}.content.ts",
|
|
67
|
+
/**
|
|
68
|
+
* If true, the compiler will rewrite the component file on disk.
|
|
69
|
+
*/
|
|
70
|
+
"saveComponents": false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -85,6 +85,17 @@ const config = {
|
|
|
85
85
|
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
86
86
|
* }
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* Variable list:
|
|
90
|
+
* - `fileName`: The name of the file.
|
|
91
|
+
* - `key`: The key of the content.
|
|
92
|
+
* - `locale`: The locale of the content.
|
|
93
|
+
* - `extension`: The extension of the file.
|
|
94
|
+
* - `componentFileName`: The name of the component file.
|
|
95
|
+
* - `componentExtension`: The extension of the component file.
|
|
96
|
+
* - `format`: The format of the dictionary.
|
|
97
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
98
|
+
* - `componentDirPath`: The directory path of the component.
|
|
88
99
|
*/
|
|
89
100
|
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
90
101
|
|
|
@@ -84,6 +84,17 @@ const config: IntlayerConfig = {
|
|
|
84
84
|
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
85
85
|
* }
|
|
86
86
|
* ```
|
|
87
|
+
*
|
|
88
|
+
* Variable list:
|
|
89
|
+
* - `fileName`: The name of the file.
|
|
90
|
+
* - `key`: The key of the content.
|
|
91
|
+
* - `locale`: The locale of the content.
|
|
92
|
+
* - `extension`: The extension of the file.
|
|
93
|
+
* - `componentFileName`: The name of the component file.
|
|
94
|
+
* - `componentExtension`: The extension of the component file.
|
|
95
|
+
* - `format`: The format of the dictionary.
|
|
96
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
97
|
+
* - `componentDirPath`: The directory path of the component.
|
|
87
98
|
*/
|
|
88
99
|
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
89
100
|
|
|
@@ -8,59 +8,47 @@ let node_module = require("node:module");
|
|
|
8
8
|
|
|
9
9
|
//#region src/loadDictionaries/getIntlayerBundle.ts
|
|
10
10
|
/**
|
|
11
|
-
* Rewrites
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Example:
|
|
15
|
-
* rewritePathsPlugin(["@intlayer/config", "@intlayer/core"], localeRequire)
|
|
16
|
-
* …will also rewrite "@intlayer/core/file" etc.
|
|
11
|
+
* Rewrites bare specifiers to absolute paths on the user's disk and externalizes them
|
|
12
|
+
* to preserve directory context (__dirname/import.meta.url).
|
|
17
13
|
*/
|
|
18
|
-
const
|
|
14
|
+
const localResolvePlugin = (aliases, rootRequire) => {
|
|
19
15
|
return {
|
|
20
|
-
name: "
|
|
16
|
+
name: "local-resolve",
|
|
21
17
|
setup(build) {
|
|
22
18
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (exact) return {
|
|
26
|
-
path: exact,
|
|
27
|
-
namespace: "intlayer-replace-modules",
|
|
19
|
+
if (aliases[args.path]) return {
|
|
20
|
+
path: aliases[args.path],
|
|
28
21
|
external: true
|
|
29
22
|
};
|
|
30
|
-
|
|
31
|
-
const sub = args.path.slice(key.length);
|
|
23
|
+
if (args.path === "defu" || args.path.startsWith("@intlayer/")) try {
|
|
32
24
|
return {
|
|
33
|
-
path:
|
|
34
|
-
namespace: "intlayer-replace-modules",
|
|
25
|
+
path: rootRequire.resolve(args.path),
|
|
35
26
|
external: true
|
|
36
27
|
};
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
37
30
|
}
|
|
31
|
+
return null;
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
};
|
|
41
35
|
};
|
|
42
|
-
/**
|
|
43
|
-
* Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.
|
|
44
|
-
*/
|
|
45
36
|
const getIntlayerBundle = async (configuration) => {
|
|
46
37
|
const rootRequire = (0, _intlayer_config_utils.getProjectRequire)(configuration.system.baseDir);
|
|
47
|
-
const configPackageRequire = _intlayer_config_utils.configESMxCJSRequire;
|
|
48
|
-
const localRequire = _intlayer_config_utils.isESModule ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : require;
|
|
49
38
|
const configurationPath = (0, node_path.join)(configuration.system.configDir, `configuration.cjs`);
|
|
50
|
-
const
|
|
51
|
-
defu: configPackageRequire.resolve("defu"),
|
|
52
|
-
esbuild: configPackageRequire.resolve("esbuild"),
|
|
53
|
-
"@intlayer/config/built": configurationPath,
|
|
54
|
-
"@intlayer/config/utils": localRequire.resolve("@intlayer/config/utils"),
|
|
55
|
-
"@intlayer/config/client": localRequire.resolve("@intlayer/config/client"),
|
|
56
|
-
"@intlayer/config/logger": localRequire.resolve("@intlayer/config/logger"),
|
|
57
|
-
"@intlayer/core/file": localRequire.resolve("@intlayer/core/file")
|
|
58
|
-
};
|
|
39
|
+
const aliases = { "@intlayer/config/built": configurationPath };
|
|
59
40
|
const filePath = rootRequire.resolve("intlayer");
|
|
60
41
|
return await (0, _intlayer_config_file.bundleFile)(await (0, node_fs_promises.readFile)(filePath, "utf-8"), filePath, {
|
|
61
|
-
|
|
42
|
+
bundle: true,
|
|
43
|
+
platform: "node",
|
|
44
|
+
external: [
|
|
45
|
+
...node_module.builtinModules,
|
|
46
|
+
...node_module.builtinModules.map((mod) => `node:${mod}`),
|
|
47
|
+
"vscode",
|
|
48
|
+
"esbuild"
|
|
49
|
+
],
|
|
62
50
|
minify: true,
|
|
63
|
-
plugins: [
|
|
51
|
+
plugins: [localResolvePlugin(aliases, rootRequire)]
|
|
64
52
|
}) ?? "";
|
|
65
53
|
};
|
|
66
54
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.cjs","names":["
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.cjs","names":["builtinModules"],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport { getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites bare specifiers to absolute paths on the user's disk and externalizes them\n * to preserve directory context (__dirname/import.meta.url).\n */\nconst localResolvePlugin = (\n aliases: Record<string, string>,\n rootRequire: NodeJS.Require\n): ESBuildPlugin => {\n return {\n name: 'local-resolve',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n // 1. Direct alias match\n if (aliases[args.path]) {\n return {\n path: aliases[args.path],\n external: true, // Prevents inlining and context loss\n };\n }\n\n // 2. Dynamic resolution via user workspace\n if (args.path === 'defu' || args.path.startsWith('@intlayer/')) {\n try {\n const absolutePath = rootRequire.resolve(args.path);\n return {\n path: absolutePath,\n external: true, // Injects `require('/absolute/path')`\n };\n } catch {\n return null;\n }\n }\n\n return null;\n });\n },\n };\n};\n\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.cjs`\n );\n\n const aliases = {\n '@intlayer/config/built': configurationPath,\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n bundle: true,\n platform: 'node',\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n 'vscode',\n 'esbuild',\n ],\n minify: true,\n plugins: [localResolvePlugin(aliases, rootRequire)],\n });\n\n return output ?? '';\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,sBACJ,SACA,gBACkB;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;AAE1C,QAAI,QAAQ,KAAK,MACf,QAAO;KACL,MAAM,QAAQ,KAAK;KACnB,UAAU;KACX;AAIH,QAAI,KAAK,SAAS,UAAU,KAAK,KAAK,WAAW,aAAa,CAC5D,KAAI;AAEF,YAAO;MACL,MAFmB,YAAY,QAAQ,KAAK,KAAK;MAGjD,UAAU;MACX;YACK;AACN,YAAO;;AAIX,WAAO;KACP;;EAEL;;AAGH,MAAa,oBAAoB,OAAO,kBAAkC;CACxE,MAAM,4DAAgC,cAAc,OAAO,QAAQ;CAEnE,MAAM,wCACJ,cAAc,OAAO,WACrB,oBACD;CAED,MAAM,UAAU,EACd,0BAA0B,mBAC3B;CAED,MAAM,WAAW,YAAY,QAAQ,WAAW;AAgBhD,QAbe,4CAFF,qCAAe,UAAU,QAAQ,EAER,UAAU;EAC9C,QAAQ;EACR,UAAU;EACV,UAAU;GACR,GAAGA;GACH,GAAGA,2BAAe,KAAK,QAAQ,QAAQ,MAAM;GAC7C;GACA;GACD;EACD,QAAQ;EACR,SAAS,CAAC,mBAAmB,SAAS,YAAY,CAAC;EACpD,CAAC,IAEe"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/utils/getUsedNodeTypes.ts
|
|
4
|
+
/**
|
|
5
|
+
* NodeType strings that correspond to plugins that can be conditionally
|
|
6
|
+
* removed from the bundle when unused.
|
|
7
|
+
*/
|
|
8
|
+
const PLUGIN_NODE_TYPES = [
|
|
9
|
+
"translation",
|
|
10
|
+
"enumeration",
|
|
11
|
+
"condition",
|
|
12
|
+
"insertion",
|
|
13
|
+
"gender",
|
|
14
|
+
"nested",
|
|
15
|
+
"file",
|
|
16
|
+
"markdown",
|
|
17
|
+
"html"
|
|
18
|
+
];
|
|
19
|
+
/** Recursively collect every `nodeType` string found in a value. */
|
|
20
|
+
const collectNodeTypes = (value, result) => {
|
|
21
|
+
if (!value || typeof value !== "object") return;
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
for (const item of value) collectNodeTypes(item, result);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const obj = value;
|
|
27
|
+
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
28
|
+
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Returns the set of NodeType strings actually used across the given
|
|
32
|
+
* built dictionaries.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
36
|
+
* // Set { 'translation', 'enumeration' }
|
|
37
|
+
*/
|
|
38
|
+
const getUsedNodeTypes = (dictionaries) => {
|
|
39
|
+
const result = /* @__PURE__ */ new Set();
|
|
40
|
+
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
41
|
+
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
49
|
+
*/
|
|
50
|
+
const nodeTypeToEnvVar = (nodeType) => `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
53
|
+
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
54
|
+
*
|
|
55
|
+
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
56
|
+
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
57
|
+
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
58
|
+
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
59
|
+
*
|
|
60
|
+
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
61
|
+
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
62
|
+
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
63
|
+
*
|
|
64
|
+
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
65
|
+
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // When only 'translation' is used:
|
|
69
|
+
* getNodeTypeDefineVars(new Set(['translation']))
|
|
70
|
+
* // {
|
|
71
|
+
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
72
|
+
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
73
|
+
* // ...
|
|
74
|
+
* // }
|
|
75
|
+
*/
|
|
76
|
+
const getNodeTypeDefineVars = (usedNodeTypes) => {
|
|
77
|
+
if (usedNodeTypes.size === 0) return {};
|
|
78
|
+
const result = {};
|
|
79
|
+
for (const nodeType of PLUGIN_NODE_TYPES) if (!usedNodeTypes.has(nodeType)) result[nodeTypeToEnvVar(nodeType)] = "false";
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.PLUGIN_NODE_TYPES = PLUGIN_NODE_TYPES;
|
|
85
|
+
exports.getNodeTypeDefineVars = getNodeTypeDefineVars;
|
|
86
|
+
exports.getUsedNodeTypes = getUsedNodeTypes;
|
|
87
|
+
exports.nodeTypeToEnvVar = nodeTypeToEnvVar;
|
|
88
|
+
//# sourceMappingURL=getUsedNodeTypes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.cjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * NodeType strings that correspond to plugins that can be conditionally\n * removed from the bundle when unused.\n */\nexport const PLUGIN_NODE_TYPES = [\n 'translation',\n 'enumeration',\n 'condition',\n 'insertion',\n 'gender',\n 'nested',\n 'file',\n 'markdown',\n 'html',\n] as const;\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Set<string> => {\n const result = new Set<string>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return result;\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'\n */\nexport const nodeTypeToEnvVar = (nodeType: string): string =>\n `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;\n\n/**\n * Returns a record mapping each **unused** NodeType to `'false'` so build\n * plugins can dead-code-eliminate the corresponding plugin from the bundle.\n *\n * Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).\n * Build plugins that need `process.env.*` keys (Vite `define`, webpack\n * `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values\n * with `JSON.stringify`; Next.js `env:` can use the record directly.\n *\n * Only NodeTypes that are confirmed absent from all dictionaries get the\n * `'false'` value; used (or unknown) types are omitted so they default to\n * `true` inside `getPlugins` / `getBasePlugins`.\n *\n * @param usedNodeTypes - Set returned by `getUsedNodeTypes`.\n * @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.\n *\n * @example\n * // When only 'translation' is used:\n * getNodeTypeDefineVars(new Set(['translation']))\n * // {\n * // INTLAYER_NODE_TYPE_ENUMERATION: 'false',\n * // INTLAYER_NODE_TYPE_CONDITION: 'false',\n * // ...\n * // }\n */\nexport const getNodeTypeDefineVars = (\n usedNodeTypes: Set<string>\n): Record<string, string> => {\n // No dictionaries found yet → safe default: keep all plugins\n if (usedNodeTypes.size === 0) return {};\n\n const result: Record<string, string> = {};\n\n for (const nodeType of PLUGIN_NODE_TYPES) {\n if (!usedNodeTypes.has(nodeType)) {\n result[nodeTypeToEnvVar(nodeType)] = 'false';\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;AAKD,MAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AAEzC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,OAAK,MAAM,QAAQ,MAAO,kBAAiB,MAAM,OAAO;AACxD;;CAGF,MAAM,MAAM;AAEZ,KAAI,OAAO,IAAI,aAAa,SAC1B,QAAO,IAAI,IAAI,SAAS;AAG1B,MAAK,MAAM,OAAO,OAAO,KAAK,IAAI,CAChC,kBAAiB,IAAI,MAAM,OAAO;;;;;;;;;;AAYtC,MAAa,oBACX,iBACgB;CAChB,MAAM,yBAAS,IAAI,KAAa;CAChC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO;;;;;;;;AAST,MAAa,oBAAoB,aAC/B,sBAAsB,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B9C,MAAa,yBACX,kBAC2B;AAE3B,KAAI,cAAc,SAAS,EAAG,QAAO,EAAE;CAEvC,MAAM,SAAiC,EAAE;AAEzC,MAAK,MAAM,YAAY,kBACrB,KAAI,CAAC,cAAc,IAAI,SAAS,CAC9B,QAAO,iBAAiB,SAAS,IAAI;AAIzC,QAAO"}
|
package/dist/cjs/utils/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const require_utils_getChunk = require('./getChunk.cjs');
|
|
|
10
10
|
const require_utils_chunkJSON = require('./chunkJSON.cjs');
|
|
11
11
|
const require_utils_getContentExtension = require('./getContentExtension.cjs');
|
|
12
12
|
const require_utils_getFormatFromExtension = require('./getFormatFromExtension.cjs');
|
|
13
|
+
const require_utils_getUsedNodeTypes = require('./getUsedNodeTypes.cjs');
|
|
13
14
|
const require_utils_mergeChunks = require('./mergeChunks.cjs');
|
|
14
15
|
const require_utils_parallelizeGlobal = require('./parallelizeGlobal.cjs');
|
|
15
16
|
const require_utils_reduceObjectFormat = require('./reduceObjectFormat.cjs');
|
|
@@ -20,6 +21,7 @@ const require_utils_runParallel_index = require('./runParallel/index.cjs');
|
|
|
20
21
|
const require_utils_sortAlphabetically = require('./sortAlphabetically.cjs');
|
|
21
22
|
const require_utils_verifyIdenticObjectFormat = require('./verifyIdenticObjectFormat.cjs');
|
|
22
23
|
|
|
24
|
+
exports.PLUGIN_NODE_TYPES = require_utils_getUsedNodeTypes.PLUGIN_NODE_TYPES;
|
|
23
25
|
exports.Queue = require_utils_pLimit.Queue;
|
|
24
26
|
exports.assembleJSON = require_utils_chunkJSON.assembleJSON;
|
|
25
27
|
exports.autoDecorateContent = require_utils_autoDecorateContent.autoDecorateContent;
|
|
@@ -32,9 +34,12 @@ exports.getContentExtension = require_utils_getContentExtension.getContentExtens
|
|
|
32
34
|
exports.getExtensionFromFormat = require_utils_getFormatFromExtension.getExtensionFromFormat;
|
|
33
35
|
exports.getFormatFromExtension = require_utils_getFormatFromExtension.getFormatFromExtension;
|
|
34
36
|
exports.getGlobalLimiter = require_utils_parallelizeGlobal.getGlobalLimiter;
|
|
37
|
+
exports.getNodeTypeDefineVars = require_utils_getUsedNodeTypes.getNodeTypeDefineVars;
|
|
35
38
|
exports.getPathHash = require_utils_getPathHash.getPathHash;
|
|
36
39
|
exports.getTaskLimiter = require_utils_parallelizeGlobal.getTaskLimiter;
|
|
40
|
+
exports.getUsedNodeTypes = require_utils_getUsedNodeTypes.getUsedNodeTypes;
|
|
37
41
|
exports.mergeChunks = require_utils_mergeChunks.mergeChunks;
|
|
42
|
+
exports.nodeTypeToEnvVar = require_utils_getUsedNodeTypes.nodeTypeToEnvVar;
|
|
38
43
|
exports.pLimit = require_utils_pLimit.pLimit;
|
|
39
44
|
exports.parallelize = require_utils_parallelize.parallelize;
|
|
40
45
|
exports.parallelizeGlobal = require_utils_parallelizeGlobal.parallelizeGlobal;
|
|
@@ -1,65 +1,52 @@
|
|
|
1
|
-
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
1
|
import { readFile } from "node:fs/promises";
|
|
3
2
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
3
|
+
import { getProjectRequire } from "@intlayer/config/utils";
|
|
5
4
|
import { bundleFile } from "@intlayer/config/file";
|
|
6
|
-
import { builtinModules
|
|
5
|
+
import { builtinModules } from "node:module";
|
|
7
6
|
|
|
8
7
|
//#region src/loadDictionaries/getIntlayerBundle.ts
|
|
9
8
|
/**
|
|
10
|
-
* Rewrites
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
* rewritePathsPlugin(["@intlayer/config", "@intlayer/core"], localeRequire)
|
|
15
|
-
* …will also rewrite "@intlayer/core/file" etc.
|
|
9
|
+
* Rewrites bare specifiers to absolute paths on the user's disk and externalizes them
|
|
10
|
+
* to preserve directory context (__dirname/import.meta.url).
|
|
16
11
|
*/
|
|
17
|
-
const
|
|
12
|
+
const localResolvePlugin = (aliases, rootRequire) => {
|
|
18
13
|
return {
|
|
19
|
-
name: "
|
|
14
|
+
name: "local-resolve",
|
|
20
15
|
setup(build) {
|
|
21
16
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (exact) return {
|
|
25
|
-
path: exact,
|
|
26
|
-
namespace: "intlayer-replace-modules",
|
|
17
|
+
if (aliases[args.path]) return {
|
|
18
|
+
path: aliases[args.path],
|
|
27
19
|
external: true
|
|
28
20
|
};
|
|
29
|
-
|
|
30
|
-
const sub = args.path.slice(key.length);
|
|
21
|
+
if (args.path === "defu" || args.path.startsWith("@intlayer/")) try {
|
|
31
22
|
return {
|
|
32
|
-
path:
|
|
33
|
-
namespace: "intlayer-replace-modules",
|
|
23
|
+
path: rootRequire.resolve(args.path),
|
|
34
24
|
external: true
|
|
35
25
|
};
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
36
28
|
}
|
|
29
|
+
return null;
|
|
37
30
|
});
|
|
38
31
|
}
|
|
39
32
|
};
|
|
40
33
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.
|
|
43
|
-
*/
|
|
44
34
|
const getIntlayerBundle = async (configuration) => {
|
|
45
35
|
const rootRequire = getProjectRequire(configuration.system.baseDir);
|
|
46
|
-
const configPackageRequire = configESMxCJSRequire;
|
|
47
|
-
const localRequire = isESModule ? createRequire(import.meta.url) : __require;
|
|
48
36
|
const configurationPath = join(configuration.system.configDir, `configuration.cjs`);
|
|
49
|
-
const
|
|
50
|
-
defu: configPackageRequire.resolve("defu"),
|
|
51
|
-
esbuild: configPackageRequire.resolve("esbuild"),
|
|
52
|
-
"@intlayer/config/built": configurationPath,
|
|
53
|
-
"@intlayer/config/utils": localRequire.resolve("@intlayer/config/utils"),
|
|
54
|
-
"@intlayer/config/client": localRequire.resolve("@intlayer/config/client"),
|
|
55
|
-
"@intlayer/config/logger": localRequire.resolve("@intlayer/config/logger"),
|
|
56
|
-
"@intlayer/core/file": localRequire.resolve("@intlayer/core/file")
|
|
57
|
-
};
|
|
37
|
+
const aliases = { "@intlayer/config/built": configurationPath };
|
|
58
38
|
const filePath = rootRequire.resolve("intlayer");
|
|
59
39
|
return await bundleFile(await readFile(filePath, "utf-8"), filePath, {
|
|
60
|
-
|
|
40
|
+
bundle: true,
|
|
41
|
+
platform: "node",
|
|
42
|
+
external: [
|
|
43
|
+
...builtinModules,
|
|
44
|
+
...builtinModules.map((mod) => `node:${mod}`),
|
|
45
|
+
"vscode",
|
|
46
|
+
"esbuild"
|
|
47
|
+
],
|
|
61
48
|
minify: true,
|
|
62
|
-
plugins: [
|
|
49
|
+
plugins: [localResolvePlugin(aliases, rootRequire)]
|
|
63
50
|
}) ?? "";
|
|
64
51
|
};
|
|
65
52
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport { getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites bare specifiers to absolute paths on the user's disk and externalizes them\n * to preserve directory context (__dirname/import.meta.url).\n */\nconst localResolvePlugin = (\n aliases: Record<string, string>,\n rootRequire: NodeJS.Require\n): ESBuildPlugin => {\n return {\n name: 'local-resolve',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n // 1. Direct alias match\n if (aliases[args.path]) {\n return {\n path: aliases[args.path],\n external: true, // Prevents inlining and context loss\n };\n }\n\n // 2. Dynamic resolution via user workspace\n if (args.path === 'defu' || args.path.startsWith('@intlayer/')) {\n try {\n const absolutePath = rootRequire.resolve(args.path);\n return {\n path: absolutePath,\n external: true, // Injects `require('/absolute/path')`\n };\n } catch {\n return null;\n }\n }\n\n return null;\n });\n },\n };\n};\n\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.cjs`\n );\n\n const aliases = {\n '@intlayer/config/built': configurationPath,\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n bundle: true,\n platform: 'node',\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n 'vscode',\n 'esbuild',\n ],\n minify: true,\n plugins: [localResolvePlugin(aliases, rootRequire)],\n });\n\n return output ?? '';\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,sBACJ,SACA,gBACkB;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;AAE1C,QAAI,QAAQ,KAAK,MACf,QAAO;KACL,MAAM,QAAQ,KAAK;KACnB,UAAU;KACX;AAIH,QAAI,KAAK,SAAS,UAAU,KAAK,KAAK,WAAW,aAAa,CAC5D,KAAI;AAEF,YAAO;MACL,MAFmB,YAAY,QAAQ,KAAK,KAAK;MAGjD,UAAU;MACX;YACK;AACN,YAAO;;AAIX,WAAO;KACP;;EAEL;;AAGH,MAAa,oBAAoB,OAAO,kBAAkC;CACxE,MAAM,cAAc,kBAAkB,cAAc,OAAO,QAAQ;CAEnE,MAAM,oBAAoB,KACxB,cAAc,OAAO,WACrB,oBACD;CAED,MAAM,UAAU,EACd,0BAA0B,mBAC3B;CAED,MAAM,WAAW,YAAY,QAAQ,WAAW;AAgBhD,QAbe,MAAM,WAFR,MAAM,SAAS,UAAU,QAAQ,EAER,UAAU;EAC9C,QAAQ;EACR,UAAU;EACV,UAAU;GACR,GAAG;GACH,GAAG,eAAe,KAAK,QAAQ,QAAQ,MAAM;GAC7C;GACA;GACD;EACD,QAAQ;EACR,SAAS,CAAC,mBAAmB,SAAS,YAAY,CAAC;EACpD,CAAC,IAEe"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//#region src/utils/getUsedNodeTypes.ts
|
|
2
|
+
/**
|
|
3
|
+
* NodeType strings that correspond to plugins that can be conditionally
|
|
4
|
+
* removed from the bundle when unused.
|
|
5
|
+
*/
|
|
6
|
+
const PLUGIN_NODE_TYPES = [
|
|
7
|
+
"translation",
|
|
8
|
+
"enumeration",
|
|
9
|
+
"condition",
|
|
10
|
+
"insertion",
|
|
11
|
+
"gender",
|
|
12
|
+
"nested",
|
|
13
|
+
"file",
|
|
14
|
+
"markdown",
|
|
15
|
+
"html"
|
|
16
|
+
];
|
|
17
|
+
/** Recursively collect every `nodeType` string found in a value. */
|
|
18
|
+
const collectNodeTypes = (value, result) => {
|
|
19
|
+
if (!value || typeof value !== "object") return;
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
for (const item of value) collectNodeTypes(item, result);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const obj = value;
|
|
25
|
+
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
26
|
+
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Returns the set of NodeType strings actually used across the given
|
|
30
|
+
* built dictionaries.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
34
|
+
* // Set { 'translation', 'enumeration' }
|
|
35
|
+
*/
|
|
36
|
+
const getUsedNodeTypes = (dictionaries) => {
|
|
37
|
+
const result = /* @__PURE__ */ new Set();
|
|
38
|
+
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
39
|
+
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
47
|
+
*/
|
|
48
|
+
const nodeTypeToEnvVar = (nodeType) => `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
51
|
+
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
52
|
+
*
|
|
53
|
+
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
54
|
+
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
55
|
+
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
56
|
+
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
57
|
+
*
|
|
58
|
+
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
59
|
+
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
60
|
+
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
61
|
+
*
|
|
62
|
+
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
63
|
+
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // When only 'translation' is used:
|
|
67
|
+
* getNodeTypeDefineVars(new Set(['translation']))
|
|
68
|
+
* // {
|
|
69
|
+
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
70
|
+
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
71
|
+
* // ...
|
|
72
|
+
* // }
|
|
73
|
+
*/
|
|
74
|
+
const getNodeTypeDefineVars = (usedNodeTypes) => {
|
|
75
|
+
if (usedNodeTypes.size === 0) return {};
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const nodeType of PLUGIN_NODE_TYPES) if (!usedNodeTypes.has(nodeType)) result[nodeTypeToEnvVar(nodeType)] = "false";
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { PLUGIN_NODE_TYPES, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar };
|
|
83
|
+
//# sourceMappingURL=getUsedNodeTypes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.mjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * NodeType strings that correspond to plugins that can be conditionally\n * removed from the bundle when unused.\n */\nexport const PLUGIN_NODE_TYPES = [\n 'translation',\n 'enumeration',\n 'condition',\n 'insertion',\n 'gender',\n 'nested',\n 'file',\n 'markdown',\n 'html',\n] as const;\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Set<string> => {\n const result = new Set<string>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return result;\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'\n */\nexport const nodeTypeToEnvVar = (nodeType: string): string =>\n `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;\n\n/**\n * Returns a record mapping each **unused** NodeType to `'false'` so build\n * plugins can dead-code-eliminate the corresponding plugin from the bundle.\n *\n * Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).\n * Build plugins that need `process.env.*` keys (Vite `define`, webpack\n * `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values\n * with `JSON.stringify`; Next.js `env:` can use the record directly.\n *\n * Only NodeTypes that are confirmed absent from all dictionaries get the\n * `'false'` value; used (or unknown) types are omitted so they default to\n * `true` inside `getPlugins` / `getBasePlugins`.\n *\n * @param usedNodeTypes - Set returned by `getUsedNodeTypes`.\n * @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.\n *\n * @example\n * // When only 'translation' is used:\n * getNodeTypeDefineVars(new Set(['translation']))\n * // {\n * // INTLAYER_NODE_TYPE_ENUMERATION: 'false',\n * // INTLAYER_NODE_TYPE_CONDITION: 'false',\n * // ...\n * // }\n */\nexport const getNodeTypeDefineVars = (\n usedNodeTypes: Set<string>\n): Record<string, string> => {\n // No dictionaries found yet → safe default: keep all plugins\n if (usedNodeTypes.size === 0) return {};\n\n const result: Record<string, string> = {};\n\n for (const nodeType of PLUGIN_NODE_TYPES) {\n if (!usedNodeTypes.has(nodeType)) {\n result[nodeTypeToEnvVar(nodeType)] = 'false';\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;AAKD,MAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AAEzC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,OAAK,MAAM,QAAQ,MAAO,kBAAiB,MAAM,OAAO;AACxD;;CAGF,MAAM,MAAM;AAEZ,KAAI,OAAO,IAAI,aAAa,SAC1B,QAAO,IAAI,IAAI,SAAS;AAG1B,MAAK,MAAM,OAAO,OAAO,KAAK,IAAI,CAChC,kBAAiB,IAAI,MAAM,OAAO;;;;;;;;;;AAYtC,MAAa,oBACX,iBACgB;CAChB,MAAM,yBAAS,IAAI,KAAa;CAChC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO;;;;;;;;AAST,MAAa,oBAAoB,aAC/B,sBAAsB,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B9C,MAAa,yBACX,kBAC2B;AAE3B,KAAI,cAAc,SAAS,EAAG,QAAO,EAAE;CAEvC,MAAM,SAAiC,EAAE;AAEzC,MAAK,MAAM,YAAY,kBACrB,KAAI,CAAC,cAAc,IAAI,SAAS,CAC9B,QAAO,iBAAiB,SAAS,IAAI;AAIzC,QAAO"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { getChunk } from "./getChunk.mjs";
|
|
|
9
9
|
import { assembleJSON, chunkJSON, reconstructFromSingleChunk } from "./chunkJSON.mjs";
|
|
10
10
|
import { getContentExtension } from "./getContentExtension.mjs";
|
|
11
11
|
import { getExtensionFromFormat, getFormatFromExtension } from "./getFormatFromExtension.mjs";
|
|
12
|
+
import { PLUGIN_NODE_TYPES, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar } from "./getUsedNodeTypes.mjs";
|
|
12
13
|
import { mergeChunks } from "./mergeChunks.mjs";
|
|
13
14
|
import { getGlobalLimiter, getTaskLimiter, parallelizeGlobal } from "./parallelizeGlobal.mjs";
|
|
14
15
|
import { reduceObjectFormat } from "./reduceObjectFormat.mjs";
|
|
@@ -19,4 +20,4 @@ import { runParallel } from "./runParallel/index.mjs";
|
|
|
19
20
|
import { sortAlphabetically } from "./sortAlphabetically.mjs";
|
|
20
21
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.mjs";
|
|
21
22
|
|
|
22
|
-
export { Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
|
23
|
+
export { PLUGIN_NODE_TYPES, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getNodeTypeDefineVars, getPathHash, getTaskLimiter, getUsedNodeTypes, mergeChunks, nodeTypeToEnvVar, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
1
|
+
import * as _$_intlayer_types_config0 from "@intlayer/types/config";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
|
|
4
4
|
type CreateDictionaryEntryPointOptions = {
|
|
@@ -8,7 +8,7 @@ type CreateDictionaryEntryPointOptions = {
|
|
|
8
8
|
/**
|
|
9
9
|
* This function generates a list of dictionaries in the main directory
|
|
10
10
|
*/
|
|
11
|
-
declare const createDictionaryEntryPoint: (configuration?: _intlayer_types_config0.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
|
|
11
|
+
declare const createDictionaryEntryPoint: (configuration?: _$_intlayer_types_config0.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint };
|
|
14
14
|
//# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"mappings":";;;KAqCY,iCAAA;EACV,OAAA;EACA,WAAA;AAAA;;;;cAMW,0BAAA,GACX,aAAA,GAkFD,
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"mappings":";;;KAqCY,iCAAA;EACV,OAAA;EACA,WAAA;AAAA;;;;cAMW,0BAAA,GACX,aAAA,GAkFD,yBAAA,CAlFC,cAAA,EACA,OAAA,GAAS,iCAAA,KAAsC,OAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
1
|
+
import * as _$_intlayer_types_config0 from "@intlayer/types/config";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/generateDictionaryListContent.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* This function generates the content of the dictionary list file
|
|
6
6
|
*/
|
|
7
|
-
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types_config0.IntlayerConfig) => string;
|
|
7
|
+
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _$_intlayer_types_config0.IntlayerConfig) => string;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { generateDictionaryListContent };
|
|
10
10
|
//# sourceMappingURL=generateDictionaryListContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;cAQa,6BAAA,GACX,YAAA,YACA,YAAA,UACA,UAAA,yBACA,MAAA,kBACA,aAAA,GA0CD,
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;cAQa,6BAAA,GACX,YAAA,YACA,YAAA,UACA,UAAA,yBACA,MAAA,kBACA,aAAA,GA0CD,yBAAA,CA1CC,cAAA"}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import * as _intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
1
|
+
import * as _$_intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
2
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
-
import * as _intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
|
|
4
|
-
import * as _intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
3
|
+
import * as _$_intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
|
|
4
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
5
5
|
|
|
6
6
|
//#region src/formatDictionary.d.ts
|
|
7
7
|
declare const formatDictionary: (dictionary: Dictionary) => Dictionary;
|
|
8
8
|
declare const formatDictionaries: (dictionaries: Dictionary[]) => Dictionary[];
|
|
9
9
|
declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
|
|
10
10
|
format: string;
|
|
11
|
-
content: _intlayer_core_messageFormat0.JsonValue;
|
|
11
|
+
content: _$_intlayer_core_messageFormat0.JsonValue;
|
|
12
12
|
$schema?: "https://intlayer.org/schema.json";
|
|
13
|
-
id?: _intlayer_types_dictionary0.DictionaryId;
|
|
13
|
+
id?: _$_intlayer_types_dictionary0.DictionaryId;
|
|
14
14
|
projectIds?: string[];
|
|
15
|
-
localId?: _intlayer_types_dictionary0.LocalDictionaryId;
|
|
16
|
-
localIds?: _intlayer_types_dictionary0.LocalDictionaryId[];
|
|
17
|
-
key: _intlayer_types_dictionary0.DictionaryKey;
|
|
15
|
+
localId?: _$_intlayer_types_dictionary0.LocalDictionaryId;
|
|
16
|
+
localIds?: _$_intlayer_types_dictionary0.LocalDictionaryId[];
|
|
17
|
+
key: _$_intlayer_types_dictionary0.DictionaryKey;
|
|
18
18
|
title?: string;
|
|
19
19
|
description?: string;
|
|
20
20
|
versions?: string[];
|
|
21
21
|
version?: string;
|
|
22
22
|
filePath?: string;
|
|
23
23
|
tags?: string[];
|
|
24
|
-
locale?: _intlayer_types_module_augmentation0.LocalesValues;
|
|
25
|
-
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
26
|
-
fill?: _intlayer_types_dictionary0.Fill;
|
|
24
|
+
locale?: _$_intlayer_types_module_augmentation0.LocalesValues;
|
|
25
|
+
contentAutoTransformation?: _$_intlayer_types_dictionary0.ContentAutoTransformation;
|
|
26
|
+
fill?: _$_intlayer_types_dictionary0.Fill;
|
|
27
27
|
filled?: true;
|
|
28
28
|
priority?: number;
|
|
29
|
-
importMode?: _intlayer_types_dictionary0.ImportMode;
|
|
30
|
-
location?: _intlayer_types_dictionary0.DictionaryLocation;
|
|
29
|
+
importMode?: _$_intlayer_types_dictionary0.ImportMode;
|
|
30
|
+
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
31
31
|
schema: undefined;
|
|
32
32
|
};
|
|
33
33
|
declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Dictionary | {
|
|
34
34
|
format: string;
|
|
35
|
-
content: _intlayer_core_messageFormat0.JsonValue;
|
|
35
|
+
content: _$_intlayer_core_messageFormat0.JsonValue;
|
|
36
36
|
$schema?: "https://intlayer.org/schema.json";
|
|
37
|
-
id?: _intlayer_types_dictionary0.DictionaryId;
|
|
37
|
+
id?: _$_intlayer_types_dictionary0.DictionaryId;
|
|
38
38
|
projectIds?: string[];
|
|
39
|
-
localId?: _intlayer_types_dictionary0.LocalDictionaryId;
|
|
40
|
-
localIds?: _intlayer_types_dictionary0.LocalDictionaryId[];
|
|
41
|
-
key: _intlayer_types_dictionary0.DictionaryKey;
|
|
39
|
+
localId?: _$_intlayer_types_dictionary0.LocalDictionaryId;
|
|
40
|
+
localIds?: _$_intlayer_types_dictionary0.LocalDictionaryId[];
|
|
41
|
+
key: _$_intlayer_types_dictionary0.DictionaryKey;
|
|
42
42
|
title?: string;
|
|
43
43
|
description?: string;
|
|
44
44
|
versions?: string[];
|
|
45
45
|
version?: string;
|
|
46
46
|
filePath?: string;
|
|
47
47
|
tags?: string[];
|
|
48
|
-
locale?: _intlayer_types_module_augmentation0.LocalesValues;
|
|
49
|
-
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
50
|
-
fill?: _intlayer_types_dictionary0.Fill;
|
|
48
|
+
locale?: _$_intlayer_types_module_augmentation0.LocalesValues;
|
|
49
|
+
contentAutoTransformation?: _$_intlayer_types_dictionary0.ContentAutoTransformation;
|
|
50
|
+
fill?: _$_intlayer_types_dictionary0.Fill;
|
|
51
51
|
filled?: true;
|
|
52
52
|
priority?: number;
|
|
53
|
-
importMode?: _intlayer_types_dictionary0.ImportMode;
|
|
54
|
-
location?: _intlayer_types_dictionary0.DictionaryLocation;
|
|
53
|
+
importMode?: _$_intlayer_types_dictionary0.ImportMode;
|
|
54
|
+
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
55
55
|
schema: undefined;
|
|
56
56
|
})[];
|
|
57
57
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;;cAUa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cA4B7C,kBAAA,GAAsB,YAAA,EAAc,UAAA,OAAe,UAAA;AAAA,cAGnD,sBAAA,GAA0B,UAAA,EAAY,UAAA,KAAU,UAAA;;WAAA,
|
|
1
|
+
{"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;;cAUa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cA4B7C,kBAAA,GAAsB,YAAA,EAAc,UAAA,OAAe,UAAA;AAAA,cAGnD,sBAAA,GAA0B,UAAA,EAAY,UAAA,KAAU,UAAA;;WAAA,+BAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;cA4BhD,wBAAA,GAA4B,YAAA,EAAc,UAAA,QAAY,UAAA;;WAAA,+BAAA,CAAA,SAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
import * as node_fs0 from "node:fs";
|
|
2
|
+
import * as _$node_fs0 from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/listDictionariesPath.d.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ import * as node_fs0 from "node:fs";
|
|
|
10
10
|
declare const listDictionaries: (configuration: IntlayerConfig) => Promise<string[]>;
|
|
11
11
|
declare const listDictionariesWithStats: (configuration: IntlayerConfig) => Promise<{
|
|
12
12
|
path: string;
|
|
13
|
-
stats: node_fs0.Stats;
|
|
13
|
+
stats: _$node_fs0.Stats;
|
|
14
14
|
}[]>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { listDictionaries, listDictionariesWithStats };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDictionariesPath.d.ts","names":[],"sources":["../../src/listDictionariesPath.ts"],"mappings":";;;;;;;AAUA;;cAAa,gBAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,cAgDU,yBAAA,GACX,aAAA,EAAe,cAAA,KAAc,OAAA;;SAAA,
|
|
1
|
+
{"version":3,"file":"listDictionariesPath.d.ts","names":[],"sources":["../../src/listDictionariesPath.ts"],"mappings":";;;;;;;AAUA;;cAAa,gBAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,cAgDU,yBAAA,GACX,aAAA,EAAe,cAAA,KAAc,OAAA;;SAAA,UAAA,CAAA,KAAA;AAAA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
|
|
3
3
|
//#region src/loadDictionaries/getIntlayerBundle.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.
|
|
6
|
-
*/
|
|
7
4
|
declare const getIntlayerBundle: (configuration: IntlayerConfig) => Promise<string>;
|
|
8
5
|
//#endregion
|
|
9
6
|
export { getIntlayerBundle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.d.ts","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.d.ts","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"mappings":";;;cA8Ca,iBAAA,GAA2B,aAAA,EAAe,cAAA,KAAc,OAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DictionariesStatus } from "./loadDictionaries.js";
|
|
2
|
-
import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
2
|
+
import * as _$_intlayer_types_config0 from "@intlayer/types/config";
|
|
3
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
import { DictionaryAPI } from "@intlayer/backend";
|
|
5
5
|
|
|
6
6
|
//#region src/loadDictionaries/loadRemoteDictionaries.d.ts
|
|
7
7
|
declare const formatDistantDictionaries: (dictionaries: (DictionaryAPI | Dictionary)[]) => Dictionary[];
|
|
8
|
-
declare const loadRemoteDictionaries: (configuration?: _intlayer_types_config0.IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: {
|
|
8
|
+
declare const loadRemoteDictionaries: (configuration?: _$_intlayer_types_config0.IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: {
|
|
9
9
|
onStartRemoteCheck?: () => void;
|
|
10
10
|
onStopRemoteCheck?: () => void;
|
|
11
11
|
onError?: (error: Error) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"mappings":";;;;;;cAUa,yBAAA,GACX,YAAA,GAAe,aAAA,GAAgB,UAAA,QAC9B,UAAA;AAAA,cAOU,sBAAA,GACX,aAAA,GAqID,
|
|
1
|
+
{"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"mappings":";;;;;;cAUa,yBAAA,GACX,YAAA,GAAe,aAAA,GAAgB,UAAA,QAC9B,UAAA;AAAA,cAOU,sBAAA,GACX,aAAA,GAqID,yBAAA,CArIC,cAAA,EACA,cAAA,IAAkB,MAAA,EAAQ,kBAAA,aAC1B,OAAA;EACE,kBAAA;EACA,iBAAA;EACA,OAAA,IAAW,KAAA,EAAO,KAAA;AAAA,MAEnB,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/getUsedNodeTypes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* NodeType strings that correspond to plugins that can be conditionally
|
|
6
|
+
* removed from the bundle when unused.
|
|
7
|
+
*/
|
|
8
|
+
declare const PLUGIN_NODE_TYPES: readonly ["translation", "enumeration", "condition", "insertion", "gender", "nested", "file", "markdown", "html"];
|
|
9
|
+
type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Returns the set of NodeType strings actually used across the given
|
|
12
|
+
* built dictionaries.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
16
|
+
* // Set { 'translation', 'enumeration' }
|
|
17
|
+
*/
|
|
18
|
+
declare const getUsedNodeTypes: (dictionaries: Record<string, Dictionary> | Dictionary[]) => Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
24
|
+
*/
|
|
25
|
+
declare const nodeTypeToEnvVar: (nodeType: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
28
|
+
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
29
|
+
*
|
|
30
|
+
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
31
|
+
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
32
|
+
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
33
|
+
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
34
|
+
*
|
|
35
|
+
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
36
|
+
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
37
|
+
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
38
|
+
*
|
|
39
|
+
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
40
|
+
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // When only 'translation' is used:
|
|
44
|
+
* getNodeTypeDefineVars(new Set(['translation']))
|
|
45
|
+
* // {
|
|
46
|
+
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
47
|
+
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
48
|
+
* // ...
|
|
49
|
+
* // }
|
|
50
|
+
*/
|
|
51
|
+
declare const getNodeTypeDefineVars: (usedNodeTypes: Set<string>) => Record<string, string>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { PLUGIN_NODE_TYPES, PluginNodeType, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar };
|
|
54
|
+
//# sourceMappingURL=getUsedNodeTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.d.ts","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"mappings":";;;;;AAMA;;cAAa,iBAAA;AAAA,KAYD,cAAA,WAAyB,iBAAA;;AAArC;;;;;AA8BA;;cAAa,gBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,GAAA;;;;;;;cAmBU,gBAAA,GAAoB,QAAA;;;;;;;AAAjC;;;;;AA4BA;;;;;;;;;;;;;;cAAa,qBAAA,GACX,aAAA,EAAe,GAAA,aACd,MAAA"}
|
|
@@ -6,6 +6,7 @@ import { formatLocale, formatPath } from "./formatter.js";
|
|
|
6
6
|
import { getChunk } from "./getChunk.js";
|
|
7
7
|
import { getContentExtension } from "./getContentExtension.js";
|
|
8
8
|
import { getPathHash } from "./getPathHash.js";
|
|
9
|
+
import { PLUGIN_NODE_TYPES, PluginNodeType, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar } from "./getUsedNodeTypes.js";
|
|
9
10
|
import { mergeChunks } from "./mergeChunks.js";
|
|
10
11
|
import { parallelize } from "./parallelize.js";
|
|
11
12
|
import { Queue, pLimit } from "./pLimit.js";
|
|
@@ -18,4 +19,4 @@ import { ParallelHandle, runParallel } from "./runParallel/index.js";
|
|
|
18
19
|
import { sortAlphabetically } from "./sortAlphabetically.js";
|
|
19
20
|
import { splitTextByLines } from "./splitTextByLine.js";
|
|
20
21
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.js";
|
|
21
|
-
export { Extension, Format, JSONObject, JsonChunk, ParallelHandle, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
|
22
|
+
export { Extension, Format, JSONObject, JsonChunk, PLUGIN_NODE_TYPES, ParallelHandle, PluginNodeType, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getNodeTypeDefineVars, getPathHash, getTaskLimiter, getUsedNodeTypes, mergeChunks, nodeTypeToEnvVar, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
package/dist/types/watcher.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
3
|
-
import * as chokidar from "chokidar";
|
|
3
|
+
import * as _$chokidar from "chokidar";
|
|
4
4
|
import { ChokidarOptions } from "chokidar";
|
|
5
5
|
|
|
6
6
|
//#region src/watcher.d.ts
|
|
@@ -9,7 +9,7 @@ type WatchOptions = ChokidarOptions & {
|
|
|
9
9
|
configOptions?: GetConfigurationOptions;
|
|
10
10
|
skipPrepare?: boolean;
|
|
11
11
|
};
|
|
12
|
-
declare const watch: (options?: WatchOptions) => chokidar.FSWatcher;
|
|
12
|
+
declare const watch: (options?: WatchOptions) => _$chokidar.FSWatcher;
|
|
13
13
|
declare const buildAndWatchIntlayer: (options?: WatchOptions) => Promise<void>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { buildAndWatchIntlayer, watch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAwDK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAwDK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,UAAA,CAAA,SAAA;AAAA,cA6J/B,qBAAA,GAA+B,OAAA,GAAU,YAAA,KAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@babel/parser": "7.29.0",
|
|
113
|
-
"@intlayer/api": "8.
|
|
114
|
-
"@intlayer/config": "8.
|
|
115
|
-
"@intlayer/core": "8.
|
|
116
|
-
"@intlayer/dictionaries-entry": "8.
|
|
117
|
-
"@intlayer/remote-dictionaries-entry": "8.
|
|
118
|
-
"@intlayer/types": "8.
|
|
119
|
-
"@intlayer/unmerged-dictionaries-entry": "8.
|
|
113
|
+
"@intlayer/api": "8.6.0",
|
|
114
|
+
"@intlayer/config": "8.6.0",
|
|
115
|
+
"@intlayer/core": "8.6.0",
|
|
116
|
+
"@intlayer/dictionaries-entry": "8.6.0",
|
|
117
|
+
"@intlayer/remote-dictionaries-entry": "8.6.0",
|
|
118
|
+
"@intlayer/types": "8.6.0",
|
|
119
|
+
"@intlayer/unmerged-dictionaries-entry": "8.6.0",
|
|
120
120
|
"chokidar": "3.6.0",
|
|
121
121
|
"defu": "6.1.4",
|
|
122
122
|
"fast-glob": "3.3.3",
|
|
@@ -130,9 +130,9 @@
|
|
|
130
130
|
"@utils/ts-config-types": "1.0.4",
|
|
131
131
|
"@utils/tsdown-config": "1.0.4",
|
|
132
132
|
"rimraf": "6.1.3",
|
|
133
|
-
"tsdown": "0.21.
|
|
133
|
+
"tsdown": "0.21.7",
|
|
134
134
|
"typescript": "6.0.2",
|
|
135
|
-
"vitest": "4.1.
|
|
135
|
+
"vitest": "4.1.2",
|
|
136
136
|
"zod": "4.3.6"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|