@bravostudioai/react 0.1.1 → 0.1.2
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/_virtual/main.js +3 -2
- package/dist/cli/commands/generate.js +161 -1438
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/codegen/generator.js +473 -0
- package/dist/codegen/generator.js.map +1 -0
- package/dist/codegen/parser.js +720 -0
- package/dist/codegen/parser.js.map +1 -0
- package/dist/components/EncoreApp.js +173 -152
- package/dist/components/EncoreApp.js.map +1 -1
- package/dist/src/cli/commands/generate.d.ts.map +1 -1
- package/dist/src/codegen/index.d.ts +4 -0
- package/dist/src/codegen/index.d.ts.map +1 -0
- package/dist/src/codegen/parser.d.ts.map +1 -1
- package/dist/src/components/EncoreApp.d.ts +5 -1
- package/dist/src/components/EncoreApp.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/EncoreApp.tsx +55 -21
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
function C(c) {
|
|
2
|
+
const f = c.replace(/[^a-zA-Z0-9\s]/g, "").trim();
|
|
3
|
+
return f ? f.split(/\s+/).map((n, p) => {
|
|
4
|
+
if (!n) return "";
|
|
5
|
+
const t = n === n.toUpperCase() && n.length > 1 ? n.toLowerCase() : n, m = t.charAt(0), a = t.slice(1);
|
|
6
|
+
return p === 0 ? m.toLowerCase() + a : m.toUpperCase() + a;
|
|
7
|
+
}).join("").replace(/^[0-9]/, "_$&") : "item";
|
|
8
|
+
}
|
|
9
|
+
function U(c, f) {
|
|
10
|
+
const n = C(c);
|
|
11
|
+
if (f.length === 0)
|
|
12
|
+
return n;
|
|
13
|
+
const p = f.filter((a) => a && a.trim()).reverse();
|
|
14
|
+
return p.length === 0 ? n : p.map(
|
|
15
|
+
(a) => C(a)
|
|
16
|
+
).map((a) => a.charAt(0).toUpperCase() + a.slice(1)).join("") + n;
|
|
17
|
+
}
|
|
18
|
+
function L(c, f) {
|
|
19
|
+
if (f.length === 0)
|
|
20
|
+
return [];
|
|
21
|
+
let n = 0;
|
|
22
|
+
const p = Math.min(
|
|
23
|
+
c.length,
|
|
24
|
+
...f.map((m) => m.length)
|
|
25
|
+
);
|
|
26
|
+
for (let m = 0; m < p; m++) {
|
|
27
|
+
const a = c[m];
|
|
28
|
+
if (f.every((y) => y[m] === a))
|
|
29
|
+
n++;
|
|
30
|
+
else
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
const t = c.slice(n);
|
|
34
|
+
for (let m = 1; m <= t.length; m++) {
|
|
35
|
+
const a = t.slice(0, m);
|
|
36
|
+
if (f.every((y) => {
|
|
37
|
+
if (y.length < n + m)
|
|
38
|
+
return !0;
|
|
39
|
+
const r = y.slice(
|
|
40
|
+
n,
|
|
41
|
+
n + m
|
|
42
|
+
);
|
|
43
|
+
return !Q(a, r);
|
|
44
|
+
}))
|
|
45
|
+
return a;
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
function Q(c, f) {
|
|
50
|
+
return c.length !== f.length ? !1 : c.every((n, p) => n === f[p]);
|
|
51
|
+
}
|
|
52
|
+
function B(c, f) {
|
|
53
|
+
return c === "component:image" || c === "component:text" || c?.startsWith("component:input-") ? "string" : "any";
|
|
54
|
+
}
|
|
55
|
+
function K(c) {
|
|
56
|
+
return c === "component:image" ? "imageUrl" : c === "component:text" ? "text" : "value";
|
|
57
|
+
}
|
|
58
|
+
function O(c) {
|
|
59
|
+
const f = [];
|
|
60
|
+
function n(t, m = []) {
|
|
61
|
+
if (!(!t || typeof t != "object")) {
|
|
62
|
+
if (t.type === "container:slider") {
|
|
63
|
+
const a = {
|
|
64
|
+
id: t.id,
|
|
65
|
+
name: t.name || "Slider",
|
|
66
|
+
arrayContainer: null
|
|
67
|
+
};
|
|
68
|
+
let e = null;
|
|
69
|
+
const y = (r) => {
|
|
70
|
+
if (!e && !(!r || typeof r != "object")) {
|
|
71
|
+
if (Array.isArray(r.tags) && (r.tags.includes("encore:data:array") || r.tags.includes("bravo:data:array"))) {
|
|
72
|
+
e = r;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
r.body && Array.isArray(r.body) && r.body.forEach(y), r.containers && Array.isArray(r.containers) && r.containers.forEach(y), r.components && Array.isArray(r.components) && r.components.forEach(y);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (t.containers && Array.isArray(t.containers) && t.containers.forEach(y), !e && t.components && Array.isArray(t.components) && t.components.forEach(y), e) {
|
|
79
|
+
const r = e;
|
|
80
|
+
let h = [];
|
|
81
|
+
const o = [], u = (s, l = []) => {
|
|
82
|
+
if (!s || typeof s != "object") return;
|
|
83
|
+
if (s.type === "component:image" && o.push(s), Array.isArray(s.tags) && (s.tags.includes("encore:data") || s.tags.includes("bravo:data"))) {
|
|
84
|
+
const P = C(s.name || "item"), v = B(s.type, s.name);
|
|
85
|
+
h.push({
|
|
86
|
+
id: s.id,
|
|
87
|
+
name: s.name || "Unnamed",
|
|
88
|
+
type: s.type,
|
|
89
|
+
tags: s.tags || [],
|
|
90
|
+
propName: P,
|
|
91
|
+
// Will be qualified later if needed
|
|
92
|
+
propType: v,
|
|
93
|
+
// Store parent path for later qualification
|
|
94
|
+
_parentPath: [...l]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const g = [...l];
|
|
98
|
+
if (s.name && (s.type?.startsWith("container:") || s.type?.startsWith("component:"))) {
|
|
99
|
+
const P = s.name.trim(), v = /^frame\s*\d*$/i.test(P) || P.toUpperCase() === "FRAME";
|
|
100
|
+
P && !v && g.push(s.name);
|
|
101
|
+
}
|
|
102
|
+
s.body && Array.isArray(s.body) && s.body.forEach(
|
|
103
|
+
(P) => u(P, g)
|
|
104
|
+
), s.containers && Array.isArray(s.containers) && s.containers.forEach(
|
|
105
|
+
(P) => u(P, g)
|
|
106
|
+
), s.components && Array.isArray(s.components) && s.components.forEach(
|
|
107
|
+
(P) => u(P, g)
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
if (r.components && Array.isArray(r.components) && r.components.forEach(
|
|
111
|
+
(s) => u(s, [])
|
|
112
|
+
), !h.some(
|
|
113
|
+
(s) => s.type === "component:image"
|
|
114
|
+
) && o.length > 0) {
|
|
115
|
+
const s = o[0], g = (s.name || "image").toLowerCase().includes("image") ? "imageUrl" : C(s.name || "image");
|
|
116
|
+
h.push({
|
|
117
|
+
id: s.id,
|
|
118
|
+
name: s.name || "Image",
|
|
119
|
+
type: s.type,
|
|
120
|
+
tags: s.tags || [],
|
|
121
|
+
propName: g,
|
|
122
|
+
// Will be qualified later if needed
|
|
123
|
+
propType: "string",
|
|
124
|
+
// imageUrl is always string
|
|
125
|
+
_parentPath: []
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const A = /* @__PURE__ */ new Map();
|
|
129
|
+
if (h.forEach((s) => {
|
|
130
|
+
const l = s, g = s.propName;
|
|
131
|
+
A.has(g) || A.set(g, []), A.get(g).push(l);
|
|
132
|
+
}), A.forEach((s, l) => {
|
|
133
|
+
if (s.length === 1)
|
|
134
|
+
return;
|
|
135
|
+
s.forEach((b) => {
|
|
136
|
+
const _ = s.filter((E) => E.id !== b.id).map((E) => E._parentPath || []), N = L(
|
|
137
|
+
b._parentPath || [],
|
|
138
|
+
_
|
|
139
|
+
);
|
|
140
|
+
b.propName = U(
|
|
141
|
+
b.name || "item",
|
|
142
|
+
N
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
let g = !0, P = 0;
|
|
146
|
+
const v = 10;
|
|
147
|
+
for (; g && P < v; ) {
|
|
148
|
+
P++;
|
|
149
|
+
const b = /* @__PURE__ */ new Map();
|
|
150
|
+
s.forEach((_) => {
|
|
151
|
+
b.has(_.propName) || b.set(_.propName, []), b.get(_.propName).push(_);
|
|
152
|
+
}), g = !1, b.forEach((_, N) => {
|
|
153
|
+
_.length > 1 && (g = !0, _.forEach((E) => {
|
|
154
|
+
const x = E._parentPath || [], W = _.filter((M) => M.id !== E.id).map((M) => M._parentPath || []);
|
|
155
|
+
let S = 0;
|
|
156
|
+
const I = Math.min(
|
|
157
|
+
x.length,
|
|
158
|
+
...W.map((M) => M.length)
|
|
159
|
+
);
|
|
160
|
+
for (let M = 0; M < I; M++) {
|
|
161
|
+
const w = x[M];
|
|
162
|
+
if (W.every((z) => z[M] === w))
|
|
163
|
+
S++;
|
|
164
|
+
else
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
const q = x.slice(S);
|
|
168
|
+
let k = !1;
|
|
169
|
+
for (let M = 1; M <= q.length; M++) {
|
|
170
|
+
const w = q.slice(
|
|
171
|
+
0,
|
|
172
|
+
M
|
|
173
|
+
), j = U(
|
|
174
|
+
E.name || "item",
|
|
175
|
+
w
|
|
176
|
+
);
|
|
177
|
+
if (h.every((F) => {
|
|
178
|
+
if (F.id === E.id) return !0;
|
|
179
|
+
if (_.some(($) => $.id === F.id)) {
|
|
180
|
+
const $ = F._parentPath || [], R = Math.min(
|
|
181
|
+
S,
|
|
182
|
+
$.length
|
|
183
|
+
), T = $.slice(
|
|
184
|
+
R
|
|
185
|
+
).slice(0, M), Z = U(
|
|
186
|
+
F.name || "item",
|
|
187
|
+
T
|
|
188
|
+
);
|
|
189
|
+
return j !== Z;
|
|
190
|
+
}
|
|
191
|
+
return j !== F.propName;
|
|
192
|
+
})) {
|
|
193
|
+
E.propName = j, k = !0;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
k || (E.propName = U(
|
|
198
|
+
E.name || "item",
|
|
199
|
+
q.length > 0 ? q : []
|
|
200
|
+
));
|
|
201
|
+
}));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
const d = /* @__PURE__ */ new Map();
|
|
205
|
+
s.forEach((b) => {
|
|
206
|
+
d.has(b.propName) || d.set(b.propName, []), d.get(b.propName).push(b);
|
|
207
|
+
}), d.forEach(
|
|
208
|
+
(b, _) => {
|
|
209
|
+
if (b.length > 1 && b.every((E) => {
|
|
210
|
+
const x = E._parentPath || [];
|
|
211
|
+
return b.every((W) => {
|
|
212
|
+
if (W.id === E.id) return !0;
|
|
213
|
+
const S = W._parentPath || [];
|
|
214
|
+
return Q(x, S);
|
|
215
|
+
});
|
|
216
|
+
})) {
|
|
217
|
+
let E = 0;
|
|
218
|
+
b.forEach((x) => {
|
|
219
|
+
E > 0 && (x.propName = `${_}${E + 1}`), E++;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
), s.forEach((b) => {
|
|
224
|
+
delete b._parentPath;
|
|
225
|
+
});
|
|
226
|
+
}), o.length > 0) {
|
|
227
|
+
const l = (o[0].name || "").toLowerCase();
|
|
228
|
+
h = h.filter((g) => {
|
|
229
|
+
if (g.type === "component:image") return !0;
|
|
230
|
+
if (g.type === "component:color") {
|
|
231
|
+
const P = (g.name || "").toLowerCase();
|
|
232
|
+
if (l.includes(P) || P.includes("image"))
|
|
233
|
+
return !1;
|
|
234
|
+
}
|
|
235
|
+
return !0;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
a.arrayContainer = {
|
|
239
|
+
id: r.id,
|
|
240
|
+
name: r.name || "Item",
|
|
241
|
+
propName: C(r.name || "items"),
|
|
242
|
+
components: h
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
f.push(a);
|
|
246
|
+
}
|
|
247
|
+
t.body && Array.isArray(t.body) && t.body.forEach((a) => n(a, [...m, "body"])), t.containers && Array.isArray(t.containers) && t.containers.forEach(
|
|
248
|
+
(a) => n(a, [...m, "containers"])
|
|
249
|
+
), t.components && Array.isArray(t.components) && t.components.forEach(
|
|
250
|
+
(a) => n(a, [...m, "components"])
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const p = c.data?.body || c.body || c.data?.body || [];
|
|
255
|
+
return Array.isArray(p) && p.length > 0 && p.forEach((t) => n(t)), f;
|
|
256
|
+
}
|
|
257
|
+
function V(c) {
|
|
258
|
+
const f = [], n = /* @__PURE__ */ new Set();
|
|
259
|
+
function p(e) {
|
|
260
|
+
!e || typeof e != "object" || (e.type === "container:slider" && n.add(e.id), e.body && Array.isArray(e.body) && e.body.forEach(p), e.containers && Array.isArray(e.containers) && e.containers.forEach(p));
|
|
261
|
+
}
|
|
262
|
+
function t(e, y, r = []) {
|
|
263
|
+
if (!e || typeof e != "object" || y && n.has(y)) return;
|
|
264
|
+
if (Array.isArray(e.tags) && (e.tags.includes("encore:data") || e.tags.includes("bravo:data")) && (e.type === "component:text" || e.type === "component:image")) {
|
|
265
|
+
const u = C(e.name || "item"), i = B(e.type, e.name);
|
|
266
|
+
f.push({
|
|
267
|
+
id: e.id,
|
|
268
|
+
name: e.name || "Unnamed",
|
|
269
|
+
type: e.type,
|
|
270
|
+
tags: e.tags || [],
|
|
271
|
+
propName: u,
|
|
272
|
+
// Will be qualified later if needed
|
|
273
|
+
propType: i,
|
|
274
|
+
// Store parent path for later qualification
|
|
275
|
+
_parentPath: [...r]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const h = [...r];
|
|
279
|
+
if (e.name && (e.type?.startsWith("container:") || e.type?.startsWith("component:"))) {
|
|
280
|
+
const u = e.name.trim(), i = /^frame\s*\d*$/i.test(u) || u.toUpperCase() === "FRAME";
|
|
281
|
+
u && !i && h.push(e.name);
|
|
282
|
+
}
|
|
283
|
+
const o = e.id;
|
|
284
|
+
e.body && Array.isArray(e.body) && e.body.forEach(
|
|
285
|
+
(u) => t(u, o, h)
|
|
286
|
+
), e.containers && Array.isArray(e.containers) && e.containers.forEach(
|
|
287
|
+
(u) => t(u, o, h)
|
|
288
|
+
), e.components && Array.isArray(e.components) && e.components.forEach(
|
|
289
|
+
(u) => t(u, o, h)
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const m = c.data?.body || c.body || c.data?.body || [];
|
|
293
|
+
Array.isArray(m) && m.length > 0 && (m.forEach(p), m.forEach((e) => t(e)));
|
|
294
|
+
const a = /* @__PURE__ */ new Map();
|
|
295
|
+
return f.forEach((e) => {
|
|
296
|
+
const y = e, r = e.propName;
|
|
297
|
+
a.has(r) || a.set(r, []), a.get(r).push(y);
|
|
298
|
+
}), a.forEach((e, y) => {
|
|
299
|
+
if (e.length === 1)
|
|
300
|
+
return;
|
|
301
|
+
e.forEach((i) => {
|
|
302
|
+
const A = e.filter((l) => l.id !== i.id).map((l) => l._parentPath || []), s = L(
|
|
303
|
+
i._parentPath || [],
|
|
304
|
+
A
|
|
305
|
+
);
|
|
306
|
+
i.propName = U(
|
|
307
|
+
i.name || "item",
|
|
308
|
+
s
|
|
309
|
+
);
|
|
310
|
+
});
|
|
311
|
+
let r = !0, h = 0;
|
|
312
|
+
const o = 10;
|
|
313
|
+
for (; r && h < o; ) {
|
|
314
|
+
h++;
|
|
315
|
+
const i = /* @__PURE__ */ new Map();
|
|
316
|
+
e.forEach((A) => {
|
|
317
|
+
i.has(A.propName) || i.set(A.propName, []), i.get(A.propName).push(A);
|
|
318
|
+
}), r = !1, i.forEach((A, s) => {
|
|
319
|
+
A.length > 1 && (r = !0, A.forEach((l) => {
|
|
320
|
+
const g = l._parentPath || [], P = A.filter((N) => N.id !== l.id).map((N) => N._parentPath || []);
|
|
321
|
+
let v = 0;
|
|
322
|
+
const d = Math.min(
|
|
323
|
+
g.length,
|
|
324
|
+
...P.map((N) => N.length)
|
|
325
|
+
);
|
|
326
|
+
for (let N = 0; N < d; N++) {
|
|
327
|
+
const E = g[N];
|
|
328
|
+
if (P.every((W) => W[N] === E))
|
|
329
|
+
v++;
|
|
330
|
+
else
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
const b = g.slice(v);
|
|
334
|
+
let _ = !1;
|
|
335
|
+
for (let N = 1; N <= b.length; N++) {
|
|
336
|
+
const E = b.slice(0, N), x = U(
|
|
337
|
+
l.name || "item",
|
|
338
|
+
E
|
|
339
|
+
);
|
|
340
|
+
if (f.every((S) => {
|
|
341
|
+
if (S.id === l.id) return !0;
|
|
342
|
+
if (A.some((I) => I.id === S.id)) {
|
|
343
|
+
const I = S._parentPath || [], q = Math.min(
|
|
344
|
+
v,
|
|
345
|
+
I.length
|
|
346
|
+
), M = I.slice(
|
|
347
|
+
q
|
|
348
|
+
).slice(
|
|
349
|
+
0,
|
|
350
|
+
N
|
|
351
|
+
), w = U(
|
|
352
|
+
S.name || "item",
|
|
353
|
+
M
|
|
354
|
+
);
|
|
355
|
+
return x !== w;
|
|
356
|
+
}
|
|
357
|
+
return x !== S.propName;
|
|
358
|
+
})) {
|
|
359
|
+
l.propName = x, _ = !0;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
_ || (l.propName = U(
|
|
364
|
+
l.name || "item",
|
|
365
|
+
g
|
|
366
|
+
));
|
|
367
|
+
}));
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
const u = /* @__PURE__ */ new Map();
|
|
371
|
+
e.forEach((i) => {
|
|
372
|
+
u.has(i.propName) || u.set(i.propName, []), u.get(i.propName).push(i);
|
|
373
|
+
}), u.forEach((i, A) => {
|
|
374
|
+
if (i.length > 1 && i.every((l) => {
|
|
375
|
+
const g = l._parentPath || [];
|
|
376
|
+
return i.every((P) => {
|
|
377
|
+
if (P.id === l.id) return !0;
|
|
378
|
+
const v = P._parentPath || [];
|
|
379
|
+
return Q(g, v);
|
|
380
|
+
});
|
|
381
|
+
})) {
|
|
382
|
+
let l = 0;
|
|
383
|
+
i.forEach((g) => {
|
|
384
|
+
l > 0 && (g.propName = `${A}${l + 1}`), l++;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}), e.forEach((i) => {
|
|
388
|
+
delete i._parentPath;
|
|
389
|
+
});
|
|
390
|
+
}), f;
|
|
391
|
+
}
|
|
392
|
+
function X(c) {
|
|
393
|
+
const f = /* @__PURE__ */ new Map();
|
|
394
|
+
function n(t) {
|
|
395
|
+
if (!(!t || typeof t != "object")) {
|
|
396
|
+
if (t.type === "component:input-stateful-set" && Array.isArray(t.tags)) {
|
|
397
|
+
const m = t.tags.find(
|
|
398
|
+
(a) => a.startsWith("input-group:")
|
|
399
|
+
);
|
|
400
|
+
if (m) {
|
|
401
|
+
const a = m.split(":");
|
|
402
|
+
if (a.length >= 3) {
|
|
403
|
+
const e = a[1], y = a[2];
|
|
404
|
+
f.has(y) || f.set(y, {
|
|
405
|
+
groupName: y,
|
|
406
|
+
groupType: e,
|
|
407
|
+
elements: []
|
|
408
|
+
}), f.get(y).elements.push({
|
|
409
|
+
id: t.id,
|
|
410
|
+
name: t.name || "Unnamed"
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
t.body && Array.isArray(t.body) && t.body.forEach(n), t.containers && Array.isArray(t.containers) && t.containers.forEach(n), t.components && Array.isArray(t.components) && t.components.forEach(n);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
const p = c.data?.body || c.body || c.data?.body || [];
|
|
419
|
+
return Array.isArray(p) && p.length > 0 && p.forEach((t) => n(t)), Array.from(f.values());
|
|
420
|
+
}
|
|
421
|
+
function Y(c) {
|
|
422
|
+
const f = [];
|
|
423
|
+
function n(t, m) {
|
|
424
|
+
if (!t || typeof t != "object") return;
|
|
425
|
+
const a = t.type?.startsWith("container:") || t.type === "container:default", e = t.name?.toLowerCase().includes("form") || Array.isArray(t.tags) && t.tags.includes("form");
|
|
426
|
+
let y = !1, r;
|
|
427
|
+
function h(o) {
|
|
428
|
+
if (!(!o || typeof o != "object")) {
|
|
429
|
+
if (Array.isArray(o.tags) && (o.tags.includes("action:submit") || o.tags.includes("submit"))) {
|
|
430
|
+
y = !0, r = o.id;
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (o.actions?.tap?.action === "submit") {
|
|
434
|
+
y = !0, r = o.id;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
o.components && Array.isArray(o.components) && o.components.forEach(h), o.body && Array.isArray(o.body) && o.body.forEach(h);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (a && (e || m === void 0) && h(t), a && (y || e)) {
|
|
441
|
+
const o = [], u = (i, A = []) => {
|
|
442
|
+
if (!i || typeof i != "object") return;
|
|
443
|
+
if (i.type?.startsWith("component:input-") || i.type === "component:input-text" || i.type === "component:input-image" || i.type === "component:input-email" || i.type === "component:input-password" || i.type === "component:input-select") {
|
|
444
|
+
const l = C(i.name || "Unnamed input");
|
|
445
|
+
o.push({
|
|
446
|
+
id: i.id,
|
|
447
|
+
name: i.name || "Unnamed input",
|
|
448
|
+
type: i.type,
|
|
449
|
+
propName: l,
|
|
450
|
+
// Will be qualified later if needed
|
|
451
|
+
_parentPath: [...A]
|
|
452
|
+
// Store parent path for qualification
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
const s = [...A];
|
|
456
|
+
if (i.name && (i.type?.startsWith("container:") || i.type?.startsWith("component:"))) {
|
|
457
|
+
const l = i.name.trim(), g = /^frame\s*\d*$/i.test(l) || l.toUpperCase() === "FRAME";
|
|
458
|
+
l && !g && s.push(i.name);
|
|
459
|
+
}
|
|
460
|
+
i.components && Array.isArray(i.components) && i.components.forEach(
|
|
461
|
+
(l) => u(l, s)
|
|
462
|
+
), i.body && Array.isArray(i.body) && i.body.forEach((l) => u(l, s));
|
|
463
|
+
};
|
|
464
|
+
u(t, []), o.length > 0 && f.push({
|
|
465
|
+
formId: t.id,
|
|
466
|
+
formName: t.name || "Form",
|
|
467
|
+
submitButtonId: r,
|
|
468
|
+
inputs: o
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
t.body && Array.isArray(t.body) && t.body.forEach(
|
|
472
|
+
(o) => n(o, a ? t : m)
|
|
473
|
+
), t.containers && Array.isArray(t.containers) && t.containers.forEach(
|
|
474
|
+
(o) => n(o, a ? t : m)
|
|
475
|
+
), t.components && Array.isArray(t.components) && t.components.forEach(
|
|
476
|
+
(o) => n(o, a ? t : m)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
const p = c.data?.body || c.body || c.data?.body || [];
|
|
480
|
+
return Array.isArray(p) && p.length > 0 && p.forEach((t) => n(t)), f;
|
|
481
|
+
}
|
|
482
|
+
function D(c, f) {
|
|
483
|
+
const n = [], p = /* @__PURE__ */ new Set();
|
|
484
|
+
f.forEach((a) => {
|
|
485
|
+
a.inputs.forEach((e) => {
|
|
486
|
+
p.add(e.id);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
function t(a, e = []) {
|
|
490
|
+
if (!a || typeof a != "object") return;
|
|
491
|
+
if (a.type === "component:input-select" && !p.has(a.id)) {
|
|
492
|
+
const r = C(a.name || "selectInput");
|
|
493
|
+
n.push({
|
|
494
|
+
id: a.id,
|
|
495
|
+
name: a.name || "Select Input",
|
|
496
|
+
propName: r,
|
|
497
|
+
_parentPath: [...e]
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
const y = [...e];
|
|
501
|
+
if (a.name && (a.type?.startsWith("container:") || a.type?.startsWith("component:"))) {
|
|
502
|
+
const r = a.name.trim(), h = /^frame\s*\d*$/i.test(r) || r.toUpperCase() === "FRAME";
|
|
503
|
+
r && !h && y.push(a.name);
|
|
504
|
+
}
|
|
505
|
+
a.body && Array.isArray(a.body) && a.body.forEach((r) => t(r, y)), a.containers && Array.isArray(a.containers) && a.containers.forEach(
|
|
506
|
+
(r) => t(r, y)
|
|
507
|
+
), a.components && Array.isArray(a.components) && a.components.forEach(
|
|
508
|
+
(r) => t(r, y)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
const m = c.data?.body || c.body || c.data?.body || [];
|
|
512
|
+
return Array.isArray(m) && m.length > 0 && m.forEach((a) => t(a)), G(n), n;
|
|
513
|
+
}
|
|
514
|
+
function G(c) {
|
|
515
|
+
const f = /* @__PURE__ */ new Map();
|
|
516
|
+
c.forEach((n) => {
|
|
517
|
+
const p = n, t = n.propName;
|
|
518
|
+
f.has(t) || f.set(t, []), f.get(t).push(p);
|
|
519
|
+
}), f.forEach((n, p) => {
|
|
520
|
+
if (n.length === 1) {
|
|
521
|
+
delete n[0]._parentPath;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
n.forEach((t) => {
|
|
525
|
+
const m = n.filter((e) => e.id !== t.id).map((e) => e._parentPath || []), a = L(
|
|
526
|
+
t._parentPath || [],
|
|
527
|
+
m
|
|
528
|
+
);
|
|
529
|
+
t.propName = U(
|
|
530
|
+
t.name || "input",
|
|
531
|
+
a
|
|
532
|
+
);
|
|
533
|
+
}), n.forEach((t) => {
|
|
534
|
+
delete t._parentPath;
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
function tt(c) {
|
|
539
|
+
const f = [];
|
|
540
|
+
function n(t, m = []) {
|
|
541
|
+
if (!t || typeof t != "object") return;
|
|
542
|
+
const a = Array.isArray(t.tags) && t.tags.some((r) => r.startsWith("action:")), e = t.actions && typeof t.actions == "object";
|
|
543
|
+
if (a || e) {
|
|
544
|
+
let r = "tap";
|
|
545
|
+
if (Array.isArray(t.tags)) {
|
|
546
|
+
const o = t.tags.find(
|
|
547
|
+
(u) => u.startsWith("action:")
|
|
548
|
+
);
|
|
549
|
+
o && (r = o.replace("action:", ""));
|
|
550
|
+
}
|
|
551
|
+
t.actions?.tap?.action && (r = t.actions.tap.action);
|
|
552
|
+
const h = C(t.name || "button");
|
|
553
|
+
f.push({
|
|
554
|
+
id: t.id,
|
|
555
|
+
name: t.name || "Button",
|
|
556
|
+
propName: h,
|
|
557
|
+
actionType: r,
|
|
558
|
+
_parentPath: [...m]
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
const y = [...m];
|
|
562
|
+
if (t.name && (t.type?.startsWith("container:") || t.type?.startsWith("component:"))) {
|
|
563
|
+
const r = t.name.trim(), h = /^frame\s*\d*$/i.test(r) || r.toUpperCase() === "FRAME";
|
|
564
|
+
r && !h && y.push(t.name);
|
|
565
|
+
}
|
|
566
|
+
t.body && Array.isArray(t.body) && t.body.forEach((r) => n(r, y)), t.containers && Array.isArray(t.containers) && t.containers.forEach(
|
|
567
|
+
(r) => n(r, y)
|
|
568
|
+
), t.components && Array.isArray(t.components) && t.components.forEach(
|
|
569
|
+
(r) => n(r, y)
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
const p = c.data?.body || c.body || c.data?.body || [];
|
|
573
|
+
return Array.isArray(p) && p.length > 0 && p.forEach((t) => n(t)), H(f), f;
|
|
574
|
+
}
|
|
575
|
+
function H(c) {
|
|
576
|
+
const f = /* @__PURE__ */ new Map();
|
|
577
|
+
c.forEach((n) => {
|
|
578
|
+
const p = n, t = n.propName;
|
|
579
|
+
f.has(t) || f.set(t, []), f.get(t).push(p);
|
|
580
|
+
}), f.forEach((n, p) => {
|
|
581
|
+
if (n.length === 1) {
|
|
582
|
+
delete n[0]._parentPath;
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
n.forEach((t) => {
|
|
586
|
+
const m = n.filter((e) => e.id !== t.id).map((e) => e._parentPath || []), a = L(
|
|
587
|
+
t._parentPath || [],
|
|
588
|
+
m
|
|
589
|
+
);
|
|
590
|
+
t.propName = U(
|
|
591
|
+
t.name || "button",
|
|
592
|
+
a
|
|
593
|
+
);
|
|
594
|
+
}), n.forEach((t) => {
|
|
595
|
+
delete t._parentPath;
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function et(c) {
|
|
600
|
+
c.forEach((f) => {
|
|
601
|
+
const n = f.inputs, p = /* @__PURE__ */ new Map();
|
|
602
|
+
n.forEach((t) => {
|
|
603
|
+
const m = t, a = t.propName;
|
|
604
|
+
p.has(a) || p.set(a, []), p.get(a).push(m);
|
|
605
|
+
}), p.forEach((t, m) => {
|
|
606
|
+
if (t.length === 1) {
|
|
607
|
+
delete t[0]._parentPath;
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
t.forEach((h) => {
|
|
611
|
+
const o = t.filter((i) => i.id !== h.id).map((i) => i._parentPath || []), u = L(
|
|
612
|
+
h._parentPath || [],
|
|
613
|
+
o
|
|
614
|
+
);
|
|
615
|
+
h.propName = U(
|
|
616
|
+
h.name || "input",
|
|
617
|
+
u
|
|
618
|
+
);
|
|
619
|
+
});
|
|
620
|
+
let a = !0, e = 0;
|
|
621
|
+
const y = 10;
|
|
622
|
+
for (; a && e < y; ) {
|
|
623
|
+
e++;
|
|
624
|
+
const h = /* @__PURE__ */ new Map();
|
|
625
|
+
t.forEach((o) => {
|
|
626
|
+
h.has(o.propName) || h.set(o.propName, []), h.get(o.propName).push(o);
|
|
627
|
+
}), a = !1, h.forEach((o, u) => {
|
|
628
|
+
o.length > 1 && (a = !0, o.forEach((i) => {
|
|
629
|
+
const A = i._parentPath || [], s = o.filter((d) => d.id !== i.id).map((d) => d._parentPath || []);
|
|
630
|
+
let l = 0;
|
|
631
|
+
const g = Math.min(
|
|
632
|
+
A.length,
|
|
633
|
+
...s.map((d) => d.length)
|
|
634
|
+
);
|
|
635
|
+
for (let d = 0; d < g; d++) {
|
|
636
|
+
const b = A[d];
|
|
637
|
+
if (s.every((N) => N[d] === b))
|
|
638
|
+
l++;
|
|
639
|
+
else
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
const P = A.slice(l);
|
|
643
|
+
let v = !1;
|
|
644
|
+
for (let d = 1; d <= P.length; d++) {
|
|
645
|
+
const b = P.slice(
|
|
646
|
+
0,
|
|
647
|
+
d
|
|
648
|
+
), _ = U(
|
|
649
|
+
i.name || "input",
|
|
650
|
+
b
|
|
651
|
+
);
|
|
652
|
+
if (n.every((E) => {
|
|
653
|
+
if (E.id === i.id) return !0;
|
|
654
|
+
if (o.some((x) => x.id === E.id)) {
|
|
655
|
+
const x = E._parentPath || [], W = Math.min(
|
|
656
|
+
l,
|
|
657
|
+
x.length
|
|
658
|
+
), I = x.slice(
|
|
659
|
+
W
|
|
660
|
+
).slice(
|
|
661
|
+
0,
|
|
662
|
+
d
|
|
663
|
+
), q = U(
|
|
664
|
+
E.name || "input",
|
|
665
|
+
I
|
|
666
|
+
);
|
|
667
|
+
return _ !== q;
|
|
668
|
+
}
|
|
669
|
+
return _ !== E.propName;
|
|
670
|
+
})) {
|
|
671
|
+
i.propName = _, v = !0;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
v || (i.propName = U(
|
|
676
|
+
i.name || "input",
|
|
677
|
+
P.length > 0 ? P : []
|
|
678
|
+
));
|
|
679
|
+
}));
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const r = /* @__PURE__ */ new Map();
|
|
683
|
+
t.forEach((h) => {
|
|
684
|
+
r.has(h.propName) || r.set(h.propName, []), r.get(h.propName).push(h);
|
|
685
|
+
}), r.forEach((h, o) => {
|
|
686
|
+
if (h.length > 1 && h.every((i) => {
|
|
687
|
+
const A = i._parentPath || [];
|
|
688
|
+
return h.every((s) => {
|
|
689
|
+
if (s.id === i.id) return !0;
|
|
690
|
+
const l = s._parentPath || [];
|
|
691
|
+
return Q(A, l);
|
|
692
|
+
});
|
|
693
|
+
})) {
|
|
694
|
+
let i = 0;
|
|
695
|
+
h.forEach((A) => {
|
|
696
|
+
i > 0 && (A.propName = `${o}${i + 1}`), i++;
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
}), t.forEach((h) => {
|
|
700
|
+
delete h._parentPath;
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
export {
|
|
706
|
+
Q as arraysEqual,
|
|
707
|
+
tt as findActionButtons,
|
|
708
|
+
Y as findForms,
|
|
709
|
+
X as findInputGroups,
|
|
710
|
+
L as findMinimalDistinguishingPath,
|
|
711
|
+
O as findSlidersAndDataBindings,
|
|
712
|
+
V as findStandaloneComponents,
|
|
713
|
+
D as findStandaloneSelectInputs,
|
|
714
|
+
U as generateQualifiedPropName,
|
|
715
|
+
K as getComponentPropName,
|
|
716
|
+
B as getComponentPropType,
|
|
717
|
+
et as qualifyFormInputs,
|
|
718
|
+
C as sanitizePropName
|
|
719
|
+
};
|
|
720
|
+
//# sourceMappingURL=parser.js.map
|