@vscode/component-explorer 0.1.1-9 → 0.2.1-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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/SECURITY.md +14 -0
  3. package/dist/components/Explorer.d.ts +4 -3
  4. package/dist/components/Explorer.d.ts.map +1 -1
  5. package/dist/components/ExplorerModel.d.ts +18 -2
  6. package/dist/components/ExplorerModel.d.ts.map +1 -1
  7. package/dist/components/FixturePreviewItem.d.ts +1 -0
  8. package/dist/components/FixturePreviewItem.d.ts.map +1 -1
  9. package/dist/components/LeftSidebar.d.ts.map +1 -1
  10. package/dist/components/PreviewArea.d.ts.map +1 -1
  11. package/dist/components/ReportComparisonRow.d.ts +16 -0
  12. package/dist/components/ReportComparisonRow.d.ts.map +1 -0
  13. package/dist/components/ScreenshotComparisonRow.d.ts.map +1 -1
  14. package/dist/components/SearchInput.d.ts +6 -0
  15. package/dist/components/SearchInput.d.ts.map +1 -0
  16. package/dist/components/TitleBar.d.ts.map +1 -1
  17. package/dist/components/TreeView.d.ts.map +1 -1
  18. package/dist/components/index.d.ts +3 -1
  19. package/dist/components/index.d.ts.map +1 -1
  20. package/dist/components/styles.d.ts +32 -32
  21. package/dist/components/treeFilter.d.ts +3 -0
  22. package/dist/components/treeFilter.d.ts.map +1 -0
  23. package/dist/components/types.d.ts +3 -1
  24. package/dist/components/types.d.ts.map +1 -1
  25. package/dist/core/ComponentRenderer.d.ts +17 -0
  26. package/dist/core/ComponentRenderer.d.ts.map +1 -0
  27. package/dist/core/ErrorInfo.d.ts +16 -0
  28. package/dist/core/ErrorInfo.d.ts.map +1 -0
  29. package/dist/core/FixtureNode.d.ts +16 -4
  30. package/dist/core/FixtureNode.d.ts.map +1 -1
  31. package/dist/core/FixturePath.d.ts +8 -0
  32. package/dist/core/FixturePath.d.ts.map +1 -0
  33. package/dist/core/FixtureRegistry.d.ts +3 -25
  34. package/dist/core/FixtureRegistry.d.ts.map +1 -1
  35. package/dist/core/fixtureApi.d.ts +329 -0
  36. package/dist/core/fixtureApi.d.ts.map +1 -0
  37. package/dist/core/fixtureApiConsumer.d.ts +84 -0
  38. package/dist/core/fixtureApiConsumer.d.ts.map +1 -0
  39. package/dist/core/index.d.ts +15 -9
  40. package/dist/core/index.d.ts.map +1 -1
  41. package/dist/daemon/DaemonConfig.d.ts +5 -11
  42. package/dist/daemon/DaemonConfig.d.ts.map +1 -1
  43. package/dist/daemon/DaemonModel.d.ts +7 -4
  44. package/dist/daemon/DaemonModel.d.ts.map +1 -1
  45. package/dist/daemon/index.d.ts +1 -2
  46. package/dist/daemon/index.d.ts.map +1 -1
  47. package/dist/index.d.ts +9 -33
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +10 -3687
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/explorerQueryParams.d.ts +4 -0
  52. package/dist/lib/explorerQueryParams.d.ts.map +1 -0
  53. package/dist/lib/explorerShadowHost.d.ts +3 -0
  54. package/dist/lib/explorerShadowHost.d.ts.map +1 -0
  55. package/dist/lib/fixtureFocusTrap.d.ts +2 -0
  56. package/dist/lib/fixtureFocusTrap.d.ts.map +1 -0
  57. package/dist/lib/fixtureSizeCache.d.ts +3 -0
  58. package/dist/lib/fixtureSizeCache.d.ts.map +1 -1
  59. package/dist/lib/queryParamObservable.d.ts +4 -0
  60. package/dist/lib/queryParamObservable.d.ts.map +1 -0
  61. package/dist/modes/EmbeddedMode.d.ts +15 -0
  62. package/dist/modes/EmbeddedMode.d.ts.map +1 -0
  63. package/dist/modes/ExplorerUIMode.d.ts +16 -0
  64. package/dist/modes/ExplorerUIMode.d.ts.map +1 -0
  65. package/dist/{core/CliRuntime.d.ts → modes/HeadlessMode.d.ts} +21 -25
  66. package/dist/modes/HeadlessMode.d.ts.map +1 -0
  67. package/dist/report/ReportModel.d.ts +23 -0
  68. package/dist/report/ReportModel.d.ts.map +1 -0
  69. package/dist/report/ScreenshotReport.d.ts +26 -0
  70. package/dist/report/ScreenshotReport.d.ts.map +1 -0
  71. package/dist/report/index.d.ts +3 -0
  72. package/dist/report/index.d.ts.map +1 -0
  73. package/dist/runtimeVersion-BeD9fm3Y.js +86 -0
  74. package/dist/runtimeVersion-BeD9fm3Y.js.map +1 -0
  75. package/dist/runtimeVersion.d.ts +3 -0
  76. package/dist/runtimeVersion.d.ts.map +1 -0
  77. package/dist/viewer.d.ts +34 -0
  78. package/dist/viewer.d.ts.map +1 -0
  79. package/dist/viewer.js +4098 -0
  80. package/dist/viewer.js.map +1 -0
  81. package/package.json +29 -9
  82. package/dist/core/CliRuntime.d.ts.map +0 -1
  83. package/dist/core/ComponentDefinition.d.ts +0 -70
  84. package/dist/core/ComponentDefinition.d.ts.map +0 -1
  85. package/dist/core/defineFixture.d.ts +0 -109
  86. package/dist/core/defineFixture.d.ts.map +0 -1
  87. package/dist/index.css +0 -1
