@bravostudioai/react 0.1.31 → 0.1.34

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 (83) hide show
  1. package/dist/cli/commands/download.js +22 -39
  2. package/dist/cli/commands/download.js.map +1 -1
  3. package/dist/cli/commands/generate.js +130 -147
  4. package/dist/cli/commands/generate.js.map +1 -1
  5. package/dist/cli.js +21 -24
  6. package/dist/cli.js.map +1 -1
  7. package/dist/codegen/generator.js +126 -125
  8. package/dist/codegen/generator.js.map +1 -1
  9. package/dist/codegen/parser.js +256 -593
  10. package/dist/codegen/parser.js.map +1 -1
  11. package/dist/codegen/propQualification.js +117 -0
  12. package/dist/codegen/propQualification.js.map +1 -0
  13. package/dist/components/DynamicComponent.js.map +1 -1
  14. package/dist/components/EncoreApp.js +156 -265
  15. package/dist/components/EncoreApp.js.map +1 -1
  16. package/dist/components/EncoreContextProviders.js +24 -0
  17. package/dist/components/EncoreContextProviders.js.map +1 -0
  18. package/dist/components.js +179 -174
  19. package/dist/components.js.map +1 -1
  20. package/dist/hooks/useFontLoader.js +41 -0
  21. package/dist/hooks/useFontLoader.js.map +1 -0
  22. package/dist/hooks/usePusherUpdates.js +41 -45
  23. package/dist/hooks/usePusherUpdates.js.map +1 -1
  24. package/dist/hooks/useRepeatingContainers.js +79 -0
  25. package/dist/hooks/useRepeatingContainers.js.map +1 -0
  26. package/dist/index.js +13 -14
  27. package/dist/index.js.map +1 -1
  28. package/dist/lib/dataPatching.js +24 -0
  29. package/dist/lib/dataPatching.js.map +1 -0
  30. package/dist/lib/dynamicModules.js +44 -45
  31. package/dist/lib/dynamicModules.js.map +1 -1
  32. package/dist/lib/fetcher.js +6 -13
  33. package/dist/lib/fetcher.js.map +1 -1
  34. package/dist/lib/logger.js +35 -0
  35. package/dist/lib/logger.js.map +1 -0
  36. package/dist/lib/moduleRegistry.js +9 -8
  37. package/dist/lib/moduleRegistry.js.map +1 -1
  38. package/dist/src/cli/commands/download.d.ts +1 -1
  39. package/dist/src/cli/commands/download.d.ts.map +1 -1
  40. package/dist/src/cli/commands/generate.d.ts +1 -1
  41. package/dist/src/cli/commands/generate.d.ts.map +1 -1
  42. package/dist/src/codegen/generator.d.ts +75 -1
  43. package/dist/src/codegen/generator.d.ts.map +1 -1
  44. package/dist/src/codegen/parser.d.ts +39 -0
  45. package/dist/src/codegen/parser.d.ts.map +1 -1
  46. package/dist/src/codegen/propQualification.d.ts +42 -0
  47. package/dist/src/codegen/propQualification.d.ts.map +1 -0
  48. package/dist/src/components/DynamicComponent.d.ts +1 -1
  49. package/dist/src/components/DynamicComponent.d.ts.map +1 -1
  50. package/dist/src/components/EncoreApp.d.ts +58 -3
  51. package/dist/src/components/EncoreApp.d.ts.map +1 -1
  52. package/dist/src/components/EncoreContextProviders.d.ts +34 -0
  53. package/dist/src/components/EncoreContextProviders.d.ts.map +1 -0
  54. package/dist/src/components.d.ts.map +1 -1
  55. package/dist/src/hooks/useFontLoader.d.ts +17 -0
  56. package/dist/src/hooks/useFontLoader.d.ts.map +1 -0
  57. package/dist/src/hooks/usePusherUpdates.d.ts.map +1 -1
  58. package/dist/src/hooks/useRepeatingContainers.d.ts +31 -0
  59. package/dist/src/hooks/useRepeatingContainers.d.ts.map +1 -0
  60. package/dist/src/index.d.ts +2 -0
  61. package/dist/src/index.d.ts.map +1 -1
  62. package/dist/src/lib/dataPatching.d.ts +18 -0
  63. package/dist/src/lib/dataPatching.d.ts.map +1 -0
  64. package/dist/src/lib/dynamicModules.d.ts.map +1 -1
  65. package/dist/src/lib/fetcher.d.ts.map +1 -1
  66. package/dist/src/lib/logger.d.ts +33 -0
  67. package/dist/src/lib/logger.d.ts.map +1 -0
  68. package/dist/src/lib/moduleRegistry.d.ts.map +1 -1
  69. package/dist/src/stores/useEncoreState.d.ts +43 -1
  70. package/dist/src/stores/useEncoreState.d.ts.map +1 -1
  71. package/dist/src/version.d.ts +1 -1
  72. package/dist/stores/useEncoreState.js.map +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/version.js.map +1 -1
  75. package/package.json +2 -1
  76. package/src/cli/commands/download.ts +8 -28
  77. package/src/cli/commands/generate.ts +44 -45
  78. package/src/cli/index.ts +49 -32
  79. package/src/codegen/generator.ts +6 -3
  80. package/src/components/DynamicComponent.tsx +1 -1
  81. package/src/components/EncoreApp.tsx +111 -21
  82. package/src/hooks/useRepeatingContainers.ts +1 -1
  83. package/src/version.ts +1 -1
