@fluixi/devtools 0.2.0-alpha.3 → 0.2.0-alpha.5

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 (91) hide show
  1. package/dist/callsite.cjs +72 -0
  2. package/dist/callsite.d.ts +1 -1
  3. package/dist/callsite.js +1 -1
  4. package/dist/callsite.mjs +51 -0
  5. package/dist/change-view.cjs +134 -0
  6. package/dist/change-view.js +2 -2
  7. package/dist/change-view.mjs +111 -0
  8. package/dist/copy.cjs +63 -0
  9. package/dist/copy.mjs +42 -0
  10. package/dist/describe.cjs +55 -0
  11. package/dist/describe.js +2 -2
  12. package/dist/describe.mjs +34 -0
  13. package/dist/detail-panel.cjs +307 -0
  14. package/dist/detail-panel.d.ts +1 -1
  15. package/dist/detail-panel.d.ts.map +1 -1
  16. package/dist/detail-panel.js +1 -1
  17. package/dist/detail-panel.mjs +284 -0
  18. package/dist/diff.cjs +225 -0
  19. package/dist/diff.js +1 -1
  20. package/dist/diff.mjs +202 -0
  21. package/dist/dom.cjs +204 -0
  22. package/dist/dom.mjs +183 -0
  23. package/dist/export.cjs +221 -0
  24. package/dist/export.d.ts +2 -2
  25. package/dist/export.d.ts.map +1 -1
  26. package/dist/export.js +1 -1
  27. package/dist/export.mjs +209 -0
  28. package/dist/float.cjs +232 -0
  29. package/dist/float.d.ts +1 -1
  30. package/dist/float.js +3 -3
  31. package/dist/float.mjs +211 -0
  32. package/dist/format.cjs +175 -0
  33. package/dist/format.js +3 -3
  34. package/dist/format.mjs +154 -0
  35. package/dist/graph-view.cjs +893 -0
  36. package/dist/graph-view.mjs +870 -0
  37. package/dist/highlight.cjs +140 -0
  38. package/dist/highlight.mjs +119 -0
  39. package/dist/history.cjs +95 -0
  40. package/dist/history.d.ts +2 -2
  41. package/dist/history.js +2 -2
  42. package/dist/history.mjs +74 -0
  43. package/dist/hook.cjs +1562 -0
  44. package/dist/hook.d.ts +3 -3
  45. package/dist/hook.js +6 -6
  46. package/dist/hook.mjs +1553 -0
  47. package/dist/index.cjs +4552 -0
  48. package/dist/index.mjs +4544 -0
  49. package/dist/inspector.cjs +688 -0
  50. package/dist/inspector.d.ts +2 -2
  51. package/dist/inspector.js +7 -7
  52. package/dist/inspector.mjs +676 -0
  53. package/dist/instrument.cjs +497 -0
  54. package/dist/instrument.mjs +487 -0
  55. package/dist/kind-filter.cjs +172 -0
  56. package/dist/kind-filter.d.ts +2 -2
  57. package/dist/kind-filter.js +1 -1
  58. package/dist/kind-filter.mjs +151 -0
  59. package/dist/menu.cjs +141 -0
  60. package/dist/menu.mjs +120 -0
  61. package/dist/observe.cjs +1352 -0
  62. package/dist/observe.mjs +1345 -0
  63. package/dist/palette.cjs +52 -0
  64. package/dist/palette.mjs +31 -0
  65. package/dist/path.cjs +45 -0
  66. package/dist/path.d.ts +2 -2
  67. package/dist/path.js +2 -2
  68. package/dist/path.mjs +24 -0
  69. package/dist/plugin.cjs +87 -0
  70. package/dist/plugin.mjs +66 -0
  71. package/dist/plugins/context.cjs +98 -0
  72. package/dist/plugins/context.mjs +75 -0
  73. package/dist/plugins/directives.cjs +98 -0
  74. package/dist/plugins/directives.mjs +75 -0
  75. package/dist/plugins/index.cjs +162 -0
  76. package/dist/plugins/index.mjs +140 -0
  77. package/dist/source.cjs +111 -0
  78. package/dist/source.d.ts +2 -2
  79. package/dist/source.js +4 -4
  80. package/dist/source.mjs +90 -0
  81. package/dist/timeline.cjs +350 -0
  82. package/dist/timeline.js +3 -3
  83. package/dist/timeline.mjs +327 -0
  84. package/dist/tree.cjs +574 -0
  85. package/dist/tree.mjs +551 -0
  86. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  87. package/dist/value-pane.cjs +223 -0
  88. package/dist/value-pane.mjs +200 -0
  89. package/dist/wire.cjs +109 -0
  90. package/dist/wire.mjs +89 -0
  91. package/package.json +19 -6
