@intlayer/core 5.2.9 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +2 -2
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/plugins.cjs +3 -3
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +78 -0
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -0
- package/dist/cjs/transpiler/markdown/index.cjs +3 -1
- package/dist/cjs/transpiler/markdown/index.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs +16 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/types/nodeType.cjs +2 -1
- package/dist/cjs/types/nodeType.cjs.map +1 -1
- package/dist/esm/interpreter/getContent/deepTransform.mjs +2 -2
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/plugins.mjs +3 -3
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +54 -0
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -0
- package/dist/esm/transpiler/markdown/index.mjs +1 -0
- package/dist/esm/transpiler/markdown/index.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs +16 -1
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/types/nodeType.mjs +2 -1
- package/dist/esm/types/nodeType.mjs.map +1 -1
- package/dist/types/interpreter/getContent/plugins.d.ts +1 -1
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts +2 -0
- package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -0
- package/dist/types/transpiler/markdown/index.d.ts +1 -0
- package/dist/types/transpiler/markdown/index.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/markdown.d.ts +1 -1
- package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
- package/dist/types/types/nodeType.d.ts +3 -1
- package/dist/types/types/nodeType.d.ts.map +1 -1
- package/package.json +12 -11
|
@@ -39,7 +39,7 @@ const deepTransformNode = (node, props) => {
|
|
|
39
39
|
return node.map((child, index) => {
|
|
40
40
|
const childProps = {
|
|
41
41
|
...props,
|
|
42
|
-
|
|
42
|
+
children: child,
|
|
43
43
|
keyPath: [
|
|
44
44
|
...props.keyPath,
|
|
45
45
|
{ type: import_types.NodeType.Array, key: index }
|
|
@@ -52,7 +52,7 @@ const deepTransformNode = (node, props) => {
|
|
|
52
52
|
for (const key in node) {
|
|
53
53
|
const childProps = {
|
|
54
54
|
...props,
|
|
55
|
-
|
|
55
|
+
children: node[key],
|
|
56
56
|
keyPath: [...props.keyPath, { type: import_types.NodeType.Object, key }]
|
|
57
57
|
};
|
|
58
58
|
result[key] = deepTransformNode(node[key], childProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../../types/index';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../../types/index';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AAQhC,MAAM,oBAAoB,CAAC,MAAW,UAA0B;AAErE,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,QAAI,OAAO,UAAU,IAAI,GAAG;AAE1B,aAAO,OAAO;AAAA,QAAU;AAAA,QAAM;AAAA,QAAO,CAACA,OAAWC,WAC/C,kBAAkBD,OAAMC,MAAK;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAGA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,WAAO,KAAK,IAAI,CAAC,OAAO,UAAU;AAChC,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,UAAU;AAAA,QACV,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,sBAAS,OAAO,KAAK,MAAM;AAAA,QACrC;AAAA,MACF;AACA,aAAO,kBAAkB,OAAO,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH;AAGA,QAAM,SAA8B,CAAC;AACrC,aAAW,OAAO,MAAM;AACtB,UAAM,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,UAAU,KAAK,GAAG;AAAA,MAClB,SAAS,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,sBAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
|
|
@@ -36,7 +36,7 @@ const translationPlugin = (locale) => ({
|
|
|
36
36
|
for (const key in result) {
|
|
37
37
|
const childProps = {
|
|
38
38
|
...props,
|
|
39
|
-
|
|
39
|
+
children: result[key],
|
|
40
40
|
keyPath: [
|
|
41
41
|
...props.keyPath,
|
|
42
42
|
{ type: import_types.NodeType.Translation, key }
|
|
@@ -58,7 +58,7 @@ const enumerationPlugin = {
|
|
|
58
58
|
const child = result[key];
|
|
59
59
|
const childProps = {
|
|
60
60
|
...props,
|
|
61
|
-
|
|
61
|
+
children: child,
|
|
62
62
|
keyPath: [
|
|
63
63
|
...props.keyPath,
|
|
64
64
|
{ type: import_types.NodeType.Enumeration, key }
|
|
@@ -80,7 +80,7 @@ const conditionPlugin = {
|
|
|
80
80
|
const child = result[key];
|
|
81
81
|
const childProps = {
|
|
82
82
|
...props,
|
|
83
|
-
|
|
83
|
+
children: child,
|
|
84
84
|
keyPath: [
|
|
85
85
|
...props.keyPath,
|
|
86
86
|
{ type: import_types.NodeType.Condition, key }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n return getTranslation(result, locale);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node.enumeration);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (quantity: number) => getEnumeration(result, quantity);\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node.condition);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (value: boolean) => getCondition(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Nested,\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, props),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locales;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S> {\n translation: TranslationCond<T, S>;\n enumeration: EnumerationCond<T, S>;\n condition: ConditionCond<T, S>;\n nested: NestedCond<T, S>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n nested: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<T, K extends keyof IInterpreterPlugin<T, S>, S> =\n // Test if the key is a key of S.\n K extends keyof S\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S> =\n // Turn any read-only array into a plain mutable array\n T extends ReadonlyArray<infer U>\n ? Array<DeepTransformContent<U, S>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S> }\n : T;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<T, S = IInterpreterPluginState> =\n // Check if there is a plugin for T:\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S>, S> extends never\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S>\n : // A plugin was found – use the plugin’s transformation.\n IInterpreterPlugin<T, S>[keyof IInterpreterPlugin<T, S>];\n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C,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,sBAAS;AAAA,EAC1D,WAAW,CAAC,MAAwB,OAAO,sBAAsB;AAC/D,UAAM,SAAS,gBAAgB,KAAK,SAAS;AAE7C,eAAW,OAAO,QAAQ;AACxB,YAAM,QAAQ,OAAO,GAA0B;AAC/C,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,UAAU;AAAA,QACV,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,sBAAS,WAAW,IAAI;AAAA,QAClC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,cAAmB,kCAAa,QAAQ,KAAK;AAAA,EACvD;AACF;AAmBO,MAAM,eAAwB;AAAA,EACnC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,sBAAS;AAAA,EAC1D,WAAW,CAAC,MAAqB,cAC/B,8BAAW,KAAK,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK;AACjE;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getMarkdownMetadata_exports = {};
|
|
20
|
+
__export(getMarkdownMetadata_exports, {
|
|
21
|
+
getMarkdownMetadata: () => getMarkdownMetadata
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getMarkdownMetadata_exports);
|
|
24
|
+
const parseToObject = (input) => {
|
|
25
|
+
let normalizedInput = input.trim().replace(/^\[/, "[").replace(/^\{/, "{").replace(/\]$/, "]").replace(/\}$/, "}").replace(/([\w\d_]+)\s*:/g, '"$1":').replace(/:\s*([a-zA-Z_][\w\d_]*)/g, ': "$1"');
|
|
26
|
+
normalizedInput = normalizedInput.replace(
|
|
27
|
+
/\[([^\[\]]+?)\]/g,
|
|
28
|
+
(_match, arrayContent) => {
|
|
29
|
+
const newContent = arrayContent.split(",").map((item) => {
|
|
30
|
+
const trimmed = item.trim();
|
|
31
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || !isNaN(Number(trimmed))) {
|
|
32
|
+
return trimmed;
|
|
33
|
+
}
|
|
34
|
+
return `"${trimmed}"`;
|
|
35
|
+
}).join(", ");
|
|
36
|
+
return `[${newContent}]`;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
return JSON.parse(normalizedInput);
|
|
40
|
+
};
|
|
41
|
+
const getMarkdownMetadata = (markdown) => {
|
|
42
|
+
const lines = markdown.split(/\r?\n/);
|
|
43
|
+
const firstNonEmptyLine = lines.find((line) => line.trim() !== "");
|
|
44
|
+
if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== "---") {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
const metadata = {};
|
|
48
|
+
let inMetadataBlock = false;
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
const trimmedLine = line.trim();
|
|
51
|
+
if (trimmedLine === "---") {
|
|
52
|
+
if (!inMetadataBlock) {
|
|
53
|
+
inMetadataBlock = true;
|
|
54
|
+
continue;
|
|
55
|
+
} else {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (inMetadataBlock) {
|
|
60
|
+
const match = line.match(/^([^:]+)\s*:\s*(.*)$/);
|
|
61
|
+
if (match) {
|
|
62
|
+
const key = match[1].trim();
|
|
63
|
+
const value = match[2].trim();
|
|
64
|
+
try {
|
|
65
|
+
metadata[key] = parseToObject(value);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
metadata[key] = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return metadata;
|
|
73
|
+
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
getMarkdownMetadata
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=getMarkdownMetadata.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["const parseToObject = <T = any>(input: string): T | null => {\n // Normalize different bracket types and keys/values\n let normalizedInput = input\n .trim()\n .replace(/^\\[/, '[') // Keep array brackets\n .replace(/^\\{/, '{') // Keep object brackets\n .replace(/\\]$/, ']') // Keep array brackets\n .replace(/\\}$/, '}') // Keep object brackets\n .replace(/([\\w\\d_]+)\\s*:/g, '\"$1\":') // Ensure JSON-valid keys (e.g., key: -> \"key\":)\n .replace(/:\\s*([a-zA-Z_][\\w\\d_]*)/g, ': \"$1\"'); // Handle unquoted string values\n\n // Fix arrays with unquoted items (e.g., [content, anotherContent])\n normalizedInput = normalizedInput.replace(\n /\\[([^\\[\\]]+?)\\]/g,\n (_match, arrayContent) => {\n const newContent = (arrayContent as string)\n .split(',')\n .map((item) => {\n const trimmed = item.trim();\n // If already quoted or is a valid number, return as is.\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n !isNaN(Number(trimmed))\n ) {\n return trimmed;\n }\n return `\"${trimmed}\"`;\n })\n .join(', ');\n return `[${newContent}]`;\n }\n );\n\n // Parse the string into an object\n return JSON.parse(normalizedInput) as T;\n};\n\nexport const getMarkdownMetadata = (markdown: string): Record<string, any> => {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n return {};\n }\n\n const metadata: Record<string, any> = {};\n let inMetadataBlock = false;\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n // Toggle metadata block on encountering the delimiter.\n if (trimmedLine === '---') {\n if (!inMetadataBlock) {\n // Begin metadata block.\n inMetadataBlock = true;\n continue;\n } else {\n // End of metadata block; stop processing.\n break;\n }\n }\n\n // If we're inside the metadata block, parse key: value pairs.\n if (inMetadataBlock) {\n const match = line.match(/^([^:]+)\\s*:\\s*(.*)$/);\n if (match) {\n const key = match[1].trim();\n const value = match[2].trim();\n try {\n metadata[key] = parseToObject(value);\n } catch (e) {\n metadata[key] = value;\n }\n }\n }\n }\n\n return metadata;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,gBAAgB,CAAU,UAA4B;AAE1D,MAAI,kBAAkB,MACnB,KAAK,EACL,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,4BAA4B,QAAQ;AAG/C,oBAAkB,gBAAgB;AAAA,IAChC;AAAA,IACA,CAAC,QAAQ,iBAAiB;AACxB,YAAM,aAAc,aACjB,MAAM,GAAG,EACT,IAAI,CAAC,SAAS;AACb,cAAM,UAAU,KAAK,KAAK;AAE1B,YACG,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,KAChD,CAAC,MAAM,OAAO,OAAO,CAAC,GACtB;AACA,iBAAO;AAAA,QACT;AACA,eAAO,IAAI,OAAO;AAAA,MACpB,CAAC,EACA,KAAK,IAAI;AACZ,aAAO,IAAI,UAAU;AAAA,IACvB;AAAA,EACF;AAGA,SAAO,KAAK,MAAM,eAAe;AACnC;AAEO,MAAM,sBAAsB,CAAC,aAA0C;AAC5E,QAAM,QAAQ,SAAS,MAAM,OAAO;AAGpC,QAAM,oBAAoB,MAAM,KAAK,CAAC,SAAS,KAAK,KAAK,MAAM,EAAE;AAEjE,MAAI,CAAC,qBAAqB,kBAAkB,KAAK,MAAM,OAAO;AAC5D,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,WAAgC,CAAC;AACvC,MAAI,kBAAkB;AAEtB,aAAW,QAAQ,OAAO;AACxB,UAAM,cAAc,KAAK,KAAK;AAG9B,QAAI,gBAAgB,OAAO;AACzB,UAAI,CAAC,iBAAiB;AAEpB,0BAAkB;AAClB;AAAA,MACF,OAAO;AAEL;AAAA,MACF;AAAA,IACF;AAGA,QAAI,iBAAiB;AACnB,YAAM,QAAQ,KAAK,MAAM,sBAAsB;AAC/C,UAAI,OAAO;AACT,cAAM,MAAM,MAAM,CAAC,EAAE,KAAK;AAC1B,cAAM,QAAQ,MAAM,CAAC,EAAE,KAAK;AAC5B,YAAI;AACF,mBAAS,GAAG,IAAI,cAAc,KAAK;AAAA,QACrC,SAAS,GAAG;AACV,mBAAS,GAAG,IAAI;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -16,8 +16,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var markdown_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(markdown_exports);
|
|
18
18
|
__reExport(markdown_exports, require('./markdown.cjs'), module.exports);
|
|
19
|
+
__reExport(markdown_exports, require('./getMarkdownMetadata.cjs'), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require('./markdown.cjs')
|
|
22
|
+
...require('./markdown.cjs'),
|
|
23
|
+
...require('./getMarkdownMetadata.cjs')
|
|
22
24
|
});
|
|
23
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/index.ts"],"sourcesContent":["export * from './markdown';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,uBAAd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/index.ts"],"sourcesContent":["export * from './markdown';\nexport * from './getMarkdownMetadata';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,uBAAd;AACA,6BAAc,kCADd;","names":[]}
|
|
@@ -22,7 +22,22 @@ __export(markdown_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(markdown_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
|
|
25
|
+
var import_getMarkdownMetadata = require('./getMarkdownMetadata.cjs');
|
|
26
|
+
const markdown = (content) => {
|
|
27
|
+
const getMetadata = () => {
|
|
28
|
+
if (typeof content === "string") {
|
|
29
|
+
return (0, import_getMarkdownMetadata.getMarkdownMetadata)(content);
|
|
30
|
+
}
|
|
31
|
+
if (typeof content === "function") {
|
|
32
|
+
return () => (0, import_getMarkdownMetadata.getMarkdownMetadata)(content());
|
|
33
|
+
} else {
|
|
34
|
+
return async () => (0, import_getMarkdownMetadata.getMarkdownMetadata)(await content);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return (0, import_types.formatNodeType)(import_types.NodeType.Markdown, content, {
|
|
38
|
+
metadata: getMetadata()
|
|
39
|
+
});
|
|
40
|
+
};
|
|
26
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
42
|
0 && (module.exports = {
|
|
28
43
|
md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\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: string): MarkdownContent
|
|
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 MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\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 = (\n content: string | Promise<string> | (() => string)\n): 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 {\n return async () => getMarkdownMetadata(await content);\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;AAqBpC,MAAM,WAAW,CACf,YACoB;AACpB,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,OAAO;AACL,aAAO,gBAAY,gDAAoB,MAAM,OAAO;AAAA,IACtD;AAAA,EACF;AAEA,aAAO,6BAAe,sBAAS,UAAU,SAAmB;AAAA,IAC1D,UAAU,YAAY;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -37,7 +37,8 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
37
37
|
NodeType2["Unknown"] = "unknown";
|
|
38
38
|
return NodeType2;
|
|
39
39
|
})(NodeType || {});
|
|
40
|
-
const formatNodeType = (nodeType, content) => ({
|
|
40
|
+
const formatNodeType = (nodeType, content, additionalAttributes) => ({
|
|
41
|
+
...additionalAttributes,
|
|
41
42
|
nodeType,
|
|
42
43
|
[nodeType]: content
|
|
43
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n Text = 'text',\n Number = 'number',\n Boolean = 'boolean',\n Unknown = 'unknown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AACX,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,aAAU;AAZA,SAAAA;AAAA,GAAA;AAqBL,MAAM,iBAAiB,CAC5B,UACA,
|
|
1
|
+
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n Text = 'text',\n Number = 'number',\n Boolean = 'boolean',\n Unknown = 'unknown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content,\n additionalAttributes?: { [key: string]: any }\n) =>\n ({\n ...additionalAttributes,\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AACX,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,aAAU;AAZA,SAAAA;AAAA,GAAA;AAqBL,MAAM,iBAAiB,CAC5B,UACA,SACA,0BAEC;AAAA,EACC,GAAG;AAAA,EACH;AAAA,EACA,CAAC,QAAQ,GAAG;AACd;","names":["NodeType"]}
|
|
@@ -16,7 +16,7 @@ const deepTransformNode = (node, props) => {
|
|
|
16
16
|
return node.map((child, index) => {
|
|
17
17
|
const childProps = {
|
|
18
18
|
...props,
|
|
19
|
-
|
|
19
|
+
children: child,
|
|
20
20
|
keyPath: [
|
|
21
21
|
...props.keyPath,
|
|
22
22
|
{ type: NodeType.Array, key: index }
|
|
@@ -29,7 +29,7 @@ const deepTransformNode = (node, props) => {
|
|
|
29
29
|
for (const key in node) {
|
|
30
30
|
const childProps = {
|
|
31
31
|
...props,
|
|
32
|
-
|
|
32
|
+
children: node[key],
|
|
33
33
|
keyPath: [...props.keyPath, { type: NodeType.Object, key }]
|
|
34
34
|
};
|
|
35
35
|
result[key] = deepTransformNode(node[key], childProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../../types/index';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../../types/index';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAQhC,MAAM,oBAAoB,CAAC,MAAW,UAA0B;AAErE,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,QAAI,OAAO,UAAU,IAAI,GAAG;AAE1B,aAAO,OAAO;AAAA,QAAU;AAAA,QAAM;AAAA,QAAO,CAACA,OAAWC,WAC/C,kBAAkBD,OAAMC,MAAK;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAGA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,WAAO,KAAK,IAAI,CAAC,OAAO,UAAU;AAChC,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,UAAU;AAAA,QACV,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,OAAO,KAAK,MAAM;AAAA,QACrC;AAAA,MACF;AACA,aAAO,kBAAkB,OAAO,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH;AAGA,QAAM,SAA8B,CAAC;AACrC,aAAW,OAAO,MAAM;AACtB,UAAM,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,UAAU,KAAK,GAAG;AAAA,MAClB,SAAS,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,SAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
|
|
@@ -10,7 +10,7 @@ const translationPlugin = (locale) => ({
|
|
|
10
10
|
for (const key in result) {
|
|
11
11
|
const childProps = {
|
|
12
12
|
...props,
|
|
13
|
-
|
|
13
|
+
children: result[key],
|
|
14
14
|
keyPath: [
|
|
15
15
|
...props.keyPath,
|
|
16
16
|
{ type: NodeType.Translation, key }
|
|
@@ -32,7 +32,7 @@ const enumerationPlugin = {
|
|
|
32
32
|
const child = result[key];
|
|
33
33
|
const childProps = {
|
|
34
34
|
...props,
|
|
35
|
-
|
|
35
|
+
children: child,
|
|
36
36
|
keyPath: [
|
|
37
37
|
...props.keyPath,
|
|
38
38
|
{ type: NodeType.Enumeration, key }
|
|
@@ -54,7 +54,7 @@ const conditionPlugin = {
|
|
|
54
54
|
const child = result[key];
|
|
55
55
|
const childProps = {
|
|
56
56
|
...props,
|
|
57
|
-
|
|
57
|
+
children: child,
|
|
58
58
|
keyPath: [
|
|
59
59
|
...props.keyPath,
|
|
60
60
|
{ type: NodeType.Condition, key }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n return getTranslation(result, locale);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node.enumeration);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (quantity: number) => getEnumeration(result, quantity);\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node.condition);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (value: boolean) => getCondition(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Nested,\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, props),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locales;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S> {\n translation: TranslationCond<T, S>;\n enumeration: EnumerationCond<T, S>;\n condition: ConditionCond<T, S>;\n nested: NestedCond<T, S>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n nested: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<T, K extends keyof IInterpreterPlugin<T, S>, S> =\n // Test if the key is a key of S.\n K extends keyof S\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S> =\n // Turn any read-only array into a plain mutable array\n T extends ReadonlyArray<infer U>\n ? Array<DeepTransformContent<U, S>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S> }\n : T;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<T, S = IInterpreterPluginState> =\n // Check if there is a plugin for T:\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S>, S> extends never\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S>\n : // A plugin was found – use the plugin’s transformation.\n IInterpreterPlugin<T, S>[keyof IInterpreterPlugin<T, S>];\n"],"mappings":"AAOA,SAA4C,gBAAgB;AAC5D,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAgC,kBAAkB;AAClD,SAAS,sBAAsB;AAqCxB,MAAM,oBAAoB,CAAC,YAAoC;AAAA,EACpE,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAA0B,OAAO,sBAAsB;AACjE,UAAM,SAAS,gBAAgB,KAAK,WAAW;AAE/C,eAAW,OAAO,QAAQ;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,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,UAAmB,aAAa,QAAQ,KAAK;AAAA,EACvD;AACF;AAmBO,MAAM,eAAwB;AAAA,EACnC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAqB,UAC/B,WAAW,KAAK,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK;AACjE;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const parseToObject = (input) => {
|
|
2
|
+
let normalizedInput = input.trim().replace(/^\[/, "[").replace(/^\{/, "{").replace(/\]$/, "]").replace(/\}$/, "}").replace(/([\w\d_]+)\s*:/g, '"$1":').replace(/:\s*([a-zA-Z_][\w\d_]*)/g, ': "$1"');
|
|
3
|
+
normalizedInput = normalizedInput.replace(
|
|
4
|
+
/\[([^\[\]]+?)\]/g,
|
|
5
|
+
(_match, arrayContent) => {
|
|
6
|
+
const newContent = arrayContent.split(",").map((item) => {
|
|
7
|
+
const trimmed = item.trim();
|
|
8
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || !isNaN(Number(trimmed))) {
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
return `"${trimmed}"`;
|
|
12
|
+
}).join(", ");
|
|
13
|
+
return `[${newContent}]`;
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
return JSON.parse(normalizedInput);
|
|
17
|
+
};
|
|
18
|
+
const getMarkdownMetadata = (markdown) => {
|
|
19
|
+
const lines = markdown.split(/\r?\n/);
|
|
20
|
+
const firstNonEmptyLine = lines.find((line) => line.trim() !== "");
|
|
21
|
+
if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== "---") {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const metadata = {};
|
|
25
|
+
let inMetadataBlock = false;
|
|
26
|
+
for (const line of lines) {
|
|
27
|
+
const trimmedLine = line.trim();
|
|
28
|
+
if (trimmedLine === "---") {
|
|
29
|
+
if (!inMetadataBlock) {
|
|
30
|
+
inMetadataBlock = true;
|
|
31
|
+
continue;
|
|
32
|
+
} else {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (inMetadataBlock) {
|
|
37
|
+
const match = line.match(/^([^:]+)\s*:\s*(.*)$/);
|
|
38
|
+
if (match) {
|
|
39
|
+
const key = match[1].trim();
|
|
40
|
+
const value = match[2].trim();
|
|
41
|
+
try {
|
|
42
|
+
metadata[key] = parseToObject(value);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
metadata[key] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return metadata;
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
getMarkdownMetadata
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=getMarkdownMetadata.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["const parseToObject = <T = any>(input: string): T | null => {\n // Normalize different bracket types and keys/values\n let normalizedInput = input\n .trim()\n .replace(/^\\[/, '[') // Keep array brackets\n .replace(/^\\{/, '{') // Keep object brackets\n .replace(/\\]$/, ']') // Keep array brackets\n .replace(/\\}$/, '}') // Keep object brackets\n .replace(/([\\w\\d_]+)\\s*:/g, '\"$1\":') // Ensure JSON-valid keys (e.g., key: -> \"key\":)\n .replace(/:\\s*([a-zA-Z_][\\w\\d_]*)/g, ': \"$1\"'); // Handle unquoted string values\n\n // Fix arrays with unquoted items (e.g., [content, anotherContent])\n normalizedInput = normalizedInput.replace(\n /\\[([^\\[\\]]+?)\\]/g,\n (_match, arrayContent) => {\n const newContent = (arrayContent as string)\n .split(',')\n .map((item) => {\n const trimmed = item.trim();\n // If already quoted or is a valid number, return as is.\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n !isNaN(Number(trimmed))\n ) {\n return trimmed;\n }\n return `\"${trimmed}\"`;\n })\n .join(', ');\n return `[${newContent}]`;\n }\n );\n\n // Parse the string into an object\n return JSON.parse(normalizedInput) as T;\n};\n\nexport const getMarkdownMetadata = (markdown: string): Record<string, any> => {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n return {};\n }\n\n const metadata: Record<string, any> = {};\n let inMetadataBlock = false;\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n // Toggle metadata block on encountering the delimiter.\n if (trimmedLine === '---') {\n if (!inMetadataBlock) {\n // Begin metadata block.\n inMetadataBlock = true;\n continue;\n } else {\n // End of metadata block; stop processing.\n break;\n }\n }\n\n // If we're inside the metadata block, parse key: value pairs.\n if (inMetadataBlock) {\n const match = line.match(/^([^:]+)\\s*:\\s*(.*)$/);\n if (match) {\n const key = match[1].trim();\n const value = match[2].trim();\n try {\n metadata[key] = parseToObject(value);\n } catch (e) {\n metadata[key] = value;\n }\n }\n }\n }\n\n return metadata;\n};\n"],"mappings":"AAAA,MAAM,gBAAgB,CAAU,UAA4B;AAE1D,MAAI,kBAAkB,MACnB,KAAK,EACL,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,4BAA4B,QAAQ;AAG/C,oBAAkB,gBAAgB;AAAA,IAChC;AAAA,IACA,CAAC,QAAQ,iBAAiB;AACxB,YAAM,aAAc,aACjB,MAAM,GAAG,EACT,IAAI,CAAC,SAAS;AACb,cAAM,UAAU,KAAK,KAAK;AAE1B,YACG,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,KAChD,CAAC,MAAM,OAAO,OAAO,CAAC,GACtB;AACA,iBAAO;AAAA,QACT;AACA,eAAO,IAAI,OAAO;AAAA,MACpB,CAAC,EACA,KAAK,IAAI;AACZ,aAAO,IAAI,UAAU;AAAA,IACvB;AAAA,EACF;AAGA,SAAO,KAAK,MAAM,eAAe;AACnC;AAEO,MAAM,sBAAsB,CAAC,aAA0C;AAC5E,QAAM,QAAQ,SAAS,MAAM,OAAO;AAGpC,QAAM,oBAAoB,MAAM,KAAK,CAAC,SAAS,KAAK,KAAK,MAAM,EAAE;AAEjE,MAAI,CAAC,qBAAqB,kBAAkB,KAAK,MAAM,OAAO;AAC5D,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,WAAgC,CAAC;AACvC,MAAI,kBAAkB;AAEtB,aAAW,QAAQ,OAAO;AACxB,UAAM,cAAc,KAAK,KAAK;AAG9B,QAAI,gBAAgB,OAAO;AACzB,UAAI,CAAC,iBAAiB;AAEpB,0BAAkB;AAClB;AAAA,MACF,OAAO;AAEL;AAAA,MACF;AAAA,IACF;AAGA,QAAI,iBAAiB;AACnB,YAAM,QAAQ,KAAK,MAAM,sBAAsB;AAC/C,UAAI,OAAO;AACT,cAAM,MAAM,MAAM,CAAC,EAAE,KAAK;AAC1B,cAAM,QAAQ,MAAM,CAAC,EAAE,KAAK;AAC5B,YAAI;AACF,mBAAS,GAAG,IAAI,cAAc,KAAK;AAAA,QACrC,SAAS,GAAG;AACV,mBAAS,GAAG,IAAI;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/index.ts"],"sourcesContent":["export * from './markdown';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/index.ts"],"sourcesContent":["export * from './markdown';\nexport * from './getMarkdownMetadata';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -2,7 +2,22 @@ import {
|
|
|
2
2
|
formatNodeType,
|
|
3
3
|
NodeType
|
|
4
4
|
} from "../../types/index.mjs";
|
|
5
|
-
|
|
5
|
+
import { getMarkdownMetadata } from "./getMarkdownMetadata.mjs";
|
|
6
|
+
const markdown = (content) => {
|
|
7
|
+
const getMetadata = () => {
|
|
8
|
+
if (typeof content === "string") {
|
|
9
|
+
return getMarkdownMetadata(content);
|
|
10
|
+
}
|
|
11
|
+
if (typeof content === "function") {
|
|
12
|
+
return () => getMarkdownMetadata(content());
|
|
13
|
+
} else {
|
|
14
|
+
return async () => getMarkdownMetadata(await content);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return formatNodeType(NodeType.Markdown, content, {
|
|
18
|
+
metadata: getMetadata()
|
|
19
|
+
});
|
|
20
|
+
};
|
|
6
21
|
export {
|
|
7
22
|
markdown as md
|
|
8
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\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: string): MarkdownContent
|
|
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 MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\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 = (\n content: string | Promise<string> | (() => string)\n): 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 {\n return async () => getMarkdownMetadata(await content);\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;AAqBpC,MAAM,WAAW,CACf,YACoB;AACpB,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,OAAO;AACL,aAAO,YAAY,oBAAoB,MAAM,OAAO;AAAA,IACtD;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,UAAU,SAAmB;AAAA,IAC1D,UAAU,YAAY;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -13,7 +13,8 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
13
13
|
NodeType2["Unknown"] = "unknown";
|
|
14
14
|
return NodeType2;
|
|
15
15
|
})(NodeType || {});
|
|
16
|
-
const formatNodeType = (nodeType, content) => ({
|
|
16
|
+
const formatNodeType = (nodeType, content, additionalAttributes) => ({
|
|
17
|
+
...additionalAttributes,
|
|
17
18
|
nodeType,
|
|
18
19
|
[nodeType]: content
|
|
19
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n Text = 'text',\n Number = 'number',\n Boolean = 'boolean',\n Unknown = 'unknown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":"AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AACX,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,aAAU;AAZA,SAAAA;AAAA,GAAA;AAqBL,MAAM,iBAAiB,CAC5B,UACA,
|
|
1
|
+
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n Text = 'text',\n Number = 'number',\n Boolean = 'boolean',\n Unknown = 'unknown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content,\n additionalAttributes?: { [key: string]: any }\n) =>\n ({\n ...additionalAttributes,\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":"AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;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AC,GAEb,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAEf,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,GACvC,KAAK,GAEL,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC7B,KAAK,GACP,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,IAEhB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAC5B,KAAK,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACjC,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAAE,GACjD,CAAC,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,CAAC,GAAG,uBAAuB,IAE7D,gBAAgB,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,KAAK,GAEhE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAEd,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMarkdownMetadata.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CA4CxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
|
|
@@ -13,6 +13,6 @@ export type MarkdownContent = TypedNodeModel<NodeType.Markdown, MarkdownContentS
|
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
declare const markdown: (content: string) => MarkdownContent;
|
|
16
|
+
declare const markdown: (content: string | Promise<string> | (() => string)) => MarkdownContent;
|
|
17
17
|
export { markdown as md };
|
|
18
18
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,QAAQ,CAAC,QAAQ,EACjB,oBAAoB,CACrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,QAAQ,GACZ,SAAS,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,KACjD,eAeF,CAAC;AAEF,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC"}
|
|
@@ -17,5 +17,7 @@ export type TypedNodeModel<T extends NodeType, Content> = {
|
|
|
17
17
|
} & {
|
|
18
18
|
[K in T]: Content;
|
|
19
19
|
};
|
|
20
|
-
export declare const formatNodeType: <T extends NodeType, Content = any>(nodeType: T | `${T}`, content: Content
|
|
20
|
+
export declare const formatNodeType: <T extends NodeType, Content = any>(nodeType: T | `${T}`, content: Content, additionalAttributes?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}) => TypedNodeModel<T, Content>;
|
|
21
23
|
//# sourceMappingURL=nodeType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,IAAI;IACxD,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;CACtB,GAAG;KACD,CAAC,IAAI,CAAC,GAAG,OAAO;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,QAAQ,EAAE,OAAO,GAAG,GAAG,EAC9D,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,EACpB,SAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,IAAI;IACxD,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;CACtB,GAAG;KACD,CAAC,IAAI,CAAC,GAAG,OAAO;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,QAAQ,EAAE,OAAO,GAAG,GAAG,EAC9D,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,EACpB,SAAS,OAAO,EAChB,uBAAuB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,KAMvC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"url": "https://github.com/aymericzip"
|
|
36
36
|
}
|
|
37
37
|
],
|
|
38
|
+
"sideEffects": false,
|
|
38
39
|
"exports": {
|
|
39
40
|
".": {
|
|
40
41
|
"types": "./dist/types/index.d.ts",
|
|
@@ -59,9 +60,9 @@
|
|
|
59
60
|
],
|
|
60
61
|
"dependencies": {
|
|
61
62
|
"negotiator": "^1.0.0",
|
|
62
|
-
"@intlayer/
|
|
63
|
-
"@intlayer/config": "5.
|
|
64
|
-
"@intlayer/
|
|
63
|
+
"@intlayer/api": "5.3.1",
|
|
64
|
+
"@intlayer/config": "5.3.1",
|
|
65
|
+
"@intlayer/dictionaries-entry": "5.3.1"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@types/negotiator": "^0.6.3",
|
|
@@ -74,16 +75,16 @@
|
|
|
74
75
|
"tsc-alias": "^1.8.10",
|
|
75
76
|
"tsup": "^8.3.5",
|
|
76
77
|
"typescript": "^5.7.3",
|
|
77
|
-
"@utils/
|
|
78
|
+
"@utils/eslint-config": "1.0.4",
|
|
78
79
|
"@utils/ts-config": "1.0.4",
|
|
79
|
-
"@utils/
|
|
80
|
-
"@utils/
|
|
80
|
+
"@utils/ts-config-types": "1.0.4",
|
|
81
|
+
"@utils/tsup-config": "1.0.4"
|
|
81
82
|
},
|
|
82
83
|
"peerDependencies": {
|
|
83
|
-
"@intlayer/api": "5.
|
|
84
|
-
"@intlayer/config": "5.
|
|
85
|
-
"@intlayer/dictionaries-entry": "5.
|
|
86
|
-
"intlayer": "5.
|
|
84
|
+
"@intlayer/api": "5.3.1",
|
|
85
|
+
"@intlayer/config": "5.3.1",
|
|
86
|
+
"@intlayer/dictionaries-entry": "5.3.1",
|
|
87
|
+
"intlayer": "5.3.1"
|
|
87
88
|
},
|
|
88
89
|
"engines": {
|
|
89
90
|
"node": ">=14.18"
|