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