@plitzi/sdk-dev-tools 0.38.23 → 0.39.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +172 -1
  2. package/dist/DevToolsContainer.d.ts +11 -1
  3. package/dist/DevToolsContainer.mjs +68 -62
  4. package/dist/DevToolsContextProvider.mjs +5 -3
  5. package/dist/PageContext.d.ts +7 -0
  6. package/dist/PageContext.mjs +6 -0
  7. package/dist/agentInspector/flowRuns.d.ts +1 -1
  8. package/dist/agentInspector/flowRuns.mjs +22 -15
  9. package/dist/agentInspector/index.d.ts +2 -0
  10. package/dist/agentInspector/index.mjs +1 -0
  11. package/dist/agentInspector/inspector.d.ts +31 -1
  12. package/dist/agentInspector/inspector.mjs +57 -19
  13. package/dist/agentInspector/report.d.ts +27 -2
  14. package/dist/agentInspector/report.mjs +59 -38
  15. package/dist/agentInspector/useAgentInspector.d.ts +3 -2
  16. package/dist/agentInspector/useAgentInspector.mjs +20 -16
  17. package/dist/components/DevToolsOverlay/DevToolsOverlay.d.ts +3 -4
  18. package/dist/components/DevToolsOverlay/DevToolsOverlay.mjs +4 -4
  19. package/dist/components/DevToolsPanel/DevToolsBody.d.ts +4 -1
  20. package/dist/components/DevToolsPanel/DevToolsBody.mjs +33 -31
  21. package/dist/components/DevToolsPanel/DevToolsButton.d.ts +3 -1
  22. package/dist/components/DevToolsPanel/DevToolsButton.mjs +4 -3
  23. package/dist/components/DevToolsPanel/DevToolsHeader.d.ts +3 -1
  24. package/dist/components/DevToolsPanel/DevToolsHeader.mjs +52 -34
  25. package/dist/components/DevToolsPanel/DevToolsPanel.d.ts +3 -1
  26. package/dist/components/DevToolsPanel/DevToolsPanel.mjs +50 -47
  27. package/dist/components/DevToolsPanel/tabs/QaViewer/QaReplayButton.mjs +2 -2
  28. package/dist/components/DevToolsPanel/tabs/RunViewer/RunReport.d.ts +7 -0
  29. package/dist/components/DevToolsPanel/tabs/RunViewer/RunReport.mjs +97 -0
  30. package/dist/components/DevToolsPanel/tabs/RunViewer/RunTaskRow.d.ts +6 -0
  31. package/dist/components/DevToolsPanel/tabs/RunViewer/RunTaskRow.mjs +79 -0
  32. package/dist/components/DevToolsPanel/tabs/RunViewer/RunViewer.d.ts +11 -0
  33. package/dist/components/DevToolsPanel/tabs/RunViewer/RunViewer.mjs +222 -0
  34. package/dist/components/DevToolsPanel/tabs/RunViewer/index.d.ts +3 -0
  35. package/dist/components/DevToolsPanel/tabs/RunViewer/index.mjs +6 -0
  36. package/dist/components/DevToolsPanel/tabs/RunViewer/reportHelpers.d.ts +9 -0
  37. package/dist/components/DevToolsPanel/tabs/RunViewer/reportHelpers.mjs +39 -0
  38. package/dist/components/DevToolsPanel/tabs/RunViewer/stepRecorder.d.ts +27 -0
  39. package/dist/components/DevToolsPanel/tabs/RunViewer/stepRecorder.mjs +51 -0
  40. package/dist/components/DevToolsPanel/tabs/RunViewer/usePointAt.d.ts +14 -0
  41. package/dist/components/DevToolsPanel/tabs/RunViewer/usePointAt.mjs +33 -0
  42. package/dist/components/DevToolsPanel/tabs/RunViewer/useRunSnapshot.d.ts +9 -0
  43. package/dist/components/DevToolsPanel/tabs/RunViewer/useRunSnapshot.mjs +22 -0
  44. package/dist/qa/QaContext.d.ts +2 -5
  45. package/dist/qa/QaContext.mjs +28 -31
  46. package/dist/qa/QaLayer.mjs +78 -77
  47. package/dist/qa/overlays/QaInspector.mjs +28 -27
  48. package/dist/qa/overlays/QaTabOrder.mjs +2 -2
  49. package/dist/qa/overlays/QaXrayTags.mjs +22 -22
  50. package/dist/useNarrowWindow.d.ts +8 -0
  51. package/dist/useNarrowWindow.mjs +13 -0
  52. package/package.json +4 -4
@@ -14,11 +14,25 @@ export type ElementReport = {
14
14
  source: string;
15
15
  template?: string;
16
16
  }[];
