@intlayer/core 5.3.7 → 5.3.8

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.
@@ -59,13 +59,17 @@ const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
59
59
  }
60
60
  currentValue = currentValue[keyObj.type][keyObj.key];
61
61
  }
62
- if (keyObj.type === import_types.NodeType.Markdown || keyObj.type === import_types.NodeType.Insertion || keyObj.type === import_types.NodeType.File) {
62
+ if (keyObj.type === import_types.NodeType.Markdown || keyObj.type === import_types.NodeType.Insertion) {
63
63
  lastKeys = [keyObj.type];
64
64
  if (!currentValue[keyObj.type] || typeof currentValue[keyObj.type] !== "object") {
65
65
  currentValue[keyObj.type] = "";
66
66
  }
67
67
  currentValue = currentValue[keyObj.type];
68
68
  }
69
+ if (keyObj.type === import_types.NodeType.File) {
70
+ lastKeys = ["content"];
71
+ currentValue = currentValue["content"];
72
+ }
69
73
  if (keyObj.type) {
70
74
  currentValue = currentValue;
71
75
  }
@@ -81,6 +85,11 @@ const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
81
85
  }
82
86
  }
83
87
  }
88
+ console.log({
89
+ dictionaryContent,
90
+ keyPath,
91
+ newValue
92
+ });
84
93
  return dictionaryContent;
85
94
  };
