@plitzi/sdk-dev-tools 0.32.4 → 0.32.6

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
@@ -1,5 +1,29 @@
1
1
  # @plitzi/sdk-dev-tools
2
2
 
3
+ ## 0.32.6
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.32.6
8
+ - Updated dependencies
9
+ - @plitzi/nexus@0.32.6
10
+ - @plitzi/sdk-navigation@0.32.6
11
+ - @plitzi/sdk-schema@0.32.6
12
+ - @plitzi/sdk-shared@0.32.6
13
+ - @plitzi/sdk-style@0.32.6
14
+
15
+ ## 0.32.5
16
+
17
+ ### Patch Changes
18
+
19
+ - v0.32.4
20
+ - Updated dependencies
21
+ - @plitzi/nexus@0.32.5
22
+ - @plitzi/sdk-navigation@0.32.5
23
+ - @plitzi/sdk-schema@0.32.5
24
+ - @plitzi/sdk-shared@0.32.5
25
+ - @plitzi/sdk-style@0.32.5
26
+
3
27
  ## 0.32.4
4
28
 
5
29
  ### Patch Changes
@@ -5,9 +5,10 @@ export type DevToolsContainerProps = {
5
5
  className?: string;
6
6
  innerClassName?: string;
7
7
  enabled?: boolean;
8
+ instanceId?: string;
8
9
  devToolsStyle?: string;
9
10
  devToolsStyleLink?: string;
10
11
  renderMode?: 'default' | 'shadow';
11
12
  };
12
- declare const DevToolsContainer: ({ children, className, innerClassName, enabled, renderMode, devToolsStyle, devToolsStyleLink }: DevToolsContainerProps) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
13
+ declare const DevToolsContainer: ({ children, className, innerClassName, enabled, instanceId, renderMode, devToolsStyle, devToolsStyleLink }: DevToolsContainerProps) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
13
14
  export default DevToolsContainer;
