@intlayer/chokidar 2.0.1 → 2.0.2
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/chokidar/watcher.cjs +11 -5
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.cjs +4 -2
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +39 -59
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.d.ts +3 -38
- package/dist/cjs/transpiler/dictionary_to_type/index.d.ts +1 -2
- package/dist/esm/chokidar/watcher.mjs +11 -5
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.mjs +4 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +3 -38
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +41 -58
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/index.d.mts +1 -2
- package/package.json +12 -11
|
@@ -52,12 +52,15 @@ const watch = (options) => {
|
|
|
52
52
|
...options
|
|
53
53
|
}).on("ready", async () => {
|
|
54
54
|
const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(files);
|
|
55
|
-
console.info("Building
|
|
56
|
-
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
55
|
+
console.info("Building TypeScript types...");
|
|
56
|
+
await (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
57
|
+
console.info("TypeScript types built");
|
|
57
58
|
console.info("Building Intlayer module augmentation...");
|
|
58
59
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
60
|
+
console.info("Intlayer module augmentation built");
|
|
59
61
|
console.info("Building Intlayer dictionary list...");
|
|
60
62
|
(0, import_createDictionaryList.createDictionaryList)();
|
|
63
|
+
console.info("Intlayer dictionary list built");
|
|
61
64
|
const relativeDictionariesPath = dictionariesPaths.map(
|
|
62
65
|
(dictionary) => (0, import_path.relative)(baseDir, dictionary)
|
|
63
66
|
);
|
|
@@ -68,16 +71,19 @@ const watch = (options) => {
|
|
|
68
71
|
console.info("Additional file detected: ", (0, import_path.relative)(baseDir, filePath));
|
|
69
72
|
const dictionaries = await (0, import_declaration_file_to_dictionary.buildDictionary)(filePath);
|
|
70
73
|
console.info("Building TypeScript types...");
|
|
71
|
-
(0, import_dictionary_to_type.createTypes)(dictionaries);
|
|
72
|
-
console.info("
|
|
74
|
+
await (0, import_dictionary_to_type.createTypes)(dictionaries);
|
|
75
|
+
console.info("TypeScript types built");
|
|
76
|
+
console.info("Building Intlayer module augmentation...");
|
|
73
77
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
78
|
+
console.info("Intlayer module augmentation built");
|
|
74
79
|
console.info("Building main...");
|
|
75
80
|
(0, import_createDictionaryList.createDictionaryList)();
|
|
76
81
|
}).on("change", async (filePath) => {
|
|
77
82
|
console.info("Change detected: ", (0, import_path.relative)(baseDir, filePath));
|
|
78
83
|
const dictionaries = await (0, import_declaration_file_to_dictionary.buildDictionary)(filePath);
|
|
79
84
|
console.info("Building TypeScript types...");
|
|
80
|
-
(0, import_dictionary_to_type.createTypes)(dictionaries);
|
|
85
|
+
await (0, import_dictionary_to_type.createTypes)(dictionaries);
|
|
86
|
+
console.info("TypeScript types built");
|
|
81
87
|
}).on("error", (error) => {
|
|
82
88
|
console.error("Watcher error:", error);
|
|
83
89
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionariesPaths);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building Intlayer dictionary list...');\n createDictionaryList();\n console.info('Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Additional file detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building main...');\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAAiC;AACjC,sBAA4C;AAC5C,kBAAqB;AACrB,4CAAgC;AAChC,kCAAqC;AACrC,gCAGO;AAGA,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,EAAE,QAAQ,QAAI,gCAAiB;AAAA,IACnC,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,6BAA6B,QAAQ,IAAI;AAEjD,QAAM,YAAkB,kBAAK,2BAA2B;AAExD,SAAO,gBAAAA,QACJ,MAAM,6BAA6B;AAAA,IAClC,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACA,GAAG,SAAS,YAAY;AACvB,UAAM,oBAAoB,UAAM,uDAAgB,KAAK;AAErD,YAAQ,KAAK,8BAA8B;AAC3C,cAAM,uCAAY,iBAAiB;AACnC,YAAQ,KAAK,wBAAwB;AAErC,YAAQ,KAAK,0CAA0C;AACvD,4DAAyB;AACzB,YAAQ,KAAK,oCAAoC;AAEjD,YAAQ,KAAK,sCAAsC;AACnD,0DAAqB;AACrB,YAAQ,KAAK,gCAAgC;AAE7C,UAAM,2BAA2B,kBAAkB;AAAA,MAAI,CAAC,mBACtD,sBAAS,SAAS,UAAU;AAAA,IAC9B;AAEA,YAAQ,KAAK,iBAAiB,wBAAwB;AAAA,EACxD,CAAC,EACA,GAAG,UAAU,CAAC,aAAa;AAE1B,YAAQ,KAAK,+BAA2B,sBAAS,SAAS,QAAQ,CAAC;AAAA,EACrE,CAAC,EACA,GAAG,OAAO,OAAO,aAAa;AAE7B,YAAQ,KAAK,kCAA8B,sBAAS,SAAS,QAAQ,CAAC;AACtE,UAAM,eAAe,UAAM,uDAAgB,QAAQ;AAEnD,YAAQ,KAAK,8BAA8B;AAC3C,cAAM,uCAAY,YAAY;AAC9B,YAAQ,KAAK,wBAAwB;AAErC,YAAQ,KAAK,0CAA0C;AACvD,4DAAyB;AACzB,YAAQ,KAAK,oCAAoC;AAEjD,YAAQ,KAAK,kBAAkB;AAC/B,0DAAqB;AAAA,EACvB,CAAC,EACA,GAAG,UAAU,OAAO,aAAa;AAEhC,YAAQ,KAAK,yBAAqB,sBAAS,SAAS,QAAQ,CAAC;AAC7D,UAAM,eAAe,UAAM,uDAAgB,QAAQ;AAEnD,YAAQ,KAAK,8BAA8B;AAC3C,cAAM,uCAAY,YAAY;AAC9B,YAAQ,KAAK,wBAAwB;AAAA,EACvC,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":["chokidar"]}
|
|
@@ -33,14 +33,16 @@ const buildDictionary = (content, locale) => {
|
|
|
33
33
|
// Translation node
|
|
34
34
|
content && content.nodeType === import_core.NodeType.Translation
|
|
35
35
|
) {
|
|
36
|
-
const result = content[locale];
|
|
36
|
+
const result = content[import_core.NodeType.Translation][locale];
|
|
37
37
|
return buildDictionary(result, locale);
|
|
38
38
|
} else if (
|
|
39
39
|
// Translation node
|
|
40
40
|
content && content.nodeType === import_core.NodeType.Enumeration
|
|
41
41
|
) {
|
|
42
42
|
const plurals = {};
|
|
43
|
-
Object.keys(
|
|
43
|
+
Object.keys(
|
|
44
|
+
content[import_core.NodeType.Enumeration]
|
|
45
|
+
).forEach((quantity) => {
|
|
44
46
|
const letterNumber = (0, import_convertPluralsValues.convertPluralsValues)(quantity);
|
|
45
47
|
const value = content[quantity];
|
|
46
48
|
plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type Content,\n type TypedNode,\n type EnumerationContent,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (content: Dictionary, locale: Locales): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[locale];\n\n return buildDictionary(result as Dictionary, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(content).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as Dictionary,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue] as Dictionary,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: Content\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAMO;AACP,kCAAqC;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,QAAI,gCAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CAAC,SAAqB,WAA6B;AACzE;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,SAAU,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type Content,\n type TypedNode,\n type EnumerationContent,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (content: Dictionary, locale: Locales): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as Dictionary, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as Dictionary,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue] as Dictionary,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: Content\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAMO;AACP,kCAAqC;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,QAAI,gCAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CAAC,SAAqB,WAA6B;AACzE;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,qBAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAAsB,MAAM;AAAA,EACrD;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,qBAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,mBAAe,kDAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAe;AAAA,QACvB;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,YAC2B;AAE3B,QAAM,SAAiC,QAAQ;AAAA,IAC7C,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -19,76 +19,52 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var createType_exports = {};
|
|
20
20
|
__export(createType_exports, {
|
|
21
21
|
createTypes: () => createTypes,
|
|
22
|
-
generateTypeScriptType: () => generateTypeScriptType
|
|
23
|
-
generateTypeScriptTypeContent: () => generateTypeScriptTypeContent
|
|
22
|
+
generateTypeScriptType: () => generateTypeScriptType
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(createType_exports);
|
|
26
25
|
var import_fs = require("fs");
|
|
27
26
|
var import_module = require("module");
|
|
28
27
|
var import_path = require("path");
|
|
29
28
|
var import_config = require("@intlayer/config");
|
|
30
|
-
var
|
|
31
|
-
var import_createModuleAugmentation = require('./createModuleAugmentation.cjs');
|
|
29
|
+
var import_quicktype_core = require("quicktype-core");
|
|
32
30
|
const import_meta = {};
|
|
33
31
|
const { content } = (0, import_config.getConfiguration)();
|
|
34
32
|
const { typesDir } = content;
|
|
35
33
|
const isESModule = typeof import_meta.url === "string";
|
|
36
34
|
const requireFunction = isESModule ? (0, import_module.createRequire)(import_meta.url) : require;
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const typeName = (0, import_createModuleAugmentation.getTypeName)(obj.id);
|
|
41
|
-
typeDefinition += `export type ${typeName} = `;
|
|
42
|
-
typeDefinition += generateTypeScriptTypeContent(obj);
|
|
43
|
-
typeDefinition += ";\n\n";
|
|
44
|
-
return typeDefinition;
|
|
45
|
-
};
|
|
46
|
-
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
47
|
-
const generateTypeScriptTypeContent = (obj) => {
|
|
48
|
-
if (typeof obj !== "object" || obj === null) {
|
|
49
|
-
return `${typeof obj}`;
|
|
50
|
-
}
|
|
51
|
-
const isReactNodeValue = isReactNode(obj);
|
|
52
|
-
if (isReactNodeValue) {
|
|
53
|
-
return `JSX.Element`;
|
|
54
|
-
}
|
|
55
|
-
if (
|
|
56
|
-
// Check if the value is a typed node
|
|
57
|
-
obj.nodeType === import_core.NodeType.Translation
|
|
58
|
-
) {
|
|
59
|
-
const { nodeType, ...content2 } = obj;
|
|
60
|
-
const languageValue = getFirstValue(
|
|
61
|
-
content2
|
|
62
|
-
);
|
|
63
|
-
const tsType = generateTypeScriptTypeContent(languageValue);
|
|
64
|
-
return `${tsType}`;
|
|
65
|
-
} else if (
|
|
66
|
-
// Check if the value is a typed node
|
|
67
|
-
obj.nodeType === import_core.NodeType.Enumeration
|
|
68
|
-
) {
|
|
69
|
-
const { nodeType, ...content2 } = obj;
|
|
70
|
-
const quantifiedValue = getFirstValue(
|
|
71
|
-
content2
|
|
72
|
-
);
|
|
73
|
-
const tsType = generateTypeScriptTypeContent(quantifiedValue);
|
|
74
|
-
return `(quantity: number) => ${tsType}`;
|
|
75
|
-
} else if (Array.isArray(obj)) {
|
|
76
|
-
const arrayType = generateTypeScriptTypeContent(obj[0]);
|
|
77
|
-
return `${arrayType}[]`;
|
|
35
|
+
const kebabCaseToCammelCase = (name) => name.split(/[\s\-_]+/).map((word, index) => {
|
|
36
|
+
if (index === 0) {
|
|
37
|
+
return word;
|
|
78
38
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
39
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
40
|
+
}).join("");
|
|
41
|
+
const generateTypeScriptType = async (typeName, jsonString) => {
|
|
42
|
+
const { lines } = await quicktypeJSON(typeName, jsonString);
|
|
43
|
+
const linesString = lines.join("\n");
|
|
44
|
+
return linesString;
|
|
45
|
+
};
|
|
46
|
+
const quicktypeJSON = async (typeName, jsonString) => {
|
|
47
|
+
const jsonInput = (0, import_quicktype_core.jsonInputForTargetLanguage)("typescript");
|
|
48
|
+
await jsonInput.addSource({
|
|
49
|
+
name: typeName,
|
|
50
|
+
samples: [jsonString]
|
|
51
|
+
});
|
|
52
|
+
const inputData = new import_quicktype_core.InputData();
|
|
53
|
+
inputData.addInput(jsonInput);
|
|
54
|
+
return await (0, import_quicktype_core.quicktype)({
|
|
55
|
+
inputData,
|
|
56
|
+
lang: "typescript",
|
|
57
|
+
alphabetizeProperties: true,
|
|
58
|
+
rendererOptions: {
|
|
59
|
+
"just-types": "true",
|
|
60
|
+
"explicit-unions": "true",
|
|
61
|
+
"acronym-style": "camel",
|
|
62
|
+
"prefer-types": "true",
|
|
63
|
+
readonly: "false"
|
|
86
64
|
}
|
|
87
|
-
}
|
|
88
|
-
typeDefinition += "}";
|
|
89
|
-
return typeDefinition;
|
|
65
|
+
});
|
|
90
66
|
};
|
|
91
|
-
const createTypes = (dictionariesPaths) => {
|
|
67
|
+
const createTypes = async (dictionariesPaths) => {
|
|
92
68
|
const resultTypesPaths = [];
|
|
93
69
|
if (!(0, import_fs.existsSync)(typesDir)) {
|
|
94
70
|
(0, import_fs.mkdirSync)(typesDir, { recursive: true });
|
|
@@ -96,7 +72,12 @@ const createTypes = (dictionariesPaths) => {
|
|
|
96
72
|
for (const dictionaryPath of dictionariesPaths) {
|
|
97
73
|
const dictionary = requireFunction(dictionaryPath);
|
|
98
74
|
const dictionaryName = dictionary.id;
|
|
99
|
-
const
|
|
75
|
+
const dictionaryNameCamelCase = kebabCaseToCammelCase(dictionaryName) + "Content";
|
|
76
|
+
const dictionaryContentString = JSON.stringify(dictionary);
|
|
77
|
+
const typeDefinition = await generateTypeScriptType(
|
|
78
|
+
dictionaryNameCamelCase,
|
|
79
|
+
dictionaryContentString
|
|
80
|
+
);
|
|
100
81
|
const outputPath = (0, import_path.resolve)(typesDir, `${dictionaryName}.d.ts`);
|
|
101
82
|
(0, import_fs.writeFileSync)(outputPath, typeDefinition);
|
|
102
83
|
resultTypesPaths.push(outputPath);
|
|
@@ -106,7 +87,6 @@ const createTypes = (dictionariesPaths) => {
|
|
|
106
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
88
|
0 && (module.exports = {
|
|
108
89
|
createTypes,
|
|
109
|
-
generateTypeScriptType
|
|
110
|
-
generateTypeScriptTypeContent
|
|
90
|
+
generateTypeScriptType
|
|
111
91
|
});
|
|
112
92
|
//# sourceMappingURL=createType.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,oBAA8B;AAC9B,kBAAwB;AACxB,oBAAiC;AAEjC,4BAIO;AATP;AAWA,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,SAAS,IAAI;AAErB,MAAM,aAAa,OAAO,YAAY,QAAQ;AAC9C,MAAM,kBAAkB,iBAAa,6BAAc,YAAY,GAAG,IAAI;AAEtE,MAAM,wBAAwB,CAAC,SAC7B,KACG,MAAM,UAAU,EAChB,IAAI,CAAC,MAAM,UAAU;AACpB,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,SAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACpD,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,yBAAyB,OACpC,UACA,eACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,cAAc,UAAU,UAAU;AAE1D,QAAM,cAAsB,MAAM,KAAK,IAAI;AAE3C,SAAO;AACT;AAEA,MAAM,gBAAgB,OAAO,UAAkB,eAAuB;AACpE,QAAM,gBAAY,kDAA2B,YAAY;AAMzD,QAAM,UAAU,UAAU;AAAA,IACxB,MAAM;AAAA,IACN,SAAS,CAAC,UAAU;AAAA,EACtB,CAAC;AAED,QAAM,YAAY,IAAI,gCAAU;AAChC,YAAU,SAAS,SAAS;AAE5B,SAAO,UAAM,iCAAU;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,IACN,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,MACf,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AAKO,MAAM,cAAc,OACzB,sBACsB;AACtB,QAAM,mBAA6B,CAAC;AAGpC,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,6BAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,aAAyB,gBAAgB,cAAc;AAC7D,UAAM,iBAAyB,WAAW;AAC1C,UAAM,0BACJ,sBAAsB,cAAc,IAAI;AAE1C,UAAM,0BAAkC,KAAK,UAAU,UAAU;AAEjE,UAAM,iBAAyB,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,iBAAqB,qBAAQ,UAAU,GAAG,cAAc,OAAO;AAErE,iCAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,42 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* This function generates a TypeScript type definition from a JSON object
|
|
6
|
-
*
|
|
7
|
-
* Example:
|
|
8
|
-
*
|
|
9
|
-
* const input = {
|
|
10
|
-
* id: '1',
|
|
11
|
-
* name: 'John Doe',
|
|
12
|
-
* address: {
|
|
13
|
-
* id: '2',
|
|
14
|
-
* street: '123 Main St',
|
|
15
|
-
* city: 'Springfield',
|
|
16
|
-
* }
|
|
17
|
-
* };
|
|
18
|
-
*
|
|
19
|
-
* const result = generateTypeScriptType(input, 'RootObject');
|
|
20
|
-
* console.log(result);
|
|
21
|
-
*
|
|
22
|
-
* Output:
|
|
23
|
-
*
|
|
24
|
-
* type RootObject = {
|
|
25
|
-
* id: '1',
|
|
26
|
-
* name: string,
|
|
27
|
-
* address: {
|
|
28
|
-
* id: '2',
|
|
29
|
-
* street: string,
|
|
30
|
-
* city: string,
|
|
31
|
-
* },
|
|
32
|
-
* };
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
declare const generateTypeScriptType: (obj: Dictionary) => string;
|
|
36
|
-
declare const generateTypeScriptTypeContent: (obj: DictionaryValue) => string;
|
|
1
|
+
declare const generateTypeScriptType: (typeName: string, jsonString: string) => Promise<string>;
|
|
37
2
|
/**
|
|
38
3
|
* This function generates a TypeScript type definition from a JSON object
|
|
39
4
|
*/
|
|
40
|
-
declare const createTypes: (dictionariesPaths: string[]) => string[]
|
|
5
|
+
declare const createTypes: (dictionariesPaths: string[]) => Promise<string[]>;
|
|
41
6
|
|
|
42
|
-
export { createTypes, generateTypeScriptType
|
|
7
|
+
export { createTypes, generateTypeScriptType };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { createModuleAugmentation, getTypeName } from './createModuleAugmentation.js';
|
|
2
|
-
export { createTypes, generateTypeScriptType
|
|
3
|
-
import '@intlayer/core';
|
|
2
|
+
export { createTypes, generateTypeScriptType } from './createType.js';
|
|
@@ -22,12 +22,15 @@ const watch = (options) => {
|
|
|
22
22
|
...options
|
|
23
23
|
}).on("ready", async () => {
|
|
24
24
|
const dictionariesPaths = await buildDictionary(files);
|
|
25
|
-
console.info("Building
|
|
26
|
-
createTypes(dictionariesPaths);
|
|
25
|
+
console.info("Building TypeScript types...");
|
|
26
|
+
await createTypes(dictionariesPaths);
|
|
27
|
+
console.info("TypeScript types built");
|
|
27
28
|
console.info("Building Intlayer module augmentation...");
|
|
28
29
|
createModuleAugmentation();
|
|
30
|
+
console.info("Intlayer module augmentation built");
|
|
29
31
|
console.info("Building Intlayer dictionary list...");
|
|
30
32
|
createDictionaryList();
|
|
33
|
+
console.info("Intlayer dictionary list built");
|
|
31
34
|
const relativeDictionariesPath = dictionariesPaths.map(
|
|
32
35
|
(dictionary) => relative(baseDir, dictionary)
|
|
33
36
|
);
|
|
@@ -38,16 +41,19 @@ const watch = (options) => {
|
|
|
38
41
|
console.info("Additional file detected: ", relative(baseDir, filePath));
|
|
39
42
|
const dictionaries = await buildDictionary(filePath);
|
|
40
43
|
console.info("Building TypeScript types...");
|
|
41
|
-
createTypes(dictionaries);
|
|
42
|
-
console.info("
|
|
44
|
+
await createTypes(dictionaries);
|
|
45
|
+
console.info("TypeScript types built");
|
|
46
|
+
console.info("Building Intlayer module augmentation...");
|
|
43
47
|
createModuleAugmentation();
|
|
48
|
+
console.info("Intlayer module augmentation built");
|
|
44
49
|
console.info("Building main...");
|
|
45
50
|
createDictionaryList();
|
|
46
51
|
}).on("change", async (filePath) => {
|
|
47
52
|
console.info("Change detected: ", relative(baseDir, filePath));
|
|
48
53
|
const dictionaries = await buildDictionary(filePath);
|
|
49
54
|
console.info("Building TypeScript types...");
|
|
50
|
-
createTypes(dictionaries);
|
|
55
|
+
await createTypes(dictionaries);
|
|
56
|
+
console.info("TypeScript types built");
|
|
51
57
|
}).on("error", (error) => {
|
|
52
58
|
console.error("Watcher error:", error);
|
|
53
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionariesPaths);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building Intlayer dictionary list...');\n createDictionaryList();\n console.info('Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Additional file detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building main...');\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,OAAO,cAAqC;AAC5C,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAGA,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAAA,IACnC,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,6BAA6B,QAAQ,IAAI;AAEjD,QAAM,QAAkB,KAAK,2BAA2B;AAExD,SAAO,SACJ,MAAM,6BAA6B;AAAA,IAClC,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACA,GAAG,SAAS,YAAY;AACvB,UAAM,oBAAoB,MAAM,gBAAgB,KAAK;AAErD,YAAQ,KAAK,8BAA8B;AAC3C,UAAM,YAAY,iBAAiB;AACnC,YAAQ,KAAK,wBAAwB;AAErC,YAAQ,KAAK,0CAA0C;AACvD,6BAAyB;AACzB,YAAQ,KAAK,oCAAoC;AAEjD,YAAQ,KAAK,sCAAsC;AACnD,yBAAqB;AACrB,YAAQ,KAAK,gCAAgC;AAE7C,UAAM,2BAA2B,kBAAkB;AAAA,MAAI,CAAC,eACtD,SAAS,SAAS,UAAU;AAAA,IAC9B;AAEA,YAAQ,KAAK,iBAAiB,wBAAwB;AAAA,EACxD,CAAC,EACA,GAAG,UAAU,CAAC,aAAa;AAE1B,YAAQ,KAAK,2BAA2B,SAAS,SAAS,QAAQ,CAAC;AAAA,EACrE,CAAC,EACA,GAAG,OAAO,OAAO,aAAa;AAE7B,YAAQ,KAAK,8BAA8B,SAAS,SAAS,QAAQ,CAAC;AACtE,UAAM,eAAe,MAAM,gBAAgB,QAAQ;AAEnD,YAAQ,KAAK,8BAA8B;AAC3C,UAAM,YAAY,YAAY;AAC9B,YAAQ,KAAK,wBAAwB;AAErC,YAAQ,KAAK,0CAA0C;AACvD,6BAAyB;AACzB,YAAQ,KAAK,oCAAoC;AAEjD,YAAQ,KAAK,kBAAkB;AAC/B,yBAAqB;AAAA,EACvB,CAAC,EACA,GAAG,UAAU,OAAO,aAAa;AAEhC,YAAQ,KAAK,qBAAqB,SAAS,SAAS,QAAQ,CAAC;AAC7D,UAAM,eAAe,MAAM,gBAAgB,QAAQ;AAEnD,YAAQ,KAAK,8BAA8B;AAC3C,UAAM,YAAY,YAAY;AAC9B,YAAQ,KAAK,wBAAwB;AAAA,EACvC,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":[]}
|
|
@@ -12,14 +12,16 @@ const buildDictionary = (content, locale) => {
|
|
|
12
12
|
// Translation node
|
|
13
13
|
content && content.nodeType === NodeType.Translation
|
|
14
14
|
) {
|
|
15
|
-
const result = content[locale];
|
|
15
|
+
const result = content[NodeType.Translation][locale];
|
|
16
16
|
return buildDictionary(result, locale);
|
|
17
17
|
} else if (
|
|
18
18
|
// Translation node
|
|
19
19
|
content && content.nodeType === NodeType.Enumeration
|
|
20
20
|
) {
|
|
21
21
|
const plurals = {};
|
|
22
|
-
Object.keys(
|
|
22
|
+
Object.keys(
|
|
23
|
+
content[NodeType.Enumeration]
|
|
24
|
+
).forEach((quantity) => {
|
|
23
25
|
const letterNumber = convertPluralsValues(quantity);
|
|
24
26
|
const value = content[quantity];
|
|
25
27
|
plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type Content,\n type TypedNode,\n type EnumerationContent,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (content: Dictionary, locale: Locales): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[locale];\n\n return buildDictionary(result as Dictionary, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(content).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as Dictionary,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue] as Dictionary,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: Content\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,OAKK;AACP,SAAS,4BAA4B;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,IAAI,iBAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CAAC,SAAqB,WAA6B;AACzE;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,SAAU,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type Content,\n type TypedNode,\n type EnumerationContent,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (content: Dictionary, locale: Locales): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as Dictionary, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as Dictionary,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue] as Dictionary,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: Content\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,OAKK;AACP,SAAS,4BAA4B;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,IAAI,iBAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CAAC,SAAqB,WAA6B;AACzE;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,SAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAAsB,MAAM;AAAA,EACrD;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,SAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,eAAe,qBAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAe;AAAA,QACvB;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,YAC2B;AAE3B,QAAM,SAAiC,QAAQ;AAAA,IAC7C,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,42 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* This function generates a TypeScript type definition from a JSON object
|
|
6
|
-
*
|
|
7
|
-
* Example:
|
|
8
|
-
*
|
|
9
|
-
* const input = {
|
|
10
|
-
* id: '1',
|
|
11
|
-
* name: 'John Doe',
|
|
12
|
-
* address: {
|
|
13
|
-
* id: '2',
|
|
14
|
-
* street: '123 Main St',
|
|
15
|
-
* city: 'Springfield',
|
|
16
|
-
* }
|
|
17
|
-
* };
|
|
18
|
-
*
|
|
19
|
-
* const result = generateTypeScriptType(input, 'RootObject');
|
|
20
|
-
* console.log(result);
|
|
21
|
-
*
|
|
22
|
-
* Output:
|
|
23
|
-
*
|
|
24
|
-
* type RootObject = {
|
|
25
|
-
* id: '1',
|
|
26
|
-
* name: string,
|
|
27
|
-
* address: {
|
|
28
|
-
* id: '2',
|
|
29
|
-
* street: string,
|
|
30
|
-
* city: string,
|
|
31
|
-
* },
|
|
32
|
-
* };
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
declare const generateTypeScriptType: (obj: Dictionary) => string;
|
|
36
|
-
declare const generateTypeScriptTypeContent: (obj: DictionaryValue) => string;
|
|
1
|
+
declare const generateTypeScriptType: (typeName: string, jsonString: string) => Promise<string>;
|
|
37
2
|
/**
|
|
38
3
|
* This function generates a TypeScript type definition from a JSON object
|
|
39
4
|
*/
|
|
40
|
-
declare const createTypes: (dictionariesPaths: string[]) => string[]
|
|
5
|
+
declare const createTypes: (dictionariesPaths: string[]) => Promise<string[]>;
|
|
41
6
|
|
|
42
|
-
export { createTypes, generateTypeScriptType
|
|
7
|
+
export { createTypes, generateTypeScriptType };
|
|
@@ -3,68 +3,47 @@ import { createRequire } from "module";
|
|
|
3
3
|
import { resolve } from "path";
|
|
4
4
|
import { getConfiguration } from "@intlayer/config";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
quicktype,
|
|
7
|
+
InputData,
|
|
8
|
+
jsonInputForTargetLanguage
|
|
9
|
+
} from "quicktype-core";
|
|
9
10
|
const { content } = getConfiguration();
|
|
10
11
|
const { typesDir } = content;
|
|
11
12
|
const isESModule = typeof import.meta.url === "string";
|
|
12
13
|
const requireFunction = isESModule ? createRequire(import.meta.url) : require;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const typeName = getTypeName(obj.id);
|
|
17
|
-
typeDefinition += `export type ${typeName} = `;
|
|
18
|
-
typeDefinition += generateTypeScriptTypeContent(obj);
|
|
19
|
-
typeDefinition += ";\n\n";
|
|
20
|
-
return typeDefinition;
|
|
21
|
-
};
|
|
22
|
-
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
23
|
-
const generateTypeScriptTypeContent = (obj) => {
|
|
24
|
-
if (typeof obj !== "object" || obj === null) {
|
|
25
|
-
return `${typeof obj}`;
|
|
26
|
-
}
|
|
27
|
-
const isReactNodeValue = isReactNode(obj);
|
|
28
|
-
if (isReactNodeValue) {
|
|
29
|
-
return `JSX.Element`;
|
|
30
|
-
}
|
|
31
|
-
if (
|
|
32
|
-
// Check if the value is a typed node
|
|
33
|
-
obj.nodeType === NodeType.Translation
|
|
34
|
-
) {
|
|
35
|
-
const { nodeType, ...content2 } = obj;
|
|
36
|
-
const languageValue = getFirstValue(
|
|
37
|
-
content2
|
|
38
|
-
);
|
|
39
|
-
const tsType = generateTypeScriptTypeContent(languageValue);
|
|
40
|
-
return `${tsType}`;
|
|
41
|
-
} else if (
|
|
42
|
-
// Check if the value is a typed node
|
|
43
|
-
obj.nodeType === NodeType.Enumeration
|
|
44
|
-
) {
|
|
45
|
-
const { nodeType, ...content2 } = obj;
|
|
46
|
-
const quantifiedValue = getFirstValue(
|
|
47
|
-
content2
|
|
48
|
-
);
|
|
49
|
-
const tsType = generateTypeScriptTypeContent(quantifiedValue);
|
|
50
|
-
return `(quantity: number) => ${tsType}`;
|
|
51
|
-
} else if (Array.isArray(obj)) {
|
|
52
|
-
const arrayType = generateTypeScriptTypeContent(obj[0]);
|
|
53
|
-
return `${arrayType}[]`;
|
|
14
|
+
const kebabCaseToCammelCase = (name) => name.split(/[\s\-_]+/).map((word, index) => {
|
|
15
|
+
if (index === 0) {
|
|
16
|
+
return word;
|
|
54
17
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
18
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
19
|
+
}).join("");
|
|
20
|
+
const generateTypeScriptType = async (typeName, jsonString) => {
|
|
21
|
+
const { lines } = await quicktypeJSON(typeName, jsonString);
|
|
22
|
+
const linesString = lines.join("\n");
|
|
23
|
+
return linesString;
|
|
24
|
+
};
|
|
25
|
+
const quicktypeJSON = async (typeName, jsonString) => {
|
|
26
|
+
const jsonInput = jsonInputForTargetLanguage("typescript");
|
|
27
|
+
await jsonInput.addSource({
|
|
28
|
+
name: typeName,
|
|
29
|
+
samples: [jsonString]
|
|
30
|
+
});
|
|
31
|
+
const inputData = new InputData();
|
|
32
|
+
inputData.addInput(jsonInput);
|
|
33
|
+
return await quicktype({
|
|
34
|
+
inputData,
|
|
35
|
+
lang: "typescript",
|
|
36
|
+
alphabetizeProperties: true,
|
|
37
|
+
rendererOptions: {
|
|
38
|
+
"just-types": "true",
|
|
39
|
+
"explicit-unions": "true",
|
|
40
|
+
"acronym-style": "camel",
|
|
41
|
+
"prefer-types": "true",
|
|
42
|
+
readonly: "false"
|
|
62
43
|
}
|
|
63
|
-
}
|
|
64
|
-
typeDefinition += "}";
|
|
65
|
-
return typeDefinition;
|
|
44
|
+
});
|
|
66
45
|
};
|
|
67
|
-
const createTypes = (dictionariesPaths) => {
|
|
46
|
+
const createTypes = async (dictionariesPaths) => {
|
|
68
47
|
const resultTypesPaths = [];
|
|
69
48
|
if (!existsSync(typesDir)) {
|
|
70
49
|
mkdirSync(typesDir, { recursive: true });
|
|
@@ -72,7 +51,12 @@ const createTypes = (dictionariesPaths) => {
|
|
|
72
51
|
for (const dictionaryPath of dictionariesPaths) {
|
|
73
52
|
const dictionary = requireFunction(dictionaryPath);
|
|
74
53
|
const dictionaryName = dictionary.id;
|
|
75
|
-
const
|
|
54
|
+
const dictionaryNameCamelCase = kebabCaseToCammelCase(dictionaryName) + "Content";
|
|
55
|
+
const dictionaryContentString = JSON.stringify(dictionary);
|
|
56
|
+
const typeDefinition = await generateTypeScriptType(
|
|
57
|
+
dictionaryNameCamelCase,
|
|
58
|
+
dictionaryContentString
|
|
59
|
+
);
|
|
76
60
|
const outputPath = resolve(typesDir, `${dictionaryName}.d.ts`);
|
|
77
61
|
writeFileSync(outputPath, typeDefinition);
|
|
78
62
|
resultTypesPaths.push(outputPath);
|
|
@@ -81,7 +65,6 @@ const createTypes = (dictionariesPaths) => {
|
|
|
81
65
|
};
|
|
82
66
|
export {
|
|
83
67
|
createTypes,
|
|
84
|
-
generateTypeScriptType
|
|
85
|
-
generateTypeScriptTypeContent
|
|
68
|
+
generateTypeScriptType
|
|
86
69
|
};
|
|
87
70
|
//# sourceMappingURL=createType.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAEjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,SAAS,IAAI;AAErB,MAAM,aAAa,OAAO,YAAY,QAAQ;AAC9C,MAAM,kBAAkB,aAAa,cAAc,YAAY,GAAG,IAAI;AAEtE,MAAM,wBAAwB,CAAC,SAC7B,KACG,MAAM,UAAU,EAChB,IAAI,CAAC,MAAM,UAAU;AACpB,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,SAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACpD,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,yBAAyB,OACpC,UACA,eACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,cAAc,UAAU,UAAU;AAE1D,QAAM,cAAsB,MAAM,KAAK,IAAI;AAE3C,SAAO;AACT;AAEA,MAAM,gBAAgB,OAAO,UAAkB,eAAuB;AACpE,QAAM,YAAY,2BAA2B,YAAY;AAMzD,QAAM,UAAU,UAAU;AAAA,IACxB,MAAM;AAAA,IACN,SAAS,CAAC,UAAU;AAAA,EACtB,CAAC;AAED,QAAM,YAAY,IAAI,UAAU;AAChC,YAAU,SAAS,SAAS;AAE5B,SAAO,MAAM,UAAU;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,IACN,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,MACf,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AAKO,MAAM,cAAc,OACzB,sBACsB;AACtB,QAAM,mBAA6B,CAAC;AAGpC,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,cAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,aAAyB,gBAAgB,cAAc;AAC7D,UAAM,iBAAyB,WAAW;AAC1C,UAAM,0BACJ,sBAAsB,cAAc,IAAI;AAE1C,UAAM,0BAAkC,KAAK,UAAU,UAAU;AAEjE,UAAM,iBAAyB,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,aAAqB,QAAQ,UAAU,GAAG,cAAc,OAAO;AAErE,kBAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { createModuleAugmentation, getTypeName } from './createModuleAugmentation.mjs';
|
|
2
|
-
export { createTypes, generateTypeScriptType
|
|
3
|
-
import '@intlayer/core';
|
|
2
|
+
export { createTypes, generateTypeScriptType } from './createType.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Chokidar application for IntLayer - Transpile IntLayer declaration files into dictionaries.",
|
|
6
6
|
"keywords": [
|
|
@@ -47,24 +47,25 @@
|
|
|
47
47
|
"chokidar": "^3.6.0",
|
|
48
48
|
"crypto-js": "^4.2.0",
|
|
49
49
|
"esbuild": "^0.20.2",
|
|
50
|
-
"esbuild-loader": "^4.
|
|
51
|
-
"glob": "^10.
|
|
50
|
+
"esbuild-loader": "^4.2.0",
|
|
51
|
+
"glob": "^10.4.2",
|
|
52
52
|
"node-loader": "^2.0.0",
|
|
53
|
+
"quicktype-core": "^23.0.170",
|
|
53
54
|
"rimraf": "5.0.5",
|
|
54
|
-
"@intlayer/config": "^2.0.
|
|
55
|
-
"@intlayer/core": "^2.0.
|
|
56
|
-
"intlayer": "^2.0.
|
|
55
|
+
"@intlayer/config": "^2.0.2",
|
|
56
|
+
"@intlayer/core": "^2.0.2",
|
|
57
|
+
"intlayer": "^2.0.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@changesets/cli": "2.27.1",
|
|
60
61
|
"@types/crypto-js": "^4.2.2",
|
|
61
|
-
"@types/node": "^20.
|
|
62
|
+
"@types/node": "^20.14.9",
|
|
62
63
|
"node-polyfill-webpack-plugin": "^3.0.0",
|
|
63
|
-
"tsup": "^8.0
|
|
64
|
-
"typescript": "^5.
|
|
64
|
+
"tsup": "^8.1.0",
|
|
65
|
+
"typescript": "^5.5.2",
|
|
65
66
|
"webpack-watch-files-plugin": "^1.2.1",
|
|
66
|
-
"@utils/eslint-config": "^1.0.
|
|
67
|
-
"@utils/ts-config": "^1.0.
|
|
67
|
+
"@utils/eslint-config": "^1.0.2",
|
|
68
|
+
"@utils/ts-config": "^1.0.2"
|
|
68
69
|
},
|
|
69
70
|
"engines": {
|
|
70
71
|
"node": ">=14.18"
|