@brucesantos/design-space 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +39 -0
- package/dist/devtools-hook.d.ts +9 -0
- package/dist/devtools-hook.js +3 -0
- package/dist/devtools-hook.js.map +1 -0
- package/dist/fiber/hook.d.ts +38 -0
- package/dist/fiber/read.d.ts +8 -0
- package/dist/fiber/tree.d.ts +33 -0
- package/dist/frame/index.d.ts +4 -3
- package/dist/hook-CeXcli-1.js +64 -0
- package/dist/hook-CeXcli-1.js.map +1 -0
- package/dist/{index-rWBjjVMg.js → index-CLox5DuH.js} +162 -158
- package/dist/index-CLox5DuH.js.map +1 -0
- package/dist/index.js +1308 -1199
- package/dist/index.js.map +1 -1
- package/dist/shell/Highlight.d.ts +5 -3
- package/dist/testing.js +1 -1
- package/dist/types/index.d.ts +11 -1
- package/package.json +7 -2
- package/dist/index-rWBjjVMg.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const j = [
|
|
2
2
|
"success",
|
|
3
3
|
"loading",
|
|
4
4
|
"empty",
|
|
5
5
|
"error",
|
|
6
6
|
"slow"
|
|
7
7
|
];
|
|
8
|
-
function
|
|
9
|
-
const o = e.split("/").filter(Boolean),
|
|
8
|
+
function I(e, t) {
|
|
9
|
+
const o = e.split("/").filter(Boolean), r = M(t).split("/").filter(Boolean), a = {};
|
|
10
10
|
for (const [s, c] of o.entries()) {
|
|
11
11
|
if (c === "*")
|
|
12
|
-
return a["*"] =
|
|
13
|
-
const h =
|
|
12
|
+
return a["*"] = r.slice(s).join("/"), a;
|
|
13
|
+
const h = r[s];
|
|
14
14
|
if (h === void 0) return null;
|
|
15
15
|
if (c.startsWith(":")) {
|
|
16
16
|
a[c.slice(1)] = h;
|
|
@@ -18,61 +18,61 @@ function j(e, r) {
|
|
|
18
18
|
}
|
|
19
19
|
if (c !== h) return null;
|
|
20
20
|
}
|
|
21
|
-
return o.length !==
|
|
21
|
+
return o.length !== r.length ? null : a;
|
|
22
22
|
}
|
|
23
|
-
function P(e,
|
|
24
|
-
const o = [...e].sort((
|
|
25
|
-
for (const
|
|
26
|
-
const a =
|
|
27
|
-
if (a) return { definition:
|
|
23
|
+
function P(e, t) {
|
|
24
|
+
const o = [...e].sort((r, a) => C(a.path) - C(r.path));
|
|
25
|
+
for (const r of o) {
|
|
26
|
+
const a = I(r.path, t);
|
|
27
|
+
if (a) return { definition: r, params: a };
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function E(e,
|
|
30
|
+
function E(e, t = {}) {
|
|
31
31
|
const o = (a) => {
|
|
32
|
-
const s =
|
|
32
|
+
const s = t[a];
|
|
33
33
|
return typeof s == "string" && s.length > 0 ? s : void 0;
|
|
34
|
-
},
|
|
34
|
+
}, r = [];
|
|
35
35
|
for (const a of e.split("/").filter(Boolean)) {
|
|
36
36
|
if (a === "*") {
|
|
37
37
|
const c = o("*");
|
|
38
|
-
c &&
|
|
38
|
+
c && r.push(...c.split("/").filter(Boolean).map(encodeURIComponent));
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
const s = a.startsWith(":") ? o(a.slice(1)) : void 0;
|
|
42
|
-
|
|
42
|
+
r.push(s === void 0 ? a : encodeURIComponent(s));
|
|
43
43
|
}
|
|
44
|
-
return `/${
|
|
44
|
+
return `/${r.join("/")}`;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
let o =
|
|
49
|
-
for (const
|
|
50
|
-
|
|
46
|
+
function C(e) {
|
|
47
|
+
const t = e.split("/").filter(Boolean);
|
|
48
|
+
let o = t.length;
|
|
49
|
+
for (const r of t)
|
|
50
|
+
r === "*" ? o -= 2 : r.startsWith(":") ? o += 1 : o += 4;
|
|
51
51
|
return o;
|
|
52
52
|
}
|
|
53
53
|
function M(e) {
|
|
54
|
-
const
|
|
54
|
+
const t = e.split("?")[0] ?? e;
|
|
55
55
|
try {
|
|
56
|
-
return decodeURI(
|
|
56
|
+
return decodeURI(t);
|
|
57
57
|
} catch {
|
|
58
|
-
return
|
|
58
|
+
return t;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
const R = /^[a-z0-9]+([.\-][a-z0-9]+)*$/, z = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
62
62
|
function u(e) {
|
|
63
63
|
return typeof e == "string" && e.trim().length > 0;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const o = [],
|
|
65
|
+
function q(e, t) {
|
|
66
|
+
const o = [], r = u(e?.id) ? `scenario:${e.id}` : `scenario[${t ?? "?"}]`, a = (c) => o.push({ level: "error", where: r, message: c }), s = (c) => o.push({ level: "warning", where: r, message: c });
|
|
67
67
|
return u(e?.id) ? R.test(e.id) || a(
|
|
68
68
|
"`id` deve ser minúsculo, em kebab-case, com pontos opcionais: `requests.approve-blocked` ou `approve-blocked`."
|
|
69
|
-
) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !
|
|
69
|
+
) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !j.includes(e.network) && a(`\`network\` deve ser um de: ${j.join(", ")}.`), e?.expected?.length || s(
|
|
70
70
|
"Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
|
|
71
71
|
), o;
|
|
72
72
|
}
|
|
73
73
|
function Q(e) {
|
|
74
|
-
const
|
|
75
|
-
u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !
|
|
74
|
+
const t = [], o = (l, n, i) => t.push({ level: l, where: n, message: i }), r = new Set(e.personas?.map((l) => l.id) ?? []), a = new Set(e.fixtures?.map((l) => l.id) ?? []), s = new Set(e.rules?.map((l) => l.id) ?? []), c = /* @__PURE__ */ new Set();
|
|
75
|
+
u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !r.has(e.defaultPersona) && o(
|
|
76
76
|
"error",
|
|
77
77
|
"product",
|
|
78
78
|
`\`defaultPersona\` aponta para persona não registrada: \`${e.defaultPersona}\`.`
|
|
@@ -88,20 +88,24 @@ function Q(e) {
|
|
|
88
88
|
o("error", i, "`path` é obrigatório.");
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
|
-
n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), h.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), h.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ?
|
|
91
|
+
n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), h.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), h.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ? L(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
|
|
92
92
|
}
|
|
93
93
|
const f = /* @__PURE__ */ new Set();
|
|
94
94
|
for (const [l, n] of (e.components ?? []).entries()) {
|
|
95
95
|
const i = `component:${n?.id ?? l}`;
|
|
96
|
-
u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre.")
|
|
96
|
+
u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre."), n?.implementation !== void 0 && (Array.isArray(n.implementation) ? n.implementation : [n.implementation]).some((g) => typeof g != "function" && (typeof g != "object" || g === null)) && o(
|
|
97
|
+
"error",
|
|
98
|
+
i,
|
|
99
|
+
"`implementation`, quando informado, é o componente React real (ou uma lista deles), não o nome."
|
|
100
|
+
);
|
|
97
101
|
const p = /* @__PURE__ */ new Set();
|
|
98
|
-
for (const [b,
|
|
99
|
-
const
|
|
100
|
-
u(
|
|
102
|
+
for (const [b, g] of (n?.fixtures ?? []).entries()) {
|
|
103
|
+
const v = `${i}/fixture:${g?.id ?? b}`;
|
|
104
|
+
u(g?.id) ? R.test(g.id) ? p.has(g.id) ? o("error", v, `Id de fixture do componente duplicado: \`${g.id}\`.`) : p.add(g.id) : o(
|
|
101
105
|
"error",
|
|
102
|
-
|
|
103
|
-
`Id de fixture do componente inválido: \`${
|
|
104
|
-
) : o("error",
|
|
106
|
+
v,
|
|
107
|
+
`Id de fixture do componente inválido: \`${g.id}\`. Use minúsculas em kebab-case.`
|
|
108
|
+
) : o("error", v, "`id` da fixture do componente é obrigatório."), u(g?.label) || o("error", v, "`label` da fixture do componente é obrigatório."), (!g || !("data" in g)) && o("error", v, "`data` da fixture do componente é obrigatório.");
|
|
105
109
|
}
|
|
106
110
|
n?.defaultFixture && !p.has(n.defaultFixture) && o(
|
|
107
111
|
"error",
|
|
@@ -127,9 +131,9 @@ function Q(e) {
|
|
|
127
131
|
);
|
|
128
132
|
}
|
|
129
133
|
for (const [l, n] of (e.scenarios ?? []).entries()) {
|
|
130
|
-
|
|
134
|
+
t.push(...q(n, l));
|
|
131
135
|
const i = `scenario:${n?.id ?? l}`;
|
|
132
|
-
n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !
|
|
136
|
+
n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !r.has(n.persona) && o("error", i, `Persona não registrada: \`${n.persona}\`.`), n?.fixture && !a.has(n.fixture) && o("error", i, `Fixture não registrada: \`${n.fixture}\`.`);
|
|
133
137
|
for (const p of n?.rules ?? [])
|
|
134
138
|
s.has(p) || o("error", i, `Regra não registrada: \`${p}\`.`);
|
|
135
139
|
for (const p of Array.isArray(n?.components) ? n.components : [])
|
|
@@ -142,22 +146,22 @@ function Q(e) {
|
|
|
142
146
|
if (!n.controls || typeof n.controls != "object" || Array.isArray(n.controls))
|
|
143
147
|
o("error", i, "`controls`, quando informado, é um objeto de id do controle → valor.");
|
|
144
148
|
else if (n.route) {
|
|
145
|
-
const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [],
|
|
146
|
-
b.flatMap((
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], g = new Map(
|
|
150
|
+
b.flatMap((v) => Array.isArray(v?.controls) ? v.controls : []).map((v) => [
|
|
151
|
+
v?.id,
|
|
152
|
+
v
|
|
149
153
|
])
|
|
150
154
|
);
|
|
151
|
-
for (const [
|
|
152
|
-
const
|
|
153
|
-
|
|
155
|
+
for (const [v, O] of Object.entries(n.controls)) {
|
|
156
|
+
const A = g.get(v);
|
|
157
|
+
A ? (A.options ?? []).some((x) => x?.value === O) || o(
|
|
154
158
|
"error",
|
|
155
159
|
i,
|
|
156
|
-
`Valor \`${O}\` não é opção do controle \`${
|
|
160
|
+
`Valor \`${O}\` não é opção do controle \`${v}\`. Opções: ${(A.options ?? []).map((x) => `\`${x?.value}\``).join(", ")}.`
|
|
157
161
|
) : o(
|
|
158
162
|
"error",
|
|
159
163
|
i,
|
|
160
|
-
`Controle \`${
|
|
164
|
+
`Controle \`${v}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
|
|
161
165
|
);
|
|
162
166
|
}
|
|
163
167
|
}
|
|
@@ -173,13 +177,13 @@ function Q(e) {
|
|
|
173
177
|
"warning",
|
|
174
178
|
"product",
|
|
175
179
|
"A fonte padrão não é `fixtures`. O padrão do ambiente é dado sintético e determinístico (D-05); API real entra como adapter opcional, com justificativa."
|
|
176
|
-
)),
|
|
180
|
+
)), t;
|
|
177
181
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
182
|
+
function L(e, t, o) {
|
|
183
|
+
const r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
180
184
|
for (const [s, c] of e.entries()) {
|
|
181
|
-
const h = `${
|
|
182
|
-
if (u(c?.id) ?
|
|
185
|
+
const h = `${t}/group:${c?.id ?? s}`;
|
|
186
|
+
if (u(c?.id) ? r.has(c.id) ? o("error", h, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : r.add(c.id) : o("error", h, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", h, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
|
|
183
187
|
o("error", h, "`controls` do grupo deve ser uma lista.");
|
|
184
188
|
continue;
|
|
185
189
|
}
|
|
@@ -206,56 +210,56 @@ function q(e, r, o) {
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
|
-
function W(e,
|
|
210
|
-
const a =
|
|
213
|
+
function W(e, t, o, r) {
|
|
214
|
+
const a = t.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = t.params;
|
|
211
215
|
if (s !== void 0 && (!s || typeof s != "object" || Array.isArray(s))) {
|
|
212
|
-
|
|
216
|
+
r("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
|
|
213
217
|
return;
|
|
214
218
|
}
|
|
215
219
|
const c = s ?? {};
|
|
216
220
|
for (const [f, d] of Object.entries(c))
|
|
217
|
-
a.includes(f) ? u(d) ||
|
|
221
|
+
a.includes(f) ? u(d) || r("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : r("warning", o, `\`params.${f}\` não é parâmetro de \`${t.path}\` e é ignorado.`);
|
|
218
222
|
const h = a.filter((f) => f !== "*" && !u(c[f]));
|
|
219
223
|
if (h.length > 0) {
|
|
220
224
|
(e.scenarios ?? []).some(
|
|
221
|
-
(d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path ===
|
|
222
|
-
) ||
|
|
225
|
+
(d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === t.path
|
|
226
|
+
) || r(
|
|
223
227
|
"warning",
|
|
224
228
|
o,
|
|
225
|
-
`Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${
|
|
229
|
+
`Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${t.path}\`. Declare \`params: { ${h.map((d) => `${d}: "…"`).join(", ")} }\`.`
|
|
226
230
|
);
|
|
227
231
|
return;
|
|
228
232
|
}
|
|
229
233
|
if (a.length > 0) {
|
|
230
|
-
const f = E(
|
|
231
|
-
d && d.definition.path !==
|
|
234
|
+
const f = E(t.path, c), d = P(e.routes ?? [], f);
|
|
235
|
+
d && d.definition.path !== t.path && r(
|
|
232
236
|
"warning",
|
|
233
237
|
o,
|
|
234
238
|
`Os exemplos de \`params\` montam \`${f}\`, que abre a rota \`${d.definition.path}\`, não esta.`
|
|
235
239
|
);
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
|
-
function _(e,
|
|
242
|
+
function _(e, t) {
|
|
239
243
|
const o = e.split("?")[0] ?? e;
|
|
240
|
-
return (
|
|
244
|
+
return (t.routes ?? []).some((r) => B(r.path, o));
|
|
241
245
|
}
|
|
242
|
-
function B(e,
|
|
243
|
-
const o = e.split("/").filter(Boolean),
|
|
246
|
+
function B(e, t) {
|
|
247
|
+
const o = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean);
|
|
244
248
|
for (const [a, s] of o.entries()) {
|
|
245
249
|
if (s === "*") return !0;
|
|
246
|
-
const c =
|
|
250
|
+
const c = r[a];
|
|
247
251
|
if (c === void 0) return !1;
|
|
248
252
|
if (!s.startsWith(":") && s !== c)
|
|
249
253
|
return !1;
|
|
250
254
|
}
|
|
251
|
-
return o.length ===
|
|
255
|
+
return o.length === r.length;
|
|
252
256
|
}
|
|
253
257
|
function X(e) {
|
|
254
|
-
return e.some((
|
|
258
|
+
return e.some((t) => t.level === "error");
|
|
255
259
|
}
|
|
256
260
|
function Y(e) {
|
|
257
|
-
return e.length === 0 ? "Nenhum problema encontrado." : e.map((
|
|
258
|
-
${
|
|
261
|
+
return e.length === 0 ? "Nenhum problema encontrado." : e.map((t) => `${t.level === "error" ? "✖" : "▲"} ${t.where}
|
|
262
|
+
${t.message}`).join(`
|
|
259
263
|
`);
|
|
260
264
|
}
|
|
261
265
|
const w = {
|
|
@@ -272,37 +276,37 @@ function ee(e) {
|
|
|
272
276
|
components: e.getAll(w.component)
|
|
273
277
|
});
|
|
274
278
|
}
|
|
275
|
-
function N(e,
|
|
276
|
-
for (const
|
|
277
|
-
if (!
|
|
279
|
+
function N(e, t) {
|
|
280
|
+
for (const r of Object.values(w)) e.delete(r);
|
|
281
|
+
if (!t) return;
|
|
278
282
|
e.set(w.enabled, "1");
|
|
279
|
-
const o = k(
|
|
280
|
-
for (const
|
|
281
|
-
for (const
|
|
282
|
-
for (const
|
|
283
|
+
const o = k(t);
|
|
284
|
+
for (const r of o.scenarios ?? []) e.append(w.scenario, r);
|
|
285
|
+
for (const r of o.routes ?? []) e.append(w.route, r);
|
|
286
|
+
for (const r of o.components ?? []) e.append(w.component, r);
|
|
283
287
|
}
|
|
284
288
|
function k(e) {
|
|
285
|
-
const
|
|
289
|
+
const t = S(e.scenarios), o = S(e.routes), r = S(e.components);
|
|
286
290
|
return {
|
|
287
|
-
...
|
|
291
|
+
...t.length ? { scenarios: t } : {},
|
|
288
292
|
...o.length ? { routes: o } : {},
|
|
289
|
-
...
|
|
293
|
+
...r.length ? { components: r } : {}
|
|
290
294
|
};
|
|
291
295
|
}
|
|
292
|
-
function D(e,
|
|
293
|
-
return !e || !!(
|
|
296
|
+
function D(e, t) {
|
|
297
|
+
return !e || !!(t && e.scenarios?.includes(t));
|
|
294
298
|
}
|
|
295
|
-
function oe(e,
|
|
296
|
-
return !e || !!(
|
|
299
|
+
function oe(e, t) {
|
|
300
|
+
return !e || !!(t && e.components?.includes(t));
|
|
297
301
|
}
|
|
298
|
-
function
|
|
299
|
-
return !e ||
|
|
302
|
+
function te(e, t, o = []) {
|
|
303
|
+
return !e || t === "/" ? !0 : [
|
|
300
304
|
...e.routes ?? [],
|
|
301
305
|
...o.filter((a) => D(e, a.id)).map((a) => a.route)
|
|
302
|
-
].some((a) =>
|
|
306
|
+
].some((a) => I(a, t) !== null);
|
|
303
307
|
}
|
|
304
308
|
function S(e) {
|
|
305
|
-
return [...new Set((e ?? []).map((
|
|
309
|
+
return [...new Set((e ?? []).map((t) => t.trim()).filter(Boolean))].sort();
|
|
306
310
|
}
|
|
307
311
|
const m = {
|
|
308
312
|
scenario: "scenario",
|
|
@@ -322,46 +326,46 @@ const m = {
|
|
|
322
326
|
zoom: "zoom",
|
|
323
327
|
rotated: "rotate",
|
|
324
328
|
highlight: "highlight"
|
|
325
|
-
},
|
|
329
|
+
}, y = "c.", H = /* @__PURE__ */ new Set([
|
|
326
330
|
...Object.values(m),
|
|
327
331
|
...Object.values(w)
|
|
328
332
|
]);
|
|
329
|
-
function
|
|
330
|
-
return e.startsWith(
|
|
333
|
+
function re(e) {
|
|
334
|
+
return e.startsWith(y) || H.has(e);
|
|
331
335
|
}
|
|
332
336
|
function ne(e) {
|
|
333
|
-
const
|
|
334
|
-
for (const [
|
|
335
|
-
if (!
|
|
336
|
-
const s =
|
|
337
|
+
const t = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
|
|
338
|
+
for (const [r, a] of t) {
|
|
339
|
+
if (!r.startsWith(y)) continue;
|
|
340
|
+
const s = r.slice(y.length);
|
|
337
341
|
s && (o[s] = a);
|
|
338
342
|
}
|
|
339
343
|
return o;
|
|
340
344
|
}
|
|
341
345
|
function ae(e) {
|
|
342
|
-
for (const
|
|
343
|
-
|
|
346
|
+
for (const t of [...e.keys()])
|
|
347
|
+
t.startsWith(y) && e.delete(t);
|
|
344
348
|
}
|
|
345
349
|
function G(e) {
|
|
346
350
|
return typeof e == "boolean" ? e ? "1" : "0" : String(e);
|
|
347
351
|
}
|
|
348
|
-
function F(e,
|
|
349
|
-
for (const [o,
|
|
350
|
-
if (
|
|
352
|
+
function F(e, t = {}) {
|
|
353
|
+
for (const [o, r] of Object.entries(t)) {
|
|
354
|
+
if (r == null) continue;
|
|
351
355
|
if (o === "handoff") {
|
|
352
|
-
N(e,
|
|
356
|
+
N(e, r);
|
|
353
357
|
continue;
|
|
354
358
|
}
|
|
355
359
|
if (o === "screenControls") {
|
|
356
|
-
for (const [s, c] of Object.entries(
|
|
357
|
-
e.set(`${
|
|
360
|
+
for (const [s, c] of Object.entries(r))
|
|
361
|
+
e.set(`${y}${s}`, c);
|
|
358
362
|
continue;
|
|
359
363
|
}
|
|
360
364
|
const a = m[o];
|
|
361
|
-
a && e.set(a, G(
|
|
365
|
+
a && e.set(a, G(r));
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
|
-
const
|
|
368
|
+
const $ = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
|
|
365
369
|
m.chromeTheme,
|
|
366
370
|
m.chrome,
|
|
367
371
|
m.inspector,
|
|
@@ -369,38 +373,38 @@ const y = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
|
|
|
369
373
|
m.zoom,
|
|
370
374
|
m.rotated
|
|
371
375
|
];
|
|
372
|
-
function V(e,
|
|
373
|
-
const o = new URLSearchParams(
|
|
374
|
-
for (const
|
|
375
|
-
return o.delete(
|
|
376
|
+
function V(e, t) {
|
|
377
|
+
const o = new URLSearchParams(t);
|
|
378
|
+
for (const r of T) o.delete(r);
|
|
379
|
+
return o.delete($), o.set($, "1"), `${e || "/"}?${o.toString()}`;
|
|
376
380
|
}
|
|
377
|
-
function se(e,
|
|
378
|
-
let { path:
|
|
381
|
+
function se(e, t, o) {
|
|
382
|
+
let { path: r, search: a } = o;
|
|
379
383
|
if (e)
|
|
380
384
|
try {
|
|
381
385
|
const c = new URL(e);
|
|
382
|
-
c.origin ===
|
|
386
|
+
c.origin === t && ({ pathname: r, search: a } = c);
|
|
383
387
|
} catch {
|
|
384
388
|
}
|
|
385
389
|
const s = new URLSearchParams(a);
|
|
386
|
-
return s.delete(m.viewport), s.delete(m.customWidth), V(
|
|
390
|
+
return s.delete(m.viewport), s.delete(m.customWidth), V(r, `?${s.toString()}`);
|
|
387
391
|
}
|
|
388
392
|
function ce(e) {
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
const o =
|
|
392
|
-
return { path:
|
|
393
|
+
const t = new URL(e, "http://design-space.invalid");
|
|
394
|
+
t.searchParams.delete($);
|
|
395
|
+
const o = t.searchParams.toString();
|
|
396
|
+
return { path: t.pathname || "/", search: o ? `?${o}` : "" };
|
|
393
397
|
}
|
|
394
398
|
function le(e) {
|
|
395
|
-
const
|
|
396
|
-
return `${
|
|
399
|
+
const t = new URL(e, "http://design-space.invalid");
|
|
400
|
+
return `${t.pathname}|${t.searchParams.get(m.component) ?? ""}`;
|
|
397
401
|
}
|
|
398
|
-
function de(e,
|
|
399
|
-
const o = new URLSearchParams(e),
|
|
400
|
-
o.delete(
|
|
402
|
+
function de(e, t) {
|
|
403
|
+
const o = new URLSearchParams(e), r = new URLSearchParams(t);
|
|
404
|
+
o.delete($);
|
|
401
405
|
for (const s of T) {
|
|
402
406
|
o.delete(s);
|
|
403
|
-
const c =
|
|
407
|
+
const c = r.get(s);
|
|
404
408
|
c !== null && o.set(s, c);
|
|
405
409
|
}
|
|
406
410
|
const a = o.toString();
|
|
@@ -408,33 +412,33 @@ function de(e, r) {
|
|
|
408
412
|
}
|
|
409
413
|
function Z(e) {
|
|
410
414
|
if (!e || typeof e != "object") return !1;
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
switch (
|
|
415
|
+
const t = e;
|
|
416
|
+
if (t.ds !== 1 || typeof t.type != "string") return !1;
|
|
417
|
+
switch (t.type) {
|
|
414
418
|
case "ready":
|
|
415
419
|
case "location":
|
|
416
|
-
return typeof
|
|
420
|
+
return typeof t.url == "string";
|
|
417
421
|
case "navigate":
|
|
418
|
-
return typeof
|
|
422
|
+
return typeof t.url == "string";
|
|
419
423
|
case "shortcut":
|
|
420
|
-
return ["C", "K", "F"].includes(
|
|
424
|
+
return ["C", "K", "F"].includes(t.key);
|
|
421
425
|
default:
|
|
422
426
|
return !1;
|
|
423
427
|
}
|
|
424
428
|
}
|
|
425
|
-
function fe(e,
|
|
426
|
-
if (e.origin ===
|
|
429
|
+
function fe(e, t) {
|
|
430
|
+
if (e.origin === t.origin && !(!t.source || e.source !== t.source))
|
|
427
431
|
return Z(e.data) ? e.data : void 0;
|
|
428
432
|
}
|
|
429
|
-
function ue(e,
|
|
433
|
+
function ue(e, t, o) {
|
|
430
434
|
try {
|
|
431
|
-
e?.postMessage(
|
|
435
|
+
e?.postMessage(t, o);
|
|
432
436
|
} catch {
|
|
433
437
|
}
|
|
434
438
|
}
|
|
435
439
|
function pe(e = typeof window > "u" ? void 0 : window) {
|
|
436
440
|
if (!e) return !1;
|
|
437
|
-
if (new URLSearchParams(e.location.search).get(
|
|
441
|
+
if (new URLSearchParams(e.location.search).get($) === "1") return !0;
|
|
438
442
|
try {
|
|
439
443
|
return !!e.frameElement?.hasAttribute(K);
|
|
440
444
|
} catch {
|
|
@@ -442,54 +446,54 @@ function pe(e = typeof window > "u" ? void 0 : window) {
|
|
|
442
446
|
}
|
|
443
447
|
}
|
|
444
448
|
function U(e = {}) {
|
|
445
|
-
const
|
|
449
|
+
const t = e.branchUrl || void 0, o = e.deploymentUrl || void 0, r = e.commit || void 0, a = e.env || "development", s = t && `https://${t}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
|
|
446
450
|
return {
|
|
447
451
|
env: a,
|
|
448
452
|
origin: s.replace(/\/$/, ""),
|
|
449
|
-
branchUrl:
|
|
453
|
+
branchUrl: t,
|
|
450
454
|
deploymentUrl: o,
|
|
451
455
|
branch: e.branch || void 0,
|
|
452
|
-
commit:
|
|
453
|
-
shortCommit:
|
|
456
|
+
commit: r,
|
|
457
|
+
shortCommit: r?.slice(0, 7),
|
|
454
458
|
isDeployed: a === "preview" || a === "production"
|
|
455
459
|
};
|
|
456
460
|
}
|
|
457
|
-
function J(e,
|
|
458
|
-
const o =
|
|
459
|
-
return
|
|
461
|
+
function J(e, t = {}) {
|
|
462
|
+
const o = t.origin ?? U().origin, r = new URL(e.route, o);
|
|
463
|
+
return r.searchParams.set(m.scenario, e.id), e.persona && r.searchParams.set(m.persona, e.persona), r.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && r.searchParams.set(m.network, e.network), F(r.searchParams, t.overrides), r.toString();
|
|
460
464
|
}
|
|
461
|
-
function me(e,
|
|
462
|
-
const o =
|
|
463
|
-
return
|
|
465
|
+
function me(e, t = {}) {
|
|
466
|
+
const o = t.origin ?? U().origin, r = new URL("/", o), a = t.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
|
|
467
|
+
return r.searchParams.set(m.component, e.id), a && r.searchParams.set(m.fixture, a), F(r.searchParams, t.overrides), r.toString();
|
|
464
468
|
}
|
|
465
|
-
function he(e,
|
|
466
|
-
const o =
|
|
469
|
+
function he(e, t) {
|
|
470
|
+
const o = t.commit ?? U().commit;
|
|
467
471
|
if (!o) return;
|
|
468
|
-
const
|
|
469
|
-
return J(e, { origin:
|
|
472
|
+
const r = t.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
|
|
473
|
+
return J(e, { origin: r });
|
|
470
474
|
}
|
|
471
475
|
export {
|
|
472
476
|
me as A,
|
|
473
477
|
Y as B,
|
|
474
|
-
|
|
478
|
+
y as C,
|
|
475
479
|
X as D,
|
|
476
|
-
|
|
477
|
-
|
|
480
|
+
I as E,
|
|
481
|
+
$ as F,
|
|
478
482
|
k as G,
|
|
479
483
|
w as H,
|
|
480
484
|
G as I,
|
|
481
|
-
|
|
482
|
-
|
|
485
|
+
q as J,
|
|
486
|
+
j as N,
|
|
483
487
|
m as P,
|
|
484
488
|
oe as a,
|
|
485
|
-
|
|
489
|
+
te as b,
|
|
486
490
|
ne as c,
|
|
487
491
|
N as d,
|
|
488
492
|
ue as e,
|
|
489
493
|
ce as f,
|
|
490
494
|
fe as g,
|
|
491
495
|
D as h,
|
|
492
|
-
|
|
496
|
+
re as i,
|
|
493
497
|
ae as j,
|
|
494
498
|
J as k,
|
|
495
499
|
F as l,
|
|
@@ -508,4 +512,4 @@ export {
|
|
|
508
512
|
se as y,
|
|
509
513
|
he as z
|
|
510
514
|
};
|
|
511
|
-
//# sourceMappingURL=index-
|
|
515
|
+
//# sourceMappingURL=index-CLox5DuH.js.map
|