@brucesantos/design-space 0.11.0 → 0.12.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 CHANGED
@@ -6,6 +6,35 @@ Versionamento semântico. **Patch** para correção sem mudança de contrato,
6
6
  Mudança estrutural — pasta obrigatória nova, schema de cenário alterado — exige
7
7
  comando explícito e revisável, nunca merge silencioso.
8
8
 
9
+ ## 0.12.0 (2026-10-11)
10
+
11
+ **Minor.** Botão novo no chrome e um rótulo novo em `Labels`; nenhum export,
12
+ parâmetro ou comportamento existente muda.
13
+
14
+ ### Adicionado
15
+
16
+ - **"Abrir em nova janela" na barra superior**, ao lado da revisão limpa. Abre
17
+ numa aba nova o quadro sozinho (`ds-frame=1`), sem chrome e sem `<iframe>`, no
18
+ endereço que o quadro está mostrando — inclusive depois de a UI do produto
19
+ navegar dentro dele. Os parâmetros só do chrome e o viewport ficam de fora
20
+ (a largura é a da janela nova, em "Ajustar"); cenário, persona, fixture,
21
+ rede, controles, query da tela, tema, idioma e handoff vão junto. É o caminho para ferramenta de captura que lê só o documento de cima,
22
+ como as extensões que levam HTML para o Figma: com `chrome=0` a UI continua
23
+ dentro do `<iframe>`, e a captura vê um bloco só.
24
+ - Rótulo `topbar.openFrame` ("Abrir em nova janela" / "Open in new window"),
25
+ sobrescrevível por `theme.labels` como os demais.
26
+
27
+ ### Sem mudança
28
+
29
+ - `chrome=0` continua escondendo o chrome com a UI dentro do
30
+ `<iframe data-ds-frame>`.
31
+
32
+ ### Migração
33
+
34
+ - Produto que declara `Labels` inteiro (em vez de override parcial) precisa
35
+ incluir `topbar.openFrame`. Quem usa `theme.labels` parcial ou
36
+ `EN_US_LABELS` não faz nada.
37
+
9
38
  ## 0.11.0 (2026-10-09)
10
39
 
11
40
  **Minor.** Funcionalidade compatível: um parâmetro de URL, um campo opcional em
package/README.md CHANGED
@@ -230,7 +230,7 @@ painel continuam vencendo. Id inexistente é erro de validação. Sem
230
230
 
231
231
  | Região | Conteúdo |
232
232
  | --- | --- |
233
- | Barra superior | Nome do produto; viewport (Celular 375, Tablet 768, Desktop 1280, Ajustar), girar, zoom 25–150%, copiar link, revisão limpa, tema, painel e — quando a validação tem algo a dizer — o indicador de diagnóstico. |
233
+ | Barra superior | Nome do produto; viewport (Celular 375, Tablet 768, Desktop 1280, Ajustar), girar, zoom 25–150%, revisão limpa, abrir em nova janela, copiar link, tema, painel e — quando a validação tem algo a dizer — o indicador de diagnóstico. |
234
234
  | Esquerda | **Telas** e **Componentes**, com contagem e busca sem acento nem caixa (nome, descrição, fluxo ou grupo, id e `source`). Telas agrupadas por fluxo (`route.group`), componentes por `group`. Redimensionável. |
235
235
  | Centro | O quadro do produto no tamanho do viewport, com zoom só de visualização. |
236
236
  | Direita | **Variações** (contexto no topo, controles da tela por componente e os cenários como atalhos; ou as fixtures do componente) e **Informações** (rota, fluxo, controles, intenção, pré-condições, ações, comportamento esperado, regras, componentes usados e **Copiar para o PR**). Redimensionável. |
@@ -255,6 +255,23 @@ entrada no histórico. Navegação feita pela UI do produto (`context.navigate`,
255
255
  `openScenario` ou um link comum) volta para a URL do chrome. Os dois lados só
256
256
  aceitam mensagem da mesma origem e da janela esperada.
257
257
 
