@metamorph-labs/polymorph-screen 1.0.17 → 1.0.18

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.
@@ -1,30 +1,92 @@
1
1
  import { A as e, c as t, d as n, f as r, g as i, i as a, l as o, n as s, o as c, s as l } from "./members-CPUURBV9.js";
2
- import { D as u, c as d, d as f, f as p, g as m, h, i as g, k as _, l as v, m as ee, n as te, o as ne, p as re, r as ie, s as ae, t as oe, u as y, x as b } from "./receivers-1COQpnEw.js";
3
- import { d as x, i as se, l as S, o as C, s as w, t as T, u as E } from "./urls-DMQZeRPI.js";
4
- import { t as D } from "./vocabulary-uhojNKy_.js";
2
+ import { D as u, c as d, d as f, f as p, g as m, h, i as g, k as _, l as v, m as y, n as ee, o as te, p as ne, r as re, s as ie, t as ae, u as b, x } from "./receivers-1COQpnEw.js";
3
+ import { d as S, i as oe, l as C, o as w, s as T, t as E, u as D } from "./urls-DMQZeRPI.js";
4
+ import { t as O } from "./vocabulary-C8KzYJUx.js";
5
+ var se = "solid", ce = "accent", le = "danger";
6
+ function ue(e, t) {
7
+ let n = e === void 0 ? se : e, r = t === void 0 ? ce : t;
8
+ return n !== null && n !== "solid" || r !== null && r !== "accent" ? !1 : n === null || r === null ? null : !0;
9
+ }
10
+ function k(e) {
11
+ return e === null ? null : e === le;
12
+ }
13
+ var de = {
14
+ Dialog: {
15
+ kind: "dialog",
16
+ outside: ["trigger"]
17
+ },
18
+ Drawer: {
19
+ kind: "dialog",
20
+ outside: []
21
+ },
22
+ Popover: {
23
+ kind: "dialog",
24
+ outside: ["trigger"]
25
+ },
26
+ Card: {
27
+ kind: "section",
28
+ outside: []
29
+ },
30
+ "Dashboard.Panel": {
31
+ kind: "section",
32
+ outside: []
33
+ }
34
+ };
35
+ function fe(e) {
36
+ let t = e.replace(".", "");
37
+ for (let [e, n] of Object.entries(de)) if (e.replace(".", "") === t) return {
38
+ name: e,
39
+ scope: n
40
+ };
41
+ return null;
42
+ }
43
+ function pe(e, t) {
44
+ return e.some(([e, n]) => t.some(([t, r]) => e === t && n !== r));
45
+ }
46
+ function me(e) {
47
+ let t = [];
48
+ return e.forEach((n, r) => {
49
+ e.slice(0, r).some((e) => !pe(e, n)) && t.push(r);
50
+ }), t;
51
+ }
52
+ function he(e, t) {
53
+ let n = [[]];
54
+ for (let r of e) t(r) ? n.push([]) : n[n.length - 1]?.push(r);
55
+ return n.filter((e) => e.length > 0);
56
+ }
57
+ function ge(e) {
58
+ let t = [];
59
+ return e.forEach((n, r) => {
60
+ n.some((e) => k(e) === !0) && e.slice(r + 1).some((e) => e.some((e) => k(e) === !1)) && t.push(r);
61
+ }), t;
62
+ }
63
+ function _e(e, t) {
64
+ return t.includes(e);
65
+ }
66
+ //#endregion
5
67
  //#region ../spec/src/validate.ts
