@intlayer/core 5.3.5 → 5.3.6
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/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/transpiler/file/file.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +1 -2
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
- package/dist/types/transpiler/file/file.d.ts +2 -2
- package/dist/types/transpiler/insertion/insertion.d.ts +2 -2
- package/dist/types/transpiler/markdown/markdown.d.ts +2 -2
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type ContentNode, NodeType } from '../types';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n switch (nodeType) {\n case NodeType.Translation:\n return {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: content ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeType.Enumeration:\n return {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': content ?? '',\n },\n } as ContentNode;\n\n case NodeType.Condition:\n return {\n nodeType: NodeType.Condition,\n [NodeType.Condition]: {\n true: content ?? '',\n false: content ?? '',\n },\n } as ContentNode;\n\n case NodeType.Insertion:\n return {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: {\n insertion: content ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeType.Nested:\n return {\n nodeType: NodeType.Nested,\n [NodeType.Nested]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeType.Markdown:\n return {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: content ?? '',\n } as ContentNode;\n\n case NodeType.File:\n return {\n nodeType: NodeType.File,\n [NodeType.File]: content ?? '',\n } as ContentNode;\n\n case NodeType.Object:\n return {\n newKey: content ?? '',\n } as unknown as ContentNode;\n\n case NodeType.Array:\n return [content ?? ''] as unknown as ContentNode;\n\n case NodeType.Text:\n return content ?? '';\n\n case NodeType.Number:\n return content ?? 0;\n\n case NodeType.Boolean:\n return content ?? true;\n\n default:\n return content ?? '';\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2C;AAEpC,MAAM,iBAAiB,CAC5B,UACA,SACA,YACgB;AAChB,UAAQ,UAAU;AAAA,IAChB,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,WAAW,GAAG,OAAO;AAAA,UAC7B,CAAC;AAAA,UACD,GAAG,QAAQ,IAAI,CAAC,YAAY;AAAA,YAC1B,CAAC,MAAM,GAAG,WAAW;AAAA,UACvB,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,WAAW,GAAG;AAAA,UACtB,KAAK,WAAW;AAAA,QAClB;AAAA,MACF;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,SAAS,GAAG;AAAA,UACpB,MAAM,WAAW;AAAA,UACjB,OAAO,WAAW;AAAA,QACpB;AAAA,MACF;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,SAAS,GAAG;AAAA,UACpB,WAAW,WAAW;AAAA,QACxB;AAAA,MACF;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,MAAM,GAAG;AAAA,UACjB,eAAe;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,QAAQ,GAAG,WAAW;AAAA,MAClC;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,UAAU,sBAAS;AAAA,QACnB,CAAC,sBAAS,IAAI,GAAG,WAAW;AAAA,MAC9B;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO;AAAA,QACL,QAAQ,WAAW;AAAA,MACrB;AAAA,IAEF,KAAK,sBAAS;AACZ,aAAO,CAAC,WAAW,EAAE;AAAA,IAEvB,KAAK,sBAAS;AACZ,aAAO,WAAW;AAAA,IAEpB,KAAK,sBAAS;AACZ,aAAO,WAAW;AAAA,IAEpB,KAAK,sBAAS;AACZ,aAAO,WAAW;AAAA,IAEpB;AACE,aAAO,WAAW;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { relative, resolve } from 'path';\nimport { appLogger } from '@intlayer/config';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { relative, resolve } from 'path';\nimport { appLogger } from '@intlayer/config';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<NodeType.File, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\ndeclare const intlayer_file_path: string; // Injected by esbuild to track the file content\ndeclare const intlayer_file_dir: string; // Injected by esbuild to track the file path\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const callerDir = intlayer_file_dir ?? process.cwd();\n\n const isAbsolutePath = path.startsWith('/');\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n\n let filePath: string;\n if (isAbsolutePath) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${intlayer_file_path}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(process.cwd(), path);\n }\n\n let content: string;\n\n if (existsSync(filePath)) {\n content = readFileSync(filePath, 'utf8');\n } else {\n appLogger(`File not found: ${filePath}`, { level: 'warn' });\n\n content = `File not found`;\n }\n\n return formatNodeType(NodeType.File, path, {\n content,\n fixedPath: relative(process.cwd(), filePath),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAyC;AACzC,mBAIO;AACP,kBAAkC;AAClC,oBAA0B;AA4BnB,MAAM,OAAO,CAAC,SAA8B;AACjD,QAAM,YAAY,qBAAqB,QAAQ,IAAI;AAEnD,QAAM,iBAAiB,KAAK,WAAW,GAAG;AAC1C,QAAM,iBAAiB,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;AAErE,MAAI;AACJ,MAAI,gBAAgB;AAClB;AAAA,MACE,sFAAsF,IAAI,oBAAoB,kBAAkB;AAAA,MAChI,EAAE,OAAO,OAAO;AAAA,IAClB;AACA,eAAW;AAAA,EACb,WAAW,gBAAgB;AACzB,mBAAW,qBAAQ,WAAW,IAAI;AAAA,EACpC,OAAO;AACL,mBAAW,qBAAQ,QAAQ,IAAI,GAAG,IAAI;AAAA,EACxC;AAEA,MAAI;AAEJ,UAAI,sBAAW,QAAQ,GAAG;AACxB,kBAAU,wBAAa,UAAU,MAAM;AAAA,EACzC,OAAO;AACL,iCAAU,mBAAmB,QAAQ,IAAI,EAAE,OAAO,OAAO,CAAC;AAE1D,cAAU;AAAA,EACZ;AAEA,aAAO,6BAAe,sBAAS,MAAM,MAAM;AAAA,IACzC;AAAA,IACA,eAAW,sBAAS,QAAQ,IAAI,GAAG,QAAQ;AAAA,EAC7C,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.Insertion, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent = undefined;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Insertion, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AACP,gCAAmC;AA0BnC,MAAM,YAAY,CAChB,YAC8B;AAC9B,QAAM,gBAAgB,MAAM;AAC1B,QAAI,OAAO,YAAY,UAAU;AAC/B,iBAAO,8CAAmB,OAAO;AAAA,IACnC;AAEA,QAAI,gBAAgB;AAEpB,QAAI,OAAO,YAAY,YAAY;AACjC,sBAAgB,QAAQ;AAAA,IAC1B,WAAW,OAAQ,QAA4B,SAAS,YAAY;AAClE,sBAAgB,gBACd,8CAAmB,MAAO,OAA2B;AAAA,IACzD;AAEA,QAAI,OAAO,kBAAkB,UAAU;AACrC,iBAAO,8CAAmB,aAAa;AAAA,IACzC;AAEA,QAAI;AACF,iBAAO,8CAAmB,KAAK,UAAU,OAAO,CAAC;AAAA,IACnD,SAAS,GAAG;AACV,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,aAAO,6BAAe,sBAAS,WAAW,SAAS;AAAA,IACjD,QAAQ,cAAc;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<Content = unknown> = MarkdownContentConstructor<{\n metadata?: Record<string, any>;\n}>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <Content = unknown>(content: Content): MarkdownContent => {\n const getMetadata = () => {\n if (typeof content === 'string') {\n return getMarkdownMetadata(content);\n }\n if (typeof content === 'function') {\n return () => getMarkdownMetadata(content());\n } else if (typeof (content as Promise<string>).then === 'function') {\n return async () =>\n getMarkdownMetadata(await (content as Promise<string>));\n }\n };\n\n return formatNodeType(NodeType.Markdown, content as string, {\n metadata: getMetadata(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AACP,iCAAoC;AAuBpC,MAAM,WAAW,CAAoB,YAAsC;AACzE,QAAM,cAAc,MAAM;AACxB,QAAI,OAAO,YAAY,UAAU;AAC/B,iBAAO,gDAAoB,OAAO;AAAA,IACpC;AACA,QAAI,OAAO,YAAY,YAAY;AACjC,aAAO,UAAM,gDAAoB,QAAQ,CAAC;AAAA,IAC5C,WAAW,OAAQ,QAA4B,SAAS,YAAY;AAClE,aAAO,gBACL,gDAAoB,MAAO,OAA2B;AAAA,IAC1D;AAAA,EACF;AAEA,aAAO,6BAAe,sBAAS,UAAU,SAAmB;AAAA,IAC1D,UAAU,YAAY;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type ContentNode, NodeType } from '../types';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n switch (nodeType) {\n case NodeType.Translation:\n return {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: content ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeType.Enumeration:\n return {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': content ?? '',\n },\n } as ContentNode;\n\n case NodeType.Condition:\n return {\n nodeType: NodeType.Condition,\n [NodeType.Condition]: {\n true: content ?? '',\n false: content ?? '',\n },\n } as ContentNode;\n\n case NodeType.Insertion:\n return {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: {\n insertion: content ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeType.Nested:\n return {\n nodeType: NodeType.Nested,\n [NodeType.Nested]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeType.Markdown:\n return {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: content ?? '',\n } as ContentNode;\n\n case NodeType.File:\n return {\n nodeType: NodeType.File,\n [NodeType.File]: content ?? '',\n } as ContentNode;\n\n case NodeType.Object:\n return {\n newKey: content ?? '',\n } as unknown as ContentNode;\n\n case NodeType.Array:\n return [content ?? ''] as unknown as ContentNode;\n\n case NodeType.Text:\n return content ?? '';\n\n case NodeType.Number:\n return content ?? 0;\n\n case NodeType.Boolean:\n return content ?? true;\n\n default:\n return content ?? '';\n }\n};\n"],"mappings":"AACA,SAA2B,gBAAgB;AAEpC,MAAM,iBAAiB,CAC5B,UACA,SACA,YACgB;AAChB,UAAQ,UAAU;AAAA,IAChB,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,WAAW,GAAG,OAAO;AAAA,UAC7B,CAAC;AAAA,UACD,GAAG,QAAQ,IAAI,CAAC,YAAY;AAAA,YAC1B,CAAC,MAAM,GAAG,WAAW;AAAA,UACvB,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,WAAW,GAAG;AAAA,UACtB,KAAK,WAAW;AAAA,QAClB;AAAA,MACF;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,SAAS,GAAG;AAAA,UACpB,MAAM,WAAW;AAAA,UACjB,OAAO,WAAW;AAAA,QACpB;AAAA,MACF;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,SAAS,GAAG;AAAA,UACpB,WAAW,WAAW;AAAA,QACxB;AAAA,MACF;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,MAAM,GAAG;AAAA,UACjB,eAAe;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,QAAQ,GAAG,WAAW;AAAA,MAClC;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,CAAC,SAAS,IAAI,GAAG,WAAW;AAAA,MAC9B;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO;AAAA,QACL,QAAQ,WAAW;AAAA,MACrB;AAAA,IAEF,KAAK,SAAS;AACZ,aAAO,CAAC,WAAW,EAAE;AAAA,IAEvB,KAAK,SAAS;AACZ,aAAO,WAAW;AAAA,IAEpB,KAAK,SAAS;AACZ,aAAO,WAAW;AAAA,IAEpB,KAAK,SAAS;AACZ,aAAO,WAAW;AAAA,IAEpB;AACE,aAAO,WAAW;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { relative, resolve } from 'path';\nimport { appLogger } from '@intlayer/config';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { relative, resolve } from 'path';\nimport { appLogger } from '@intlayer/config';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<NodeType.File, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\ndeclare const intlayer_file_path: string; // Injected by esbuild to track the file content\ndeclare const intlayer_file_dir: string; // Injected by esbuild to track the file path\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const callerDir = intlayer_file_dir ?? process.cwd();\n\n const isAbsolutePath = path.startsWith('/');\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n\n let filePath: string;\n if (isAbsolutePath) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${intlayer_file_path}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(process.cwd(), path);\n }\n\n let content: string;\n\n if (existsSync(filePath)) {\n content = readFileSync(filePath, 'utf8');\n } else {\n appLogger(`File not found: ${filePath}`, { level: 'warn' });\n\n content = `File not found`;\n }\n\n return formatNodeType(NodeType.File, path, {\n content,\n fixedPath: relative(process.cwd(), filePath),\n });\n};\n"],"mappings":"AAAA,SAAS,YAAY,oBAAoB;AACzC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,UAAU,eAAe;AAClC,SAAS,iBAAiB;AA4BnB,MAAM,OAAO,CAAC,SAA8B;AACjD,QAAM,YAAY,qBAAqB,QAAQ,IAAI;AAEnD,QAAM,iBAAiB,KAAK,WAAW,GAAG;AAC1C,QAAM,iBAAiB,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;AAErE,MAAI;AACJ,MAAI,gBAAgB;AAClB;AAAA,MACE,sFAAsF,IAAI,oBAAoB,kBAAkB;AAAA,MAChI,EAAE,OAAO,OAAO;AAAA,IAClB;AACA,eAAW;AAAA,EACb,WAAW,gBAAgB;AACzB,eAAW,QAAQ,WAAW,IAAI;AAAA,EACpC,OAAO;AACL,eAAW,QAAQ,QAAQ,IAAI,GAAG,IAAI;AAAA,EACxC;AAEA,MAAI;AAEJ,MAAI,WAAW,QAAQ,GAAG;AACxB,cAAU,aAAa,UAAU,MAAM;AAAA,EACzC,OAAO;AACL,cAAU,mBAAmB,QAAQ,IAAI,EAAE,OAAO,OAAO,CAAC;AAE1D,cAAU;AAAA,EACZ;AAEA,SAAO,eAAe,SAAS,MAAM,MAAM;AAAA,IACzC;AAAA,IACA,WAAW,SAAS,QAAQ,IAAI,GAAG,QAAQ;AAAA,EAC7C,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.Insertion, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent = undefined;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Insertion, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,0BAA0B;AA0BnC,MAAM,YAAY,CAChB,YAC8B;AAC9B,QAAM,gBAAgB,MAAM;AAC1B,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO,mBAAmB,OAAO;AAAA,IACnC;AAEA,QAAI,gBAAgB;AAEpB,QAAI,OAAO,YAAY,YAAY;AACjC,sBAAgB,QAAQ;AAAA,IAC1B,WAAW,OAAQ,QAA4B,SAAS,YAAY;AAClE,sBAAgB,YACd,mBAAmB,MAAO,OAA2B;AAAA,IACzD;AAEA,QAAI,OAAO,kBAAkB,UAAU;AACrC,aAAO,mBAAmB,aAAa;AAAA,IACzC;AAEA,QAAI;AACF,aAAO,mBAAmB,KAAK,UAAU,OAAO,CAAC;AAAA,IACnD,SAAS,GAAG;AACV,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,WAAW,SAAS;AAAA,IACjD,QAAQ,cAAc;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<Content = unknown> = MarkdownContentConstructor<{\n metadata?: Record<string, any>;\n}>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <Content = unknown>(content: Content): MarkdownContent => {\n const getMetadata = () => {\n if (typeof content === 'string') {\n return getMarkdownMetadata(content);\n }\n if (typeof content === 'function') {\n return () => getMarkdownMetadata(content());\n } else if (typeof (content as Promise<string>).then === 'function') {\n return async () =>\n getMarkdownMetadata(await (content as Promise<string>));\n }\n };\n\n return formatNodeType(NodeType.Markdown, content as string, {\n metadata: getMetadata(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,2BAA2B;AAuBpC,MAAM,WAAW,CAAoB,YAAsC;AACzE,QAAM,cAAc,MAAM;AACxB,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO,oBAAoB,OAAO;AAAA,IACpC;AACA,QAAI,OAAO,YAAY,YAAY;AACjC,aAAO,MAAM,oBAAoB,QAAQ,CAAC;AAAA,IAC5C,WAAW,OAAQ,QAA4B,SAAS,YAAY;AAClE,aAAO,YACL,oBAAoB,MAAO,OAA2B;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,UAAU,SAAmB;AAAA,IAC1D,UAAU,YAAY;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import type { TranslationContent, EnumerationContent, ConditionContent, NestedContent, MarkdownContent, InsertionContent, FileContent } from '../transpiler';
|
|
3
2
|
import { type ContentNode, NodeType } from '../types';
|
|
4
|
-
export declare const getDefaultNode: (nodeType: NodeType, locales: LocalesValues[], content?: ContentNode) =>
|
|
3
|
+
export declare const getDefaultNode: (nodeType: NodeType, locales: LocalesValues[], content?: ContentNode) => ContentNode;
|
|
5
4
|
//# sourceMappingURL=getDefaultNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultNode.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"getDefaultNode.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,cAAc,GACzB,UAAU,QAAQ,EAClB,SAAS,aAAa,EAAE,EACxB,UAAU,WAAW,KACpB,WA8EF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
2
|
-
export type
|
|
3
|
-
export type FileContent =
|
|
2
|
+
export type FileContentConstructor<T extends Record<string, any> = {}> = TypedNodeModel<NodeType.File, string, T>;
|
|
3
|
+
export type FileContent = FileContentConstructor<{
|
|
4
4
|
content: string;
|
|
5
5
|
fixedPath?: string;
|
|
6
6
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
2
|
-
export type
|
|
3
|
-
export type InsertionContent<Content = unknown> =
|
|
2
|
+
export type InsertionContentConstructor<Content = unknown, T extends Record<string, any> = {}> = TypedNodeModel<NodeType.Insertion, Content, T>;
|
|
3
|
+
export type InsertionContent<Content = unknown> = InsertionContentConstructor<Content, {
|
|
4
4
|
fields: string[];
|
|
5
5
|
}>;
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
2
|
-
export type
|
|
3
|
-
export type MarkdownContent<Content = unknown> =
|
|
2
|
+
export type MarkdownContentConstructor<T extends Record<string, any> = {}, Content = unknown> = TypedNodeModel<NodeType.Markdown, Content, T>;
|
|
3
|
+
export type MarkdownContent<Content = unknown> = MarkdownContentConstructor<{
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
}>;
|
|
6
6
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"negotiator": "^1.0.0",
|
|
74
|
-
"@intlayer/config": "5.3.
|
|
75
|
-
"@intlayer/
|
|
76
|
-
"@intlayer/
|
|
74
|
+
"@intlayer/config": "5.3.6",
|
|
75
|
+
"@intlayer/dictionaries-entry": "5.3.6",
|
|
76
|
+
"@intlayer/api": "5.3.6"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/negotiator": "^0.6.3",
|
|
@@ -88,14 +88,14 @@
|
|
|
88
88
|
"typescript": "^5.7.3",
|
|
89
89
|
"@utils/eslint-config": "1.0.4",
|
|
90
90
|
"@utils/ts-config": "1.0.4",
|
|
91
|
-
"@utils/
|
|
92
|
-
"@utils/
|
|
91
|
+
"@utils/tsup-config": "1.0.4",
|
|
92
|
+
"@utils/ts-config-types": "1.0.4"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@intlayer/
|
|
96
|
-
"@intlayer/
|
|
97
|
-
"intlayer": "5.3.
|
|
98
|
-
"@intlayer/
|
|
95
|
+
"@intlayer/api": "5.3.6",
|
|
96
|
+
"@intlayer/dictionaries-entry": "5.3.6",
|
|
97
|
+
"intlayer": "5.3.6",
|
|
98
|
+
"@intlayer/config": "5.3.6"
|
|
99
99
|
},
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=14.18"
|