17
+ /**
18
+ * What each binding gave it now — `<category>.<to>`, from the sources it sees (a list's rows: the last row drawn): what a plugin
19
+ * received (the map's `hazards` after a filter), which the template alone does not say. Only while its sources can be
20
+ * read (debug mode).
21
+ */
22
+ resolved?: Record<string, unknown>;
17
23
  /** The element's own UI state — an open dropdown, a tab — as the runtime keeps it. */
18
24
  state?: unknown;
19
25
  /** How many copies are on the page: a list row's elements are one per row, a component's one per instance. */
20
26
  copies: number;
27
+ /**
28
+ * What its first copy shows, as a visitor reads it — its bindings resolved — so a count that follows a filter is
29
+ * read, not worked out from the template. Cut at 300 characters.
30
+ */
31
+ text?: string;
32
+ /** Whether a visitor sees its first copy — scrolling where the page lets them (`sightOf`), not only a box drawn. */
21
33
  visible: boolean;
34
+ /** Why no visitor sees it — clipped, under another element — or the box they scroll to see it: said when either is so. */
35
+ sight?: string;
22
36
  box?: {
23
37
  x: number;
24
38
  y: number;
@@ -35,8 +49,19 @@ export type ElementReport = {
35
49
  */
36
50
  export declare const plain: (value: unknown, depth?: number, path?: WeakSet<object>) => unknown;
37
51
  export declare const recordAt: (value: unknown, ...path: string[]) => Record<string, unknown>;
52
+ /** The element by its id in whichever tree holds it — the pages', or one component's — and that component. */
53
+ export declare const findElement: (schema: Record<string, unknown>, id: string) => {
54
+ element?: unknown;
55
+ inComponent?: string;
56
+ };
57
+ /**
58
+ * What each binding of `element` gives it from `sources` — the sources one copy of it sees — worked out as the element
59
+ * does (`getBindingsDetails`), so what is said is what it received.
60
+ */
61
+ export declare const resolvedBindings: (element: unknown, sources: Record<string, unknown>) => Record<string, unknown> | undefined;
38
62
  /**
39
63
  * What an element is and how it is doing, read from the root store's state and the page: its type and attributes, what
40
- * it binds to, its own state, and where it is on screen. Undefined for an id neither the document nor the page knows.
64
+ * it binds to, what they gave it (`sourcesOf`: the sources an element sees, by its id), its own state, and where it is
65
+ * on screen. Undefined for an id neither the document nor the page knows.
41
66
  */
42
- export declare const elementReport: (state: unknown, id: string, document: Document) => ElementReport | undefined;
67
+ export declare const elementReport: (state: unknown, id: string, document: Document, sourcesOf?: (id: string) => unknown) => ElementReport | undefined;
@@ -1,58 +1,79 @@
1
1
  import { isRecord as e } from "@plitzi/sdk-shared/helpers";
2
+ import { get as t } from "@plitzi/plitzi-ui/helpers";
3
+ import { getBindingsDetails as n } from "@plitzi/sdk-shared/dataSource";
4
+ import { sightOf as r, sightText as i } from "@plitzi/sdk-shared/devTools/sight";
2
5
  //#region src/agentInspector/report.ts
3
- var t = (e, n = 0, r = /* @__PURE__ */ new WeakSet()) => {
6
+ var a = 300, o = (e) => {
7
+ let t = Reflect.get(e, "innerText");
8
+ return typeof t == "string" ? t : e.textContent;
9
+ }, s = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
4
10
  if (typeof e == "function") return;
5
11
  if (typeof e != "object" || !e) return e;
6
- if (r.has(e) || n > 12) return "[…]";
7
- r.add(e);
8
- let i = Array.isArray(e) ? e.map((e) => t(e, n + 1, r)) : Object.fromEntries(Object.entries(e).map(([e, i]) => [e, t(i, n + 1, r)]).filter(([, e]) => e !== void 0));
9
- return r.delete(e), i;
10
- }, n = (t, ...n) => {
12
+ if (n.has(e) || t > 12) return "[…]";
13
+ n.add(e);
14
+ let r = Array.isArray(e) ? e.map((e) => s(e, t + 1, n)) : Object.fromEntries(Object.entries(e).map(([e, r]) => [e, s(r, t + 1, n)]).filter(([, e]) => e !== void 0));
15
+ return n.delete(e), r;
16
+ }, c = (t, ...n) => {
11
17
  let r = t;
12
18
  for (let t of n) r = e(r) ? r[t] : void 0;
13
19
  return e(r) ? r : {};
14
- }, r = (e) => Array.isArray(e) ? e : [], i = (e) => Object.entries(n(e, "definition", "bindings")).flatMap(([e, t]) => r(t).flatMap((t) => {
15
- let { to: i, source: a, transformers: o } = n(t), s = r(o).map((e) => n(e, "params").template).find((e) => typeof e == "string");
16
- return typeof i == "string" && typeof a == "string" ? [{
20
+ }, l = (e) => Array.isArray(e) ? e : [], u = (e) => Object.entries(c(e, "definition", "bindings")).flatMap(([e, t]) => l(t).flatMap((t) => {
21
+ let { to: n, source: r, transformers: i } = c(t), a = l(i).map((e) => c(e, "params").template).find((e) => typeof e == "string");
22
+ return typeof n == "string" && typeof r == "string" ? [{
17
23
  category: e,
18
- to: i,
19
- source: a,
20
- ...typeof s == "string" ? { template: s } : {}
24
+ to: n,
25
+ source: r,
26
+ ...typeof a == "string" ? { template: a } : {}
21
27
  }] : [];
22
- })), a = (e, t) => {
23
- let r = n(e, "flat");
24
- if (Object.hasOwn(r, t)) return { element: r[t] };
25
- for (let [r, i] of Object.entries(n(e, "components"))) {
26
- let e = n(i, "flat");
28
+ })), d = (e, t) => {
29
+ let n = c(e, "flat");
30
+ if (Object.hasOwn(n, t)) return { element: n[t] };
31
+ for (let [n, r] of Object.entries(c(e, "components"))) {
32
+ let e = c(r, "flat");
27
33
  if (Object.hasOwn(e, t)) return {
28
34
  element: e[t],
29
- inComponent: r
35
+ inComponent: n
30
36
  };
31
37
  }
32
38
  return {};
33
- }, o = (r, o, s) => {
34
- let { element: c, inComponent: l } = a(n(r, "schema"), o), u = Array.from(s.querySelectorAll(`[data-id="${o}"]`));
35
- if (!e(c) && u.length === 0) return;
36
- let d = u.at(0), f = d?.getBoundingClientRect(), p = d ? getComputedStyle(d) : void 0, m = f !== void 0 && f.width > 0 && f.height > 0 && p?.display !== "none" && p?.visibility !== "hidden", h = n(c, "definition").type, g = n(c, "attributes"), _ = h === "reference" && g.referenceType === "component" && typeof g.referenceId == "string" ? g.referenceId : void 0, v = n(r, "runtime", "elements")[o];
39
+ }, f = (e, r) => {
40
+ let i = u(e);
41
+ if (i.length === 0) return;
42
+ let a = n(r, {
43
+ attributes: c(e, "attributes"),
44
+ definition: c(e, "definition")
45
+ });
46
+ return Object.fromEntries(i.map(({ category: e, to: n }) => [`${e}.${n}`, s(t(a, e === "initialState" ? [
47
+ "definition",
48
+ "initialState",
49
+ n
50
+ ] : [e, n]))]));
51
+ }, p = (t, n, l, p) => {
52
+ let { element: m, inComponent: h } = d(c(t, "schema"), n), g = Array.from(l.querySelectorAll(`[data-id="${n}"]`));
53
+ if (!e(m) && g.length === 0) return;
54
+ let _ = g.at(0), v = _?.getBoundingClientRect(), y = _ ? getComputedStyle(_) : void 0, b = _ && y?.display !== "none" && y?.visibility !== "hidden" ? r(_) : void 0, x = b?.seen === !0, S = b === void 0 || (b.seen ? b.scrolled === void 0 : b.why === "no-size") ? void 0 : i(b), C = c(m, "definition").type, w = c(m, "attributes"), T = C === "reference" && w.referenceType === "component" && typeof w.referenceId == "string" ? w.referenceId : void 0, E = c(t, "runtime", "elements")[n], D = _ instanceof HTMLElement ? o(_).replace(/\s+/g, " ").trim() : "", O = p?.(n), k = e(m) && e(O) ? f(m, O) : void 0;
37
55
  return {
38
- id: o,
39
- ...typeof h == "string" ? { type: h } : {},
40
- ...l === void 0 ? {} : { inComponent: l },
41
- ..._ === void 0 ? {} : { instanceOf: _ },
42
- ...e(c) ? {
43
- attributes: n(t(c), "attributes"),
44
- bindings: i(c)
56
+ id: n,
57
+ ...typeof C == "string" ? { type: C } : {},
58
+ ...h === void 0 ? {} : { inComponent: h },
59
+ ...T === void 0 ? {} : { instanceOf: T },
60
+ ...e(m) ? {
61
+ attributes: c(s(m), "attributes"),
62
+ bindings: u(m)
45
63
  } : {},
46
- ...v === void 0 ? {} : { state: t(v) },
47
- copies: u.length,
48
- visible: m,
49
- ...f ? { box: {
50
- x: Math.round(f.x),
51
- y: Math.round(f.y),
52
- width: Math.round(f.width),
53
- height: Math.round(f.height)
64
+ ...k === void 0 ? {} : { resolved: k },
65
+ ...E === void 0 ? {} : { state: s(E) },
66
+ copies: g.length,
67
+ ...D ? { text: D.length > a ? `${D.slice(0, a)}…` : D } : {},
68
+ visible: x,
69
+ ...S === void 0 ? {} : { sight: S },
70
+ ...v ? { box: {
71
+ x: Math.round(v.x),
72
+ y: Math.round(v.y),
73
+ width: Math.round(v.width),
74
+ height: Math.round(v.height)
54
75
  } } : {}
55
76
  };
56
77
  };
57
78
  //#endregion
58
- export { o as elementReport, t as plain, n as recordAt };
79
+ export { p as elementReport, d as findElement, s as plain, c as recordAt, f as resolvedBindings };
@@ -6,10 +6,11 @@ declare global {
6
6
  }
7
7
  }
8
8
  /**
9
- * Puts the selected instance's state, sources, elements and flows on `window.__plitzi`, while the dev tools are on.
9
+ * Puts the selected instance's state, sources, elements and flows on `window.__plitzi`, while the dev tools are on — or
10
+ * on another window's, `target`: the builder's canvas is an iframe whose document the SDK draws in from the editor's.
10
11
  *
11
12
  * The panel shows all of it to a person; an agent driving the page through a browser reads text, and was left inferring
12
13
  * state from classes in the DOM. Every flow that ends is kept from the moment the dev tools mount.
13
14
  */
14
- declare const useAgentInspector: (enabled: boolean) => void;
15
+ declare const useAgentInspector: (enabled: boolean, target?: Window | null) => void;
15
16
  export default useAgentInspector;
@@ -6,30 +6,34 @@ import { pConsole as o } from "@plitzi/sdk-shared/devTools";
6
6
  import { getDevStoresSnapshot as s } from "@plitzi/nexus";
7
7
  import { useCommonStoreSetter as c } from "@plitzi/sdk-shared/store";
8
8
  //#region src/agentInspector/useAgentInspector.ts
9
- var l = 100, u = (u) => {
10
- let d = r(a), f = c();
9
+ var l = 100, u = (u, d) => {
10
+ let f = r(a), p = c();
11
11
  i(() => {
12
- if (!u || !d) return;
13
- let r = [], i = !1, a = o.addListener((n) => {
14
- let a = t(n);
15
- a && (r.push(a), r.length > l && r.shift(), i && console.info(e(a)));
16
- }, { replay: !0 }), c = n({
17
- root: d,
18
- writeState: (e, t) => f(`runtime.state.${e}`, t),
12
+ let r = d === void 0 ? window : d;
13
+ if (!u || !f || !r) return;
14
+ let i = [], a = !1, c = o.addListener((n) => {
15
+ let r = t(n);
16
+ r && (i.push(r), i.length > l && i.shift(), a && console.info(e(r)));
17
+ }, { replay: !0 }), m = n({
18
+ root: f,
19
+ writeState: (e, t) => p(`runtime.state.${e}`, t),
20
+ writeTestAccount: (e) => p("runtime.testAccount", e),
19
21
  stores: () => s().map((e) => e.store),
20
- runs: () => r,
22
+ runs: () => i,
21
23
  setWatching: (e) => {
22
- i = e;
24
+ a = e;
23
25
  },
24
- document
26
+ elementSources: (e) => o.providerData(`getElementDataSource-${e}`),
27
+ document: r.document
25
28
  });
26
- return window.__plitzi = c, () => {
27
- a(), window.__plitzi === c && delete window.__plitzi;
29
+ return r.__plitzi = m, () => {
30
+ c(), r.__plitzi === m && delete r.__plitzi;
28
31
  };
29
32
  }, [
30
33
  u,
31
- d,
32
- f
34
+ f,
35
+ p,
36
+ d
33
37
  ]);
34
38
  };
35
39
  //#endregion
@@ -1,6 +1,5 @@
1
1
  import { Orientation } from '../../DevToolsContainer';
2
2
  import { LogType } from '@plitzi/sdk-shared';
3
- import { RefObject } from 'react';
4
3
  export type DevToolsOverlayProps = {
5
4
  className?: string;
6
5
  collapsed: boolean;
@@ -11,10 +10,10 @@ export type DevToolsOverlayProps = {
11
10
  onCollapse: () => void;
12
11
  onTabSelect: (tabSelected: string) => void;
13
12
  onChangeOrientation: (orientation: Orientation) => void;
14
- /** The page's own box, which the QA tools draw over and look in. */
15
- pageRef: RefObject<HTMLElement | null>;
16
13
  /** Whether the QA tab and its layer are offered: only over a page — see `DevToolsContainer`. */
17
14
  qa: boolean;
15
+ /** Whether the page's server previews a run, for the Run tab — see `DevToolsContainer`. */
16
+ run: boolean;
18
17
  };
19
- declare const DevToolsOverlay: ({ className, collapsed, orientation, tabSelected, logTypeFilter, onOpen, onCollapse, onTabSelect, onChangeOrientation, pageRef, qa }: DevToolsOverlayProps) => import('react').JSX.Element;
18
+ declare const DevToolsOverlay: ({ className, collapsed, orientation, tabSelected, logTypeFilter, onOpen, onCollapse, onTabSelect, onChangeOrientation, qa, run }: DevToolsOverlayProps) => import('react').JSX.Element;
20
19
  export default DevToolsOverlay;
@@ -4,7 +4,7 @@ import n from "../../qa/QaLayer.mjs";
4
4
  import r from "../DevToolsPanel/index.mjs";
5
5
  import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
6
6
  //#region src/components/DevToolsOverlay/DevToolsOverlay.tsx
7
- var s = ({ className: s, collapsed: c, orientation: l, tabSelected: u, logTypeFilter: d, onOpen: f, onCollapse: p, onTabSelect: m, onChangeOrientation: h, pageRef: g, qa: _ }) => {
7
+ var s = ({ className: s, collapsed: c, orientation: l, tabSelected: u, logTypeFilter: d, onOpen: f, onCollapse: p, onTabSelect: m, onChangeOrientation: h, qa: g, run: _ }) => {
8
8
  let v = /* @__PURE__ */ o(i, { children: [c && /* @__PURE__ */ a(e, {
9
9
  className: s,
10
10
  onOpen: f
@@ -13,13 +13,13 @@ var s = ({ className: s, collapsed: c, orientation: l, tabSelected: u, logTypeFi
13
13
  orientation: l,
14
14
  tabSelected: u,
15
15
  logTypeFilter: d,
16
- qa: _,
16
+ qa: g,
17
+ run: _,
17
18
  onCollapse: p,
18
19
  onTabSelect: m,
19
20
  onChangeOrientation: h
20
21
  })] });
21
- return _ ? /* @__PURE__ */ o(t, {
22
- pageRef: g,
22
+ return g ? /* @__PURE__ */ o(t, {
23
23
  collapsed: c,
24
24
  children: [/* @__PURE__ */ a(n, {}), v]
25
25
  }) : v;
@@ -1,4 +1,5 @@
1
1
  import { LogType } from '@plitzi/sdk-shared';
2
+ import { RunSnapshot } from '@plitzi/sdk-shared/runs';
2
3
  export type DevToolsBodyProps = {
3
4
  className?: string;
4
5
  tabSelected?: string;
@@ -8,6 +9,8 @@ export type DevToolsBodyProps = {
8
9
  onSelectElement: (id?: string) => void;
9
10
  /** Whether the QA tab is offered. */
10
11
  qa?: boolean;
12
+ /** The run of agents a preview serves the page from, when one does. */
13
+ run?: RunSnapshot;
11
14
  };
12
- declare const DevToolsBody: ({ className, tabSelected, orientation, logTypeFilter, elementSelected, onSelectElement, qa }: DevToolsBodyProps) => import('react').JSX.Element;
15
+ declare const DevToolsBody: ({ className, tabSelected, orientation, logTypeFilter, elementSelected, onSelectElement, qa, run }: DevToolsBodyProps) => import('react').JSX.Element;
13
16
  export default DevToolsBody;
@@ -6,43 +6,45 @@ import i from "./tabs/HistoryViewer/index.mjs";
6
6
  import a from "./tabs/Logs/index.mjs";
7
7
  import o from "./tabs/PluginsViewer/PluginsViewer.mjs";
8
8
  import s from "./tabs/QaViewer/index.mjs";
9
- import c from "./tabs/StoreViewer/index.mjs";
10
- import l from "./tabs/TracingViewer/TracingViewer.mjs";
11
- import u from "./tabs/VariablesViewer/index.mjs";
12
- import d from "clsx";
13
- import { use as f } from "react";
14
- import { DevToolsContext as p } from "@plitzi/sdk-shared/devTools/react";
15
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
9
+ import c from "./tabs/RunViewer/index.mjs";
10
+ import l from "./tabs/StoreViewer/index.mjs";
11
+ import u from "./tabs/TracingViewer/TracingViewer.mjs";
12
+ import d from "./tabs/VariablesViewer/index.mjs";
13
+ import f from "clsx";
14
+ import { use as p } from "react";
15
+ import { DevToolsContext as m } from "@plitzi/sdk-shared/devTools/react";
16
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
16
17
  //#region src/components/DevToolsPanel/DevToolsBody.tsx
17
- var g = ({ className: g, tabSelected: _, orientation: v, logTypeFilter: y, elementSelected: b, onSelectElement: x, qa: S = !1 }) => {
18
- let { logs: C, clearLogs: w } = f(p);
19
- return /* @__PURE__ */ m("div", {
20
- className: d("flex h-full w-full grow overflow-auto bg-white dark:bg-zinc-900", g),
21
- children: /* @__PURE__ */ h("div", {
22
- className: "flex w-full flex-col",
18
+ var _ = ({ className: _, tabSelected: v, orientation: y, logTypeFilter: b, elementSelected: x, onSelectElement: S, qa: C = !1, run: w }) => {
19
+ let { logs: T, clearLogs: E } = p(m);
20
+ return /* @__PURE__ */ h("div", {
21
+ className: f("flex min-h-0 w-full flex-1 overflow-auto bg-white dark:bg-zinc-900", _),
22
+ children: /* @__PURE__ */ g("div", {
23
+ className: "flex min-h-0 w-full flex-col",
23
24
  children: [
24
- _ === "logs" && /* @__PURE__ */ m(a, {
25
- items: C,
26
- orientation: v,
27
- logTypeFilter: y,
28
- onClear: w
25
+ v === "logs" && /* @__PURE__ */ h(a, {
26
+ items: T,
27
+ orientation: y,
28
+ logTypeFilter: b,
29
+ onClear: E
29
30
  }),
30
- _ === "store" && /* @__PURE__ */ m(c, { elementSelected: b }),
31
- _ === "cache" && /* @__PURE__ */ m(t, {}),
32
- _ === "history" && /* @__PURE__ */ m(i, {}),
33
- _ === "variables" && /* @__PURE__ */ m(u, {}),
34
- _ === "flags" && /* @__PURE__ */ m(r, {}),
35
- _ === "elements" && /* @__PURE__ */ m(n, {
36
- elementSelected: b,
37
- onSelectElement: x
31
+ v === "store" && /* @__PURE__ */ h(l, { elementSelected: x }),
32
+ v === "cache" && /* @__PURE__ */ h(t, {}),
33
+ v === "history" && /* @__PURE__ */ h(i, {}),
34
+ v === "variables" && /* @__PURE__ */ h(d, {}),
35
+ v === "flags" && /* @__PURE__ */ h(r, {}),
36
+ v === "elements" && /* @__PURE__ */ h(n, {
37
+ elementSelected: x,
38
+ onSelectElement: S
38
39
  }),
39
- _ === "plugins" && /* @__PURE__ */ m(o, {}),
40
- _ === "tracing" && /* @__PURE__ */ m(l, {}),
41
- _ === "actions" && /* @__PURE__ */ m(e, {}),
42
- S && _ === "qa" && /* @__PURE__ */ m(s, {})
40
+ v === "plugins" && /* @__PURE__ */ h(o, {}),
41
+ v === "tracing" && /* @__PURE__ */ h(u, {}),
42
+ v === "actions" && /* @__PURE__ */ h(e, {}),
43
+ C && v === "qa" && /* @__PURE__ */ h(s, {}),
44
+ v === "run" && /* @__PURE__ */ h(c, { snapshot: w })
43
45
  ]
44
46
  })
45
47
  });
46
48
  };
47
49
  //#endregion
48
- export { g as default };
50
+ export { _ as default };
@@ -4,7 +4,9 @@ export type DevToolsButtonProps = {
4
4
  isSelected?: boolean;
5
5
  iconClassName?: string;
6
6
  title?: string;
7
+ /** Offered and not to be pressed now: its title says why. */
8
+ disabled?: boolean;
7
9
  onClick?: (e: MouseEvent) => void;
8
10
  };
9
- declare const DevToolsButton: ({ className, iconClassName, title, isSelected, onClick }: DevToolsButtonProps) => import('react').JSX.Element;
11
+ declare const DevToolsButton: ({ className, iconClassName, title, isSelected, disabled, onClick }: DevToolsButtonProps) => import('react').JSX.Element;
10
12
  export default DevToolsButton;
@@ -1,13 +1,14 @@
1
1
  import e from "clsx";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
3
  //#region src/components/DevToolsPanel/DevToolsButton.tsx
4
- var n = ({ className: n, iconClassName: r, title: i, isSelected: a = !1, onClick: o }) => /* @__PURE__ */ t("button", {
5
- className: e("flex h-6 w-6 cursor-pointer items-center justify-center rounded transition-colors", {
4
+ var n = ({ className: n, iconClassName: r, title: i, isSelected: a = !1, disabled: o = !1, onClick: s }) => /* @__PURE__ */ t("button", {
5
+ className: e("flex h-6 w-6 cursor-pointer items-center justify-center rounded transition-colors disabled:cursor-not-allowed disabled:opacity-40", {
6
6
  "bg-violet-500/10 text-violet-600 dark:bg-violet-500/20 dark:text-violet-400": a,
7
7
  "text-zinc-500 hover:bg-zinc-200 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-700 dark:hover:text-zinc-100": !a
8
8
  }, n),
9
9
  title: i,
10
- onClick: o,
10
+ disabled: o,
11
+ onClick: s,
11
12
  children: /* @__PURE__ */ t("i", { className: e("text-xs", r) })
12
13
  });
13
14
  //#endregion
@@ -8,6 +8,8 @@ export type DevToolsHeaderProps = {
8
8
  onTabSelect?: (tabIndex: string) => void;
9
9
  /** Whether the QA tab is offered. */
10
10
  qa?: boolean;
11
+ /** Whether the Run tab is offered: a run's preview serves the page. */
12
+ run?: boolean;
11
13
  };
12
- declare const DevToolsHeader: ({ tabSelected, orientation, onChangeOrientation, onCollapse, onTabSelect, qa }: DevToolsHeaderProps) => import('react').JSX.Element;
14
+ declare const DevToolsHeader: ({ tabSelected, orientation, onChangeOrientation, onCollapse, onTabSelect, qa, run }: DevToolsHeaderProps) => import('react').JSX.Element;
13
15
  export default DevToolsHeader;
@@ -1,11 +1,12 @@
1
- import { useScopeSelector as e } from "../../scope/useScope.mjs";
2
- import t from "./DevToolsButton.mjs";
3
- import n from "./ThemeControl.mjs";
4
- import r from "clsx";
5
- import { useCallback as i } from "react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
1
+ import e from "../../useNarrowWindow.mjs";
2
+ import { useScopeSelector as t } from "../../scope/useScope.mjs";
3
+ import n from "./DevToolsButton.mjs";
4
+ import r from "./ThemeControl.mjs";
5
+ import i from "clsx";
6
+ import { useCallback as a, useEffect as o, useRef as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
8
  //#region src/components/DevToolsPanel/DevToolsHeader.tsx
8
- var s = [
9
+ var u = [
9
10
  {
10
11
  id: "logs",
11
12
  label: "Logs",
@@ -60,56 +61,73 @@ var s = [
60
61
  id: "qa",
61
62
  label: "QA",
62
63
  icon: "fa-solid fa-ruler-combined"
64
+ },
65
+ {
66
+ id: "run",
67
+ label: "Run",
68
+ icon: "fa-solid fa-people-group"
63
69
  }
64
- ], c = ({ tabSelected: c, orientation: l = "vertical", onChangeOrientation: u, onCollapse: d, onTabSelect: f, qa: p = !1 }) => {
65
- let m = p ? s : s.filter((e) => e.id !== "qa"), { options: h, value: g, onSelect: _ } = e(), v = i(() => {
66
- u?.(l === "horizontal" ? "vertical" : "horizontal");
67
- }, [l, u]), y = i((e) => () => f?.(e), [f]), b = i((e) => _(e.target.value), [_]);
68
- return /* @__PURE__ */ o("div", {
70
+ ], d = ({ tabSelected: d, orientation: f = "vertical", onChangeOrientation: p, onCollapse: m, onTabSelect: h, qa: g = !1, run: _ = !1 }) => {
71
+ let v = u.filter((e) => (e.id !== "qa" || g) && (e.id !== "run" || _)), y = e(), b = s(null);
72
+ o(() => {
73
+ b.current?.querySelector("[aria-selected=\"true\"]")?.scrollIntoView({
74
+ block: "nearest",
75
+ inline: "nearest"
76
+ });
77
+ }, [d]);
78
+ let { options: x, value: S, onSelect: C } = t(), w = a(() => {
79
+ p?.(f === "horizontal" ? "vertical" : "horizontal");
80
+ }, [f, p]), T = a((e) => () => h?.(e), [h]), E = a((e) => C(e.target.value), [C]);
81
+ return /* @__PURE__ */ l("div", {
69
82
  className: "flex shrink-0 items-stretch justify-between border-b border-zinc-200 bg-zinc-100 select-none dark:border-zinc-700 dark:bg-zinc-800",
70
- children: [/* @__PURE__ */ a("div", {
71
- className: "flex items-stretch overflow-x-auto",
72
- children: m.map((e) => {
73
- let t = c === e.id;
74
- return /* @__PURE__ */ o("button", {
75
- onClick: y(e.id),
76
- className: r("flex cursor-pointer items-center gap-1.5 border-b-2 px-3 py-2 font-medium transition-colors", {
83
+ children: [/* @__PURE__ */ c("div", {
84
+ ref: b,
85
+ role: "tablist",
86
+ className: "flex min-w-0 items-stretch overflow-x-auto",
87
+ children: v.map((e) => {
88
+ let t = d === e.id;
89
+ return /* @__PURE__ */ l("button", {
90
+ role: "tab",
91
+ "aria-selected": t,
92
+ onClick: T(e.id),
93
+ className: i("flex cursor-pointer items-center gap-1.5 border-b-2 px-3 py-2 font-medium transition-colors", {
77
94
  "border-violet-500 text-violet-600 dark:text-violet-400": t,
78
95
  "border-transparent text-zinc-500 hover:bg-zinc-200/70 hover:text-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-700/50 dark:hover:text-zinc-100": !t
79
96
  }),
80
- children: [/* @__PURE__ */ a("i", { className: r(e.icon, "text-[10px]") }), e.label]
97
+ children: [/* @__PURE__ */ c("i", { className: i(e.icon, "text-[10px]") }), e.label]
81
98
  }, e.id);
82
99
  })
83
- }), /* @__PURE__ */ o("div", {
100
+ }), /* @__PURE__ */ l("div", {
84
101
  className: "flex shrink-0 items-center gap-1 border-l border-zinc-200 px-2 dark:border-zinc-700",
85
102
  children: [
86
- h.length > 0 && /* @__PURE__ */ a("select", {
87
- value: g ?? "",
88
- onChange: b,
103
+ x.length > 0 && /* @__PURE__ */ c("select", {
104
+ value: S ?? "",
105
+ onChange: E,
89
106
  title: "Instance / StoreProvider driving the panel",
90
107
  className: "max-w-52 rounded border border-zinc-300 bg-white px-1 py-0.5 text-[11px] text-zinc-700 dark:border-zinc-600 dark:bg-zinc-900 dark:text-zinc-200",
91
- children: h.map((e) => /* @__PURE__ */ a("optgroup", {
108
+ children: x.map((e) => /* @__PURE__ */ c("optgroup", {
92
109
  label: e.label,
93
- children: e.options.map((e) => /* @__PURE__ */ a("option", {
110
+ children: e.options.map((e) => /* @__PURE__ */ c("option", {
94
111
  value: e.value,
95
112
  children: e.label
96
113
  }, e.value))
97
114
  }, e.label))
98
115
  }),
99
- /* @__PURE__ */ a(n, {}),
100
- /* @__PURE__ */ a(t, {
101
- iconClassName: r("fa-solid fa-table-columns", { "rotate-90": l === "vertical" }),
102
- title: l === "horizontal" ? "Switch to side panel" : "Switch to bottom panel",
103
- onClick: v
116
+ /* @__PURE__ */ c(r, {}),
117
+ /* @__PURE__ */ c(n, {
118
+ iconClassName: i("fa-solid fa-table-columns", { "rotate-90": f === "vertical" }),
119
+ title: y ? "At the bottom while the window is under 900 px: beside it, the page would have no room" : f === "horizontal" ? "Switch to side panel" : "Switch to bottom panel",
120
+ disabled: y,
121
+ onClick: w
104
122
  }),
105
- /* @__PURE__ */ a(t, {
123
+ /* @__PURE__ */ c(n, {
106
124
  iconClassName: "fa-solid fa-xmark",
107
125
  title: "Collapse to the indicator",
108
- onClick: d
126
+ onClick: m
109
127
  })
110
128
  ]
111
129
  })]
112
130
  });
113
131
  };
114
132
  //#endregion
115
- export { c as default };
133
+ export { d as default };
@@ -13,6 +13,8 @@ export type DevToolsPanelProps = {
13
13
  onChangeOrientation?: (orientation: Orientation) => void;
14
14
  /** Whether the QA tab is offered. */
15
15
  qa?: boolean;
16
+ /** Whether the page's server previews a run: the Run tab asks it for the run only then. */
17
+ run?: boolean;
16
18
  };
17
- declare const DevToolsPanel: ({ className, orientation, tabSelected, logTypeFilter, onCollapse, onTabSelect, onChangeOrientation, qa }: DevToolsPanelProps) => import('react').JSX.Element;
19
+ declare const DevToolsPanel: ({ className, orientation, tabSelected, logTypeFilter, onCollapse, onTabSelect, onChangeOrientation, qa, run: previewsRun }: DevToolsPanelProps) => import('react').JSX.Element;
18
20
  export default DevToolsPanel;