@@ -1,34 +1,38 @@
1
- import e from "./components/DevToolsPanel/index.mjs";
2
- import t from "./DevToolsContextProvider.mjs";
3
- import n from "clsx";
4
- import { use as r, useCallback as i, useState as a } from "react";
5
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
- import { ThemeContext as c } from "@plitzi/sdk-shared";
7
- import l from "@plitzi/plitzi-ui/ContainerShadow";
1
+ import { useIsSelectedInstance as e } from "./instanceRegistry.mjs";
2
+ import t from "./components/DevToolsPanel/index.mjs";
3
+ import n from "./DevToolsContextProvider.mjs";
4
+ import r from "@plitzi/plitzi-ui/hooks/useStorage";
5
+ import i from "clsx";
6
+ import { use as a, useCallback as o, useRef as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import { DevStoreScopeContext as u } from "@plitzi/nexus/react";
9
+ import { ThemeContext as d } from "@plitzi/sdk-shared";
10
+ import f from "@plitzi/plitzi-ui/ContainerShadow";
8
11
  //#region src/DevToolsContainer.tsx
9
- var u = ({ children: u, className: d, innerClassName: f, enabled: p = !1, renderMode: m = "default", devToolsStyle: h = "", devToolsStyleLink: g = "" }) => {
10
- let { theme: _ } = r(c), [v, y] = a("horizontal"), b = i((e) => y(e), []);
11
- return p ? /* @__PURE__ */ o(t, { children: /* @__PURE__ */ s("div", {
12
- className: n("flex grow overflow-auto", {
13
- "flex-col": v === "horizontal",
14
- "h-screen": v === "vertical"
15
- }, d),
16
- children: [
17
- /* @__PURE__ */ o("div", {
18
- className: n("grow basis-0 flex-col overflow-auto", f),
19
- children: u
20
- }),
21
- m === "default" && /* @__PURE__ */ o(e, {
22
- orientation: v,
23
- onChangeOrientation: b
24
- }),
25
- m === "shadow" && /* @__PURE__ */ s(l, { children: [g && /* @__PURE__ */ o(l.Link, { href: g }), /* @__PURE__ */ s(l.Content, { children: [/* @__PURE__ */ o("style", { dangerouslySetInnerHTML: { __html: h } }), /* @__PURE__ */ o(e, {
26
- className: n({ dark: _ === "dark" }),
27
- orientation: v,
28
- onChangeOrientation: b
29
- })] })] })
30
- ]
31
- }) }) : u;
12
+ var p = 0, m = ({ children: m, className: h, innerClassName: g, enabled: _ = !1, instanceId: v, renderMode: y = "default", devToolsStyle: b = "", devToolsStyleLink: x = "" }) => {
13
+ let { theme: S } = a(d), [C, w] = r("plitzi-sdk.dev-tools.orientation", "horizontal"), T = s(void 0);
14
+ T.current ||= `sdk-instance-${++p}`;
15
+ let E = v || T.current, D = e(E, _), O = o((e) => w(e), [w]);
16
+ return _ ? /* @__PURE__ */ l("div", {
17
+ className: i("flex grow overflow-auto", {
18
+ "flex-col": C === "horizontal",
19
+ "h-screen": C === "vertical"
20
+ }, h),
21
+ children: [/* @__PURE__ */ c(u, {
22
+ value: E,
23
+ children: /* @__PURE__ */ c("div", {
24
+ className: i("grow basis-0 flex-col overflow-auto", g),
25
+ children: m
26
+ })
27
+ }), D && /* @__PURE__ */ l(n, { children: [y === "default" && /* @__PURE__ */ c(t, {
28
+ orientation: C,
29
+ onChangeOrientation: O
30
+ }), y === "shadow" && /* @__PURE__ */ l(f, { children: [x && /* @__PURE__ */ c(f.Link, { href: x }), /* @__PURE__ */ l(f.Content, { children: [/* @__PURE__ */ c("style", { dangerouslySetInnerHTML: { __html: b } }), /* @__PURE__ */ c(t, {
31
+ className: i({ dark: S === "dark" }),
32
+ orientation: C,
33
+ onChangeOrientation: O
34
+ })] })] })] })]
35
+ }) : m;
32
36
  };
33
37
  //#endregion
34
- export { u as default };
38
+ export { m as default };
@@ -1,8 +1,9 @@
1
- import e from "clsx";
2
- import { useCallback as t } from "react";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
1
+ import { useScopeSelector as e } from "../../scope/useScope.mjs";
2
+ import t from "clsx";
3
+ import { useCallback as n } from "react";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
5
  //#region src/components/DevToolsPanel/DevToolsHeader.tsx
5
- var i = [
6
+ var a = [
6
7
  {
7
8
  id: "logs",
8
9
  label: "Logs",
@@ -38,35 +39,47 @@ var i = [
38
39
  label: "Tracing",
39
40
  icon: "fa-solid fa-gauge-high"
40
41
  }
41
- ], a = ({ tabSelected: a, orientation: o = "vertical", onChangeOrientation: s, onTabSelect: c }) => {
42
- let l = t(() => {
43
- s?.(o === "horizontal" ? "vertical" : "horizontal");
44
- }, [o, s]), u = t((e) => () => c?.(e), [c]);
45
- return /* @__PURE__ */ r("div", {
42
+ ], o = ({ tabSelected: o, orientation: s = "vertical", onChangeOrientation: c, onTabSelect: l }) => {
43
+ let { options: u, value: d, onSelect: f } = e(), p = n(() => {
44
+ c?.(s === "horizontal" ? "vertical" : "horizontal");
45
+ }, [s, c]), m = n((e) => () => l?.(e), [l]), h = n((e) => f(e.target.value), [f]);
46
+ return /* @__PURE__ */ i("div", {
46
47
  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",
47
- children: [/* @__PURE__ */ n("div", {
48
+ children: [/* @__PURE__ */ r("div", {
48
49
  className: "flex items-stretch overflow-x-auto",
49
- children: i.map((t) => {
50
- let i = a === t.id;
51
- return /* @__PURE__ */ r("button", {
52
- onClick: u(t.id),
53
- className: e("flex cursor-pointer items-center gap-1.5 border-b-2 px-3 py-2 font-medium transition-colors", {
54
- "border-violet-500 text-violet-600 dark:text-violet-400": i,
55
- "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": !i
50
+ children: a.map((e) => {
51
+ let n = o === e.id;
52
+ return /* @__PURE__ */ i("button", {
53
+ onClick: m(e.id),
54
+ className: t("flex cursor-pointer items-center gap-1.5 border-b-2 px-3 py-2 font-medium transition-colors", {
55
+ "border-violet-500 text-violet-600 dark:text-violet-400": n,
56
+ "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": !n
56
57
  }),
57
- children: [/* @__PURE__ */ n("i", { className: e(t.icon, "text-[10px]") }), t.label]
58
- }, t.id);
58
+ children: [/* @__PURE__ */ r("i", { className: t(e.icon, "text-[10px]") }), e.label]
59
+ }, e.id);
59
60
  })
60
- }), /* @__PURE__ */ n("div", {
61
+ }), /* @__PURE__ */ i("div", {
61
62
  className: "flex shrink-0 items-center gap-1 border-l border-zinc-200 px-2 dark:border-zinc-700",
62
- children: /* @__PURE__ */ n("button", {
63
+ children: [u.length > 0 && /* @__PURE__ */ r("select", {
64
+ value: d ?? "",
65
+ onChange: h,
66
+ title: "Instance / StoreProvider driving the panel",
67
+ 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",
68
+ children: u.map((e) => /* @__PURE__ */ r("optgroup", {
69
+ label: e.label,
70
+ children: e.options.map((e) => /* @__PURE__ */ r("option", {
71
+ value: e.value,
72
+ children: e.label
73
+ }, e.value))
74
+ }, e.label))
75
+ }), /* @__PURE__ */ r("button", {
63
76
  className: "flex h-6 w-6 items-center justify-center rounded text-zinc-500 transition-colors hover:bg-zinc-200 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-700 dark:hover:text-zinc-100",
64
- title: o === "horizontal" ? "Switch to side panel" : "Switch to bottom panel",
65
- onClick: l,
66
- children: /* @__PURE__ */ n("i", { className: e("fa-solid fa-table-columns text-xs", { "rotate-90": o === "vertical" }) })
67
- })
77
+ title: s === "horizontal" ? "Switch to side panel" : "Switch to bottom panel",
78
+ onClick: p,
79
+ children: /* @__PURE__ */ r("i", { className: t("fa-solid fa-table-columns text-xs", { "rotate-90": s === "vertical" }) })
80
+ })]
68
81
  })]
69
82
  });
70
83
  };
71
84
  //#endregion
72
- export { a as default };
85
+ export { o as default };
@@ -10,6 +10,6 @@ var e = (e) => new Date(e).toLocaleTimeString(void 0, { hour12: !1 }) + "." + St
10
10
  n = t;
11
11
  }
12
12
  return n.length > 120 ? n.slice(0, 120) + "…" : n;
13
- }, n = (e, t) => t ? (e.path ?? "").toLowerCase().includes(t.toLowerCase()) : !0;
13
+ }, n = (e, t) => !t || (e.path ?? "").toLowerCase().includes(t.toLowerCase());
14
14
  //#endregion
15
15
  export { e as formatTime, n as matchesFilter, t as previewValue };
@@ -8,13 +8,11 @@ var l = ({ items: l = [], autoScrollOffset: u = 40, orientation: d = "horizontal
8
8
  let [p, m] = o(), h = a(null), g = a(!0);
9
9
  i(() => {
10
10
  let e = h.current;
11
- e && g.current && (e.scrollTop = e.scrollHeight);
11
+ e && g.current && (e.scrollTop = 0);
12
12
  }, [l]);
13
13
  let _ = r(() => {
14
14
  let e = h.current;
15
- if (!e) return;
16
- let t = e.scrollHeight - e.scrollTop - e.clientHeight <= u;
17
- g.current = t;
15
+ e && (g.current = e.scrollTop <= u);
18
16
  }, [u]), v = r((e) => {
19
17
  m(e);
20
18
  }, []);
@@ -49,7 +47,10 @@ var l = ({ items: l = [], autoScrollOffset: u = 40, orientation: d = "horizontal
49
47
  children: l.length === 0 ? /* @__PURE__ */ c("div", {
50
48
  className: "flex grow flex-col items-center justify-center gap-2 text-zinc-400 dark:text-zinc-500",
51
49
  children: [/* @__PURE__ */ s("i", { className: "fa-solid fa-terminal text-3xl opacity-20" }), /* @__PURE__ */ s("span", { children: "No logs yet" })]
52
- }) : l.filter((e) => !p || e.logType === p).map((t, n) => /* @__PURE__ */ s(e, {
50
+ }) : l.map((e, t) => ({
51
+ item: e,
52
+ key: t
53
+ })).filter(({ item: e }) => !p || e.logType === p).reverse().map(({ item: t, key: n }) => /* @__PURE__ */ s(e, {
53
54
  category: t.category,
54
55
  time: t.time,
55
56
  params: t.params,
@@ -1,32 +1,55 @@
1
- import { use as e } from "react";
2
- import t from "@plitzi/sdk-shared/devTools/DevToolsContext";
3
- import { useCommonStore as n } from "@plitzi/sdk-shared/store";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import i from "@uiw/react-json-view";
6
- import * as a from "@uiw/react-json-view/vscode";
7
- import { emptyObject as o } from "@plitzi/sdk-shared/helpers/utils";
1
+ import { useSelectedStore as e } from "../../../../scope/useScope.mjs";
2
+ import t from "../../../../scope/useStoreState.mjs";
3
+ import n from "@plitzi/plitzi-ui/hooks/useStorage";
4
+ import r from "clsx";
5
+ import { use as i, useCallback as a } from "react";
6
+ import o from "@plitzi/sdk-shared/devTools/DevToolsContext";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ import l from "@uiw/react-json-view";
9
+ import * as u from "@uiw/react-json-view/vscode";
10
+ import { emptyObject as d } from "@plitzi/sdk-shared/helpers/utils";
8
11
  //#region src/components/DevToolsPanel/tabs/StoreViewer/StoreViewer.tsx
9
- var s = {
10
- ...a.vscodeTheme,
12
+ var f = {
13
+ ...u.vscodeTheme,
11
14
  width: "100%",
12
15
  height: "100%",
13
16
  overflow: "auto",
14
17
  padding: "8px",
15
18
  fontSize: "14px"
16
- }, c = ({ elementSelected: a }) => {
17
- let { getData: c } = e(t), [l] = n();
18
- return /* @__PURE__ */ r("div", {
19
+ }, p = (e) => r("cursor-pointer rounded px-2 py-0.5 font-medium transition-colors", e ? "bg-violet-500/15 text-violet-600 dark:text-violet-300" : "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"), m = ({ elementSelected: r }) => {
20
+ let { getData: u } = i(o), m = e(), [h, g] = n("plitzi-sdk.dev-tools.store.view", "own"), _ = t(r ? void 0 : m, h === "merged"), v = a(() => g("own"), [g]), y = a(() => g("merged"), [g]), b = r ? u?.(`getElementDataSource-${r}`) : _;
21
+ return /* @__PURE__ */ c("div", {
19
22
  className: "flex h-full w-full flex-col",
20
- children: /* @__PURE__ */ r(i, {
21
- value: (a ? c?.(`getElementDataSource-${a}`) : l) ?? o,
22
- style: s,
23
+ children: [!r && /* @__PURE__ */ c("div", {
24
+ className: "flex shrink-0 items-center gap-1 border-b border-zinc-200 px-2 py-1 text-[11px] dark:border-zinc-800",
25
+ children: [
26
+ /* @__PURE__ */ s("span", {
27
+ className: "mr-1 text-zinc-400 dark:text-zinc-500",
28
+ children: "View"
29
+ }),
30
+ /* @__PURE__ */ s("button", {
31
+ className: p(h === "own"),
32
+ onClick: v,
33
+ title: "Only this scope's own layer",
34
+ children: "Own"
35
+ }),
36
+ /* @__PURE__ */ s("button", {
37
+ className: p(h === "merged"),
38
+ onClick: y,
39
+ title: "Own layer merged over the parent scope chain",
40
+ children: "Merged"
41
+ })
42
+ ]
43
+ }), /* @__PURE__ */ s(l, {
44
+ value: b ?? d,
45
+ style: f,
23
46
  enableClipboard: !1,
24
47
  indentWidth: 15,
25
48
  collapsed: 2,
26
49
  displayObjectSize: !1,
27
50
  displayDataTypes: !1
28
- })
51
+ })]
29
52
  });
30
53
  };
31
54
  //#endregion
32
- export { c as default };
55
+ export { m as default };
@@ -6,100 +6,92 @@ import i from "../SidebarShell/SidebarShell.mjs";
6
6
  import a from "../SidebarShell/SidebarEmpty.mjs";
7
7
  import o from "../SidebarToggle/SidebarToggle.mjs";
8
8
  import s from "./FlameFrame.mjs";
9
- import { useCallback as c, useEffect as l, useMemo as u, useState as d } from "react";
10
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ import { useCallback as c, useMemo as l } from "react";
10
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
11
  //#region src/components/DevToolsPanel/tabs/TracingViewer/components/Flamegraph/Flamegraph.tsx
12
- var m = 1e-6, h = ({ commit: h, model: g, active: _, origin: v, sidebarOpen: y, onSelectElement: b, onToggleSidebar: x }) => {
13
- let [S, C] = d();
14
- l(() => C(void 0), [h.commitId, g]);
15
- let w = u(() => {
12
+ var f = 1e-6, p = ({ commit: p, model: m, active: h, origin: g, sidebarOpen: _, onSelectElement: v, onToggleSidebar: y }) => {
13
+ let b = l(() => {
16
14
  let e = /* @__PURE__ */ new Map();
17
- for (let t of g.nodes) e.set(t.id, t);
15
+ for (let t of m.nodes) e.set(t.id, t);
18
16
  return e;
19
- }, [g]), T = S ? w.get(S) : void 0, E = T ? T.x : 0, D = T ? T.width : 1, O = T ? T.depth : 0, k = u(() => {
20
- if (!T) return [];
21
- let e = [], t = T.parentId;
17
+ }, [m]), x = h, S = x ? x.x : 0, C = x ? x.width : 1, w = x ? x.depth : 0, T = l(() => {
18
+ if (!x) return [];
19
+ let e = [], t = x.parentId;
22
20
  for (; t !== void 0;) {
23
- let n = w.get(t);
21
+ let n = b.get(t);
24
22
  if (!n) break;
25
23
  e.push(n), t = n.parentId;
26
24
  }
27
25
  return e.reverse();
28
- }, [T, w]), A = u(() => g.nodes.filter((e) => e.depth >= O && e.x >= E - m && e.x + e.width <= E + D + m), [
29
- g,
30
- E,
31
- D,
32
- O
33
- ]), j = u(() => A.reduce((e, t) => Math.max(e, t.depth), O), [A, O]), M = c((e) => {
34
- let t = e.id === _?.id;
35
- b(t ? void 0 : e.id), C(t ? void 0 : e.id);
36
- }, [_, b]), N = c((e) => {
37
- let t = e.id === _?.id;
38
- b(t ? void 0 : e.id), C(t ? void 0 : e.id);
39
- }, [_, b]);
40
- return /* @__PURE__ */ p("div", {
26
+ }, [x, b]), E = l(() => m.nodes.filter((e) => e.depth >= w && e.x >= S - f && e.x + e.width <= S + C + f), [
27
+ m,
28
+ S,
29
+ C,
30
+ w
31
+ ]), D = l(() => E.reduce((e, t) => Math.max(e, t.depth), w), [E, w]), O = c((e) => v(e.id === h?.id ? void 0 : e.id), [h, v]);
32
+ return /* @__PURE__ */ d("div", {
41
33
  className: "flex min-h-0 flex-1 flex-col overflow-hidden",
42
34
  children: [
43
- /* @__PURE__ */ p("div", {
35
+ /* @__PURE__ */ d("div", {
44
36
  className: "flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-zinc-200 px-2 py-1 text-[10px] text-zinc-500 dark:border-zinc-800 dark:text-zinc-400",
45
37
  children: [
46
- /* @__PURE__ */ p("span", {
38
+ /* @__PURE__ */ d("span", {
47
39
  className: "font-medium text-zinc-700 dark:text-zinc-200",
48
- children: ["Commit #", h.commitId]
40
+ children: ["Commit #", p.commitId]
49
41
  }),
50
- v !== "update" && /* @__PURE__ */ f("span", {
42
+ g !== "update" && /* @__PURE__ */ u("span", {
51
43
  className: "rounded bg-violet-100 px-1 text-[9px] font-medium text-violet-700 uppercase dark:bg-violet-500/20 dark:text-violet-300",
52
- children: e[v]
44
+ children: e[g]
53
45
  }),
54
- /* @__PURE__ */ f("span", {
46
+ /* @__PURE__ */ u("span", {
55
47
  className: "opacity-60",
56
48
  children: "click a frame to zoom · click the focused frame to zoom out"
57
49
  }),
58
- /* @__PURE__ */ f(t, {
59
- commit: h,
60
- model: g,
61
- active: _,
62
- onSelectElement: b
50
+ /* @__PURE__ */ u(t, {
51
+ commit: p,
52
+ model: m,
53
+ active: h,
54
+ onSelectElement: v
63
55
  }),
64
- /* @__PURE__ */ f(o, {
56
+ /* @__PURE__ */ u(o, {
65
57
  className: "ml-auto",
66
- open: y,
67
- onToggle: x
58
+ open: _,
59
+ onToggle: y
68
60
  })
69
61
  ]
70
62
  }),
71
- /* @__PURE__ */ p("div", {
63
+ /* @__PURE__ */ d("div", {
72
64
  className: "flex min-h-0 flex-1 overflow-hidden",
73
- children: [/* @__PURE__ */ f("div", {
65
+ children: [/* @__PURE__ */ u("div", {
74
66
  className: "min-h-0 flex-1 overflow-auto p-1",
75
- children: /* @__PURE__ */ p("div", {
67
+ children: /* @__PURE__ */ d("div", {
76
68
  className: "relative w-full",
77
- style: { height: (j + 1) * 18 },
78
- children: [k.map((e) => /* @__PURE__ */ f(s, {
69
+ style: { height: (D + 1) * 18 },
70
+ children: [T.map((e) => /* @__PURE__ */ u(s, {
79
71
  node: e,
80
72
  left: 0,
81
73
  width: 100,
82
74
  top: e.depth * 18,
83
- selected: e.id === _?.id,
84
- onClick: N
85
- }, e.id)), A.map((e) => /* @__PURE__ */ f(s, {
75
+ selected: e.id === h?.id,
76
+ onClick: O
77
+ }, e.id)), E.map((e) => /* @__PURE__ */ u(s, {
86
78
  node: e,
87
- left: (e.x - E) / D * 100,
88
- width: e.width / D * 100,
79
+ left: (e.x - S) / C * 100,
80
+ width: e.width / C * 100,
89
81
  top: e.depth * 18,
90
- selected: e.id === _?.id,
91
- onClick: M
82
+ selected: e.id === h?.id,
83
+ onClick: O
92
84
  }, e.id))]
93
85
  })
94
- }), y && /* @__PURE__ */ f(i, { children: _ ? /* @__PURE__ */ f(n, {
95
- node: _,
96
- commit: h,
97
- model: g
98
- }) : /* @__PURE__ */ f(a, {}) })]
86
+ }), _ && /* @__PURE__ */ u(i, { children: h ? /* @__PURE__ */ u(n, {
87
+ node: h,
88
+ commit: p,
89
+ model: m
90
+ }) : /* @__PURE__ */ u(a, {}) })]
99
91
  }),
100
- /* @__PURE__ */ f(r, {})
92
+ /* @__PURE__ */ u(r, {})
101
93
  ]
102
94
  });
103
95
  };
104
96
  //#endregion
105
- export { h as default };
97
+ export { p as default };
@@ -0,0 +1,6 @@
1
+ export declare const selectInstance: (instanceId: string) => void;
2
+ export declare const useIsSelectedInstance: (instanceId: string, enabled: boolean) => boolean;
3
+ export declare const useDevInstances: () => {
4
+ instanceIds: ReadonlyArray<string>;
5
+ selectedId: string | undefined;
6
+ };
@@ -0,0 +1,24 @@
1
+ import { useEffect as e, useSyncExternalStore as t } from "react";
2
+ //#region src/instanceRegistry.ts
3
+ var n = [], r = /* @__PURE__ */ new Set(), i, a = [], o = () => {
4
+ a = [...n];
5
+ for (let e of r) e();
6
+ }, s = (e) => (n.push(e), i === void 0 && (i = e), o(), () => {
7
+ let t = n.indexOf(e);
8
+ t !== -1 && n.splice(t, 1), i === e && (i = n[0]), o();
9
+ }), c = (e) => (r.add(e), () => {
10
+ r.delete(e);
11
+ }), l = () => a, u = () => i, d = (e) => {
12
+ i !== e && (i = e, o());
13
+ }, f = (n, r) => {
14
+ e(() => {
15
+ if (r) return s(n);
16
+ }, [r, n]);
17
+ let i = t(c, u, u);
18
+ return r && i === n;
19
+ }, p = () => ({
20
+ instanceIds: t(c, l, l),
21
+ selectedId: t(c, u, u)
22
+ });
23
+ //#endregion
24
+ export { d as selectInstance, p as useDevInstances, f as useIsSelectedInstance };
@@ -0,0 +1,13 @@
1
+ import { DevStoreEntry } from '@plitzi/nexus';
2
+ export type ScopeOption = {
3
+ label: string;
4
+ value: string;
5
+ };
6
+ export type ScopeOptionGroup = {
7
+ label: string;
8
+ options: ScopeOption[];
9
+ };
10
+ export declare const storeLabel: (entry: DevStoreEntry, rootKeys?: ReadonlySet<string>) => string;
11
+ export declare const rootKeysOf: (entries: ReadonlyArray<DevStoreEntry>) => ReadonlySet<string> | undefined;
12
+ export declare const buildScopeOptions: (entries: ReadonlyArray<DevStoreEntry>, instanceIds: ReadonlyArray<string>, activeInstanceId: string | undefined) => ScopeOptionGroup[];
13
+ export declare const resolveSelectedUid: (entries: ReadonlyArray<DevStoreEntry>, selectedUid: string | undefined) => string | undefined;
@@ -0,0 +1,23 @@
1
+ //#region src/scope/helpers.ts
2
+ var e = (e, t) => {
3
+ if (!t) return;
4
+ let n = Object.keys(e.getState()).filter((e) => !t.has(e));
5
+ return n.length > 0 ? `{ ${n.slice(0, 4).join(", ")} }` : void 0;
6
+ }, t = (t, n) => {
7
+ let { store: r, name: i, scopeId: a } = t;
8
+ return i ? r.scopePath ? `${i} · ${r.scopePath}` : i : r.scopePath ? r.scopePath : r.id ? r.id : a === void 0 ? "root" : e(r, n) ?? "scope";
9
+ }, n = (e) => {
10
+ let t = e.find((e) => e.scopeId === void 0);
11
+ return t ? new Set(Object.keys(t.store.getState())) : void 0;
12
+ }, r = (e, r, i) => {
13
+ let a = n(e);
14
+ return r.map((n) => ({
15
+ label: n,
16
+ options: e.filter((e) => e.scopeId === n || e.scopeId === void 0 && n === i).map((e) => ({
17
+ label: t(e, a),
18
+ value: e.uid
19
+ }))
20
+ }));
21
+ }, i = (e, t) => t && e.some((e) => e.uid === t) ? t : (e.find((e) => e.scopeId === void 0) ?? e.at(0))?.uid;
22
+ //#endregion
23
+ export { r as buildScopeOptions, i as resolveSelectedUid, n as rootKeysOf, t as storeLabel };
@@ -0,0 +1,2 @@
1
+ export declare const selectStore: (uid: string | undefined) => void;
2
+ export declare const useSelectedStoreUid: () => string | undefined;
@@ -0,0 +1,11 @@
1
+ import { useSyncExternalStore as e } from "react";
2
+ //#region src/scope/storeSelection.ts
3
+ var t, n = /* @__PURE__ */ new Set(), r = () => {
4
+ for (let e of n) e();
5
+ }, i = (e) => (n.add(e), () => {
6
+ n.delete(e);
7
+ }), a = () => t, o = (e) => {
8
+ t !== e && (t = e, r());
9
+ }, s = () => e(i, a, a);
10
+ //#endregion
11
+ export { o as selectStore, s as useSelectedStoreUid };
@@ -0,0 +1,3 @@
1
+ import { DevStoreEntry } from '@plitzi/nexus';
2
+ declare const useDevStores: () => ReadonlyArray<DevStoreEntry>;
3
+ export default useDevStores;
@@ -0,0 +1,6 @@
1
+ import { useSyncExternalStore as e } from "react";
2
+ import { getDevStoresSnapshot as t, subscribeDevStores as n } from "@plitzi/nexus";
3
+ //#region src/scope/useDevStores.ts
4
+ var r = () => e(n, t, t);
5
+ //#endregion
6
+ export { r as default };
@@ -0,0 +1,9 @@
1
+ import { ScopeOptionGroup } from './helpers';
2
+ import { DevStore } from '@plitzi/nexus';
3
+ export type ScopeSelector = {
4
+ options: ScopeOptionGroup[];
5
+ value: string | undefined;
6
+ onSelect: (uid: string) => void;
7
+ };
8
+ export declare const useScopeSelector: () => ScopeSelector;
9
+ export declare const useSelectedStore: () => DevStore | undefined;
@@ -0,0 +1,26 @@
1
+ import { selectInstance as e, useDevInstances as t } from "../instanceRegistry.mjs";
2
+ import { buildScopeOptions as n, resolveSelectedUid as r } from "./helpers.mjs";
3
+ import { selectStore as i, useSelectedStoreUid as a } from "./storeSelection.mjs";
4
+ import o from "./useDevStores.mjs";
5
+ import { useCallback as s, useMemo as c } from "react";
6
+ //#region src/scope/useScope.ts
7
+ var l = () => {
8
+ let l = o(), { instanceIds: u, selectedId: d } = t(), f = a();
9
+ return {
10
+ options: c(() => n(l, u, d), [
11
+ l,
12
+ u,
13
+ d
14
+ ]),
15
+ value: c(() => r(l, f), [l, f]),
16
+ onSelect: s((t) => {
17
+ let n = l.find((e) => e.uid === t);
18
+ n?.scopeId && e(n.scopeId), i(t);
19
+ }, [l])
20
+ };
21
+ }, u = () => {
22
+ let e = o(), t = a(), n = c(() => r(e, t), [e, t]);
23
+ return c(() => e.find((e) => e.uid === n)?.store, [e, n]);
24
+ };
25
+ //#endregion
26
+ export { l as useScopeSelector, u as useSelectedStore };
@@ -0,0 +1,3 @@
1
+ import { DevStore } from '@plitzi/nexus';
2
+ declare const useStoreState: (store: DevStore | undefined, merged: boolean) => Record<string, unknown>;
3
+ export default useStoreState;
@@ -0,0 +1,8 @@
1
+ import { useCallback as e, useSyncExternalStore as t } from "react";
2
+ //#region src/scope/useStoreState.ts
3
+ var n = {}, r = () => () => {}, i = (i, a) => {
4
+ let o = e((e) => i ? i.subscribe(e) : r(), [i]), s = e(() => i ? a ? i.getState() : i.getOwnState() : n, [i, a]);
5
+ return t(o, s, s);
6
+ };
7
+ //#endregion
8
+ export { i as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-dev-tools",
3
- "version": "0.32.4",
3
+ "version": "0.32.6",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -532,6 +532,30 @@
532
532
  "./index": {
533
533
  "types": "./dist/index.d.ts",
534
534
  "import": "./dist/index.mjs"
535
+ },
536
+ "./instanceRegistry": {
537
+ "types": "./dist/instanceRegistry.d.ts",
538
+ "import": "./dist/instanceRegistry.mjs"
539
+ },
540
+ "./scope/helpers": {
541
+ "types": "./dist/scope/helpers.d.ts",
542
+ "import": "./dist/scope/helpers.mjs"
543
+ },
544
+ "./scope/storeSelection": {
545
+ "types": "./dist/scope/storeSelection.d.ts",
546
+ "import": "./dist/scope/storeSelection.mjs"
547
+ },
548
+ "./scope/useDevStores": {
549
+ "types": "./dist/scope/useDevStores.d.ts",
550
+ "import": "./dist/scope/useDevStores.mjs"
551
+ },
552
+ "./scope/useScope": {
553
+ "types": "./dist/scope/useScope.d.ts",
554
+ "import": "./dist/scope/useScope.mjs"
555
+ },
556
+ "./scope/useStoreState": {
557
+ "types": "./dist/scope/useStoreState.d.ts",
558
+ "import": "./dist/scope/useStoreState.mjs"
535
559
  }
536
560
  },
537
561
  "scripts": {
@@ -544,23 +568,23 @@
544
568
  "type": "module",
545
569
  "sideEffects": false,
546
570
  "devDependencies": {
547
- "eslint": "^9.39.4",
548
- "react": "^19.2.7",
549
- "react-dom": "^19.2.7",
571
+ "eslint": "^9.39.5",
572
+ "react": "^19.2.8",
573
+ "react-dom": "^19.2.8",
550
574
  "typescript": "^6.0.3",
551
- "vite": "^8.0.16"
575
+ "vite": "^8.1.5"
552
576
  },
553
577
  "peerDependencies": {
554
578
  "react": "^19",
555
579
  "react-dom": "^19"
556
580
  },
557
581
  "dependencies": {
558
- "@plitzi/nexus": "0.32.4",
559
- "@plitzi/plitzi-ui": "^1.6.13",
560
- "@plitzi/sdk-navigation": "0.32.4",
561
- "@plitzi/sdk-schema": "0.32.4",
562
- "@plitzi/sdk-shared": "0.32.4",
563
- "@plitzi/sdk-style": "0.32.4",
582
+ "@plitzi/nexus": "0.32.6",
583
+ "@plitzi/plitzi-ui": "^1.6.17",
584
+ "@plitzi/sdk-navigation": "0.32.6",
585
+ "@plitzi/sdk-schema": "0.32.6",
586
+ "@plitzi/sdk-shared": "0.32.6",
587
+ "@plitzi/sdk-style": "0.32.6",
564
588
  "@uiw/react-json-view": "^2.0.0-alpha.43",
565
589
  "clsx": "^2.1.1"
566
590
  }