json-to-spec 20.1.0 → 21.1.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.
Files changed (194) hide show
  1. package/docs/dist/min.js +98 -303
  2. package/docs/dist/v17/min.js +355 -355
  3. package/docs/dist/v18/min.js +160 -160
  4. package/docs/dist/v19/min.js +164 -164
  5. package/docs/dist/v20/min.js +326 -321
  6. package/docs/dist/v21/min.js +116 -0
  7. package/package.json +2 -2
  8. package/samples/form/input/data.json +8 -8
  9. package/samples/form/input/structure.json +191 -191
  10. package/samples/form1/input/data.json +37 -37
  11. package/samples/form1/input/structure.json +277 -277
  12. package/samples/table/input/structure.json +13 -13
  13. package/samples/table1/input/structure.json +10 -10
  14. package/samples/table2/input/structure.json +18 -18
  15. package/samples/table3/input/structure.json +44 -44
  16. package/src/index.js +2 -2
  17. package/src/v20/walk/iterate/v4/createChildren.js +0 -1
  18. package/src/v20/walk/loopArray/v2/index.js +0 -2
  19. package/src/v20/walk/replaceWithArray/v1/replaceCommon.js +0 -1
  20. package/src/v20/walk/replaceWithArray/v1/replaceTextContent.js +0 -1
  21. package/src/v20/walk/replaceWithData/v2/index.js +0 -43
  22. package/src/v20/walk/replaceWithData/v2/replaceCommon.js +0 -1
  23. package/src/v20/walk/replaceWithData/v3/replaceCommon.js +0 -1
  24. package/src/v20/walk/replaceWithObject/v1/replaceCommon.js +0 -1
  25. package/src/v20/walk/walk.js +0 -4
  26. package/src/v21/buildSpec/buildChildrenNodes.js +24 -0
  27. package/src/v21/buildSpec/buildSingleElement.js +18 -0
  28. package/src/v21/buildSpec/buildSpecArray.js +16 -0
  29. package/src/v21/buildSpec/forArray/v1/index.js +22 -0
  30. package/src/v21/buildSpec/forObject/v1/index.js +22 -0
  31. package/src/v21/buildSpec/forSpec/v3/index.js +91 -0
  32. package/src/v21/buildSpec/forSpec.js +76 -0
  33. package/src/v21/buildSpec/guards.js +26 -0
  34. package/src/v21/buildSpec/index.js +53 -0
  35. package/src/v21/index.js +21 -0
  36. package/src/v21/meta.js +6 -0
  37. package/src/{v18 → v21}/registerGlobal.js +1 -1
  38. package/src/v10/index.js +0 -96
  39. package/src/v10/instructionEngine/compile/compileTree.js +0 -191
  40. package/src/v10/instructionEngine/compileTree.js +0 -1
  41. package/src/v10/instructionEngine/expandIteration.js +0 -1
  42. package/src/v10/instructionEngine/index.js +0 -29
  43. package/src/v10/instructionEngine/interpolate.js +0 -2
  44. package/src/v10/instructionEngine/iteration/expandIteration.js +0 -95
  45. package/src/v10/instructionEngine/operation/operation.js +0 -237
  46. package/src/v10/instructionEngine/other/other.js +0 -150
  47. package/src/v10/instructionEngine/pipeline/pipeline.js +0 -47
  48. package/src/v10/instructionEngine/replace/replace.js +0 -173
  49. package/src/v10/instructionEngine/resolve/resolvePath.js +0 -18
  50. package/src/v10/instructionEngine/resolve/resolveTokenValue.js +0 -22
  51. package/src/v10/instructionEngine/resolvePath.js +0 -1
  52. package/src/v10/instructionEngine/resolveTokenValue.js +0 -1
  53. package/src/v10/instructionEngine/story/storyInjector.js +0 -50
  54. package/src/v10/instructionEngine/storyInjector.js +0 -1
  55. package/src/v10/instructionEngine/value/interpolate.js +0 -38
  56. package/src/v11/index.js +0 -116
  57. package/src/v11/iterate.js +0 -270
  58. package/src/v11/replace.js +0 -169
  59. package/src/v11/resolvePath.js +0 -29
  60. package/src/v12/index.js +0 -122
  61. package/src/v12/iterate/bindFormValues.js +0 -74
  62. package/src/v12/iterate/expandIteration.js +0 -181
  63. package/src/v12/iterate/index.js +0 -10
  64. package/src/v12/iterate/iterate.js +0 -56
  65. package/src/v12/iterate/iterateNode.js +0 -86
  66. package/src/v12/iterate/resolveCollection.js +0 -37
  67. package/src/v12/iterate.js +0 -270
  68. package/src/v12/replace.js +0 -169
  69. package/src/v12/resolvePath.js +0 -29
  70. package/src/v13/index.js +0 -110
  71. package/src/v13/iterate/bindFormValues.js +0 -74
  72. package/src/v13/iterate/expandIteration.js +0 -188
  73. package/src/v13/iterate/index.js +0 -9
  74. package/src/v13/iterate/iterate.js +0 -32
  75. package/src/v13/iterate/iterateNode.js +0 -86
  76. package/src/v13/iterate/resolveCollection.js +0 -37
  77. package/src/v13/iterate/walk.js +0 -90
  78. package/src/v13/iterate.js +0 -270
  79. package/src/v13/replace.js +0 -169
  80. package/src/v13/resolvePath.js +0 -29
  81. package/src/v14/index.js +0 -112
  82. package/src/v14/iterate/bindFormValues.js +0 -74
  83. package/src/v14/iterate/expandIteration.js +0 -188
  84. package/src/v14/iterate/index.js +0 -9
  85. package/src/v14/iterate/iterate.js +0 -32
  86. package/src/v14/iterate/resolveCollection.js +0 -37
  87. package/src/v14/iterate/walk/walk copy 2.js +0 -114
  88. package/src/v14/iterate/walk/walk copy.js +0 -90
  89. package/src/v14/iterate/walk/walk.js +0 -98
  90. package/src/v14/iterate.js +0 -270
  91. package/src/v14/replace/index.js +0 -16
  92. package/src/v14/replace/walk.js +0 -90
  93. package/src/v14/replace.js +0 -153
  94. package/src/v14/resolvePath.js +0 -29
  95. package/src/v15/index.js +0 -123
  96. package/src/v15/iterate/bindFormValues.js +0 -74
  97. package/src/v15/iterate/expandIteration.js +0 -188
  98. package/src/v15/iterate/index.js +0 -9
  99. package/src/v15/iterate/iterate.js +0 -32
  100. package/src/v15/iterate/resolveCollection.js +0 -37
  101. package/src/v15/iterate/walk/walk copy 2.js +0 -114
  102. package/src/v15/iterate/walk/walk copy.js +0 -90
  103. package/src/v15/iterate/walk/walk.js +0 -195
  104. package/src/v15/iterate.js +0 -270
  105. package/src/v15/replace/index.js +0 -16
  106. package/src/v15/replace/walk.js +0 -90
  107. package/src/v15/replace.js +0 -155
  108. package/src/v15/resolvePath.js +0 -29
  109. package/src/v16/index.js +0 -129
  110. package/src/v16/iterate/bindFormValues.js +0 -74
  111. package/src/v16/iterate/expandIteration.js +0 -188
  112. package/src/v16/iterate/index.js +0 -9
  113. package/src/v16/iterate/iterate.js +0 -32
  114. package/src/v16/iterate/resolveCollection.js +0 -37
  115. package/src/v16/iterate/walk/walk copy 2.js +0 -114
  116. package/src/v16/iterate/walk/walk copy.js +0 -90
  117. package/src/v16/iterate/walk/walk.js +0 -196
  118. package/src/v16/iterate.js +0 -270
  119. package/src/v16/replace/index.js +0 -16
  120. package/src/v16/replace/walk.js +0 -90
  121. package/src/v16/replace.js +0 -155
  122. package/src/v16/resolvePath.js +0 -29
  123. package/src/v17/index.js +0 -119
  124. package/src/v17/iterate/bindFormValues.js +0 -74
  125. package/src/v17/iterate/expandIteration.js +0 -188
  126. package/src/v17/iterate/index.js +0 -9
  127. package/src/v17/iterate/iterate.js +0 -32
  128. package/src/v17/iterate/resolveCollection.js +0 -37
  129. package/src/v17/iterate/walk/iterateDo.js +0 -42
  130. package/src/v17/iterate/walk/replaceWithData.js +0 -60
  131. package/src/v17/iterate/walk/walk.js +0 -94
  132. package/src/v17/iterate.js +0 -270
  133. package/src/v17/replace/index.js +0 -16
  134. package/src/v17/replace/walk.js +0 -90
  135. package/src/v17/replace.js +0 -160
  136. package/src/v17/resolvePath.js +0 -29
  137. package/src/v18/index.js +0 -66
  138. package/src/v18/meta.js +0 -7
  139. package/src/v18/replace.js +0 -18
  140. package/src/v18/resolvePath.js +0 -29
  141. package/src/v18/walk/iterate/v1/index.js +0 -42
  142. package/src/v18/walk/iterate/v2/index.js +0 -32
  143. package/src/v18/walk/iterate/v3/index.js +0 -46
  144. package/src/v18/walk/iterate/v4/createChildren.js +0 -24
  145. package/src/v18/walk/iterate/v4/index.js +0 -25
  146. package/src/v18/walk/replaceWithData/v1/index.js +0 -42
  147. package/src/v18/walk/replaceWithData/v1/replaceCommon.js +0 -21
  148. package/src/v18/walk/replaceWithData/v2/index.js +0 -105
  149. package/src/v18/walk/replaceWithData/v2/replaceCommon.js +0 -21
  150. package/src/v18/walk/replaceWithData/v3/index.js +0 -15
  151. package/src/v18/walk/replaceWithData/v3/replaceAttributes.js +0 -29
  152. package/src/v18/walk/replaceWithData/v3/replaceCommon.js +0 -23
  153. package/src/v18/walk/replaceWithData/v3/replaceNodeValue.js +0 -27
  154. package/src/v18/walk/walk.js +0 -94
  155. package/src/v20/walk/iterate/v1/index.js +0 -42
  156. package/src/v20/walk/iterate/v2/index.js +0 -32
  157. package/src/v20/walk/loopArray/v1/createChildren.js +0 -42
  158. package/src/v20/walk/loopArray/v1/index.js +0 -33
  159. package/src/v20/walk/loopObject/v1/createChildren.js +0 -27
  160. package/src/v20/walk/loopObject/v1/index.js +0 -25
  161. package/src/v20/walk/replaceWithData/v1/index.js +0 -42
  162. package/src/v20/walk/replaceWithData/v1/replaceCommon.js +0 -21
  163. package/src/v8/index.js +0 -69
  164. package/src/v8/instructionEngine/compile/compileTree.js +0 -191
  165. package/src/v8/instructionEngine/compileTree.js +0 -1
  166. package/src/v8/instructionEngine/expandIteration.js +0 -1
  167. package/src/v8/instructionEngine/index.js +0 -16
  168. package/src/v8/instructionEngine/interpolate.js +0 -2
  169. package/src/v8/instructionEngine/iteration/expandIteration.js +0 -95
  170. package/src/v8/instructionEngine/resolve/resolvePath.js +0 -18
  171. package/src/v8/instructionEngine/resolve/resolveTokenValue.js +0 -22
  172. package/src/v8/instructionEngine/resolvePath.js +0 -1
  173. package/src/v8/instructionEngine/resolveTokenValue.js +0 -1
  174. package/src/v8/instructionEngine/story/storyInjector.js +0 -50
  175. package/src/v8/instructionEngine/storyInjector.js +0 -1
  176. package/src/v8/instructionEngine/value/interpolate.js +0 -38
  177. package/src/v9/index.js +0 -96
  178. package/src/v9/instructionEngine/compile/compileTree.js +0 -191
  179. package/src/v9/instructionEngine/compileTree.js +0 -1
  180. package/src/v9/instructionEngine/expandIteration.js +0 -1
  181. package/src/v9/instructionEngine/index.js +0 -29
  182. package/src/v9/instructionEngine/interpolate.js +0 -2
  183. package/src/v9/instructionEngine/iteration/expandIteration.js +0 -95
  184. package/src/v9/instructionEngine/operation/operation.js +0 -237
  185. package/src/v9/instructionEngine/other/other.js +0 -150
  186. package/src/v9/instructionEngine/pipeline/pipeline.js +0 -47
  187. package/src/v9/instructionEngine/replace/replace.js +0 -173
  188. package/src/v9/instructionEngine/resolve/resolvePath.js +0 -18
  189. package/src/v9/instructionEngine/resolve/resolveTokenValue.js +0 -22
  190. package/src/v9/instructionEngine/resolvePath.js +0 -1
  191. package/src/v9/instructionEngine/resolveTokenValue.js +0 -1
  192. package/src/v9/instructionEngine/story/storyInjector.js +0 -50
  193. package/src/v9/instructionEngine/storyInjector.js +0 -1
  194. package/src/v9/instructionEngine/value/interpolate.js +0 -38
