json-to-spec 19.1.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.
Files changed (217) hide show
  1. package/README.md +118 -0
  2. package/docs/demo.html +426 -0
  3. package/docs/dist/min.js +164 -0
  4. package/docs/dist/v1/min.js +124 -0
  5. package/docs/dist/v17/min.js +355 -0
  6. package/docs/dist/v18/min.js +160 -0
  7. package/docs/dist/v19/min.js +164 -0
  8. package/docs/dist/v2/min.js +129 -0
  9. package/docs/dist/v3/min.js +201 -0
  10. package/docs/index.html +248 -0
  11. package/docs/pages/architecture.html +115 -0
  12. package/docs/pages/how-it-works.html +125 -0
  13. package/docs/pages/what-not.html +100 -0
  14. package/docs/pages/what.html +105 -0
  15. package/docs/pages/why.html +88 -0
  16. package/docs/samples/form.html +265 -0
  17. package/docs/samples/index.html +112 -0
  18. package/docs/samples/table.html +306 -0
  19. package/index.js +2 -0
  20. package/package.json +50 -0
  21. package/samples/dataList/index.html +31 -0
  22. package/samples/dataList/index.js +62 -0
  23. package/samples/dataList/input/data.json +5043 -0
  24. package/samples/dataList/input/structure.json +38 -0
  25. package/samples/dataList copy/index.html +30 -0
  26. package/samples/dataList copy/index.js +61 -0
  27. package/samples/dataList copy/input/data.json +35307 -0
  28. package/samples/dataList copy/input/structure.json +18 -0
  29. package/samples/form/index.html +29 -0
  30. package/samples/form/index.js +64 -0
  31. package/samples/form/input/data.json +9 -0
  32. package/samples/form/input/structure.json +192 -0
  33. package/samples/form-/data.json +42 -0
  34. package/samples/form-/structure.json +110 -0
  35. package/samples/select/index.html +31 -0
  36. package/samples/select/index.js +61 -0
  37. package/samples/select/input/data.json +35287 -0
  38. package/samples/select/input/select.json +18 -0
  39. package/samples/select/input/structure.json +47 -0
  40. package/samples/table/index.html +29 -0
  41. package/samples/table/index.js +61 -0
  42. package/samples/table/input/data.json +35287 -0
  43. package/samples/table/input/structure copy.json +47 -0
  44. package/samples/table/input/structure.json +86 -0
  45. package/samples/table/input/table.json +135 -0
  46. package/samples/table-/data.json +68 -0
  47. package/samples/table-/structure.json +235 -0
  48. package/src/index.js +2 -0
  49. package/src/v10/index.js +96 -0
  50. package/src/v10/instructionEngine/compile/compileTree.js +191 -0
  51. package/src/v10/instructionEngine/compileTree.js +1 -0
  52. package/src/v10/instructionEngine/expandIteration.js +1 -0
  53. package/src/v10/instructionEngine/index.js +29 -0
  54. package/src/v10/instructionEngine/interpolate.js +2 -0
  55. package/src/v10/instructionEngine/iteration/expandIteration.js +95 -0
  56. package/src/v10/instructionEngine/operation/operation.js +237 -0
  57. package/src/v10/instructionEngine/other/other.js +150 -0
  58. package/src/v10/instructionEngine/pipeline/pipeline.js +47 -0
  59. package/src/v10/instructionEngine/replace/replace.js +173 -0
  60. package/src/v10/instructionEngine/resolve/resolvePath.js +18 -0
  61. package/src/v10/instructionEngine/resolve/resolveTokenValue.js +22 -0
  62. package/src/v10/instructionEngine/resolvePath.js +1 -0
  63. package/src/v10/instructionEngine/resolveTokenValue.js +1 -0
  64. package/src/v10/instructionEngine/story/storyInjector.js +50 -0
  65. package/src/v10/instructionEngine/storyInjector.js +1 -0
  66. package/src/v10/instructionEngine/value/interpolate.js +38 -0
  67. package/src/v11/index.js +116 -0
  68. package/src/v11/iterate.js +270 -0
  69. package/src/v11/replace.js +169 -0
  70. package/src/v11/resolvePath.js +29 -0
  71. package/src/v12/index.js +122 -0
  72. package/src/v12/iterate/bindFormValues.js +74 -0
  73. package/src/v12/iterate/expandIteration.js +181 -0
  74. package/src/v12/iterate/index.js +10 -0
  75. package/src/v12/iterate/iterate.js +56 -0
  76. package/src/v12/iterate/iterateNode.js +86 -0
  77. package/src/v12/iterate/resolveCollection.js +37 -0
  78. package/src/v12/iterate.js +270 -0
  79. package/src/v12/replace.js +169 -0
  80. package/src/v12/resolvePath.js +29 -0
  81. package/src/v13/index.js +110 -0
  82. package/src/v13/iterate/bindFormValues.js +74 -0
  83. package/src/v13/iterate/expandIteration.js +188 -0
  84. package/src/v13/iterate/index.js +9 -0
  85. package/src/v13/iterate/iterate.js +32 -0
  86. package/src/v13/iterate/iterateNode.js +86 -0
  87. package/src/v13/iterate/resolveCollection.js +37 -0
  88. package/src/v13/iterate/walk.js +90 -0
  89. package/src/v13/iterate.js +270 -0
  90. package/src/v13/replace.js +169 -0
  91. package/src/v13/resolvePath.js +29 -0
  92. package/src/v14/index.js +112 -0
  93. package/src/v14/iterate/bindFormValues.js +74 -0
  94. package/src/v14/iterate/expandIteration.js +188 -0
  95. package/src/v14/iterate/index.js +9 -0
  96. package/src/v14/iterate/iterate.js +32 -0
  97. package/src/v14/iterate/resolveCollection.js +37 -0
  98. package/src/v14/iterate/walk/walk copy 2.js +114 -0
  99. package/src/v14/iterate/walk/walk copy.js +90 -0
  100. package/src/v14/iterate/walk/walk.js +98 -0
  101. package/src/v14/iterate.js +270 -0
  102. package/src/v14/replace/index.js +16 -0
  103. package/src/v14/replace/walk.js +90 -0
  104. package/src/v14/replace.js +153 -0
  105. package/src/v14/resolvePath.js +29 -0
  106. package/src/v15/index.js +123 -0
  107. package/src/v15/iterate/bindFormValues.js +74 -0
  108. package/src/v15/iterate/expandIteration.js +188 -0
  109. package/src/v15/iterate/index.js +9 -0
  110. package/src/v15/iterate/iterate.js +32 -0
  111. package/src/v15/iterate/resolveCollection.js +37 -0
  112. package/src/v15/iterate/walk/walk copy 2.js +114 -0
  113. package/src/v15/iterate/walk/walk copy.js +90 -0
  114. package/src/v15/iterate/walk/walk.js +195 -0
  115. package/src/v15/iterate.js +270 -0
  116. package/src/v15/replace/index.js +16 -0
  117. package/src/v15/replace/walk.js +90 -0
  118. package/src/v15/replace.js +155 -0
  119. package/src/v15/resolvePath.js +29 -0
  120. package/src/v16/index.js +129 -0
  121. package/src/v16/iterate/bindFormValues.js +74 -0
  122. package/src/v16/iterate/expandIteration.js +188 -0
  123. package/src/v16/iterate/index.js +9 -0
  124. package/src/v16/iterate/iterate.js +32 -0
  125. package/src/v16/iterate/resolveCollection.js +37 -0
  126. package/src/v16/iterate/walk/walk copy 2.js +114 -0
  127. package/src/v16/iterate/walk/walk copy.js +90 -0
  128. package/src/v16/iterate/walk/walk.js +196 -0
  129. package/src/v16/iterate.js +270 -0
  130. package/src/v16/replace/index.js +16 -0
  131. package/src/v16/replace/walk.js +90 -0
  132. package/src/v16/replace.js +155 -0
  133. package/src/v16/resolvePath.js +29 -0
  134. package/src/v17/index.js +119 -0
  135. package/src/v17/iterate/bindFormValues.js +74 -0
  136. package/src/v17/iterate/expandIteration.js +188 -0
  137. package/src/v17/iterate/index.js +9 -0
  138. package/src/v17/iterate/iterate.js +32 -0
  139. package/src/v17/iterate/resolveCollection.js +37 -0
  140. package/src/v17/iterate/walk/iterateDo.js +42 -0
  141. package/src/v17/iterate/walk/replaceWithData.js +60 -0
  142. package/src/v17/iterate/walk/walk.js +94 -0
  143. package/src/v17/iterate.js +270 -0
  144. package/src/v17/replace/index.js +16 -0
  145. package/src/v17/replace/walk.js +90 -0
  146. package/src/v17/replace.js +160 -0
  147. package/src/v17/resolvePath.js +29 -0
  148. package/src/v18/index.js +66 -0
  149. package/src/v18/meta.js +7 -0
  150. package/src/v18/registerGlobal.js +17 -0
  151. package/src/v18/replace.js +18 -0
  152. package/src/v18/resolvePath.js +29 -0
  153. package/src/v18/walk/iterate/v1/index.js +42 -0
  154. package/src/v18/walk/iterate/v2/index.js +32 -0
  155. package/src/v18/walk/iterate/v3/index.js +46 -0
  156. package/src/v18/walk/iterate/v4/createChildren.js +24 -0
  157. package/src/v18/walk/iterate/v4/index.js +25 -0
  158. package/src/v18/walk/replaceWithData/v1/index.js +42 -0
  159. package/src/v18/walk/replaceWithData/v1/replaceCommon.js +21 -0
  160. package/src/v18/walk/replaceWithData/v2/index.js +105 -0
  161. package/src/v18/walk/replaceWithData/v2/replaceCommon.js +21 -0
  162. package/src/v18/walk/replaceWithData/v3/index.js +15 -0
  163. package/src/v18/walk/replaceWithData/v3/replaceAttributes.js +29 -0
  164. package/src/v18/walk/replaceWithData/v3/replaceCommon.js +23 -0
  165. package/src/v18/walk/replaceWithData/v3/replaceNodeValue.js +27 -0
  166. package/src/v18/walk/walk.js +94 -0
  167. package/src/v19/index.js +55 -0
  168. package/src/v19/meta.js +7 -0
  169. package/src/v19/registerGlobal.js +17 -0
  170. package/src/v19/replace.js +18 -0
  171. package/src/v19/resolvePath.js +29 -0
  172. package/src/v19/walk/iterate/v1/index.js +42 -0
  173. package/src/v19/walk/iterate/v2/index.js +32 -0
  174. package/src/v19/walk/iterate/v3/index.js +46 -0
  175. package/src/v19/walk/iterate/v4/createChildren.js +27 -0
  176. package/src/v19/walk/iterate/v4/index.js +25 -0
  177. package/src/v19/walk/replaceWithData/v1/index.js +42 -0
  178. package/src/v19/walk/replaceWithData/v1/replaceCommon.js +21 -0
  179. package/src/v19/walk/replaceWithData/v2/index.js +105 -0
  180. package/src/v19/walk/replaceWithData/v2/replaceCommon.js +21 -0
  181. package/src/v19/walk/replaceWithData/v3/index.js +15 -0
  182. package/src/v19/walk/replaceWithData/v3/replaceAttributes.js +29 -0
  183. package/src/v19/walk/replaceWithData/v3/replaceCommon.js +23 -0
  184. package/src/v19/walk/replaceWithData/v3/replaceNodeValue.js +27 -0
  185. package/src/v19/walk/walk.js +97 -0
  186. package/src/v8/index.js +69 -0
  187. package/src/v8/instructionEngine/compile/compileTree.js +191 -0
  188. package/src/v8/instructionEngine/compileTree.js +1 -0
  189. package/src/v8/instructionEngine/expandIteration.js +1 -0
  190. package/src/v8/instructionEngine/index.js +16 -0
  191. package/src/v8/instructionEngine/interpolate.js +2 -0
  192. package/src/v8/instructionEngine/iteration/expandIteration.js +95 -0
  193. package/src/v8/instructionEngine/resolve/resolvePath.js +18 -0
  194. package/src/v8/instructionEngine/resolve/resolveTokenValue.js +22 -0
  195. package/src/v8/instructionEngine/resolvePath.js +1 -0
  196. package/src/v8/instructionEngine/resolveTokenValue.js +1 -0
  197. package/src/v8/instructionEngine/story/storyInjector.js +50 -0
  198. package/src/v8/instructionEngine/storyInjector.js +1 -0
  199. package/src/v8/instructionEngine/value/interpolate.js +38 -0
  200. package/src/v9/index.js +96 -0
  201. package/src/v9/instructionEngine/compile/compileTree.js +191 -0
  202. package/src/v9/instructionEngine/compileTree.js +1 -0
  203. package/src/v9/instructionEngine/expandIteration.js +1 -0
  204. package/src/v9/instructionEngine/index.js +29 -0
  205. package/src/v9/instructionEngine/interpolate.js +2 -0
  206. package/src/v9/instructionEngine/iteration/expandIteration.js +95 -0
  207. package/src/v9/instructionEngine/operation/operation.js +237 -0
  208. package/src/v9/instructionEngine/other/other.js +150 -0
  209. package/src/v9/instructionEngine/pipeline/pipeline.js +47 -0
  210. package/src/v9/instructionEngine/replace/replace.js +173 -0
  211. package/src/v9/instructionEngine/resolve/resolvePath.js +18 -0
  212. package/src/v9/instructionEngine/resolve/resolveTokenValue.js +22 -0
  213. package/src/v9/instructionEngine/resolvePath.js +1 -0
  214. package/src/v9/instructionEngine/resolveTokenValue.js +1 -0
  215. package/src/v9/instructionEngine/story/storyInjector.js +50 -0
  216. package/src/v9/instructionEngine/storyInjector.js +1 -0
  217. package/src/v9/instructionEngine/value/interpolate.js +38 -0
