@intlayer/chokidar 8.5.2 → 8.6.1
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/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getUsedNodeTypes.cjs +68 -0
- package/dist/cjs/utils/getUsedNodeTypes.cjs.map +1 -0
- package/dist/cjs/utils/index.cjs +6 -0
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +23 -36
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getUsedNodeTypes.mjs +62 -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/formatter.d.ts +3 -2
- package/dist/types/utils/formatter.d.ts.map +1 -1
- package/dist/types/utils/getUsedNodeTypes.d.ts +28 -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 +11 -12
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.cjs","names":["configuration","ANSIColors","ENGLISH"],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize
|
|
1
|
+
{"version":3,"file":"formatter.cjs","names":["configuration","ANSIColors","ENGLISH"],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n type ANSIColorsType,\n colorize,\n colorizePath,\n} from '@intlayer/config/logger';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColorsType | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/') ? relative(configuration.system.baseDir, path) : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColorsType | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,cACX,MACA,UAEA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SACJ,KAAK,WAAW,IAAI,2BAAYA,+BAAc,OAAO,SAAS,KAAK,GAAG,KACvE,CACA,KAAK,iBACJ,UAAU,QAAQ,yDAA4B,cAAc,MAAM,CACnE,CACA,KAAK,KAAK;AAEf,MAAa,gBACX,QACA,QAAgCC,wBAAW,UAE3C,CAAC,OAAO,CACL,MAAM,CACN,KAAK,WAAW,kDAAiB,QAAQC,gCAAQ,CAAC,IAAI,OAAO,GAAG,CAChE,KAAK,SAAU,UAAU,QAAQ,6CAAgB,MAAM,MAAM,CAAE,CAC/D,KAAK,KAAK"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_utils_parallelize = require('./parallelize.cjs');
|
|
4
|
+
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
5
|
+
|
|
6
|
+
//#region src/utils/getUsedNodeTypes.ts
|
|
7
|
+
/** Recursively collect every `nodeType` string found in a value. */
|
|
8
|
+
const collectNodeTypes = (value, result) => {
|
|
9
|
+
if (!value || typeof value !== "object") return;
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
for (const item of value) collectNodeTypes(item, result);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const obj = value;
|
|
15
|
+
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
16
|
+
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns the set of NodeType strings actually used across the given
|
|
20
|
+
* built dictionaries.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
24
|
+
* // Set { 'translation', 'enumeration' }
|
|
25
|
+
*/
|
|
26
|
+
const getUsedNodeTypes = (dictionaries) => {
|
|
27
|
+
const result = /* @__PURE__ */ new Set();
|
|
28
|
+
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
29
|
+
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
30
|
+
return [...result];
|
|
31
|
+
};
|
|
32
|
+
const getUnusedNodeTypes = (dictionaries) => {
|
|
33
|
+
const usedNodeTypes = getUsedNodeTypes(dictionaries);
|
|
34
|
+
return _intlayer_types_nodeType.PLUGIN_NODE_TYPES.filter((nodeType) => !usedNodeTypes.includes(nodeType));
|
|
35
|
+
};
|
|
36
|
+
const getUsedNodeTypesAsync = async (dictionaries) => {
|
|
37
|
+
const results = await require_utils_parallelize.parallelize(Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries), async (dictionary) => {
|
|
38
|
+
const result = /* @__PURE__ */ new Set();
|
|
39
|
+
collectNodeTypes(dictionary.content, result);
|
|
40
|
+
return result;
|
|
41
|
+
});
|
|
42
|
+
const finalResult = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const res of results) for (const val of res) finalResult.add(val);
|
|
44
|
+
return [...finalResult];
|
|
45
|
+
};
|
|
46
|
+
const getUnusedNodeTypesAsync = async (dictionaries) => {
|
|
47
|
+
const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);
|
|
48
|
+
return _intlayer_types_nodeType.PLUGIN_NODE_TYPES.filter((nodeType) => !usedNodeTypes.includes(nodeType));
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* formatNodeTypeToEnvVar(['enumeration']) // { 'INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
55
|
+
* formatNodeTypeToEnvVar(['enumeration'], true) // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
56
|
+
*/
|
|
57
|
+
const formatNodeTypeToEnvVar = (nodeTypes, addProcessEnv = false) => nodeTypes.reduce((acc, nodeType) => {
|
|
58
|
+
acc[addProcessEnv ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}` : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`] = "\"false\"";
|
|
59
|
+
return acc;
|
|
60
|
+
}, {});
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.formatNodeTypeToEnvVar = formatNodeTypeToEnvVar;
|
|
64
|
+
exports.getUnusedNodeTypes = getUnusedNodeTypes;
|
|
65
|
+
exports.getUnusedNodeTypesAsync = getUnusedNodeTypesAsync;
|
|
66
|
+
exports.getUsedNodeTypes = getUsedNodeTypes;
|
|
67
|
+
exports.getUsedNodeTypesAsync = getUsedNodeTypesAsync;
|
|
68
|
+
//# sourceMappingURL=getUsedNodeTypes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.cjs","names":["PLUGIN_NODE_TYPES","parallelize"],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { PLUGIN_NODE_TYPES } from '@intlayer/types/nodeType';\nimport { parallelize } from './parallelize';\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): PluginNodeType[] => {\n const result = new Set<PluginNodeType>();\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\nexport const getUnusedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const usedNodeTypes = getUsedNodeTypes(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\nexport const getUsedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n const results = await parallelize(dicts, async (dictionary) => {\n const result = new Set<PluginNodeType>();\n\n collectNodeTypes(dictionary.content, result as Set<string>);\n\n return result;\n });\n\n const finalResult = new Set<PluginNodeType>();\n\n for (const res of results) {\n for (const val of res) {\n finalResult.add(val);\n }\n }\n\n return [...finalResult];\n};\n\nexport const getUnusedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration']) // { 'INTLAYER_NODE_TYPE_ENUMERATION': 'false' }\n * formatNodeTypeToEnvVar(['enumeration'], true) // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': 'false' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n"],"mappings":";;;;;;;AAOA,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,iBACqB;CACrB,MAAM,yBAAS,IAAI,KAAqB;CACxC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO,CAAC,GAAG,OAAO;;AAGpB,MAAa,sBACX,iBACqB;CACrB,MAAM,gBAAgB,iBAAiB,aAAa;AAEpD,QAAOA,2CAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,SAAS,CAChD;;AAGH,MAAa,wBAAwB,OACnC,iBAC8B;CAK9B,MAAM,UAAU,MAAMC,sCAJR,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa,EAEU,OAAO,eAAe;EAC7D,MAAM,yBAAS,IAAI,KAAqB;AAExC,mBAAiB,WAAW,SAAS,OAAsB;AAE3D,SAAO;GACP;CAEF,MAAM,8BAAc,IAAI,KAAqB;AAE7C,MAAK,MAAM,OAAO,QAChB,MAAK,MAAM,OAAO,IAChB,aAAY,IAAI,IAAI;AAIxB,QAAO,CAAC,GAAG,YAAY;;AAGzB,MAAa,0BAA0B,OACrC,iBAC8B;CAC9B,MAAM,gBAAgB,MAAM,sBAAsB,aAAa;AAE/D,QAAOD,2CAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,SAAS,CAChD;;;;;;;;;AAUH,MAAa,0BACX,WACA,gBAAyB,UAEzB,UAAU,QACP,KAAK,aAAa;AACjB,KACE,gBACI,kCAAkC,SAAS,aAAa,KACxD,sBAAsB,SAAS,aAAa,MAC9C;AACJ,QAAO;GAET,EAAE,CACH"}
|
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');
|
|
@@ -26,6 +27,7 @@ exports.autoDecorateContent = require_utils_autoDecorateContent.autoDecorateCont
|
|
|
26
27
|
exports.buildComponentFilesList = require_utils_buildComponentFilesList.buildComponentFilesList;
|
|
27
28
|
exports.chunkJSON = require_utils_chunkJSON.chunkJSON;
|
|
28
29
|
exports.formatLocale = require_utils_formatter.formatLocale;
|
|
30
|
+
exports.formatNodeTypeToEnvVar = require_utils_getUsedNodeTypes.formatNodeTypeToEnvVar;
|
|
29
31
|
exports.formatPath = require_utils_formatter.formatPath;
|
|
30
32
|
exports.getChunk = require_utils_getChunk.getChunk;
|
|
31
33
|
exports.getContentExtension = require_utils_getContentExtension.getContentExtension;
|
|
@@ -34,6 +36,10 @@ exports.getFormatFromExtension = require_utils_getFormatFromExtension.getFormatF
|
|
|
34
36
|
exports.getGlobalLimiter = require_utils_parallelizeGlobal.getGlobalLimiter;
|
|
35
37
|
exports.getPathHash = require_utils_getPathHash.getPathHash;
|
|
36
38
|
exports.getTaskLimiter = require_utils_parallelizeGlobal.getTaskLimiter;
|
|
39
|
+
exports.getUnusedNodeTypes = require_utils_getUsedNodeTypes.getUnusedNodeTypes;
|
|
40
|
+
exports.getUnusedNodeTypesAsync = require_utils_getUsedNodeTypes.getUnusedNodeTypesAsync;
|
|
41
|
+
exports.getUsedNodeTypes = require_utils_getUsedNodeTypes.getUsedNodeTypes;
|
|
42
|
+
exports.getUsedNodeTypesAsync = require_utils_getUsedNodeTypes.getUsedNodeTypesAsync;
|
|
37
43
|
exports.mergeChunks = require_utils_mergeChunks.mergeChunks;
|
|
38
44
|
exports.pLimit = require_utils_pLimit.pLimit;
|
|
39
45
|
exports.parallelize = require_utils_parallelize.parallelize;
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n type ANSIColorsType,\n colorize,\n colorizePath,\n} from '@intlayer/config/logger';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColorsType | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/') ? relative(configuration.system.baseDir, path) : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColorsType | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":";;;;;;;;AAYA,MAAa,cACX,MACA,UAEA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SACJ,KAAK,WAAW,IAAI,GAAG,SAAS,cAAc,OAAO,SAAS,KAAK,GAAG,KACvE,CACA,KAAK,iBACJ,UAAU,QAAQ,eAAe,aAAa,cAAc,MAAM,CACnE,CACA,KAAK,KAAK;AAEf,MAAa,gBACX,QACA,QAAgC,WAAW,UAE3C,CAAC,OAAO,CACL,MAAM,CACN,KAAK,WAAW,GAAG,cAAc,QAAQ,QAAQ,CAAC,IAAI,OAAO,GAAG,CAChE,KAAK,SAAU,UAAU,QAAQ,OAAO,SAAS,MAAM,MAAM,CAAE,CAC/D,KAAK,KAAK"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { parallelize } from "./parallelize.mjs";
|
|
2
|
+
import { PLUGIN_NODE_TYPES } from "@intlayer/types/nodeType";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/getUsedNodeTypes.ts
|
|
5
|
+
/** Recursively collect every `nodeType` string found in a value. */
|
|
6
|
+
const collectNodeTypes = (value, result) => {
|
|
7
|
+
if (!value || typeof value !== "object") return;
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
for (const item of value) collectNodeTypes(item, result);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const obj = value;
|
|
13
|
+
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
14
|
+
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Returns the set of NodeType strings actually used across the given
|
|
18
|
+
* built dictionaries.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
22
|
+
* // Set { 'translation', 'enumeration' }
|
|
23
|
+
*/
|
|
24
|
+
const getUsedNodeTypes = (dictionaries) => {
|
|
25
|
+
const result = /* @__PURE__ */ new Set();
|
|
26
|
+
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
27
|
+
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
28
|
+
return [...result];
|
|
29
|
+
};
|
|
30
|
+
const getUnusedNodeTypes = (dictionaries) => {
|
|
31
|
+
const usedNodeTypes = getUsedNodeTypes(dictionaries);
|
|
32
|
+
return PLUGIN_NODE_TYPES.filter((nodeType) => !usedNodeTypes.includes(nodeType));
|
|
33
|
+
};
|
|
34
|
+
const getUsedNodeTypesAsync = async (dictionaries) => {
|
|
35
|
+
const results = await parallelize(Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries), async (dictionary) => {
|
|
36
|
+
const result = /* @__PURE__ */ new Set();
|
|
37
|
+
collectNodeTypes(dictionary.content, result);
|
|
38
|
+
return result;
|
|
39
|
+
});
|
|
40
|
+
const finalResult = /* @__PURE__ */ new Set();
|
|
41
|
+
for (const res of results) for (const val of res) finalResult.add(val);
|
|
42
|
+
return [...finalResult];
|
|
43
|
+
};
|
|
44
|
+
const getUnusedNodeTypesAsync = async (dictionaries) => {
|
|
45
|
+
const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);
|
|
46
|
+
return PLUGIN_NODE_TYPES.filter((nodeType) => !usedNodeTypes.includes(nodeType));
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* formatNodeTypeToEnvVar(['enumeration']) // { 'INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
53
|
+
* formatNodeTypeToEnvVar(['enumeration'], true) // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
54
|
+
*/
|
|
55
|
+
const formatNodeTypeToEnvVar = (nodeTypes, addProcessEnv = false) => nodeTypes.reduce((acc, nodeType) => {
|
|
56
|
+
acc[addProcessEnv ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}` : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`] = "\"false\"";
|
|
57
|
+
return acc;
|
|
58
|
+
}, {});
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { formatNodeTypeToEnvVar, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync };
|
|
62
|
+
//# 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';\nimport { PLUGIN_NODE_TYPES } from '@intlayer/types/nodeType';\nimport { parallelize } from './parallelize';\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): PluginNodeType[] => {\n const result = new Set<PluginNodeType>();\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\nexport const getUnusedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const usedNodeTypes = getUsedNodeTypes(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\nexport const getUsedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n const results = await parallelize(dicts, async (dictionary) => {\n const result = new Set<PluginNodeType>();\n\n collectNodeTypes(dictionary.content, result as Set<string>);\n\n return result;\n });\n\n const finalResult = new Set<PluginNodeType>();\n\n for (const res of results) {\n for (const val of res) {\n finalResult.add(val);\n }\n }\n\n return [...finalResult];\n};\n\nexport const getUnusedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration']) // { 'INTLAYER_NODE_TYPE_ENUMERATION': 'false' }\n * formatNodeTypeToEnvVar(['enumeration'], true) // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': 'false' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n"],"mappings":";;;;;AAOA,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,iBACqB;CACrB,MAAM,yBAAS,IAAI,KAAqB;CACxC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO,CAAC,GAAG,OAAO;;AAGpB,MAAa,sBACX,iBACqB;CACrB,MAAM,gBAAgB,iBAAiB,aAAa;AAEpD,QAAO,kBAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,SAAS,CAChD;;AAGH,MAAa,wBAAwB,OACnC,iBAC8B;CAK9B,MAAM,UAAU,MAAM,YAJR,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa,EAEU,OAAO,eAAe;EAC7D,MAAM,yBAAS,IAAI,KAAqB;AAExC,mBAAiB,WAAW,SAAS,OAAsB;AAE3D,SAAO;GACP;CAEF,MAAM,8BAAc,IAAI,KAAqB;AAE7C,MAAK,MAAM,OAAO,QAChB,MAAK,MAAM,OAAO,IAChB,aAAY,IAAI,IAAI;AAIxB,QAAO,CAAC,GAAG,YAAY;;AAGzB,MAAa,0BAA0B,OACrC,iBAC8B;CAC9B,MAAM,gBAAgB,MAAM,sBAAsB,aAAa;AAE/D,QAAO,kBAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,SAAS,CAChD;;;;;;;;;AAUH,MAAa,0BACX,WACA,gBAAyB,UAEzB,UAAU,QACP,KAAK,aAAa;AACjB,KACE,gBACI,kCAAkC,SAAS,aAAa,KACxD,sBAAsB,SAAS,aAAa,MAC9C;AACJ,QAAO;GAET,EAAE,CACH"}
|
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 { formatNodeTypeToEnvVar, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync } 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 { Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatNodeTypeToEnvVar, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, mergeChunks, 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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ANSIColorsType } from "@intlayer/config/logger";
|
|
2
3
|
|
|
3
4
|
//#region src/utils/formatter.d.ts
|
|
4
|
-
declare const formatPath: (path: string | string[], color?:
|
|
5
|
-
declare const formatLocale: (locale: LocalesValues | LocalesValues[], color?:
|
|
5
|
+
declare const formatPath: (path: string | string[], color?: ANSIColorsType | false) => string;
|
|
6
|
+
declare const formatLocale: (locale: LocalesValues | LocalesValues[], color?: ANSIColorsType | false) => string;
|
|
6
7
|
//#endregion
|
|
7
8
|
export { formatLocale, formatPath };
|
|
8
9
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":";;;;cAYa,UAAA,GACX,IAAA,qBACA,KAAA,GAAQ,cAAA;AAAA,cAYG,YAAA,GACX,MAAA,EAAQ,aAAA,GAAgB,aAAA,IACxB,KAAA,GAAO,cAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
2
|
+
import { PLUGIN_NODE_TYPES } from "@intlayer/types/nodeType";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/getUsedNodeTypes.d.ts
|
|
5
|
+
type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Returns the set of NodeType strings actually used across the given
|
|
8
|
+
* built dictionaries.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
12
|
+
* // Set { 'translation', 'enumeration' }
|
|
13
|
+
*/
|
|
14
|
+
declare const getUsedNodeTypes: (dictionaries: Record<string, Dictionary> | Dictionary[]) => PluginNodeType[];
|
|
15
|
+
declare const getUnusedNodeTypes: (dictionaries: Record<string, Dictionary> | Dictionary[]) => PluginNodeType[];
|
|
16
|
+
declare const getUsedNodeTypesAsync: (dictionaries: Record<string, Dictionary> | Dictionary[]) => Promise<PluginNodeType[]>;
|
|
17
|
+
declare const getUnusedNodeTypesAsync: (dictionaries: Record<string, Dictionary> | Dictionary[]) => Promise<PluginNodeType[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a NodeType key to its corresponding env-var name.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* formatNodeTypeToEnvVar(['enumeration']) // { 'INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
23
|
+
* formatNodeTypeToEnvVar(['enumeration'], true) // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': 'false' }
|
|
24
|
+
*/
|
|
25
|
+
declare const formatNodeTypeToEnvVar: (nodeTypes: string[], addProcessEnv?: boolean) => Record<string, string>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { PluginNodeType, formatNodeTypeToEnvVar, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync };
|
|
28
|
+
//# sourceMappingURL=getUsedNodeTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.d.ts","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"mappings":";;;;KAIY,cAAA,WAAyB,iBAAA;;AAArC;;;;;AA8BA;;cAAa,gBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,cAAA;AAAA,cAaU,kBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,cAAA;AAAA,cAQU,qBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,OAAA,CAAQ,cAAA;AAAA,cAwBE,uBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,OAAA,CAAQ,cAAA;;;;;;;;cAeE,sBAAA,GACX,SAAA,YACA,aAAA,eACC,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 { PluginNodeType, formatNodeTypeToEnvVar, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync } 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, ParallelHandle, PluginNodeType, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatNodeTypeToEnvVar, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, mergeChunks, 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.1",
|
|
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": [
|
|
@@ -109,19 +109,18 @@
|
|
|
109
109
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@
|
|
113
|
-
"@intlayer/
|
|
114
|
-
"@intlayer/
|
|
115
|
-
"@intlayer/
|
|
116
|
-
"@intlayer/dictionaries-entry": "8.
|
|
117
|
-
"@intlayer/
|
|
118
|
-
"@intlayer/
|
|
119
|
-
"@intlayer/unmerged-dictionaries-entry": "8.5.2",
|
|
112
|
+
"@intlayer/api": "8.6.1",
|
|
113
|
+
"@intlayer/config": "8.6.1",
|
|
114
|
+
"@intlayer/core": "8.6.1",
|
|
115
|
+
"@intlayer/dictionaries-entry": "8.6.1",
|
|
116
|
+
"@intlayer/remote-dictionaries-entry": "8.6.1",
|
|
117
|
+
"@intlayer/types": "8.6.1",
|
|
118
|
+
"@intlayer/unmerged-dictionaries-entry": "8.6.1",
|
|
120
119
|
"chokidar": "3.6.0",
|
|
121
120
|
"defu": "6.1.4",
|
|
122
121
|
"fast-glob": "3.3.3",
|
|
123
122
|
"recast": "^0.23.11",
|
|
124
|
-
"simple-git": "3.
|
|
123
|
+
"simple-git": "3.33.0",
|
|
125
124
|
"zod-to-ts": "2.0.0"
|
|
126
125
|
},
|
|
127
126
|
"devDependencies": {
|
|
@@ -130,9 +129,9 @@
|
|
|
130
129
|
"@utils/ts-config-types": "1.0.4",
|
|
131
130
|
"@utils/tsdown-config": "1.0.4",
|
|
132
131
|
"rimraf": "6.1.3",
|
|
133
|
-
"tsdown": "0.21.
|
|
132
|
+
"tsdown": "0.21.7",
|
|
134
133
|
"typescript": "6.0.2",
|
|
135
|
-
"vitest": "4.1.
|
|
134
|
+
"vitest": "4.1.2",
|
|
136
135
|
"zod": "4.3.6"
|
|
137
136
|
},
|
|
138
137
|
"engines": {
|