258
+ ### Abrir em nova janela
259
+
260
+ O botão ao lado da revisão limpa abre o quadro sozinho, numa aba nova: o mesmo
261
+ endereço com `ds-frame=1`, sem chrome e sem `<iframe>`. É o caminho para
262
+ ferramenta de captura que lê só o documento de cima — como as extensões que
263
+ levam HTML para o Figma. `chrome=0` não serve para isso: ele esconde o chrome,
264
+ mas a UI continua dentro do `<iframe>`, e a ferramenta enxerga um bloco só.
265
+
266
+ O endereço é o que o quadro está mostrando, inclusive depois de o produto
267
+ navegar dentro dele. Cenário, persona, fixture, rede, controles e query da tela,
268
+ tema, idioma e handoff vão junto; os parâmetros só do chrome (`appearance`,
269
+ `chrome`, `panel`, `tab`, `zoom`, `rotate`) ficam de fora. O viewport (`viewport`,
270
+ `w`) também fica: a largura é a da janela nova, e o quadro abre em "Ajustar",
271
+ então `context.viewport` e `@media` concordam. Para capturar a tela de celular,
272
+ estreite a janela. Sem janela pai, o quadro funciona sozinho; só os atalhos do
273
+ chrome deixam de existir.
274
+
258
275
  ### Navegação
259
276
 
260
277
  `context.navigate(to, options?)` — e um link comum dentro do quadro — segue duas
@@ -65,6 +65,25 @@ export type FrameMessage =
65
65
  * chegam à mesma string para o mesmo estado, e é isso que evita recarga à toa.
66
66
  */
67
67
  export declare function toFrameUrl(path: string, search: string): string;
68
+ /**
69
+ * Endereço para abrir o quadro sozinho, numa janela própria. É o caminho para
70
+ * ferramenta de captura que lê só o documento de cima e não entra no `<iframe>`.
71
+ *
72
+ * Parte do endereço que o quadro está mostrando de fato (`frameHref`), porque a
73
+ * UI do produto pode ter navegado dentro dele; sem esse endereço — quadro ainda
74
+ * em `about:blank`, em outra origem ou inacessível —, parte do estado do pai.
75
+ * Nos dois casos sai pelo `toFrameUrl`: sem os parâmetros do chrome e com
76
+ * `ds-frame=1`, mesmo que uma navegação completa do quadro o tenha perdido.
77
+ *
78
+ * O viewport também fica de fora. Na janela própria a largura é a da janela, e
79
+ * sem o parâmetro o quadro cai em "Ajustar": `context.viewport` e `@media`
80
+ * contam a mesma história. Com `viewport=mobile` numa janela larga, a tela que
81
+ * decide pelo contexto mostraria celular esticado.
82
+ */
83
+ export declare function standaloneFrameUrl(frameHref: string | undefined, origin: string, fallback: {
84
+ path: string;
85
+ search: string;
86
+ }): string;
68
87
  /** Caminho e query de um endereço do quadro, sem o parâmetro de modo. */
69
88
  export declare function fromFrameUrl(url: string): {
70
89
  path: string;
@@ -10,13 +10,13 @@ function j(e, r) {
10
10
  for (const [s, c] of o.entries()) {
11
11
  if (c === "*")
12
12
  return a["*"] = t.slice(s).join("/"), a;
13
- const m = t[s];
14
- if (m === void 0) return null;
13
+ const h = t[s];
14
+ if (h === void 0) return null;
15
15
  if (c.startsWith(":")) {
16
- a[c.slice(1)] = m;
16
+ a[c.slice(1)] = h;
17
17
  continue;
18
18
  }
19
- if (c !== m) return null;
19
+ if (c !== h) return null;
20
20
  }
21
21
  return o.length !== t.length ? null : a;
22
22
  }
@@ -27,7 +27,7 @@ function P(e, r) {
27
27
  if (a) return { definition: t, params: a };
28
28
  }
29
29
  }
