@fluixi/devtools 1.0.0-alpha.108 → 1.0.0-alpha.109

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 (65) hide show
  1. package/dist/callsite.mjs +4 -63
  2. package/dist/change-view.mjs +6 -106
  3. package/dist/chunk-2VDMQ3VF.mjs +520 -0
  4. package/dist/chunk-33U2S43X.mjs +121 -0
  5. package/dist/chunk-4P45Y5EB.mjs +214 -0
  6. package/dist/chunk-B3SAJ7QG.mjs +72 -0
  7. package/dist/chunk-CPZWLBCQ.mjs +35 -0
  8. package/dist/chunk-D25KZZBZ.mjs +212 -0
  9. package/dist/chunk-EBSROPWJ.mjs +314 -0
  10. package/dist/chunk-F664XLZL.mjs +743 -0
  11. package/dist/chunk-FY5K3QVT.mjs +35 -0
  12. package/dist/chunk-G7Z7CVP5.mjs +184 -0
  13. package/dist/chunk-GDQXCOQB.mjs +43 -0
  14. package/dist/chunk-L6XQGNMW.mjs +106 -0
  15. package/dist/chunk-MN6O673L.mjs +90 -0
  16. package/dist/chunk-NDUBBBNL.mjs +70 -0
  17. package/dist/chunk-NT7YMK77.mjs +157 -0
  18. package/dist/chunk-NVULLJDH.mjs +120 -0
  19. package/dist/chunk-NWLSDERQ.mjs +68 -0
  20. package/dist/chunk-OPIGF5XB.mjs +184 -0
  21. package/dist/chunk-P5I7DWFX.mjs +292 -0
  22. package/dist/chunk-PKARAAIS.mjs +75 -0
  23. package/dist/chunk-PSSBFXBD.mjs +155 -0
  24. package/dist/chunk-PTQ5VCYE.mjs +103 -0
  25. package/dist/chunk-PU4MJ5RU.mjs +107 -0
  26. package/dist/chunk-UAEJ3N7F.mjs +76 -0
  27. package/dist/chunk-V6DKWEYD.mjs +67 -0
  28. package/dist/chunk-VO2V7AC5.mjs +80 -0
  29. package/dist/chunk-WGQH7RUW.mjs +25 -0
  30. package/dist/chunk-Y5OQWBAM.mjs +777 -0
  31. package/dist/chunk-Z6KYHEKY.mjs +64 -0
  32. package/dist/copy.mjs +3 -39
  33. package/dist/describe.mjs +3 -31
  34. package/dist/detail-panel.mjs +6 -280
  35. package/dist/diff.mjs +4 -201
  36. package/dist/dom.mjs +7 -176
  37. package/dist/export.mjs +6 -207
  38. package/dist/float.mjs +5 -206
  39. package/dist/format.mjs +5 -151
  40. package/dist/graph-view.mjs +9 -875
  41. package/dist/highlight.mjs +6 -113
  42. package/dist/history.mjs +4 -70
  43. package/dist/hook.mjs +16 -1719
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.mjs +106 -4673
  46. package/dist/inspector.mjs +11 -677
  47. package/dist/instrument.mjs +9 -486
  48. package/dist/kind-filter.mjs +6 -148
  49. package/dist/menu.mjs +4 -116
  50. package/dist/observe.mjs +14 -1510
  51. package/dist/palette.mjs +6 -28
  52. package/dist/path.mjs +3 -21
  53. package/dist/plugin.mjs +9 -57
  54. package/dist/plugins/context.mjs +6 -71
  55. package/dist/plugins/directives.mjs +8 -68
  56. package/dist/plugins/index.cjs +1 -1
  57. package/dist/plugins/index.mjs +13 -136
  58. package/dist/source.mjs +12 -93
  59. package/dist/timeline.mjs +7 -323
  60. package/dist/tree.mjs +11 -558
  61. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  62. package/dist/value-pane.mjs +6 -196
  63. package/dist/wire.cjs +1 -1
  64. package/dist/wire.mjs +6 -86
  65. package/package.json +3 -3