86
95
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKeys = [keyObj.type];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type) {\n // No treated TypedNode\n\n currentValue = currentValue;\n }\n\n // Only update the value when processing the last key in the keyPath.\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n // Drill down if lastKeys contains more than one key.\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n if (typeof newValue === 'undefined') {\n delete target[lastKeys[lastKeys.length - 1]];\n } else {\n target[lastKeys[lastKeys.length - 1]] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AAKhC,MAAM,0BAA0B,CACrC,mBACA,SACA,aACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,WAA0B,CAAC;AAE/B,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,SAAS,QAAQ,CAAC;AACxB,kBAAc;AAEd,QAAI,OAAO,SAAS,sBAAS,UAAU,OAAO,SAAS,sBAAS,OAAO;AACrE,iBAAW,CAAC,OAAO,GAAG;AACtB,UACE,CAAC,aAAa,OAAO,GAAG,KACxB,OAAO,aAAa,OAAO,GAAG,MAAM,UACpC;AACA,qBAAa,OAAO,GAAG,IAAI,CAAC;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC;AAEA,QACE,OAAO,SAAS,sBAAS,eACzB,OAAO,SAAS,sBAAS,aACzB;AACA,iBAAW,CAAC,OAAO,MAAM,OAAO,GAAG;AACnC,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI,CAAC;AAAA,MAC/B;AACA,UACE,CAAC,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,KACrC,OAAO,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,MAAM,UACjD;AACA,qBAAa,OAAO,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;AAAA,MAC3C;AACA,qBAAe,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG;AAAA,IACrD;AAEA,QACE,OAAO,SAAS,sBAAS,eACzB,OAAO,SAAS,sBAAS,WACzB;AACA,iBAAW,CAAC,OAAO,MAAM,OAAO,GAAG;AACnC,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI,CAAC;AAAA,MAC/B;AACA,UACE,CAAC,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,KACrC,OAAO,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,MAAM,UACjD;AACA,qBAAa,OAAO,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;AAAA,MAC3C;AACA,qBAAe,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG;AAAA,IACrD;AAEA,QACE,OAAO,SAAS,sBAAS,YACzB,OAAO,SAAS,sBAAS,aACzB,OAAO,SAAS,sBAAS,MACzB;AACA,iBAAW,CAAC,OAAO,IAAI;AACvB,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,IAAI;AAAA,IACzC;AAEA,QAAI,OAAO,MAAM;AAGf,qBAAe;AAAA,IACjB;AAGA,QAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,SAAS,GAAG;AAClE,UAAI,SAAS;AAEb,iBAAW,OAAO,SAAS,MAAM,GAAG,EAAE,GAAG;AACvC,iBAAS,OAAO,GAAG;AAAA,MACrB;AACA,UAAI,OAAO,aAAa,aAAa;AACnC,eAAO,OAAO,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,MAC7C,OAAO;AACL,eAAO,SAAS,SAAS,SAAS,CAAC,CAAC,IAAI;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion\n ) {\n lastKeys = [keyObj.type];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type === NodeType.File) {\n lastKeys = ['content'];\n\n currentValue = currentValue['content'];\n }\n\n if (keyObj.type) {\n // No treated TypedNode\n\n currentValue = currentValue;\n }\n\n // Only update the value when processing the last key in the keyPath.\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n // Drill down if lastKeys contains more than one key.\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n if (typeof newValue === 'undefined') {\n delete target[lastKeys[lastKeys.length - 1]];\n } else {\n target[lastKeys[lastKeys.length - 1]] = newValue;\n }\n }\n }\n\n console.log({\n dictionaryContent,\n keyPath,\n newValue,\n });\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AAKhC,MAAM,0BAA0B,CACrC,mBACA,SACA,aACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,WAA0B,CAAC;AAE/B,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,SAAS,QAAQ,CAAC;AACxB,kBAAc;AAEd,QAAI,OAAO,SAAS,sBAAS,UAAU,OAAO,SAAS,sBAAS,OAAO;AACrE,iBAAW,CAAC,OAAO,GAAG;AACtB,UACE,CAAC,aAAa,OAAO,GAAG,KACxB,OAAO,aAAa,OAAO,GAAG,MAAM,UACpC;AACA,qBAAa,OAAO,GAAG,IAAI,CAAC;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC;AAEA,QACE,OAAO,SAAS,sBAAS,eACzB,OAAO,SAAS,sBAAS,aACzB;AACA,iBAAW,CAAC,OAAO,MAAM,OAAO,GAAG;AACnC,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI,CAAC;AAAA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AAG,EAAE,GAAG;AACvC,iBAAS,OAAO,GAAG;AAAA,MACrB;AACA,UAAI,OAAO,aAAa,aAAa;AACnC,eAAO,OAAO,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,MAC7C,OAAO;AACL,eAAO,SAAS,SAAS,SAAS,CAAC,CAAC,IAAI;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,IAAI;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -17,9 +17,11 @@ var getContent_exports = {};
17
17
  module.exports = __toCommonJS(getContent_exports);
18
18
  __reExport(getContent_exports, require('./deepTransform.cjs'), module.exports);
19
19
  __reExport(getContent_exports, require('./plugins.cjs'), module.exports);
20
+ __reExport(getContent_exports, require('./getContent.cjs'), module.exports);
20
21
  // Annotate the CommonJS export names for ESM import in node:
21
22
  0 && (module.exports = {
22
23
  ...require('./deepTransform.cjs'),
23
- ...require('./plugins.cjs')
24
+ ...require('./plugins.cjs'),
25
+ ...require('./getContent.cjs')
24
26
  });
25
27
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from './deepTransform';\nexport * from './plugins';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,4BAAd;AACA,+BAAc,sBADd;","names":[]}
1
+ {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from './deepTransform';\nexport * from './plugins';\nexport * from './getContent';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,4BAAd;AACA,+BAAc,sBADd;AAEA,+BAAc,yBAFd;","names":[]}
@@ -23,6 +23,7 @@ __reExport(interpreter_exports, require('./getDictionary.cjs'), module.exports);
23
23
  __reExport(interpreter_exports, require('./getIntlayerAsync.cjs'), module.exports);
24
24
  __reExport(interpreter_exports, require('./getTranslation.cjs'), module.exports);
25
25
  __reExport(interpreter_exports, require('./getCondition.cjs'), module.exports);
26
+ __reExport(interpreter_exports, require('./getContent/index.cjs'), module.exports);
26
27
  // Annotate the CommonJS export names for ESM import in node:
27
28
  0 && (module.exports = {
28
29
  ...require('./getContent/index.cjs'),
@@ -32,6 +33,7 @@ __reExport(interpreter_exports, require('./getCondition.cjs'), module.exports);
32
33
  ...require('./getDictionary.cjs'),
33
34
  ...require('./getIntlayerAsync.cjs'),
34
35
  ...require('./getTranslation.cjs'),
35
- ...require('./getCondition.cjs')
36
+ ...require('./getCondition.cjs'),
37
+ ...require('./getContent/index.cjs')
36
38
  });
37
39
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,+BAAd;AACA,gCAAc,yBADd;AAEA,gCAAc,6BAFd;AAGA,gCAAc,0BAHd;AAIA,gCAAc,4BAJd;AAKA,gCAAc,+BALd;AAMA,gCAAc,6BANd;AAOA,gCAAc,2BAPd;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\nexport * from './getContent/index';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,+BAAd;AACA,gCAAc,yBADd;AAEA,gCAAc,6BAFd;AAGA,gCAAc,0BAHd;AAIA,gCAAc,4BAJd;AAKA,gCAAc,+BALd;AAMA,gCAAc,6BANd;AAOA,gCAAc,2BAPd;AAQA,gCAAc,+BARd;","names":[]}
@@ -36,13 +36,17 @@ const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
36
36
  }
37
37
  currentValue = currentValue[keyObj.type][keyObj.key];
38
38
  }