@@ -1,720 +1,383 @@
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;
1
+ import { qualifyPropNames as E } from "./propQualification.js";
2
+ function g(i) {
3
+ const c = i.replace(/[^a-zA-Z0-9\s]/g, "").trim();
4
+ return c ? c.split(/\s+/).map((s, y) => {
5
+ if (!s) return "";
6
+ const t = s === s.toUpperCase() && s.length > 1 ? s.toLowerCase() : s, o = t.charAt(0), r = t.slice(1);
7
+ return y === 0 ? o.toLowerCase() + r : o.toUpperCase() + r;
7
8
  }).join("").replace(/^[0-9]/, "_$&") : "item";
8
9
  }
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;
10
+ function F(i, c) {
11
+ const s = g(i);
12
+ if (c.length === 0)
13
+ return s;
14
+ const y = c.filter((r) => r && r.trim()).reverse();
15
+ return y.length === 0 ? s : y.map(
16
+ (r) => g(r)
17
+ ).map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("") + s;
17
18
  }
18
- function L(c, f) {
19
- if (f.length === 0)
19
+ function S(i, c) {
20
+ if (c.length === 0)
20
21
  return [];
21
- let n = 0;
22
- const p = Math.min(
23
- c.length,
24
- ...f.map((m) => m.length)
22
+ let s = 0;
23
+ const y = Math.min(
24
+ i.length,
25
+ ...c.map((o) => o.length)
25
26
  );
26
- for (let m = 0; m < p; m++) {
27
- const a = c[m];
28
- if (f.every((y) => y[m] === a))
29
- n++;
27
+ for (let o = 0; o < y; o++) {
28
+ const r = i[o];
29
+ if (c.every((f) => f[o] === r))
30
+ s++;
30
31
  else
31
32
  break;
32
33
  }
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)
34
+ const t = i.slice(s);
35
+ for (let o = 1; o <= t.length; o++) {
36
+ const r = t.slice(0, o);
37
+ if (c.every((f) => {
38
+ if (f.length < s + o)
38
39
  return !0;
39
- const r = y.slice(
40
- n,
41
- n + m
40
+ const a = f.slice(
41
+ s,
42
+ s + o
42
43
  );
43
- return !Q(a, r);
44
+ return !W(r, a);
44
45
  }))
45
- return a;
46
+ return r;
46
47
  }
47
48
  return t;
48
49
  }
49
- function Q(c, f) {
50
- return c.length !== f.length ? !1 : c.every((n, p) => n === f[p]);
50
+ function W(i, c) {
51
+ return i.length !== c.length ? !1 : i.every((s, y) => s === c[y]);
51
52
  }
52
- function B(c, f) {
53
- return c === "component:image" || c === "component:text" || c?.startsWith("component:input-") ? "string" : "any";
53
+ function P(i, c) {
54
+ return i === "component:image" || i === "component:text" || i?.startsWith("component:input-") ? "string" : "any";
54
55
  }
55
- function K(c) {
56
- return c === "component:image" ? "imageUrl" : c === "component:text" ? "text" : "value";
56
+ function j(i) {
57
+ return i === "component:image" ? "imageUrl" : i === "component:text" ? "text" : "value";
57
58
  }
58
- function O(c) {
59
- const f = [];
60
- function n(t, m = []) {
59
+ function x(i) {
60
+ const c = [];
61
+ function s(t, o = []) {
61
62
  if (!(!t || typeof t != "object")) {
62
63
  if (t.type === "container:slider") {
63
- const a = {
64
+ const r = {
64
65
  id: t.id,
65
66
  name: t.name || "Slider",
66
67
  arrayContainer: null
67
68
  };
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;
69
+ let p = null;
70
+ const f = (a) => {
71
+ if (!p && !(!a || typeof a != "object")) {
72
+ if (Array.isArray(a.tags) && (a.tags.includes("encore:data:array") || a.tags.includes("bravo:data:array"))) {
73
+ p = a;
73
74
  return;
74
75
  }
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
+ a.body && Array.isArray(a.body) && a.body.forEach(f), a.containers && Array.isArray(a.containers) && a.containers.forEach(f), a.components && Array.isArray(a.components) && a.components.forEach(f);
76
77
  }
77
78
  };
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,
79
+ if (t.containers && Array.isArray(t.containers) && t.containers.forEach(f), !p && t.components && Array.isArray(t.components) && t.components.forEach(f), p) {
80
+ const a = p;
81
+ let u = [];
82
+ const n = [], l = (e, b = []) => {
83
+ if (!e || typeof e != "object") return;
84
+ if (e.type === "component:image" && n.push(e), Array.isArray(e.tags) && (e.tags.includes("encore:data") || e.tags.includes("bravo:data"))) {
85
+ const A = g(e.name || "item"), C = P(e.type, e.name);
86
+ u.push({
87
+ id: e.id,
88
+ name: e.name || "Unnamed",
89
+ type: e.type,
90
+ tags: e.tags || [],
91
+ propName: A,
91
92
  // Will be qualified later if needed
92
- propType: v,
93
+ propType: C,
93
94
  // Store parent path for later qualification
94
- _parentPath: [...l]
95
+ _parentPath: [...b]
95
96
  });
96
97
  }
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);
98
+ const h = [...b];
99
+ if (e.name && (e.type?.startsWith("container:") || e.type?.startsWith("component:"))) {
100
+ const A = e.name.trim(), C = /^frame\s*\d*$/i.test(A) || A.toUpperCase() === "FRAME";
101
+ A && !C && h.push(e.name);
101
102
  }
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)
103
+ e.body && Array.isArray(e.body) && e.body.forEach(
104
+ (A) => l(A, h)
105
+ ), e.containers && Array.isArray(e.containers) && e.containers.forEach(
106
+ (A) => l(A, h)
107
+ ), e.components && Array.isArray(e.components) && e.components.forEach(
108
+ (A) => l(A, h)
108
109
  );
109
110
  };
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,
111
+ if (a.components && Array.isArray(a.components) && a.components.forEach(
112
+ (e) => l(e, [])
113
+ ), !u.some(
114
+ (e) => e.type === "component:image"
115
+ ) && n.length > 0) {
116
+ const e = n[0], h = (e.name || "image").toLowerCase().includes("image") ? "imageUrl" : g(e.name || "image");
117
+ u.push({
118
+ id: e.id,
119
+ name: e.name || "Image",
120
+ type: e.type,
121
+ tags: e.tags || [],
122
+ propName: h,
122
123
  // Will be qualified later if needed
123
124
  propType: "string",
124
125
  // imageUrl is always string
125
126
  _parentPath: []
126
127
  });
127
128
  }
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"))
129
+ if (E(u), n.length > 0) {
130
+ const b = (n[0].name || "").toLowerCase();
131
+ u = u.filter((h) => {
132
+ if (h.type === "component:image") return !0;
133
+ if (h.type === "component:color") {
134
+ const A = (h.name || "").toLowerCase();
135
+ if (b.includes(A) || A.includes("image"))
233
136
  return !1;
234
137
  }
235
138
  return !0;
236
139
  });
237
140
  }
238
- a.arrayContainer = {
239
- id: r.id,
240
- name: r.name || "Item",
241
- propName: C(r.name || "items"),
242
- components: h
141
+ r.arrayContainer = {
142
+ id: a.id,
143
+ name: a.name || "Item",
144
+ propName: g(a.name || "items"),
145
+ components: u
243
146
  };
244
147
  }
245
- f.push(a);
148
+ c.push(r);
246
149
  }
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"])
150
+ t.body && Array.isArray(t.body) && t.body.forEach((r) => s(r, [...o, "body"])), t.containers && Array.isArray(t.containers) && t.containers.forEach(
151
+ (r) => s(r, [...o, "containers"])
249
152
  ), t.components && Array.isArray(t.components) && t.components.forEach(
250
- (a) => n(a, [...m, "components"])
153
+ (r) => s(r, [...o, "components"])
251
154
  );
252
155
  }
253
156
  }
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;
157
+ const y = i.data?.body || i.body || i.data?.body || [];
158
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), c;
256
159
  }
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));
160
+ function N(i) {
161
+ const c = [], s = /* @__PURE__ */ new Set();
162
+ function y(r) {
163
+ !r || typeof r != "object" || (r.type === "container:slider" && s.add(r.id), r.body && Array.isArray(r.body) && r.body.forEach(y), r.containers && Array.isArray(r.containers) && r.containers.forEach(y));
261
164
  }
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,
165
+ function t(r, p, f = []) {
166
+ if (!r || typeof r != "object" || p && s.has(p)) return;
167
+ if (Array.isArray(r.tags) && (r.tags.includes("encore:data") || r.tags.includes("bravo:data")) && (r.type === "component:text" || r.type === "component:image")) {
168
+ const n = g(r.name || "item"), l = P(r.type, r.name);
169
+ c.push({
170
+ id: r.id,
171
+ name: r.name || "Unnamed",
172
+ type: r.type,
173
+ tags: r.tags || [],
174
+ propName: n,
272
175
  // Will be qualified later if needed
273
- propType: i,
176
+ propType: l,
274
177
  // Store parent path for later qualification
275
- _parentPath: [...r]
178
+ _parentPath: [...f]
276
179
  });
277
180
  }
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);
181
+ const a = [...f];
182
+ if (r.name && (r.type?.startsWith("container:") || r.type?.startsWith("component:"))) {
183
+ const n = r.name.trim(), l = /^frame\s*\d*$/i.test(n) || n.toUpperCase() === "FRAME";
184
+ n && !l && a.push(r.name);
282
185
  }
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)
186
+ const u = r.id;
187
+ r.body && Array.isArray(r.body) && r.body.forEach(
188
+ (n) => t(n, u, a)
189
+ ), r.containers && Array.isArray(r.containers) && r.containers.forEach(
190
+ (n) => t(n, u, a)
191
+ ), r.components && Array.isArray(r.components) && r.components.forEach(
192
+ (n) => t(n, u, a)
290
193
  );
291
194
  }
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;
195
+ const o = i.data?.body || i.body || i.data?.body || [];
196
+ return Array.isArray(o) && o.length > 0 && (o.forEach(y), o.forEach((r) => t(r))), E(c), c;
391
197
  }
392
- function X(c) {
393
- const f = /* @__PURE__ */ new Map();
394
- function n(t) {
198
+ function d(i) {
199
+ const c = /* @__PURE__ */ new Map();
200
+ function s(t) {
395
201
  if (!(!t || typeof t != "object")) {
396
202
  if (t.type === "component:input-stateful-set" && Array.isArray(t.tags)) {
397
- const m = t.tags.find(
398
- (a) => a.startsWith("input-group:")
203
+ const o = t.tags.find(
204
+ (r) => r.startsWith("input-group:")
399
205
  );
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,
206
+ if (o) {
207
+ const r = o.split(":");
208
+ if (r.length >= 3) {
209
+ const p = r[1], f = r[2];
210
+ c.has(f) || c.set(f, {
211
+ groupName: f,
212
+ groupType: p,
407
213
  elements: []
408
- }), f.get(y).elements.push({
214
+ }), c.get(f).elements.push({
409
215
  id: t.id,
410
216
  name: t.name || "Unnamed"
411
217
  });
412
218
  }
413
219
  }
414
220
  }
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);
221
+ t.body && Array.isArray(t.body) && t.body.forEach(s), t.containers && Array.isArray(t.containers) && t.containers.forEach(s), t.components && Array.isArray(t.components) && t.components.forEach(s);
416
222
  }
417
223
  }
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());
224
+ const y = i.data?.body || i.body || i.data?.body || [];
225
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), Array.from(c.values());
420
226
  }
421
- function Y(c) {
422
- const f = [];
423
- function n(t, m) {
227
+ function M(i) {
228
+ const c = [];
229
+ function s(t, o) {
424
230
  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;
231
+ const r = t.type?.startsWith("container:") || t.type === "container:default", p = t.name?.toLowerCase().includes("form") || Array.isArray(t.tags) && t.tags.includes("form");
232
+ let f = !1, a;
233
+ function u(n) {
234
+ if (!(!n || typeof n != "object")) {
235
+ if (Array.isArray(n.tags) && (n.tags.includes("action:submit") || n.tags.includes("submit"))) {
236
+ f = !0, a = n.id;
431
237
  return;
432
238
  }
433
- if (o.actions?.tap?.action === "submit") {
434
- y = !0, r = o.id;
239
+ if (n.actions?.tap?.action === "submit") {
240
+ f = !0, a = n.id;
435
241
  return;
436
242
  }
437
- o.components && Array.isArray(o.components) && o.components.forEach(h), o.body && Array.isArray(o.body) && o.body.forEach(h);
243
+ n.components && Array.isArray(n.components) && n.components.forEach(u), n.body && Array.isArray(n.body) && n.body.forEach(u);
438
244
  }
439
245
  }
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,
246
+ if (r && (p || o === void 0) && u(t), r && (f || p)) {
247
+ const n = [], l = (m, e = []) => {
248
+ if (!m || typeof m != "object") return;
249
+ if (m.type?.startsWith("component:input-") || m.type === "component:input-text" || m.type === "component:input-image" || m.type === "component:input-email" || m.type === "component:input-password" || m.type === "component:input-select") {
250
+ const h = g(m.name || "Unnamed input");
251
+ n.push({
252
+ id: m.id,
253
+ name: m.name || "Unnamed input",
254
+ type: m.type,
255
+ propName: h,
450
256
  // Will be qualified later if needed
451
- _parentPath: [...A]
257
+ _parentPath: [...e]
452
258
  // Store parent path for qualification
453
259
  });
454
260
  }
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);
261
+ const b = [...e];
262
+ if (m.name && (m.type?.startsWith("container:") || m.type?.startsWith("component:"))) {
263
+ const h = m.name.trim(), A = /^frame\s*\d*$/i.test(h) || h.toUpperCase() === "FRAME";
264
+ h && !A && b.push(m.name);
459
265
  }
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));
266
+ m.components && Array.isArray(m.components) && m.components.forEach(
267
+ (h) => l(h, b)
268
+ ), m.body && Array.isArray(m.body) && m.body.forEach((h) => l(h, b));
463
269
  };
464
- u(t, []), o.length > 0 && f.push({
270
+ l(t, []), n.length > 0 && c.push({
465
271
  formId: t.id,
466
272
  formName: t.name || "Form",
467
- submitButtonId: r,
468
- inputs: o
273
+ submitButtonId: a,
274
+ inputs: n
469
275
  });
470
276
  }
471
277
  t.body && Array.isArray(t.body) && t.body.forEach(
472
- (o) => n(o, a ? t : m)
278
+ (n) => s(n, r ? t : o)
473
279
  ), t.containers && Array.isArray(t.containers) && t.containers.forEach(
474
- (o) => n(o, a ? t : m)
280
+ (n) => s(n, r ? t : o)
475
281
  ), t.components && Array.isArray(t.components) && t.components.forEach(
476
- (o) => n(o, a ? t : m)
282
+ (n) => s(n, r ? t : o)
477
283
  );
478
284
  }
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;
285
+ const y = i.data?.body || i.body || i.data?.body || [];
286
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), c;
481
287
  }
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);
288
+ function L(i, c) {
289
+ const s = [], y = /* @__PURE__ */ new Set();
290
+ c.forEach((r) => {
291
+ r.inputs.forEach((p) => {
292
+ y.add(p.id);
487
293
  });
488
294
  });
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]
295
+ function t(r, p = []) {
296
+ if (!r || typeof r != "object") return;
297
+ if (r.type === "component:input-select" && !y.has(r.id)) {
298
+ const a = g(r.name || "selectInput");
299
+ s.push({
300
+ id: r.id,
301
+ name: r.name || "Select Input",
302
+ propName: a,
303
+ _parentPath: [...p]
498
304
  });
499
305
  }
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);
306
+ const f = [...p];
307
+ if (r.name && (r.type?.startsWith("container:") || r.type?.startsWith("component:"))) {
308
+ const a = r.name.trim(), u = /^frame\s*\d*$/i.test(a) || a.toUpperCase() === "FRAME";
309
+ a && !u && f.push(r.name);
504
310
  }
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)
311
+ r.body && Array.isArray(r.body) && r.body.forEach((a) => t(a, f)), r.containers && Array.isArray(r.containers) && r.containers.forEach(
312
+ (a) => t(a, f)
313
+ ), r.components && Array.isArray(r.components) && r.components.forEach(
314
+ (a) => t(a, f)
509
315
  );
510
316
  }
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;
317
+ const o = i.data?.body || i.body || i.data?.body || [];
318
+ return Array.isArray(o) && o.length > 0 && o.forEach((r) => t(r)), I(s), s;
513
319
  }
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
- });
320
+ function I(i) {
321
+ E(i);
537
322
  }