package/docs/dist/min.js CHANGED
@@ -1,321 +1,116 @@
1
- const f = {
2
- version: "19.0.0",
3
- name: "json-to-spec/v19",
4
- description: "Minimalist 2-layer compiler: pure value replace + jsonToSpec iterate"
5
- }, b = (n) => {
6
- typeof globalThis > "u" || !n || (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks["json-to-spec"] = {
7
- meta: f,
8
- compile: n
1
+ const u = {
2
+ version: "v21.0",
3
+ description: "Pure spec engine no document at all"
4
+ }, i = (e) => {
5
+ typeof globalThis > "u" || !e || (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks["json-to-spec"] = {
6
+ meta: u,
7
+ buildSpecElement: e
9
8
  });
10
- }, d = ({ inData: n, inDataKey: r }) => {
11
- const t = r;
12
- if (t === "") return n;
13
- let e = n[t];
14
- return t.includes(".") && (e = t.split(".").reduce(
15
- (c, a) => c == null ? void 0 : c[a],
16
- n
17
- )), e;
18
- }, O = ({
19
- inNode: n,
20
- inData: r
21
- } = {}) => {
22
- const t = n, e = r;
23
- if (!(t != null && t.textContent)) return "no-textContent";
24
- if (typeof t.textContent != "string") return "not-a-string";
25
- if (!t.textContent.includes("${")) return "no-template-token";
26
- const o = t.textContent.replace(/^\$\{/, "").replace(/\}$/, "");
27
- t.textContent = d({
28
- inData: e,
29
- inDataKey: o
30
- });
31
- }, C = ({
32
- inNode: n,
33
- inData: r
34
- } = {}) => {
35
- const t = n, e = r;
36
- if ("attributes" in t) {
37
- const o = Object.fromEntries(
38
- Object.entries(t.attributes || {}).map(([s, c]) => [
39
- s,
40
- typeof c == "string" && c.includes("${") ? d({
41
- inData: e,
42
- inDataKey: c.replace(/^\$\{/, "").replace(/\}$/, "")
43
- }) : c
44
- ])
45
- );
46
- t.attributes = { ...o };
9
+ }, f = ({ inSpec: e }) => {
10
+ const t = e;
11
+ return t == null;
12
+ }, d = ({ inSpec: e }) => typeof Node < "u" && e instanceof Node, p = ({ inSpecJson: e }) => Array.isArray(e), y = ({ inArray: e = [], inShowLog: t = !1, inDataJson: o }) => {
13
+ const r = e, l = t, n = o;
14
+ return Array.isArray(r) ? r.map((c) => a({
15
+ inSpecJson: c,
16
+ inShowLog: l,
17
+ inDataJson: n
18
+ })).flat().filter(Boolean) : [];
19
+ }, s = (e, t) => typeof e != "string" ? e : e.replace(/\$\{([^}]+)\}/g, (o, r) => {
20
+ const l = r.trim().split(".");
21
+ let n = t;
22
+ for (const c of l) {
23
+ if (n == null)
24
+ return "";
25
+ n = n[c];
47
26
  }
48
- }, $ = ({
49
- inNode: n,
50
- inData: r
51
- } = {}) => {
52
- const t = n, e = r;
53
- O({ inNode: t, inData: e }), C({ inNode: t, inData: e });
54
- }, T = ({
55
- inTemplate: n,
56
- inSourceValues: r
57
- } = {}) => {
58
- const t = r;
59
- return t === void 0 ? void 0 : t.map((o) => {
60
- const s = structuredClone(n);
61
- return l({
62
- inNode: s,
63
- inData: o,
64
- inOperation: "replace"
27
+ return n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean" ? String(n ?? "") : n;
28
+ }), m = ({ inSpecJson: e, inData: t, inShowLog: o }) => ("key" in t && "value" in t ? "textContent" in e && (e.textContent = s(
29
+ e.textContent,
30
+ t
31
+ )) : ("textContent" in e && (e.textContent = s(
32
+ e.textContent,
33
+ t
34
+ )), "attributes" in e && (e.attributes = Object.fromEntries(
35
+ Object.entries(e.attributes).map(
36
+ ([r, l]) => [
37
+ r,
38
+ s(l, t)
39
+ ]
40
+ )
41
+ )), "children" in e && (e.children = e.children.map((r) => a({
42
+ inSpecJson: r,
43
+ inShowLog: o,
44
+ inDataJson: t
45
+ })))), e), b = ({ inTemplate: e, inDataAsArray: t }) => {
46
+ const o = t, r = e;
47
+ return o.map((n) => {
48
+ const c = structuredClone(r);
49
+ return a({
50
+ inSpecJson: c,
51
+ inDataJson: n
65
52
  });
66
53
  });
67
- }, k = ({
68
- inNode: n,
69
- inData: r,
70
- inShowLog: t
71
- } = {}) => {
72
- const e = n, o = r;
73
- if (!("jsonToSpec" in e) || !("operation" in e.jsonToSpec) || e.jsonToSpec.operation !== "iterate" || !("source" in e.jsonToSpec)) return;
74
- const s = o[e.jsonToSpec.source], c = T({
75
- inTemplate: e.jsonToSpec.template,
76
- inSourceValues: s
77
- });
78
- e.children = c;
79
- }, A = ({
80
- inNode: n,
81
- inData: r
82
- } = {}) => {
83
- const t = n;
84
- if (!(t != null && t.textContent)) return "no-textContent";
85
- if (typeof t.textContent != "string") return "not-a-string";
86
- if (!t.textContent.includes("${")) return "no-template-token";
87
- t.textContent === "${key}" && (t.textContent = r.key), t.textContent === "${value}" && (t.textContent = r.value);
88
- }, x = ({
89
- inNode: n,
90
- inData: r
91
- } = {}) => {
92
- const t = n;
93
- if ("attributes" in t) {
94
- const e = Object.fromEntries(
95
- Object.entries(t.attributes).map(([o, s]) => {
96
- let c = s;
97
- return s === "${key}" ? c = r.key : s === "${value}" && (c = r.value), [o, c];
98
- })
99
- );
100
- t.attributes = { ...e };
101
- }
102
- }, j = ({
103
- inNode: n,
104
- inData: r
105
- } = {}) => {
106
- const t = n, e = r;
107
- A({ inNode: t, inData: e }), x({ inNode: t, inData: e });
108
- };
109
- function m(n) {
110
- return n !== null && typeof n == "object" && Object.getPrototypeOf(n) === Object.prototype;
111
- }
112
- const h = ({
113
- inTemplate: n,
114
- inSourceValues: r,
115
- inShowLog: t
116
- } = {}) => {
117
- const e = r;
118
- if (e === void 0 || !m(e)) return;
119
- t && console.log("loopObject:createChildren:1 ", n, r);
54
+ }, h = ({ inTemplate: e, inDataAsObject: t }) => {
120
55
  let o = [];
121
- for (const [s, c] of Object.entries(e)) {
122
- const a = structuredClone(n);
123
- j({ inNode: a, inData: { key: s, value: c } }), o.push(a);
56
+ console.log("11111111--------loopObject : ", t);
57
+ for (const [r, l] of Object.entries(t)) {
58
+ const n = structuredClone(e), c = a({
59
+ inSpecJson: n,
60
+ inDataJson: { key: r, value: l }
61
+ });
62
+ o.push(c);
124
63
  }
125
64
  return o;
126
- }, D = ({
127
- inNode: n,
128
- inData: r,
129
- inShowLog: t
130
- } = {}) => {
131
- const e = n, o = r;
132
- if (t && console.log("loopObject:1 ", n, r), !("jsonToSpec" in e) || !("operation" in e.jsonToSpec) || e.jsonToSpec.operation !== "loopObject" || !("source" in e.jsonToSpec)) return;
133
- t && console.log("loopObject:2 ", n, r);
134
- const s = o[e.jsonToSpec.source], c = h({
135
- inTemplate: e.jsonToSpec.template,
136
- inSourceValues: s,
137
- inShowLog: t
138
- });
139
- e.children = c;
140
- };
141
- function S(n) {
142
- return n !== null && typeof n == "object" && Object.getPrototypeOf(n) === Object.prototype;
143
- }
144
- const g = ({
145
- inNode: n,
146
- inData: r
147
- } = {}) => {
148
- if (Object.keys(r).map((o) => `\${${o}}`).includes(n.textContent)) {
149
- const o = n.textContent.slice(2, -1);
150
- n.textContent = r[o];
151
- }
152
- }, F = ({
153
- inNode: n,
154
- inData: r
155
- } = {}) => {
156
- const t = n, e = r;
157
- if (console.log("localData------- : ", e), !(t != null && t.textContent)) return "no-textContent";
158
- if (typeof t.textContent != "string") return "not-a-string";
159
- if (!t.textContent.includes("${")) return "no-template-token";
160
- S(e) ? g({ inNode: n, inData: r }) : t.textContent === "${}" && (t.textContent = e);
161
- }, N = ({
162
- inNode: n,
163
- inData: r
164
- } = {}) => {
165
- const t = n;
166
- if ("attributes" in t) {
167
- const e = Object.fromEntries(
168
- Object.entries(t.attributes).map(([o, s]) => {
169
- let c = s;
170
- return s === "${}" && (c = r.key), [o, c];
171
- })
172
- );
173
- t.attributes = { ...e };
174
- }
175
- }, V = ({
176
- inNode: n,
177
- inData: r
178
- } = {}) => {
179
- const t = n, e = r;
180
- F({ inNode: t, inData: e }), N({ inNode: t, inData: e });
181
- }, w = ({
182
- inTemplate: n,
183
- inSourceValuesAsArray: r,
184
- inShowLog: t
185
- } = {}) => {
186
- const e = r;
187
- if (e === void 0 || !Array.isArray(e)) return;
188
- t && console.log("loopObject:createChildren:1 ", n, inSourceValues);
189
- let o = [];
190
- return e.forEach((s) => {
191
- var a, i;
192
- const c = structuredClone(n);
193
- if ("jsonToSpec" in c) {
194
- const y = (a = c == null ? void 0 : c.jsonToSpec) == null ? void 0 : a.source;
195
- let u = {};
196
- u[y] = s, l({
197
- inNode: c,
198
- inData: u,
199
- inOperation: (i = c == null ? void 0 : c.jsonToSpec) == null ? void 0 : i.operation,
200
- inShowLog: t
65
+ }, a = ({ inSpecJson: e, inShowLog: t = !1, inDataJson: o } = {}) => {
66
+ if (f({ inSpec: e })) return null;
67
+ if (d({ inSpec: e })) return e;
68
+ if (p({ inSpecJson: e }))
69
+ return y({
70
+ inArray: e,
71
+ inShowLog: t,
72
+ inDataJson: o
73
+ });
74
+ if ("jsonToSpec" in e) {
75
+ if ("isSpecBuilt" in e)
76
+ return e;
77
+ if (e.jsonToSpec.operation === "loopArray") {
78
+ const r = b({
79
+ inTemplate: e.jsonToSpec.template,
80
+ inDataAsArray: o[e.jsonToSpec.source]
201
81
  });
82
+ e.children = r;
202
83
  }
203
- V({ inNode: c, inData: s }), o.push(c);
204
- }), o;
205
- }, K = ({
206
- inNode: n,
207
- inData: r,
208
- inShowLog: t
209
- } = {}) => {
210
- const e = n, o = r;
211
- if (console.log("loopArray:1 ", n, r), t && console.log("loopObject:1 ", n, r), !("jsonToSpec" in e) || !("operation" in e.jsonToSpec) || e.jsonToSpec.operation !== "loopArray" || !("source" in e.jsonToSpec)) return;
212
- const s = o[e.jsonToSpec.source];
213
- if (!Array.isArray(s)) return;
214
- t && console.log("loopObject:2 ", n, r);
215
- const c = w({
216
- inTemplate: e.jsonToSpec.template,
217
- inSourceValuesAsArray: s,
218
- inShowLog: t
219
- });
220
- e.children = c;
221
- }, p = ({ inNode: n, inData: r, inOperation: t }) => {
222
- const e = n, o = r, s = t;
223
- if (Array.isArray(e)) {
224
- const c = [];
225
- for (const a of e) {
226
- const i = l({
227
- inNode: a,
228
- inData: o,
229
- inOperation: s
84
+ if (e.jsonToSpec.operation === "loopObject") {
85
+ const r = h({
86
+ inTemplate: e.jsonToSpec.template,
87
+ inDataAsObject: o
230
88
  });
231
- Array.isArray(i) ? c.push(...i) : i != null && c.push(i);
89
+ e.children = r;
232
90
  }
233
- return c;
91
+ e.isSpecBuilt = !0;
234
92
  }
235
- }, l = ({
236
- inNode: n,
237
- inData: r = {},
238
- inOperation: t,
239
- inShowLog: e = !1
240
- } = {}) => {
241
- const o = n, s = r, c = t;
242
- if (e && console.log("walk ", n, r, t), o == null)
243
- return o;
244
- if (Array.isArray(o))
245
- return p({
246
- inNode: o,
247
- inData: r,
248
- inOperation: c
249
- });
250
- if ("children" in o && Array.isArray(o == null ? void 0 : o.children) && (o.children = p({
251
- inNode: o == null ? void 0 : o.children,
252
- inData: r,
253
- inOperation: c
254
- })), typeof o != "object")
255
- return o;
256
- switch (e && console.log("localOperation ", c), c) {
257
- case "replace":
258
- typeof o == "object" && $({
259
- inNode: o,
260
- inData: r
261
- });
262
- break;
263
- case "replaceObject":
264
- typeof o == "object" && j({
265
- inNode: o,
266
- inData: r
267
- });
268
- break;
269
- case "iterateDo":
270
- k({
271
- inNode: o,
272
- inData: s,
273
- inShowLog: e
274
- });
275
- break;
276
- case "loopObject":
277
- D({
278
- inNode: o,
279
- inData: s,
280
- inShowLog: e
281
- });
282
- break;
283
- case "loopArray":
284
- K({
285
- inNode: o,
286
- inData: s,
287
- inShowLog: e
288
- });
289
- break;
290
- }
291
- return o;
292
- }, E = ({ inStructureAsJson: n, inDataAsJson: r, inOperation: t, inShowLog: e }) => {
293
- try {
294
- return l({
295
- inNode: n,
296
- inData: r,
297
- inOperation: t,
298
- inShowLog: e
299
- });
300
- } catch (o) {
301
- throw console.error("[json-to-spec/v17] replace error:", o), o;
302
- }
303
- }, P = (n, r = {}, t = !1) => {
304
- let e = n, o = r;
305
- t && console.log(f.name, e, o);
93
+ return m({
94
+ inSpecJson: e,
95
+ inShowLog: t,
96
+ inData: o
97
+ });
98
+ }, A = ({
99
+ specJson: e,
100
+ showLog: t,
101
+ dataJson: o
102
+ }) => {
306
103
  try {
307
- return E({
308
- inStructureAsJson: e,
309
- inDataAsJson: o,
310
- inOperation: "loopArray",
311
- inShowLog: t
104
+ return a({
105
+ inSpecJson: e,
106
+ inShowLog: t,
107
+ inDataJson: o
312
108
  });
313
- } catch (s) {
314
- throw console.error("[json-to-spec/v19] compile error:", s), s;
109
+ } catch (r) {
110
+ console.log("error : ", r);
315
111
  }
316
112
  };
317
- b(P);
113
+ i(A);
318
114
  export {
319
- P as compile,
320
- P as default
115
+ A as default
321
116
  };