package/dist/index.js CHANGED
@@ -1,3690 +1,13 @@
1
- var vt = Object.defineProperty;
2
- var bt = (s, e, t) => e in s ? vt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var l = (s, e, t) => bt(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { createRoot as yt } from "react-dom/client";
5
- import { createContext as Le, useReducer as Ct, useState as xt, useContext as wt, useEffect as Ie, createElement as St } from "react";
6
- import { jsx as a, jsxs as p, Fragment as be } from "react/jsx-runtime";
7
- import { unstable_batchedUpdates as $e } from "react-dom";
8
- const It = {
9
- mobile: { width: 390, height: 844 },
10
- tablet: { width: 768, height: 1024 },
11
- desktop: { width: 1440, height: 900 }
12
- };
13
- function Ot(s) {
14
- return typeof s == "string" ? { name: s, ...It[s] } : s;
15
- }
16
- function Tt(s) {
17
- const e = {};
18
- for (const t of s)
19
- e[t.name] = t.defaultValue;
20
- return e;
21
- }
22
- function ys(s) {
23
- return typeof s == "object" && s !== null && "render" in s && typeof s.render == "function" && "id" in s && "name" in s;
24
- }
25
- const Ue = Symbol("singleFixture"), je = Symbol("fixtureGroup"), Pe = Symbol("fixtureVariants");
26
- function Rt(s) {
27
- return typeof s == "object" && s !== null && Ue in s;
28
- }
29
- function Vt(s) {
30
- return typeof s == "object" && s !== null && je in s;
31
- }
32
- function Nt(s) {
33
- return typeof s == "object" && s !== null && Pe in s;
34
- }
35
- function kt(s, e, t) {
36
- return {
37
- id: e,
38
- name: t,
39
- description: s.description,
40
- isolation: s.isolation ?? "shadow-dom",
41
- displayMode: s.displayMode ?? { type: "component" },
42
- styles: s.styles,
43
- background: s.background ?? "light",
44
- properties: s.properties ?? [],
45
- render: s.render
46
- };
47
- }
48
- function ee(s) {
49
- return {
50
- [Ue]: !0,
51
- _options: s,
52
- _createDefinition: (e, t) => kt(s, e, t)
53
- };
54
- }
55
- function Cs(s) {
56
- return {
57
- [je]: !0,
58
- _entries: s
59
- };
60
- }
61
- function xs(s) {
62
- return {
63
- [Pe]: !0,
64
- _variants: s
65
- };
66
- }
67
- function ce(s) {
68
- const e = {
69
- id: "",
70
- name: "Components",
71
- type: "folder",
72
- children: []
73
- };
74
- for (const [t, n] of s) {
75
- const r = Dt(t);
76
- Ge(e, [r], n);
77
- }
78
- return e;
79
- }
80
- function Dt(s) {
81
- return (s.split("/").pop() ?? s).replace(/\.fixture\.(tsx?|jsx?)$/, "");
82
- }
83
- function Ge(s, e, t) {
84
- var n;
85
- if (Rt(t)) {
86
- const r = e.join("/"), i = e[e.length - 1], o = {
87
- id: r,
88
- name: i,
89
- type: "component",
90
- component: t._createDefinition(r, i)
91
- };
92
- s.children || (s.children = []), s.children.push(o);
93
- } else if (Vt(t)) {
94
- const r = e[e.length - 1], i = e.join("/");
95
- let o = (n = s.children) == null ? void 0 : n.find(
96
- (d) => d.type === "folder" && d.name === r
97
- );
98
- o || (o = {
99
- id: i,
100
- name: r,
101
- type: "folder",
102
- children: []
103
- }, s.children || (s.children = []), s.children.push(o));
104
- for (const [d, c] of Object.entries(t._entries))
105
- Ge(o, [...e, d], c);
106
- } else if (Nt(t)) {
107
- const r = e[e.length - 1], o = {
108
- id: e.join("/"),
109
- name: r,
110
- type: "variants",
111
- children: []
112
- };
113
- s.children || (s.children = []), s.children.push(o);
114
- for (const [d, c] of Object.entries(t._variants)) {
115
- const g = [...e, d].join("/"), _ = {
116
- id: g,
117
- name: d,
118
- type: "component",
119
- component: c._createDefinition(g, d)
120
- };
121
- o.children.push(_);
122
- }
123
- }
124
- }
125
- function Oe(s, e) {
126
- if (e.length === 0)
127
- return s;
128
- let t = s;
129
- for (const n of e) {
130
- if (!t || !t.children)
131
- return;
132
- t = t.children.find((r) => r.name === n);
133
- }
134
- return t;
135
- }
136
- function At(s) {
137
- if (s.type === "component" && s.component)
138
- return [s.component];
139
- const e = [];
140
- for (const t of s.children ?? [])
141
- e.push(...At(t));
142
- return e;
143
- }
144
- let L;
145
- function We(s) {
146
- L ? L instanceof Te ? L.loggers.push(s) : L = new Te([L, s]) : L = s;
147
- }
148
- function m() {
149
- return L;
150
- }
151
- let le;
152
- function Mt(s) {
153
- le = s;
154
- }
155
- function Ft(s) {
156
- le && le(s);
157
- }
158
- class Te {
159
- constructor(e) {
160
- this.loggers = e;
161
- }
162
- handleObservableCreated(e, t) {
163
- for (const n of this.loggers)
164
- n.handleObservableCreated(e, t);
165
- }
166
- handleOnListenerCountChanged(e, t) {
167
- for (const n of this.loggers)
168
- n.handleOnListenerCountChanged(e, t);
169
- }
170
- handleObservableUpdated(e, t) {
171
- for (const n of this.loggers)
172
- n.handleObservableUpdated(e, t);
173
- }
174
- handleAutorunCreated(e, t) {
175
- for (const n of this.loggers)
176
- n.handleAutorunCreated(e, t);
177
- }
178
- handleAutorunDisposed(e) {
179
- for (const t of this.loggers)
180
- t.handleAutorunDisposed(e);
181
- }
182
- handleAutorunDependencyChanged(e, t, n) {
183
- for (const r of this.loggers)
184
- r.handleAutorunDependencyChanged(e, t, n);
185
- }
186
- handleAutorunStarted(e) {
187
- for (const t of this.loggers)
188
- t.handleAutorunStarted(e);
189
- }
190
- handleAutorunFinished(e) {
191
- for (const t of this.loggers)
192
- t.handleAutorunFinished(e);
193
- }
194
- handleDerivedDependencyChanged(e, t, n) {
195
- for (const r of this.loggers)
196
- r.handleDerivedDependencyChanged(e, t, n);
197
- }
198
- handleDerivedCleared(e) {
199
- for (const t of this.loggers)
200
- t.handleDerivedCleared(e);
201
- }
202
- handleBeginTransaction(e) {
203
- for (const t of this.loggers)
204
- t.handleBeginTransaction(e);
205
- }
206
- handleEndTransaction(e) {
207
- for (const t of this.loggers)
208
- t.handleEndTransaction(e);
209
- }
210
- }
211
- var T;
212
- (function(s) {
213
- let e = !1;
214
- function t() {
215
- e = !0;
216
- }
217
- s.enable = t;
218
- function n() {
219
- return r(1);
220
- }
221
- s.ofCaller = n;
222
- function r(i) {
223
- if (!e)
224
- return;
225
- const o = Error, d = o.stackTraceLimit;
226
- o.stackTraceLimit = 3;
227
- const c = new Error().stack;
228
- return o.stackTraceLimit = d, ye.fromStack(c, i + 1);
229
- }
230
- s.ofNthCaller = r;
231
- })(T || (T = {}));
232
- class ye {
233
- static fromStack(e, t) {
234
- const n = e.split(`
235
- `), r = Bt(n[t + 1]);
236
- if (r)
237
- return new ye(r.fileName, r.line, r.column, r.id);
238
- }
239
- constructor(e, t, n, r) {
240
- this.fileName = e, this.line = t, this.column = n, this.id = r;
241
- }
242
- }
243
- function Bt(s) {
244
- if (!s)
245
- return;
246
- const e = s.match(/\((.*):(\d+):(\d+)\)/);
247
- if (e)
248
- return {
249
- fileName: e[1],
250
- line: parseInt(e[2]),
251
- column: parseInt(e[3]),
252
- id: s
253
- };
254
- const t = s.match(/at ([^\(\)]*):(\d+):(\d+)/);
255
- if (t)
256
- return {
257
- fileName: t[1],
258
- line: parseInt(t[2]),
259
- column: parseInt(t[3]),
260
- id: s
261
- };
262
- }
263
- class M {
264
- constructor(e, t, n) {
265
- this.owner = e, this.debugNameSource = t, this.referenceFn = n;
266
- }
267
- getDebugName(e) {
268
- return Et(e, this);
269
- }
270
- }
271
- const Re = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new WeakMap();
272
- function Et(s, e) {
273
- const t = he.get(s);
274
- if (t)
275
- return t;
276
- const n = zt(s, e);
277
- if (n) {
278
- let r = Re.get(n) ?? 0;
279
- r++, Re.set(n, r);
280
- const i = r === 1 ? n : `${n}#${r}`;
281
- return he.set(s, i), i;
282
- }
283
- }
284
- function zt(s, e) {
285
- const t = he.get(s);
286
- if (t)
287
- return t;
288
- const n = e.owner ? Lt(e.owner) + "." : "";
289
- let r;
290
- const i = e.debugNameSource;
291
- if (i !== void 0)
292
- if (typeof i == "function") {
293
- if (r = i(), r !== void 0)
294
- return n + r;
295
- } else
296
- return n + i;
297
- const o = e.referenceFn;
298
- if (o !== void 0 && (r = Ce(o), r !== void 0))
299
- return n + r;
300
- if (e.owner !== void 0) {
301
- const d = Ht(e.owner, s);
302
- if (d !== void 0)
303
- return n + d;
304
- }
305
- }
306
- function Ht(s, e) {
307
- for (const t in s)
308
- if (s[t] === e)
309
- return t;
310
- }
311
- const Ve = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new WeakMap();
312
- function Lt(s) {
313
- const e = Ne.get(s);
314
- if (e)
315
- return e;
316
- const t = qe(s) ?? "Object";
317
- let n = Ve.get(t) ?? 0;
318
- n++, Ve.set(t, n);
319
- const r = n === 1 ? t : `${t}#${n}`;
320
- return Ne.set(s, r), r;
321
- }
322
- function qe(s) {
323
- const e = s.constructor;
324
- if (e)
325
- return e.name === "Object" ? void 0 : e.name;
326
- }
327
- function Ce(s) {
328
- const e = s.toString(), n = /\/\*\*\s*@description\s*([^*]*)\*\//.exec(e), r = n ? n[1] : void 0;
329
- return r == null ? void 0 : r.trim();
330
- }
331
- let ue;
332
- function $t(s) {
333
- ue = s;
334
- }
335
- let Ke;
336
- function Ut(s) {
337
- Ke = s;
338
- }
339
- let Je;
340
- function jt(s) {
341
- Je = s;
342
- }
343
- let Ze;
344
- function Pt(s) {
345
- Ze = s;
346
- }
347
- class Gt {
348
- get TChange() {
349
- return null;
350
- }
351
- reportChanges() {
352
- this.get();
353
- }
354
- /** @sealed */
355
- read(e) {
356
- return e ? e.readObservable(this) : this.get();
357
- }
358
- map(e, t, n = T.ofCaller()) {
359
- const r = t === void 0 ? void 0 : e, i = t === void 0 ? e : t;
360
- return ue({
361
- owner: r,
362
- debugName: () => {
363
- const o = Ce(i);
364
- if (o !== void 0)
365
- return o;
366
- const c = /^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/.exec(i.toString());
367
- if (c)
368
- return `${this.debugName}.${c[2]}`;
369
- if (!r)
370
- return `${this.debugName} (mapped)`;
371
- },
372
- debugReferenceFn: i
373
- }, (o) => i(this.read(o), o), n);
374
- }
375
- /**
376
- * @sealed
377
- * Converts an observable of an observable value into a direct observable of the value.
378
- */
379
- flatten() {
380
- return ue({
381
- owner: void 0,
382
- debugName: () => `${this.debugName} (flattened)`
383
- }, (e) => this.read(e).read(e));
384
- }
385
- recomputeInitiallyAndOnChange(e, t) {
386
- return e.add(Ke(this, t)), this;
387
- }
388
- /**
389
- * Ensures that this observable is observed. This keeps the cache alive.
390
- * However, in case of deriveds, it does not force eager evaluation (only when the value is read/get).
391
- * Use `recomputeInitiallyAndOnChange` for eager evaluation.
392
- */
393
- keepObserved(e) {
394
- return e.add(Je(this)), this;
395
- }
396
- get debugValue() {
397
- return this.get();
398
- }
399
- debugGetDependencyGraph() {
400
- return Ze(this);
401
- }
402
- }
403
- class xe extends Gt {
404
- constructor(e) {
405
- var t;
406
- super(), this._observers = /* @__PURE__ */ new Set(), (t = m()) == null || t.handleObservableCreated(this, e);
407
- }
408
- addObserver(e) {
409
- var n;
410
- const t = this._observers.size;
411
- this._observers.add(e), t === 0 && this.onFirstObserverAdded(), t !== this._observers.size && ((n = m()) == null || n.handleOnListenerCountChanged(this, this._observers.size));
412
- }
413
- removeObserver(e) {
414
- var n;
415
- const t = this._observers.delete(e);
416
- t && this._observers.size === 0 && this.onLastObserverRemoved(), t && ((n = m()) == null || n.handleOnListenerCountChanged(this, this._observers.size));
417
- }
418
- onFirstObserverAdded() {
419
- }
420
- onLastObserverRemoved() {
421
- }
422
- log() {
423
- var t;
424
- const e = !!m();
425
- return Ft(this), e || (t = m()) == null || t.handleObservableCreated(this, T.ofCaller()), this;
426
- }
427
- debugGetObservers() {
428
- return this._observers;
429
- }
430
- }
431
- function Xe(s) {
432
- return {
433
- dispose: s
434
- };
435
- }
436
- class I extends Error {
437
- constructor(e) {
438
- super(e || "An unexpected bug occurred."), Object.setPrototypeOf(this, I.prototype);
439
- }
440
- }
441
- function ne(s) {
442
- throw s;
443
- }
444
- function fe(s) {
445
- console.error("Unexpected error:", s);
446
- }
447
- const Z = (s, e) => s === e;
448
- function Y(s) {
449
- return s != null;
450
- }
451
- class X {
452
- constructor() {
453
- this.disposables = [], this._isDisposed = !1;
454
- }
455
- get isDisposed() {
456
- return this._isDisposed;
457
- }
458
- dispose() {
459
- this.clear(), this._isDisposed = !0;
460
- }
461
- add(e) {
462
- return e && this.disposables.push(e), e;
463
- }
464
- remove(e) {
465
- if (!e)
466
- return e;
467
- const t = this.disposables.indexOf(e);
468
- return t !== -1 && this.disposables.splice(t, 1), e;
469
- }
470
- clear() {
471
- for (const e of this.disposables)
472
- e.dispose();
473
- this.disposables = [];
474
- }
475
- leakItems() {
476
- this.disposables = [];
477
- }
478
- }
479
- function Wt(s) {
480
- switch (s) {
481
- case 0:
482
- return "initial";
483
- case 1:
484
- return "dependenciesMightHaveChanged";
485
- case 2:
486
- return "stale";
487
- case 3:
488
- return "upToDate";
489
- default:
490
- return "<unknown>";
491
- }
492
- }
493
- class C extends xe {
494
- get debugName() {
495
- return this._debugNameData.getDebugName(this) ?? "(anonymous)";
496
- }
497
- constructor(e, t, n, r = void 0, i, o) {
498
- var d;
499
- super(o), this._debugNameData = e, this._computeFn = t, this._changeTracker = n, this._handleLastObserverRemoved = r, this._equalityComparator = i, this._state = 0, this._value = void 0, this._updateCount = 0, this._dependencies = /* @__PURE__ */ new Set(), this._dependenciesToBeRemoved = /* @__PURE__ */ new Set(), this._changeSummary = void 0, this._isUpdating = !1, this._isComputing = !1, this._didReportChange = !1, this._isInBeforeUpdate = !1, this._isReaderValid = !1, this._store = void 0, this._delayedStore = void 0, this._removedObserverToCallEndUpdateOn = null, this._changeSummary = (d = this._changeTracker) == null ? void 0 : d.createChangeSummary(void 0);
500
- }
501
- onLastObserverRemoved() {
502
- var e, t;
503
- this._state = 0, this._value = void 0, (e = m()) == null || e.handleDerivedCleared(this);
504
- for (const n of this._dependencies)
505
- n.removeObserver(this);
506
- this._dependencies.clear(), this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._delayedStore !== void 0 && (this._delayedStore.dispose(), this._delayedStore = void 0), (t = this._handleLastObserverRemoved) == null || t.call(this);
507
- }
508
- get() {
509
- var t, n;
510
- if (this._isComputing, this._observers.size === 0) {
511
- let r;
512
- try {
513
- this._isReaderValid = !0;
514
- let i;
515
- this._changeTracker && (i = this._changeTracker.createChangeSummary(void 0), (n = (t = this._changeTracker).beforeUpdate) == null || n.call(t, this, i)), r = this._computeFn(this, i);
516
- } finally {
517
- this._isReaderValid = !1;
518
- }
519
- return this.onLastObserverRemoved(), r;
520
- } else {
521
- do {
522
- if (this._state === 1) {
523
- for (const r of this._dependencies)
524
- if (r.reportChanges(), this._state === 2)
525
- break;
526
- }
527
- this._state === 1 && (this._state = 3), this._state !== 3 && this._recompute();
528
- } while (this._state !== 3);
529
- return this._value;
530
- }
531
- }
532
- _recompute() {
533
- var n, r, i, o;
534
- let e = !1;
535
- this._isComputing = !0, this._didReportChange = !1;
536
- const t = this._dependenciesToBeRemoved;
537
- this._dependenciesToBeRemoved = this._dependencies, this._dependencies = t;
538
- try {
539
- const d = this._changeSummary;
540
- this._isReaderValid = !0, this._changeTracker && (this._isInBeforeUpdate = !0, (r = (n = this._changeTracker).beforeUpdate) == null || r.call(n, this, d), this._isInBeforeUpdate = !1, this._changeSummary = (i = this._changeTracker) == null ? void 0 : i.createChangeSummary(d));
541
- const c = this._state !== 0, h = this._value;
542
- this._state = 3;
543
- const g = this._delayedStore;
544
- g !== void 0 && (this._delayedStore = void 0);
545
- try {
546
- this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._value = this._computeFn(this, d);
547
- } finally {
548
- this._isReaderValid = !1;
549
- for (const _ of this._dependenciesToBeRemoved)
550
- _.removeObserver(this);
551
- this._dependenciesToBeRemoved.clear(), g !== void 0 && g.dispose();
552
- }
553
- e = this._didReportChange || c && !this._equalityComparator(h, this._value), (o = m()) == null || o.handleObservableUpdated(this, {
554
- oldValue: h,
555
- newValue: this._value,
556
- change: void 0,
557
- didChange: e,
558
- hadValue: c
559
- });
560
- } catch (d) {
561
- ne(d);
562
- }
563
- if (this._isComputing = !1, !this._didReportChange && e)
564
- for (const d of this._observers)
565
- d.handleChange(this, void 0);
566
- else
567
- this._didReportChange = !1;
568
- }
569
- toString() {
570
- return `LazyDerived<${this.debugName}>`;
571
- }
572
- // IObserver Implementation
573
- beginUpdate(e) {
574
- if (this._isUpdating)
575
- throw new I("Cyclic deriveds are not supported yet!");
576
- this._updateCount++, this._isUpdating = !0;
577
- try {
578
- const t = this._updateCount === 1;
579
- if (this._state === 3 && (this._state = 1, !t))
580
- for (const n of this._observers)
581
- n.handlePossibleChange(this);
582
- if (t)
583
- for (const n of this._observers)
584
- n.beginUpdate(this);
585
- } finally {
586
- this._isUpdating = !1;
587
- }
588
- }
589
- endUpdate(e) {
590
- if (this._updateCount--, this._updateCount === 0) {
591
- const t = [...this._observers];
592
- for (const n of t)
593
- n.endUpdate(this);
594
- if (this._removedObserverToCallEndUpdateOn) {
595
- const n = [...this._removedObserverToCallEndUpdateOn];
596
- this._removedObserverToCallEndUpdateOn = null;
597
- for (const r of n)
598
- r.endUpdate(this);
599
- }
600
- }
601
- }
602
- handlePossibleChange(e) {
603
- if (this._state === 3 && this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e)) {
604
- this._state = 1;
605
- for (const t of this._observers)
606
- t.handlePossibleChange(this);
607
- }
608
- }
609
- handleChange(e, t) {
610
- var n;
611
- if (this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e) || this._isInBeforeUpdate) {
612
- (n = m()) == null || n.handleDerivedDependencyChanged(this, e, t);
613
- let r = !1;
614
- try {
615
- r = this._changeTracker ? this._changeTracker.handleChange({
616
- changedObservable: e,
617
- change: t,
618
- didChange: (o) => o === e
619
- }, this._changeSummary) : !0;
620
- } catch (o) {
621
- ne(o);
622
- }
623
- const i = this._state === 3;
624
- if (r && (this._state === 1 || i) && (this._state = 2, i))
625
- for (const o of this._observers)
626
- o.handlePossibleChange(this);
627
- }
628
- }
629
- // IReader Implementation
630
- _ensureReaderValid() {
631
- if (!this._isReaderValid)
632
- throw new I("The reader object cannot be used outside its compute function!");
633
- }
634
- readObservable(e) {
635
- this._ensureReaderValid(), e.addObserver(this);
636
- const t = e.get();
637
- return this._dependencies.add(e), this._dependenciesToBeRemoved.delete(e), t;
638
- }
639
- reportChange(e) {
640
- this._ensureReaderValid(), this._didReportChange = !0;
641
- for (const t of this._observers)
642
- t.handleChange(this, e);
643
- }
644
- get store() {
645
- return this._ensureReaderValid(), this._store === void 0 && (this._store = new X()), this._store;
646
- }
647
- get delayedStore() {
648
- return this._ensureReaderValid(), this._delayedStore === void 0 && (this._delayedStore = new X()), this._delayedStore;
649
- }
650
- addObserver(e) {
651
- const t = !this._observers.has(e) && this._updateCount > 0;
652
- super.addObserver(e), t && (this._removedObserverToCallEndUpdateOn && this._removedObserverToCallEndUpdateOn.has(e) ? this._removedObserverToCallEndUpdateOn.delete(e) : e.beginUpdate(this));
653
- }
654
- removeObserver(e) {
655
- this._observers.has(e) && this._updateCount > 0 && (this._removedObserverToCallEndUpdateOn || (this._removedObserverToCallEndUpdateOn = /* @__PURE__ */ new Set()), this._removedObserverToCallEndUpdateOn.add(e)), super.removeObserver(e);
656
- }
657
- debugGetState() {
658
- return {
659
- state: this._state,
660
- stateStr: Wt(this._state),
661
- updateCount: this._updateCount,
662
- isComputing: this._isComputing,
663
- dependencies: this._dependencies,
664
- value: this._value
665
- };
666
- }
667
- debugSetValue(e) {
668
- this._value = e;
669
- }
670
- debugRecompute() {
671
- this._isComputing ? this._state = 2 : this._recompute();
672
- }
673
- setValue(e, t, n) {
674
- this._value = e;
675
- const r = this._observers;
676
- t.updateObserver(this, this);
677
- for (const i of r)
678
- i.handleChange(this, n);
679
- }
680
- }
681
- function N(s, e, t = T.ofCaller()) {
682
- return e !== void 0 ? new C(new M(s, void 0, e), e, void 0, void 0, Z, t) : new C(new M(void 0, void 0, s), s, void 0, void 0, Z, t);
683
- }
684
- function qt(s, e, t = T.ofCaller()) {
685
- return new C(new M(s.owner, s.debugName, s.debugReferenceFn), e, void 0, s.onLastObserverRemoved, s.equalsFn ?? Z, t);
686
- }
687
- $t(qt);
688
- function Kt(s, e, t = T.ofCaller()) {
689
- let n, r;
690
- n = s, r = void 0;
691
- let i;
692
- return new C(new M(r, void 0, n), (o) => {
693
- i ? i.clear() : i = new X();
694
- const d = n(o);
695
- return d && i.add(d), d;
696
- }, void 0, () => {
697
- i && (i.dispose(), i = void 0);
698
- }, Z, t);
699
- }
700
- function Jt(s) {
701
- switch (s) {
702
- case 1:
703
- return "dependenciesMightHaveChanged";
704
- case 2:
705
- return "stale";
706
- case 3:
707
- return "upToDate";
708
- default:
709
- return "<unknown>";
710
- }
711
- }
712
- class se {
713
- get debugName() {
714
- return this._debugNameData.getDebugName(this) ?? "(anonymous)";
715
- }
716
- constructor(e, t, n, r) {
717
- var i, o;
718
- this._debugNameData = e, this._runFn = t, this._changeTracker = n, this._state = 2, this._updateCount = 0, this._disposed = !1, this._dependencies = /* @__PURE__ */ new Set(), this._dependenciesToBeRemoved = /* @__PURE__ */ new Set(), this._isRunning = !1, this._store = void 0, this._delayedStore = void 0, this._changeSummary = (i = this._changeTracker) == null ? void 0 : i.createChangeSummary(void 0), (o = m()) == null || o.handleAutorunCreated(this, r), this._run();
719
- }
720
- dispose() {
721
- var e;
722
- if (!this._disposed) {
723
- this._disposed = !0;
724
- for (const t of this._dependencies)
725
- t.removeObserver(this);
726
- this._dependencies.clear(), this._store !== void 0 && this._store.dispose(), this._delayedStore !== void 0 && this._delayedStore.dispose(), (e = m()) == null || e.handleAutorunDisposed(this);
727
- }
728
- }
729
- _run() {
730
- var t, n, r, i;
731
- const e = this._dependenciesToBeRemoved;
732
- this._dependenciesToBeRemoved = this._dependencies, this._dependencies = e, this._state = 3;
733
- try {
734
- if (!this._disposed) {
735
- (t = m()) == null || t.handleAutorunStarted(this);
736
- const o = this._changeSummary, d = this._delayedStore;
737
- d !== void 0 && (this._delayedStore = void 0);
738
- try {
739
- this._isRunning = !0, this._changeTracker && ((r = (n = this._changeTracker).beforeUpdate) == null || r.call(n, this, o), this._changeSummary = this._changeTracker.createChangeSummary(o)), this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._runFn(this, o);
740
- } catch (c) {
741
- ne(c);
742
- } finally {
743
- this._isRunning = !1, d !== void 0 && d.dispose();
744
- }
745
- }
746
- } finally {
747
- this._disposed || (i = m()) == null || i.handleAutorunFinished(this);
748
- for (const o of this._dependenciesToBeRemoved)
749
- o.removeObserver(this);
750
- this._dependenciesToBeRemoved.clear();
751
- }
752
- }
753
- toString() {
754
- return `Autorun<${this.debugName}>`;
755
- }
756
- // IObserver implementation
757
- beginUpdate(e) {
758
- this._state === 3 && (this._state = 1), this._updateCount++;
759
- }
760
- endUpdate(e) {
761
- try {
762
- if (this._updateCount === 1)
763
- do {
764
- if (this._state === 1) {
765
- this._state = 3;
766
- for (const t of this._dependencies)
767
- if (t.reportChanges(), this._state === 2)
768
- break;
769
- }
770
- this._state !== 3 && this._run();
771
- } while (this._state !== 3);
772
- } finally {
773
- this._updateCount--;
774
- }
775
- }
776
- handlePossibleChange(e) {
777
- this._state === 3 && this._isDependency(e) && (this._state = 1);
778
- }
779
- handleChange(e, t) {
780
- var n;
781
- if (this._isDependency(e)) {
782
- (n = m()) == null || n.handleAutorunDependencyChanged(this, e, t);
783
- try {
784
- (this._changeTracker ? this._changeTracker.handleChange({
785
- changedObservable: e,
786
- change: t,
787
- didChange: (i) => i === e
788
- }, this._changeSummary) : !0) && (this._state = 2);
789
- } catch (r) {
790
- ne(r);
791
- }
792
- }
793
- }
794
- _isDependency(e) {
795
- return this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e);
796
- }
797
- // IReader implementation
798
- _ensureNoRunning() {
799
- if (!this._isRunning)
800
- throw new I("The reader object cannot be used outside its compute function!");
801
- }
802
- readObservable(e) {
803
- if (this._ensureNoRunning(), this._disposed)
804
- return e.get();
805
- e.addObserver(this);
806
- const t = e.get();
807
- return this._dependencies.add(e), this._dependenciesToBeRemoved.delete(e), t;
808
- }
809
- get store() {
810
- if (this._ensureNoRunning(), this._disposed)
811
- throw new I("Cannot access store after dispose");
812
- return this._store === void 0 && (this._store = new X()), this._store;
813
- }
814
- get delayedStore() {
815
- if (this._ensureNoRunning(), this._disposed)
816
- throw new I("Cannot access store after dispose");
817
- return this._delayedStore === void 0 && (this._delayedStore = new X()), this._delayedStore;
818
- }
819
- debugGetState() {
820
- return {
821
- isRunning: this._isRunning,
822
- updateCount: this._updateCount,
823
- dependencies: this._dependencies,
824
- state: this._state,
825
- stateStr: Jt(this._state)
826
- };
827
- }
828
- debugRerun() {
829
- this._isRunning ? this._state = 2 : this._run();
830
- }
831
- }
832
- function Ye(s, e = T.ofCaller()) {
833
- return new se(new M(void 0, void 0, s), s, void 0, e);
834
- }
835
- function ke(s) {
836
- const e = new Error("BugIndicatingErrorRecovery: " + s);
837
- fe(e), console.error("recovered from an error that indicates a bug", e);
838
- }
839
- function Qe(s, e) {
840
- const t = new et(s, e);
841
- try {
842
- s(t);
843
- } finally {
844
- t.finish();
845
- }
846
- }
847
- function Zt(s, e, t) {
848
- s ? e(s) : Qe(e, t);
849
- }
850
- class et {
851
- constructor(e, t) {
852
- var n;
853
- this._fn = e, this._getDebugName = t, this._updatingObservers = [], (n = m()) == null || n.handleBeginTransaction(this);
854
- }
855
- getDebugName() {
856
- return this._getDebugName ? this._getDebugName() : Ce(this._fn);
857
- }
858
- updateObserver(e, t) {
859
- if (!this._updatingObservers) {
860
- ke("Transaction already finished!"), Qe((n) => {
861
- n.updateObserver(e, t);
862
- });
863
- return;
864
- }
865
- this._updatingObservers.push({ observer: e, observable: t }), e.beginUpdate(t);
866
- }
867
- finish() {
868
- var t;
869
- const e = this._updatingObservers;
870
- if (!e) {
871
- ke("transaction.finish() has already been called!");
872
- return;
873
- }
874
- for (let n = 0; n < e.length; n++) {
875
- const { observer: r, observable: i } = e[n];
876
- r.endUpdate(i);
877
- }
878
- this._updatingObservers = null, (t = m()) == null || t.handleEndTransaction(this);
879
- }
880
- debugGetUpdatingObservers() {
881
- return this._updatingObservers;
882
- }
883
- }
884
- function v(s, e, t = T.ofCaller()) {
885
- let n;
886
- return typeof s == "string" ? n = new M(void 0, s, void 0) : n = new M(s, void 0, void 0), new re(n, e, Z, t);
887
- }
888
- class re extends xe {
889
- get debugName() {
890
- return this._debugNameData.getDebugName(this) ?? "ObservableValue";
891
- }
892
- constructor(e, t, n, r) {
893
- var i;
894
- super(r), this._debugNameData = e, this._equalityComparator = n, this._value = t, (i = m()) == null || i.handleObservableUpdated(this, { hadValue: !1, newValue: t, change: void 0, didChange: !0, oldValue: void 0 });
895
- }
896
- get() {
897
- return this._value;
898
- }
899
- set(e, t, n) {
900
- var i;
901
- if (n === void 0 && this._equalityComparator(this._value, e))
902
- return;
903
- let r;
904
- t || (t = r = new et(() => {
905
- }, () => `Setting ${this.debugName}`));
906
- try {
907
- const o = this._value;
908
- this._setValue(e), (i = m()) == null || i.handleObservableUpdated(this, { oldValue: o, newValue: e, change: n, didChange: !0, hadValue: !0 });
909
- for (const d of this._observers)
910
- t.updateObserver(d, this), d.handleChange(this, n);
911
- } finally {
912
- r && r.finish();
913
- }
914
- }
915
- toString() {
916
- return `${this.debugName}: ${this._value}`;
917
- }
918
- _setValue(e) {
919
- this._value = e;
920
- }
921
- debugGetState() {
922
- return {
923
- value: this._value
924
- };
925
- }
926
- debugSetValue(e) {
927
- this._value = e;
928
- }
929
- }
930
- function De(...s) {
931
- let e, t, n, r;
932
- return s.length === 2 ? [t, n] = s : [e, t, n, r] = s, new A(new M(e, void 0, n), t, n, () => A.globalTransaction, Z, r ?? T.ofCaller());
933
- }
934
- class A extends xe {
935
- constructor(e, t, n, r, i, o) {
936
- super(o), this._debugNameData = e, this.event = t, this._getValue = n, this._getTransaction = r, this._equalityComparator = i, this._hasValue = !1, this.handleEvent = (d) => {
937
- var x;
938
- const c = this._getValue(d), h = this._value, g = !this._hasValue || !this._equalityComparator(h, c);
939
- let _ = !1;
940
- g && (this._value = c, this._hasValue && (_ = !0, Zt(this._getTransaction(), (w) => {
941
- var U;
942
- (U = m()) == null || U.handleObservableUpdated(this, { oldValue: h, newValue: c, change: void 0, didChange: g, hadValue: this._hasValue });
943
- for (const D of this._observers)
944
- w.updateObserver(D, this), D.handleChange(this, void 0);
945
- }, () => {
946
- const w = this.getDebugName();
947
- return "Event fired" + (w ? `: ${w}` : "");
948
- })), this._hasValue = !0), _ || (x = m()) == null || x.handleObservableUpdated(this, { oldValue: h, newValue: c, change: void 0, didChange: g, hadValue: this._hasValue });
949
- };
950
- }
951
- getDebugName() {
952
- return this._debugNameData.getDebugName(this);
953
- }
954
- get debugName() {
955
- const e = this.getDebugName();
956
- return "From Event" + (e ? `: ${e}` : "");
957
- }
958
- onFirstObserverAdded() {
959
- this._subscription = this.event(this.handleEvent);
960
- }
961
- onLastObserverRemoved() {
962
- this._subscription.dispose(), this._subscription = void 0, this._hasValue = !1, this._value = void 0;
963
- }
964
- get() {
965
- return this._subscription ? (this._hasValue || this.handleEvent(void 0), this._value) : this._getValue(void 0);
966
- }
967
- debugSetValue(e) {
968
- this._value = e;
969
- }
970
- debugGetState() {
971
- return { value: this._value, hasValue: this._hasValue };
972
- }
973
- }
974
- (function(s) {
975
- s.Observer = A;
976
- function e(t, n) {
977
- let r = !1;
978
- A.globalTransaction === void 0 && (A.globalTransaction = t, r = !0);
979
- try {
980
- n();
981
- } finally {
982
- r && (A.globalTransaction = void 0);
983
- }
984
- }
985
- s.batchEventsGlobally = e;
986
- })(De || (De = {}));
987
- function Xt(s) {
988
- const e = new tt(!1, void 0);
989
- return s.addObserver(e), Xe(() => {
990
- s.removeObserver(e);
991
- });
992
- }
993
- jt(Xt);
994
- function Yt(s, e) {
995
- const t = new tt(!0, e);
996
- s.addObserver(t);
997
- try {
998
- t.beginUpdate(s);
999
- } finally {
1000
- t.endUpdate(s);
1001
- }
1002
- return Xe(() => {
1003
- s.removeObserver(t);
1004
- });
1005
- }
1006
- Ut(Yt);
1007
- class tt {
1008
- constructor(e, t) {
1009
- this._forceRecompute = e, this._handleValue = t, this._counter = 0;
1010
- }
1011
- beginUpdate(e) {
1012
- this._counter++;
1013
- }
1014
- endUpdate(e) {
1015
- this._counter === 1 && this._forceRecompute && (this._handleValue ? this._handleValue(e.get()) : e.reportChanges()), this._counter--;
1016
- }
1017
- handlePossibleChange(e) {
1018
- }
1019
- handleChange(e, t) {
1020
- }
1021
- }
1022
- let te;
1023
- function Qt(s) {
1024
- te || (te = new en(), We(te)), te.addFilteredObj(s);
1025
- }
1026
- class en {
1027
- constructor() {
1028
- this.indentation = 0, this.changedObservablesSets = /* @__PURE__ */ new WeakMap();
1029
- }
1030
- addFilteredObj(e) {
1031
- this._filteredObjects || (this._filteredObjects = /* @__PURE__ */ new Set()), this._filteredObjects.add(e);
1032
- }
1033
- _isIncluded(e) {
1034
- var t;
1035
- return ((t = this._filteredObjects) == null ? void 0 : t.has(e)) ?? !0;
1036
- }
1037
- textToConsoleArgs(e) {
1038
- return tn([
1039
- j(rn("| ", this.indentation)),
1040
- e
1041
- ]);
1042
- }
1043
- formatInfo(e) {
1044
- return e.hadValue ? e.didChange ? [
1045
- j(" "),
1046
- S(V(e.oldValue, 70), {
1047
- color: "red",
1048
- strikeThrough: !0
1049
- }),
1050
- j(" "),
1051
- S(V(e.newValue, 60), {
1052
- color: "green"
1053
- })
1054
- ] : [j(" (unchanged)")] : [
1055
- j(" "),
1056
- S(V(e.newValue, 60), {
1057
- color: "green"
1058
- }),
1059
- j(" (initial)")
1060
- ];
1061
- }
1062
- handleObservableCreated(e) {
1063
- if (e instanceof C) {
1064
- const t = e;
1065
- this.changedObservablesSets.set(t, /* @__PURE__ */ new Set());
1066
- }
1067
- }
1068
- handleOnListenerCountChanged(e, t) {
1069
- }
1070
- handleObservableUpdated(e, t) {
1071
- if (this._isIncluded(e)) {
1072
- if (e instanceof C) {
1073
- this._handleDerivedRecomputed(e, t);
1074
- return;
1075
- }
1076
- console.log(...this.textToConsoleArgs([
1077
- P("observable value changed"),
1078
- S(e.debugName, { color: "BlueViolet" }),
1079
- ...this.formatInfo(t)
1080
- ]));
1081
- }
1082
- }
1083
- formatChanges(e) {
1084
- if (e.size !== 0)
1085
- return S(" (changed deps: " + [...e].map((t) => t.debugName).join(", ") + ")", { color: "gray" });
1086
- }
1087
- handleDerivedDependencyChanged(e, t, n) {
1088
- var r;
1089
- this._isIncluded(e) && ((r = this.changedObservablesSets.get(e)) == null || r.add(t));
1090
- }
1091
- _handleDerivedRecomputed(e, t) {
1092
- if (!this._isIncluded(e))
1093
- return;
1094
- const n = this.changedObservablesSets.get(e);
1095
- n && (console.log(...this.textToConsoleArgs([
1096
- P("derived recomputed"),
1097
- S(e.debugName, { color: "BlueViolet" }),
1098
- ...this.formatInfo(t),
1099
- this.formatChanges(n),
1100
- { data: [{ fn: e._debugNameData.referenceFn ?? e._computeFn }] }
1101
- ])), n.clear());
1102
- }
1103
- handleDerivedCleared(e) {
1104
- this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1105
- P("derived cleared"),
1106
- S(e.debugName, { color: "BlueViolet" })
1107
- ]));
1108
- }
1109
- handleFromEventObservableTriggered(e, t) {
1110
- this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1111
- P("observable from event triggered"),
1112
- S(e.debugName, { color: "BlueViolet" }),
1113
- ...this.formatInfo(t),
1114
- { data: [{ fn: e._getValue }] }
1115
- ]));
1116
- }
1117
- handleAutorunCreated(e) {
1118
- this._isIncluded(e) && this.changedObservablesSets.set(e, /* @__PURE__ */ new Set());
1119
- }
1120
- handleAutorunDisposed(e) {
1121
- }
1122
- handleAutorunDependencyChanged(e, t, n) {
1123
- this._isIncluded(e) && this.changedObservablesSets.get(e).add(t);
1124
- }
1125
- handleAutorunStarted(e) {
1126
- const t = this.changedObservablesSets.get(e);
1127
- t && (this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1128
- P("autorun"),
1129
- S(e.debugName, { color: "BlueViolet" }),
1130
- this.formatChanges(t),
1131
- { data: [{ fn: e._debugNameData.referenceFn ?? e._runFn }] }
1132
- ])), t.clear(), this.indentation++);
1133
- }
1134
- handleAutorunFinished(e) {
1135
- this.indentation--;
1136
- }
1137
- handleBeginTransaction(e) {
1138
- let t = e.getDebugName();
1139
- t === void 0 && (t = ""), this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1140
- P("transaction"),
1141
- S(t, { color: "BlueViolet" }),
1142
- { data: [{ fn: e._fn }] }
1143
- ])), this.indentation++;
1144
- }
1145
- handleEndTransaction() {
1146
- this.indentation--;
1147
- }
1148
- }
1149
- function tn(s) {
1150
- const e = new Array(), t = [];
1151
- let n = "";
1152
- function r(o) {
1153
- if ("length" in o)
1154
- for (const d of o)
1155
- d && r(d);
1156
- else "text" in o ? (n += `%c${o.text}`, e.push(o.style), o.data && t.push(...o.data)) : "data" in o && t.push(...o.data);
1157
- }
1158
- r(s);
1159
- const i = [n, ...e];
1160
- return i.push(...t), i;
1161
- }
1162
- function j(s) {
1163
- return S(s, { color: "black" });
1164
- }
1165
- function P(s) {
1166
- return S(on(`${s}: `, 10), { color: "black", bold: !0 });
1167
- }
1168
- function S(s, e = {
1169
- color: "black"
1170
- }) {
1171
- function t(r) {
1172
- return Object.entries(r).reduce((i, [o, d]) => `${i}${o}:${d};`, "");
1173
- }
1174
- const n = {
1175
- color: e.color
1176
- };
1177
- return e.strikeThrough && (n["text-decoration"] = "line-through"), e.bold && (n["font-weight"] = "bold"), {
1178
- text: s,
1179
- style: t(n)
1180
- };
1181
- }
1182
- function V(s, e) {
1183
- switch (typeof s) {
1184
- case "number":
1185
- return "" + s;
1186
- case "string":
1187
- return s.length + 2 <= e ? `"${s}"` : `"${s.substr(0, e - 7)}"+...`;
1188
- case "boolean":
1189
- return s ? "true" : "false";
1190
- case "undefined":
1191
- return "undefined";
1192
- case "object":
1193
- return s === null ? "null" : Array.isArray(s) ? nn(s, e) : sn(s, e);
1194
- case "symbol":
1195
- return s.toString();
1196
- case "function":
1197
- return `[[Function${s.name ? " " + s.name : ""}]]`;
1198
- default:
1199
- return "" + s;
1200
- }
1201
- }
1202
- function nn(s, e) {
1203
- let t = "[ ", n = !0;
1204
- for (const r of s) {
1205
- if (n || (t += ", "), t.length - 5 > e) {
1206
- t += "...";
1207
- break;
1208
- }
1209
- n = !1, t += `${V(r, e - t.length)}`;
1210
- }
1211
- return t += " ]", t;
1212
- }
1213
- function sn(s, e) {
1214
- if (typeof s.toString == "function" && s.toString !== Object.prototype.toString) {
1215
- const i = s.toString();
1216
- return i.length <= e ? i : i.substring(0, e - 3) + "...";
1217
- }
1218
- const t = qe(s);
1219
- let n = t ? t + "(" : "{ ", r = !0;
1220
- for (const [i, o] of Object.entries(s)) {
1221
- if (r || (n += ", "), n.length - 5 > e) {
1222
- n += "...";
1223
- break;
1224
- }
1225
- r = !1, n += `${i}: ${V(o, e - n.length)}`;
1226
- }
1227
- return n += t ? ")" : " }", n;
1228
- }
1229
- function rn(s, e) {
1230
- let t = "";
1231
- for (let n = 1; n <= e; n++)
1232
- t += s;
1233
- return t;
1234
- }
1235
- function on(s, e) {
1236
- for (; s.length < e; )
1237
- s += " ";
1238
- return s;
1239
- }
1240
- class ie {
1241
- static createHost(e, t) {
1242
- return new ie(e, t);
1243
- }
1244
- static createClient(e, t) {
1245
- return new ie(e, t);
1246
- }
1247
- constructor(e, t) {
1248
- this._channelFactory = e, this._getHandler = t, this._channel = this._channelFactory({
1249
- handleNotification: (i) => {
1250
- const o = i, d = this._getHandler().notifications[o[0]];
1251
- if (!d)
1252
- throw new Error(`Unknown notification "${o[0]}"!`);
1253
- d(...o[1]);
1254
- },
1255
- handleRequest: (i) => {
1256
- const o = i;
1257
- try {
1258
- return { type: "result", value: this._getHandler().requests[o[0]](...o[1]) };
1259
- } catch (d) {
1260
- return { type: "error", value: d };
1261
- }
1262
- }
1263
- });
1264
- const n = new Proxy({}, {
1265
- get: (i, o) => async (...d) => {
1266
- const c = await this._channel.sendRequest([o, d]);
1267
- if (c.type === "error")
1268
- throw c.value;
1269
- return c.value;
1270
- }
1271
- }), r = new Proxy({}, {
1272
- get: (i, o) => (...d) => {
1273
- this._channel.sendNotification([o, d]);
1274
- }
1275
- });
1276
- this.api = { notifications: r, requests: n };
1277
- }
1278
- }
1279
- function an(s, e) {
1280
- const t = globalThis;
1281
- let n = [], r;
1282
- const { channel: i, handler: o } = dn({
1283
- sendNotification: (c) => {
1284
- r ? r.sendNotification(c) : n.push(c);
1285
- }
1286
- });
1287
- let d;
1288
- return (t.$$debugValueEditor_debugChannels ?? (t.$$debugValueEditor_debugChannels = {}))[s] = (c) => {
1289
- d = e(), r = c;
1290
- for (const h of n)
1291
- c.sendNotification(h);
1292
- return n = [], o;
1293
- }, ie.createClient(i, () => {
1294
- if (!d)
1295
- throw new Error("Not supported");
1296
- return d;
1297
- });
1298
- }
1299
- function dn(s) {
1300
- let e;
1301
- return {
1302
- channel: (n) => (e = n, {
1303
- sendNotification: (r) => {
1304
- s.sendNotification(r);
1305
- },
1306
- sendRequest: (r) => {
1307
- throw new Error("not supported");
1308
- }
1309
- }),
1310
- handler: {
1311
- handleRequest: (n) => n.type === "notification" ? e == null ? void 0 : e.handleNotification(n.data) : e == null ? void 0 : e.handleRequest(n.data)
1312
- }
1313
- };
1314
- }
1315
- class cn {
1316
- constructor() {
1317
- this._timeout = void 0;
1318
- }
1319
- throttle(e, t) {
1320
- this._timeout === void 0 && (this._timeout = setTimeout(() => {
1321
- this._timeout = void 0, e();
1322
- }, t));
1323
- }
1324
- dispose() {
1325
- this._timeout !== void 0 && clearTimeout(this._timeout);
1326
- }
1327
- }
1328
- function nt(s, e) {
1329
- for (const t in e)
1330
- s[t] && typeof s[t] == "object" && e[t] && typeof e[t] == "object" ? nt(s[t], e[t]) : s[t] = e[t];
1331
- }
1332
- function st(s, e) {
1333
- for (const t in e)
1334
- e[t] === null ? delete s[t] : s[t] && typeof s[t] == "object" && e[t] && typeof e[t] == "object" ? st(s[t], e[t]) : s[t] = e[t];
1335
- }
1336
- class $ {
1337
- static getInstance() {
1338
- return $._instance === void 0 && ($._instance = new $()), $._instance;
1339
- }
1340
- getTransactionState() {
1341
- const e = [], t = [...this._activeTransactions];
1342
- if (t.length === 0)
1343
- return;
1344
- const n = t.flatMap((i) => i.debugGetUpdatingObservers() ?? []).map((i) => i.observer), r = /* @__PURE__ */ new Set();
1345
- for (; n.length > 0; ) {
1346
- const i = n.shift();
1347
- if (r.has(i))
1348
- continue;
1349
- r.add(i);
1350
- const o = this._getInfo(i, (d) => {
1351
- r.has(d) || n.push(d);
1352
- });
1353
- o && e.push(o);
1354
- }
1355
- return { names: t.map((i) => i.getDebugName() ?? "tx"), affected: e };
1356
- }
1357
- _getObservableInfo(e) {
1358
- const t = this._instanceInfos.get(e);
1359
- if (!t) {
1360
- fe(new I("No info found"));
1361
- return;
1362
- }
1363
- return t;
1364
- }
1365
- _getAutorunInfo(e) {
1366
- const t = this._instanceInfos.get(e);
1367
- if (!t) {
1368
- fe(new I("No info found"));
1369
- return;
1370
- }
1371
- return t;
1372
- }
1373
- _getInfo(e, t) {
1374
- if (e instanceof C) {
1375
- const n = [...e.debugGetObservers()];
1376
- for (const c of n)
1377
- t(c);
1378
- const r = this._getObservableInfo(e);
1379
- if (!r)
1380
- return;
1381
- const i = e.debugGetState(), o = { name: e.debugName, instanceId: r.instanceId, updateCount: i.updateCount }, d = [...r.changedObservables].map((c) => {
1382
- var h;
1383
- return (h = this._instanceInfos.get(c)) == null ? void 0 : h.instanceId;
1384
- }).filter(Y);
1385
- if (i.isComputing)
1386
- return { ...o, type: "observable/derived", state: "updating", changedDependencies: d, initialComputation: !1 };
1387
- switch (i.state) {
1388
- case 0:
1389
- return { ...o, type: "observable/derived", state: "noValue" };
1390
- case 3:
1391
- return { ...o, type: "observable/derived", state: "upToDate" };
1392
- case 2:
1393
- return { ...o, type: "observable/derived", state: "stale", changedDependencies: d };
1394
- case 1:
1395
- return { ...o, type: "observable/derived", state: "possiblyStale" };
1396
- }
1397
- } else if (e instanceof se) {
1398
- const n = this._getAutorunInfo(e);
1399
- if (!n)
1400
- return;
1401
- const r = { name: e.debugName, instanceId: n.instanceId, updateCount: n.updateCount }, i = [...n.changedObservables].map((o) => this._instanceInfos.get(o).instanceId);
1402
- if (e.debugGetState().isRunning)
1403
- return { ...r, type: "autorun", state: "updating", changedDependencies: i };
1404
- switch (e.debugGetState().state) {
1405
- case 3:
1406
- return { ...r, type: "autorun", state: "upToDate" };
1407
- case 2:
1408
- return { ...r, type: "autorun", state: "stale", changedDependencies: i };
1409
- case 1:
1410
- return { ...r, type: "autorun", state: "possiblyStale" };
1411
- }
1412
- }
1413
- }
1414
- _formatObservable(e) {
1415
- const t = this._getObservableInfo(e);
1416
- if (t)
1417
- return { name: e.debugName, instanceId: t.instanceId };
1418
- }
1419
- _formatObserver(e) {
1420
- var n;
1421
- if (e instanceof C)
1422
- return { name: e.toString(), instanceId: (n = this._getObservableInfo(e)) == null ? void 0 : n.instanceId };
1423
- const t = this._getAutorunInfo(e);
1424
- if (t)
1425
- return { name: e.toString(), instanceId: t.instanceId };
1426
- }
1427
- constructor() {
1428
- this._declarationId = 0, this._instanceId = 0, this._declarations = /* @__PURE__ */ new Map(), this._instanceInfos = /* @__PURE__ */ new WeakMap(), this._aliveInstances = /* @__PURE__ */ new Map(), this._activeTransactions = /* @__PURE__ */ new Set(), this._channel = an("observableDevTools", () => ({
1429
- notifications: {
1430
- setDeclarationIdFilter: (e) => {
1431
- },
1432
- logObservableValue: (e) => {
1433
- console.log("logObservableValue", e);
1434
- },
1435
- flushUpdates: () => {
1436
- this._flushUpdates();
1437
- },
1438
- resetUpdates: () => {
1439
- this._pendingChanges = null, this._channel.api.notifications.handleChange(this._fullState, !0);
1440
- }
1441
- },
1442
- requests: {
1443
- getDeclarations: () => {
1444
- const e = {};
1445
- for (const t of this._declarations.values())
1446
- e[t.id] = t;
1447
- return { decls: e };
1448
- },
1449
- getSummarizedInstances: () => null,
1450
- getObservableValueInfo: (e) => ({
1451
- observers: [...this._aliveInstances.get(e).debugGetObservers()].map((n) => this._formatObserver(n)).filter(Y)
1452
- }),
1453
- getDerivedInfo: (e) => {
1454
- const t = this._aliveInstances.get(e);
1455
- return {
1456
- dependencies: [...t.debugGetState().dependencies].map((n) => this._formatObservable(n)).filter(Y),
1457
- observers: [...t.debugGetObservers()].map((n) => this._formatObserver(n)).filter(Y)
1458
- };
1459
- },
1460
- getAutorunInfo: (e) => ({
1461
- dependencies: [...this._aliveInstances.get(e).debugGetState().dependencies].map((n) => this._formatObservable(n)).filter(Y)
1462
- }),
1463
- getTransactionState: () => this.getTransactionState(),
1464
- setValue: (e, t) => {
1465
- const n = this._aliveInstances.get(e);
1466
- if (n instanceof C)
1467
- n.debugSetValue(t);
1468
- else if (n instanceof re)
1469
- n.debugSetValue(t);
1470
- else if (n instanceof A)
1471
- n.debugSetValue(t);
1472
- else
1473
- throw new I("Observable is not supported");
1474
- const r = [...n.debugGetObservers()];
1475
- for (const i of r)
1476
- i.beginUpdate(n);
1477
- for (const i of r)
1478
- i.handleChange(n, void 0);
1479
- for (const i of r)
1480
- i.endUpdate(n);
1481
- },
1482
- getValue: (e) => {
1483
- const t = this._aliveInstances.get(e);
1484
- if (t instanceof C)
1485
- return V(t.debugGetState().value, 200);
1486
- if (t instanceof re)
1487
- return V(t.debugGetState().value, 200);
1488
- },
1489
- logValue: (e) => {
1490
- const t = this._aliveInstances.get(e);
1491
- if (t && "get" in t)
1492
- console.log("Logged Value:", t.get());
1493
- else
1494
- throw new I("Observable is not supported");
1495
- },
1496
- rerun: (e) => {
1497
- const t = this._aliveInstances.get(e);
1498
- if (t instanceof C)
1499
- t.debugRecompute();
1500
- else if (t instanceof se)
1501
- t.debugRerun();
1502
- else
1503
- throw new I("Observable is not supported");
1504
- }
1505
- }
1506
- })), this._pendingChanges = null, this._changeThrottler = new cn(), this._fullState = {}, this._flushUpdates = () => {
1507
- this._pendingChanges !== null && (this._channel.api.notifications.handleChange(this._pendingChanges, !1), this._pendingChanges = null);
1508
- }, T.enable();
1509
- }
1510
- _handleChange(e) {
1511
- st(this._fullState, e), this._pendingChanges === null ? this._pendingChanges = e : nt(this._pendingChanges, e), this._changeThrottler.throttle(this._flushUpdates, 10);
1512
- }
1513
- _getDeclarationId(e, t) {
1514
- if (!t)
1515
- return -1;
1516
- let n = this._declarations.get(t.id);
1517
- return n === void 0 && (n = {
1518
- id: this._declarationId++,
1519
- type: e,
1520
- url: t.fileName,
1521
- line: t.line,
1522
- column: t.column
1523
- }, this._declarations.set(t.id, n), this._handleChange({ decls: { [n.id]: n } })), n.id;
1524
- }
1525
- handleObservableCreated(e, t) {
1526
- const r = {
1527
- declarationId: this._getDeclarationId("observable/value", t),
1528
- instanceId: this._instanceId++,
1529
- listenerCount: 0,
1530
- lastValue: void 0,
1531
- updateCount: 0,
1532
- changedObservables: /* @__PURE__ */ new Set()
1533
- };
1534
- this._instanceInfos.set(e, r);
1535
- }
1536
- handleOnListenerCountChanged(e, t) {
1537
- const n = this._getObservableInfo(e);
1538
- if (n) {
1539
- if (n.listenerCount === 0 && t > 0) {
1540
- const r = e instanceof C ? "observable/derived" : "observable/value";
1541
- this._aliveInstances.set(n.instanceId, e), this._handleChange({
1542
- instances: {
1543
- [n.instanceId]: {
1544
- instanceId: n.instanceId,
1545
- declarationId: n.declarationId,
1546
- formattedValue: n.lastValue,
1547
- type: r,
1548
- name: e.debugName
1549
- }
1550
- }
1551
- });
1552
- } else n.listenerCount > 0 && t === 0 && (this._handleChange({
1553
- instances: { [n.instanceId]: null }
1554
- }), this._aliveInstances.delete(n.instanceId));
1555
- n.listenerCount = t;
1556
- }
1557
- }
1558
- handleObservableUpdated(e, t) {
1559
- if (e instanceof C) {
1560
- this._handleDerivedRecomputed(e, t);
1561
- return;
1562
- }
1563
- const n = this._getObservableInfo(e);
1564
- n && t.didChange && (n.lastValue = V(t.newValue, 30), n.listenerCount > 0 && this._handleChange({
1565
- instances: { [n.instanceId]: { formattedValue: n.lastValue } }
1566
- }));
1567
- }
1568
- handleAutorunCreated(e, t) {
1569
- const r = {
1570
- declarationId: this._getDeclarationId("autorun", t),
1571
- instanceId: this._instanceId++,
1572
- updateCount: 0,
1573
- changedObservables: /* @__PURE__ */ new Set()
1574
- };
1575
- this._instanceInfos.set(e, r), this._aliveInstances.set(r.instanceId, e), r && this._handleChange({
1576
- instances: {
1577
- [r.instanceId]: {
1578
- instanceId: r.instanceId,
1579
- declarationId: r.declarationId,
1580
- runCount: 0,
1581
- type: "autorun",
1582
- name: e.debugName
1583
- }
1584
- }
1585
- });
1586
- }
1587
- handleAutorunDisposed(e) {
1588
- const t = this._getAutorunInfo(e);
1589
- t && (this._handleChange({
1590
- instances: { [t.instanceId]: null }
1591
- }), this._instanceInfos.delete(e), this._aliveInstances.delete(t.instanceId));
1592
- }
1593
- handleAutorunDependencyChanged(e, t, n) {
1594
- const r = this._getAutorunInfo(e);
1595
- r && r.changedObservables.add(t);
1596
- }
1597
- handleAutorunStarted(e) {
1598
- }
1599
- handleAutorunFinished(e) {
1600
- const t = this._getAutorunInfo(e);
1601
- t && (t.changedObservables.clear(), t.updateCount++, this._handleChange({
1602
- instances: { [t.instanceId]: { runCount: t.updateCount } }
1603
- }));
1604
- }
1605
- handleDerivedDependencyChanged(e, t, n) {
1606
- const r = this._getObservableInfo(e);
1607
- r && r.changedObservables.add(t);
1608
- }
1609
- _handleDerivedRecomputed(e, t) {
1610
- const n = this._getObservableInfo(e);
1611
- if (!n)
1612
- return;
1613
- const r = V(t.newValue, 30);
1614
- n.updateCount++, n.changedObservables.clear(), n.lastValue = r, n.listenerCount > 0 && this._handleChange({
1615
- instances: { [n.instanceId]: { formattedValue: r, recomputationCount: n.updateCount } }
1616
- });
1617
- }
1618
- handleDerivedCleared(e) {
1619
- const t = this._getObservableInfo(e);
1620
- t && (t.lastValue = void 0, t.changedObservables.clear(), t.listenerCount > 0 && this._handleChange({
1621
- instances: {
1622
- [t.instanceId]: {
1623
- formattedValue: void 0
1624
- }
1625
- }
1626
- }));
1627
- }
1628
- handleBeginTransaction(e) {
1629
- this._activeTransactions.add(e);
1630
- }
1631
- handleEndTransaction(e) {
1632
- this._activeTransactions.delete(e);
1633
- }
1634
- }
1635
- $._instance = void 0;
1636
- function ln(s, e) {
1637
- const t = (e == null ? void 0 : e.debugNamePostProcessor) ?? ((i) => i), n = O.from(s, t);
1638
- return n ? rt(n, 0, /* @__PURE__ */ new Set()).trim() : "";
1639
- }
1640
- function rt(s, e, t) {
1641
- const n = " ".repeat(e), r = [];
1642
- if (t.has(s.sourceObj))
1643
- return r.push(`${n}* ${s.type} ${s.name} (already listed)`), r.join(`
1644
- `);
1645
- if (t.add(s.sourceObj), r.push(`${n}* ${s.type} ${s.name}:`), r.push(`${n} value: ${V(s.value, 50)}`), r.push(`${n} state: ${s.state}`), s.dependencies.length > 0) {
1646
- r.push(`${n} dependencies:`);
1647
- for (const o of s.dependencies)
1648
- r.push(rt(o, e + 1, t));
1649
- }
1650
- return r.join(`
1651
- `);
1652
- }
1653
- class O {
1654
- static from(e, t) {
1655
- if (e instanceof se) {
1656
- const n = e.debugGetState();
1657
- return new O(e, t(e.debugName), "autorun", void 0, n.stateStr, Array.from(n.dependencies).map((r) => O.from(r, t) || O.unknown(r)));
1658
- } else if (e instanceof C) {
1659
- const n = e.debugGetState();
1660
- return new O(e, t(e.debugName), "derived", n.value, n.stateStr, Array.from(n.dependencies).map((r) => O.from(r, t) || O.unknown(r)));
1661
- } else if (e instanceof re) {
1662
- const n = e.debugGetState();
1663
- return new O(e, t(e.debugName), "observableValue", n.value, "upToDate", []);
1664
- } else if (e instanceof A) {
1665
- const n = e.debugGetState();
1666
- return new O(e, t(e.debugName), "fromEvent", n.value, n.hasValue ? "upToDate" : "initial", []);
1667
- }
1668
- }
1669
- static unknown(e) {
1670
- return new O(e, "(unknown)", "unknown", void 0, "unknown", []);
1671
- }
1672
- constructor(e, t, n, r, i, o) {
1673
- this.sourceObj = e, this.name = t, this.type = n, this.value = r, this.state = i, this.dependencies = o;
1674
- }
1675
- }
1676
- Pt(ln);
1677
- Mt(Qt);
1678
- We($.getInstance());
1679
- class it {
1680
- constructor() {
1681
- l(this, "_fixtures", v(this, /* @__PURE__ */ new Map()));
1682
- /** Observable root of the fixture tree */
1683
- l(this, "root", N(this, (e) => {
1684
- const t = this._fixtures.read(e);
1685
- return ce(t);
1686
- }));
1687
- }
1688
- /**
1689
- * Registers a fixture file.
1690
- * @param path The file path (e.g., 'components/Button.fixture.tsx')
1691
- * @param fixtureExport The exported fixture object
1692
- */
1693
- register(e, t) {
1694
- const n = new Map(this._fixtures.get());
1695
- n.set(e, t), this._fixtures.set(n, void 0);
1696
- }
1697
- /**
1698
- * Unregisters a fixture file.
1699
- * @param path The file path to remove
1700
- */
1701
- unregister(e) {
1702
- const t = new Map(this._fixtures.get());
1703
- t.delete(e) && this._fixtures.set(t, void 0);
1704
- }
1705
- /**
1706
- * Clears all registered fixtures.
1707
- */
1708
- clear() {
1709
- this._fixtures.set(/* @__PURE__ */ new Map(), void 0);
1710
- }
1711
- /**
1712
- * Gets a node by path.
1713
- */
1714
- getNode(e, t) {
1715
- const n = this.root.read(e);
1716
- return Oe(n, t);
1717
- }
1718
- /**
1719
- * Gets a component by path (non-reactive, for use in preview iframe).
1720
- * @param path Array of path segments (e.g., ['Button', 'Primary'])
1721
- */
1722
- getComponentByPath(e) {
1723
- const t = this._fixtures.get(), n = ce(t), r = Oe(n, e);
1724
- return r == null ? void 0 : r.component;
1725
- }
1726
- }
1727
- class ws {
1728
- constructor(e, t) {
1729
- l(this, "sessionId", Math.random().toString(36).slice(2));
1730
- l(this, "_updateVersion", 0);
1731
- l(this, "_root");
1732
- l(this, "_fixtureModules");
1733
- l(this, "_currentDisposable");
1734
- l(this, "_currentContainer");
1735
- this._containerElement = e, this._fixtureModules = t, this._root = this._buildRegistry(), this._installGlobalApi();
1736
- const n = this._flattenFixtures(this._root).length;
1737
- console.log("[cli] CLI entry initialized, sessionId:", this.sessionId, "version:", this._updateVersion, "fixtures:", n);
1738
- }
1739
- get updateVersion() {
1740
- return this._updateVersion;
1741
- }
1742
- updateFixtures(e) {
1743
- this._fixtureModules = e, this._root = this._buildRegistry(), this._updateVersion++;
1744
- const t = this._flattenFixtures(this._root).length;
1745
- console.log("[cli] Registry rebuilt, version:", this._updateVersion, "fixtures:", t);
1746
- }
1747
- bumpVersion() {
1748
- this._updateVersion++, console.log("[cli] Version bumped:", this._updateVersion);
1749
- }
1750
- listFixtures() {
1751
- return this._flattenFixtures(this._root);
1752
- }
1753
- async renderFixture(e) {
1754
- const t = this._findFixtureNode(this._root, e);
1755
- if (!t || !t.component)
1756
- throw new Error("Fixture not found: " + e);
1757
- this._currentDisposable && (this._currentDisposable.dispose(), this._currentDisposable = void 0), this._currentContainer && (this._currentContainer.remove(), this._currentContainer = void 0);
1758
- const n = document.createElement("div");
1759
- n.style.display = "inline-block", this._containerElement.appendChild(n), this._currentContainer = n;
1760
- const r = t.component, i = Tt(r.properties);
1761
- let o = n;
1762
- if (r.isolation === "shadow-dom") {
1763
- const c = n.attachShadow({ mode: "open" });
1764
- o = document.createElement("div"), c.appendChild(o);
1765
- }
1766
- const d = r.render(o, i);
1767
- this._currentDisposable = d && typeof d == "object" && "dispose" in d ? d : void 0, await new Promise((c) => requestAnimationFrame(() => requestAnimationFrame(() => c())));
1768
- }
1769
- _buildRegistry() {
1770
- const e = /* @__PURE__ */ new Map();
1771
- for (const [t, n] of Object.entries(this._fixtureModules)) {
1772
- const r = n.default;
1773
- r && typeof r == "object" && e.set(t, r);
1774
- }
1775
- return ce(e);
1776
- }
1777
- _flattenFixtures(e, t = []) {
1778
- const n = [];
1779
- e.type === "component" && n.push({ fixtureId: e.id, fixtureName: e.name, groupPath: t });
1780
- for (const r of e.children ?? []) {
1781
- const i = e.id ? [...t, e.name] : t;
1782
- n.push(...this._flattenFixtures(r, i));
1783
- }
1784
- return n;
1785
- }
1786
- _findFixtureNode(e, t) {
1787
- if (e.id === t) return e;
1788
- for (const n of e.children ?? []) {
1789
- const r = this._findFixtureNode(n, t);
1790
- if (r) return r;
1791
- }
1792
- }
1793
- _installGlobalApi() {
1794
- window.__componentExplorerCli__ = {
1795
- sessionId: this.sessionId,
1796
- get updateVersion() {
1797
- return 0;
1798
- },
1799
- listFixtures: () => this.listFixtures(),
1800
- renderFixture: (e) => this.renderFixture(e)
1801
- }, Object.defineProperty(window.__componentExplorerCli__, "updateVersion", {
1802
- get: () => this._updateVersion
1803
- });
1804
- }
1805
- }
1806
- class hn {
1807
- constructor(e) {
1808
- this._run = e, this._changes = [], this._map = /* @__PURE__ */ new Map(), this._updateCounter = 0;
1809
- }
1810
- addDependency(e, t) {
1811
- return this._map.set(e, t), e.addObserver(this), {
1812
- dispose: () => {
1813
- this._map.delete(e), e.removeObserver(this);
1814
- }
1815
- };
1816
- }
1817
- beginUpdate(e) {
1818
- this._updateCounter++, this._changes.push(this._map.get(e));
1819
- }
1820
- endUpdate(e) {
1821
- if (this._updateCounter--, this._updateCounter === 0 && this._changes.length > 0) {
1822
- const t = this._changes;
1823
- this._changes = [], this._run(t);
1824
- }
1825
- }
1826
- handlePossibleChange(e) {
1827
- this._changes.push(this._map.get(e));
1828
- }
1829
- handleChange(e, t) {
1830
- }
1831
- }
1832
- function f() {
1833
- return pe.instance;
1834
- }
1835
- function un() {
1836
- return ge.instance;
1837
- }
1838
- function fn() {
1839
- return me.instance;
1840
- }
1841
- f.const = un;
1842
- f.obs = fn;
1843
- class pe {
1844
- create(e) {
1845
- const t = N((n) => e(n));
1846
- return { read: (n) => t };
1847
- }
1848
- }
1849
- pe.instance = new pe();
1850
- class ge {
1851
- create(e) {
1852
- const t = N((n) => e(n));
1853
- return { read: (n) => t.read(n) };
1854
- }
1855
- }
1856
- ge.instance = new ge();
1857
- class me {
1858
- create(e) {
1859
- const t = N((n) => {
1860
- const r = e(n);
1861
- return pn(r) ? r.read(n) : r;
1862
- });
1863
- return { read: (n) => t };
1864
- }
1865
- }
1866
- me.instance = new me();
1867
- function pn(s) {
1868
- return typeof s == "object" && s !== null && "read" in s;
1869
- }
1870
- function q(s, e) {
1871
- return Object.fromEntries(Object.entries(s).map(([t, n]) => [t, e(n, t)]));
1872
- }
1873
- const ae = Symbol("ViewModelContext");
1874
- class gn {
1875
- constructor(e) {
1876
- this._store = new X(), this.props = e;
1877
- }
1878
- dispose() {
1879
- this._store.dispose();
1880
- }
1881
- }
1882
- function mn(s) {
1883
- return s[ae] || (s[ae] = Le(void 0)), s[ae];
1884
- }
1885
- function F(s = {}) {
1886
- var e;
1887
- return e = class extends gn {
1888
- }, e._props = s, e;
1889
- }
1890
- let _e = 0;
1891
- const _n = new hn((s) => {
1892
- for (const e of s)
1893
- e.rendered = !1;
1894
- if (_e > 0) {
1895
- const e = s.find((t) => t.isRendering);
1896
- e.itemsToRender = s;
1897
- } else
1898
- $e(() => {
1899
- for (const e of s)
1900
- e.rendered || e.forceUpdate();
1901
- });
1902
- });
1903
- let vn = 0;
1904
- class bn {
1905
- constructor(e, t) {
1906
- this.debugName = e, this.renderFactory = t, this._obsProps = void 0, this.forceUpdate = void 0, this._render = void 0, this._disposable = void 0, this.contextValues = /* @__PURE__ */ new Map(), this.cleanupEffect = () => () => {
1907
- var n;
1908
- (n = this._disposable) == null || n.dispose();
1909
- }, this.itemsToRender = [], this.handleAfterRender = () => {
1910
- $e(() => {
1911
- for (const n of this.itemsToRender)
1912
- n.rendered || n.forceUpdate();
1913
- }), this.itemsToRender = [];
1914
- }, this.rendering = void 0, this.isRendering = !1, this.rendered = !1;
1915
- }
1916
- toString() {
1917
- return this.debugName;
1918
- }
1919
- updateProps(e) {
1920
- this._obsProps ? this._obsProps.set(e, void 0) : (this._obsProps = v(this, e), this._render = this.renderFactory(this._obsProps, () => this.contextValues), this.rendering = N(this, this._render), this._disposable = _n.addDependency(this.rendering, this));
1921
- }
1922
- }
1923
- function we(s, e, t) {
1924
- const n = (o) => o + 1, r = () => new bn(s + ++vn, e), i = function(o) {
1925
- const d = Ct(n, 0)[1], c = xt(r)[0];
1926
- for (const h of t ?? [])
1927
- c.contextValues.set(h, wt(h));
1928
- if (Ie(c.cleanupEffect, []), Ie(c.handleAfterRender), c.isRendering)
1929
- throw new Error("Component is already rendering");
1930
- c.isRendering = !0, _e++;
1931
- try {
1932
- c.forceUpdate = d, c.updateProps(o);
1933
- const h = c.rendering.get();
1934
- return c.rendered = !0, h;
1935
- } finally {
1936
- c.isRendering = !1, _e--;
1937
- }
1938
- };
1939
- return i.displayName = s, i;
1940
- }
1941
- we("ObsView", (s) => (e) => s.read(e).children(e));
1942
- function k(s, e) {
1943
- return we("view", (t) => {
1944
- const n = q(s, (r, i) => r.create((o) => t.read(o)[i], void 0));
1945
- return (r) => {
1946
- const i = q(n, (o) => o.read(r));
1947
- return e(r, i);
1948
- };
1949
- });
1950
- }
1951
- function yn(s) {
1952
- const e = [];
1953
- for (const t of Object.values(s)) {
1954
- const n = t._requiredContext;
1955
- n && !e.includes(n) && e.push(n);
1956
- }
1957
- return e;
1958
- }
1959
- function B(s, e, t) {
1960
- const n = typeof e == "function" ? {} : e, r = typeof e == "function" ? e : t, i = "_props" in s ? s._props : {}, o = yn({ ...i, ...n }), d = mn(s), c = [...o, d];
1961
- return we("viewWithModel", (h, g) => {
1962
- const _ = g(), x = _.get(d), w = "_props" in s ? q(s._props, (y, E) => y.create((z) => h.read(z)[E], _.get(y._requiredContext))) : {}, U = x ? { read: () => x, dispose: () => {
1963
- } } : Kt((y) => {
1964
- const E = q(w, (z) => z.read(y));
1965
- return new s(E);
1966
- }), D = q(n, (y, E) => y.create((z) => h.read(z)[E], _.get(y._requiredContext)));
1967
- return (y) => {
1968
- const E = U.read(y), z = q(D, (_t) => _t.read(y));
1969
- return r(y, E, z);
1970
- };
1971
- }, c.length > 0 ? c : void 0);
1972
- }
1973
- k({ value: f.obs() }, (s, e) => e.value.read(s));
1974
- Le(null);
1975
- function ot(s) {
1976
- var e;
1977
- return {
1978
- id: s.id,
1979
- name: s.name,
1980
- type: s.type,
1981
- children: (e = s.children) == null ? void 0 : e.map(ot),
1982
- component: s.component
1983
- };
1984
- }
1985
- function Q(s, e) {
1986
- const {
1987
- storageKey: t,
1988
- defaultValue: n,
1989
- serialize: r = JSON.stringify,
1990
- deserialize: i = JSON.parse
1991
- } = e;
1992
- let o = n;
1993
- try {
1994
- const h = localStorage.getItem(t);
1995
- h !== null && (o = i(h));
1996
- } catch {
1997
- }
1998
- const d = v(s, o), c = d.set.bind(d);
1999
- return d.set = (h, g) => {
2000
- try {
2001
- localStorage.setItem(t, r(h));
2002
- } catch {
2003
- }
2004
- c(h, g);
2005
- }, d;
2006
- }
2007
- class Cn extends F({
2008
- registry: f.const(),
2009
- daemonModel: f.const()
2010
- }) {
2011
- constructor() {
2012
- super(...arguments);
2013
- l(this, "leftSidebarVisible", Q(this, {
2014
- storageKey: "component-explorer:leftSidebarVisible",
2015
- defaultValue: !0
2016
- }));
2017
- l(this, "rightSidebarVisible", Q(this, {
2018
- storageKey: "component-explorer:rightSidebarVisible",
2019
- defaultValue: !0
2020
- }));
2021
- l(this, "isDarkTheme", Q(this, {
2022
- storageKey: "component-explorer:isDarkTheme",
2023
- defaultValue: !0
2024
- }));
2025
- l(this, "selectedNodeId", Q(this, {
2026
- storageKey: "component-explorer:selectedNodeId",
2027
- defaultValue: void 0
2028
- }));
2029
- l(this, "expandedNodeIds", v(this, /* @__PURE__ */ new Set()));
2030
- l(this, "viewMode", Q(this, {
2031
- storageKey: "component-explorer:viewMode",
2032
- defaultValue: "session"
2033
- }));
2034
- /** The explorer's tree derived from the registry */
2035
- l(this, "tree", N(this, (t) => {
2036
- const n = this.props.registry.root.read(t);
2037
- return ot(n);
2038
- }));
2039
- l(this, "selectedNode", N(this, (t) => {
2040
- const n = this.selectedNodeId.read(t);
2041
- if (!n) return;
2042
- const r = this.tree.read(t);
2043
- return this._findNode(r.children ?? [], n);
2044
- }));
2045
- /** List of preview rows to render based on current selection and view mode */
2046
- l(this, "selectedFixtures", N(this, (t) => {
2047
- const n = this.selectedNode.read(t);
2048
- return n ? this.viewMode.read(t) === "diff" && this.daemonAvailable ? this._collectDiffRows(n, n.name) : this._collectPreviewRows(n, n.name) : [];
2049
- }));
2050
- l(this, "setViewMode", (t) => {
2051
- this.viewMode.set(t, void 0);
2052
- });
2053
- l(this, "navigateToSession", (t) => {
2054
- const n = this.props.daemonModel;
2055
- if (!n) return;
2056
- const r = n.getSessionExplorerUrl(t);
2057
- r && (window.location.href = r);
2058
- });
2059
- l(this, "toggleLeftSidebar", () => {
2060
- this.leftSidebarVisible.set(!this.leftSidebarVisible.get(), void 0);
2061
- });
2062
- l(this, "toggleRightSidebar", () => {
2063
- this.rightSidebarVisible.set(!this.rightSidebarVisible.get(), void 0);
2064
- });
2065
- l(this, "toggleTheme", () => {
2066
- this.isDarkTheme.set(!this.isDarkTheme.get(), void 0);
2067
- });
2068
- l(this, "selectNode", (t) => {
2069
- this.selectedNodeId.set(t, void 0);
2070
- });
2071
- l(this, "toggleNodeExpanded", (t) => {
2072
- const n = this.expandedNodeIds.get(), r = new Set(n);
2073
- r.has(t) ? r.delete(t) : r.add(t), this.expandedNodeIds.set(r, void 0);
2074
- });
2075
- }
2076
- get daemonAvailable() {
2077
- return this.props.daemonModel !== void 0;
2078
- }
2079
- get daemon() {
2080
- return this.props.daemonModel;
2081
- }
2082
- isNodeExpanded(t, n) {
2083
- return this.expandedNodeIds.read(n).has(t);
2084
- }
2085
- _findNode(t, n) {
2086
- for (const r of t) {
2087
- if (r.id === n) return r;
2088
- if (r.children) {
2089
- const i = this._findNode(r.children, n);
2090
- if (i) return i;
2091
- }
2092
- }
2093
- }
2094
- _collectPreviewRows(t, n) {
2095
- if (t.type === "component" && t.component)
2096
- return [{
2097
- type: "single",
2098
- fixture: {
2099
- id: t.id,
2100
- name: t.name,
2101
- path: n,
2102
- component: t.component
2103
- }
2104
- }];
2105
- if (t.type === "variants") {
2106
- const i = [];
2107
- for (const o of t.children ?? [])
2108
- o.type === "component" && o.component && i.push({
2109
- id: o.id,
2110
- name: o.name,
2111
- path: `${n} / ${o.name}`,
2112
- component: o.component
2113
- });
2114
- return i.length > 0 ? [{
2115
- type: "variants",
2116
- id: t.id,
2117
- name: t.name,
2118
- path: n,
2119
- fixtures: i
2120
- }] : [];
2121
- }
2122
- const r = [];
2123
- for (const i of t.children ?? []) {
2124
- const o = n ? `${n} / ${i.name}` : i.name;
2125
- r.push(...this._collectPreviewRows(i, o));
2126
- }
2127
- return r;
2128
- }
2129
- /**
2130
- * In diff mode: fixtures become screenshot comparison items showing current vs baseline.
2131
- * Variants become comparison groups.
2132
- */
2133
- _collectDiffRows(t, n) {
2134
- if (t.type === "component")
2135
- return [{
2136
- type: "screenshot-comparison",
2137
- id: t.id,
2138
- name: t.name,
2139
- path: n,
2140
- items: [{
2141
- fixtureId: t.id,
2142
- name: t.name,
2143
- path: n
2144
- }]
2145
- }];
2146
- if (t.type === "variants") {
2147
- const i = [];
2148
- for (const o of t.children ?? [])
2149
- o.type === "component" && i.push({
2150
- fixtureId: o.id,
2151
- name: o.name,
2152
- path: `${n} / ${o.name}`
2153
- });
2154
- return i.length > 0 ? [{
2155
- type: "screenshot-comparison",
2156
- id: t.id,
2157
- name: t.name,
2158
- path: n,
2159
- items: i
2160
- }] : [];
2161
- }
2162
- const r = [];
2163
- for (const i of t.children ?? []) {
2164
- const o = n ? `${n} / ${i.name}` : i.name;
2165
- r.push(...this._collectDiffRows(i, o));
2166
- }
2167
- return r;
2168
- }
2169
- }
2170
- const u = {
2171
- container: {
2172
- display: "flex",
2173
- flexDirection: "row",
2174
- height: "100%",
2175
- width: "100%",
2176
- fontFamily: "var(--vscode-font-family)",
2177
- fontSize: "var(--vscode-font-size)",
2178
- color: "var(--vscode-foreground)",
2179
- backgroundColor: "var(--vscode-editor-background)"
2180
- },
2181
- centerArea: {
2182
- display: "flex",
2183
- flexDirection: "column",
2184
- flex: 1,
2185
- overflow: "hidden"
2186
- },
2187
- titleBar: {
2188
- display: "flex",
2189
- alignItems: "center",
2190
- justifyContent: "space-between",
2191
- height: "35px",
2192
- minHeight: "35px",
2193
- padding: "0 10px",
2194
- backgroundColor: "var(--vscode-titleBar-activeBackground)",
2195
- color: "var(--vscode-titleBar-activeForeground)",
2196
- borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2197
- },
2198
- titleBarSection: {
2199
- display: "flex",
2200
- alignItems: "center",
2201
- gap: "2px"
2202
- },
2203
- titleBarCenter: {
2204
- display: "flex",
2205
- alignItems: "center",
2206
- gap: "4px",
2207
- fontSize: "13px",
2208
- fontWeight: 400
2209
- },
2210
- titleBarButton: {
2211
- display: "flex",
2212
- alignItems: "center",
2213
- justifyContent: "center",
2214
- width: "28px",
2215
- height: "28px",
2216
- border: "none",
2217
- background: "transparent",
2218
- color: "var(--vscode-titleBar-activeForeground)",
2219
- cursor: "pointer",
2220
- borderRadius: "4px"
2221
- },
2222
- titleBarButtonHover: {
2223
- backgroundColor: "var(--vscode-toolbar-hoverBackground)"
2224
- },
2225
- titleBarButtonActive: {
2226
- backgroundColor: "var(--vscode-toolbar-activeBackground)",
2227
- color: "var(--vscode-focusBorder)"
2228
- },
2229
- sidebar: {
2230
- display: "flex",
2231
- flexDirection: "column",
2232
- width: "260px",
2233
- minWidth: "200px",
2234
- backgroundColor: "var(--vscode-sideBar-background)",
2235
- borderRight: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2236
- },
2237
- sidebarRight: {
2238
- borderRight: "none",
2239
- borderLeft: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2240
- },
2241
- sidebarHeader: {
2242
- display: "flex",
2243
- alignItems: "center",
2244
- height: "35px",
2245
- minHeight: "35px",
2246
- padding: "0 12px",
2247
- fontSize: "11px",
2248
- fontWeight: 700,
2249
- textTransform: "uppercase",
2250
- letterSpacing: "0.04em",
2251
- color: "var(--vscode-titleBar-activeForeground)",
2252
- backgroundColor: "var(--vscode-titleBar-activeBackground)",
2253
- borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2254
- },
2255
- sidebarContent: {
2256
- flex: 1,
2257
- overflow: "auto",
2258
- padding: "4px 0"
2259
- },
2260
- treeItem: {
2261
- display: "flex",
2262
- alignItems: "center",
2263
- height: "22px",
2264
- paddingRight: "8px",
2265
- cursor: "pointer",
2266
- userSelect: "none"
2267
- },
2268
- treeItemSelected: {
2269
- backgroundColor: "var(--vscode-list-activeSelectionBackground)",
2270
- color: "var(--vscode-list-activeSelectionForeground)"
2271
- },
2272
- treeItemHover: {
2273
- backgroundColor: "var(--vscode-list-hoverBackground)"
2274
- },
2275
- treeItemChevron: {
2276
- display: "flex",
2277
- alignItems: "center",
2278
- justifyContent: "center",
2279
- width: "16px",
2280
- height: "16px",
2281
- color: "var(--vscode-foreground)",
2282
- opacity: 0.8,
2283
- cursor: "pointer"
2284
- },
2285
- treeItemChevronPlaceholder: {
2286
- width: "16px"
2287
- },
2288
- treeItemIcon: {
2289
- display: "flex",
2290
- alignItems: "center",
2291
- justifyContent: "center",
2292
- width: "16px",
2293
- height: "16px",
2294
- marginRight: "4px"
2295
- },
2296
- treeItemLabel: {
2297
- flex: 1,
2298
- overflow: "hidden",
2299
- textOverflow: "ellipsis",
2300
- whiteSpace: "nowrap",
2301
- fontSize: "13px"
2302
- },
2303
- treeItemCount: {
2304
- marginLeft: "8px",
2305
- fontSize: "11px",
2306
- color: "var(--vscode-descriptionForeground)"
2307
- },
2308
- mainContent: {
2309
- flex: 1,
2310
- display: "flex",
2311
- alignItems: "center",
2312
- justifyContent: "center",
2313
- backgroundColor: "var(--vscode-editor-background)",
2314
- color: "var(--vscode-descriptionForeground)",
2315
- fontSize: "14px"
2316
- },
2317
- propertiesPanel: {
2318
- padding: "12px"
2319
- },
2320
- propertyRow: {
2321
- marginBottom: "12px"
2322
- },
2323
- propertyLabel: {
2324
- fontSize: "12px",
2325
- color: "var(--vscode-foreground)",
2326
- marginBottom: "4px"
2327
- },
2328
- propertyDescription: {
2329
- fontSize: "11px",
2330
- color: "var(--vscode-descriptionForeground)",
2331
- marginTop: "2px"
2332
- },
2333
- propertyInput: {
2334
- width: "100%",
2335
- height: "26px",
2336
- padding: "0 8px",
2337
- fontSize: "13px",
2338
- color: "var(--vscode-input-foreground)",
2339
- backgroundColor: "var(--vscode-input-background)",
2340
- border: "1px solid var(--vscode-input-border, transparent)",
2341
- borderRadius: "2px",
2342
- outline: "none",
2343
- boxSizing: "border-box"
2344
- },
2345
- propertySelect: {
2346
- width: "100%",
2347
- height: "26px",
2348
- padding: "0 8px",
2349
- fontSize: "13px",
2350
- color: "var(--vscode-dropdown-foreground)",
2351
- backgroundColor: "var(--vscode-dropdown-background)",
2352
- border: "1px solid var(--vscode-dropdown-border)",
2353
- borderRadius: "2px",
2354
- outline: "none",
2355
- boxSizing: "border-box",
2356
- cursor: "pointer"
2357
- }
2358
- };
2359
- function Se(...s) {
2360
- return Object.assign({}, ...s.filter(Boolean));
2361
- }
2362
- class xn extends F({
2363
- active: f()
2364
- }) {
2365
- constructor() {
2366
- super(...arguments);
2367
- l(this, "isHovered", v(this, !1));
2368
- l(this, "setHovered", (t) => {
2369
- this.isHovered.set(t, void 0);
2370
- });
2371
- }
2372
- get active() {
2373
- return this.props.active;
2374
- }
2375
- }
2376
- const de = B(
2377
- xn,
2378
- {
2379
- onClick: f.const(),
2380
- title: f.const(),
2381
- children: f.const()
2382
- },
2383
- (s, e, t) => {
2384
- const n = e.isHovered.read(s), r = e.active.read(s), i = Se(
2385
- u.titleBarButton,
2386
- n && !r && u.titleBarButtonHover,
2387
- r && u.titleBarButtonActive
2388
- );
2389
- return /* @__PURE__ */ a(
2390
- "button",
2391
- {
2392
- style: i,
2393
- onClick: t.onClick,
2394
- title: t.title,
2395
- onMouseEnter: () => e.setHovered(!0),
2396
- onMouseLeave: () => e.setHovered(!1),
2397
- children: t.children
2398
- }
2399
- );
2400
- }
2401
- ), wn = ({ style: s }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: s, children: /* @__PURE__ */ a("path", { d: "M5.7 13.7L5 13l4.6-4.6L5 3.7l.7-.7 5.3 5.4-5.3 5.3z" }) }), Sn = ({ style: s }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: s, children: /* @__PURE__ */ a("path", { d: "M11 5.5L6 10.5L5.3 9.8L9.6 5.5L5.3 1.2L6 0.5L11 5.5z", transform: "rotate(90 8 5.5)" }) }), In = ({ style: s }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: s, children: /* @__PURE__ */ a("path", { d: "M14.5 2H9l-.35.15-.65.64-.65-.64L7 2H1.5l-.5.5v10l.5.5H7l.35-.15.65-.64.65.64.35.15h5.5l.5-.5v-10l-.5-.5zm-7 10H2V3h5v.86L5.85 5l1.15 1.14V10l-1.15-1.14L7 7.72V12zm6 0H8V7.72l1.15 1.14L8 10V6.14L9.15 5 8 3.86V3h5v9z" }) }), On = ({ style: s }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: s, children: /* @__PURE__ */ a("path", { d: "M14.5 3H7.71l-.85-.85L6.5 2h-5l-.5.5v11l.5.5h13l.5-.5v-10l-.5-.5zm-.5 10H2V6h12v7zm0-8H2V3h4.29l.85.85.36.15H14v1z" }) }), Tn = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M2 2v12h12V2H2zm11 11H6V3h7v10zM3 3h2v10H3V3z" }) }), Rn = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M2 2v12h12V2H2zm6 11V3h5v10H8zM3 3h4v10H3V3z" }) }), Vn = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z" }) }), Nn = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z" }) }), kn = k(
2402
- { model: f.const() },
2403
- (s, e) => {
2404
- var d, c;
2405
- const t = e.model, n = t.viewMode.read(s), r = ((d = t.daemon) == null ? void 0 : d.sessions.read(s)) ?? [], i = (c = t.daemon) == null ? void 0 : c.sessionName, o = r.filter((h) => h.name !== i);
2406
- return /* @__PURE__ */ p("div", { style: K.container, children: [
2407
- /* @__PURE__ */ p("div", { style: K.segmentedControl, children: [
2408
- /* @__PURE__ */ a(Ae, { label: "Live", mode: "session", active: n === "session", onClick: () => t.setViewMode("session") }),
2409
- /* @__PURE__ */ a(Ae, { label: "Diff", mode: "diff", active: n === "diff", onClick: () => t.setViewMode("diff") })
2410
- ] }),
2411
- o.length > 0 && /* @__PURE__ */ a("div", { style: K.sessionLinks, children: o.map((h) => /* @__PURE__ */ p(
2412
- "button",
2413
- {
2414
- style: K.sessionLink,
2415
- onClick: () => t.navigateToSession(h.name),
2416
- title: `Switch to ${h.name} session`,
2417
- children: [
2418
- "→ ",
2419
- h.name
2420
- ]
2421
- },
2422
- h.name
2423
- )) })
2424
- ] });
2425
- }
2426
- );
2427
- function Ae({ label: s, mode: e, active: t, onClick: n }) {
2428
- return /* @__PURE__ */ a(
2429
- "button",
2430
- {
2431
- style: t ? K.segmentActive : K.segment,
2432
- onClick: n,
2433
- children: s
2434
- }
2435
- );
2436
- }
2437
- const Dn = k(
2438
- {
2439
- model: f.const()
2440
- },
2441
- (s, e) => {
2442
- const t = e.model, n = t.leftSidebarVisible.read(s), r = t.rightSidebarVisible.read(s), i = t.isDarkTheme.read(s), o = t.selectedNode.read(s);
2443
- return /* @__PURE__ */ p("div", { style: u.titleBar, children: [
2444
- /* @__PURE__ */ a("div", { style: u.titleBarSection, children: /* @__PURE__ */ a(
2445
- de,
2446
- {
2447
- active: n,
2448
- onClick: t.toggleLeftSidebar,
2449
- title: "Toggle left sidebar",
2450
- children: /* @__PURE__ */ a(Tn, {})
2451
- }
2452
- ) }),
2453
- /* @__PURE__ */ p("div", { style: u.titleBarCenter, children: [
2454
- t.daemonAvailable && /* @__PURE__ */ a(kn, { model: t }),
2455
- o ? /* @__PURE__ */ p(be, { children: [
2456
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "<" }),
2457
- /* @__PURE__ */ a("span", { children: o.name }),
2458
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "/>" })
2459
- ] }) : /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: "No component selected" })
2460
- ] }),
2461
- /* @__PURE__ */ p("div", { style: u.titleBarSection, children: [
2462
- /* @__PURE__ */ a(
2463
- de,
2464
- {
2465
- active: !1,
2466
- onClick: t.toggleTheme,
2467
- title: i ? "Switch to light theme" : "Switch to dark theme",
2468
- children: i ? /* @__PURE__ */ a(Vn, {}) : /* @__PURE__ */ a(Nn, {})
2469
- }
2470
- ),
2471
- /* @__PURE__ */ a(
2472
- de,
2473
- {
2474
- active: r,
2475
- onClick: t.toggleRightSidebar,
2476
- title: "Toggle right sidebar",
2477
- children: /* @__PURE__ */ a(Rn, {})
2478
- }
2479
- )
2480
- ] })
2481
- ] });
2482
- }
2483
- ), K = {
2484
- container: {
2485
- display: "flex",
2486
- alignItems: "center",
2487
- gap: 8,
2488
- marginRight: 12
2489
- },
2490
- segmentedControl: {
2491
- display: "flex",
2492
- borderRadius: 4,
2493
- overflow: "hidden",
2494
- border: "1px solid var(--vscode-panel-border)"
2495
- },
2496
- segment: {
2497
- padding: "2px 10px",
2498
- fontSize: 11,
2499
- fontWeight: 500,
2500
- border: "none",
2501
- background: "transparent",
2502
- color: "var(--vscode-descriptionForeground)",
2503
- cursor: "pointer"
2504
- },
2505
- segmentActive: {
2506
- padding: "2px 10px",
2507
- fontSize: 11,
2508
- fontWeight: 500,
2509
- border: "none",
2510
- background: "var(--vscode-button-background)",
2511
- color: "var(--vscode-button-foreground)",
2512
- cursor: "pointer"
2513
- },
2514
- sessionLinks: {
2515
- display: "flex",
2516
- gap: 4
2517
- },
2518
- sessionLink: {
2519
- padding: "2px 8px",
2520
- fontSize: 11,
2521
- border: "1px solid var(--vscode-panel-border)",
2522
- borderRadius: 4,
2523
- background: "transparent",
2524
- color: "var(--vscode-textLink-foreground)",
2525
- cursor: "pointer"
2526
- }
2527
- }, at = k(
2528
- {
2529
- model: f.const(),
2530
- nodes: f.const(),
2531
- depth: f.const()
2532
- },
2533
- (s, e) => /* @__PURE__ */ a(be, { children: e.nodes.map((t) => /* @__PURE__ */ a(Mn, { model: e.model, node: t, depth: e.depth }, t.id)) })
2534
- );
2535
- class An extends F({
2536
- model: f.const(),
2537
- node: f.const(),
2538
- depth: f.const()
2539
- }) {
2540
- constructor() {
2541
- super(...arguments);
2542
- l(this, "isHovered", v(this, !1));
2543
- l(this, "setHovered", (t) => {
2544
- this.isHovered.set(t, void 0);
2545
- });
2546
- l(this, "handleClick", () => {
2547
- this.props.model.selectNode(this.props.node.id);
2548
- });
2549
- l(this, "handleDoubleClick", () => {
2550
- this._hasChildren && this.props.model.toggleNodeExpanded(this.props.node.id);
2551
- });
2552
- l(this, "handleChevronClick", (t) => {
2553
- t.stopPropagation(), this.props.model.toggleNodeExpanded(this.props.node.id);
2554
- });
2555
- }
2556
- // Expose props for render function
2557
- get explorerModel() {
2558
- return this.props.model;
2559
- }
2560
- get treeNode() {
2561
- return this.props.node;
2562
- }
2563
- get treeDepth() {
2564
- return this.props.depth;
2565
- }
2566
- get _hasChildren() {
2567
- return !!(this.props.node.children && this.props.node.children.length > 0);
2568
- }
2569
- }
2570
- const Mn = B(An, {}, (s, e) => {
2571
- const t = e.explorerModel, n = e.treeNode, r = e.treeDepth, i = !!(n.children && n.children.length > 0), o = i ? t.isNodeExpanded(n.id, s) : !1, c = t.selectedNodeId.read(s) === n.id, h = e.isHovered.read(s), g = Se(
2572
- u.treeItem,
2573
- { paddingLeft: `${8 + r * 12}px` },
2574
- c && u.treeItemSelected,
2575
- !c && h && u.treeItemHover
2576
- );
2577
- return /* @__PURE__ */ p(be, { children: [
2578
- /* @__PURE__ */ p(
2579
- "div",
2580
- {
2581
- style: g,
2582
- onClick: e.handleClick,
2583
- onDoubleClick: e.handleDoubleClick,
2584
- onMouseEnter: () => e.setHovered(!0),
2585
- onMouseLeave: () => e.setHovered(!1),
2586
- children: [
2587
- i ? /* @__PURE__ */ a("div", { style: u.treeItemChevron, onClick: e.handleChevronClick, children: o ? /* @__PURE__ */ a(Sn, {}) : /* @__PURE__ */ a(wn, {}) }) : /* @__PURE__ */ a("div", { style: u.treeItemChevronPlaceholder }),
2588
- /* @__PURE__ */ a("div", { style: u.treeItemIcon, children: n.type === "folder" ? /* @__PURE__ */ a(On, { style: { color: "var(--vscode-symbolIcon-folderForeground)" } }) : /* @__PURE__ */ a(In, { style: { color: "#deb45b" } }) }),
2589
- /* @__PURE__ */ a("span", { style: u.treeItemLabel, children: n.name }),
2590
- i && /* @__PURE__ */ a("span", { style: u.treeItemCount, children: n.children.length })
2591
- ]
2592
- }
2593
- ),
2594
- i && o && /* @__PURE__ */ a(at, { model: t, nodes: n.children, depth: r + 1 })
2595
- ] });
2596
- }), Fn = k(
2597
- {
2598
- model: f.const()
2599
- },
2600
- (s, e) => {
2601
- const t = e.model.tree.read(s);
2602
- return /* @__PURE__ */ p("div", { style: u.sidebar, children: [
2603
- /* @__PURE__ */ a("div", { style: u.sidebarHeader, children: "Explorer" }),
2604
- /* @__PURE__ */ a("div", { style: u.sidebarContent, children: /* @__PURE__ */ a(at, { model: e.model, nodes: t.children ?? [], depth: 0 }) })
2605
- ] });
2606
- }
2607
- );
2608
- class Bn extends F({}) {
2609
- constructor() {
2610
- super(...arguments);
2611
- l(this, "checked", v(this, !1));
2612
- l(this, "toggle", () => {
2613
- this.checked.set(!this.checked.get(), void 0);
2614
- });
2615
- }
2616
- }
2617
- const En = B(Bn, {}, (s, e) => {
2618
- const t = e.checked.read(s), n = {
2619
- position: "relative",
2620
- width: "36px",
2621
- height: "18px",
2622
- backgroundColor: t ? "var(--vscode-button-background)" : "var(--vscode-input-background)",
2623
- borderRadius: "9px",
2624
- cursor: "pointer",
2625
- transition: "background-color 0.2s",
2626
- border: "1px solid var(--vscode-input-border, transparent)"
2627
- }, r = {
2628
- position: "absolute",
2629
- top: "2px",
2630
- left: t ? "18px" : "2px",
2631
- width: "12px",
2632
- height: "12px",
2633
- backgroundColor: "var(--vscode-foreground)",
2634
- borderRadius: "50%",
2635
- transition: "left 0.2s"
2636
- };
2637
- return /* @__PURE__ */ a("div", { style: n, onClick: e.toggle, children: /* @__PURE__ */ a("div", { style: r }) });
2638
- }), zn = k(
2639
- {
2640
- node: f.const()
2641
- },
2642
- (s, e) => e.node.type !== "component" ? /* @__PURE__ */ a("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component (not a folder) to view its properties" }) : /* @__PURE__ */ p("div", { style: u.propertiesPanel, children: [
2643
- /* @__PURE__ */ p("div", { style: u.propertyRow, children: [
2644
- /* @__PURE__ */ p("div", { style: u.propertyLabel, children: [
2645
- "children",
2646
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : string" })
2647
- ] }),
2648
- /* @__PURE__ */ a(
2649
- "input",
2650
- {
2651
- type: "text",
2652
- style: u.propertyInput,
2653
- defaultValue: "Click me",
2654
- placeholder: "Enter text..."
2655
- }
2656
- ),
2657
- /* @__PURE__ */ a("div", { style: u.propertyDescription, children: "Button text content" })
2658
- ] }),
2659
- /* @__PURE__ */ p("div", { style: u.propertyRow, children: [
2660
- /* @__PURE__ */ p("div", { style: u.propertyLabel, children: [
2661
- "variant",
2662
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
2663
- ] }),
2664
- /* @__PURE__ */ p("select", { style: u.propertySelect, defaultValue: "default", children: [
2665
- /* @__PURE__ */ a("option", { value: "default", children: "default" }),
2666
- /* @__PURE__ */ a("option", { value: "primary", children: "primary" }),
2667
- /* @__PURE__ */ a("option", { value: "secondary", children: "secondary" }),
2668
- /* @__PURE__ */ a("option", { value: "destructive", children: "destructive" })
2669
- ] }),
2670
- /* @__PURE__ */ a("div", { style: u.propertyDescription, children: "Visual style variant" })
2671
- ] }),
2672
- /* @__PURE__ */ p("div", { style: u.propertyRow, children: [
2673
- /* @__PURE__ */ p("div", { style: u.propertyLabel, children: [
2674
- "size",
2675
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
2676
- ] }),
2677
- /* @__PURE__ */ p("select", { style: u.propertySelect, defaultValue: "default", children: [
2678
- /* @__PURE__ */ a("option", { value: "sm", children: "sm" }),
2679
- /* @__PURE__ */ a("option", { value: "default", children: "default" }),
2680
- /* @__PURE__ */ a("option", { value: "lg", children: "lg" })
2681
- ] }),
2682
- /* @__PURE__ */ a("div", { style: u.propertyDescription, children: "Button size" })
2683
- ] }),
2684
- /* @__PURE__ */ p("div", { style: u.propertyRow, children: [
2685
- /* @__PURE__ */ p("div", { style: u.propertyLabel, children: [
2686
- "disabled",
2687
- /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : boolean" })
2688
- ] }),
2689
- /* @__PURE__ */ a(En, {}),
2690
- /* @__PURE__ */ a("div", { style: u.propertyDescription, children: "Disable the button" })
2691
- ] })
2692
- ] })
2693
- ), Hn = k(
2694
- {
2695
- selectedNode: f.const()
2696
- },
2697
- (s, e) => /* @__PURE__ */ p("div", { style: Se(u.sidebar, u.sidebarRight), children: [
2698
- /* @__PURE__ */ p("div", { style: u.sidebarHeader, children: [
2699
- /* @__PURE__ */ a("span", { style: { marginRight: "6px", color: "var(--vscode-textLink-foreground)" }, children: "</>" }),
2700
- "Props"
2701
- ] }),
2702
- /* @__PURE__ */ a("div", { style: u.sidebarContent, children: e.selectedNode ? /* @__PURE__ */ a(zn, { node: e.selectedNode }) : /* @__PURE__ */ a("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component to view its properties" }) })
2703
- ] })
2704
- );
2705
- class Ln extends F({
2706
- fixture: f.const(),
2707
- compact: f.const()
2708
- }) {
2709
- constructor() {
2710
- super(...arguments);
2711
- l(this, "_containerRef", null);
2712
- l(this, "_shadowRoot", null);
2713
- l(this, "_renderContainer", null);
2714
- l(this, "_disposable", null);
2715
- l(this, "_resizeObserver", null);
2716
- l(this, "measuredWidth", v(this, void 0));
2717
- l(this, "measuredHeight", v(this, void 0));
2718
- l(this, "setContainerRef", (t) => {
2719
- if (t === this._containerRef || (this._cleanup(), this._containerRef = t, !t)) return;
2720
- const n = this.fixture.component;
2721
- n.isolation === "shadow-dom" ? this._renderInShadowDom(t, n) : this._renderDirect(t, n);
2722
- const r = this._renderContainer ?? t;
2723
- this._resizeObserver = new ResizeObserver((i) => {
2724
- for (const o of i) {
2725
- const { width: d, height: c } = o.contentRect;
2726
- c > 0 && (this.measuredWidth.set(Math.round(d), void 0), this.measuredHeight.set(Math.round(c), void 0));
2727
- }
2728
- }), this._resizeObserver.observe(r);
2729
- });
2730
- }
2731
- get fixture() {
2732
- return this.props.fixture;
2733
- }
2734
- get compact() {
2735
- return this.props.compact ?? !1;
2736
- }
2737
- _renderInShadowDom(t, n) {
2738
- if (t.shadowRoot) {
2739
- for (this._shadowRoot = t.shadowRoot; this._shadowRoot.firstChild; )
2740
- this._shadowRoot.removeChild(this._shadowRoot.firstChild);
2741
- this._shadowRoot.adoptedStyleSheets = [];
2742
- } else
2743
- this._shadowRoot = t.attachShadow({ mode: "open" });
2744
- if (n.styles)
2745
- for (const o of n.styles)
2746
- if (o.type === "css") {
2747
- const d = document.createElement("style");
2748
- d.textContent = o.content, this._shadowRoot.appendChild(d);
2749
- } else if (o.type === "url") {
2750
- const d = document.createElement("link");
2751
- d.rel = "stylesheet", d.href = o.href, this._shadowRoot.appendChild(d);
2752
- } else o.type === "adopted" && (this._shadowRoot.adoptedStyleSheets = [
2753
- ...this._shadowRoot.adoptedStyleSheets,
2754
- o.sheet
2755
- ]);
2756
- const r = document.createElement("div");
2757
- r.style.display = "inline-block", this._renderContainer = r, this._shadowRoot.appendChild(r);
2758
- const i = this._getDefaultProps(n);
2759
- this._disposable = n.render(r, i);
2760
- }
2761
- _renderDirect(t, n) {
2762
- this._renderContainer = t;
2763
- const r = this._getDefaultProps(n);
2764
- this._disposable = n.render(t, r);
2765
- }
2766
- _getDefaultProps(t) {
2767
- const n = {};
2768
- for (const r of t.properties)
2769
- n[r.name] = r.defaultValue;
2770
- return n;
2771
- }
2772
- _cleanup() {
2773
- var t;
2774
- this._disposable && (typeof this._disposable == "function" ? this._disposable() : typeof this._disposable.dispose == "function" && this._disposable.dispose()), this._disposable = null, (t = this._resizeObserver) == null || t.disconnect(), this._resizeObserver = null, this._shadowRoot = null, this._renderContainer = null;
2775
- }
2776
- dispose() {
2777
- this._cleanup();
2778
- }
2779
- }
2780
- const dt = B(
2781
- Ln,
2782
- {},
2783
- (s, e) => {
2784
- const t = e.fixture, n = t.component, r = n.displayMode, i = e.measuredWidth.read(s), o = e.measuredHeight.read(s), d = e.compact;
2785
- let c;
2786
- if (r.type === "page") {
2787
- const x = r.viewports[0], w = Ot(x);
2788
- c = {
2789
- width: w.width,
2790
- height: w.height,
2791
- overflow: "auto"
2792
- };
2793
- } else
2794
- c = {
2795
- display: "inline-block"
2796
- };
2797
- const h = i && o ? `${i} × ${o}` : "", g = d ? W.wrapperCompact : W.wrapper, _ = d ? W.nameCompact : W.name;
2798
- return /* @__PURE__ */ p("div", { style: g, children: [
2799
- /* @__PURE__ */ p("div", { style: W.labelRow, children: [
2800
- /* @__PURE__ */ a("span", { style: _, children: t.name }),
2801
- !d && h && /* @__PURE__ */ a("span", { style: W.dimensions, children: h })
2802
- ] }),
2803
- /* @__PURE__ */ a("div", { style: Pn(n.background), children: /* @__PURE__ */ a("div", { ref: e.setContainerRef, style: c }) })
2804
- ] });
2805
- }
2806
- ), G = 8;
2807
- function ct(s, e) {
2808
- return `
2809
- linear-gradient(45deg, ${e} 25%, transparent 25%),
2810
- linear-gradient(-45deg, ${e} 25%, transparent 25%),
2811
- linear-gradient(45deg, transparent 75%, ${e} 75%),
2812
- linear-gradient(-45deg, transparent 75%, ${e} 75%)
2813
- `;
2814
- }
2815
- const $n = {
2816
- backgroundColor: "#ffffff",
2817
- backgroundImage: ct("#ffffff", "#e5e5e5")
2818
- }, Un = {
2819
- backgroundColor: "#1e1e1e",
2820
- backgroundImage: ct("#1e1e1e", "#2d2d2d")
2821
- }, jn = {
2822
- display: "inline-block",
2823
- padding: "12px",
2824
- borderRadius: "4px",
2825
- backgroundSize: `${G * 2}px ${G * 2}px`,
2826
- backgroundPosition: `0 0, 0 ${G}px, ${G}px -${G}px, -${G}px 0`,
2827
- boxShadow: "0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08)"
2828
- };
2829
- function Pn(s) {
2830
- const e = s === "dark" ? Un : $n;
2831
- return {
2832
- ...jn,
2833
- backgroundColor: e.backgroundColor,
2834
- backgroundImage: e.backgroundImage
2835
- };
2836
- }
2837
- const W = {
2838
- wrapper: {
2839
- marginBottom: "32px"
2840
- },
2841
- wrapperCompact: {
2842
- marginBottom: "0"
2843
- },
2844
- labelRow: {
2845
- display: "flex",
2846
- alignItems: "baseline",
2847
- gap: "8px",
2848
- marginBottom: "8px"
2849
- },
2850
- name: {
2851
- fontSize: "12px",
2852
- fontWeight: 500,
2853
- color: "var(--vscode-foreground)"
2854
- },
2855
- nameCompact: {
2856
- fontSize: "11px",
2857
- fontWeight: 500,
2858
- color: "var(--vscode-descriptionForeground)"
2859
- },
2860
- dimensions: {
2861
- fontSize: "11px",
2862
- color: "var(--vscode-descriptionForeground)",
2863
- fontFamily: "var(--vscode-editor-font-family, monospace)"
2864
- }
2865
- };
2866
- class Gn extends F({
2867
- fixtureId: f.const(),
2868
- sessionName: f.const(),
2869
- daemon: f.const()
2870
- }) {
2871
- constructor(t) {
2872
- super(t);
2873
- l(this, "screenshot", v(this, { status: "idle" }));
2874
- l(this, "_fetchVersion", 0);
2875
- this._store.add(Ye((n) => {
2876
- this.props.daemon.sourceTreeIds.read(n).get(this.props.sessionName) && this._fetchScreenshot();
2877
- }));
2878
- }
2879
- get fixtureId() {
2880
- return this.props.fixtureId;
2881
- }
2882
- async _fetchScreenshot() {
2883
- const t = ++this._fetchVersion;
2884
- this.screenshot.set({ status: "loading" }, void 0);
2885
- try {
2886
- const n = await this.props.daemon.getScreenshot(this.props.sessionName, this.props.fixtureId);
2887
- t === this._fetchVersion && this.screenshot.set({ status: "ready", data: n }, void 0);
2888
- } catch (n) {
2889
- t === this._fetchVersion && this.screenshot.set({ status: "error", message: String(n) }, void 0);
2890
- }
2891
- }
2892
- }
2893
- const Me = B(
2894
- Gn,
2895
- {},
2896
- (s, e) => {
2897
- const t = e.screenshot.read(s);
2898
- if (t.status === "idle" || t.status === "loading")
2899
- return /* @__PURE__ */ a("div", { style: H.placeholder, children: /* @__PURE__ */ a("div", { style: H.shimmer }) });
2900
- if (t.status === "error")
2901
- return /* @__PURE__ */ a("div", { style: H.error, children: /* @__PURE__ */ a("span", { style: H.errorText, children: "Screenshot failed" }) });
2902
- const { data: n } = t;
2903
- return n.image ? /* @__PURE__ */ a(
2904
- "img",
2905
- {
2906
- src: `data:image/png;base64,${n.image}`,
2907
- style: H.image,
2908
- alt: `Screenshot of ${e.fixtureId}`
2909
- }
2910
- ) : /* @__PURE__ */ a("div", { style: H.placeholder, children: /* @__PURE__ */ a("span", { style: H.hashText, children: n.hash.slice(0, 12) }) });
2911
- }
2912
- ), H = {
2913
- placeholder: {
2914
- minHeight: 80,
2915
- display: "flex",
2916
- alignItems: "center",
2917
- justifyContent: "center",
2918
- backgroundColor: "var(--vscode-editor-background)",
2919
- border: "1px solid var(--vscode-panel-border)",
2920
- borderRadius: 4,
2921
- overflow: "hidden"
2922
- },
2923
- shimmer: {
2924
- width: "100%",
2925
- height: 80,
2926
- background: "linear-gradient(90deg, var(--vscode-editor-background) 25%, var(--vscode-list-hoverBackground) 50%, var(--vscode-editor-background) 75%)",
2927
- backgroundSize: "200% 100%",
2928
- animation: "shimmer 1.5s infinite"
2929
- },
2930
- error: {
2931
- minHeight: 80,
2932
- display: "flex",
2933
- alignItems: "center",
2934
- justifyContent: "center",
2935
- backgroundColor: "var(--vscode-inputValidation-errorBackground)",
2936
- border: "1px solid var(--vscode-inputValidation-errorBorder)",
2937
- borderRadius: 4
2938
- },
2939
- errorText: {
2940
- fontSize: 12,
2941
- color: "var(--vscode-errorForeground)"
2942
- },
2943
- hashText: {
2944
- fontSize: 11,
2945
- color: "var(--vscode-descriptionForeground)",
2946
- fontFamily: "var(--vscode-editor-font-family, monospace)"
2947
- },
2948
- image: {
2949
- maxWidth: "100%",
2950
- display: "block",
2951
- borderRadius: 4,
2952
- border: "1px solid var(--vscode-panel-border)"
2953
- }
2954
- };
2955
- class Wn extends F({
2956
- fixtureId: f.const(),
2957
- daemon: f.const(),
2958
- baselineSession: f.const(),
2959
- currentSession: f.const()
2960
- }) {
2961
- constructor(t) {
2962
- super(t);
2963
- l(this, "comparisonStatus", v(this, { status: "loading" }));
2964
- this._store.add(Ye((n) => {
2965
- const r = this.props.daemon.sourceTreeIds.read(n), i = r.get(this.props.baselineSession), o = r.get(this.props.currentSession);
2966
- i && o && this._fetchComparison();
2967
- }));
2968
- }
2969
- get fixtureId() {
2970
- return this.props.fixtureId;
2971
- }
2972
- get daemon() {
2973
- return this.props.daemon;
2974
- }
2975
- get baselineSession() {
2976
- return this.props.baselineSession;
2977
- }
2978
- get currentSession() {
2979
- return this.props.currentSession;
2980
- }
2981
- async _fetchComparison() {
2982
- this.comparisonStatus.set({ status: "loading" }, void 0);
2983
- try {
2984
- const t = await this.props.daemon.compare(
2985
- this.props.fixtureId,
2986
- this.props.baselineSession,
2987
- this.props.currentSession
2988
- );
2989
- this.comparisonStatus.set({ status: "ready", match: t.match }, void 0);
2990
- } catch (t) {
2991
- this.comparisonStatus.set({ status: "error", message: String(t) }, void 0);
2992
- }
2993
- }
2994
- }
2995
- const qn = B(
2996
- Wn,
2997
- {},
2998
- (s, e) => {
2999
- const t = e.comparisonStatus.read(s), n = t.status === "loading" ? /* @__PURE__ */ a("span", { style: b.badgeLoading, children: "comparing..." }) : t.status === "error" ? /* @__PURE__ */ a("span", { style: b.badgeError, children: "error" }) : t.match ? /* @__PURE__ */ a("span", { style: b.badgeMatch, children: "✓ match" }) : /* @__PURE__ */ a("span", { style: b.badgeChanged, children: "● changed" });
3000
- return /* @__PURE__ */ p("div", { style: b.fixtureRow, children: [
3001
- /* @__PURE__ */ p("div", { style: b.fixtureLabel, children: [
3002
- /* @__PURE__ */ a("span", { style: b.fixtureName, children: e.fixtureId }),
3003
- n
3004
- ] }),
3005
- /* @__PURE__ */ p("div", { style: b.sideBySide, children: [
3006
- /* @__PURE__ */ p("div", { style: b.screenshotColumn, children: [
3007
- /* @__PURE__ */ a("span", { style: b.columnLabel, children: "Current" }),
3008
- /* @__PURE__ */ a(
3009
- Me,
3010
- {
3011
- fixtureId: e.fixtureId,
3012
- sessionName: e.currentSession,
3013
- daemon: e.daemon
3014
- }
3015
- )
3016
- ] }),
3017
- /* @__PURE__ */ p("div", { style: b.screenshotColumn, children: [
3018
- /* @__PURE__ */ a("span", { style: b.columnLabel, children: "Baseline" }),
3019
- /* @__PURE__ */ a(
3020
- Me,
3021
- {
3022
- fixtureId: e.fixtureId,
3023
- sessionName: e.baselineSession,
3024
- daemon: e.daemon
3025
- }
3026
- )
3027
- ] })
3028
- ] })
3029
- ] });
3030
- }
3031
- ), Kn = k(
3032
- {
3033
- name: f.const(),
3034
- path: f.const(),
3035
- items: f.const(),
3036
- daemon: f.const(),
3037
- baselineSession: f.const(),
3038
- currentSession: f.const()
3039
- },
3040
- (s, e) => /* @__PURE__ */ p("div", { children: [
3041
- /* @__PURE__ */ a("div", { style: b.groupHeader, children: /* @__PURE__ */ a("span", { style: b.groupTitle, children: e.path }) }),
3042
- /* @__PURE__ */ a("div", { style: b.groupContent, children: e.items.map((t) => /* @__PURE__ */ a(
3043
- qn,
3044
- {
3045
- fixtureId: t.fixtureId,
3046
- daemon: e.daemon,
3047
- baselineSession: e.baselineSession,
3048
- currentSession: e.currentSession
3049
- },
3050
- t.fixtureId
3051
- )) })
3052
- ] })
3053
- ), b = {
3054
- groupHeader: {
3055
- marginBottom: 12
3056
- },
3057
- groupTitle: {
3058
- fontSize: 13,
3059
- fontWeight: 500,
3060
- color: "var(--vscode-foreground)"
3061
- },
3062
- groupContent: {
3063
- display: "flex",
3064
- flexDirection: "column",
3065
- gap: 24
3066
- },
3067
- fixtureRow: {
3068
- display: "flex",
3069
- flexDirection: "column",
3070
- gap: 8
3071
- },
3072
- fixtureLabel: {
3073
- display: "flex",
3074
- alignItems: "center",
3075
- gap: 8
3076
- },
3077
- fixtureName: {
3078
- fontSize: 12,
3079
- fontWeight: 500,
3080
- color: "var(--vscode-foreground)"
3081
- },
3082
- sideBySide: {
3083
- display: "flex",
3084
- flexDirection: "row",
3085
- gap: 16
3086
- },
3087
- screenshotColumn: {
3088
- flex: 1,
3089
- display: "flex",
3090
- flexDirection: "column",
3091
- gap: 4,
3092
- minWidth: 0
3093
- },
3094
- columnLabel: {
3095
- fontSize: 11,
3096
- fontWeight: 500,
3097
- color: "var(--vscode-descriptionForeground)",
3098
- textTransform: "uppercase",
3099
- letterSpacing: "0.05em"
3100
- },
3101
- badgeMatch: {
3102
- fontSize: 11,
3103
- color: "var(--vscode-testing-iconPassed)",
3104
- fontWeight: 500
3105
- },
3106
- badgeChanged: {
3107
- fontSize: 11,
3108
- color: "var(--vscode-testing-iconFailed)",
3109
- fontWeight: 500
3110
- },
3111
- badgeLoading: {
3112
- fontSize: 11,
3113
- color: "var(--vscode-descriptionForeground)",
3114
- fontStyle: "italic"
3115
- },
3116
- badgeError: {
3117
- fontSize: 11,
3118
- color: "var(--vscode-errorForeground)",
3119
- fontWeight: 500
3120
- }
3121
- }, lt = "component-explorer:fixtureHeights", Fe = 500;
3122
- let R = null;
3123
- function ht() {
3124
- if (R !== null) return R;
3125
- try {
3126
- const s = localStorage.getItem(lt);
3127
- if (s)
3128
- return R = JSON.parse(s), R;
3129
- } catch {
3130
- }
3131
- return R = {}, R;
3132
- }
3133
- function Jn() {
3134
- if (R !== null)
3135
- try {
3136
- const s = Object.entries(R);
3137
- s.length > Fe && (R = Object.fromEntries(s.slice(-Fe))), localStorage.setItem(lt, JSON.stringify(R));
3138
- } catch {
3139
- }
3140
- }
3141
- function Zn(s, e) {
3142
- const t = ht();
3143
- t[s] = e, Jn();
3144
- }
3145
- function Xn() {
3146
- return new Map(Object.entries(ht()));
3147
- }
3148
- const Yn = 280, Qn = 32, oe = 32, Be = 400, ut = "component-explorer:scrollAnchors", Ee = 100;
3149
- function ft() {
3150
- try {
3151
- const s = localStorage.getItem(ut);
3152
- if (s) return JSON.parse(s);
3153
- } catch {
3154
- }
3155
- return {};
3156
- }
3157
- function es(s, e) {
3158
- try {
3159
- const t = ft();
3160
- t[s] = e;
3161
- const n = Object.entries(t), r = n.length > Ee ? Object.fromEntries(n.slice(-Ee)) : t;
3162
- localStorage.setItem(ut, JSON.stringify(r));
3163
- } catch {
3164
- }
3165
- }
3166
- function ts(s) {
3167
- return ft()[s];
3168
- }
3169
- function pt(s) {
3170
- return s.type === "single" ? s.fixture.id : s.id;
3171
- }
3172
- function ns(s, e) {
3173
- const t = new Array(s.length);
3174
- let n = oe;
3175
- for (let r = 0; r < s.length; r++) {
3176
- const i = e.get(pt(s[r])) ?? Yn;
3177
- t[r] = { top: n, height: i }, n += i + Qn;
3178
- }
3179
- return t;
3180
- }
3181
- function ss(s) {
3182
- if (s.length === 0) return 0;
3183
- const e = s[s.length - 1];
3184
- return e.top + e.height + oe;
3185
- }
3186
- function gt(s, e) {
3187
- let t = 0, n = s.length;
3188
- for (; t < n; ) {
3189
- const r = t + n >> 1;
3190
- s[r].top + s[r].height < e ? t = r + 1 : n = r;
3191
- }
3192
- return t;
3193
- }
3194
- function rs(s, e, t) {
3195
- if (s.length === 0) return { start: 0, end: 0 };
3196
- const n = gt(s, e - Be);
3197
- let r = n;
3198
- const i = e + t + Be;
3199
- for (; r < s.length && s[r].top < i; )
3200
- r++;
3201
- return { start: n, end: r };
3202
- }
3203
- function ze(s, e) {
3204
- if (s.length === 0) return;
3205
- const t = gt(s, e), n = Math.min(t, s.length - 1);
3206
- return {
3207
- rowIndex: n,
3208
- offsetFromViewport: s[n].top - e
3209
- };
3210
- }
3211
- function He(s, e) {
3212
- return e.rowIndex >= s.length ? 0 : s[e.rowIndex].top - e.offsetFromViewport;
3213
- }
3214
- class is extends F({
3215
- model: f.const()
3216
- }) {
3217
- constructor() {
3218
- super(...arguments);
3219
- l(this, "_rowHeights", v(this, Xn()));
3220
- l(this, "_scrollTop", v(this, 0));
3221
- l(this, "_viewportHeight", v(this, 0));
3222
- l(this, "_scrollContainerRef", null);
3223
- l(this, "_resizeObserver", null);
3224
- l(this, "_viewportResizeObserver", null);
3225
- l(this, "_currentNodeId");
3226
- l(this, "_scrollSaveTimeout", null);
3227
- l(this, "_suppressScrollHandler", !1);
3228
- l(this, "layout", N(this, (t) => {
3229
- const n = this.explorerModel.selectedFixtures.read(t), r = this._rowHeights.read(t);
3230
- return ns(n, r);
3231
- }));
3232
- l(this, "visibleRowRange", N(this, (t) => {
3233
- const n = this.layout.read(t), r = this._scrollTop.read(t), i = this._viewportHeight.read(t);
3234
- return rs(n, r, i);
3235
- }));
3236
- l(this, "setScrollContainerRef", (t) => {
3237
- var n;
3238
- this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), (n = this._viewportResizeObserver) == null || n.disconnect(), this._scrollContainerRef = t, t && (t.addEventListener("scroll", this._handleScroll, { passive: !0 }), this._viewportHeight.set(t.clientHeight, void 0), this._viewportResizeObserver = new ResizeObserver(([r]) => {
3239
- this._viewportHeight.set(Math.round(r.contentRect.height), void 0);
3240
- }), this._viewportResizeObserver.observe(t), this._restoreScrollPosition());
3241
- });
3242
- l(this, "_handleScroll", () => {
3243
- this._scrollContainerRef && (this._scrollTop.set(this._scrollContainerRef.scrollTop, void 0), !(this._suppressScrollHandler || !this._currentNodeId) && (this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout), this._scrollSaveTimeout = setTimeout(() => {
3244
- if (!this._currentNodeId) return;
3245
- const t = this.layout.get(), n = ze(t, this._scrollTop.get());
3246
- n && es(this._currentNodeId, n);
3247
- }, 150)));
3248
- });
3249
- l(this, "observeRowElement", (t, n) => {
3250
- t && (this._resizeObserver || (this._resizeObserver = new ResizeObserver((r) => {
3251
- const i = this._rowHeights.get();
3252
- let o;
3253
- for (const d of r) {
3254
- const c = d.target.getAttribute("data-row-id");
3255
- if (!c) continue;
3256
- const h = Math.round(d.contentRect.height);
3257
- h > 0 && i.get(c) !== h && (o || (o = new Map(i)), o.set(c, h), Zn(c, h));
3258
- }
3259
- if (o) {
3260
- const d = this.layout.get(), c = ze(d, this._scrollTop.get());
3261
- if (this._rowHeights.set(o, void 0), c && this._scrollContainerRef) {
3262
- const h = this.layout.get(), g = He(h, c);
3263
- this._suppressScrollHandler = !0, this._scrollContainerRef.scrollTop = g, this._scrollTop.set(g, void 0), requestAnimationFrame(() => {
3264
- this._suppressScrollHandler = !1;
3265
- });
3266
- }
3267
- }
3268
- })), t.setAttribute("data-row-id", n), this._resizeObserver.observe(t));
3269
- });
3270
- }
3271
- get explorerModel() {
3272
- return this.props.model;
3273
- }
3274
- updateForSelection(t) {
3275
- this._currentNodeId !== t && (this._currentNodeId = t, this._restoreScrollPosition());
3276
- }
3277
- _restoreScrollPosition() {
3278
- if (!this._scrollContainerRef || !this._currentNodeId) return;
3279
- const t = ts(this._currentNodeId);
3280
- if (!t) return;
3281
- const n = this.layout.get(), r = He(n, t);
3282
- this._suppressScrollHandler = !0, this._scrollContainerRef.scrollTop = r, this._scrollTop.set(r, void 0), requestAnimationFrame(() => {
3283
- this._suppressScrollHandler = !1;
3284
- });
3285
- }
3286
- dispose() {
3287
- var t, n;
3288
- (t = this._resizeObserver) == null || t.disconnect(), (n = this._viewportResizeObserver) == null || n.disconnect(), this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout);
3289
- }
3290
- }
3291
- const os = B(
3292
- is,
3293
- {},
3294
- (s, e) => {
3295
- const t = e.explorerModel.selectedFixtures.read(s), n = e.explorerModel.selectedNodeId.read(s), r = e.layout.read(s), { start: i, end: o } = e.visibleRowRange.read(s);
3296
- if (e.updateForSelection(n), t.length === 0)
3297
- return /* @__PURE__ */ a("div", { style: J.emptyState, children: /* @__PURE__ */ a("span", { style: J.emptyText, children: "Select a component or folder to preview" }) });
3298
- const d = ss(r);
3299
- return /* @__PURE__ */ a("div", { ref: e.setScrollContainerRef, style: J.scrollContainer, children: /* @__PURE__ */ a("div", { style: { position: "relative", height: d }, children: t.slice(i, o).map((c, h) => {
3300
- const g = i + h, { top: _ } = r[g], x = pt(c);
3301
- return /* @__PURE__ */ a(
3302
- "div",
3303
- {
3304
- ref: (w) => e.observeRowElement(w, x),
3305
- style: { position: "absolute", top: _, left: oe, right: oe },
3306
- children: c.type === "single" ? /* @__PURE__ */ a(dt, { fixture: c.fixture, compact: !1 }) : c.type === "variants" ? /* @__PURE__ */ a(as, { row: c }) : c.type === "screenshot-comparison" && e.explorerModel.daemon ? /* @__PURE__ */ a(
3307
- Kn,
3308
- {
3309
- name: c.name,
3310
- path: c.path,
3311
- items: c.items,
3312
- daemon: e.explorerModel.daemon,
3313
- baselineSession: "baseline",
3314
- currentSession: "current"
3315
- }
3316
- ) : null
3317
- },
3318
- x
3319
- );
3320
- }) }) });
3321
- }
3322
- ), as = k(
3323
- { row: f.const() },
3324
- (s, e) => {
3325
- const t = e.row;
3326
- return /* @__PURE__ */ p("div", { children: [
3327
- /* @__PURE__ */ a("div", { style: J.variantsHeader, children: /* @__PURE__ */ a("span", { style: J.variantsTitle, children: t.path }) }),
3328
- /* @__PURE__ */ a("div", { style: J.variantsContent, children: t.fixtures.map((n) => /* @__PURE__ */ a(dt, { fixture: n, compact: !0 }, n.id)) })
3329
- ] });
3330
- }
3331
- ), J = {
3332
- scrollContainer: {
3333
- flex: 1,
3334
- overflow: "auto",
3335
- backgroundColor: "var(--vscode-editor-background)"
3336
- },
3337
- emptyState: {
3338
- flex: 1,
3339
- display: "flex",
3340
- alignItems: "center",
3341
- justifyContent: "center",
3342
- backgroundColor: "var(--vscode-editor-background)"
3343
- },
3344
- emptyText: {
3345
- color: "var(--vscode-descriptionForeground)",
3346
- fontSize: "14px"
3347
- },
3348
- variantsHeader: {
3349
- marginBottom: "12px"
3350
- },
3351
- variantsTitle: {
3352
- fontSize: "13px",
3353
- fontWeight: 500,
3354
- color: "var(--vscode-foreground)"
3355
- },
3356
- variantsContent: {
3357
- display: "flex",
3358
- flexDirection: "row",
3359
- flexWrap: "wrap",
3360
- gap: "16px"
3361
- }
3362
- }, mt = B(
3363
- Cn,
3364
- { daemonModel: f.const() },
3365
- (s, e) => {
3366
- const t = e.leftSidebarVisible.read(s), n = e.rightSidebarVisible.read(s), r = e.isDarkTheme.read(s), i = e.selectedNode.read(s);
3367
- return /* @__PURE__ */ p("div", { className: r ? "vscode-theme default-dark-plus" : "vscode-theme default-light-plus", style: u.container, children: [
3368
- t && /* @__PURE__ */ a(Fn, { model: e }),
3369
- /* @__PURE__ */ p("div", { style: u.centerArea, children: [
3370
- /* @__PURE__ */ a(Dn, { model: e }),
3371
- /* @__PURE__ */ a(os, { model: e })
3372
- ] }),
3373
- n && /* @__PURE__ */ a(Hn, { selectedNode: i })
3374
- ] });
3375
- }
3376
- );
3377
- function ds() {
3378
- const s = new it();
3379
- return s.register("components/Button.fixture.tsx", ee({
3380
- Primary: {
3381
- render: (e) => (e.innerHTML = "<button>Primary Button</button>", { dispose: () => {
3382
- e.innerHTML = "";
3383
- } })
3384
- },
3385
- Icon: {
3386
- render: (e) => (e.innerHTML = "<button>🔔 Icon Button</button>", { dispose: () => {
3387
- e.innerHTML = "";
3388
- } })
3389
- }
3390
- })), s.register("components/Input.fixture.tsx", ee({
3391
- Text: {
3392
- render: (e) => (e.innerHTML = '<input type="text" placeholder="Text Input" />', { dispose: () => {
3393
- e.innerHTML = "";
3394
- } })
3395
- },
3396
- Search: {
3397
- render: (e) => (e.innerHTML = '<input type="search" placeholder="Search..." />', { dispose: () => {
3398
- e.innerHTML = "";
3399
- } })
3400
- }
3401
- })), s.register("components/Card.fixture.tsx", ee({
3402
- Basic: {
3403
- render: (e) => (e.innerHTML = '<div style="border: 1px solid #ccc; padding: 16px;">Basic Card</div>', { dispose: () => {
3404
- e.innerHTML = "";
3405
- } })
3406
- }
3407
- })), s.register("components/Feedback.fixture.tsx", ee({
3408
- Badge: {
3409
- render: (e) => (e.innerHTML = '<span style="background: blue; color: white; padding: 2px 8px; border-radius: 4px;">Badge</span>', { dispose: () => {
3410
- e.innerHTML = "";
3411
- } })
3412
- },
3413
- Alert: {
3414
- render: (e) => (e.innerHTML = '<div style="background: #ffffcc; padding: 8px; border: 1px solid #cc0;">Alert message</div>', { dispose: () => {
3415
- e.innerHTML = "";
3416
- } })
3417
- }
3418
- })), s;
3419
- }
3420
- function Ss() {
3421
- const s = ds();
3422
- return /* @__PURE__ */ a(mt, { registry: s });
3423
- }
3424
- var cs = class ve {
3425
- constructor(e) {
3426
- this.iterator = e;
3427
- }
3428
- static fromIterable(e) {
3429
- return new ve(e[Symbol.asyncIterator]());
3430
- }
3431
- static fromFn(e) {
3432
- return new ve(e());
3433
- }
3434
- [Symbol.asyncIterator]() {
3435
- return this.iterator;
3436
- }
3437
- }, ls = class extends Error {
3438
- constructor(s, e, t) {
3439
- super(t), this.statusCode = s, this.method = e, this.name = "ApiError";
3440
- }
3441
- }, hs = class {
3442
- constructor(s) {
3443
- l(this, "methods", this._createProxy(""));
3444
- this._request = s;
3445
- }
3446
- _createProxy(s) {
3447
- return new Proxy(() => {
3448
- }, {
3449
- apply: async (e, t, n) => await this._request(s, n[0]),
3450
- get: (e, t) => this._createProxy(`${s}${s ? "/" : ""}${t}`)
3451
- });
3452
- }
3453
- };
3454
- function us(s, e) {
3455
- return new hs(async (t, n) => {
3456
- var d;
3457
- const r = await fetch(`${s}/${t}`, {
3458
- method: "POST",
3459
- headers: {
3460
- "Content-Type": "application/json",
3461
- ...(d = e == null ? void 0 : e.getHeaders) == null ? void 0 : d.call(e)
3462
- },
3463
- body: JSON.stringify(n)
3464
- });
3465
- if (r.status !== 200) {
3466
- const c = await r.json().catch(() => null);
3467
- let h;
3468
- throw c && typeof c == "object" && "errorMessage" in c ? h = `${c.errorMessage}` : h = `Error calling API method ${t}: ${JSON.stringify(c)} (Status: ${r.status}, Status Text: ${r.statusText})`, new ls(r.status, t, h);
3469
- }
3470
- const i = r.headers.get("Content-Type");
3471
- return i != null && i.startsWith("application/jsonl") ? cs.fromFn(async function* () {
3472
- var x;
3473
- const c = (x = r.body) == null ? void 0 : x.getReader();
3474
- if (!c)
3475
- return;
3476
- let h = "";
3477
- const g = new TextDecoder("utf-8");
3478
- for (; ; ) {
3479
- const { done: w, value: U } = await c.read();
3480
- if (w)
3481
- break;
3482
- h += g.decode(U, { stream: !0 });
3483
- let D;
3484
- for (; (D = h.indexOf(`
3485
- `)) >= 0; ) {
3486
- const y = h.slice(0, D).trim();
3487
- h = h.slice(D + 1), y.length > 0 && (yield JSON.parse(y));
3488
- }
3489
- }
3490
- const _ = h.trim();
3491
- _.length > 0 && (yield JSON.parse(_));
3492
- }) : await r.json();
3493
- });
3494
- }
3495
- class fs {
3496
- constructor(e) {
3497
- l(this, "_sourceTreeIds", v(this, /* @__PURE__ */ new Map()));
3498
- l(this, "_sessions", v(this, []));
3499
- l(this, "_screenshotCache", /* @__PURE__ */ new Map());
3500
- l(this, "_client");
3501
- l(this, "_eventStreamAbort", null);
3502
- l(this, "sessionName");
3503
- /** Observable map of sessionName → current sourceTreeId */
3504
- l(this, "sourceTreeIds", this._sourceTreeIds);
3505
- /** Observable list of sessions from the daemon */
3506
- l(this, "sessions", this._sessions);
3507
- this.config = e, this.sessionName = e.sessionName, this._client = us("/__explorer/daemon-api");
3508
- }
3509
- /**
3510
- * Initializes the model: fetches initial session info and starts listening to events.
3511
- * Call this once after construction.
3512
- */
3513
- async initialize() {
3514
- await this._fetchSessionInfos(), this._startEventStream();
3515
- }
3516
- /**
3517
- * Get a screenshot for a fixture in a session, using cache when available.
3518
- * Cache is keyed on sessionName + fixtureId and invalidated when sourceTreeId changes.
3519
- */
3520
- async getScreenshot(e, t) {
3521
- const n = this._sourceTreeIds.get().get(e);
3522
- if (!n)
3523
- throw new Error(`No sourceTreeId known for session '${e}'`);
3524
- const r = `${e}:${t}`, i = this._screenshotCache.get(r);
3525
- if (i && i.sourceTreeId === n)
3526
- return i.data;
3527
- const o = await this._client.methods.screenshots.take({
3528
- fixtureId: t,
3529
- sessionName: e,
3530
- sourceTreeId: n,
3531
- includeImage: !0
3532
- });
3533
- return this._screenshotCache.set(r, { sourceTreeId: n, data: o }), o;
3534
- }
3535
- /**
3536
- * Compare a fixture across two sessions. Returns match status and hashes (no images).
3537
- */
3538
- async compare(e, t, n) {
3539
- const r = this._sourceTreeIds.get().get(t), i = this._sourceTreeIds.get().get(n);
3540
- if (!r || !i)
3541
- throw new Error("Missing sourceTreeId for sessions");
3542
- return this._client.methods.screenshots.compare({
3543
- fixtureId: e,
3544
- baselineSessionName: t,
3545
- baselineSourceTreeId: r,
3546
- currentSessionName: n,
3547
- currentSourceTreeId: i,
3548
- includeImages: !1
3549
- });
3550
- }
3551
- /**
3552
- * List fixtures from a session.
3553
- */
3554
- async listFixtures(e) {
3555
- const t = this._sourceTreeIds.get().get(e);
3556
- if (!t)
3557
- throw new Error(`No sourceTreeId known for session '${e}'`);
3558
- return this._client.methods.fixtures.list({ sessionName: e, sourceTreeId: t });
3559
- }
3560
- /**
3561
- * Get the explorer URL for a different session (for session switching via full navigation).
3562
- */
3563
- getSessionExplorerUrl(e) {
3564
- const t = this._sessions.get().find((n) => n.name === e);
3565
- if (t)
3566
- return t.serverUrl + "/___explorer";
3567
- }
3568
- dispose() {
3569
- var e;
3570
- (e = this._eventStreamAbort) == null || e.abort(), this._eventStreamAbort = null;
3571
- }
3572
- // ---------------------------------------------------------------------------
3573
- // Private
3574
- // ---------------------------------------------------------------------------
3575
- async _fetchSessionInfos() {
3576
- const e = await this._client.methods.sessions(), t = /* @__PURE__ */ new Map(), n = [];
3577
- for (const r of e)
3578
- t.set(r.name, r.sourceTreeId), n.push({ name: r.name, serverUrl: r.serverUrl });
3579
- this._sourceTreeIds.set(t, void 0), this._sessions.set(n, void 0);
3580
- }
3581
- async _startEventStream() {
3582
- this._eventStreamAbort = new AbortController();
3583
- const e = this._eventStreamAbort.signal;
3584
- try {
3585
- const t = await this._client.methods.events();
3586
- for await (const n of t) {
3587
- if (e.aborted) break;
3588
- this._handleEvent(n);
3589
- }
3590
- } catch (t) {
3591
- e.aborted || (console.error("[DaemonModel] Event stream error:", t), setTimeout(() => {
3592
- e.aborted || this._startEventStream();
3593
- }, 2e3));
3594
- }
3595
- }
3596
- _handleEvent(e) {
3597
- if (e.type === "source-change") {
3598
- const t = new Map(this._sourceTreeIds.get());
3599
- t.set(e.sessionName, e.sourceTreeId), this._sourceTreeIds.set(t, void 0);
3600
- for (const n of this._screenshotCache.keys())
3601
- n.startsWith(`${e.sessionName}:`) && this._screenshotCache.delete(n);
3602
- }
3603
- }
3604
- }
3605
- function ps() {
3606
- return window.__EXPLORER_DAEMON__;
3607
- }
3608
- class Is {
3609
- constructor(e, t) {
3610
- l(this, "_root");
3611
- l(this, "_registry", new it());
3612
- l(this, "_daemonModel");
3613
- this._populateRegistry(t), this._daemonModel = this._initializeDaemonModel(), this._root = yt(e), this._root.render(St(mt, { registry: this._registry, daemonModel: this._daemonModel }));
3614
- }
3615
- _initializeDaemonModel() {
3616
- const e = ps();
3617
- if (!e)
3618
- return;
3619
- const t = new fs(e);
3620
- return t.initialize().catch((n) => {
3621
- console.error("[ExplorerApp] Failed to initialize DaemonModel:", n);
3622
- }), t;
3623
- }
3624
- _populateRegistry(e) {
3625
- this._registry.clear();
3626
- for (const [t, n] of Object.entries(e)) {
3627
- const r = n.default;
3628
- r && typeof r == "object" && this._registry.register(t, r);
3629
- }
3630
- }
3631
- /**
3632
- * Updates the fixtures. The UI will update automatically since the registry is observable.
3633
- */
3634
- updateFixtures(e) {
3635
- this._populateRegistry(e);
3636
- }
3637
- /**
3638
- * No-op for ExplorerApp (only meaningful for CliRuntime).
3639
- * Present so the plugin's HMR wiring can call it polymorphically.
3640
- */
3641
- bumpVersion() {
3642
- }
3643
- /**
3644
- * Unmounts the explorer and cleans up resources.
3645
- */
3646
- dispose() {
3647
- var e;
3648
- (e = this._daemonModel) == null || e.dispose(), this._root.unmount();
3649
- }
3650
- }
1
+ import { _ as r } from "./runtimeVersion-BeD9fm3Y.js";
2
+ import { d as s, a as n, b as t, f as u, c as f, r as o, s as d } from "./runtimeVersion-BeD9fm3Y.js";
3
+ globalThis._buildInfo = r;
3651
4
  export {
3652
- Sn as ChevronDownIcon,
3653
- wn as ChevronRightIcon,
3654
- ws as CliRuntime,
3655
- In as ComponentIcon,
3656
- fs as DaemonModel,
3657
- mt as Explorer,
3658
- Is as ExplorerApp,
3659
- Cn as ExplorerModel,
3660
- Ss as ExplorerWithDefaults,
3661
- it as FixtureRegistry,
3662
- On as FolderIcon,
3663
- Fn as LeftSidebar,
3664
- Nn as MoonIcon,
3665
- Tn as PanelLeftIcon,
3666
- Rn as PanelRightIcon,
3667
- Hn as RightSidebar,
3668
- Vn as SunIcon,
3669
- Dn as TitleBar,
3670
- de as TitleBarButton,
3671
- Mn as TreeItem,
3672
- at as TreeView,
3673
- It as VIEWPORT_SIZES,
3674
- At as collectComponents,
3675
- ce as createFixtureTree,
3676
- ee as defineFixture,
3677
- Cs as defineFixtureGroup,
3678
- xs as defineFixtureVariants,
3679
- Oe as findNodeByPath,
3680
- Tt as getDefaultPropertyValues,
3681
- ys as isComponentDefinition,
3682
- Vt as isFixtureGroup,
3683
- Nt as isFixtureVariants,
3684
- Rt as isSingleFixture,
3685
- Se as mergeStyles,
3686
- Ot as resolveViewport,
3687
- u as styles,
3688
- ot as toExplorerTree
5
+ s as defineFixture,
6
+ n as defineFixtureGroup,
7
+ t as defineFixtureVariants,
8
+ u as fixtureGroupBrand,
9
+ f as fixtureVariantsBrand,
10
+ o as runtimeVersion,
11
+ d as singleFixtureBrand
3689
12
  };
3690
13
  //# sourceMappingURL=index.js.map