@json-to-office/shared 0.7.0 → 0.8.0

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/index.d.ts CHANGED
@@ -18,4 +18,17 @@ interface ServicesConfig {
18
18
  highcharts?: HighchartsServiceConfig;
19
19
  }
20
20
 
21
- export type { HighchartsServiceConfig, ServicesConfig };
21
+ /**
22
+ * Deep Merge Utilities
23
+ * Generic deep-merge helpers used by both docx and pptx
24
+ * componentDefaults resolution systems.
25
+ */
26
+ /**
27
+ * Merge theme defaults with user-provided configuration.
28
+ * User config takes precedence over theme defaults.
29
+ * Uses deep merge to preserve nested objects.
30
+ * Arrays are replaced wholesale, not merged per-element.
31
+ */
32
+ declare function mergeWithDefaults<T>(userConfig: T, themeDefaults: Partial<T>): T;
33
+
34
+ export { type HighchartsServiceConfig, type ServicesConfig, mergeWithDefaults };
package/dist/index.js CHANGED
@@ -8,6 +8,12 @@ import {
8
8
  resolveComponentVersion,
9
9
  validateCustomComponentProps
10
10
  } from "./chunk-HS3W472G.js";
11
+ import {
12
+ compareSemver,
13
+ isValidSemver,
14
+ latestVersion,
15
+ parseSemver
16
+ } from "./chunk-244MHDOZ.js";
11
17
  import {
12
18
  convertToJsonSchema,
13
19
  createComponentSchema,
@@ -15,12 +21,6 @@ import {
15
21
  exportSchemaToFile,
16
22
  fixSchemaReferences
17
23
  } from "./chunk-5J43F4XD.js";
18
- import {
19
- compareSemver,
20
- isValidSemver,
21
- latestVersion,
22
- parseSemver
23
- } from "./chunk-244MHDOZ.js";
24
24
  import {
25
25
  DEFAULT_ERROR_CONFIG,
26
26
  ERROR_EMOJIS,
@@ -41,6 +41,31 @@ import {
41
41
  transformValueError,
42
42
  transformValueErrors
43
43
  } from "./chunk-ZKD5BAMU.js";
44
+
45
+ // src/utils/deepMerge.ts
46
+ function isObject(item) {
47
+ return item !== null && typeof item === "object" && !Array.isArray(item);
48
+ }
49
+ function deepMerge(target, source) {
50
+ const output = { ...target };
51
+ if (isObject(target) && isObject(source)) {
52
+ Object.keys(source).forEach((key) => {
53
+ if (isObject(source[key])) {
54
+ if (!(key in target)) {
55
+ output[key] = source[key];
56
+ } else {
57
+ output[key] = deepMerge(target[key], source[key]);
58
+ }
59
+ } else {
60
+ output[key] = source[key];
61
+ }
62
+ });
63
+ }
64
+ return output;
65
+ }
66
+ function mergeWithDefaults(userConfig, themeDefaults) {
67
+ return deepMerge(themeDefaults, userConfig);
68
+ }
44
69
  export {
45
70
  ComponentValidationError,
46
71
  DEFAULT_ERROR_CONFIG,
@@ -72,6 +97,7 @@ export {
72
97
  isValidSemver,
73
98
  isValidationSuccess,
74
99
  latestVersion,
100
+ mergeWithDefaults,
75
101
  parseSemver,
76
102
  resolveComponentVersion,
77
103
  transformValueError,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/utils/deepMerge.ts"],"sourcesContent":["/**\n * Deep Merge Utilities\n * Generic deep-merge helpers used by both docx and pptx\n * componentDefaults resolution systems.\n */\n\nfunction isObject(item: any): boolean {\n return item !== null && typeof item === 'object' && !Array.isArray(item);\n}\n\nfunction deepMerge<T>(target: any, source: any): T {\n const output = { ...target };\n\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach((key) => {\n if (isObject(source[key])) {\n if (!(key in target)) {\n output[key] = source[key];\n } else {\n output[key] = deepMerge(target[key], source[key]);\n }\n } else {\n output[key] = source[key];\n }\n });\n }\n\n return output as T;\n}\n\n/**\n * Merge theme defaults with user-provided configuration.\n * User config takes precedence over theme defaults.\n * Uses deep merge to preserve nested objects.\n * Arrays are replaced wholesale, not merged per-element.\n */\nexport function mergeWithDefaults<T>(\n userConfig: T,\n themeDefaults: Partial<T>\n): T {\n return deepMerge<T>(themeDefaults, userConfig);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,SAAS,MAAoB;AACpC,SAAO,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI;AACzE;AAEA,SAAS,UAAa,QAAa,QAAgB;AACjD,QAAM,SAAS,EAAE,GAAG,OAAO;AAE3B,MAAI,SAAS,MAAM,KAAK,SAAS,MAAM,GAAG;AACxC,WAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,QAAQ;AACnC,UAAI,SAAS,OAAO,GAAG,CAAC,GAAG;AACzB,YAAI,EAAE,OAAO,SAAS;AACpB,iBAAO,GAAG,IAAI,OAAO,GAAG;AAAA,QAC1B,OAAO;AACL,iBAAO,GAAG,IAAI,UAAU,OAAO,GAAG,GAAG,OAAO,GAAG,CAAC;AAAA,QAClD;AAAA,MACF,OAAO;AACL,eAAO,GAAG,IAAI,OAAO,GAAG;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAQO,SAAS,kBACd,YACA,eACG;AACH,SAAO,UAAa,eAAe,UAAU;AAC/C;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-to-office/shared",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Format-agnostic shared types, schemas and validation utilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",