@@ -0,0 +1,160 @@
1
+ const d = {
2
+ version: "18.0.0",
3
+ name: "json-to-spec/v18",
4
+ description: "Minimalist 2-layer compiler: pure value replace + jsonToSpec iterate"
5
+ }, f = (n) => {
6
+ typeof globalThis > "u" || !n || (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks["json-to-spec"] = {
7
+ meta: d,
8
+ compile: n
9
+ });
10
+ }, p = ({ inData: n, inDataKey: o }) => {
11
+ const t = o;
12
+ if (t === "") return n;
13
+ let e = n[t];
14
+ return t.includes(".") && (e = t.split(".").reduce(
15
+ (a, c) => a == null ? void 0 : a[c],
16
+ n
17
+ )), e;
18
+ }, y = ({
19
+ inNode: n,
20
+ inData: o
21
+ } = {}) => {
22
+ const t = n, e = o;
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 r = t.textContent.replace(/^\$\{/, "").replace(/\}$/, "");
27
+ t.textContent = p({
28
+ inData: e,
29
+ inDataKey: r
30
+ });
31
+ }, h = ({
32
+ inNode: n,
33
+ inData: o
34
+ } = {}) => {
35
+ const t = n, e = o;
36
+ if ("attributes" in t) {
37
+ const r = Object.fromEntries(
38
+ Object.entries(t.attributes || {}).map(([s, a]) => [
39
+ s,
40
+ typeof a == "string" && a.includes("${") ? p({
41
+ inData: e,
42
+ inDataKey: a.replace(/^\$\{/, "").replace(/\}$/, "")
43
+ }) : a
44
+ ])
45
+ );
46
+ t.attributes = { ...r };
47
+ }
48
+ }, m = ({
49
+ inNode: n,
50
+ inData: o
51
+ } = {}) => {
52
+ const t = n, e = o;
53
+ y({ inNode: t, inData: e }), h({ inNode: t, inData: e });
54
+ }, j = ({
55
+ inTemplate: n,
56
+ inSourceValues: o
57
+ } = {}) => o.map((r) => {
58
+ const s = structuredClone(n);
59
+ return i({
60
+ inNode: s,
61
+ inData: r,
62
+ inOperation: "replace"
63
+ });
64
+ }), A = ({
65
+ inNode: n,
66
+ inData: o
67
+ } = {}) => {
68
+ const t = n, e = o;
69
+ if (!("jsonToSpec" in t) || !("operation" in t.jsonToSpec) || t.jsonToSpec.operation !== "iterate" || !("source" in t.jsonToSpec)) return;
70
+ const r = e[t.jsonToSpec.source], s = j({
71
+ inTemplate: t.jsonToSpec.template,
72
+ inSourceValues: r
73
+ });
74
+ t.children = s;
75
+ }, l = ({ inNode: n, inData: o, inOperation: t }) => {
76
+ const e = n, r = t;
77
+ if (Array.isArray(e)) {
78
+ const s = [];
79
+ for (const a of e) {
80
+ const c = i({
81
+ inNode: a,
82
+ inData: o,
83
+ inOperation: r
84
+ });
85
+ Array.isArray(c) ? s.push(...c) : c != null && s.push(c);
86
+ }
87
+ return s;
88
+ }
89
+ }, i = ({
90
+ inNode: n,
91
+ inData: o = {},
92
+ inOperation: t
93
+ } = {}) => {
94
+ const e = n, r = t;
95
+ if (e == null)
96
+ return e;
97
+ if (Array.isArray(e))
98
+ return l({
99
+ inNode: e,
100
+ inData: o,
101
+ inOperation: r
102
+ });
103
+ if ("children" in e && Array.isArray(e == null ? void 0 : e.children) && (e.children = l({
104
+ inNode: e == null ? void 0 : e.children,
105
+ inData: o,
106
+ inOperation: r
107
+ })), typeof e != "object")
108
+ return e;
109
+ switch (r) {
110
+ case "replace":
111
+ typeof e == "object" && m({
112
+ inNode: e,
113
+ inData: o
114
+ });
115
+ break;
116
+ case "iterateDo":
117
+ A({
118
+ inNode: e,
119
+ inData: o
120
+ });
121
+ }
122
+ return e;
123
+ }, u = ({ inStructureAsJson: n, inDataAsJson: o, inOperation: t }) => {
124
+ try {
125
+ return i({
126
+ inNode: n,
127
+ inData: o,
128
+ inOperation: t
129
+ });
130
+ } catch (e) {
131
+ throw console.error("[json-to-spec/v17] replace error:", e), e;
132
+ }
133
+ }, D = {
134
+ version: "18.0.0",
135
+ name: "json-to-spec/v18",
136
+ description: "Minimalist 2-layer compiler: pure value replace + jsonToSpec iterate"
137
+ }, b = (n, o = {}, t = !1) => {
138
+ let e = n, r = o;
139
+ t && console.log(D.name, e, r);
140
+ try {
141
+ const s = u({
142
+ inStructureAsJson: e,
143
+ inDataAsJson: r,
144
+ inOperation: "iterateDo"
145
+ }), a = u({
146
+ inStructureAsJson: s,
147
+ inDataAsJson: r,
148
+ inOperation: "replace"
149
+ });
150
+ return console.log("iteratedData : ", s, a), a;
151
+ } catch (s) {
152
+ throw console.error("[json-to-spec/v17] compile error:", s), s;
153
+ }
154
+ };
155
+ f(b);
156
+ export {
157
+ b as compile,
158
+ b as default,
159
+ D as meta
160
+ };
@@ -0,0 +1,164 @@
1
+ const p = {
2
+ version: "19.0.0",
3
+ name: "json-to-spec/v19",
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
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;
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 e = t.textContent.replace(/^\$\{/, "").replace(/\}$/, "");
27
+ t.textContent = f({
28
+ inData: n,
29
+ inDataKey: e
30
+ });
31
+ }, h = ({
32
+ inNode: r,
33
+ inData: o
34
+ } = {}) => {
35
+ const t = r, n = o;
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
44
+ ])
45
+ );
46
+ t.attributes = { ...e };
47
+ }
48
+ }, j = ({
49
+ inNode: r,
50
+ inData: o
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,
64
+ inOperation: "replace"
65
+ });
66
+ });
67
+ }, D = ({
68
+ inNode: r,
69
+ inData: o,
70
+ inShowLog: t
71
+ } = {}) => {
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
77
+ });
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,
86
+ inData: o,
87
+ inOperation: e
88
+ });
89
+ Array.isArray(c) ? a.push(...c) : c != null && a.push(c);
90
+ }
91
+ return a;
92
+ }
93
+ }, i = ({
94
+ inNode: r,
95
+ inData: o = {},
96
+ inOperation: t,
97
+ inShowLog: n = !1
98
+ } = {}) => {
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
107
+ });
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) {
115
+ case "replace":
116
+ typeof e == "object" && j({
117
+ inNode: e,
118
+ inData: o
119
+ });
120
+ break;
121
+ case "iterateDo":
122
+ D({
123
+ inNode: e,
124
+ inData: a,
125
+ inShowLog: n
126
+ });
127
+ }
128
+ return e;
129
+ }, u = ({ inStructureAsJson: r, inDataAsJson: o, inOperation: t, inShowLog: n }) => {
130
+ try {
131
+ return i({
132
+ inNode: r,
133
+ inData: o,
134
+ inOperation: t,
135
+ inShowLog: n
136
+ });
137
+ } catch (e) {
138
+ throw console.error("[json-to-spec/v17] replace error:", e), e;
139
+ }
140
+ }, m = (r, o = {}, t = !1) => {
141
+ let n = r, e = o;
142
+ t && console.log(p.name, n, e);
143
+ 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",
153
+ inShowLog: t
154
+ });
155
+ return t && console.log("iteratedData : ", a, s), s;
156
+ } catch (a) {
157
+ throw console.error("[json-to-spec/v19] compile error:", a), a;
158
+ }
159
+ };
160
+ d(m);
161
+ export {
162
+ m as compile,
163
+ m as default
164
+ };
@@ -0,0 +1,129 @@
1
+ const b = ({ inData: t, inPath: f }) => {
2
+ const s = t, e = f;
3
+ if (s == null) return;
4
+ if (e == null || e === "" || e === ".")
5
+ return s;
6
+ const u = Array.isArray(e) ? e : String(e).split(".");
7
+ let n = s;
8
+ for (const g of u) {
9
+ if (n == null)
10
+ return;
11
+ n = n[g];
12
+ }
13
+ return n;
14
+ }, S = ({ inText: t, inItemContext: f, inRootData: s }) => {
15
+ const e = t, u = f, n = s;
16
+ return typeof e != "string" || !e.includes("${") ? e : e.replace(/\$\{([^}]+)\}/g, (g, a) => {
17
+ const c = a.trim();
18
+ let d = b({ inData: u, inPath: c });
19
+ return d === void 0 && n && (d = b({ inData: n, inPath: c })), d != null ? String(d) : "";
20
+ });
21
+ }, h = ({ inNode: t, inContext: f = {}, inRootData: s = {} } = {}) => {
22
+ var d;
23
+ const e = t, u = f || {}, n = s || {};
24
+ if (e == null) return null;
25
+ if (Array.isArray(e)) {
26
+ const i = [];
27
+ for (const l of e) {
28
+ const r = h({
29
+ inNode: l,
30
+ inContext: u,
31
+ inRootData: n
32
+ });
33
+ Array.isArray(r) ? i.push(...r) : r != null && i.push(r);
34
+ }
35
+ return i;
36
+ }
37
+ if (typeof e != "object")
38
+ return S({
39
+ inText: e,
40
+ inItemContext: u.item,
41
+ inRootData: n
42
+ });
43
+ if (e.operation === "iterate" || !!e.$iterate) {
44
+ const i = e.source || e.iterateOn || e.$iterate, l = n && n[i] || b({ inData: n, inPath: i }) || u && u[i] || b({ inData: u, inPath: i });
45
+ if (!Array.isArray(l)) return [];
46
+ const r = e.template || e.item || {}, A = e.filter, j = l.filter((o) => {
47
+ if (!o || typeof o != "object") return !0;
48
+ if (A && typeof A == "object") {
49
+ for (const [p, y] of Object.entries(A))
50
+ if (o[p] !== y) return !1;
51
+ }
52
+ return o.isVisible !== !1;
53
+ }), N = [];
54
+ return j.forEach((o, p) => {
55
+ const y = {
56
+ ...u,
57
+ item: o,
58
+ ...typeof o == "object" && o !== null ? o : {},
59
+ $index: p,
60
+ $number: p + 1
61
+ };
62
+ if ((i === "rows" || i.endsWith(".rows") || i === "items") && (y.row = o), u.row && (o.field || o.columnName || o.name)) {
63
+ const D = o.field || o.columnName || o.name, v = u.row[D];
64
+ v !== void 0 && (y.cellValue = v, y.value = v);
65
+ }
66
+ const m = h({
67
+ inNode: r,
68
+ inContext: y,
69
+ inRootData: n
70
+ });
71
+ Array.isArray(m) ? N.push(...m) : m != null && N.push(m);
72
+ }), N;
73
+ }
74
+ const a = { ...e }, c = u.item || u;
75
+ if (c.type === "textarea" && a.tagName === "input" && (a.tagName = "textarea", a.attributes && (a.attributes = { ...a.attributes }, delete a.attributes.type)), a.textContent && (a.textContent = S({
76
+ inText: a.textContent,
77
+ inItemContext: c,
78
+ inRootData: n
79
+ })), a.attributes) {
80
+ a.attributes = { ...a.attributes };
81
+ for (const [l, r] of Object.entries(a.attributes))
82
+ typeof r == "string" && (a.attributes[l] = S({
83
+ inText: r,
84
+ inItemContext: c,
85
+ inRootData: n
86
+ }));
87
+ if (["input", "textarea", "select", "option"].includes((d = a.tagName) == null ? void 0 : d.toLowerCase())) {
88
+ const l = c.field || c.columnName || c.name;
89
+ c.value !== void 0 && c.value !== null ? a.attributes.value = String(c.value) : l && n[l] !== void 0 && n[l] !== null ? a.attributes.value = String(n[l]) : l && n.values && n.values[l] !== void 0 && n.values[l] !== null && (a.attributes.value = String(n.values[l]));
90
+ }
91
+ }
92
+ if (Array.isArray(a.children)) {
93
+ const i = [];
94
+ for (const l of a.children) {
95
+ const r = h({
96
+ inNode: l,
97
+ inContext: u,
98
+ inRootData: n
99
+ });
100
+ Array.isArray(r) ? i.push(...r) : r != null && i.push(r);
101
+ }
102
+ a.children = i;
103
+ }
104
+ return a;
105
+ }, R = {
106
+ version: "2.0.0",
107
+ name: "json-to-spec/v2",
108
+ description: "Pure JSON Specification Compiler: (contextJson, dataJson) -> Spec JSON ready for json-to-dom"
109
+ }, T = (t, f = {}) => {
110
+ let s = t, e = f || {};
111
+ return t && typeof t == "object" && !Array.isArray(t) && ("context" in t && ("data" in t || f === void 0 || Object.keys(f).length === 0) ? (s = t.context, e = t.data || e) : "structure" in t && ("data" in t || f === void 0 || Object.keys(f).length === 0) ? (s = t.structure, e = t.data || e) : ("inStructure" in t || "inContext" in t || "inTree" in t) && (s = t.inStructure || t.inContext || t.inTree, e = t.inData || e)), h({
112
+ inNode: s,
113
+ inContext: e,
114
+ inRootData: e
115
+ });
116
+ };
117
+ typeof globalThis < "u" && (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks["json-to-spec"] = {
118
+ meta: R,
119
+ compile: T,
120
+ compileNode: h,
121
+ resolvePath: b
122
+ });
123
+ export {
124
+ T as compile,
125
+ h as compileNode,
126
+ T as default,
127
+ R as meta,
128
+ b as resolvePath
129
+ };
@@ -0,0 +1,201 @@
1
+ const x = ({ inData: i, inPath: u }) => {
2
+ const f = i, e = u;
3
+ if (f == null) return;
4
+ if (e == null || e === "" || e === ".")
5
+ return f;
6
+ const a = Array.isArray(e) ? e : String(e).split(".");
7
+ let o = f;
8
+ for (const l of a) {
9
+ if (o == null)
10
+ return;
11
+ o = o[l];
12
+ }
13
+ return o;
14
+ }, D = ({ inPath: i, inItemContext: u, inRootData: f }) => {
15
+ const e = i, a = u, o = f;
16
+ let l = x({ inData: a, inPath: e });
17
+ return l === void 0 && a && typeof a == "object" && (a.item && typeof a.item == "object" && (l = x({ inData: a.item, inPath: e })), l === void 0 && a.row && typeof a.row == "object" && (l = x({ inData: a.row, inPath: e }))), l === void 0 && o && (l = x({ inData: o, inPath: e })), l;
18
+ }, h = ({ inValue: i, inItemContext: u, inRootData: f }) => {
19
+ const e = i, a = u, o = f;
20
+ if (typeof e != "string" || !e.includes("${"))
21
+ return e;
22
+ const l = e.match(/^\$\{([^}]+)\}$/);
23
+ if (l) {
24
+ const t = D({
25
+ inPath: l[1].trim(),
26
+ inItemContext: a,
27
+ inRootData: o
28
+ });
29
+ return t ?? "";
30
+ }
31
+ return e.replace(/\$\{([^}]+)\}/g, (t, d) => {
32
+ const y = D({
33
+ inPath: d.trim(),
34
+ inItemContext: a,
35
+ inRootData: o
36
+ });
37
+ return y != null ? String(y) : "";
38
+ });
39
+ }, v = ({ inText: i, inItemContext: u, inRootData: f }) => {
40
+ const e = h({
41
+ inValue: i,
42
+ inItemContext: u,
43
+ inRootData: f
44
+ });
45
+ return e != null ? String(e) : "";
46
+ }, C = ({ inNode: i, inContext: u = {}, inRootData: f = {} } = {}) => {
47
+ var y;
48
+ const e = i, a = u || {}, o = f || {};
49
+ if (e == null) return null;
50
+ if (Array.isArray(e)) {
51
+ const s = [];
52
+ for (const r of e) {
53
+ const c = C({
54
+ inNode: r,
55
+ inContext: a,
56
+ inRootData: o
57
+ });
58
+ Array.isArray(c) ? s.push(...c) : c != null && s.push(c);
59
+ }
60
+ return s;
61
+ }
62
+ if (typeof e != "object")
63
+ return v({
64
+ inText: e,
65
+ inItemContext: a,
66
+ inRootData: o
67
+ });
68
+ const l = e.jsonToSpec || (e.operation ? e : null);
69
+ if (l && (l.operation === "iterate" || l.source || l.$iterate)) {
70
+ const s = l.source || l.iterateOn || l.$iterate, r = x({ inData: o, inPath: s }) || o && o[s] || x({ inData: a, inPath: s }) || a && a[s];
71
+ if (!Array.isArray(r)) {
72
+ if (e.tagName) {
73
+ const n = { ...e };
74
+ return delete n.jsonToSpec, n.children = [], n;
75
+ }
76
+ return [];
77
+ }
78
+ const c = l.template || l.item || {}, N = l.filter, V = r.filter((n) => {
79
+ if (!n || typeof n != "object") return !0;
80
+ if (N && typeof N == "object") {
81
+ for (const [m, p] of Object.entries(N))
82
+ if (n[m] !== p) return !1;
83
+ }
84
+ return n.isVisible !== !1;
85
+ }), g = [];
86
+ if (V.forEach((n, m) => {
87
+ const p = {
88
+ ...a,
89
+ item: n,
90
+ ...typeof n == "object" && n !== null ? n : {},
91
+ $index: m,
92
+ $number: m + 1
93
+ };
94
+ if ((s === "rows" || s.endsWith(".rows") || s === "items" || s.endsWith("Rows")) && (p.row = n), a.row && (n.field || n.columnName || n.name)) {
95
+ const T = n.field || n.columnName || n.name, j = a.row[T];
96
+ j !== void 0 && (p.cellValue = j, p.value = j, typeof n == "object" && n !== null && n.value === void 0 && (n.value = j));
97
+ }
98
+ const b = C({
99
+ inNode: c,
100
+ inContext: p,
101
+ inRootData: o
102
+ });
103
+ Array.isArray(b) ? g.push(...b) : b != null && g.push(b);
104
+ }), e.tagName) {
105
+ const n = { ...e };
106
+ if (delete n.jsonToSpec, n.children = g, n.textContent && (n.textContent = v({
107
+ inText: n.textContent,
108
+ inItemContext: a,
109
+ inRootData: o
110
+ })), n.attributes) {
111
+ n.attributes = { ...n.attributes };
112
+ for (const [m, p] of Object.entries(n.attributes))
113
+ typeof p == "string" && (n.attributes[m] = h({
114
+ inValue: p,
115
+ inItemContext: a,
116
+ inRootData: o
117
+ }));
118
+ }
119
+ if (n.properties) {
120
+ n.properties = { ...n.properties };
121
+ for (const [m, p] of Object.entries(n.properties))
122
+ typeof p == "string" && (n.properties[m] = h({
123
+ inValue: p,
124
+ inItemContext: a,
125
+ inRootData: o
126
+ }));
127
+ }
128
+ return n;
129
+ }
130
+ return g;
131
+ }
132
+ const t = { ...e };
133
+ "jsonToSpec" in t && delete t.jsonToSpec;
134
+ const d = {
135
+ ...typeof a.item == "object" ? a.item : {},
136
+ ...a
137
+ };
138
+ if (d.type === "textarea" && t.tagName === "input" && (t.tagName = "textarea", t.attributes && (t.attributes = { ...t.attributes }, delete t.attributes.type)), t.textContent && (t.textContent = v({
139
+ inText: t.textContent,
140
+ inItemContext: d,
141
+ inRootData: o
142
+ })), t.attributes) {
143
+ t.attributes = { ...t.attributes };
144
+ for (const [r, c] of Object.entries(t.attributes))
145
+ typeof c == "string" && (t.attributes[r] = h({
146
+ inValue: c,
147
+ inItemContext: d,
148
+ inRootData: o
149
+ }));
150
+ if (["input", "textarea", "select", "option"].includes((y = t.tagName) == null ? void 0 : y.toLowerCase())) {
151
+ const r = d.field || d.columnName || d.name;
152
+ d.value !== void 0 && d.value !== null ? (t.attributes.value = String(d.value), t.tagName === "textarea" && !t.textContent && (t.textContent = String(d.value))) : r && o[r] !== void 0 && o[r] !== null ? (t.attributes.value = String(o[r]), t.tagName === "textarea" && !t.textContent && (t.textContent = String(o[r]))) : r && o.values && o.values[r] !== void 0 && o.values[r] !== null && (t.attributes.value = String(o.values[r]), t.tagName === "textarea" && !t.textContent && (t.textContent = String(o.values[r])));
153
+ }
154
+ }
155
+ if (t.properties) {
156
+ t.properties = { ...t.properties };
157
+ for (const [s, r] of Object.entries(t.properties))
158
+ typeof r == "string" && (t.properties[s] = h({
159
+ inValue: r,
160
+ inItemContext: d,
161
+ inRootData: o
162
+ }));
163
+ }
164
+ if (Array.isArray(t.children)) {
165
+ const s = [];
166
+ for (const r of t.children) {
167
+ const c = C({
168
+ inNode: r,
169
+ inContext: a,
170
+ inRootData: o
171
+ });
172
+ Array.isArray(c) ? s.push(...c) : c != null && s.push(c);
173
+ }
174
+ t.children = s;
175
+ }
176
+ return t;
177
+ }, R = {
178
+ version: "3.0.0",
179
+ name: "json-to-spec/v3",
180
+ description: "Pure JSON Specification Compiler with jsonToSpec namespace: (structure, data) -> Spec JSON ready for json-to-dom"
181
+ }, A = (i, u = {}) => {
182
+ let f = i, e = u || {};
183
+ return i && typeof i == "object" && !Array.isArray(i) && ("structure" in i && ("data" in i || u === void 0 || Object.keys(u).length === 0) ? (f = i.structure, e = i.data || e) : "context" in i && ("data" in i || u === void 0 || Object.keys(u).length === 0) ? (f = i.context, e = i.data || e) : ("inStructure" in i || "inContext" in i || "inTree" in i) && (f = i.inStructure || i.inContext || i.inTree, e = i.inData || e)), C({
184
+ inNode: f,
185
+ inContext: e,
186
+ inRootData: e
187
+ });
188
+ };
189
+ typeof globalThis < "u" && (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks["json-to-spec"] = {
190
+ meta: R,
191
+ compile: A,
192
+ compileNode: C,
193
+ resolvePath: x
194
+ }, globalThis.ks["json-to-spec-v3"] = globalThis.ks["json-to-spec"]);
195
+ export {
196
+ A as compile,
197
+ C as compileNode,
198
+ A as default,
199
+ R as meta,
200
+ x as resolvePath
201
+ };