@@ -1,490 +1,13 @@
1
- // src/instrument.ts
2
1
  import {
3
- createSignal,
4
- createMemo,
5
- createEffect,
6
- createResource,
7
- createRoot,
8
- untrack,
9
- onCleanup,
10
- getOwner,
11
- runWithOwner,
12
- Signal
13
- } from "@fluixi/reactive/signal";
14
- import { createStore } from "@fluixi/reactive/store";
15
-
16
- // src/source.ts
17
- var MARKER = "__fx_source";
18
- var COMPONENT_MARKER = "__fx_component";
19
- var CLASS_MARKER = "__fx_class";
20
- var HOLE_MARKER = "__fx_hole";
21
- var PROPS_MARKER = "__fx_props";
22
- var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
23
- var host = globalThis;
24
- var shared = host[MARKS] ?? {
25
- pending: null,
26
- expiring: false,
27
- components: /* @__PURE__ */ new Map()
28
- };
29
- host[MARKS] = shared;
30
- shared.classes ??= /* @__PURE__ */ new WeakMap();
31
- function markReactiveSource(file, line, column, name, self) {
32
- const location = locate(file, line, column);
33
- if (shared.pending && location.external && !shared.pending.location?.external) return;
34
- shared.pending = self && typeof self === "object" ? { name, location, self } : { name, location };
35
- shared.expiring = false;
36
- }
37
- function locate(file, line, column) {
38
- const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
39
- return external ? { file, line, column, external } : { file, line, column };
40
- }
41
- function markComponentSource(name, file, line, column) {
42
- const seen = shared.components.get(name);
43
- const next = locate(file, line, column);
44
- if (seen === void 0) {
45
- shared.components.set(name, next);
46
- return;
47
- }
48
- if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
49
- }
50
- function markClassSource(constructor, file, line, column) {
51
- if (typeof constructor === "function") shared.classes.set(constructor, locate(file, line, column));
52
- }
53
- function componentSource(name) {
54
- return shared.components.get(name) ?? void 0;
55
- }
56
- function takeReactiveSource() {
57
- const mark = shared.pending;
58
- if (mark) {
59
- if (mark.name !== void 0 || mark.self) shared.pending = { location: mark.location };
60
- if (!shared.expiring) {
61
- shared.expiring = true;
62
- queueMicrotask(() => {
63
- shared.expiring = false;
64
- shared.pending = null;
65
- });
66
- }
67
- }
68
- return mark;
69
- }
70
- var HOLES = /* @__PURE__ */ new WeakMap();
71
- var HOLE_TAG = "__fx_at";
72
- function markHole(accessor, line, column, name) {
73
- if (accessor && (typeof accessor === "object" || typeof accessor === "function")) {
74
- const at = name === void 0 ? { line, column } : { line, column, name };
75
- HOLES.set(accessor, at);
76
- try {
77
- Object.defineProperty(accessor, HOLE_TAG, { value: at, configurable: true });
78
- } catch {
79
- }
80
- }
81
- shared.pending = null;
82
- return accessor;
83
- }
84
- var PROPS = /* @__PURE__ */ new WeakMap();
85
- function markProps(props, at) {
86
- if (props && typeof props === "object") PROPS.set(props, at);
87
- return props;
88
- }
89
- function installSourceMarker() {
90
- if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
91
- if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
92
- if (typeof host[CLASS_MARKER] !== "function") host[CLASS_MARKER] = markClassSource;
93
- if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
94
- if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
95
- }
96
-
97
- // src/format.ts
98
- var MAX_DEPTH = 3;
99
- var MAX_ENTRIES = 8;
100
- function domName(v) {
101
- if (typeof v?.nodeType !== "number" || typeof v.nodeName !== "string") return null;
102
- return v.tagName ? `<${v.tagName.toLowerCase()}>` : `#${v.nodeName.toLowerCase()}`;
103
- }
104
- function fnName(v) {
105
- return v.name ? `ƒ ${v.name}()` : "ƒ";
106
- }
107
- function className(v) {
108
- const name = v.constructor?.name;
109
- return name && name !== "Object" ? `${name} ` : "";
110
- }
111
- function primitive(v) {
112
- if (v === null) return "null";
113
- switch (typeof v) {
114
- case "undefined":
115
- return "undefined";
116
- case "string":
117
- return JSON.stringify(v);
118
- case "number":
119
- case "boolean":
120
- return String(v);
121
- case "bigint":
122
- return `${v}n`;
123
- case "symbol":
124
- return v.toString();
125
- case "function":
126
- return fnName(v);
127
- default:
128
- return null;
129
- }
130
- }
131
- function walk(value, depth, seen) {
132
- const simple = primitive(value);
133
- if (simple !== null) return simple;
134
- const object = value;
135
- if (seen.has(object)) return "[circular]";
136
- const dom = domName(object);
137
- if (dom) return dom;
138
- if (object instanceof Date) return Number.isNaN(object.getTime()) ? "Invalid Date" : object.toISOString();
139
- if (object instanceof RegExp) return String(object);
140
- if (object instanceof Error) return `${object.name}: ${object.message}`;
141
- if (object instanceof Promise) return "Promise";
142
- if (ArrayBuffer.isView(object)) {
143
- return `${className(object).trim()}(${object.length ?? ""})`;
144
- }
145
- if (depth >= MAX_DEPTH) return Array.isArray(object) ? "[…]" : "{…}";
146
- seen.add(object);
147
- try {
148
- if (Array.isArray(object)) {
149
- const shown2 = object.slice(0, MAX_ENTRIES).map((item) => walk(item, depth + 1, seen));
150
- if (object.length > MAX_ENTRIES) shown2.push("…");
151
- return `[${shown2.join(", ")}]`;
152
- }
153
- if (object instanceof Map) {
154
- const shown2 = [];
155
- for (const [k, v] of object) {
156
- if (shown2.length === MAX_ENTRIES) {
157
- shown2.push("…");
158
- break;
159
- }
160
- shown2.push(`${walk(k, depth + 1, seen)} => ${walk(v, depth + 1, seen)}`);
161
- }
162
- return `Map(${object.size}) {${shown2.join(", ")}}`;
163
- }
164
- if (object instanceof Set) {
165
- const shown2 = [];
166
- for (const item of object) {
167
- if (shown2.length === MAX_ENTRIES) {
168
- shown2.push("…");
169
- break;
170
- }
171
- shown2.push(walk(item, depth + 1, seen));
172
- }
173
- return `Set(${object.size}) {${shown2.join(", ")}}`;
174
- }
175
- const keys = Object.keys(object);
176
- const shown = keys.slice(0, MAX_ENTRIES).map((key) => {
177
- let read;
178
- try {
179
- const descriptor = Object.getOwnPropertyDescriptor(object, key);
180
- if (descriptor?.get) return `${key}: [getter]`;
181
- read = walk(object[key], depth + 1, seen);
182
- } catch {
183
- read = "[unreadable]";
184
- }
185
- return `${key}: ${read}`;
186
- });
187
- if (keys.length > MAX_ENTRIES) shown.push("…");
188
- return `${className(object)}{${shown.join(", ")}}`;
189
- } finally {
190
- seen.delete(object);
191
- }
192
- }
193
- function formatValue(value, limit = 240) {
194
- let text;
195
- try {
196
- text = walk(value, 0, /* @__PURE__ */ new Set());
197
- } catch {
198
- text = "[unreadable]";
199
- }
200
- return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
201
- }
202
- function shorten(text, limit = 18) {
203
- return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
204
- }
205
-
206
- // src/instrument.ts
207
- var $NODE = /* @__PURE__ */ Symbol.for("signal-node");
208
- var KIND_OF_BUILTIN = {
209
- Show: "control",
210
- For: "control",
211
- Index: "control",
212
- Switch: "control",
213
- Match: "control",
214
- Portal: "control",
215
- Dynamic: "control",
216
- ErrorBoundary: "control",
217
- Suspense: "control",
218
- SuspenseList: "control",
219
- Await: "control",
220
- Router: "router",
221
- Outlet: "router",
222
- Redirect: "router",
223
- Link: "router"
224
- };
225
- var CORE_STATE = { 0: "clean", 1: "check", 2: "dirty" };
226
- function nodeVersion(n) {
227
- return n.core && typeof n.core.version === "number" ? n.core.version : n.runs;
228
- }
229
- function nodeState(n) {
230
- return n.core && typeof n.core.state === "number" ? CORE_STATE[n.core.state] : void 0;
231
- }
232
- var fmt = (v) => formatValue(v);
233
- var short = (s, n = 18) => shorten(s, n);
234
- function createReactor() {
235
- installSourceMarker();
236
- const graph = /* @__PURE__ */ new Map();
237
- const runsAtLastSample = /* @__PURE__ */ new Map();
238
- const unnamed = /* @__PURE__ */ new Set();
239
- const consumerStack = [];
240
- let seq = 0;
241
- let dispose = () => {
242
- };
243
- let rootOwner = null;
244
- const claims = (node, value) => {
245
- for (const dep of node.deps) {
246
- const other = graph.get(dep);
247
- if (other?.read && other.read() === value) return false;
248
- }
249
- return true;
250
- };
251
- const forget = (id) => {
252
- const owner = getOwner() ?? rootOwner;
253
- if (owner) {
254
- runWithOwner(
255
- owner,
256
- () => onCleanup(() => {
257
- graph.delete(id);
258
- runsAtLastSample.delete(id);
259
- unnamed.delete(id);
260
- })
261
- );
262
- }
263
- };
264
- const recordRead = (sourceId) => {
265
- const c = consumerStack[consumerStack.length - 1];
266
- if (c != null) graph.get(c)?.deps.add(sourceId);
267
- };
268
- const recordWrite = (targetId) => {
269
- const c = consumerStack[consumerStack.length - 1];
270
- if (c != null && c !== targetId) graph.get(c)?.writes.add(targetId);
271
- };
272
- const base = (id, named, kind, fallback) => {
273
- const mark = takeReactiveSource();
274
- if (!named && !mark?.name) unnamed.add(id);
275
- return {
276
- id,
277
- label: named ?? mark?.name ?? fallback,
278
- kind,
279
- deps: /* @__PURE__ */ new Set(),
280
- writes: /* @__PURE__ */ new Set(),
281
- runs: 0,
282
- lastPulse: 0,
283
- ...mark?.location ? { source: mark.location } : {}
284
- };
285
- };
286
- const trackedCreateSignal = (value, options) => {
287
- const id = seq++;
288
- const [get, set] = createSignal(value, options);
289
- const node = base(id, options?.name, "state", `s${id}`);
290
- node.read = () => untrack(get);
291
- node.detail = formatValue(value);
292
- node.value = shorten(node.detail);
293
- node.core = get[$NODE] ?? null;
294
- graph.set(id, node);
295
- forget(id);
296
- const read = () => {
297
- recordRead(id);
298
- return get();
299
- };
300
- const write = (v) => {
301
- recordWrite(id);
302
- return set(typeof v === "function" ? v(untrack(get)) : v);
303
- };
304
- return [read, write];
305
- };
306
- const trackedCreateMemo = (fn, value, options) => {
307
- const id = seq++;
308
- const node = base(id, options?.name, "memo", `m${id}`);
309
- graph.set(id, node);
310
- forget(id);
311
- const m = createMemo(() => {
312
- node.core ??= Signal.subtle.currentComputed();
313
- node.deps.clear();
314
- node.writes.clear();
315
- node.runs++;
316
- consumerStack.push(id);
317
- try {
318
- return fn();
319
- } finally {
320
- consumerStack.pop();
321
- }
322
- }, value, options);
323
- node.read = () => untrack(m);
324
- return () => {
325
- recordRead(id);
326
- return m();
327
- };
328
- };
329
- const trackedCreateEffect = (fn, options) => {
330
- const id = seq++;
331
- const node = base(id, options?.name, "effect", `e${id}`);
332
- graph.set(id, node);
333
- forget(id);
334
- createEffect(() => {
335
- node.core ??= Signal.subtle.currentComputed();
336
- node.deps.clear();
337
- node.writes.clear();
338
- node.runs++;
339
- node.lastPulse = performance.now();
340
- consumerStack.push(id);
341
- try {
342
- fn();
343
- } finally {
344
- consumerStack.pop();
345
- }
346
- });
347
- };
348
- const trackedCreateStore = (initial, options) => {
349
- const id = seq++;
350
- const [proxy, setter] = createStore(initial, { immutable: true, ...options });
351
- const node = base(id, options?.name, "store", `store${id}`);
352
- node.read = () => {
353
- try {
354
- return untrack(() => JSON.stringify(proxy));
355
- } catch {
356
- return "{…}";
357
- }
358
- };
359
- node.value = "{…}";
360
- graph.set(id, node);
361
- forget(id);
362
- const recording = new Proxy(proxy, {
363
- get(t, p, r) {
364
- recordRead(id);
365
- return Reflect.get(t, p, r);
366
- }
367
- });
368
- const write = (...args) => {
369
- recordWrite(id);
370
- return setter(...args);
371
- };
372
- return [recording, write];
373
- };
374
- const trackedCreateResource = (...args) => {
375
- const id = seq++;
376
- const last = args[args.length - 1];
377
- const name = last && typeof last === "object" && !Array.isArray(last) && typeof last !== "function" ? last.name : void 0;
378
- const node = base(id, name, "resource", `res${id}`);
379
- const [data, actions] = createResource(...args);
380
- node.read = () => {
381
- try {
382
- return untrack(() => data.loading ? "⏳ loading" : JSON.stringify(data.latest));
383
- } catch {
384
- return "?";
385
- }
386
- };
387
- node.value = "⏳ loading";
388
- graph.set(id, node);
389
- forget(id);
390
- const accessor = (() => {
391
- recordRead(id);
392
- return data();
393
- });
394
- for (const k of ["loading", "error", "latest", "state"]) {
395
- Object.defineProperty(accessor, k, { get: () => data[k] });
396
- }
397
- return [accessor, actions];
398
- };
399
- const trackedSignal = (value, options) => {
400
- const [read, write] = trackedCreateSignal(value, options);
401
- Object.defineProperty(read, "set", { value: write });
402
- return read;
403
- };
404
- const trackedMemo = trackedCreateMemo;
405
- const trackedEffect = trackedCreateEffect;
406
- const trackedStore = (initial, options) => {
407
- const [state, set] = trackedCreateStore(initial, options);
408
- return new Proxy(state, {
409
- get: (target, key) => key === "set" ? set : target[key],
410
- has: (target, key) => key === "set" || Reflect.has(target, key)
411
- });
412
- };
413
- const trackedResource = (...args) => {
414
- const [accessor, controls] = trackedCreateResource(...args);
415
- return Object.assign(accessor, controls);
416
- };
417
- const api = {
418
- createSignal: trackedCreateSignal,
419
- createMemo: trackedCreateMemo,
420
- createEffect: trackedCreateEffect,
421
- createStore: trackedCreateStore,
422
- createResource: trackedCreateResource,
423
- signal: trackedSignal,
424
- memo: trackedMemo,
425
- store: trackedStore,
426
- effect: trackedEffect,
427
- resource: trackedResource
428
- };
429
- return {
430
- graph,
431
- run(setup) {
432
- dispose();
433
- graph.clear();
434
- runsAtLastSample.clear();
435
- unnamed.clear();
436
- seq = 0;
437
- consumerStack.length = 0;
438
- createRoot((d) => {
439
- dispose = d;
440
- rootOwner = getOwner();
441
- setup(api);
442
- });
443
- },
444
- sample() {
445
- const changed = [];
446
- const now = Date.now();
447
- for (const node of graph.values()) {
448
- if (!node.read) {
449
- const seen = runsAtLastSample.get(node.id);
450
- if (seen !== void 0 && node.runs > seen) {
451
- node.lastPulse = now;
452
- changed.push(node.id);
453
- }
454
- runsAtLastSample.set(node.id, node.runs);
455
- continue;
456
- }
457
- const raw = node.read();
458
- const stamped = raw?.$name;
459
- if (node.kind === "memo" && typeof stamped === "string" && stamped && claims(node, raw)) {
460
- node.kind = KIND_OF_BUILTIN[stamped] ?? "component";
461
- node.declaredAt = componentSource(stamped);
462
- node.source ??= node.declaredAt;
463
- if (unnamed.has(node.id)) {
464
- node.label = stamped;
465
- unnamed.delete(node.id);
466
- }
467
- }
468
- const detail = formatValue(raw);
469
- const next = shorten(detail);
470
- if (next !== node.value || detail !== node.detail) {
471
- node.detail = detail;
472
- node.value = next;
473
- node.runs++;
474
- node.lastPulse = now;
475
- changed.push(node.id);
476
- }
477
- runsAtLastSample.set(node.id, node.runs);
478
- }
479
- return changed;
480
- },
481
- dispose() {
482
- dispose();
483
- dispose = () => {
484
- };
485
- }
486
- };
487
- }
2
+ KIND_OF_BUILTIN,
3
+ createReactor,
4
+ fmt,
5
+ nodeState,
6
+ nodeVersion,
7
+ short
8
+ } from "./chunk-EBSROPWJ.mjs";
9
+ import "./chunk-L6XQGNMW.mjs";
10
+ import "./chunk-NT7YMK77.mjs";
488
11
  export {
489
12
  KIND_OF_BUILTIN,
490
13
  createReactor,
@@ -1,151 +1,9 @@
1
- // src/kind-filter.ts
2
- var FILTERABLE_KINDS = [
3
- "state",
4
- "memo",
5
- "effect",
6
- "store",
7
- "resource",
8
- "component",
9
- "provider",
10
- "control",
11
- "router",
12
- "handler",
13
- "context",
14
- "directive",
15
- "custom-element",
16
- "module",
17
- "service"
18
- ];
19
- var LABEL = { handler: "route", "custom-element": "custom element" };
20
- function createKindFilter(host, options) {
21
- const doc = host.ownerDocument;
22
- const kinds = options.kinds ?? FILTERABLE_KINDS;
23
- const on = new Set(kinds);
24
- const root = doc.createElement("div");
25
- root.className = "fx-kinds";
26
- const button = doc.createElement("button");
27
- button.type = "button";
28
- button.className = "fx-kinds-button fx-dropdown-btn";
29
- button.setAttribute("aria-haspopup", "true");
30
- button.setAttribute("aria-expanded", "false");
31
- button.title = "Choose which kinds of node the graph draws";
32
- const caret = doc.createElement("div");
33
- caret.className = "fx-dropdown-caret";
34
- const panel = doc.createElement("div");
35
- panel.className = "fx-kinds-panel";
36
- if (options.panelClass) {
37
- panel.classList.add(...options.panelClass.split(/\s+/).filter((c) => c));
38
- }
39
- panel.hidden = true;
40
- const all = doc.createElement("input");
41
- all.type = "checkbox";
42
- const allRow = doc.createElement("label");
43
- allRow.className = "fx-kinds-all";
44
- allRow.append(all, doc.createTextNode("all"));
45
- const boxes = /* @__PURE__ */ new Map();
46
- for (const kind of kinds) {
47
- const box = doc.createElement("input");
48
- box.type = "checkbox";
49
- box.checked = true;
50
- const row = doc.createElement("label");
51
- row.append(box, doc.createTextNode(LABEL[kind] ?? kind));
52
- panel.append(row);
53
- boxes.set(kind, box);
54
- }
55
- panel.prepend(allRow);
56
- root.append(button, panel);
57
- host.append(root);
58
- const everything = () => on.size === kinds.length;
59
- const chosen = () => kinds.filter((kind) => on.has(kind));
60
- function paint() {
61
- const name = options.label ?? "Kinds";
62
- button.textContent = everything() ? name : `${name} · ${on.size}`;
63
- button.classList.toggle("on", !everything());
64
- all.checked = everything();
65
- button.appendChild(caret);
66
- all.indeterminate = on.size > 0 && !everything();
67
- for (const [kind, box] of boxes) box.checked = on.has(kind);
68
- }
69
- function report() {
70
- options.onChange(everything() ? null : chosen());
71
- }
72
- for (const [kind, box] of boxes) {
73
- box.addEventListener("change", () => {
74
- if (box.checked) on.add(kind);
75
- else on.delete(kind);
76
- paint();
77
- report();
78
- });
79
- }
80
- all.addEventListener("change", () => {
81
- for (const kind of kinds) on.add(kind);
82
- paint();
83
- report();
84
- });
85
- const close = () => {
86
- panel.hidden = true;
87
- button.setAttribute("aria-expanded", "false");
88
- };
89
- button.addEventListener("click", (event) => {
90
- event.stopPropagation();
91
- panel.hidden = !panel.hidden;
92
- button.setAttribute("aria-expanded", String(!panel.hidden));
93
- });
94
- panel.addEventListener("click", (event) => event.stopPropagation());
95
- const away = () => close();
96
- const key = (event) => {
97
- if (event.key === "Escape") close();
98
- };
99
- doc.addEventListener("click", away);
100
- doc.addEventListener("keydown", key);
101
- paint();
102
- return {
103
- get selected() {
104
- return chosen();
105
- },
106
- select(next) {
107
- on.clear();
108
- for (const kind of next ?? kinds) on.add(kind);
109
- paint();
110
- },
111
- destroy() {
112
- doc.removeEventListener("click", away);
113
- doc.removeEventListener("keydown", key);
114
- root.remove();
115
- }
116
- };
117
- }
118
- var KIND_FILTER_CSS = `
119
- .fx-kinds { position: relative; display: inline-flex; }
120
- .fx-kinds-button { white-space: nowrap; }
121
- /* The hidden attribute is display:none from the user agent, which a class setting display outranks. */
122
- .fx-kinds-panel[hidden] { display: none; }
123
- .fx-kinds-panel {
124
- position: absolute; top: calc(100% + 4px); z-index: 40;
125
- display: grid; gap: 2px; padding: 6px 8px; min-width: 132px;
126
- background: var(--fx-panel, #14161c);
127
- border: 1px solid var(--fx-line, #262a35); border-radius: 6px;
128
- box-shadow: 0 6px 18px rgba(0, 0, 0, .38);
129
- }
130
- .fx-kinds-panel:not(.fx-panel-left){ right: 0; }
131
- .fx-kinds-panel.fx-panel-left { left: 0; }
132
- .fx-kinds-panel label {
133
- display: flex; align-items: center; gap: 6px;
134
- font-size: 11px; color: var(--fx-muted, #8a90a2); cursor: pointer; user-select: none;
135
- }
136
- .fx-kinds-panel label:hover { color: var(--fx-label, #e7e9ee); }
137
- .fx-kinds-panel input { width: 11px; height: 11px; margin: 0; accent-color: var(--fx-accent, #5eead4); }
138
- .fx-kinds-all {
139
- padding-bottom: 4px; margin-bottom: 2px;
140
- border-bottom: 1px solid var(--fx-line, #262a35);
141
- color: var(--fx-label, #e7e9ee) !important;
142
- }
143
- `;
144
- var DROPDOWN_FILTER_CSS = `
145
- .fx-dropdown-btn { background-color: transparent; appearance: none; border: 1px solid var(--line-strong); outline: none; border-radius: .25rem; padding-block: .25rem; padding-inline: .875rem; font-size: .75rem; cursor: pointer }
146
- .fx-dropdown-btn:hover { border-color: color-mix(in oklab, var(--accent) 50%, transparent); background-color: var(--bg); }
147
- .fx-dropdown-caret { width: 0;height: 0;border-left: .15rem solid transparent; border-right: .15rem solid transparent; border-top: .15rem solid currentColor; transition: transform 0.2s ease; right: .4rem; top: 50%; color: color-mix(in oklab, var(--muted) 50%, transparent); position: absolute; }
148
- `;
1
+ import {
2
+ DROPDOWN_FILTER_CSS,
3
+ FILTERABLE_KINDS,
4
+ KIND_FILTER_CSS,
5
+ createKindFilter
6
+ } from "./chunk-PSSBFXBD.mjs";
149
7
  export {
150
8
  DROPDOWN_FILTER_CSS,
151
9
  FILTERABLE_KINDS,