intlayer-editor 8.12.2 → 8.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{CodeBlockClient-b-yeqFuz.js → CodeBlockClient-BQMC5gqu.js} +3 -3
- package/client/dist/assets/{CodeBlockShiki-CKm7rixD.js → CodeBlockShiki-DB7ndrOR.js} +2 -2
- package/client/dist/assets/{MarkDownRender-EQEw6Grf.js → MarkDownRender-BQwPctN-.js} +3 -3
- package/client/dist/assets/{bundle-web-DofprJDj.js → bundle-web-C4HpQhJS.js} +1 -1
- package/client/dist/assets/{dist-BFhKwA67.js → dist-GH_AdANR.js} +1 -1
- package/client/dist/assets/index-DIJj_-IN.css +2 -0
- package/client/dist/assets/index-DJVEpj0g.js +189 -0
- package/client/dist/assets/purify.es-6-uFcs4-.js +3 -0
- package/client/dist/index.html +2 -2
- package/package.json +15 -15
- package/server/dist/@intlayer/chokidar/dist/types/build.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/cleanOutputDir.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createType/createModuleAugmentation.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createType/createType.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/formatDictionary.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/intlayer/dist/types/index.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/prepareIntlayer.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeConfiguration/index.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +6 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/transformJSFile.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeJSFile.d.ts +2 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/ICU.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/i18next.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/index.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/po.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/vue-i18n.d.ts +1 -0
- package/server/dist/controllers/configuration.controller.cjs +1 -0
- package/server/dist/controllers/configuration.controller.cjs.map +1 -1
- package/server/dist/controllers/configuration.controller.mjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.cjs +1 -0
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
- package/server/dist/index.cjs.map +1 -1
- package/server/dist/index.mjs.map +1 -1
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs +32 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs +31 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +82 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +81 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs +26 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs +25 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs +24 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs +23 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs +94 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +92 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs +416 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs +412 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs +127 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs +125 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs +164 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +163 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs +92 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs +91 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs +65 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +64 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs +43 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs +45 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +43 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs +32 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +32 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs +56 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs +54 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs +27 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs +26 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs +58 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs +56 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs +160 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs +158 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs +71 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs +70 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs +38 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs +37 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs +22 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs +21 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs +87 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs +86 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs +14 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs +13 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs +58 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs +57 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs.map +1 -0
- package/server/dist/routes/config.routes.cjs +1 -0
- package/server/dist/routes/config.routes.cjs.map +1 -1
- package/server/dist/routes/config.routes.mjs.map +1 -1
- package/server/dist/routes/dictionary.routes.cjs +1 -0
- package/server/dist/routes/dictionary.routes.cjs.map +1 -1
- package/server/dist/routes/dictionary.routes.mjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.cjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.mjs.map +1 -1
- package/server/dist/utils/responseData.cjs.map +1 -1
- package/server/dist/utils/responseData.mjs.map +1 -1
- package/client/dist/assets/index-CTSrsWZb.css +0 -2
- package/client/dist/assets/index-bVSusa0N.js +0 -185
- package/client/dist/assets/purify.es-Dt2VzQ8a.js +0 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
3
|
+
|
|
4
|
+
//#region ../../@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs
|
|
5
|
+
const getContentDeclarationFileTemplate = async (key, format, fileParams = {}, noMetadata) => {
|
|
6
|
+
const camelCaseKey = (0, _intlayer_config_utils.kebabCaseToCamelCase)(key);
|
|
7
|
+
const name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);
|
|
8
|
+
const fileParamsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([paramKey, value]) => {
|
|
9
|
+
return `\n ${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey) ? paramKey : JSON.stringify(paramKey)}: ${typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value},`;
|
|
10
|
+
}).join("");
|
|
11
|
+
let content;
|
|
12
|
+
if (noMetadata) content = "{}";
|
|
13
|
+
else if (format === "json" || format === "jsonc" || format === "json5") content = [
|
|
14
|
+
"{",
|
|
15
|
+
" \"$schema\": \"https://intlayer.org/schema.json\",",
|
|
16
|
+
` "key": "${key}",${fileParamsString}`,
|
|
17
|
+
" \"content\": {",
|
|
18
|
+
" }",
|
|
19
|
+
"}"
|
|
20
|
+
].join("\n");
|
|
21
|
+
else content = [
|
|
22
|
+
"{",
|
|
23
|
+
` key: '${key}',${fileParamsString}`,
|
|
24
|
+
" content: {",
|
|
25
|
+
" },",
|
|
26
|
+
"}"
|
|
27
|
+
].join("\n");
|
|
28
|
+
const jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? "['content']" : ""}} **/`;
|
|
29
|
+
const satisfiesType = noMetadata ? "Dictionary['content']" : "Dictionary";
|
|
30
|
+
switch (format) {
|
|
31
|
+
case "yaml": return `${[
|
|
32
|
+
`key: ${key}`,
|
|
33
|
+
...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
|
|
34
|
+
...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
|
|
35
|
+
...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
|
|
36
|
+
...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((tag) => ` - ${JSON.stringify(tag)}`)] : [],
|
|
37
|
+
"content: {}"
|
|
38
|
+
].join("\n")}\n`;
|
|
39
|
+
case "md": return [
|
|
40
|
+
"---",
|
|
41
|
+
...[
|
|
42
|
+
`key: ${key}`,
|
|
43
|
+
...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
|
|
44
|
+
...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
|
|
45
|
+
...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
|
|
46
|
+
...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((t) => ` - ${JSON.stringify(t)}`)] : []
|
|
47
|
+
],
|
|
48
|
+
"---",
|
|
49
|
+
"",
|
|
50
|
+
""
|
|
51
|
+
].join("\n");
|
|
52
|
+
case "ts": return [
|
|
53
|
+
"import { type Dictionary } from 'intlayer';",
|
|
54
|
+
"",
|
|
55
|
+
`const ${name}Content = ${content} satisfies ${satisfiesType};`,
|
|
56
|
+
"",
|
|
57
|
+
`export default ${name}Content;`,
|
|
58
|
+
""
|
|
59
|
+
].join("\n");
|
|
60
|
+
case "cjs": return [
|
|
61
|
+
jsdoc,
|
|
62
|
+
`const ${name}Content = ${content};`,
|
|
63
|
+
"",
|
|
64
|
+
`module.exports = ${name}Content;`,
|
|
65
|
+
""
|
|
66
|
+
].join("\n");
|
|
67
|
+
case "json":
|
|
68
|
+
case "jsonc":
|
|
69
|
+
case "json5": return [content, ""].join("\n");
|
|
70
|
+
default: return [
|
|
71
|
+
jsdoc,
|
|
72
|
+
`const ${name}Content = ${content};`,
|
|
73
|
+
"",
|
|
74
|
+
`export default ${name}Content;`,
|
|
75
|
+
""
|
|
76
|
+
].join("\n");
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
exports.getContentDeclarationFileTemplate = getContentDeclarationFileTemplate;
|
|
82
|
+
//# sourceMappingURL=getContentDeclarationFileTemplate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getContentDeclarationFileTemplate.cjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs"],"sourcesContent":["import { kebabCaseToCamelCase } from \"@intlayer/config/utils\";\n\n//#region src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts\nconst getContentDeclarationFileTemplate = async (key, format, fileParams = {}, noMetadata) => {\n\tconst camelCaseKey = kebabCaseToCamelCase(key);\n\tconst name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\tconst fileParamsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([paramKey, value]) => {\n\t\treturn `\\n ${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey) ? paramKey : JSON.stringify(paramKey)}: ${typeof value === \"object\" || typeof value === \"string\" ? JSON.stringify(value) : value},`;\n\t}).join(\"\");\n\tlet content;\n\tif (noMetadata) content = \"{}\";\n\telse if (format === \"json\" || format === \"jsonc\" || format === \"json5\") content = [\n\t\t\"{\",\n\t\t\" \\\"$schema\\\": \\\"https://intlayer.org/schema.json\\\",\",\n\t\t` \"key\": \"${key}\",${fileParamsString}`,\n\t\t\" \\\"content\\\": {\",\n\t\t\" }\",\n\t\t\"}\"\n\t].join(\"\\n\");\n\telse content = [\n\t\t\"{\",\n\t\t` key: '${key}',${fileParamsString}`,\n\t\t\" content: {\",\n\t\t\" },\",\n\t\t\"}\"\n\t].join(\"\\n\");\n\tconst jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? \"['content']\" : \"\"}} **/`;\n\tconst satisfiesType = noMetadata ? \"Dictionary['content']\" : \"Dictionary\";\n\tswitch (format) {\n\t\tcase \"yaml\": return `${[\n\t\t\t`key: ${key}`,\n\t\t\t...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],\n\t\t\t...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],\n\t\t\t...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],\n\t\t\t...fileParams.tags?.length ? [\"tags:\", ...fileParams.tags.map((tag) => ` - ${JSON.stringify(tag)}`)] : [],\n\t\t\t\"content: {}\"\n\t\t].join(\"\\n\")}\\n`;\n\t\tcase \"md\": return [\n\t\t\t\"---\",\n\t\t\t...[\n\t\t\t\t`key: ${key}`,\n\t\t\t\t...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],\n\t\t\t\t...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],\n\t\t\t\t...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],\n\t\t\t\t...fileParams.tags?.length ? [\"tags:\", ...fileParams.tags.map((t) => ` - ${JSON.stringify(t)}`)] : []\n\t\t\t],\n\t\t\t\"---\",\n\t\t\t\"\",\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"ts\": return [\n\t\t\t\"import { type Dictionary } from 'intlayer';\",\n\t\t\t\"\",\n\t\t\t`const ${name}Content = ${content} satisfies ${satisfiesType};`,\n\t\t\t\"\",\n\t\t\t`export default ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"cjs\": return [\n\t\t\tjsdoc,\n\t\t\t`const ${name}Content = ${content};`,\n\t\t\t\"\",\n\t\t\t`module.exports = ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"json\":\n\t\tcase \"jsonc\":\n\t\tcase \"json5\": return [content, \"\"].join(\"\\n\");\n\t\tdefault: return [\n\t\t\tjsdoc,\n\t\t\t`const ${name}Content = ${content};`,\n\t\t\t\"\",\n\t\t\t`export default ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t}\n};\n\n//#endregion\nexport { getContentDeclarationFileTemplate };\n//# sourceMappingURL=getContentDeclarationFileTemplate.mjs.map"],"mappings":";;;;AAGA,MAAM,oCAAoC,OAAO,KAAK,QAAQ,aAAa,EAAE,EAAE,eAAe;CAC7F,MAAM,gEAAoC,IAAI;CAC9C,MAAM,OAAO,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CACzE,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,WAAW;AACtH,SAAO,OAAO,6BAA6B,KAAK,SAAS,GAAG,WAAW,KAAK,UAAU,SAAS,CAAC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,KAAK,UAAU,MAAM,GAAG,MAAM;GAC1L,CAAC,KAAK,GAAG;CACX,IAAI;AACJ,KAAI,WAAY,WAAU;UACjB,WAAW,UAAU,WAAW,WAAW,WAAW,QAAS,WAAU;EACjF;EACA;EACA,aAAa,IAAI,IAAI;EACrB;EACA;EACA;EACA,CAAC,KAAK,KAAK;KACP,WAAU;EACd;EACA,WAAW,IAAI,IAAI;EACnB;EACA;EACA;EACA,CAAC,KAAK,KAAK;CACZ,MAAM,QAAQ,2CAA2C,aAAa,gBAAgB,GAAG;CACzF,MAAM,gBAAgB,aAAa,0BAA0B;AAC7D,SAAQ,QAAR;EACC,KAAK,OAAQ,QAAO,GAAG;GACtB,QAAQ;GACR,GAAG,WAAW,SAAS,CAAC,WAAW,WAAW,SAAS,GAAG,EAAE;GAC5D,GAAG,WAAW,QAAQ,CAAC,UAAU,KAAK,UAAU,WAAW,MAAM,GAAG,GAAG,EAAE;GACzE,GAAG,WAAW,cAAc,CAAC,gBAAgB,KAAK,UAAU,WAAW,YAAY,GAAG,GAAG,EAAE;GAC3F,GAAG,WAAW,MAAM,SAAS,CAAC,SAAS,GAAG,WAAW,KAAK,KAAK,QAAQ,OAAO,KAAK,UAAU,IAAI,GAAG,CAAC,GAAG,EAAE;GAC1G;GACA,CAAC,KAAK,KAAK,CAAC;EACb,KAAK,KAAM,QAAO;GACjB;GACA,GAAG;IACF,QAAQ;IACR,GAAG,WAAW,SAAS,CAAC,WAAW,WAAW,SAAS,GAAG,EAAE;IAC5D,GAAG,WAAW,QAAQ,CAAC,UAAU,KAAK,UAAU,WAAW,MAAM,GAAG,GAAG,EAAE;IACzE,GAAG,WAAW,cAAc,CAAC,gBAAgB,KAAK,UAAU,WAAW,YAAY,GAAG,GAAG,EAAE;IAC3F,GAAG,WAAW,MAAM,SAAS,CAAC,SAAS,GAAG,WAAW,KAAK,KAAK,MAAM,OAAO,KAAK,UAAU,EAAE,GAAG,CAAC,GAAG,EAAE;IACtG;GACD;GACA;GACA;GACA,CAAC,KAAK,KAAK;EACZ,KAAK,KAAM,QAAO;GACjB;GACA;GACA,SAAS,KAAK,YAAY,QAAQ,aAAa,cAAc;GAC7D;GACA,kBAAkB,KAAK;GACvB;GACA,CAAC,KAAK,KAAK;EACZ,KAAK,MAAO,QAAO;GAClB;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,oBAAoB,KAAK;GACzB;GACA,CAAC,KAAK,KAAK;EACZ,KAAK;EACL,KAAK;EACL,KAAK,QAAS,QAAO,CAAC,SAAS,GAAG,CAAC,KAAK,KAAK;EAC7C,QAAS,QAAO;GACf;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,kBAAkB,KAAK;GACvB;GACA,CAAC,KAAK,KAAK"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { kebabCaseToCamelCase } from "@intlayer/config/utils";
|
|
2
|
+
|
|
3
|
+
//#region ../../@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs
|
|
4
|
+
const getContentDeclarationFileTemplate = async (key, format, fileParams = {}, noMetadata) => {
|
|
5
|
+
const camelCaseKey = kebabCaseToCamelCase(key);
|
|
6
|
+
const name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);
|
|
7
|
+
const fileParamsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([paramKey, value]) => {
|
|
8
|
+
return `\n ${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey) ? paramKey : JSON.stringify(paramKey)}: ${typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value},`;
|
|
9
|
+
}).join("");
|
|
10
|
+
let content;
|
|
11
|
+
if (noMetadata) content = "{}";
|
|
12
|
+
else if (format === "json" || format === "jsonc" || format === "json5") content = [
|
|
13
|
+
"{",
|
|
14
|
+
" \"$schema\": \"https://intlayer.org/schema.json\",",
|
|
15
|
+
` "key": "${key}",${fileParamsString}`,
|
|
16
|
+
" \"content\": {",
|
|
17
|
+
" }",
|
|
18
|
+
"}"
|
|
19
|
+
].join("\n");
|
|
20
|
+
else content = [
|
|
21
|
+
"{",
|
|
22
|
+
` key: '${key}',${fileParamsString}`,
|
|
23
|
+
" content: {",
|
|
24
|
+
" },",
|
|
25
|
+
"}"
|
|
26
|
+
].join("\n");
|
|
27
|
+
const jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? "['content']" : ""}} **/`;
|
|
28
|
+
const satisfiesType = noMetadata ? "Dictionary['content']" : "Dictionary";
|
|
29
|
+
switch (format) {
|
|
30
|
+
case "yaml": return `${[
|
|
31
|
+
`key: ${key}`,
|
|
32
|
+
...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
|
|
33
|
+
...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
|
|
34
|
+
...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
|
|
35
|
+
...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((tag) => ` - ${JSON.stringify(tag)}`)] : [],
|
|
36
|
+
"content: {}"
|
|
37
|
+
].join("\n")}\n`;
|
|
38
|
+
case "md": return [
|
|
39
|
+
"---",
|
|
40
|
+
...[
|
|
41
|
+
`key: ${key}`,
|
|
42
|
+
...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
|
|
43
|
+
...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
|
|
44
|
+
...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
|
|
45
|
+
...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((t) => ` - ${JSON.stringify(t)}`)] : []
|
|
46
|
+
],
|
|
47
|
+
"---",
|
|
48
|
+
"",
|
|
49
|
+
""
|
|
50
|
+
].join("\n");
|
|
51
|
+
case "ts": return [
|
|
52
|
+
"import { type Dictionary } from 'intlayer';",
|
|
53
|
+
"",
|
|
54
|
+
`const ${name}Content = ${content} satisfies ${satisfiesType};`,
|
|
55
|
+
"",
|
|
56
|
+
`export default ${name}Content;`,
|
|
57
|
+
""
|
|
58
|
+
].join("\n");
|
|
59
|
+
case "cjs": return [
|
|
60
|
+
jsdoc,
|
|
61
|
+
`const ${name}Content = ${content};`,
|
|
62
|
+
"",
|
|
63
|
+
`module.exports = ${name}Content;`,
|
|
64
|
+
""
|
|
65
|
+
].join("\n");
|
|
66
|
+
case "json":
|
|
67
|
+
case "jsonc":
|
|
68
|
+
case "json5": return [content, ""].join("\n");
|
|
69
|
+
default: return [
|
|
70
|
+
jsdoc,
|
|
71
|
+
`const ${name}Content = ${content};`,
|
|
72
|
+
"",
|
|
73
|
+
`export default ${name}Content;`,
|
|
74
|
+
""
|
|
75
|
+
].join("\n");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { getContentDeclarationFileTemplate };
|
|
81
|
+
//# sourceMappingURL=getContentDeclarationFileTemplate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getContentDeclarationFileTemplate.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs"],"sourcesContent":["import { kebabCaseToCamelCase } from \"@intlayer/config/utils\";\n\n//#region src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts\nconst getContentDeclarationFileTemplate = async (key, format, fileParams = {}, noMetadata) => {\n\tconst camelCaseKey = kebabCaseToCamelCase(key);\n\tconst name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\tconst fileParamsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([paramKey, value]) => {\n\t\treturn `\\n ${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey) ? paramKey : JSON.stringify(paramKey)}: ${typeof value === \"object\" || typeof value === \"string\" ? JSON.stringify(value) : value},`;\n\t}).join(\"\");\n\tlet content;\n\tif (noMetadata) content = \"{}\";\n\telse if (format === \"json\" || format === \"jsonc\" || format === \"json5\") content = [\n\t\t\"{\",\n\t\t\" \\\"$schema\\\": \\\"https://intlayer.org/schema.json\\\",\",\n\t\t` \"key\": \"${key}\",${fileParamsString}`,\n\t\t\" \\\"content\\\": {\",\n\t\t\" }\",\n\t\t\"}\"\n\t].join(\"\\n\");\n\telse content = [\n\t\t\"{\",\n\t\t` key: '${key}',${fileParamsString}`,\n\t\t\" content: {\",\n\t\t\" },\",\n\t\t\"}\"\n\t].join(\"\\n\");\n\tconst jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? \"['content']\" : \"\"}} **/`;\n\tconst satisfiesType = noMetadata ? \"Dictionary['content']\" : \"Dictionary\";\n\tswitch (format) {\n\t\tcase \"yaml\": return `${[\n\t\t\t`key: ${key}`,\n\t\t\t...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],\n\t\t\t...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],\n\t\t\t...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],\n\t\t\t...fileParams.tags?.length ? [\"tags:\", ...fileParams.tags.map((tag) => ` - ${JSON.stringify(tag)}`)] : [],\n\t\t\t\"content: {}\"\n\t\t].join(\"\\n\")}\\n`;\n\t\tcase \"md\": return [\n\t\t\t\"---\",\n\t\t\t...[\n\t\t\t\t`key: ${key}`,\n\t\t\t\t...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],\n\t\t\t\t...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],\n\t\t\t\t...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],\n\t\t\t\t...fileParams.tags?.length ? [\"tags:\", ...fileParams.tags.map((t) => ` - ${JSON.stringify(t)}`)] : []\n\t\t\t],\n\t\t\t\"---\",\n\t\t\t\"\",\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"ts\": return [\n\t\t\t\"import { type Dictionary } from 'intlayer';\",\n\t\t\t\"\",\n\t\t\t`const ${name}Content = ${content} satisfies ${satisfiesType};`,\n\t\t\t\"\",\n\t\t\t`export default ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"cjs\": return [\n\t\t\tjsdoc,\n\t\t\t`const ${name}Content = ${content};`,\n\t\t\t\"\",\n\t\t\t`module.exports = ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t\tcase \"json\":\n\t\tcase \"jsonc\":\n\t\tcase \"json5\": return [content, \"\"].join(\"\\n\");\n\t\tdefault: return [\n\t\t\tjsdoc,\n\t\t\t`const ${name}Content = ${content};`,\n\t\t\t\"\",\n\t\t\t`export default ${name}Content;`,\n\t\t\t\"\"\n\t\t].join(\"\\n\");\n\t}\n};\n\n//#endregion\nexport { getContentDeclarationFileTemplate };\n//# sourceMappingURL=getContentDeclarationFileTemplate.mjs.map"],"mappings":";;;AAGA,MAAM,oCAAoC,OAAO,KAAK,QAAQ,aAAa,EAAE,EAAE,eAAe;CAC7F,MAAM,eAAe,qBAAqB,IAAI;CAC9C,MAAM,OAAO,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CACzE,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,WAAW;AACtH,SAAO,OAAO,6BAA6B,KAAK,SAAS,GAAG,WAAW,KAAK,UAAU,SAAS,CAAC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,KAAK,UAAU,MAAM,GAAG,MAAM;GAC1L,CAAC,KAAK,GAAG;CACX,IAAI;AACJ,KAAI,WAAY,WAAU;UACjB,WAAW,UAAU,WAAW,WAAW,WAAW,QAAS,WAAU;EACjF;EACA;EACA,aAAa,IAAI,IAAI;EACrB;EACA;EACA;EACA,CAAC,KAAK,KAAK;KACP,WAAU;EACd;EACA,WAAW,IAAI,IAAI;EACnB;EACA;EACA;EACA,CAAC,KAAK,KAAK;CACZ,MAAM,QAAQ,2CAA2C,aAAa,gBAAgB,GAAG;CACzF,MAAM,gBAAgB,aAAa,0BAA0B;AAC7D,SAAQ,QAAR;EACC,KAAK,OAAQ,QAAO,GAAG;GACtB,QAAQ;GACR,GAAG,WAAW,SAAS,CAAC,WAAW,WAAW,SAAS,GAAG,EAAE;GAC5D,GAAG,WAAW,QAAQ,CAAC,UAAU,KAAK,UAAU,WAAW,MAAM,GAAG,GAAG,EAAE;GACzE,GAAG,WAAW,cAAc,CAAC,gBAAgB,KAAK,UAAU,WAAW,YAAY,GAAG,GAAG,EAAE;GAC3F,GAAG,WAAW,MAAM,SAAS,CAAC,SAAS,GAAG,WAAW,KAAK,KAAK,QAAQ,OAAO,KAAK,UAAU,IAAI,GAAG,CAAC,GAAG,EAAE;GAC1G;GACA,CAAC,KAAK,KAAK,CAAC;EACb,KAAK,KAAM,QAAO;GACjB;GACA,GAAG;IACF,QAAQ;IACR,GAAG,WAAW,SAAS,CAAC,WAAW,WAAW,SAAS,GAAG,EAAE;IAC5D,GAAG,WAAW,QAAQ,CAAC,UAAU,KAAK,UAAU,WAAW,MAAM,GAAG,GAAG,EAAE;IACzE,GAAG,WAAW,cAAc,CAAC,gBAAgB,KAAK,UAAU,WAAW,YAAY,GAAG,GAAG,EAAE;IAC3F,GAAG,WAAW,MAAM,SAAS,CAAC,SAAS,GAAG,WAAW,KAAK,KAAK,MAAM,OAAO,KAAK,UAAU,EAAE,GAAG,CAAC,GAAG,EAAE;IACtG;GACD;GACA;GACA;GACA,CAAC,KAAK,KAAK;EACZ,KAAK,KAAM,QAAO;GACjB;GACA;GACA,SAAS,KAAK,YAAY,QAAQ,aAAa,cAAc;GAC7D;GACA,kBAAkB,KAAK;GACvB;GACA,CAAC,KAAK,KAAK;EACZ,KAAK,MAAO,QAAO;GAClB;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,oBAAoB,KAAK;GACzB;GACA,CAAC,KAAK,KAAK;EACZ,KAAK;EACL,KAAK;EACL,KAAK,QAAS,QAAO,CAAC,SAAS,GAAG,CAAC,KAAK,KAAK;EAC7C,QAAS,QAAO;GACf;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,kBAAkB,KAAK;GACvB;GACA,CAAC,KAAK,KAAK"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs
|
|
3
|
+
const getFormatFromExtension = (extension) => {
|
|
4
|
+
switch (extension) {
|
|
5
|
+
case ".ts":
|
|
6
|
+
case ".tsx": return "ts";
|
|
7
|
+
case ".cjs":
|
|
8
|
+
case ".cjsx": return "cjs";
|
|
9
|
+
case ".js":
|
|
10
|
+
case ".jsx":
|
|
11
|
+
case ".mjs":
|
|
12
|
+
case ".mjsx": return "esm";
|
|
13
|
+
case ".json":
|
|
14
|
+
case ".jsonc":
|
|
15
|
+
case ".json5": return "json";
|
|
16
|
+
case ".md":
|
|
17
|
+
case ".mdx": return "md";
|
|
18
|
+
case ".yaml":
|
|
19
|
+
case ".yml": return "yaml";
|
|
20
|
+
}
|
|
21
|
+
return "ts";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.getFormatFromExtension = getFormatFromExtension;
|
|
26
|
+
//# sourceMappingURL=getFormatFromExtension.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.cjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs"],"sourcesContent":["//#region src/utils/getFormatFromExtension.ts\nconst getFormatFromExtension = (extension) => {\n\tswitch (extension) {\n\t\tcase \".ts\":\n\t\tcase \".tsx\": return \"ts\";\n\t\tcase \".cjs\":\n\t\tcase \".cjsx\": return \"cjs\";\n\t\tcase \".js\":\n\t\tcase \".jsx\":\n\t\tcase \".mjs\":\n\t\tcase \".mjsx\": return \"esm\";\n\t\tcase \".json\":\n\t\tcase \".jsonc\":\n\t\tcase \".json5\": return \"json\";\n\t\tcase \".md\":\n\t\tcase \".mdx\": return \"md\";\n\t\tcase \".yaml\":\n\t\tcase \".yml\": return \"yaml\";\n\t}\n\treturn \"ts\";\n};\nconst getExtensionFromFormat = (format) => {\n\tswitch (format) {\n\t\tcase \"ts\": return \".ts\";\n\t\tcase \"cjs\": return \".cjs\";\n\t\tcase \"json\": return \".json\";\n\t\tcase \"jsonc\": return \".jsonc\";\n\t\tcase \"json5\": return \".json5\";\n\t\tcase \"esm\": return \".mjs\";\n\t\tcase \"md\": return \".md\";\n\t\tcase \"yaml\": return \".yaml\";\n\t}\n\treturn \".ts\";\n};\n\n//#endregion\nexport { getExtensionFromFormat, getFormatFromExtension };\n//# sourceMappingURL=getFormatFromExtension.mjs.map"],"mappings":";;AACA,MAAM,0BAA0B,cAAc;AAC7C,SAAQ,WAAR;EACC,KAAK;EACL,KAAK,OAAQ,QAAO;EACpB,KAAK;EACL,KAAK,QAAS,QAAO;EACrB,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QAAS,QAAO;EACrB,KAAK;EACL,KAAK;EACL,KAAK,SAAU,QAAO;EACtB,KAAK;EACL,KAAK,OAAQ,QAAO;EACpB,KAAK;EACL,KAAK,OAAQ,QAAO;;AAErB,QAAO"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region ../../@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs
|
|
2
|
+
const getFormatFromExtension = (extension) => {
|
|
3
|
+
switch (extension) {
|
|
4
|
+
case ".ts":
|
|
5
|
+
case ".tsx": return "ts";
|
|
6
|
+
case ".cjs":
|
|
7
|
+
case ".cjsx": return "cjs";
|
|
8
|
+
case ".js":
|
|
9
|
+
case ".jsx":
|
|
10
|
+
case ".mjs":
|
|
11
|
+
case ".mjsx": return "esm";
|
|
12
|
+
case ".json":
|
|
13
|
+
case ".jsonc":
|
|
14
|
+
case ".json5": return "json";
|
|
15
|
+
case ".md":
|
|
16
|
+
case ".mdx": return "md";
|
|
17
|
+
case ".yaml":
|
|
18
|
+
case ".yml": return "yaml";
|
|
19
|
+
}
|
|
20
|
+
return "ts";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getFormatFromExtension };
|
|
25
|
+
//# sourceMappingURL=getFormatFromExtension.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs"],"sourcesContent":["//#region src/utils/getFormatFromExtension.ts\nconst getFormatFromExtension = (extension) => {\n\tswitch (extension) {\n\t\tcase \".ts\":\n\t\tcase \".tsx\": return \"ts\";\n\t\tcase \".cjs\":\n\t\tcase \".cjsx\": return \"cjs\";\n\t\tcase \".js\":\n\t\tcase \".jsx\":\n\t\tcase \".mjs\":\n\t\tcase \".mjsx\": return \"esm\";\n\t\tcase \".json\":\n\t\tcase \".jsonc\":\n\t\tcase \".json5\": return \"json\";\n\t\tcase \".md\":\n\t\tcase \".mdx\": return \"md\";\n\t\tcase \".yaml\":\n\t\tcase \".yml\": return \"yaml\";\n\t}\n\treturn \"ts\";\n};\nconst getExtensionFromFormat = (format) => {\n\tswitch (format) {\n\t\tcase \"ts\": return \".ts\";\n\t\tcase \"cjs\": return \".cjs\";\n\t\tcase \"json\": return \".json\";\n\t\tcase \"jsonc\": return \".jsonc\";\n\t\tcase \"json5\": return \".json5\";\n\t\tcase \"esm\": return \".mjs\";\n\t\tcase \"md\": return \".md\";\n\t\tcase \"yaml\": return \".yaml\";\n\t}\n\treturn \".ts\";\n};\n\n//#endregion\nexport { getExtensionFromFormat, getFormatFromExtension };\n//# sourceMappingURL=getFormatFromExtension.mjs.map"],"mappings":";AACA,MAAM,0BAA0B,cAAc;AAC7C,SAAQ,WAAR;EACC,KAAK;EACL,KAAK,OAAQ,QAAO;EACpB,KAAK;EACL,KAAK,QAAS,QAAO;EACrB,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QAAS,QAAO;EACrB,KAAK;EACL,KAAK;EACL,KAAK,SAAU,QAAO;EACtB,KAAK;EACL,KAAK,OAAQ,QAAO;EACpB,KAAK;EACL,KAAK,OAAQ,QAAO;;AAErB,QAAO"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
|
|
5
|
+
//#region ../../@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Reads all JSON dictionary files from a directory, keyed by filename.
|
|
8
|
+
* Uses readFileSync instead of require() to avoid require.cache memory leak.
|
|
9
|
+
*/
|
|
10
|
+
const readDictionariesFromDisk = (directory) => {
|
|
11
|
+
const dictionaries = {};
|
|
12
|
+
if ((0, node_fs.existsSync)(directory)) {
|
|
13
|
+
const files = (0, node_fs.readdirSync)(directory).filter((file) => file.endsWith(".json"));
|
|
14
|
+
for (const file of files) {
|
|
15
|
+
const key = (0, node_path.basename)(file, (0, node_path.extname)(file));
|
|
16
|
+
dictionaries[key] = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(directory, file), "utf-8"));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return dictionaries;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.readDictionariesFromDisk = readDictionariesFromDisk;
|
|
24
|
+
//# sourceMappingURL=readDictionariesFromDisk.cjs.map
|
package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readDictionariesFromDisk.cjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs"],"sourcesContent":["import { basename, extname, join } from \"node:path\";\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\n\n//#region src/utils/readDictionariesFromDisk.ts\n/**\n* Reads all JSON dictionary files from a directory, keyed by filename.\n* Uses readFileSync instead of require() to avoid require.cache memory leak.\n*/\nconst readDictionariesFromDisk = (directory) => {\n\tconst dictionaries = {};\n\tif (existsSync(directory)) {\n\t\tconst files = readdirSync(directory).filter((file) => file.endsWith(\".json\"));\n\t\tfor (const file of files) {\n\t\t\tconst key = basename(file, extname(file));\n\t\t\tdictionaries[key] = JSON.parse(readFileSync(join(directory, file), \"utf-8\"));\n\t\t}\n\t}\n\treturn dictionaries;\n};\n\n//#endregion\nexport { readDictionariesFromDisk };\n//# sourceMappingURL=readDictionariesFromDisk.mjs.map"],"mappings":";;;;;;;;;AAQA,MAAM,4BAA4B,cAAc;CAC/C,MAAM,eAAe,EAAE;AACvB,6BAAe,UAAU,EAAE;EAC1B,MAAM,iCAAoB,UAAU,CAAC,QAAQ,SAAS,KAAK,SAAS,QAAQ,CAAC;AAC7E,OAAK,MAAM,QAAQ,OAAO;GACzB,MAAM,8BAAe,6BAAc,KAAK,CAAC;AACzC,gBAAa,OAAO,KAAK,oDAAwB,WAAW,KAAK,EAAE,QAAQ,CAAC;;;AAG9E,QAAO"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { basename, extname, join } from "node:path";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs
|
|
5
|
+
/**
|
|
6
|
+
* Reads all JSON dictionary files from a directory, keyed by filename.
|
|
7
|
+
* Uses readFileSync instead of require() to avoid require.cache memory leak.
|
|
8
|
+
*/
|
|
9
|
+
const readDictionariesFromDisk = (directory) => {
|
|
10
|
+
const dictionaries = {};
|
|
11
|
+
if (existsSync(directory)) {
|
|
12
|
+
const files = readdirSync(directory).filter((file) => file.endsWith(".json"));
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
const key = basename(file, extname(file));
|
|
15
|
+
dictionaries[key] = JSON.parse(readFileSync(join(directory, file), "utf-8"));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return dictionaries;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { readDictionariesFromDisk };
|
|
23
|
+
//# sourceMappingURL=readDictionariesFromDisk.mjs.map
|
package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readDictionariesFromDisk.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs"],"sourcesContent":["import { basename, extname, join } from \"node:path\";\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\n\n//#region src/utils/readDictionariesFromDisk.ts\n/**\n* Reads all JSON dictionary files from a directory, keyed by filename.\n* Uses readFileSync instead of require() to avoid require.cache memory leak.\n*/\nconst readDictionariesFromDisk = (directory) => {\n\tconst dictionaries = {};\n\tif (existsSync(directory)) {\n\t\tconst files = readdirSync(directory).filter((file) => file.endsWith(\".json\"));\n\t\tfor (const file of files) {\n\t\t\tconst key = basename(file, extname(file));\n\t\t\tdictionaries[key] = JSON.parse(readFileSync(join(directory, file), \"utf-8\"));\n\t\t}\n\t}\n\treturn dictionaries;\n};\n\n//#endregion\nexport { readDictionariesFromDisk };\n//# sourceMappingURL=readDictionariesFromDisk.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,4BAA4B,cAAc;CAC/C,MAAM,eAAe,EAAE;AACvB,KAAI,WAAW,UAAU,EAAE;EAC1B,MAAM,QAAQ,YAAY,UAAU,CAAC,QAAQ,SAAS,KAAK,SAAS,QAAQ,CAAC;AAC7E,OAAK,MAAM,QAAQ,OAAO;GACzB,MAAM,MAAM,SAAS,MAAM,QAAQ,KAAK,CAAC;AACzC,gBAAa,OAAO,KAAK,MAAM,aAAa,KAAK,WAAW,KAAK,EAAE,QAAQ,CAAC;;;AAG9E,QAAO"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_deepTransform = require('../../../../core/dist/esm/interpreter/getContent/deepTransform.cjs');
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
|
+
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
7
|
+
_intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
|
|
8
|
+
|
|
9
|
+
//#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs
|
|
10
|
+
/**
|
|
11
|
+
* Write file plugin
|
|
12
|
+
*/
|
|
13
|
+
const writeFilePlugin = {
|
|
14
|
+
id: "write-file-plugin",
|
|
15
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.FILE,
|
|
16
|
+
transform: (node) => {
|
|
17
|
+
const fileContent = node.content;
|
|
18
|
+
const filePath = node.fixedPath;
|
|
19
|
+
if (typeof fileContent !== "string") throw new Error("File content must be a string");
|
|
20
|
+
if (typeof filePath !== "string") throw new Error("File path must be a string");
|
|
21
|
+
try {
|
|
22
|
+
const absoluteFilePath = (0, node_path.join)(process.cwd(), filePath);
|
|
23
|
+
const fileDirectory = (0, node_path.dirname)(absoluteFilePath);
|
|
24
|
+
if (!(0, node_fs.existsSync)(fileDirectory)) (0, node_fs.mkdirSync)(fileDirectory, { recursive: true });
|
|
25
|
+
(0, node_fs.writeFileSync)(absoluteFilePath, fileContent);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
throw new Error(`${_intlayer_config_logger.x} Error writing file to ${(0, _intlayer_config_logger.colorizePath)(filePath)}: ${error}`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
nodeType: _intlayer_types_nodeType.FILE,
|
|
31
|
+
[_intlayer_types_nodeType.FILE]: node[_intlayer_types_nodeType.FILE]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Markdown file plugin
|
|
37
|
+
*/
|
|
38
|
+
const markdownFilePlugin = {
|
|
39
|
+
id: "markdown-file-plugin",
|
|
40
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
|
|
41
|
+
transform: (node, props, deepTransformNode) => {
|
|
42
|
+
return {
|
|
43
|
+
nodeType: _intlayer_types_nodeType.MARKDOWN,
|
|
44
|
+
[_intlayer_types_nodeType.MARKDOWN]: deepTransformNode(node[_intlayer_types_nodeType.MARKDOWN], props)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Insertion file plugin
|
|
50
|
+
*/
|
|
51
|
+
const insertionFilePlugin = {
|
|
52
|
+
id: "insertion-file-plugin",
|
|
53
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
|
|
54
|
+
transform: (node, props, deepTransformNode) => {
|
|
55
|
+
return {
|
|
56
|
+
nodeType: _intlayer_types_nodeType.INSERTION,
|
|
57
|
+
[_intlayer_types_nodeType.INSERTION]: deepTransformNode(node[_intlayer_types_nodeType.INSERTION], props)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* HTML file plugin
|
|
63
|
+
*/
|
|
64
|
+
const htmlFilePlugin = {
|
|
65
|
+
id: "html-file-plugin",
|
|
66
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
|
|
67
|
+
transform: (node, props, deepTransformNode) => {
|
|
68
|
+
return {
|
|
69
|
+
nodeType: _intlayer_types_nodeType.HTML,
|
|
70
|
+
[_intlayer_types_nodeType.HTML]: deepTransformNode(node[_intlayer_types_nodeType.HTML], props)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Process content declaration content
|
|
76
|
+
*
|
|
77
|
+
* It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.
|
|
78
|
+
*
|
|
79
|
+
* And write external sources as file content if necessary.
|
|
80
|
+
*/
|
|
81
|
+
const processContentDeclarationContent = async (dictionary) => require_deepTransform.deepTransformNode(dictionary, {
|
|
82
|
+
dictionaryKey: dictionary.key,
|
|
83
|
+
keyPath: [],
|
|
84
|
+
plugins: [
|
|
85
|
+
writeFilePlugin,
|
|
86
|
+
markdownFilePlugin,
|
|
87
|
+
insertionFilePlugin,
|
|
88
|
+
htmlFilePlugin
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.processContentDeclarationContent = processContentDeclarationContent;
|
|
94
|
+
//# sourceMappingURL=processContentDeclarationContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processContentDeclarationContent.cjs","names":["NodeTypes","x","deepTransformNode"],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs"],"sourcesContent":["import { dirname, join } from \"node:path\";\nimport { colorizePath, x } from \"@intlayer/config/logger\";\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { deepTransformNode } from \"@intlayer/core/interpreter\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/writeContentDeclaration/processContentDeclarationContent.ts\n/**\n* Write file plugin\n*/\nconst writeFilePlugin = {\n\tid: \"write-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.FILE,\n\ttransform: (node) => {\n\t\tconst fileContent = node.content;\n\t\tconst filePath = node.fixedPath;\n\t\tif (typeof fileContent !== \"string\") throw new Error(\"File content must be a string\");\n\t\tif (typeof filePath !== \"string\") throw new Error(\"File path must be a string\");\n\t\ttry {\n\t\t\tconst absoluteFilePath = join(process.cwd(), filePath);\n\t\t\tconst fileDirectory = dirname(absoluteFilePath);\n\t\t\tif (!existsSync(fileDirectory)) mkdirSync(fileDirectory, { recursive: true });\n\t\t\twriteFileSync(absoluteFilePath, fileContent);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`${x} Error writing file to ${colorizePath(filePath)}: ${error}`);\n\t\t}\n\t\treturn {\n\t\t\tnodeType: NodeTypes.FILE,\n\t\t\t[NodeTypes.FILE]: node[NodeTypes.FILE]\n\t\t};\n\t}\n};\n/**\n* Markdown file plugin\n*/\nconst markdownFilePlugin = {\n\tid: \"markdown-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.MARKDOWN,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.MARKDOWN,\n\t\t\t[NodeTypes.MARKDOWN]: deepTransformNode(node[NodeTypes.MARKDOWN], props)\n\t\t};\n\t}\n};\n/**\n* Insertion file plugin\n*/\nconst insertionFilePlugin = {\n\tid: \"insertion-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.INSERTION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.INSERTION,\n\t\t\t[NodeTypes.INSERTION]: deepTransformNode(node[NodeTypes.INSERTION], props)\n\t\t};\n\t}\n};\n/**\n* HTML file plugin\n*/\nconst htmlFilePlugin = {\n\tid: \"html-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.HTML,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.HTML,\n\t\t\t[NodeTypes.HTML]: deepTransformNode(node[NodeTypes.HTML], props)\n\t\t};\n\t}\n};\n/**\n* Process content declaration content\n*\n* It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.\n*\n* And write external sources as file content if necessary.\n*/\nconst processContentDeclarationContent = async (dictionary) => deepTransformNode(dictionary, {\n\tdictionaryKey: dictionary.key,\n\tkeyPath: [],\n\tplugins: [\n\t\twriteFilePlugin,\n\t\tmarkdownFilePlugin,\n\t\tinsertionFilePlugin,\n\t\thtmlFilePlugin\n\t]\n});\n\n//#endregion\nexport { processContentDeclarationContent };\n//# sourceMappingURL=processContentDeclarationContent.mjs.map"],"mappings":";;;;;;;;;;;;AAUA,MAAM,kBAAkB;CACvB,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,SAAS;EACpB,MAAM,cAAc,KAAK;EACzB,MAAM,WAAW,KAAK;AACtB,MAAI,OAAO,gBAAgB,SAAU,OAAM,IAAI,MAAM,gCAAgC;AACrF,MAAI,OAAO,aAAa,SAAU,OAAM,IAAI,MAAM,6BAA6B;AAC/E,MAAI;GACH,MAAM,uCAAwB,QAAQ,KAAK,EAAE,SAAS;GACtD,MAAM,uCAAwB,iBAAiB;AAC/C,OAAI,yBAAY,cAAc,CAAE,wBAAU,eAAe,EAAE,WAAW,MAAM,CAAC;AAC7E,8BAAc,kBAAkB,YAAY;WACpC,OAAO;AACf,SAAM,IAAI,MAAM,GAAGC,0BAAE,mEAAsC,SAAS,CAAC,IAAI,QAAQ;;AAElF,SAAO;GACN,UAAUD,yBAAU;IACnBA,yBAAU,OAAO,KAAKA,yBAAU;GACjC;;CAEF;;;;AAID,MAAM,qBAAqB;CAC1B,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAUA,yBAAU;IACnBA,yBAAU,WAAW,kBAAkB,KAAKA,yBAAU,WAAW,MAAM;GACxE;;CAEF;;;;AAID,MAAM,sBAAsB;CAC3B,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAUA,yBAAU;IACnBA,yBAAU,YAAY,kBAAkB,KAAKA,yBAAU,YAAY,MAAM;GAC1E;;CAEF;;;;AAID,MAAM,iBAAiB;CACtB,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,kBAAkB,KAAKA,yBAAU,OAAO,MAAM;GAChE;;CAEF;;;;;;;;AAQD,MAAM,mCAAmC,OAAO,eAAeE,wCAAkB,YAAY;CAC5F,eAAe,WAAW;CAC1B,SAAS,EAAE;CACX,SAAS;EACR;EACA;EACA;EACA;EACA;CACD,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { deepTransformNode } from "../../../../core/dist/esm/interpreter/getContent/deepTransform.mjs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { colorizePath, x } from "@intlayer/config/logger";
|
|
5
|
+
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
6
|
+
|
|
7
|
+
//#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs
|
|
8
|
+
/**
|
|
9
|
+
* Write file plugin
|
|
10
|
+
*/
|
|
11
|
+
const writeFilePlugin = {
|
|
12
|
+
id: "write-file-plugin",
|
|
13
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.FILE,
|
|
14
|
+
transform: (node) => {
|
|
15
|
+
const fileContent = node.content;
|
|
16
|
+
const filePath = node.fixedPath;
|
|
17
|
+
if (typeof fileContent !== "string") throw new Error("File content must be a string");
|
|
18
|
+
if (typeof filePath !== "string") throw new Error("File path must be a string");
|
|
19
|
+
try {
|
|
20
|
+
const absoluteFilePath = join(process.cwd(), filePath);
|
|
21
|
+
const fileDirectory = dirname(absoluteFilePath);
|
|
22
|
+
if (!existsSync(fileDirectory)) mkdirSync(fileDirectory, { recursive: true });
|
|
23
|
+
writeFileSync(absoluteFilePath, fileContent);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new Error(`${x} Error writing file to ${colorizePath(filePath)}: ${error}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
nodeType: NodeTypes.FILE,
|
|
29
|
+
[NodeTypes.FILE]: node[NodeTypes.FILE]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Markdown file plugin
|
|
35
|
+
*/
|
|
36
|
+
const markdownFilePlugin = {
|
|
37
|
+
id: "markdown-file-plugin",
|
|
38
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
|
|
39
|
+
transform: (node, props, deepTransformNode) => {
|
|
40
|
+
return {
|
|
41
|
+
nodeType: NodeTypes.MARKDOWN,
|
|
42
|
+
[NodeTypes.MARKDOWN]: deepTransformNode(node[NodeTypes.MARKDOWN], props)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Insertion file plugin
|
|
48
|
+
*/
|
|
49
|
+
const insertionFilePlugin = {
|
|
50
|
+
id: "insertion-file-plugin",
|
|
51
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
52
|
+
transform: (node, props, deepTransformNode) => {
|
|
53
|
+
return {
|
|
54
|
+
nodeType: NodeTypes.INSERTION,
|
|
55
|
+
[NodeTypes.INSERTION]: deepTransformNode(node[NodeTypes.INSERTION], props)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* HTML file plugin
|
|
61
|
+
*/
|
|
62
|
+
const htmlFilePlugin = {
|
|
63
|
+
id: "html-file-plugin",
|
|
64
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
65
|
+
transform: (node, props, deepTransformNode) => {
|
|
66
|
+
return {
|
|
67
|
+
nodeType: NodeTypes.HTML,
|
|
68
|
+
[NodeTypes.HTML]: deepTransformNode(node[NodeTypes.HTML], props)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Process content declaration content
|
|
74
|
+
*
|
|
75
|
+
* It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.
|
|
76
|
+
*
|
|
77
|
+
* And write external sources as file content if necessary.
|
|
78
|
+
*/
|
|
79
|
+
const processContentDeclarationContent = async (dictionary) => deepTransformNode(dictionary, {
|
|
80
|
+
dictionaryKey: dictionary.key,
|
|
81
|
+
keyPath: [],
|
|
82
|
+
plugins: [
|
|
83
|
+
writeFilePlugin,
|
|
84
|
+
markdownFilePlugin,
|
|
85
|
+
insertionFilePlugin,
|
|
86
|
+
htmlFilePlugin
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { processContentDeclarationContent };
|
|
92
|
+
//# sourceMappingURL=processContentDeclarationContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processContentDeclarationContent.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs"],"sourcesContent":["import { dirname, join } from \"node:path\";\nimport { colorizePath, x } from \"@intlayer/config/logger\";\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { deepTransformNode } from \"@intlayer/core/interpreter\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/writeContentDeclaration/processContentDeclarationContent.ts\n/**\n* Write file plugin\n*/\nconst writeFilePlugin = {\n\tid: \"write-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.FILE,\n\ttransform: (node) => {\n\t\tconst fileContent = node.content;\n\t\tconst filePath = node.fixedPath;\n\t\tif (typeof fileContent !== \"string\") throw new Error(\"File content must be a string\");\n\t\tif (typeof filePath !== \"string\") throw new Error(\"File path must be a string\");\n\t\ttry {\n\t\t\tconst absoluteFilePath = join(process.cwd(), filePath);\n\t\t\tconst fileDirectory = dirname(absoluteFilePath);\n\t\t\tif (!existsSync(fileDirectory)) mkdirSync(fileDirectory, { recursive: true });\n\t\t\twriteFileSync(absoluteFilePath, fileContent);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`${x} Error writing file to ${colorizePath(filePath)}: ${error}`);\n\t\t}\n\t\treturn {\n\t\t\tnodeType: NodeTypes.FILE,\n\t\t\t[NodeTypes.FILE]: node[NodeTypes.FILE]\n\t\t};\n\t}\n};\n/**\n* Markdown file plugin\n*/\nconst markdownFilePlugin = {\n\tid: \"markdown-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.MARKDOWN,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.MARKDOWN,\n\t\t\t[NodeTypes.MARKDOWN]: deepTransformNode(node[NodeTypes.MARKDOWN], props)\n\t\t};\n\t}\n};\n/**\n* Insertion file plugin\n*/\nconst insertionFilePlugin = {\n\tid: \"insertion-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.INSERTION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.INSERTION,\n\t\t\t[NodeTypes.INSERTION]: deepTransformNode(node[NodeTypes.INSERTION], props)\n\t\t};\n\t}\n};\n/**\n* HTML file plugin\n*/\nconst htmlFilePlugin = {\n\tid: \"html-file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.HTML,\n\ttransform: (node, props, deepTransformNode) => {\n\t\treturn {\n\t\t\tnodeType: NodeTypes.HTML,\n\t\t\t[NodeTypes.HTML]: deepTransformNode(node[NodeTypes.HTML], props)\n\t\t};\n\t}\n};\n/**\n* Process content declaration content\n*\n* It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.\n*\n* And write external sources as file content if necessary.\n*/\nconst processContentDeclarationContent = async (dictionary) => deepTransformNode(dictionary, {\n\tdictionaryKey: dictionary.key,\n\tkeyPath: [],\n\tplugins: [\n\t\twriteFilePlugin,\n\t\tmarkdownFilePlugin,\n\t\tinsertionFilePlugin,\n\t\thtmlFilePlugin\n\t]\n});\n\n//#endregion\nexport { processContentDeclarationContent };\n//# sourceMappingURL=processContentDeclarationContent.mjs.map"],"mappings":";;;;;;;;;;AAUA,MAAM,kBAAkB;CACvB,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,SAAS;EACpB,MAAM,cAAc,KAAK;EACzB,MAAM,WAAW,KAAK;AACtB,MAAI,OAAO,gBAAgB,SAAU,OAAM,IAAI,MAAM,gCAAgC;AACrF,MAAI,OAAO,aAAa,SAAU,OAAM,IAAI,MAAM,6BAA6B;AAC/E,MAAI;GACH,MAAM,mBAAmB,KAAK,QAAQ,KAAK,EAAE,SAAS;GACtD,MAAM,gBAAgB,QAAQ,iBAAiB;AAC/C,OAAI,CAAC,WAAW,cAAc,CAAE,WAAU,eAAe,EAAE,WAAW,MAAM,CAAC;AAC7E,iBAAc,kBAAkB,YAAY;WACpC,OAAO;AACf,SAAM,IAAI,MAAM,GAAG,EAAE,yBAAyB,aAAa,SAAS,CAAC,IAAI,QAAQ;;AAElF,SAAO;GACN,UAAU,UAAU;IACnB,UAAU,OAAO,KAAK,UAAU;GACjC;;CAEF;;;;AAID,MAAM,qBAAqB;CAC1B,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAU,UAAU;IACnB,UAAU,WAAW,kBAAkB,KAAK,UAAU,WAAW,MAAM;GACxE;;CAEF;;;;AAID,MAAM,sBAAsB;CAC3B,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAU,UAAU;IACnB,UAAU,YAAY,kBAAkB,KAAK,UAAU,YAAY,MAAM;GAC1E;;CAEF;;;;AAID,MAAM,iBAAiB;CACtB,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;AAC9C,SAAO;GACN,UAAU,UAAU;IACnB,UAAU,OAAO,kBAAkB,KAAK,UAAU,OAAO,MAAM;GAChE;;CAEF;;;;;;;;AAQD,MAAM,mCAAmC,OAAO,eAAe,kBAAkB,YAAY;CAC5F,eAAe,WAAW;CAC1B,SAAS,EAAE;CACX,SAAS;EACR;EACA;EACA;EACA;EACA;CACD,CAAC"}
|