39
- if (keyObj.type === NodeType.Markdown || keyObj.type === NodeType.Insertion || keyObj.type === NodeType.File) {
39
+ if (keyObj.type === NodeType.Markdown || keyObj.type === NodeType.Insertion) {
40
40
  lastKeys = [keyObj.type];
41
41
  if (!currentValue[keyObj.type] || typeof currentValue[keyObj.type] !== "object") {
42
42
  currentValue[keyObj.type] = "";
43
43
  }
44
44
  currentValue = currentValue[keyObj.type];
45
45
  }
46
+ if (keyObj.type === NodeType.File) {
47
+ lastKeys = ["content"];
48
+ currentValue = currentValue["content"];
49
+ }
46
50
  if (keyObj.type) {
47
51
  currentValue = currentValue;
48
52
  }
@@ -58,6 +62,11 @@ const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
58
62
  }
59
63
  }
60
64
  }
65
+ console.log({
66
+ dictionaryContent,
67
+ keyPath,
68
+ newValue
69
+ });
61
70
  return dictionaryContent;
62
71
  };
63
72
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKeys = [keyObj.type];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type) {\n // No treated TypedNode\n\n currentValue = currentValue;\n }\n\n // Only update the value when processing the last key in the keyPath.\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n // Drill down if lastKeys contains more than one key.\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n if (typeof newValue === 'undefined') {\n delete target[lastKeys[lastKeys.length - 1]];\n } else {\n target[lastKeys[lastKeys.length - 1]] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAKhC,MAAM,0BAA0B,CACrC,mBACA,SACA,aAC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AO,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,MAAM,UACjD;AACA,qBAAa,OAAO,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;AAAA,MAC3C;AACA,qBAAe,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG;AAAA,IACrD;AAEA,QACE,OAAO,SAAS,SAAS,YACzB,OAAO,SAAS,SAAS,aACzB,OAAO,SAAS,SAAS,MACzB;AACA,iBAAW,CAAC,OAAO,IAAI;AACvB,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,IAAI;AAAA,IACzC;AAEA,QAAI,OAAO,MAAM;AAGf,qBAAe;AAAA,IACjB;AAGA,QAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,SAAS,GAAG;AAClE,UAAI,SAAS;AAEb,iBAAW,OAAO,SAAS,MAAM,GAAG,EAAE,GAAG;AACvC,iBAAS,OAAO,GAAG;AAAA,MACrB;AACA,UAAI,OAAO,aAAa,aAAa;AACnC,eAAO,OAAO,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,MAC7C,OAAO;AACL,eAAO,SAAS,SAAS,SAAS,CAAC,CAAC,IAAI;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion\n ) {\n lastKeys = [keyObj.type];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type === NodeType.File) {\n lastKeys = ['content'];\n\n currentValue = currentValue['content'];\n }\n\n if (keyObj.type) {\n // No treated TypedNode\n\n currentValue = currentValue;\n }\n\n // Only update the value when processing the last key in the keyPath.\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n // Drill down if lastKeys contains more than one key.\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n if (typeof newValue === 'undefined') {\n delete target[lastKeys[lastKeys.length - 1]];\n } else {\n target[lastKeys[lastKeys.length - 1]] = newValue;\n }\n }\n }\n\n console.log({\n dictionaryContent,\n keyPath,\n newValue,\n });\n\n return dictionaryContent;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAKhC,MAAM,0BAA0B,CACrC,mBACA,SACA,aACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,WAA0B,CAAC;AAE/B,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,SAAS,QAAQ,CAAC;AACxB,kBAAc;AAEd,QAAI,OAAO,SAAS,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO;AACrE,iBAAW,CAAC,OAAO,GAAG;AACtB,UACE,CAAC,aAAa,OAAO,GAAG,KACxB,OAAO,aAAa,OAAO,GAAG,MAAM,UACpC;AACA,qBAAa,OAAO,GAAG,IAAI,CAAC;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC;AAEA,QACE,OAAO,SAAS,SAAS,eACzB,OAAO,SAAS,SAAS,aACzB;AACA,iBAAW,CAAC,OAAO,MAAM,OAAO,GAAG;AACnC,UACE,CAAC,aAAa,OAAO,IAAI,KACzB,OAAO,aAAa,OAAO,IAAI,MAAM,UACrC;AACA,qBAAa,OAAO,IAAI,IAAI,CAAC;AAAA,MAC/B;AACA,UACE,CAAC,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,KACrC,OAAO,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG,MAAM,UACjD;AACA,qBAAa,OAAO,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;AAAA,MAC3C;AACA,qBAAe,aAAa,OAAO,IAAI,EAAE,OAAO,GAAG;AAAA,IACrD;AAEA,QACE,OAAO,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A;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -1,3 +1,4 @@
1
1
  export * from "./deepTransform.mjs";
2
2
  export * from "./plugins.mjs";
3
+ export * from "./getContent.mjs";
3
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from './deepTransform';\nexport * from './plugins';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from './deepTransform';\nexport * from './plugins';\nexport * from './getContent';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -6,4 +6,5 @@ export * from "./getDictionary.mjs";
6
6
  export * from "./getIntlayerAsync.mjs";
7
7
  export * from "./getTranslation.mjs";
8
8
  export * from "./getCondition.mjs";
9
+ export * from "./getContent/index.mjs";
9
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\nexport * from './getContent/index';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"editDictionaryByKeyPath.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,uBAAuB,GAClC,mBAAmB,WAAW,EAC9B,SAAS,OAAO,EAAE,EAClB,UAAU,WAAW,KACpB,WAqGF,CAAC"}
1
+ {"version":3,"file":"editDictionaryByKeyPath.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,uBAAuB,GAClC,mBAAmB,WAAW,EAC9B,SAAS,OAAO,EAAE,EAClB,UAAU,WAAW,KACpB,WAgHF,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './deepTransform';
2
2
  export * from './plugins';
3
+ export * from './getContent';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
@@ -6,4 +6,5 @@ export * from './getDictionary';
6
6
  export * from './getIntlayerAsync';
7
7
  export * from './getTranslation';
8
8
  export * from './getCondition';
9
+ export * from './getContent/index';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interpreter/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interpreter/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "5.3.7",
3
+ "version": "5.3.8",
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/api": "5.3.7",
75
- "@intlayer/config": "5.3.7",
76
- "@intlayer/dictionaries-entry": "5.3.7"
74
+ "@intlayer/config": "5.3.8",
75
+ "@intlayer/dictionaries-entry": "5.3.8",
76
+ "@intlayer/api": "5.3.8"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@types/negotiator": "^0.6.3",
@@ -86,16 +86,16 @@
86
86
  "tsc-alias": "^1.8.10",
87
87
  "tsup": "^8.3.5",
88
88
  "typescript": "^5.7.3",
89
- "@utils/eslint-config": "1.0.4",
90
89
  "@utils/ts-config": "1.0.4",
91
90
  "@utils/ts-config-types": "1.0.4",
92
- "@utils/tsup-config": "1.0.4"
91
+ "@utils/tsup-config": "1.0.4",
92
+ "@utils/eslint-config": "1.0.4"
93
93
  },
94
94
  "peerDependencies": {
95
- "@intlayer/api": "5.3.7",
96
- "@intlayer/config": "5.3.7",
97
- "@intlayer/dictionaries-entry": "5.3.7",
98
- "intlayer": "5.3.7"
95
+ "@intlayer/config": "5.3.8",
96
+ "@intlayer/dictionaries-entry": "5.3.8",
97
+ "@intlayer/api": "5.3.8",
98
+ "intlayer": "5.3.8"
99
99
  },
100
100
  "engines": {
101
101
  "node": ">=14.18"