package/dist/float.cjs ADDED
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/float.ts
21
+ var float_exports = {};
22
+ __export(float_exports, {
23
+ FLOAT_CSS: () => FLOAT_CSS,
24
+ floatCard: () => floatCard,
25
+ makeFloatable: () => makeFloatable
26
+ });
27
+ module.exports = __toCommonJS(float_exports);
28
+ var MIN_W = 240;
29
+ var MIN_H = 160;
30
+ function draggable(handle, onMove, onStart) {
31
+ handle.addEventListener("pointerdown", (event) => {
32
+ if (event.button !== 0) return;
33
+ if (event.target.closest("button")) return;
34
+ event.preventDefault();
35
+ handle.setPointerCapture(event.pointerId);
36
+ const fromX = event.clientX;
37
+ const fromY = event.clientY;
38
+ onStart?.();
39
+ const move = (e) => onMove(e.clientX - fromX, e.clientY - fromY);
40
+ const stop = () => {
41
+ handle.removeEventListener("pointermove", move);
42
+ handle.removeEventListener("pointerup", stop);
43
+ handle.removeEventListener("pointercancel", stop);
44
+ handle.removeEventListener("lostpointercapture", stop);
45
+ if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
46
+ };
47
+ handle.addEventListener("pointermove", move);
48
+ handle.addEventListener("pointerup", stop);
49
+ handle.addEventListener("pointercancel", stop);
50
+ handle.addEventListener("lostpointercapture", stop);
51
+ });
52
+ }
53
+ var opened = 0;
54
+ function floatCard(doc, title, at) {
55
+ const card = doc.createElement("div");
56
+ card.className = "fx-float";
57
+ const spot = at ?? {
58
+ x: 60 + opened % 4 * 28,
59
+ y: 60 + opened % 4 * 28,
60
+ width: 360,
61
+ height: 280
62
+ };
63
+ opened += 1;
64
+ const bar = doc.createElement("div");
65
+ bar.className = "fx-float-bar";
66
+ const name = doc.createElement("span");
67
+ name.textContent = title;
68
+ bar.append(name);
69
+ card.append(bar);
70
+ let x = spot.x;
71
+ let y = spot.y;
72
+ let w = spot.width;
73
+ let h = spot.height;
74
+ const apply = () => {
75
+ const view = doc.defaultView;
76
+ const vw = view?.innerWidth ?? w;
77
+ const vh = view?.innerHeight ?? h;
78
+ w = Math.min(Math.max(MIN_W, w), vw);
79
+ h = Math.min(Math.max(MIN_H, h), vh);
80
+ x = Math.min(Math.max(0, x), Math.max(0, vw - w));
81
+ y = Math.min(Math.max(0, y), Math.max(0, vh - h));
82
+ card.style.left = `${x}px`;
83
+ card.style.top = `${y}px`;
84
+ card.style.width = `${w}px`;
85
+ card.style.height = `${h}px`;
86
+ };
87
+ let from = { x, y, w, h };
88
+ const remember = () => {
89
+ from = { x, y, w, h };
90
+ };
91
+ for (const edge of ["n", "s", "e", "w", "ne", "nw", "se", "sw"]) {
92
+ const handle = doc.createElement("div");
93
+ handle.className = `fx-float-h fx-float-${edge}`;
94
+ card.append(handle);
95
+ draggable(
96
+ handle,
97
+ (dx, dy) => {
98
+ if (edge.includes("e")) w = from.w + dx;
99
+ if (edge.includes("s")) h = from.h + dy;
100
+ if (edge.includes("w")) {
101
+ w = Math.max(MIN_W, from.w - dx);
102
+ x = from.x + from.w - w;
103
+ }
104
+ if (edge.includes("n")) {
105
+ h = Math.max(MIN_H, from.h - dy);
106
+ y = from.y + from.h - h;
107
+ }
108
+ apply();
109
+ },
110
+ remember
111
+ );
112
+ }
113
+ draggable(
114
+ bar,
115
+ (dx, dy) => {
116
+ x = from.x + dx;
117
+ y = from.y + dy;
118
+ apply();
119
+ },
120
+ remember
121
+ );
122
+ apply();
123
+ return { card, bar, remove: () => card.remove() };
124
+ }
125
+ function makeFloatable(pane, options) {
126
+ const doc = pane.ownerDocument;
127
+ let card = null;
128
+ let home = null;
129
+ const button = doc.createElement("button");
130
+ button.type = "button";
131
+ button.className = "fx-float-btn";
132
+ button.textContent = "⇱";
133
+ button.title = `Float ${options.title}`;
134
+ pane.classList.add("fx-floatable");
135
+ pane.append(button);
136
+ const keep = new MutationObserver(() => {
137
+ if (button.parentNode !== pane) pane.append(button);
138
+ });
139
+ keep.observe(pane, { childList: true });
140
+ function dock() {
141
+ if (!card || !home) return;
142
+ home.parent.insertBefore(pane, home.before);
143
+ card.remove();
144
+ card = null;
145
+ home = null;
146
+ pane.classList.remove("fx-floated");
147
+ button.textContent = "⇱";
148
+ button.title = `Float ${options.title}`;
149
+ options.onChange?.(false);
150
+ }
151
+ function float() {
152
+ if (card || !pane.parentNode) return;
153
+ home = { parent: pane.parentNode, before: pane.nextSibling };
154
+ const built = floatCard(doc, options.title, options.at);
155
+ card = built.card;
156
+ card.append(pane);
157
+ doc.body.appendChild(card);
158
+ pane.classList.add("fx-floated");
159
+ button.textContent = "⇲";
160
+ button.title = `Put ${options.title} back`;
161
+ options.onChange?.(true);
162
+ }
163
+ button.addEventListener("click", (event) => {
164
+ event.stopPropagation();
165
+ if (card) dock();
166
+ else float();
167
+ });
168
+ return {
169
+ get floating() {
170
+ return card !== null;
171
+ },
172
+ toggle() {
173
+ if (card) dock();
174
+ else float();
175
+ return card !== null;
176
+ },
177
+ dock,
178
+ destroy() {
179
+ keep.disconnect();
180
+ dock();
181
+ button.remove();
182
+ pane.classList.remove("fx-floatable");
183
+ }
184
+ };
185
+ }
186
+ var FLOAT_CSS = `
187
+ .fx-floatable { position: relative; }
188
+ .fx-float-btn {
189
+ position: absolute; top: 2px; right: 2px; z-index: 5;
190
+ width: 18px; height: 18px; padding: 0; line-height: 1;
191
+ font-size: 11px; color: var(--fx-muted, #8a90a2);
192
+ background: var(--fx-panel, #14161c);
193
+ border: 1px solid var(--fx-line, #262a35); border-radius: 4px;
194
+ cursor: pointer; opacity: 0; transition: opacity .12s;
195
+ }
196
+ .fx-floatable:hover .fx-float-btn, .fx-float-btn:focus-visible { opacity: 1; }
197
+ .fx-float-btn:hover { color: var(--fx-accent, #5eead4); border-color: var(--fx-accent, #5eead4); }
198
+
199
+ .fx-float {
200
+ position: fixed; z-index: 60; display: flex; flex-direction: column;
201
+ background: var(--fx-panel, #14161c);
202
+ border: 1px solid var(--fx-line, #262a35); border-radius: 8px;
203
+ box-shadow: 0 12px 34px rgba(0, 0, 0, .5); overflow: hidden;
204
+ }
205
+ .fx-float-bar {
206
+ display: flex; align-items: center; padding: 4px 8px; cursor: move;
207
+ font-size: 11px; color: var(--fx-muted, #8a90a2);
208
+ background: var(--fx-bg, #0f1115); border-bottom: 1px solid var(--fx-line, #262a35);
209
+ user-select: none;
210
+ }
211
+ /* The pane fills the card, whatever it was sized to in the layout it came from. */
212
+ .fx-float > .fx-floated {
213
+ flex: 1; min-height: 0; width: auto; height: auto; overflow: auto;
214
+ }
215
+ /* Edges and corners. Thin, and over everything, so a card can be resized from whichever
216
+ side is reachable. */
217
+ .fx-float-h { position: absolute; z-index: 1; }
218
+ .fx-float-n, .fx-float-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
219
+ .fx-float-e, .fx-float-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
220
+ .fx-float-n { top: -3px; }
221
+ .fx-float-s { bottom: -3px; }
222
+ .fx-float-e { right: -3px; }
223
+ .fx-float-w { left: -3px; }
224
+ .fx-float-ne, .fx-float-nw, .fx-float-se, .fx-float-sw { width: 14px; height: 14px; }
225
+ .fx-float-nw { top: -3px; left: -3px; cursor: nwse-resize; }
226
+ .fx-float-ne { top: -3px; right: -3px; cursor: nesw-resize; }
227
+ .fx-float-sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
228
+ .fx-float-se {
229
+ bottom: 0; right: 0; cursor: nwse-resize;
230
+ background: linear-gradient(135deg, transparent 50%, var(--fx-line, #262a35) 50%);
231
+ }
232
+ `;
package/dist/float.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * it back exactly where it was.
8
8
  *
