@brucesantos/design-space 0.11.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 +70 -0
- package/README.md +57 -1
- 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 +23 -3
- package/dist/hook-CeXcli-1.js +64 -0
- package/dist/hook-CeXcli-1.js.map +1 -0
- package/dist/{index-Dv-W-bL0.js → index-CLox5DuH.js} +231 -215
- package/dist/index-CLox5DuH.js.map +1 -0
- package/dist/index.js +1421 -1283
- package/dist/index.js.map +1 -1
- package/dist/shell/Canvas.d.ts +4 -1
- package/dist/shell/Highlight.d.ts +5 -3
- package/dist/shell/Topbar.d.ts +3 -1
- package/dist/shell/icons.d.ts +1 -1
- package/dist/shell/labels.d.ts +2 -0
- package/dist/testing.js +1 -1
- package/dist/types/index.d.ts +11 -1
- package/package.json +7 -2
- package/dist/index-Dv-W-bL0.js.map +0 -1
|
@@ -1,78 +1,78 @@
|
|
|
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
|
|
14
|
-
if (
|
|
12
|
+
return a["*"] = r.slice(s).join("/"), a;
|
|
13
|
+
const h = r[s];
|
|
14
|
+
if (h === void 0) return null;
|
|
15
15
|
if (c.startsWith(":")) {
|
|
16
|
-
a[c.slice(1)] =
|
|
16
|
+
a[c.slice(1)] = h;
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
-
if (c !==
|
|
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
|
|
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 q(e,
|
|
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}\`.`
|
|
@@ -81,27 +81,31 @@ function Q(e) {
|
|
|
81
81
|
"product",
|
|
82
82
|
"`modules` foi removido na 0.8.0 e é ignorado: cada rota é uma tela, e os cenários da rota são as variações dela."
|
|
83
83
|
);
|
|
84
|
-
const
|
|
84
|
+
const h = /* @__PURE__ */ new Set();
|
|
85
85
|
for (const [l, n] of (e.routes ?? []).entries()) {
|
|
86
86
|
const i = `route:${n?.path ?? l}`;
|
|
87
87
|
if (!u(n?.path)) {
|
|
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 `/`."),
|
|
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",
|
|
@@ -112,7 +116,7 @@ function Q(e) {
|
|
|
112
116
|
for (const l of e.routes ?? []) {
|
|
113
117
|
if (!u(l?.path)) continue;
|
|
114
118
|
const n = `route:${l.path}`;
|
|
115
|
-
|
|
119
|
+
W(e, l, n, o);
|
|
116
120
|
for (const i of Array.isArray(l.components) ? l.components : [])
|
|
117
121
|
f.has(i) || o(
|
|
118
122
|
"warning",
|
|
@@ -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,27 +146,27 @@ 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 \`${
|
|
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
|
}
|
|
164
168
|
}
|
|
165
|
-
n?.route && !
|
|
169
|
+
n?.route && !_(n.route, e) && o(
|
|
166
170
|
"error",
|
|
167
171
|
i,
|
|
168
172
|
`Rota \`${n.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
|
|
@@ -173,18 +177,18 @@ 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
|
|
182
|
-
if (u(c?.id) ?
|
|
183
|
-
o("error",
|
|
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)) {
|
|
187
|
+
o("error", h, "`controls` do grupo deve ser uma lista.");
|
|
184
188
|
continue;
|
|
185
189
|
}
|
|
186
190
|
for (const [f, d] of c.controls.entries()) {
|
|
187
|
-
const l = `${
|
|
191
|
+
const l = `${h}/control:${d?.id ?? f}`;
|
|
188
192
|
u(d?.id) ? z.test(d.id) ? a.has(d.id) ? o("error", l, `\`id\` de controle duplicado na tela: \`${d.id}\`.`) : a.add(d.id) : o(
|
|
189
193
|
"error",
|
|
190
194
|
l,
|
|
@@ -206,105 +210,105 @@ function _(e, r, o) {
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
|
-
function
|
|
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) ||
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
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.`);
|
|
222
|
+
const h = a.filter((f) => f !== "*" && !u(c[f]));
|
|
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 ${
|
|
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 =
|
|
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
|
|
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
|
|
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
|
-
const
|
|
265
|
+
const w = {
|
|
262
266
|
enabled: "handoff",
|
|
263
267
|
scenario: "allowScenario",
|
|
264
268
|
route: "allowRoute",
|
|
265
269
|
component: "allowComponent"
|
|
266
270
|
};
|
|
267
|
-
function
|
|
268
|
-
if (e.get(
|
|
271
|
+
function ee(e) {
|
|
272
|
+
if (e.get(w.enabled) === "1")
|
|
269
273
|
return k({
|
|
270
|
-
scenarios: e.getAll(
|
|
271
|
-
routes: e.getAll(
|
|
272
|
-
components: e.getAll(
|
|
274
|
+
scenarios: e.getAll(w.scenario),
|
|
275
|
+
routes: e.getAll(w.route),
|
|
276
|
+
components: e.getAll(w.component)
|
|
273
277
|
});
|
|
274
278
|
}
|
|
275
|
-
function
|
|
276
|
-
for (const
|
|
277
|
-
if (!
|
|
278
|
-
e.set(
|
|
279
|
-
const o = k(
|
|
280
|
-
for (const
|
|
281
|
-
for (const
|
|
282
|
-
for (const
|
|
279
|
+
function N(e, t) {
|
|
280
|
+
for (const r of Object.values(w)) e.delete(r);
|
|
281
|
+
if (!t) return;
|
|
282
|
+
e.set(w.enabled, "1");
|
|
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
|
|
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
|
-
const
|
|
311
|
+
const m = {
|
|
308
312
|
scenario: "scenario",
|
|
309
313
|
component: "component",
|
|
310
314
|
persona: "persona",
|
|
@@ -322,178 +326,190 @@ const g = {
|
|
|
322
326
|
zoom: "zoom",
|
|
323
327
|
rotated: "rotate",
|
|
324
328
|
highlight: "highlight"
|
|
325
|
-
},
|
|
326
|
-
...Object.values(
|
|
327
|
-
...Object.values(
|
|
329
|
+
}, y = "c.", H = /* @__PURE__ */ new Set([
|
|
330
|
+
...Object.values(m),
|
|
331
|
+
...Object.values(w)
|
|
328
332
|
]);
|
|
329
333
|
function re(e) {
|
|
330
|
-
return e.startsWith(
|
|
334
|
+
return e.startsWith(y) || H.has(e);
|
|
331
335
|
}
|
|
332
|
-
function
|
|
333
|
-
const
|
|
334
|
-
for (const [
|
|
335
|
-
if (!
|
|
336
|
-
const s =
|
|
336
|
+
function ne(e) {
|
|
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
|
-
function
|
|
342
|
-
for (const
|
|
343
|
-
|
|
345
|
+
function ae(e) {
|
|
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
|
|
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
|
-
|
|
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
|
-
const a =
|
|
361
|
-
a && e.set(a, G(
|
|
364
|
+
const a = m[o];
|
|
365
|
+
a && e.set(a, G(r));
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
const $ = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
|
|
369
|
+
m.chromeTheme,
|
|
370
|
+
m.chrome,
|
|
371
|
+
m.inspector,
|
|
372
|
+
m.panelTab,
|
|
373
|
+
m.zoom,
|
|
374
|
+
m.rotated
|
|
371
375
|
];
|
|
372
|
-
function
|
|
373
|
-
const o = new URLSearchParams(
|
|
374
|
-
for (const
|
|
375
|
-
return o.delete(
|
|
376
|
-
}
|
|
377
|
-
function se(e) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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()}`;
|
|
380
|
+
}
|
|
381
|
+
function se(e, t, o) {
|
|
382
|
+
let { path: r, search: a } = o;
|
|
383
|
+
if (e)
|
|
384
|
+
try {
|
|
385
|
+
const c = new URL(e);
|
|
386
|
+
c.origin === t && ({ pathname: r, search: a } = c);
|
|
387
|
+
} catch {
|
|
388
|
+
}
|
|
389
|
+
const s = new URLSearchParams(a);
|
|
390
|
+
return s.delete(m.viewport), s.delete(m.customWidth), V(r, `?${s.toString()}`);
|
|
382
391
|
}
|
|
383
392
|
function ce(e) {
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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}` : "" };
|
|
397
|
+
}
|
|
398
|
+
function le(e) {
|
|
399
|
+
const t = new URL(e, "http://design-space.invalid");
|
|
400
|
+
return `${t.pathname}|${t.searchParams.get(m.component) ?? ""}`;
|
|
401
|
+
}
|
|
402
|
+
function de(e, t) {
|
|
403
|
+
const o = new URLSearchParams(e), r = new URLSearchParams(t);
|
|
404
|
+
o.delete($);
|
|
405
|
+
for (const s of T) {
|
|
391
406
|
o.delete(s);
|
|
392
|
-
const c =
|
|
407
|
+
const c = r.get(s);
|
|
393
408
|
c !== null && o.set(s, c);
|
|
394
409
|
}
|
|
395
410
|
const a = o.toString();
|
|
396
411
|
return a ? `?${a}` : "";
|
|
397
412
|
}
|
|
398
|
-
function
|
|
413
|
+
function Z(e) {
|
|
399
414
|
if (!e || typeof e != "object") return !1;
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
switch (
|
|
415
|
+
const t = e;
|
|
416
|
+
if (t.ds !== 1 || typeof t.type != "string") return !1;
|
|
417
|
+
switch (t.type) {
|
|
403
418
|
case "ready":
|
|
404
419
|
case "location":
|
|
405
|
-
return typeof
|
|
420
|
+
return typeof t.url == "string";
|
|
406
421
|
case "navigate":
|
|
407
|
-
return typeof
|
|
422
|
+
return typeof t.url == "string";
|
|
408
423
|
case "shortcut":
|
|
409
|
-
return ["C", "K", "F"].includes(
|
|
424
|
+
return ["C", "K", "F"].includes(t.key);
|
|
410
425
|
default:
|
|
411
426
|
return !1;
|
|
412
427
|
}
|
|
413
428
|
}
|
|
414
|
-
function
|
|
415
|
-
if (e.origin ===
|
|
416
|
-
return
|
|
429
|
+
function fe(e, t) {
|
|
430
|
+
if (e.origin === t.origin && !(!t.source || e.source !== t.source))
|
|
431
|
+
return Z(e.data) ? e.data : void 0;
|
|
417
432
|
}
|
|
418
|
-
function
|
|
433
|
+
function ue(e, t, o) {
|
|
419
434
|
try {
|
|
420
|
-
e?.postMessage(
|
|
435
|
+
e?.postMessage(t, o);
|
|
421
436
|
} catch {
|
|
422
437
|
}
|
|
423
438
|
}
|
|
424
|
-
function
|
|
439
|
+
function pe(e = typeof window > "u" ? void 0 : window) {
|
|
425
440
|
if (!e) return !1;
|
|
426
|
-
if (new URLSearchParams(e.location.search).get(
|
|
441
|
+
if (new URLSearchParams(e.location.search).get($) === "1") return !0;
|
|
427
442
|
try {
|
|
428
443
|
return !!e.frameElement?.hasAttribute(K);
|
|
429
444
|
} catch {
|
|
430
445
|
return !1;
|
|
431
446
|
}
|
|
432
447
|
}
|
|
433
|
-
function
|
|
434
|
-
const
|
|
448
|
+
function U(e = {}) {
|
|
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");
|
|
435
450
|
return {
|
|
436
451
|
env: a,
|
|
437
452
|
origin: s.replace(/\/$/, ""),
|
|
438
|
-
branchUrl:
|
|
453
|
+
branchUrl: t,
|
|
439
454
|
deploymentUrl: o,
|
|
440
455
|
branch: e.branch || void 0,
|
|
441
|
-
commit:
|
|
442
|
-
shortCommit:
|
|
456
|
+
commit: r,
|
|
457
|
+
shortCommit: r?.slice(0, 7),
|
|
443
458
|
isDeployed: a === "preview" || a === "production"
|
|
444
459
|
};
|
|
445
460
|
}
|
|
446
|
-
function
|
|
447
|
-
const o =
|
|
448
|
-
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();
|
|
449
464
|
}
|
|
450
|
-
function
|
|
451
|
-
const o =
|
|
452
|
-
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();
|
|
453
468
|
}
|
|
454
|
-
function
|
|
455
|
-
const o =
|
|
469
|
+
function he(e, t) {
|
|
470
|
+
const o = t.commit ?? U().commit;
|
|
456
471
|
if (!o) return;
|
|
457
|
-
const
|
|
458
|
-
return
|
|
472
|
+
const r = t.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
|
|
473
|
+
return J(e, { origin: r });
|
|
459
474
|
}
|
|
460
475
|
export {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
G,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
oe as
|
|
474
|
-
te as
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
me as A,
|
|
477
|
+
Y as B,
|
|
478
|
+
y as C,
|
|
479
|
+
X as D,
|
|
480
|
+
I as E,
|
|
481
|
+
$ as F,
|
|
482
|
+
k as G,
|
|
483
|
+
w as H,
|
|
484
|
+
G as I,
|
|
485
|
+
q as J,
|
|
486
|
+
j as N,
|
|
487
|
+
m as P,
|
|
488
|
+
oe as a,
|
|
489
|
+
te as b,
|
|
490
|
+
ne as c,
|
|
491
|
+
N as d,
|
|
492
|
+
ue as e,
|
|
493
|
+
ce as f,
|
|
494
|
+
fe as g,
|
|
479
495
|
D as h,
|
|
480
496
|
re as i,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
497
|
+
ae as j,
|
|
498
|
+
J as k,
|
|
499
|
+
F as l,
|
|
500
|
+
T as m,
|
|
501
|
+
le as n,
|
|
486
502
|
K as o,
|
|
487
|
-
|
|
488
|
-
|
|
503
|
+
ee as p,
|
|
504
|
+
ie as q,
|
|
489
505
|
P as r,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
506
|
+
E as s,
|
|
507
|
+
V as t,
|
|
508
|
+
pe as u,
|
|
493
509
|
Q as v,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
510
|
+
U as w,
|
|
511
|
+
de as x,
|
|
512
|
+
se as y,
|
|
513
|
+
he as z
|
|
498
514
|
};
|
|
499
|
-
//# sourceMappingURL=index-
|
|
515
|
+
//# sourceMappingURL=index-CLox5DuH.js.map
|