30
- function F(e, r = {}) {
30
+ function E(e, r = {}) {
31
31
  const o = (a) => {
32
32
  const s = r[a];
33
33
  return typeof s == "string" && s.length > 0 ? s : void 0;
@@ -62,7 +62,7 @@ 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, r) {
65
+ function L(e, r) {
66
66
  const o = [], t = u(e?.id) ? `scenario:${e.id}` : `scenario[${r ?? "?"}]`, a = (c) => o.push({ level: "error", where: t, message: c }), s = (c) => o.push({ level: "warning", where: t, 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`."
@@ -81,14 +81,14 @@ 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 m = /* @__PURE__ */ new Set();
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 `/`."), m.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), m.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) ? _(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
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) ? q(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()) {
@@ -96,12 +96,12 @@ function Q(e) {
96
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.");
97
97
  const p = /* @__PURE__ */ new Set();
98
98
  for (const [b, v] of (n?.fixtures ?? []).entries()) {
99
- const h = `${i}/fixture:${v?.id ?? b}`;
100
- u(v?.id) ? R.test(v.id) ? p.has(v.id) ? o("error", h, `Id de fixture do componente duplicado: \`${v.id}\`.`) : p.add(v.id) : o(
99
+ const g = `${i}/fixture:${v?.id ?? b}`;
100
+ u(v?.id) ? R.test(v.id) ? p.has(v.id) ? o("error", g, `Id de fixture do componente duplicado: \`${v.id}\`.`) : p.add(v.id) : o(
101
101
  "error",
102
- h,
102
+ g,
103
103
  `Id de fixture do componente inválido: \`${v.id}\`. Use minúsculas em kebab-case.`
104
- ) : o("error", h, "`id` da fixture do componente é obrigatório."), u(v?.label) || o("error", h, "`label` da fixture do componente é obrigatório."), (!v || !("data" in v)) && o("error", h, "`data` da fixture do componente é obrigatório.");
104
+ ) : o("error", g, "`id` da fixture do componente é obrigatório."), u(v?.label) || o("error", g, "`label` da fixture do componente é obrigatório."), (!v || !("data" in v)) && o("error", g, "`data` da fixture do componente é obrigatório.");
105
105
  }
106
106
  n?.defaultFixture && !p.has(n.defaultFixture) && o(
107
107
  "error",
@@ -112,7 +112,7 @@ function Q(e) {
112
112
  for (const l of e.routes ?? []) {
113
113
  if (!u(l?.path)) continue;
114
114
  const n = `route:${l.path}`;
115
- B(e, l, n, o);
115
+ W(e, l, n, o);
116
116
  for (const i of Array.isArray(l.components) ? l.components : [])
117
117
  f.has(i) || o(
118
118
  "warning",
@@ -127,7 +127,7 @@ function Q(e) {
127
127
  );
128
128
  }
129
129
  for (const [l, n] of (e.scenarios ?? []).entries()) {
130
- r.push(...q(n, l));
130
+ r.push(...L(n, l));
131
131
  const i = `scenario:${n?.id ?? l}`;
132
132
  n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !t.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
133
  for (const p of n?.rules ?? [])
@@ -143,26 +143,26 @@ function Q(e) {
143
143
  o("error", i, "`controls`, quando informado, é um objeto de id do controle → valor.");
144
144
  else if (n.route) {
145
145
  const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], v = new Map(
146
- b.flatMap((h) => Array.isArray(h?.controls) ? h.controls : []).map((h) => [
147
- h?.id,
148
- h
146
+ b.flatMap((g) => Array.isArray(g?.controls) ? g.controls : []).map((g) => [
147
+ g?.id,
148
+ g
149
149
  ])
150
150
  );
151
- for (const [h, U] of Object.entries(n.controls)) {
152
- const x = v.get(h);
153
- x ? (x.options ?? []).some((A) => A?.value === U) || o(
151
+ for (const [g, O] of Object.entries(n.controls)) {
152
+ const x = v.get(g);
153
+ x ? (x.options ?? []).some((A) => A?.value === O) || o(
154
154
  "error",
155
155
  i,
156
- `Valor \`${U}\` não é opção do controle \`${h}\`. Opções: ${(x.options ?? []).map((A) => `\`${A?.value}\``).join(", ")}.`
156
+ `Valor \`${O}\` não é opção do controle \`${g}\`. Opções: ${(x.options ?? []).map((A) => `\`${A?.value}\``).join(", ")}.`
157
157
  ) : o(
158
158
  "error",
159
159
  i,
160
- `Controle \`${h}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
160
+ `Controle \`${g}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
161
161
  );
162
162
  }
163
163
  }
164
164
  }
165
- n?.route && !L(n.route, e) && o(
165
+ n?.route && !_(n.route, e) && o(
166
166
  "error",
167
167
  i,
168
168
  `Rota \`${n.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
@@ -175,16 +175,16 @@ function Q(e) {
175
175
  "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
176
  )), r;
177
177
  }
178
- function _(e, r, o) {
178
+ function q(e, r, o) {
179
179
  const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
180
180
  for (const [s, c] of e.entries()) {
181
- const m = `${r}/group:${c?.id ?? s}`;
182
- if (u(c?.id) ? t.has(c.id) ? o("error", m, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : t.add(c.id) : o("error", m, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", m, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
183
- o("error", m, "`controls` do grupo deve ser uma lista.");
181
+ const h = `${r}/group:${c?.id ?? s}`;
182
+ if (u(c?.id) ? t.has(c.id) ? o("error", h, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : t.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
+ o("error", h, "`controls` do grupo deve ser uma lista.");
184
184
  continue;
185
185
  }
186
186
  for (const [f, d] of c.controls.entries()) {
187
- const l = `${m}/control:${d?.id ?? f}`;
187
+ const l = `${h}/control:${d?.id ?? f}`;
188
188
  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
189
  "error",
190
190
  l,
@@ -206,7 +206,7 @@ function _(e, r, o) {
206
206
  }
207
207
  }
208
208
  }
209
- function B(e, r, o, t) {
209
+ function W(e, r, o, t) {
210
210
  const a = r.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = r.params;
211
211
  if (s !== void 0 && (!s || typeof s != "object" || Array.isArray(s))) {
212
212
  t("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
@@ -215,19 +215,19 @@ function B(e, r, o, t) {
215
215
  const c = s ?? {};
216
216
  for (const [f, d] of Object.entries(c))
217
217
  a.includes(f) ? u(d) || t("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : t("warning", o, `\`params.${f}\` não é parâmetro de \`${r.path}\` e é ignorado.`);
218
- const m = a.filter((f) => f !== "*" && !u(c[f]));
219
- if (m.length > 0) {
218
+ const h = a.filter((f) => f !== "*" && !u(c[f]));
219
+ if (h.length > 0) {
220
220
  (e.scenarios ?? []).some(
221
221
  (d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === r.path
222
222
  ) || t(
223
223
  "warning",
224
224
  o,
225
- `Sem exemplo para ${m.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${r.path}\`. Declare \`params: { ${m.map((d) => `${d}: "…"`).join(", ")} }\`.`
225
+ `Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${r.path}\`. Declare \`params: { ${h.map((d) => `${d}: "…"`).join(", ")} }\`.`
226
226
  );
227
227
  return;
228
228
  }
229
229
  if (a.length > 0) {
230
- const f = F(r.path, c), d = P(e.routes ?? [], f);
230
+ const f = E(r.path, c), d = P(e.routes ?? [], f);
231
231
  d && d.definition.path !== r.path && t(
232
232
  "warning",
233
233
  o,
@@ -235,11 +235,11 @@ function B(e, r, o, t) {
235
235
  );
236
236
  }
237
237
  }
238
- function L(e, r) {
238
+ function _(e, r) {
239
239
  const o = e.split("?")[0] ?? e;
240
- return (r.routes ?? []).some((t) => N(t.path, o));
240
+ return (r.routes ?? []).some((t) => B(t.path, o));
241
241
  }
242
- function N(e, r) {
242
+ function B(e, r) {
243
243
  const o = e.split("/").filter(Boolean), t = r.split("/").filter(Boolean);
244
244
  for (const [a, s] of o.entries()) {
245
245
  if (s === "*") return !0;
@@ -258,28 +258,28 @@ function Y(e) {
258
258
  ${r.message}`).join(`
259
259
  `);
260
260
  }
261
- const $ = {
261
+ const w = {
262
262
  enabled: "handoff",
263
263
  scenario: "allowScenario",
264
264
  route: "allowRoute",
265
265
  component: "allowComponent"
266
266
  };
267
- function J(e) {
268
- if (e.get($.enabled) === "1")
267
+ function ee(e) {
268
+ if (e.get(w.enabled) === "1")
269
269
  return k({
270
- scenarios: e.getAll($.scenario),
271
- routes: e.getAll($.route),
272
- components: e.getAll($.component)
270
+ scenarios: e.getAll(w.scenario),
271
+ routes: e.getAll(w.route),
272
+ components: e.getAll(w.component)
273
273
  });
274
274
  }
275
- function W(e, r) {
276
- for (const t of Object.values($)) e.delete(t);
275
+ function N(e, r) {
276
+ for (const t of Object.values(w)) e.delete(t);
277
277
  if (!r) return;
278
- e.set($.enabled, "1");
278
+ e.set(w.enabled, "1");
279
279
  const o = k(r);
280
- for (const t of o.scenarios ?? []) e.append($.scenario, t);
281
- for (const t of o.routes ?? []) e.append($.route, t);
282
- for (const t of o.components ?? []) e.append($.component, t);
280
+ for (const t of o.scenarios ?? []) e.append(w.scenario, t);
281
+ for (const t of o.routes ?? []) e.append(w.route, t);
282
+ for (const t of o.components ?? []) e.append(w.component, t);
283
283
  }
284
284
  function k(e) {
285
285
  const r = S(e.scenarios), o = S(e.routes), t = S(e.components);
@@ -292,10 +292,10 @@ function k(e) {
292
292
  function D(e, r) {
293
293
  return !e || !!(r && e.scenarios?.includes(r));
294
294
  }
295
- function ee(e, r) {
295
+ function oe(e, r) {
296
296
  return !e || !!(r && e.components?.includes(r));
297
297
  }
298
- function oe(e, r, o = []) {
298
+ function re(e, r, o = []) {
299
299
  return !e || r === "/" ? !0 : [
300
300
  ...e.routes ?? [],
301
301
  ...o.filter((a) => D(e, a.id)).map((a) => a.route)
@@ -304,7 +304,7 @@ function oe(e, r, o = []) {
304
304
  function S(e) {
305
305
  return [...new Set((e ?? []).map((r) => r.trim()).filter(Boolean))].sort();
306
306
  }
307
- const g = {
307
+ const m = {
308
308
  scenario: "scenario",
309
309
  component: "component",
310
310
  persona: "persona",
@@ -322,72 +322,83 @@ const g = {
322
322
  zoom: "zoom",
323
323
  rotated: "rotate",
324
324
  highlight: "highlight"
325
- }, w = "c.", H = /* @__PURE__ */ new Set([
326
- ...Object.values(g),
327
- ...Object.values($)
325
+ }, $ = "c.", H = /* @__PURE__ */ new Set([
326
+ ...Object.values(m),
327
+ ...Object.values(w)
328
328
  ]);
329
- function re(e) {
330
- return e.startsWith(w) || H.has(e);
331
- }
332
329
  function te(e) {
330
+ return e.startsWith($) || H.has(e);
331
+ }
332
+ function ne(e) {
333
333
  const r = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
334
334
  for (const [t, a] of r) {
335
- if (!t.startsWith(w)) continue;
336
- const s = t.slice(w.length);
335
+ if (!t.startsWith($)) continue;
336
+ const s = t.slice($.length);
337
337
  s && (o[s] = a);
338
338
  }
339
339
  return o;
340
340
  }
341
- function ne(e) {
341
+ function ae(e) {
342
342
  for (const r of [...e.keys()])
343
- r.startsWith(w) && e.delete(r);
343
+ r.startsWith($) && e.delete(r);
344
344
  }
345
345
  function G(e) {
346
346
  return typeof e == "boolean" ? e ? "1" : "0" : String(e);
347
347
  }
348
- function T(e, r = {}) {
348
+ function F(e, r = {}) {
349
349
  for (const [o, t] of Object.entries(r)) {
350
350
  if (t == null) continue;
351
351
  if (o === "handoff") {
352
- W(e, t);
352
+ N(e, t);
353
353
  continue;
354
354
  }
355
355
  if (o === "screenControls") {
356
356
  for (const [s, c] of Object.entries(t))
357
- e.set(`${w}${s}`, c);
357
+ e.set(`${$}${s}`, c);
358
358
  continue;
359
359
  }
360
- const a = g[o];
360
+ const a = m[o];
361
361
  a && e.set(a, G(t));
362
362
  }
363
363
  }
364
- const y = "ds-frame", K = "data-ds-frame", ae = "data-ds-component", E = [
365
- g.chromeTheme,
366
- g.chrome,
367
- g.inspector,
368
- g.panelTab,
369
- g.zoom,
370
- g.rotated
364
+ const y = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
365
+ m.chromeTheme,
366
+ m.chrome,
367
+ m.inspector,
368
+ m.panelTab,
369
+ m.zoom,
370
+ m.rotated
371
371
  ];
372
- function ie(e, r) {
372
+ function V(e, r) {
373
373
  const o = new URLSearchParams(r);
374
- for (const t of E) o.delete(t);
374
+ for (const t of T) o.delete(t);
375
375
  return o.delete(y), o.set(y, "1"), `${e || "/"}?${o.toString()}`;
376
376
  }
377
- function se(e) {
377
+ function se(e, r, o) {
378
+ let { path: t, search: a } = o;
379
+ if (e)
380
+ try {
381
+ const c = new URL(e);
382
+ c.origin === r && ({ pathname: t, search: a } = c);
383
+ } catch {
384
+ }
385
+ const s = new URLSearchParams(a);
386
+ return s.delete(m.viewport), s.delete(m.customWidth), V(t, `?${s.toString()}`);
387
+ }
388
+ function ce(e) {
378
389
  const r = new URL(e, "http://design-space.invalid");
379
390
  r.searchParams.delete(y);
380
391
  const o = r.searchParams.toString();
381
392
  return { path: r.pathname || "/", search: o ? `?${o}` : "" };
382
393
  }
383
- function ce(e) {
394
+ function le(e) {
384
395
  const r = new URL(e, "http://design-space.invalid");
385
- return `${r.pathname}|${r.searchParams.get(g.component) ?? ""}`;
396
+ return `${r.pathname}|${r.searchParams.get(m.component) ?? ""}`;
386
397
  }
387
- function le(e, r) {
398
+ function de(e, r) {
388
399
  const o = new URLSearchParams(e), t = new URLSearchParams(r);
389
400
  o.delete(y);
390
- for (const s of E) {
401
+ for (const s of T) {
391
402
  o.delete(s);
392
403
  const c = t.get(s);
393
404
  c !== null && o.set(s, c);
@@ -395,7 +406,7 @@ function le(e, r) {
395
406
  const a = o.toString();
396
407
  return a ? `?${a}` : "";
397
408
  }
398
- function V(e) {
409
+ function Z(e) {
399
410
  if (!e || typeof e != "object") return !1;
400
411
  const r = e;
401
412
  if (r.ds !== 1 || typeof r.type != "string") return !1;
@@ -411,17 +422,17 @@ function V(e) {
411
422
  return !1;
412
423
  }
413
424
  }
414
- function de(e, r) {
425
+ function fe(e, r) {
415
426
  if (e.origin === r.origin && !(!r.source || e.source !== r.source))
416
- return V(e.data) ? e.data : void 0;
427
+ return Z(e.data) ? e.data : void 0;
417
428
  }
418
- function fe(e, r, o) {
429
+ function ue(e, r, o) {
419
430
  try {
420
431
  e?.postMessage(r, o);
421
432
  } catch {
422
433
  }
423
434
  }
424
- function ue(e = typeof window > "u" ? void 0 : window) {
435
+ function pe(e = typeof window > "u" ? void 0 : window) {
425
436
  if (!e) return !1;
426
437
  if (new URLSearchParams(e.location.search).get(y) === "1") return !0;
427
438
  try {
@@ -430,7 +441,7 @@ function ue(e = typeof window > "u" ? void 0 : window) {
430
441
  return !1;
431
442
  }
432
443
  }
433
- function O(e = {}) {
444
+ function U(e = {}) {
434
445
  const r = e.branchUrl || void 0, o = e.deploymentUrl || void 0, t = e.commit || void 0, a = e.env || "development", s = r && `https://${r}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
435
446
  return {
436
447
  env: a,
@@ -443,57 +454,58 @@ function O(e = {}) {
443
454
  isDeployed: a === "preview" || a === "production"
444
455
  };
445
456
  }
446
- function Z(e, r = {}) {
447
- const o = r.origin ?? O().origin, t = new URL(e.route, o);
448
- return t.searchParams.set(g.scenario, e.id), e.persona && t.searchParams.set(g.persona, e.persona), t.searchParams.set(g.fixture, e.fixture), e.network && e.network !== "success" && t.searchParams.set(g.network, e.network), T(t.searchParams, r.overrides), t.toString();
457
+ function J(e, r = {}) {
458
+ const o = r.origin ?? U().origin, t = new URL(e.route, o);
459
+ return t.searchParams.set(m.scenario, e.id), e.persona && t.searchParams.set(m.persona, e.persona), t.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && t.searchParams.set(m.network, e.network), F(t.searchParams, r.overrides), t.toString();
449
460
  }
450
- function pe(e, r = {}) {
451
- const o = r.origin ?? O().origin, t = new URL("/", o), a = r.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
452
- return t.searchParams.set(g.component, e.id), a && t.searchParams.set(g.fixture, a), T(t.searchParams, r.overrides), t.toString();
461
+ function me(e, r = {}) {
462
+ const o = r.origin ?? U().origin, t = new URL("/", o), a = r.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
463
+ return t.searchParams.set(m.component, e.id), a && t.searchParams.set(m.fixture, a), F(t.searchParams, r.overrides), t.toString();
453
464
  }
454
- function me(e, r) {
455
- const o = r.commit ?? O().commit;
465
+ function he(e, r) {
466
+ const o = r.commit ?? U().commit;
456
467
  if (!o) return;
457
468
  const t = r.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
458
- return Z(e, { origin: t });
469
+ return J(e, { origin: t });
459
470
  }
460
471
  export {
461
- Y as A,
462
- X as B,
463
- w as C,
464
- j as D,
465
- k as E,
472
+ me as A,
473
+ Y as B,
474
+ $ as C,
475
+ X as D,
476
+ j as E,
466
477
  y as F,
467
- G,
468
- $ as H,
469
- q as I,
478
+ k as G,
479
+ w as H,
480
+ G as I,
481
+ L as J,
470
482
  C as N,
471
- g as P,
472
- ee as a,
473
- oe as b,
474
- te as c,
475
- W as d,
476
- fe as e,
477
- se as f,
478
- de as g,
483
+ m as P,
484
+ oe as a,
485
+ re as b,
486
+ ne as c,
487
+ N as d,
488
+ ue as e,
489
+ ce as f,
490
+ fe as g,
479
491
  D as h,
480
- re as i,
481
- ne as j,
482
- Z as k,
483
- T as l,
484
- E as m,
485
- ce as n,
492
+ te as i,
493
+ ae as j,
494
+ J as k,
495
+ F as l,
496
+ T as m,
497
+ le as n,
486
498
  K as o,
487
- J as p,
488
- ae as q,
499
+ ee as p,
500
+ ie as q,
489
501
  P as r,
490
- F as s,
491
- ie as t,
492
- ue as u,
502
+ E as s,
503
+ V as t,
504
+ pe as u,
493
505
  Q as v,
494
- O as w,
495
- le as x,
496
- me as y,
497
- pe as z
506
+ U as w,
507
+ de as x,
508
+ se as y,
509
+ he as z
498
510
  };
499
- //# sourceMappingURL=index-Dv-W-bL0.js.map
511
+ //# sourceMappingURL=index-rWBjjVMg.js.map