9
9
  * The pane element itself is moved rather than re-rendered. Whatever drew into it keeps its
10
- * handle on it, its listeners, and its scroll position a floated timeline is the same
10
+ * handle on it, its listeners, and its scroll position, a floated timeline is the same
11
11
  * timeline, not a copy of one.
12
12
  */
13
13
  export interface FloatOptions {
package/dist/float.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * it back exactly where it was.
8
8
  *
9
9
  * The pane element itself is moved rather than re-rendered. Whatever drew into it keeps its
10
- * handle on it, its listeners, and its scroll position a floated timeline is the same
10
+ * handle on it, its listeners, and its scroll position, a floated timeline is the same
11
11
  * timeline, not a copy of one.
12
12
  */
13
13
  /** So a card cannot be dragged or resized into something unreadable. */
@@ -146,8 +146,8 @@ export function makeFloatable(pane, options) {
146
146
  pane.classList.add('fx-floatable');
147
147
  pane.append(button);
148
148
  /**
149
- * The panes rewrite their own contents the inspector replaces its markup whenever the
150
- * selection changes which takes the button with it. Rather than asking each of them to
149
+ * The panes rewrite their own contents: the inspector replaces its markup whenever the
150
+ * selection changes: which takes the button with it. Rather than asking each of them to
151
151
  * leave it alone, it is put back when it goes.
152
152
  */
153
153
  const keep = new MutationObserver(() => {
package/dist/float.mjs ADDED
@@ -0,0 +1,211 @@
1
+ // src/float.ts
2
+ var MIN_W = 240;
3
+ var MIN_H = 160;
4
+ function draggable(handle, onMove, onStart) {
5
+ handle.addEventListener("pointerdown", (event) => {
6
+ if (event.button !== 0) return;
7
+ if (event.target.closest("button")) return;
8
+ event.preventDefault();
9
+ handle.setPointerCapture(event.pointerId);
10
+ const fromX = event.clientX;
11
+ const fromY = event.clientY;
12
+ onStart?.();
13
+ const move = (e) => onMove(e.clientX - fromX, e.clientY - fromY);
14
+ const stop = () => {
15
+ handle.removeEventListener("pointermove", move);
16
+ handle.removeEventListener("pointerup", stop);
17
+ handle.removeEventListener("pointercancel", stop);
18
+ handle.removeEventListener("lostpointercapture", stop);
19
+ if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
20
+ };
21
+ handle.addEventListener("pointermove", move);
22
+ handle.addEventListener("pointerup", stop);
23
+ handle.addEventListener("pointercancel", stop);
24
+ handle.addEventListener("lostpointercapture", stop);
25
+ });
26
+ }
27
+ var opened = 0;
28
+ function floatCard(doc, title, at) {
29
+ const card = doc.createElement("div");
30
+ card.className = "fx-float";
31
+ const spot = at ?? {
32
+ x: 60 + opened % 4 * 28,
33
+ y: 60 + opened % 4 * 28,
34
+ width: 360,
35
+ height: 280
36
+ };
37
+ opened += 1;
38
+ const bar = doc.createElement("div");
39
+ bar.className = "fx-float-bar";
40
+ const name = doc.createElement("span");
41
+ name.textContent = title;
42
+ bar.append(name);
43
+ card.append(bar);
44
+ let x = spot.x;
45
+ let y = spot.y;
46
+ let w = spot.width;
47
+ let h = spot.height;
48
+ const apply = () => {
49
+ const view = doc.defaultView;
50
+ const vw = view?.innerWidth ?? w;
51
+ const vh = view?.innerHeight ?? h;
52
+ w = Math.min(Math.max(MIN_W, w), vw);
53
+ h = Math.min(Math.max(MIN_H, h), vh);
54
+ x = Math.min(Math.max(0, x), Math.max(0, vw - w));
55
+ y = Math.min(Math.max(0, y), Math.max(0, vh - h));
56
+ card.style.left = `${x}px`;
57
+ card.style.top = `${y}px`;
58
+ card.style.width = `${w}px`;
59
+ card.style.height = `${h}px`;
60
+ };
61
+ let from = { x, y, w, h };
62
+ const remember = () => {
63
+ from = { x, y, w, h };
64
+ };
65
+ for (const edge of ["n", "s", "e", "w", "ne", "nw", "se", "sw"]) {
66
+ const handle = doc.createElement("div");
67
+ handle.className = `fx-float-h fx-float-${edge}`;
68
+ card.append(handle);
69
+ draggable(
70
+ handle,
71
+ (dx, dy) => {
72
+ if (edge.includes("e")) w = from.w + dx;
73
+ if (edge.includes("s")) h = from.h + dy;
74
+ if (edge.includes("w")) {
75
+ w = Math.max(MIN_W, from.w - dx);
76
+ x = from.x + from.w - w;
77
+ }
78
+ if (edge.includes("n")) {
79
+ h = Math.max(MIN_H, from.h - dy);
80
+ y = from.y + from.h - h;
81
+ }
82
+ apply();
83
+ },
84
+ remember
85
+ );
86
+ }
87
+ draggable(
88
+ bar,
89
+ (dx, dy) => {
90
+ x = from.x + dx;
91
+ y = from.y + dy;
92
+ apply();
93
+ },
94
+ remember
95
+ );
96
+ apply();
97
+ return { card, bar, remove: () => card.remove() };
98
+ }
99
+ function makeFloatable(pane, options) {
100
+ const doc = pane.ownerDocument;
101
+ let card = null;
102
+ let home = null;
103
+ const button = doc.createElement("button");
104
+ button.type = "button";
105
+ button.className = "fx-float-btn";
106
+ button.textContent = "⇱";
107
+ button.title = `Float ${options.title}`;
108
+ pane.classList.add("fx-floatable");
109
+ pane.append(button);
110
+ const keep = new MutationObserver(() => {
111
+ if (button.parentNode !== pane) pane.append(button);
112
+ });
113
+ keep.observe(pane, { childList: true });
114
+ function dock() {
115
+ if (!card || !home) return;
116
+ home.parent.insertBefore(pane, home.before);
117
+ card.remove();
118
+ card = null;
119
+ home = null;
120
+ pane.classList.remove("fx-floated");
121
+ button.textContent = "⇱";
122
+ button.title = `Float ${options.title}`;
123
+ options.onChange?.(false);
124
+ }
125
+ function float() {
126
+ if (card || !pane.parentNode) return;
127
+ home = { parent: pane.parentNode, before: pane.nextSibling };
128
+ const built = floatCard(doc, options.title, options.at);
129
+ card = built.card;
130
+ card.append(pane);
131
+ doc.body.appendChild(card);
132
+ pane.classList.add("fx-floated");
133
+ button.textContent = "⇲";
134
+ button.title = `Put ${options.title} back`;
135
+ options.onChange?.(true);
136
+ }
137
+ button.addEventListener("click", (event) => {
138
+ event.stopPropagation();
139
+ if (card) dock();
140
+ else float();
141
+ });
142
+ return {
143
+ get floating() {
144
+ return card !== null;
145
+ },
146
+ toggle() {
147
+ if (card) dock();
148
+ else float();
149
+ return card !== null;
150
+ },
151
+ dock,
152
+ destroy() {
153
+ keep.disconnect();
154
+ dock();
155
+ button.remove();
156
+ pane.classList.remove("fx-floatable");
157
+ }
158
+ };
159
+ }
160
+ var FLOAT_CSS = `
161
+ .fx-floatable { position: relative; }
162
+ .fx-float-btn {
163
+ position: absolute; top: 2px; right: 2px; z-index: 5;
164
+ width: 18px; height: 18px; padding: 0; line-height: 1;
165
+ font-size: 11px; color: var(--fx-muted, #8a90a2);
166
+ background: var(--fx-panel, #14161c);
167
+ border: 1px solid var(--fx-line, #262a35); border-radius: 4px;
168
+ cursor: pointer; opacity: 0; transition: opacity .12s;
169
+ }
170
+ .fx-floatable:hover .fx-float-btn, .fx-float-btn:focus-visible { opacity: 1; }
171
+ .fx-float-btn:hover { color: var(--fx-accent, #5eead4); border-color: var(--fx-accent, #5eead4); }
172
+
173
+ .fx-float {
174
+ position: fixed; z-index: 60; display: flex; flex-direction: column;
175
+ background: var(--fx-panel, #14161c);
176
+ border: 1px solid var(--fx-line, #262a35); border-radius: 8px;
177
+ box-shadow: 0 12px 34px rgba(0, 0, 0, .5); overflow: hidden;
178
+ }
179
+ .fx-float-bar {
180
+ display: flex; align-items: center; padding: 4px 8px; cursor: move;
181
+ font-size: 11px; color: var(--fx-muted, #8a90a2);
182
+ background: var(--fx-bg, #0f1115); border-bottom: 1px solid var(--fx-line, #262a35);
183
+ user-select: none;
184
+ }
185
+ /* The pane fills the card, whatever it was sized to in the layout it came from. */
186
+ .fx-float > .fx-floated {
187
+ flex: 1; min-height: 0; width: auto; height: auto; overflow: auto;
188
+ }
189
+ /* Edges and corners. Thin, and over everything, so a card can be resized from whichever
190
+ side is reachable. */
191
+ .fx-float-h { position: absolute; z-index: 1; }
192
+ .fx-float-n, .fx-float-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
193
+ .fx-float-e, .fx-float-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
194
+ .fx-float-n { top: -3px; }
195
+ .fx-float-s { bottom: -3px; }
196
+ .fx-float-e { right: -3px; }
197
+ .fx-float-w { left: -3px; }
198
+ .fx-float-ne, .fx-float-nw, .fx-float-se, .fx-float-sw { width: 14px; height: 14px; }
199
+ .fx-float-nw { top: -3px; left: -3px; cursor: nwse-resize; }
200
+ .fx-float-ne { top: -3px; right: -3px; cursor: nesw-resize; }
201
+ .fx-float-sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
202
+ .fx-float-se {
203
+ bottom: 0; right: 0; cursor: nwse-resize;
204
+ background: linear-gradient(135deg, transparent 50%, var(--fx-line, #262a35) 50%);
205
+ }
206
+ `;
207
+ export {
208
+ FLOAT_CSS,
209
+ floatCard,
210
+ makeFloatable
211
+ };
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/format.ts
21
+ var format_exports = {};
22
+ __export(format_exports, {
23
+ formatValue: () => formatValue,
24
+ indentValue: () => indentValue,
25
+ shorten: () => shorten
26
+ });
27
+ module.exports = __toCommonJS(format_exports);
28
+ var MAX_DEPTH = 3;
29
+ var MAX_ENTRIES = 8;
30
+ function domName(v) {
31
+ if (typeof v?.nodeType !== "number" || typeof v.nodeName !== "string") return null;
32
+ return v.tagName ? `<${v.tagName.toLowerCase()}>` : `#${v.nodeName.toLowerCase()}`;
33
+ }
34
+ function fnName(v) {
35
+ return v.name ? `ƒ ${v.name}()` : "ƒ";
36
+ }
37
+ function className(v) {
38
+ const name = v.constructor?.name;
39
+ return name && name !== "Object" ? `${name} ` : "";
40
+ }
41
+ function primitive(v) {
42
+ if (v === null) return "null";
43
+ switch (typeof v) {
44
+ case "undefined":
45
+ return "undefined";
46
+ case "string":
47
+ return JSON.stringify(v);
48
+ case "number":
49
+ case "boolean":
50
+ return String(v);
51
+ case "bigint":
52
+ return `${v}n`;
53
+ case "symbol":
54
+ return v.toString();
55
+ case "function":
56
+ return fnName(v);
57
+ default:
58
+ return null;
59
+ }
60
+ }
61
+ function walk(value, depth, seen) {
62
+ const simple = primitive(value);
63
+ if (simple !== null) return simple;
64
+ const object = value;
65
+ if (seen.has(object)) return "[circular]";
66
+ const dom = domName(object);
67
+ if (dom) return dom;
68
+ if (object instanceof Date) return Number.isNaN(object.getTime()) ? "Invalid Date" : object.toISOString();
69
+ if (object instanceof RegExp) return String(object);
70
+ if (object instanceof Error) return `${object.name}: ${object.message}`;
71
+ if (object instanceof Promise) return "Promise";
72
+ if (ArrayBuffer.isView(object)) {
73
+ return `${className(object).trim()}(${object.length ?? ""})`;
74
+ }
75
+ if (depth >= MAX_DEPTH) return Array.isArray(object) ? "[…]" : "{…}";
76
+ seen.add(object);
77
+ try {
78
+ if (Array.isArray(object)) {
79
+ const shown2 = object.slice(0, MAX_ENTRIES).map((item) => walk(item, depth + 1, seen));
80
+ if (object.length > MAX_ENTRIES) shown2.push("…");
81
+ return `[${shown2.join(", ")}]`;
82
+ }
83
+ if (object instanceof Map) {
84
+ const shown2 = [];
85
+ for (const [k, v] of object) {
86
+ if (shown2.length === MAX_ENTRIES) {
87
+ shown2.push("…");
88
+ break;
89
+ }
90
+ shown2.push(`${walk(k, depth + 1, seen)} => ${walk(v, depth + 1, seen)}`);
91
+ }
92
+ return `Map(${object.size}) {${shown2.join(", ")}}`;
93
+ }
94
+ if (object instanceof Set) {
95
+ const shown2 = [];
96
+ for (const item of object) {
97
+ if (shown2.length === MAX_ENTRIES) {
98
+ shown2.push("…");
99
+ break;
100
+ }
101
+ shown2.push(walk(item, depth + 1, seen));
102
+ }
103
+ return `Set(${object.size}) {${shown2.join(", ")}}`;
104
+ }
105
+ const keys = Object.keys(object);
106
+ const shown = keys.slice(0, MAX_ENTRIES).map((key) => {
107
+ let read;
108
+ try {
109
+ read = walk(object[key], depth + 1, seen);
110
+ } catch {
111
+ read = "[unreadable]";
112
+ }
113
+ return `${key}: ${read}`;
114
+ });
115
+ if (keys.length > MAX_ENTRIES) shown.push("…");
116
+ return `${className(object)}{${shown.join(", ")}}`;
117
+ } finally {
118
+ seen.delete(object);
119
+ }
120
+ }
121
+ function formatValue(value, limit = 240) {
122
+ let text;
123
+ try {
124
+ text = walk(value, 0, /* @__PURE__ */ new Set());
125
+ } catch {
126
+ text = "[unreadable]";
127
+ }
128
+ return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
129
+ }
130
+ function shorten(text, limit = 18) {
131
+ return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
132
+ }
133
+ function indentValue(text, pad = " ") {
134
+ const out = [];
135
+ let depth = 0;
136
+ let quote = null;
137
+ let line = "";
138
+ const flush = () => {
139
+ if (line.trim()) out.push(pad.repeat(depth) + line.trim());
140
+ line = "";
141
+ };
142
+ for (let i = 0; i < text.length; i++) {
143
+ const c = text[i];
144
+ if (quote) {
145
+ line += c;
146
+ if (c === quote && text[i - 1] !== "\\") quote = null;
147
+ continue;
148
+ }
149
+ if (c === '"' || c === "'") {
150
+ quote = c;
151
+ line += c;
152
+ continue;
153
+ }
154
+ if (c === "{" || c === "[") {
155
+ line += c;
156
+ flush();
157
+ depth++;
158
+ continue;
159
+ }
160
+ if (c === "}" || c === "]") {
161
+ flush();
162
+ depth = Math.max(0, depth - 1);
163
+ line = c;
164
+ continue;
165
+ }
166
+ if (c === ",") {
167
+ line += c;
168
+ flush();
169
+ continue;
170
+ }
171
+ line += c;
172
+ }
173
+ flush();
174
+ return out.join("\n");
175
+ }
package/dist/format.js CHANGED
@@ -1,14 +1,14 @@
1
1
  // Turning a live value into something a graph can print.
2
2
  //
3
- // Not JSON.stringify: a signal holds whatever the author put in it a Map, a Date, a class
4
- // instance, a dom node, something that refers to itself, a getter that throws and
3
+ // Not JSON.stringify: a signal holds whatever the author put in it, a Map, a Date, a class
4
+ // instance, a dom node, something that refers to itself, a getter that throws, and
5
5
  // stringify answers `{}`, `[object Object]` or an exception for most of that. This walks the
6
6
  // value instead, so every case has an answer and none of them is a crash.
7
7
  //
8
8
  // It is a label, not a serializer. Depth and length are capped, and what is cut says so.
9
9
  const MAX_DEPTH = 3;
10
10
  const MAX_ENTRIES = 8;
11
- /** A dom node, without assuming this realm's Node an iframe's is a different class. */
11
+ /** A dom node, without assuming this realm's Node, an iframe's is a different class. */
12
12
  function domName(v) {
13
13
  if (typeof v?.nodeType !== 'number' || typeof v.nodeName !== 'string')
14
14
  return null;