538
- function tt(c) {
539
- const f = [];
540
- function n(t, m = []) {
323
+ function _(i) {
324
+ const c = [];
325
+ function s(t, o = []) {
541
326
  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";
327
+ const r = Array.isArray(t.tags) && t.tags.some((a) => a.startsWith("action:")), p = t.actions && typeof t.actions == "object";
328
+ if (r || p) {
329
+ let a = "tap";
545
330
  if (Array.isArray(t.tags)) {
546
- const o = t.tags.find(
547
- (u) => u.startsWith("action:")
331
+ const n = t.tags.find(
332
+ (l) => l.startsWith("action:")
548
333
  );
549
- o && (r = o.replace("action:", ""));
334
+ n && (a = n.replace("action:", ""));
550
335
  }
551
- t.actions?.tap?.action && (r = t.actions.tap.action);
552
- const h = C(t.name || "button");
553
- f.push({
336
+ t.actions?.tap?.action && (a = t.actions.tap.action);
337
+ const u = g(t.name || "button");
338
+ c.push({
554
339
  id: t.id,
555
340
  name: t.name || "Button",
556
- propName: h,
557
- actionType: r,
558
- _parentPath: [...m]
341
+ propName: u,
342
+ actionType: a,
343
+ _parentPath: [...o]
559
344
  });
560
345
  }
561
- const y = [...m];
346
+ const f = [...o];
562
347
  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);
348
+ const a = t.name.trim(), u = /^frame\s*\d*$/i.test(a) || a.toUpperCase() === "FRAME";
349
+ a && !u && f.push(t.name);
565
350
  }
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)
351
+ t.body && Array.isArray(t.body) && t.body.forEach((a) => s(a, f)), t.containers && Array.isArray(t.containers) && t.containers.forEach(
352
+ (a) => s(a, f)
568
353
  ), t.components && Array.isArray(t.components) && t.components.forEach(
569
- (r) => n(r, y)
354
+ (a) => s(a, f)
570
355
  );
571
356
  }
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;
357
+ const y = i.data?.body || i.body || i.data?.body || [];
358
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), v(c), c;
574
359
  }
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
- });
360
+ function v(i) {
361
+ E(i);
598
362
  }
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
- });
363
+ function q(i) {
364
+ i.forEach((c) => {
365
+ E(c.inputs);
703
366
  });
704
367
  }
705
368
  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
369
+ W as arraysEqual,
370
+ _ as findActionButtons,
371
+ M as findForms,
372
+ d as findInputGroups,
373
+ S as findMinimalDistinguishingPath,
374
+ x as findSlidersAndDataBindings,
375
+ N as findStandaloneComponents,
376
+ L as findStandaloneSelectInputs,
377
+ F as generateQualifiedPropName,
378
+ j as getComponentPropName,
379
+ P as getComponentPropType,
380
+ q as qualifyFormInputs,
381
+ g as sanitizePropName
719
382
  };
720
383
  //# sourceMappingURL=parser.js.map