@intlayer/chokidar 7.5.12 → 7.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +2 -0
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/init/index.cjs +1 -1
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +3 -0
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/pLimit.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +13 -6
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +21 -17
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/index.cjs +2 -0
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +77 -0
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +10 -0
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +2 -0
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/init/index.mjs +1 -1
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
- package/dist/esm/utils/chunkJSON.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +3 -0
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/pLimit.mjs.map +1 -1
- package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
- package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +13 -6
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
- package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
- package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
- package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +21 -17
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/index.mjs +2 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +76 -0
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +11 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/formatDictionary.d.ts +15 -15
- package/dist/types/index.d.ts +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/getFormatFromExtension.d.ts +2 -2
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
- package/dist/types/utils/runOnce.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/detectFormatCommand.d.ts +1 -1
- package/dist/types/writeContentDeclaration/detectFormatCommand.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/index.d.ts +2 -1
- package/dist/types/writeContentDeclaration/transformJSONFile.d.ts +7 -0
- package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IndentationText, Node, Project, QuoteKind, SyntaxKind } from "ts-morph";
|
|
2
|
+
|
|
3
|
+
//#region src/writeContentDeclaration/transformJSONFile.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a value is a plain object (and not null/array)
|
|
6
|
+
*/
|
|
7
|
+
const isPlainObject = (value) => {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Safely formats a key for use in object literals.
|
|
12
|
+
* Always quotes keys to ensure compatibility with standard JSON files.
|
|
13
|
+
*/
|
|
14
|
+
const stringifyKey = (objectKey) => {
|
|
15
|
+
return JSON.stringify(objectKey);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Robustly finds a property in an ObjectLiteralExpression.
|
|
19
|
+
* Handles cases where the property name in the source file is quoted ("key") or unquoted (key).
|
|
20
|
+
*/
|
|
21
|
+
const getMatchingProperty = (node, key) => {
|
|
22
|
+
return node.getProperties().find((prop) => {
|
|
23
|
+
if (Node.isPropertyAssignment(prop)) {
|
|
24
|
+
const propName = prop.getName();
|
|
25
|
+
return propName === key || propName === `"${key}"` || propName === `'${key}'`;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Recursively updates the AST object literal with new data.
|
|
32
|
+
*/
|
|
33
|
+
const updateObjectLiteral = (node, data) => {
|
|
34
|
+
for (const [key, val] of Object.entries(data)) {
|
|
35
|
+
if (val === void 0) continue;
|
|
36
|
+
const stringifiedValue = JSON.stringify(val, null, 2);
|
|
37
|
+
if (stringifiedValue === void 0 && !isPlainObject(val)) continue;
|
|
38
|
+
const existingProp = getMatchingProperty(node, key);
|
|
39
|
+
if (isPlainObject(val)) if (existingProp && Node.isPropertyAssignment(existingProp)) {
|
|
40
|
+
const initializer = existingProp.getInitializer();
|
|
41
|
+
if (Node.isObjectLiteralExpression(initializer)) updateObjectLiteral(initializer, val);
|
|
42
|
+
else existingProp.setInitializer(stringifiedValue);
|
|
43
|
+
} else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
|
|
44
|
+
else node.addPropertyAssignment({
|
|
45
|
+
name: stringifyKey(key),
|
|
46
|
+
initializer: stringifiedValue
|
|
47
|
+
});
|
|
48
|
+
else if (existingProp && Node.isPropertyAssignment(existingProp)) existingProp.setInitializer(stringifiedValue);
|
|
49
|
+
else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
|
|
50
|
+
else node.addPropertyAssignment({
|
|
51
|
+
name: stringifyKey(key),
|
|
52
|
+
initializer: stringifiedValue
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const transformJSONFile = (fileContent, dictionary) => {
|
|
57
|
+
const project = new Project({
|
|
58
|
+
useInMemoryFileSystem: true,
|
|
59
|
+
manipulationSettings: {
|
|
60
|
+
indentationText: IndentationText.TwoSpaces,
|
|
61
|
+
quoteKind: QuoteKind.Double
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const dummyFileName = "temp.ts";
|
|
65
|
+
const wrappedContent = `const _config = ${fileContent.trim() || "{}"}`;
|
|
66
|
+
const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);
|
|
67
|
+
const objectLiteral = sourceFile.getVariableDeclaration("_config")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
68
|
+
if (!objectLiteral) return JSON.stringify(dictionary, null, 2);
|
|
69
|
+
updateObjectLiteral(objectLiteral, dictionary);
|
|
70
|
+
sourceFile.formatText();
|
|
71
|
+
return objectLiteral.getText();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { transformJSONFile };
|
|
76
|
+
//# sourceMappingURL=transformJSONFile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformJSONFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport {\n IndentationText,\n Node,\n type ObjectLiteralExpression,\n Project,\n QuoteKind,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a value is a plain object (and not null/array)\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Safely formats a key for use in object literals.\n * Always quotes keys to ensure compatibility with standard JSON files.\n */\nconst stringifyKey = (objectKey: string): string => {\n return JSON.stringify(objectKey);\n};\n\n/**\n * Robustly finds a property in an ObjectLiteralExpression.\n * Handles cases where the property name in the source file is quoted (\"key\") or unquoted (key).\n */\nconst getMatchingProperty = (node: ObjectLiteralExpression, key: string) => {\n return node.getProperties().find((prop) => {\n // We only care about property assignments (key: value)\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n // Check for strict match (unquoted identifier) or quoted match (string literal)\n // We check both double and single quotes to handle JSONC/JSON5 variations.\n return (\n propName === key || propName === `\"${key}\"` || propName === `'${key}'`\n );\n }\n return false;\n });\n};\n\n/**\n * Recursively updates the AST object literal with new data.\n */\nconst updateObjectLiteral = (\n node: ObjectLiteralExpression,\n data: Record<string, any>\n) => {\n for (const [key, val] of Object.entries(data)) {\n // Skip undefined values.\n if (val === undefined) continue;\n\n const stringifiedValue = JSON.stringify(val, null, 2);\n\n // Safety check: ensure we have a string unless we are recursing into an object\n if (stringifiedValue === undefined && !isPlainObject(val)) continue;\n\n // Use robust lookup instead of node.getProperty(key)\n const existingProp = getMatchingProperty(node, key);\n\n if (isPlainObject(val)) {\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n const initializer = existingProp.getInitializer();\n\n if (Node.isObjectLiteralExpression(initializer)) {\n // Recurse into nested object\n updateObjectLiteral(initializer, val);\n } else {\n // Property exists but is not an object (e.g. was null or number), overwrite with new object\n existingProp.setInitializer(stringifiedValue!);\n }\n } else if (existingProp) {\n // Property exists but isn't a simple assignment, overwrite it safely\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n // Property doesn't exist, add it\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n } else {\n // Handling Primitives / Arrays\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n existingProp.setInitializer(stringifiedValue!);\n } else if (existingProp) {\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n }\n }\n};\n\nexport const transformJSONFile = (\n fileContent: string,\n dictionary: Dictionary\n): string => {\n // Initialize a virtual project\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: {\n indentationText: IndentationText.TwoSpaces,\n quoteKind: QuoteKind.Double,\n },\n });\n\n // Wrap content in a variable declaration so it acts as a valid SourceFile\n const dummyFileName = 'temp.ts';\n const wrappedContent = `const _config = ${fileContent.trim() || '{}'}`;\n const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);\n\n // Locate the object literal\n const varDecl = sourceFile.getVariableDeclaration('_config');\n const objectLiteral = varDecl?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression\n );\n\n if (!objectLiteral) {\n // Fallback if parsing failed\n return JSON.stringify(dictionary, null, 2);\n }\n\n // Update the AST\n updateObjectLiteral(objectLiteral, dictionary);\n\n // Format text to ensure new properties are aligned\n sourceFile.formatText();\n\n // Extract the object literal text.\n return objectLiteral.getText();\n};\n"],"mappings":";;;;;;AAaA,MAAM,iBAAiB,UAAqD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;;AAO7E,MAAM,gBAAgB,cAA8B;AAClD,QAAO,KAAK,UAAU,UAAU;;;;;;AAOlC,MAAM,uBAAuB,MAA+B,QAAgB;AAC1E,QAAO,KAAK,eAAe,CAAC,MAAM,SAAS;AAEzC,MAAI,KAAK,qBAAqB,KAAK,EAAE;GACnC,MAAM,WAAW,KAAK,SAAS;AAG/B,UACE,aAAa,OAAO,aAAa,IAAI,IAAI,MAAM,aAAa,IAAI,IAAI;;AAGxE,SAAO;GACP;;;;;AAMJ,MAAM,uBACJ,MACA,SACG;AACH,MAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE;AAE7C,MAAI,QAAQ,OAAW;EAEvB,MAAM,mBAAmB,KAAK,UAAU,KAAK,MAAM,EAAE;AAGrD,MAAI,qBAAqB,UAAa,CAAC,cAAc,IAAI,CAAE;EAG3D,MAAM,eAAe,oBAAoB,MAAM,IAAI;AAEnD,MAAI,cAAc,IAAI,CACpB,KAAI,gBAAgB,KAAK,qBAAqB,aAAa,EAAE;GAC3D,MAAM,cAAc,aAAa,gBAAgB;AAEjD,OAAI,KAAK,0BAA0B,YAAY,CAE7C,qBAAoB,aAAa,IAAI;OAGrC,cAAa,eAAe,iBAAkB;aAEvC,aAET,cAAa,gBACX,GAAG,aAAa,IAAI,CAAC,IAAI,mBAC1B;MAGD,MAAK,sBAAsB;GACzB,MAAM,aAAa,IAAI;GACvB,aAAa;GACd,CAAC;WAIA,gBAAgB,KAAK,qBAAqB,aAAa,CACzD,cAAa,eAAe,iBAAkB;WACrC,aACT,cAAa,gBACX,GAAG,aAAa,IAAI,CAAC,IAAI,mBAC1B;MAED,MAAK,sBAAsB;GACzB,MAAM,aAAa,IAAI;GACvB,aAAa;GACd,CAAC;;;AAMV,MAAa,qBACX,aACA,eACW;CAEX,MAAM,UAAU,IAAI,QAAQ;EAC1B,uBAAuB;EACvB,sBAAsB;GACpB,iBAAiB,gBAAgB;GACjC,WAAW,UAAU;GACtB;EACF,CAAC;CAGF,MAAM,gBAAgB;CACtB,MAAM,iBAAiB,mBAAmB,YAAY,MAAM,IAAI;CAChE,MAAM,aAAa,QAAQ,iBAAiB,eAAe,eAAe;CAI1E,MAAM,gBADU,WAAW,uBAAuB,UAAU,EAC7B,qBAC7B,WAAW,wBACZ;AAED,KAAI,CAAC,cAEH,QAAO,KAAK,UAAU,YAAY,MAAM,EAAE;AAI5C,qBAAoB,eAAe,WAAW;AAG9C,YAAW,YAAY;AAGvB,QAAO,cAAc,SAAS"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
|
|
2
2
|
import { processContentDeclarationContent } from "./processContentDeclarationContent.mjs";
|
|
3
|
+
import { transformJSONFile } from "./transformJSONFile.mjs";
|
|
3
4
|
import { writeJSFile } from "./writeJSFile.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
7
|
import { dirname, extname, join, resolve } from "node:path";
|
|
6
8
|
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
7
9
|
import { getFilteredLocalesDictionary, getPerLocaleDictionary } from "@intlayer/core";
|
|
@@ -101,6 +103,14 @@ const writeFileWithDirectories = async (absoluteFilePath, dictionary, configurat
|
|
|
101
103
|
await writeFile(absoluteFilePath, `${JSON.stringify(dictionary, null, 2)}\n`);
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
106
|
+
if ([".jsonc", ".json5"].includes(extension)) {
|
|
107
|
+
let fileContent = "{}";
|
|
108
|
+
if (existsSync(absoluteFilePath)) try {
|
|
109
|
+
fileContent = await readFile(absoluteFilePath, "utf-8");
|
|
110
|
+
} catch {}
|
|
111
|
+
await writeFile(absoluteFilePath, transformJSONFile(fileContent, dictionary), "utf-8");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
104
114
|
await writeJSFile(absoluteFilePath, dictionary, configuration);
|
|
105
115
|
try {
|
|
106
116
|
await rm(join(configuration.content.cacheDir, "intlayer-prepared.lock"), { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.mjs","names":["
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.mjs","names":["extension"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n live: dictionary.live,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n // Handle JSONC, and JSON5 via the AST transformer\n if (['.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(fileContent, dictionary);\n\n // We use standard writeFile because transformedContent is already a string\n await writeFile(absoluteFilePath, transformedContent, 'utf-8');\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAM,iCAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,WAAU,uBACR,qBACA,WAAW,OACZ,CAAC;UACO,WACT,WAAU,6BACR,qBACA,WACD,CAAC;CAGJ,IAAI,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EACvB,MAAM,kBAAkB,MAAM,OAAO,eAAe;GAClD,YAAY;GACZ;GACD,CAAC;AAEF,MAAI,gBACF,sBAAqB;;AAQ3B,KAAI,EAFF,mBAAmB,WAAW,mBAAmB,KAE1B,QAAO;CAEhC,IAAI,SAAqB;EACvB,KAAK,WAAW;EAChB,IAAI,WAAW;EACf,OAAO,WAAW;EAClB,aAAa,WAAW;EACxB,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,UAAU,WAAW;EACrB,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB;EACD;AAUD,KAFe,uBAFb,WAAW,WAAW,QAAQ,WAAW,SAAS,GAAG,QAEP,KAGnC,UACX,mBAAmB,WACnB,mBAAmB,IAEnB,UAAS;EACP,SAAS;EACT,GAAG;EACJ;AAGH,QAAO;;AAST,MAAM,iBAAiB,EACrB,qBAAqB,yBACtB;AAED,MAAa,0BAA0B,OACrC,YACA,eACA,YACwD;CACxD,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,qBAAqB,eAAe;EAC1C,GAAG;EACH,GAAG;EACJ;CAED,MAAM,4BAA4B,KAAK,SAAS,oBAAoB;CAOpE,MAAM,qBAL6B,wBAAwB,cAAc,CAEvE,WAAW,MAGoC,MAC9C,OAAO,GAAG,YAAY,WAAW,QACnC;CAED,MAAM,8BAA8B,MAAM,yBACxC,YACA,eACA,WACD;AAED,KAAI,oBAAoB,UAAU;EAEhC,MAAM,gBAAgB,kBAAkB,oBAAoB,WAAW;EAEvE,MAAM,WAAW,QACf,cAAc,QAAQ,SACtB,mBAAmB,SACpB;AAGD,MAAI,cACF,QAAO;GACL,QAAQ;GACR,MAAM;GACP;AAGH,QAAM,yBACJ,UACA,6BACA,cACD;AAED,SAAO;GAAE,QAAQ;GAAW,MAAM;GAAU;;AAG9C,KAAI,WAAW,UAAU;EACvB,MAAM,WAAW,QACf,cAAc,QAAQ,SACtB,WAAW,SACZ;AAED,QAAM,yBACJ,UACA,6BACA,cACD;AAED,SAAO;GAAE,QAAQ;GAAW,MAAM;GAAU;;CAI9C,MAAM,yBAAyB,KAC7B,2BACA,GAAG,WAAW,IAAI,eACnB;AAED,OAAM,yBACJ,wBACA,6BACA,cACD;AAED,QAAO;EACL,QAAQ;EACR,MAAM;EACP;;AAGH,MAAM,2BAA2B,OAC/B,kBACA,YACA,kBACkB;AAKlB,OAAM,MAHM,QAAQ,iBAAiB,EAGpB,EAAE,WAAW,MAAM,CAAC;CAErC,MAAM,YAAY,QAAQ,iBAAiB;AAK3C,KAAI,CAJuB,cAAc,QAAQ,eAAe,KAC7D,gBAAc,QAAQA,YAAU,CAClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,QAAM,UAAU,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAIF,KAAI,CAAC,UAAU,SAAS,CAAC,SAAS,UAAU,EAAE;EAC5C,IAAI,cAAc;AAElB,MAAI,WAAW,iBAAiB,CAC9B,KAAI;AACF,iBAAc,MAAM,SAAS,kBAAkB,QAAQ;UACjD;AAQV,QAAM,UAAU,kBAHW,kBAAkB,aAAa,WAAW,EAGf,QAAQ;AAC9D;;AAGF,OAAM,YAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AAKF,QAAM,GAJe,KACnB,cAAc,QAAQ,UACtB,yBACD,EACsB,EAAE,WAAW,MAAM,CAAC;SACrC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
|
|
2
|
+
import { detectFormatCommand } from "./detectFormatCommand.mjs";
|
|
2
3
|
import { transformJSFile } from "./transformJSFile.mjs";
|
|
3
4
|
import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
|
|
4
|
-
import { detectFormatCommand } from "./detectFormatCommand.mjs";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { readFile, writeFile } from "node:fs/promises";
|
|
7
7
|
import { extname } from "node:path";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
2
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
3
3
|
import { LocalizedDictionaryOutput } from "./writeDynamicDictionary.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _intlayer_types3 from "@intlayer/types";
|
|
5
5
|
import { Dictionary } from "@intlayer/types";
|
|
6
6
|
|
|
7
7
|
//#region src/buildIntlayerDictionary/buildIntlayerDictionary.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
10
10
|
*/
|
|
11
|
-
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?:
|
|
11
|
+
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types3.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
|
|
12
12
|
unmergedDictionaries: UnmergedDictionaryOutput;
|
|
13
13
|
mergedDictionaries: MergedDictionaryOutput;
|
|
14
14
|
dynamicDictionaries: LocalizedDictionaryOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAca,4CACe,8BAAU,
|
|
1
|
+
{"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAca,4CACe,8BAAU,gBAAA,CACpC,mFAE8B;wBAFI;EAFvB,kBAsEZ,wBAAA;EArE2B,mBAAA,2BAAA;EAAU,iBACpC,2BAAA;CAAkC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { Dictionary, Locale } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
@@ -12,7 +12,7 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
|
12
12
|
/**
|
|
13
13
|
* This function generates the content of the dictionary list file
|
|
14
14
|
*/
|
|
15
|
-
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
15
|
+
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types0.IntlayerConfig) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Write the localized dictionaries to the dictionariesDir
|
|
18
18
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -29,7 +29,7 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
|
|
|
29
29
|
* // { key: 'home', content: { ... } },
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?:
|
|
32
|
+
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
33
33
|
//#endregion
|
|
34
34
|
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
35
35
|
//# sourceMappingURL=writeDynamicDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KAcY,gBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,yBAAA,GAA4B,OAAH,CACnC,MADmC,CAC5B,MAD4B,EACpB,gBADoB,CAAA,CAAA;AAC5B,KAGG,yBAAA,GAA4B,MAH/B,CAAA,MAAA,EAKP,yBALO,CAAA;;;;AADsC,cAYlC,4BAZkC,EAAA,CAAA,gCAAA,EAaX,yBAbW,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAac,
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KAcY,gBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,yBAAA,GAA4B,OAAH,CACnC,MADmC,CAC5B,MAD4B,EACpB,gBADoB,CAAA,CAAA;AAC5B,KAGG,yBAAA,GAA4B,MAH/B,CAAA,MAAA,EAKP,yBALO,CAAA;;;;AADsC,cAYlC,4BAZkC,EAAA,CAAA,gCAAA,EAaX,yBAbW,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAac,gBAAA,CAE3D,cAf6C,EAAA,GAAA,MAAA;AAI/C;AAQA;AAsDA;;;;;;;;;;;;;;cAAa,6CACS,wCAAsB,gBAAA,CAC1C,gDAEC,QAAQ"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LocalizedDictionaryOutput, LocalizedDictionaryResult } from "./writeDynamicDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types1 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* This function generates the content of the dictionary list file
|
|
7
7
|
*/
|
|
8
|
-
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
8
|
+
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types1.IntlayerConfig) => string;
|
|
9
9
|
/**
|
|
10
10
|
* Write the localized dictionaries to the dictionariesDir
|
|
11
11
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -22,7 +22,7 @@ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: Loc
|
|
|
22
22
|
* // { key: 'home', content: { ... } },
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?:
|
|
25
|
+
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?: _intlayer_types1.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { generateDictionaryEntryPoint, writeFetchDictionary };
|
|
28
28
|
//# sourceMappingURL=writeFetchDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBa,cAAA,4BACqB,EAAA,CAAA,8BAAyB,EAAzB,yBAEE,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAFuB,
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBa,cAAA,4BACqB,EAAA,CAAA,8BAAyB,EAAzB,yBAEE,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAFuB,gBAAA,CAEzD,cAAkC,EAAA,GAAA,MAAA;AA+CpC;;;;;;;;;;;;;;;;cAAa,4CACU,2CAAyB,gBAAA,CAC9C,gDAEC,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types5 from "@intlayer/types";
|
|
3
3
|
import { Dictionary } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
|
|
@@ -24,7 +24,7 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
|
|
|
24
24
|
* // { key: 'home', content: { ... } },
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?:
|
|
27
|
+
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types5.IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
|
|
30
30
|
//# sourceMappingURL=writeMergedDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KASY,sBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,+CACU,0CAAwB,
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KASY,sBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,+CACU,0CAAwB,gBAAA,CAC7C,mBACC,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types4 from "@intlayer/types";
|
|
2
2
|
import { Dictionary } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeRemoteDictionary.d.ts
|
|
@@ -23,7 +23,7 @@ type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;
|
|
|
23
23
|
* // { key: 'home', content: { ... } },
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?:
|
|
26
|
+
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types4.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { RemoteDictionaryOutput, RemoteDictionaryResult, writeRemoteDictionary };
|
|
29
29
|
//# sourceMappingURL=writeRemoteDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,gBAAA,CAC9B,mBACC,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types7 from "@intlayer/types";
|
|
2
2
|
import { Dictionary } from "@intlayer/types";
|
|
3
3
|
import * as _intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
|
|
4
4
|
|
|
@@ -9,45 +9,45 @@ declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
|
|
|
9
9
|
format: string;
|
|
10
10
|
content: _intlayer_core_messageFormat0.JsonValue;
|
|
11
11
|
$schema?: string;
|
|
12
|
-
id?:
|
|
12
|
+
id?: _intlayer_types7.DictionaryId;
|
|
13
13
|
projectIds?: string[];
|
|
14
|
-
localId?:
|
|
15
|
-
localIds?:
|
|
16
|
-
key:
|
|
14
|
+
localId?: _intlayer_types7.LocalDictionaryId;
|
|
15
|
+
localIds?: _intlayer_types7.LocalDictionaryId[];
|
|
16
|
+
key: _intlayer_types7.DictionaryKey;
|
|
17
17
|
title?: string;
|
|
18
18
|
description?: string;
|
|
19
19
|
versions?: string[];
|
|
20
20
|
version?: string;
|
|
21
21
|
filePath?: string;
|
|
22
22
|
tags?: string[];
|
|
23
|
-
locale?:
|
|
24
|
-
fill?:
|
|
23
|
+
locale?: _intlayer_types7.LocalesValues;
|
|
24
|
+
fill?: _intlayer_types7.Fill;
|
|
25
25
|
filled?: true;
|
|
26
26
|
priority?: number;
|
|
27
27
|
live?: boolean;
|
|
28
|
-
location?:
|
|
28
|
+
location?: _intlayer_types7.DictionaryLocation;
|
|
29
29
|
};
|
|
30
30
|
declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Dictionary | {
|
|
31
31
|
format: string;
|
|
32
32
|
content: _intlayer_core_messageFormat0.JsonValue;
|
|
33
33
|
$schema?: string;
|
|
34
|
-
id?:
|
|
34
|
+
id?: _intlayer_types7.DictionaryId;
|
|
35
35
|
projectIds?: string[];
|
|
36
|
-
localId?:
|
|
37
|
-
localIds?:
|
|
38
|
-
key:
|
|
36
|
+
localId?: _intlayer_types7.LocalDictionaryId;
|
|
37
|
+
localIds?: _intlayer_types7.LocalDictionaryId[];
|
|
38
|
+
key: _intlayer_types7.DictionaryKey;
|
|
39
39
|
title?: string;
|
|
40
40
|
description?: string;
|
|
41
41
|
versions?: string[];
|
|
42
42
|
version?: string;
|
|
43
43
|
filePath?: string;
|
|
44
44
|
tags?: string[];
|
|
45
|
-
locale?:
|
|
46
|
-
fill?:
|
|
45
|
+
locale?: _intlayer_types7.LocalesValues;
|
|
46
|
+
fill?: _intlayer_types7.Fill;
|
|
47
47
|
filled?: true;
|
|
48
48
|
priority?: number;
|
|
49
49
|
live?: boolean;
|
|
50
|
-
location?:
|
|
50
|
+
location?: _intlayer_types7.DictionaryLocation;
|
|
51
51
|
})[];
|
|
52
52
|
//#endregion
|
|
53
53
|
export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,10 +51,10 @@ import { splitTextByLines } from "./utils/splitTextByLine.js";
|
|
|
51
51
|
import { verifyIdenticObjectFormat } from "./utils/verifyIdenticObjectFormat.js";
|
|
52
52
|
import { buildAndWatchIntlayer, watch } from "./watcher.js";
|
|
53
53
|
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
|
|
54
|
+
import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.js";
|
|
54
55
|
import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
|
|
55
56
|
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
56
57
|
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
|
|
57
58
|
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
|
|
58
59
|
import "./writeContentDeclaration/index.js";
|
|
59
|
-
import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.js";
|
|
60
60
|
export { ATTRIBUTES_TO_EXTRACT, type BuildFilesListOptions, type DictionaryStatus, type DiffMode, type Extension, type Format, type JSONObject, type JsonChunk, type ListGitFilesOptions, type ListGitLinesOptions, type ListProjectsOptions, type PackageName, type ParallelHandle, assembleJSON, buildAndWatchIntlayer, buildDictionary, buildFilesList, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, extractDictionaryKey, extractIntlayer, fetchDistantDictionaries, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatLocale, formatPath, generateDictionaryListContent, generateKey, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, initIntlayer, isInvalidDictionary, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, shouldExtract, sortAlphabetically, splitTextByLines, transformFiles, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DictionariesStatus } from "./loadDictionaries.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types6 from "@intlayer/types";
|
|
3
3
|
import { Dictionary } from "@intlayer/types";
|
|
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?:
|
|
8
|
+
declare const loadRemoteDictionaries: (configuration?: _intlayer_types6.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"],"sourcesContent":[],"mappings":";;;;;;cAUa,2CACI,gBAAgB,kBAC9B;cAOU,yCAsIZ,
|
|
1
|
+
{"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":[],"mappings":";;;;;;cAUa,2CACI,gBAAgB,kBAC9B;cAOU,yCAsIZ,gBAAA,CArIC,0CAC0B,sCAVK;;EADpB,iBAAA,CAAA,EAAA,GAAA,GAAA,IAOR;EANY,OAAA,CAAA,EAAA,CAAA,KAAA,EAcK,KAdL,EAAA,GAAA,IAAA;CAAgB,EAAA,GAgB9B,OAhB8B,CAgBtB,UAhBsB,EAAA,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/utils/getFormatFromExtension.d.ts
|
|
2
|
-
type Format = 'ts' | 'cjs' | 'esm' | 'json';
|
|
3
|
-
type Extension = '.ts' | '.tsx' | '.js' | '.jsx' | '.cjs' | '.cjsx' | '.mjs' | '.mjsx' | '.json' | '.json5';
|
|
2
|
+
type Format = 'ts' | 'cjs' | 'esm' | 'json' | 'jsonc' | 'json5';
|
|
3
|
+
type Extension = '.ts' | '.tsx' | '.js' | '.jsx' | '.cjs' | '.cjsx' | '.mjs' | '.mjsx' | '.json' | '.jsonc' | '.json5';
|
|
4
4
|
declare const getFormatFromExtension: (extension: Extension) => Format;
|
|
5
5
|
declare const getExtensionFromFormat: (format: Format) => Extension;
|
|
6
6
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AACN,
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA,GAAA,QAAA;AACN,cAaC,sBAbQ,EAAA,CAAA,SAAA,EAa6B,SAb7B,EAAA,GAayC,MAbzC;AAaR,cAmBA,sBAnBqC,EAAA,CAAA,MAAA,EAmBH,MAF9C,EAAA,GAEuD,SAFvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runOnce.d.ts","names":[],"sources":["../../../src/utils/runOnce.ts"],"sourcesContent":[],"mappings":";KAIK,cAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"runOnce.d.ts","names":[],"sources":["../../../src/utils/runOnce.ts"],"sourcesContent":[],"mappings":";KAIK,cAAA;EAAA;AAoFL;;EAGY,UAAA,CAAA,EAAA,GAAA,GAAA,IAAA,GAnFgB,OAmFhB,CAAA,IAAA,CAAA;EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAHb,2DAEY,yBACb,mBAAc"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/writeContentDeclaration/detectFormatCommand.d.ts
|
|
4
|
-
declare const detectFormatCommand: (configuration: IntlayerConfig) => string;
|
|
4
|
+
declare const detectFormatCommand: (configuration: IntlayerConfig, projectRequireProp?: NodeJS.Require) => string;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { detectFormatCommand };
|
|
7
7
|
//# sourceMappingURL=detectFormatCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectFormatCommand.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"detectFormatCommand.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":[],"mappings":";;;cAKa,qCACI,qCACM,MAAA,CAAO"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { detectExportedComponentName } from "./detectExportedComponentName.js";
|
|
2
|
+
import { detectFormatCommand } from "./detectFormatCommand.js";
|
|
2
3
|
import { DictionaryStatus } from "./dictionaryStatus.js";
|
|
3
4
|
import { transformJSFile } from "./transformJSFile.js";
|
|
4
5
|
import { writeContentDeclaration } from "./writeContentDeclaration.js";
|
|
5
6
|
import { writeJSFile } from "./writeJSFile.js";
|
|
6
|
-
export { DictionaryStatus, detectExportedComponentName, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
7
|
+
export { DictionaryStatus, detectExportedComponentName, detectFormatCommand, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Dictionary } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/writeContentDeclaration/transformJSONFile.d.ts
|
|
4
|
+
declare const transformJSONFile: (fileContent: string, dictionary: Dictionary) => string;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { transformJSONFile };
|
|
7
|
+
//# sourceMappingURL=transformJSONFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformJSONFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":[],"mappings":";;;cAwGa,qDAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":[],"mappings":";;;;KAqHK,8BAAA;;EAAA,UAAA,CAAA,EAEU,aAFV,EAAA;EAUQ,cAAA,CAAA,EAPM,MAON;CACC;AACG,cAFJ,uBAEI,EAAA,CAAA,UAAA,EADH,UACG,EAAA,aAAA,EAAA,cAAA,EAAA,OAAA,CAAA,EACL,8BADK,EAAA,GAEd,OAFc,CAAA;EACL,MAAA,EACS,gBADT;EACS,IAAA,EAAA,MAAA;CAAlB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.14",
|
|
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": [
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@intlayer/api": "7.5.
|
|
79
|
-
"@intlayer/config": "7.5.
|
|
80
|
-
"@intlayer/core": "7.5.
|
|
81
|
-
"@intlayer/dictionaries-entry": "7.5.
|
|
82
|
-
"@intlayer/remote-dictionaries-entry": "7.5.
|
|
83
|
-
"@intlayer/types": "7.5.
|
|
84
|
-
"@intlayer/unmerged-dictionaries-entry": "7.5.
|
|
78
|
+
"@intlayer/api": "7.5.14",
|
|
79
|
+
"@intlayer/config": "7.5.14",
|
|
80
|
+
"@intlayer/core": "7.5.14",
|
|
81
|
+
"@intlayer/dictionaries-entry": "7.5.14",
|
|
82
|
+
"@intlayer/remote-dictionaries-entry": "7.5.14",
|
|
83
|
+
"@intlayer/types": "7.5.14",
|
|
84
|
+
"@intlayer/unmerged-dictionaries-entry": "7.5.14",
|
|
85
85
|
"chokidar": "3.6.0",
|
|
86
86
|
"crypto-js": "4.2.0",
|
|
87
87
|
"defu": "6.1.4",
|
|
@@ -91,18 +91,18 @@
|
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@types/crypto-js": "4.2.2",
|
|
94
|
-
"@types/node": "25.0.
|
|
94
|
+
"@types/node": "25.0.6",
|
|
95
95
|
"@utils/ts-config": "1.0.4",
|
|
96
96
|
"@utils/ts-config-types": "1.0.4",
|
|
97
97
|
"@utils/tsdown-config": "1.0.4",
|
|
98
98
|
"rimraf": "6.1.2",
|
|
99
|
-
"tsdown": "0.
|
|
99
|
+
"tsdown": "0.19.0",
|
|
100
100
|
"typescript": "5.9.3",
|
|
101
|
-
"vitest": "4.0.
|
|
101
|
+
"vitest": "4.0.17"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@intlayer/svelte-transformer": "7.5.
|
|
105
|
-
"@intlayer/vue-transformer": "7.5.
|
|
104
|
+
"@intlayer/svelte-transformer": "7.5.14",
|
|
105
|
+
"@intlayer/vue-transformer": "7.5.14"
|
|
106
106
|
},
|
|
107
107
|
"peerDependenciesMeta": {
|
|
108
108
|
"@intlayer/svelte-transformer": {
|