6
- var O = [
68
+ var A = [
7
69
  2,
8
70
  3,
9
71
  4
10
- ], k = new Set([
72
+ ], j = new Set([
11
73
  "break case catch class const continue debugger default delete do else enum export extends",
12
74
  "false finally for function if import in instanceof new null return super switch this throw",
13
75
  "true try typeof var void while with",
14
76
  "await implements interface let package private protected public static yield",
15
77
  "arguments eval"
16
- ].flatMap((e) => e.split(" "))), ce = "patch", le = "a binding is `{ \"$\": \"anInput\" }`, an element is `{ \"component\": … }`, and a plain object, such as a column or an option, is written `{ \"$object\": { … } }`";
17
- function ue(t, n, r = {}, i = {}) {
18
- let a = j(n, "$");
78
+ ].flatMap((e) => e.split(" "))), ve = "patch", ye = "a binding is `{ \"$\": \"anInput\" }`, an element is `{ \"component\": … }`, and a plain object, such as a column or an option, is written `{ \"$object\": { … } }`";
79
+ function be(t, n, r = {}, i = {}) {
80
+ let a = P(n, "$");
19
81
  if (a.length > 0) return {
20
82
  ok: !1,
21
83
  faults: a
22
84
  };
23
- let o = new Map(t.components.map((e) => [e.name, e])), s = new Map(t.exceptions.primitives.map((e) => [e.name, e])), c = M(n, "$", (e) => G(e, o, s)), l = e(w, n).map((e) => {
85
+ let o = new Map(t.components.map((e) => [e.name, e])), s = new Map(t.exceptions.primitives.map((e) => [e.name, e])), c = F(n, "$", (e) => W(e, o, s)), l = e(T, n).map((e) => {
24
86
  let [t = "$", ...n] = e.split(": "), r = n.join(": ");
25
87
  return {
26
88
  path: t,
27
- message: c.get(t) ?? (r.startsWith("an object here has ") ? `${r} — ${le}` : r)
89
+ message: c.get(t) ?? (r.startsWith("an object here has ") ? `${r} — ${ye}` : r)
28
90
  };
29
91
  });
30
92
  if (l.length > 0) return {
@@ -37,18 +99,18 @@ function ue(t, n, r = {}, i = {}) {
37
99
  message: `${/^[aeiou]/.test(f) ? "an" : "a"} ${f} screen runs on the web, and this one names ${d} — remove \`platform\`, or validate it without a framework`
38
100
  });
39
101
  let m = new Set(u.inputs.map((e) => e.name)), h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
40
- de(u, p), me(u, p, r.inputType), ve(u, p);
102
+ xe(u, p), Ce(u, p, r.inputType), De(u, p);
41
103
  let _ = (e, n, r) => {
42
104
  if (Array.isArray(e)) {
43
- let t = r || e.some((e) => !Array.isArray(e) && E(e));
105
+ let t = r || e.some((e) => !Array.isArray(e) && D(e));
44
106
  e.forEach((e, r) => _(e, `${n}[${r}]`, t));
45
- } else if (S(e)) {
107
+ } else if (C(e)) {
46
108
  let [t] = e.$.split(".");
47
109
  (t === void 0 || !m.has(t)) && p.push({
48
110
  path: n,
49
111
  message: `\`${e.$}\` binds to "${t}", which the screen does not declare as an input`
50
112
  });
51
- } else if (x(e)) {
113
+ } else if (S(e)) {
52
114
  if (r) {
53
115
  p.push({
54
116
  path: n,
@@ -56,30 +118,30 @@ function ue(t, n, r = {}, i = {}) {
56
118
  });
57
119
  return;
58
120
  }
59
- Z(t, e.$object, n, p);
121
+ X(t, e.$object, n, p);
60
122
  for (let [t, r] of Object.entries(e.$object)) _(r, `${n}.${t}`, !1);
61
- } else E(e) && v(e, n);
123
+ } else D(e) && v(e, n);
62
124
  }, v = (e, n) => {
63
- let r = e.props ?? {}, i = U(G(e.component, o, s), e.component, d);
125
+ let r = e.props ?? {}, i = H(W(e.component, o, s), e.component, d);
64
126
  if (h.add(e.component.split(".")[0] ?? e.component), g.add(e.component), i === null) p.push({
65
127
  path: n,
66
- message: `no component called \`${e.component}\`` + (Ae(e.component, o, d, f) ?? Ie(t, e.component, o, s))
128
+ message: `no component called \`${e.component}\`` + (Ue(e.component, o, d, f) ?? Xe(t, e.component, o, s))
67
129
  });
68
130
  else {
69
- je(e, i, d, n, p), Me(e, i, f, n, p);
70
- let a = J(e.component, i, d, f);
131
+ We(e, i, d, n, p), Ge(e, i, f, n, p);
132
+ let a = q(e.component, i, d, f);
71
133
  a !== null && p.push({
72
134
  path: n,
73
135
  message: a
74
136
  });
75
137
  for (let t of Object.keys(r)) i.props.has(t) || p.push({
76
138
  path: `${n}.props.${t}`,
77
- message: `\`${e.component}\` has no prop \`${t}\`${Re(t, i.props)}`
139
+ message: `\`${e.component}\` has no prop \`${t}\`${Qe(t, i.props)}`
78
140
  });
79
141
  for (let [t, a] of Object.entries(r)) {
80
142
  let r = i.types.get(t);
81
143
  if (!r) continue;
82
- let o = Ne(r.type, a);
144
+ let o = Ke(r.type, a);
83
145
  o !== null && p.push({
84
146
  path: `${n}.props.${t}`,
85
147
  message: `\`${e.component}\` prop \`${t}\` wants \`${r.type}\`, got ${o}`
@@ -89,25 +151,25 @@ function ue(t, n, r = {}, i = {}) {
89
151
  path: n,
90
152
  message: `\`${e.component}\` is missing its required prop \`${t}\``
91
153
  });
92
- i.component && i.part === void 0 && Pe(i.component, r, n, p), Z(t, r, n, p), e.children !== void 0 && !i.props.has("children") && p.push({
154
+ i.component && i.part === void 0 && qe(i.component, r, n, p), X(t, r, n, p), e.children !== void 0 && !i.props.has("children") && p.push({
93
155
  path: n,
94
156
  message: `\`${e.component}\` takes no children`
95
157
  });
96
158
  }
97
- Fe(e, i, n, p);
159
+ Ye(e, i, n, p);
98
160
  for (let [e, t] of Object.entries(r)) _(t, `${n}.props.${e}`, !1);
99
161
  (e.children ?? []).forEach((e, t) => _(e, `${n}.children[${t}]`, !0));
100
162
  };
101
- return v(u.root, "$.root"), ye(u, F(h, g, f), p), I(d) && Oe(u, d, o, s, p, r), {
163
+ return v(u.root, "$.root"), Je(u.root, t.icons.trailing, p), je(u, Ae(h, g, f), p), I(d) && Ve(u, d, o, s, p, r), {
102
164
  ok: p.length === 0,
103
165
  faults: p
104
166
  };
105
167
  }
106
- function de(e, t) {
168
+ function xe(e, t) {
107
169
  let n = /* @__PURE__ */ new Set();
108
170
  e.inputs.forEach((e, r) => {
109
171
  let i = `$.inputs[${r}].name`;
110
- k.has(e.name) && t.push({
172
+ j.has(e.name) && t.push({
111
173
  path: i,
112
174
  message: `\`${e.name}\` is a word the language has taken — the emitted component destructures its inputs, and no parameter can be called that`
113
175
  }), n.has(e.name) && t.push({
@@ -116,72 +178,72 @@ function de(e, t) {
116
178
  }), n.add(e.name);
117
179
  });
118
180
  }
119
- function fe(e) {
181
+ function M(e) {
120
182
  return e.length <= 1 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
121
183
  }
122
- function A(e) {
184
+ function N(e) {
123
185
  let t = e.replace(/\s+/g, " ");
124
186
  return t.length <= 60 ? t : `${t.slice(0, 57)}…`;
125
187
  }
126
- function j(e, t) {
127
- if (Array.isArray(e)) return e.flatMap((e, n) => j(e, `${t}[${n}]`));
188
+ function P(e, t) {
189
+ if (Array.isArray(e)) return e.flatMap((e, n) => P(e, `${t}[${n}]`));
128
190
  if (typeof e != "object" || !e) return [];
129
191
  let n = e, r = n.$;
130
- return typeof r == "string" && !C.test(r) ? [{
192
+ return typeof r == "string" && !w.test(r) ? [{
131
193
  path: t,
132
- message: `\`${A(r)}\` is not a binding — a binding names an input and, with dots, a path into it (\`draft.subject\`). It cannot hold an expression: a call, an index, a condition or an element is computed by the container that renders this screen, and handed in as an input`
133
- }] : Object.entries(n).flatMap(([e, n]) => j(n, `${t}.${e}`));
194
+ message: `\`${N(r)}\` is not a binding — a binding names an input and, with dots, a path into it (\`draft.subject\`). It cannot hold an expression: a call, an index, a condition or an element is computed by the container that renders this screen, and handed in as an input`
195
+ }] : Object.entries(n).flatMap(([e, n]) => P(n, `${t}.${e}`));
134
196
  }
135
- var pe = /* @__PURE__ */ new Set([
197
+ var Se = /* @__PURE__ */ new Set([
136
198
  "component",
137
199
  "props",
138
200
  "children",
139
201
  "exception"
140
202
  ]);
141
- function M(e, t, n, r = /* @__PURE__ */ new Map()) {
142
- if (Array.isArray(e)) return e.forEach((e, i) => M(e, `${t}[${i}]`, n, r)), r;
203
+ function F(e, t, n, r = /* @__PURE__ */ new Map()) {
204
+ if (Array.isArray(e)) return e.forEach((e, i) => F(e, `${t}[${i}]`, n, r)), r;
143
205
  if (typeof e != "object" || !e) return r;
144
206
  let i = e, a = i.component, o = typeof a == "string" ? n(a)?.props : void 0;
145
207
  for (let [e, s] of Object.entries(i)) {
146
- if (o?.has(e) === !0 && !pe.has(e)) {
147
- let n = A(String(a));
208
+ if (o?.has(e) === !0 && !Se.has(e)) {
209
+ let n = N(String(a));
148
210
  r.set(`${t}.${e}`, `\`${e}\` is a prop of \`${n}\`, written here as a field of the element — a prop goes inside \`props\`: \`{ "component": "${n}", "props": { "${e}": … } }\``);
149
211
  }
150
- M(s, `${t}.${e}`, n, r);
212
+ F(s, `${t}.${e}`, n, r);
151
213
  }
152
214
  return r;
153
215
  }
154
- function me(e, t, n) {
216
+ function Ce(e, t, n) {
155
217
  n !== void 0 && e.inputs.forEach((e, r) => {
156
218
  let i = n(e.type);
157
219
  i !== null && t.push({
158
220
  path: `$.inputs[${r}].type`,
159
- message: `\`${A(e.type)}\` ${i} — an input's type is one TypeScript type, written into the props interface as it stands`
221
+ message: `\`${N(e.type)}\` ${i} — an input's type is one TypeScript type, written into the props interface as it stands`
160
222
  });
161
223
  });
162
224
  }
163
- var he = /^[A-Za-z_$][A-Za-z0-9_$]*$/, ge = /^[^\s'"`\\]+$/, _e = "A spec has no default or namespace import: name the type itself (`ReactNode`), and write it in the input’s type without the namespace (`ReactNode`, not `React.ReactNode`)";
164
- function ve(e, t) {
165
- for (let [n, r] of Object.entries(e.types ?? {})) ge.test(n) || t.push({
166
- path: `$.types.${A(n)}`,
225
+ var we = /^[A-Za-z_$][A-Za-z0-9_$]*$/, Te = /^[^\s'"`\\]+$/, Ee = "A spec has no default or namespace import: name the type itself (`ReactNode`), and write it in the input’s type without the namespace (`ReactNode`, not `React.ReactNode`)";
226
+ function De(e, t) {
227
+ for (let [n, r] of Object.entries(e.types ?? {})) Te.test(n) || t.push({
228
+ path: `$.types.${N(n)}`,
167
229
  message: "is not a module specifier — it is written between the quotes of an import, so it holds no quote, backslash or space"
168
230
  }), r.forEach((e, r) => {
169
- (!he.test(e) || k.has(e)) && t.push({
170
- path: `$.types.${A(n)}[${r}]`,
171
- message: `\`${A(e)}\` is not a type name — an import names identifiers` + (/\bas\b|\*/.test(e) ? `. ${_e}` : "")
231
+ (!we.test(e) || j.has(e)) && t.push({
232
+ path: `$.types.${N(n)}[${r}]`,
233
+ message: `\`${N(e)}\` is not a type name — an import names identifiers` + (/\bas\b|\*/.test(e) ? `. ${Ee}` : "")
172
234
  });
173
235
  });
174
236
  }
175
- var N = (e) => e.replace(".", ""), P = ["Component", "input"];
176
- function F(e, t, n) {
237
+ var Oe = (e) => e.replace(".", ""), ke = ["Component", "input"];
238
+ function Ae(e, t, n) {
177
239
  let r = /* @__PURE__ */ new Map();
178
240
  for (let t of e) r.set(t, "a member this screen composes");
179
241
  if (n !== "angular") return r;
180
- for (let e of P) r.set(e, "a name from `@angular/core`");
181
- for (let e of t) r.set(N(e), "a member or part this screen composes");
242
+ for (let e of ke) r.set(e, "a name from `@angular/core`");
243
+ for (let e of t) r.set(Oe(e), "a member or part this screen composes");
182
244
  return r;
183
245
  }
184
- function ye(e, t, n) {
246
+ function je(e, t, n) {
185
247
  let r = new Map(t);
186
248
  for (let [t, n] of Object.entries(e.types ?? {})) for (let e of n) r.set(e, `a type it imports from \`${t}\``);
187
249
  for (let t of [e.name, `${e.name}Props`]) {
@@ -192,35 +254,35 @@ function ye(e, t, n) {
192
254
  });
193
255
  }
194
256
  }
195
- var I = (e) => e === "ios" || e === "android", be = {
257
+ var I = (e) => e === "ios" || e === "android", Me = {
196
258
  ios: "Swift",
197
259
  android: "Kotlin"
198
260
  }, L = {
199
261
  ios: "SwiftUI",
200
262
  android: "Compose"
201
- }, xe = {
263
+ }, Ne = {
202
264
  ios: "packages/native/src/pending.ts",
203
265
  android: "packages/native/src/kotlin-pending.ts"
204
- }, R = "AppShell", Se = "archetypes", z = ["empty", "pending"], B = {
266
+ }, R = "AppShell", Pe = "archetypes", Fe = ["empty", "pending"], z = {
205
267
  name: "onRetry",
206
268
  type: "(() => void) | undefined",
207
269
  optional: !0
208
- }, Ce = new Set([
270
+ }, Ie = new Set([
209
271
  "Any Self Type as associatedtype async await break case catch class continue default defer",
210
272
  "deinit do else enum extension fallthrough false fileprivate for func guard if import in init",
211
273
  "inout internal is let nil operator private protocol public repeat rethrows return self static",
212
274
  "struct subscript super switch throw throws true try typealias var where while"
213
- ].flatMap((e) => e.split(" "))), we = new Set(["as break class continue do else false for fun if in interface is null object package return", "super this throw true try typealias typeof val var when while"].flatMap((e) => e.split(" "))), Te = /* @__PURE__ */ new Set([
214
- ...we,
275
+ ].flatMap((e) => e.split(" "))), Le = new Set(["as break class continue do else false for fun if in interface is null object package return", "super this throw true try typealias typeof val var when while"].flatMap((e) => e.split(" "))), Re = /* @__PURE__ */ new Set([
276
+ ...Le,
215
277
  "equals",
216
278
  "hashCode",
217
279
  "toString"
218
280
  ]);
219
- function V(e) {
281
+ function B(e) {
220
282
  return e.replace(/(View|Screen)$/, "");
221
283
  }
222
- function Ee(e, t) {
223
- let n = V(t);
284
+ function ze(e, t) {
285
+ let n = B(t);
224
286
  return e === "ios" ? [
225
287
  `${n}Model`,
226
288
  `${n}Actions`,
@@ -232,7 +294,7 @@ function Ee(e, t) {
232
294
  `${n}Inert`
233
295
  ];
234
296
  }
235
- var De = {
297
+ var Be = {
236
298
  ios: /* @__PURE__ */ new Set([
237
299
  "AnyView",
238
300
  "EmptyView",
@@ -241,18 +303,18 @@ var De = {
241
303
  "View"
242
304
  ]),
243
305
  android: /* @__PURE__ */ new Set(["Composable", "Text"])
244
- }, H = (e) => e !== void 0 && e.tier === Se && e.name !== R;
245
- function U(e, t, n) {
246
- if (e === null || !I(n) || !H(e.component) || t !== e.component?.name || e.props.has(B.name)) return e;
306
+ }, V = (e) => e !== void 0 && e.tier === Pe && e.name !== R;
307
+ function H(e, t, n) {
308
+ if (e === null || !I(n) || !V(e.component) || t !== e.component?.name || e.props.has(z.name)) return e;
247
309
  let r = new Map(e.types);
248
- return r.set(B.name, B), {
310
+ return r.set(z.name, z), {
249
311
  ...e,
250
312
  props: new Set(r.keys()),
251
313
  types: r
252
314
  };
253
315
  }
254
- function Oe(e, t, n, r, i, a) {
255
- let o = be[t], s = t === "ios" ? Ce : Te, c = new Set(e.inputs.filter((e) => _(e.type)).map((e) => e.name));
316
+ function Ve(e, t, n, r, i, a) {
317
+ let o = Me[t], s = t === "ios" ? Ie : Re, c = new Set(e.inputs.filter((e) => _(e.type)).map((e) => e.name));
256
318
  e.inputs.forEach((t, n) => {
257
319
  let r = `$.inputs[${n}]`;
258
320
  t.name === "loadStatus" ? i.push({
@@ -267,31 +329,31 @@ function Oe(e, t, n, r, i, a) {
267
329
  let l = a.nativeType(t, e);
268
330
  l !== null && i.push({
269
331
  path: `${r}.type`,
270
- message: `\`${A(t.type)}\` ${l}`
332
+ message: `\`${N(t.type)}\` ${l}`
271
333
  });
272
- }), H(n.get(e.root.component)) || i.push({
334
+ }), V(n.get(e.root.component)) || i.push({
273
335
  path: "$.root",
274
336
  message: `a native screen’s root is a page archetype that draws the four load states, and \`${e.root.component}\` is not one — use ListPage, DetailPage, FormPage, Dashboard, SettingsPage, MasterDetailPage, SearchPage, ConversationPage or AuthPage` + (e.root.component === R ? "; AppShell is the app’s frame around its router" : "")
275
337
  });
276
338
  let l = (e, t) => {
277
339
  if (Array.isArray(e)) e.forEach((e, n) => l(e, `${t}[${n}]`));
278
- else if (S(e)) {
340
+ else if (C(e)) {
279
341
  let [n = e.$, ...r] = e.$.split(".");
280
342
  r.length > 0 && c.has(n) && i.push({
281
343
  path: t,
282
344
  message: `\`${e.$}\` is a path into the action \`${n}\`, and an action has no fields — bind \`${n}\` itself, or a model input`
283
345
  });
284
- } else if (x(e)) for (let [n, r] of Object.entries(e.$object)) l(r, `${t}.${n}`);
285
- else E(e) && u(e, t);
346
+ } else if (S(e)) for (let [n, r] of Object.entries(e.$object)) l(r, `${t}.${n}`);
347
+ else D(e) && u(e, t);
286
348
  }, u = (e, o) => {
287
- let s = U(G(e.component, n, r), e.component, t), u = s?.component, d = u !== void 0 && e.component === u.name, f = e.props ?? {};
288
- s !== null && J(e.component, s, t, "react") === null && a.renders !== void 0 && !a.renders(e.component) && i.push({
349
+ let s = H(W(e.component, n, r), e.component, t), u = s?.component, d = u !== void 0 && e.component === u.name, f = e.props ?? {};
350
+ s !== null && q(e.component, s, t, "react") === null && a.renders !== void 0 && !a.renders(e.component) && i.push({
289
351
  path: o,
290
- message: `\`${e.component}\` has no ${L[t]} rendering yet (\`${xe[t]}\`), so a screen for ${t} that uses it would not compile — leave it out until it is drawn, or compose the screen from members that are`
352
+ message: `\`${e.component}\` has no ${L[t]} rendering yet (\`${Ne[t]}\`), so a screen for ${t} that uses it would not compile — leave it out until it is drawn, or compose the screen from members that are`
291
353
  });
292
354
  for (let [t, n] of Object.entries(f)) {
293
355
  let r = `${o}.props.${t}`;
294
- if (l(n, r), d && H(u) && z.includes(t)) {
356
+ if (l(n, r), d && V(u) && Fe.includes(t)) {
295
357
  i.push({
296
358
  path: r,
297
359
  message: `\`${e.component}\`’s \`${t}\` is set from \`loadStatus\` on a native screen — remove it, and set the model’s \`loadStatus\` in the app’s store`
@@ -299,22 +361,22 @@ function Oe(e, t, n, r, i, a) {
299
361
  continue;
300
362
  }
301
363
  let a = s?.types.get(t)?.type;
302
- a !== void 0 && (_(a) ? S(n) ? c.has(n.$.split(".")[0] ?? n.$) || i.push({
364
+ a !== void 0 && (_(a) ? C(n) ? c.has(n.$.split(".")[0] ?? n.$) || i.push({
303
365
  path: r,
304
366
  message: `\`${t}\` is an event, and \`${n.$}\` is model data — bind it to a function-typed input, an action`
305
367
  }) : i.push({
306
368
  path: r,
307
369
  message: `\`${t}\` is an event, and an event is handed an action — bind it to a function-typed input`
308
- }) : S(n) && c.has(n.$) && i.push({
370
+ }) : C(n) && c.has(n.$) && i.push({
309
371
  path: r,
310
372
  message: `\`${t}\` holds data, and \`${n.$}\` is an action — bind it to a model input`
311
373
  }));
312
374
  }
313
- d && u.grid !== null && ke(u, f, o, i);
375
+ d && u.grid !== null && He(u, f, o, i);
314
376
  let p = e.children ?? [];
315
377
  p.forEach((e, t) => {
316
378
  let n = `${o}.children[${t}]`;
317
- S(e) && c.has(e.$) && i.push({
379
+ C(e) && c.has(e.$) && i.push({
318
380
  path: n,
319
381
  message: `a child is drawn, and \`${e.$}\` is an action — bind a model input`
320
382
  }), l(e, n);
@@ -328,23 +390,23 @@ function Oe(e, t, n, r, i, a) {
328
390
  u(e.root, "$.root");
329
391
  let d = /* @__PURE__ */ new Map();
330
392
  for (let [t, n] of Object.entries(e.types ?? {})) for (let e of n) d.set(e, t);
331
- let f = V(e.name), p = Ee(t, e.name);
393
+ let f = B(e.name), p = ze(t, e.name);
332
394
  if (f === "") i.push({
333
395
  path: "$.name",
334
- message: `\`${e.name}\` leaves no name once its suffix is gone, and the file declares ${fe(p.map((e) => `\`<Name>${e}\``))} — name the screen for what it shows`
396
+ message: `\`${e.name}\` leaves no name once its suffix is gone, and the file declares ${M(p.map((e) => `\`<Name>${e}\``))} — name the screen for what it shows`
335
397
  });
336
398
  else for (let e of p) {
337
399
  let n = d.get(e);
338
400
  n !== void 0 && i.push({
339
401
  path: "$.name",
340
402
  message: `the emitted file declares \`${e}\`, which \`types\` also names from \`${n}\` — name the screen something else`
341
- }), De[t].has(e) && i.push({
403
+ }), Be[t].has(e) && i.push({
342
404
  path: "$.name",
343
405
  message: `the emitted file declares \`${e}\`, which it also uses from ${L[t]} — name the screen something else`
344
406
  });
345
407
  }
346
408
  }
347
- function ke(e, t, n, r) {
409
+ function He(e, t, n, r) {
348
410
  let i = e.grid, a = t.variant, o = t.tone;
349
411
  for (let [t, i] of [["variant", a], ["tone", o]]) if (i !== void 0 && typeof i != "string") {
350
412
  r.push({
@@ -365,15 +427,15 @@ function ke(e, t, n, r) {
365
427
  message: `\`${e.name}\`’s variant and tone are one lawful cell on a native screen, and \`${String(a ?? o)}\` pairs with ${s.map((e) => `\`${a === void 0 ? e.variant : e.tone}\``).join(", ")} — give \`${l}\` too`
366
428
  });
367
429
  }
368
- function W(e) {
430
+ function U(e) {
369
431
  let t = /* @__PURE__ */ new Map();
370
432
  for (let n of e) n.name.includes(".") || t.set(n.name, n);
371
433
  return t;
372
434
  }
373
- function G(e, t, n) {
435
+ function W(e, t, n) {
374
436
  let r = n.get(e);
375
437
  if (r) {
376
- let e = W(r.props);
438
+ let e = U(r.props);
377
439
  return {
378
440
  props: new Set(e.keys()),
379
441
  types: e,
@@ -382,7 +444,7 @@ function G(e, t, n) {
382
444
  }
383
445
  let i = t.get(e);
384
446
  if (i) {
385
- let e = W(i.props);
447
+ let e = U(i.props);
386
448
  return {
387
449
  props: new Set(e.keys()),
388
450
  types: e,
@@ -401,23 +463,23 @@ function G(e, t, n) {
401
463
  part: s
402
464
  };
403
465
  }
404
- function K(e, t, n) {
466
+ function G(e, t, n) {
405
467
  let r = new Set(e.parts.map((e) => e.name));
406
468
  return i(e, t, n).map((e) => e.name).filter((e) => r.has(e));
407
469
  }
408
- function q(e, t, n) {
409
- let r = K(e, t, n).map((t) => `\`${e.name}.${t}\``);
470
+ function K(e, t, n) {
471
+ let r = G(e, t, n).map((t) => `\`${e.name}.${t}\``);
410
472
  return r.length === 0 ? `\`${e.name}\` has no parts` : `\`${e.name}\`’s parts are ${r.join(", ")}`;
411
473
  }
412
- function J(e, t, n, r) {
474
+ function q(e, t, n, r) {
413
475
  let { component: i, part: a } = t;
414
- return i === void 0 || a === void 0 || K(i, n, r).includes(a) ? null : `\`${e}\` is not a part ${n === "web" ? `in ${r}` : `on ${n}`} — ${q(i, n, r)} there`;
476
+ return i === void 0 || a === void 0 || G(i, n, r).includes(a) ? null : `\`${e}\` is not a part ${n === "web" ? `in ${r}` : `on ${n}`} — ${K(i, n, r)} there`;
415
477
  }
416
- function Ae(e, t, n, r) {
478
+ function Ue(e, t, n, r) {
417
479
  let a = e.split("."), [o, s] = a, c = o === void 0 ? void 0 : t.get(o);
418
- return a.length !== 2 || c === void 0 ? null : i(c, n, r).some((e) => e.name === s) ? ` — it is a part in ${r} whose props the registry does not record, so a spec cannot compose it` : ` — ${q(c, n, r)}`;
480
+ return a.length !== 2 || c === void 0 ? null : i(c, n, r).some((e) => e.name === s) ? ` — it is a part in ${r} whose props the registry does not record, so a spec cannot compose it` : ` — ${K(c, n, r)}`;
419
481
  }
420
- function je(e, t, n, r, i) {
482
+ function We(e, t, n, r, i) {
421
483
  let a = t.component ?? t.primitive;
422
484
  if (a === void 0 || e.component !== a.name) return;
423
485
  let o = a.platforms[n];
@@ -428,7 +490,7 @@ function je(e, t, n, r, i) {
428
490
  message: `\`${a.name}\` is absent on ${n} — ${c}` + (o.reason === void 0 ? "" : `. ${o.reason}`)
429
491
  });
430
492
  }
431
- function Me(e, t, n, r, i) {
493
+ function Ge(e, t, n, r, i) {
432
494
  let a = t.component ?? t.primitive;
433
495
  if (a === void 0 || e.component !== a.name) return;
434
496
  let o = a.frameworks[n];
@@ -437,7 +499,7 @@ function Me(e, t, n, r, i) {
437
499
  message: `\`${a.name}\` is absent in ${n}` + (o.reason === void 0 ? "" : ` — ${o.reason}`)
438
500
  });
439
501
  }
440
- function Ne(e, t) {
502
+ function Ke(e, t) {
441
503
  if (t !== null && typeof t != "string" && typeof t != "number" && typeof t != "boolean" && (!Array.isArray(t) || !t.every((e) => [
442
504
  "string",
443
505
  "number",
@@ -447,12 +509,12 @@ function Ne(e, t) {
447
509
  for (let e of n) {
448
510
  let n = /^(readonly\s+)?(.+)\[\]$/.exec(e), i = n ? n[2] : null;
449
511
  if (i !== null) {
450
- if (!Y(i) || (r += 1, Array.isArray(t) && t.every((e) => X(i, e)))) return null;
451
- } else if (!Y(e) || (r += 1, !Array.isArray(t) && X(e, t))) return null;
512
+ if (!J(i) || (r += 1, Array.isArray(t) && t.every((e) => Y(i, e)))) return null;
513
+ } else if (!J(e) || (r += 1, !Array.isArray(t) && Y(e, t))) return null;
452
514
  }
453
515
  return r === 0 ? null : JSON.stringify(t);
454
516
  }
455
- function Y(e) {
517
+ function J(e) {
456
518
  return !!([
457
519
  "string",
458
520
  "number",
@@ -462,7 +524,7 @@ function Y(e) {
462
524
  "false"
463
525
  ].includes(e) || /^["'].*["']$/.test(e) || /^-?\d+(\.\d+)?$/.test(e));
464
526
  }
465
- function X(e, t) {
527
+ function Y(e, t) {
466
528
  if (e === "string") return typeof t == "string";
467
529
  if (e === "number") return typeof t == "number";
468
530
  if (e === "boolean") return typeof t == "boolean";
@@ -472,7 +534,7 @@ function X(e, t) {
472
534
  let n = /^["'](.*)["']$/.exec(e);
473
535
  return n ? t === n[1] : /^-?\d+(\.\d+)?$/.test(e) ? t === Number(e) : !1;
474
536
  }
475
- function Pe(e, t, n, r) {
537
+ function qe(e, t, n, r) {
476
538
  let i = e.grid;
477
539
  if (!i) return;
478
540
  let a = t.variant, o = t.tone;
@@ -486,7 +548,7 @@ function Pe(e, t, n, r) {
486
548
  message: `\`${e.name}\` has no \`${a}\` × \`${o}\` cell — ${a} takes ${s.join(", ")}`
487
549
  });
488
550
  }
489
- function Z(e, t, n, r) {
551
+ function X(e, t, n, r) {
490
552
  let i = t.icon;
491
553
  if (typeof i != "string") return;
492
554
  let a = e.icons.roles.map((e) => e.name);
@@ -497,41 +559,91 @@ function Z(e, t, n, r) {
497
559
  message: `\`${i}\` is not an icon role — the set is closed` + (o.length === 0 ? "" : `, did you mean ${o.map((e) => `\`${e}\``).join(", ")}?`)
498
560
  });
499
561
  }
500
- function Fe(e, t, n, r) {
501
- let i = t?.primitive?.rung ?? (e.props?.[ce] === void 0 ? null : 3), a = e.exception;
562
+ var Z = (e) => e === void 0 ? void 0 : typeof e == "string" ? e : null;
563
+ function Je(e, t, n) {
564
+ let r = [], i = (e, t) => {
565
+ let r = e.map((e, n) => ({
566
+ item: e,
567
+ at: `${t}[${n}]`
568
+ })), i = ({ item: e }) => D(e) && e.component === "Separator";
569
+ for (let e of he(r, i)) {
570
+ let r = e.flatMap(({ item: e, at: t }) => D(e) && e.component === "Button" ? [{
571
+ tone: Z(e.props?.tone),
572
+ at: t
573
+ }] : []);
574
+ for (let e of ge(r.map(({ tone: e }) => [e]))) n.push({
575
+ path: r[e]?.at ?? t,
576
+ message: "a danger Button before another Button in its group — the destructive one comes last, so the safe one is met first; move it last, or into a group of its own"
577
+ });
578
+ }
579
+ }, a = (e, t, n) => {
580
+ if (Array.isArray(e)) i(e, t), e.forEach((e, r) => a(e, `${t}[${r}]`, n));
581
+ else if (S(e)) for (let [r, i] of Object.entries(e.$object)) a(i, `${t}.${r}`, n);
582
+ else D(e) && o(e, t, n);
583
+ }, o = (e, i, o) => {
584
+ if (e.component === "Bespoke") return;
585
+ let s = e.props ?? {};
586
+ if (e.component === "Button") {
587
+ ue(Z(s.variant), Z(s.tone)) === !0 && o !== null && o.buttons.push(i);
588
+ let e = s.trailingIcon;
589
+ t !== void 0 && typeof e == "string" && !_e(e, t) && n.push({
590
+ path: `${i}.props.trailingIcon`,
591
+ message: `\`${e}\` does not trail its text — an icon leads its text, and only ${M(t.map((e) => `\`${e}\``))} trail it; ` + (s.icon === void 0 ? `make it \`"icon": "${e}"\`` : `drop it, or make it \`"icon": "${e}"\` in place of the other`)
592
+ });
593
+ }
594
+ let c = fe(e.component), l = c === null ? o : {
595
+ name: c.name,
596
+ scope: c.scope,
597
+ buttons: []
598
+ };
599
+ c !== null && l !== null && r.push(l);
600
+ for (let [e, t] of Object.entries(s)) {
601
+ let n = c !== null && c.scope.outside.includes(e);
602
+ a(t, `${i}.props.${e}`, n ? o : l);
603
+ }
604
+ e.children !== void 0 && a(e.children, `${i}.children`, l);
605
+ };
606
+ o(e, "$.root", null);
607
+ for (let e of r) for (let t of me(e.buttons.map(() => []))) n.push({
608
+ path: e.buttons[t] ?? "$.root",
609
+ message: `a second main Button in this \`${e.name}\` — a ${e.scope.kind} has one solid accent Button, which marks its next step; make this one \`"variant": "outline", "tone": "neutral"\``
610
+ });
611
+ }
612
+ function Ye(e, t, n, r) {
613
+ let i = t?.primitive?.rung ?? (e.props?.[ve] === void 0 ? null : 3), a = e.exception;
502
614
  a === void 0 ? i !== null && r.push({
503
615
  path: n,
504
616
  message: `\`${e.component}\` is a rung-${i} exception and is not declared — add "exception": { "rung": ${i}, "because": "…" }`
505
617
  }) : i === null ? r.push({
506
618
  path: `${n}.exception`,
507
619
  message: `\`${e.component}\` takes no exception — nothing here deviates from the vocabulary`
508
- }) : (O.includes(a.rung) ? a.rung !== i && r.push({
620
+ }) : (A.includes(a.rung) ? a.rung !== i && r.push({
509
621
  path: `${n}.exception.rung`,
510
622
  message: `\`${e.component}\` is rung ${i}, declared as rung ${a.rung}`
511
623
  }) : r.push({
512
624
  path: `${n}.exception.rung`,
513
- message: `rung ${a.rung} is not something a screen can declare — ${O.join(", ")} are`
625
+ message: `rung ${a.rung} is not something a screen can declare — ${A.join(", ")} are`
514
626
  }), a.because.trim().split(/\s+/).length < 4 && r.push({
515
627
  path: `${n}.exception.because`,
516
628
  message: "say why the vocabulary was not enough — this is read by whoever finds it later"
517
629
  }));
518
630
  }
519
631
  var Q = (e) => e.replace(/[^a-z0-9]/gi, "").toLowerCase();
520
- function Ie(e, t, n, r) {
632
+ function Xe(e, t, n, r) {
521
633
  let i = Q(t), a = [...n.keys(), ...r.keys()].filter((e) => Q(e).includes(i) || i.includes(Q(e))), o = t.toLowerCase(), s = e.components.filter((e) => e.purpose.toLowerCase().includes(o)).map((e) => e.name), c = [.../* @__PURE__ */ new Set([...a, ...s])].slice(0, 3);
522
634
  return c.length === 0 ? "" : ` — did you mean ${c.map((e) => `\`${e}\``).join(", ")}?`;
523
635
  }
524
- var Le = 4;
525
- function Re(e, t) {
636
+ var Ze = 4;
637
+ function Qe(e, t) {
526
638
  let n = Q(e), r = [...t].filter((e) => {
527
639
  let t = Q(e);
528
- return Math.min(t.length, n.length) < Le ? !1 : t.includes(n) || n.includes(t);
640
+ return Math.min(t.length, n.length) < Ze ? !1 : t.includes(n) || n.includes(t);
529
641
  });
530
642
  return r.length === 0 ? "" : ` — did you mean \`${r[0]}\`?`;
531
643
  }
532
644
  //#endregion
533
645
  //#region src/check.ts
534
- function ze(e, t = {}) {
646
+ function $e(e, t = {}) {
535
647
  let n = m(e);
536
648
  if (n !== null) return {
537
649
  ok: !1,
@@ -540,17 +652,17 @@ function ze(e, t = {}) {
540
652
  message: h
541
653
  }]
542
654
  };
543
- let r = t.vocabulary ?? D, { faults: i } = ue(r, e, {}, { ...t.framework === void 0 ? {} : { framework: t.framework } }), o = [...i, ...Ve(r, e, a(r, t), new Set(i.map(({ path: e }) => e)))];
655
+ let r = t.vocabulary ?? O, { faults: i } = be(r, e, {}, { ...t.framework === void 0 ? {} : { framework: t.framework } }), o = [...i, ...tt(r, e, a(r, t), new Set(i.map(({ path: e }) => e)))];
544
656
  return {
545
657
  ok: o.length === 0,
546
658
  faults: o
547
659
  };
548
660
  }
549
- var $ = (e) => typeof e == "object" && !!e && !Array.isArray(e), Be = (e) => $(e) && typeof e.component == "string";
550
- function Ve(e, i, a, m) {
661
+ var $ = (e) => typeof e == "object" && !!e && !Array.isArray(e), et = (e) => $(e) && typeof e.component == "string";
662
+ function tt(e, i, a, m) {
551
663
  let h = [], _ = (e, t, n) => {
552
- if (!($(t) && typeof t.$ == "string")) for (let r of se(e, t, n)) m.has(r.path) || h.push(r);
553
- }, x = /* @__PURE__ */ new Map(), S = (t, i, a) => {
664
+ if (!($(t) && typeof t.$ == "string")) for (let r of oe(e, t, n)) m.has(r.path) || h.push(r);
665
+ }, S = /* @__PURE__ */ new Map(), C = (t, i, a) => {
554
666
  let o = r(e, t), u = i.name;
555
667
  if (o === null || c(o) === null || typeof u != "string" || u === "") return;
556
668
  let d = `${a}.props.name`;
@@ -561,32 +673,32 @@ function Ve(e, i, a, m) {
561
673
  });
562
674
  return;
563
675
  }
564
- let f = x.get(u);
676
+ let f = S.get(u);
565
677
  f !== void 0 && h.push({
566
678
  path: d,
567
679
  message: n(u, f)
568
- }), x.set(u, a);
569
- }, C = (e, t) => {
680
+ }), S.set(u, a);
681
+ }, w = (e, t) => {
570
682
  m.has(e) || h.push({
571
683
  path: e,
572
684
  message: t
573
685
  });
574
- }, w = /* @__PURE__ */ new Set(), E = $(i) ? i.inputs : void 0;
575
- Array.isArray(E) && E.forEach((e, t) => {
686
+ }, T = /* @__PURE__ */ new Set(), D = $(i) ? i.inputs : void 0;
687
+ Array.isArray(D) && D.forEach((e, t) => {
576
688
  if (!$(e) || typeof e.name != "string") return;
577
689
  let n = e.type;
578
- typeof n == "string" && (n.length > 500 ? C(`$.inputs[${t}].type`, u(e.name, n.length)) : b(n) && w.add(e.name));
690
+ typeof n == "string" && (n.length > 500 ? w(`$.inputs[${t}].type`, u(e.name, n.length)) : x(n) && T.add(e.name));
579
691
  });
580
- let D = (n, i, s, c = !1) => {
692
+ let O = (n, i, s, c = !1) => {
581
693
  if (Array.isArray(n)) {
582
- let t = ae(e, s);
583
- n.forEach((e, n) => D(e, `${i}[${n}]`, t, c));
694
+ let t = ie(e, s);
695
+ n.forEach((e, n) => O(e, `${i}[${n}]`, t, c));
584
696
  return;
585
697
  }
586
698
  if (!$(n)) return;
587
699
  if (typeof n.$ == "string") {
588
700
  let t = n.$;
589
- w.has(t) && oe(e, s) === null && C(i, re(t));
701
+ T.has(t) && ae(e, s) === null && w(i, ne(t));
590
702
  return;
591
703
  }
592
704
  if (typeof n.component == "string") {
@@ -595,43 +707,43 @@ function Ve(e, i, a, m) {
595
707
  path: i,
596
708
  message: l
597
709
  });
598
- let u = r(e, s), p = new Map((u?.props ?? []).map((e) => [e.name, e.type])), m = $(n.props) ? n.props : {}, g = (u?.props ?? []).some((t) => !t.optional && t.name !== "children" && !b(t.type) && (!f(e, t.type) || y(e, t.type)) && !Object.prototype.hasOwnProperty.call(m, t.name)), v = c || g;
599
- v || S(s, m, i);
710
+ let u = r(e, s), p = new Map((u?.props ?? []).map((e) => [e.name, e.type])), m = $(n.props) ? n.props : {}, g = (u?.props ?? []).some((t) => !t.optional && t.name !== "children" && !x(t.type) && (!f(e, t.type) || b(e, t.type)) && !Object.prototype.hasOwnProperty.call(m, t.name)), v = c || g;
711
+ v || C(s, m, i);
600
712
  for (let [n, r] of Object.entries(m)) {
601
713
  if (n.length > 100) {
602
- C(i, t(n.length));
714
+ w(i, t(n.length));
603
715
  continue;
604
716
  }
605
717
  let a = `${i}.props.${n}`;
606
- y(e, p.get(n) ?? null) && !Be(r) && C(a, d(n)), T.has(n) && _(n, r, a), D(r, a, p.get(n) ?? null, v);
718
+ b(e, p.get(n) ?? null) && !et(r) && w(a, d(n)), E.has(n) && _(n, r, a), O(r, a, p.get(n) ?? null, v);
607
719
  }
608
- D(n.children, `${i}.children`, p.get("children") ?? null, v);
720
+ O(n.children, `${i}.children`, p.get("children") ?? null, v);
609
721
  return;
610
722
  }
611
723
  let l = n.$object;
612
724
  if ($(l)) for (let [n, r] of Object.entries(l)) {
613
725
  if (n.length > 100) {
614
- C(i, t(n.length));
726
+ w(i, t(n.length));
615
727
  continue;
616
728
  }
617
729
  let a = `${i}.${n}`, o = g(e, s, n), l = r;
618
730
  if (o !== null && !f(e, o?.type ?? "never")) {
619
- let t = v(e, s), i = o === void 0 ? p(n, t) : te(n, t);
620
- if (ne(e, o)) {
621
- let e = ee(r);
622
- if (e.removed && C(a, i), e.value === void 0) continue;
731
+ let t = v(e, s), i = o === void 0 ? p(n, t) : ee(n, t);
732
+ if (te(e, o)) {
733
+ let e = y(r);
734
+ if (e.removed && w(a, i), e.value === void 0) continue;
623
735
  l = e.value;
624
- } else if (ie(r)) {
625
- C(a, i);
736
+ } else if (re(r)) {
737
+ w(a, i);
626
738
  continue;
627
739
  }
628
740
  }
629
- T.has(n) && _(n, l, a), D(l, a, o?.type ?? null, c);
741
+ E.has(n) && _(n, l, a), O(l, a, o?.type ?? null, c);
630
742
  }
631
743
  };
632
- return $(i) && D(i.root, "$.root", null), h;
744
+ return $(i) && O(i.root, "$.root", null), h;
633
745
  }
634
746
  //#endregion
635
- export { ze as t };
747
+ export { $e as t };
636
748
 
637
- //# sourceMappingURL=check-DDXOiNKG.js.map
749
+ //# sourceMappingURL=check-BB8y9DW3.js.map