@epoch32/visage 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +55 -4085
- package/dist/charts/index.js +48 -2806
- package/dist/devtools/index.js +18 -4766
- package/dist/dom/index.js +32 -1639
- package/dist/form/index.js +13 -1498
- package/dist/index-061jf06a.js +848 -0
- package/dist/index-0madxn60.js +442 -0
- package/dist/index-1xtrtz1t.js +256 -0
- package/dist/index-2zz0g2n2.js +212 -0
- package/dist/index-5s255b3w.js +303 -0
- package/dist/index-6kfe1nr4.js +1179 -0
- package/dist/index-8czhpea8.js +338 -0
- package/dist/index-8x8xz80v.js +727 -0
- package/dist/index-921pn75b.js +0 -0
- package/dist/index-965ryh36.js +537 -0
- package/dist/index-9fvarkrx.js +98 -0
- package/dist/index-a4xns6cc.js +219 -0
- package/dist/index-b5wc752a.js +1696 -0
- package/dist/index-df5e614s.js +334 -0
- package/dist/index-dyvgtp43.js +1094 -0
- package/dist/index-grhdtcb5.js +234 -0
- package/dist/index-h6tjqk6e.js +158 -0
- package/dist/index-js199er4.js +101 -0
- package/dist/index-x2rs3vab.js +124 -0
- package/dist/index-y9bq7h9g.js +1162 -0
- package/dist/index-zr6cvset.js +2092 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +458 -11915
- package/dist/jsx-runtime/index.js +13 -1719
- package/dist/query/index.js +47 -2505
- package/dist/router/index.js +25 -1945
- package/dist/rpc/index.js +39 -3567
- package/dist/server/index.js +11 -1256
- package/dist/signals/index.js +52 -1160
- package/dist/style/index.js +77 -2429
- package/dist/template/index.js +7 -1232
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +150 -4244
- package/dist/ui/tabs.d.ts +23 -1
- package/dist/virtual/index.js +12 -2044
- package/dist/vite/index.js +5 -744
- package/package.json +2 -2
- package/src/dom/render.ts +20 -7
- package/src/index.ts +2 -0
- package/src/signals/computed.ts +19 -12
- package/src/signals/context.ts +1 -2
- package/src/signals/effect.ts +7 -7
- package/src/signals/signal.ts +16 -12
- package/src/signals/system.ts +50 -21
- package/src/ui/index.ts +2 -0
- package/src/ui/tabs.tsx +211 -5
- package/src/ui/utils.ts +1 -3
package/dist/devtools/index.js
CHANGED
|
@@ -1,4768 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// src/signals/system.ts
|
|
16
|
-
var currentSubscriber = null;
|
|
17
|
-
var currentScope = null;
|
|
18
|
-
var batchDepth = 0;
|
|
19
|
-
var pendingEffects = new Set;
|
|
20
|
-
var warnedCyclicSubscribers = new WeakSet;
|
|
21
|
-
var isFlushing = false;
|
|
22
|
-
function setCurrentSubscriber(sub) {
|
|
23
|
-
currentSubscriber = sub;
|
|
24
|
-
}
|
|
25
|
-
function setCurrentScope(scope) {
|
|
26
|
-
currentScope = scope;
|
|
27
|
-
}
|
|
28
|
-
function getCurrentScope() {
|
|
29
|
-
return currentScope;
|
|
30
|
-
}
|
|
31
|
-
function addPendingEffect(eff) {
|
|
32
|
-
pendingEffects.add(eff);
|
|
33
|
-
}
|
|
34
|
-
function removePendingEffect(eff) {
|
|
35
|
-
pendingEffects.delete(eff);
|
|
36
|
-
}
|
|
37
|
-
var MAX_FLUSH_COUNT = 100;
|
|
38
|
-
function flushEffects() {
|
|
39
|
-
if (isFlushing || batchDepth > 0)
|
|
40
|
-
return;
|
|
41
|
-
isFlushing = true;
|
|
42
|
-
let iterations = 0;
|
|
43
|
-
try {
|
|
44
|
-
while (pendingEffects.size > 0) {
|
|
45
|
-
if (++iterations > MAX_FLUSH_COUNT) {
|
|
46
|
-
pendingEffects.clear();
|
|
47
|
-
throw new Error(`[Visage Reactivity] Maximum update depth exceeded (${MAX_FLUSH_COUNT} cycles). ` + `An effect continuously triggered state mutations (infinite loop detected). ` + `Ensure effects that modify signals do not unconditionally depend on them, or use untrack() to read state.`);
|
|
48
|
-
}
|
|
49
|
-
const effectsToRun = Array.from(pendingEffects);
|
|
50
|
-
pendingEffects.clear();
|
|
51
|
-
for (const eff of effectsToRun) {
|
|
52
|
-
if (eff.state === 2 /* DIRTY */ || eff.state === 1 /* CHECK_DIRTY */) {
|
|
53
|
-
eff.run();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} finally {
|
|
58
|
-
isFlushing = false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function batch(fn) {
|
|
62
|
-
batchDepth++;
|
|
63
|
-
try {
|
|
64
|
-
return fn();
|
|
65
|
-
} finally {
|
|
66
|
-
batchDepth--;
|
|
67
|
-
if (batchDepth === 0) {
|
|
68
|
-
flushEffects();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function untrack(fn) {
|
|
73
|
-
const prev = currentSubscriber;
|
|
74
|
-
currentSubscriber = null;
|
|
75
|
-
try {
|
|
76
|
-
return fn();
|
|
77
|
-
} finally {
|
|
78
|
-
currentSubscriber = prev;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/signals/computed.ts
|
|
83
|
-
class Computed {
|
|
84
|
-
[COMPUTED_BRAND] = true;
|
|
85
|
-
_fn;
|
|
86
|
-
_value;
|
|
87
|
-
_subscribers = new Set;
|
|
88
|
-
sources = new Set;
|
|
89
|
-
sourceVersions = new Map;
|
|
90
|
-
state = 2 /* DIRTY */;
|
|
91
|
-
scope;
|
|
92
|
-
version = 0;
|
|
93
|
-
constructor(fn) {
|
|
94
|
-
this._fn = fn;
|
|
95
|
-
this.scope = currentScope;
|
|
96
|
-
if (currentScope) {
|
|
97
|
-
currentScope.addSubscriber(this);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
get() {
|
|
101
|
-
if (this.state === 3 /* DISPOSED */) {
|
|
102
|
-
return this._fn();
|
|
103
|
-
}
|
|
104
|
-
if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
|
|
105
|
-
this._subscribers.add(currentSubscriber);
|
|
106
|
-
currentSubscriber.sources.add(this);
|
|
107
|
-
currentSubscriber.sourceVersions.set(this, this.version);
|
|
108
|
-
}
|
|
109
|
-
if (this.state === 2 /* DIRTY */ || this.state === 1 /* CHECK_DIRTY */) {
|
|
110
|
-
this.updateIfNecessary();
|
|
111
|
-
}
|
|
112
|
-
return this._value;
|
|
113
|
-
}
|
|
114
|
-
get value() {
|
|
115
|
-
return this.get();
|
|
116
|
-
}
|
|
117
|
-
removeSubscriber(sub) {
|
|
118
|
-
this._subscribers.delete(sub);
|
|
119
|
-
}
|
|
120
|
-
markDirty(targetState = 1 /* CHECK_DIRTY */) {
|
|
121
|
-
if (this.state >= targetState || this.state === 3 /* DISPOSED */) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this.state = targetState;
|
|
125
|
-
for (const sub of this._subscribers) {
|
|
126
|
-
sub.markDirty(1 /* CHECK_DIRTY */);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
updateIfNecessary() {
|
|
130
|
-
if (this.state === 2 /* DIRTY */) {
|
|
131
|
-
const prev = this._value;
|
|
132
|
-
this.recompute();
|
|
133
|
-
return !Object.is(prev, this._value);
|
|
134
|
-
}
|
|
135
|
-
if (this.state === 1 /* CHECK_DIRTY */) {
|
|
136
|
-
let anyChanged = false;
|
|
137
|
-
for (const source of this.sources) {
|
|
138
|
-
if (source instanceof Computed) {
|
|
139
|
-
source.updateIfNecessary();
|
|
140
|
-
}
|
|
141
|
-
const lastVersion = this.sourceVersions.get(source);
|
|
142
|
-
if (lastVersion !== undefined && lastVersion !== source.version) {
|
|
143
|
-
anyChanged = true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (anyChanged) {
|
|
147
|
-
const prev = this._value;
|
|
148
|
-
this.recompute();
|
|
149
|
-
return !Object.is(prev, this._value);
|
|
150
|
-
}
|
|
151
|
-
this.state = 0 /* CLEAN */;
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
recompute() {
|
|
157
|
-
this.cleanupSources();
|
|
158
|
-
const prevSubscriber = currentSubscriber;
|
|
159
|
-
setCurrentSubscriber(this);
|
|
160
|
-
const prevScope = currentScope;
|
|
161
|
-
setCurrentScope(this.scope);
|
|
162
|
-
try {
|
|
163
|
-
const next = this._fn();
|
|
164
|
-
if (!Object.is(this._value, next)) {
|
|
165
|
-
this._value = next;
|
|
166
|
-
this.version++;
|
|
167
|
-
}
|
|
168
|
-
this.state = 0 /* CLEAN */;
|
|
169
|
-
} finally {
|
|
170
|
-
setCurrentSubscriber(prevSubscriber);
|
|
171
|
-
setCurrentScope(prevScope);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
cleanupSources() {
|
|
175
|
-
for (const source of this.sources) {
|
|
176
|
-
source.removeSubscriber(this);
|
|
177
|
-
}
|
|
178
|
-
this.sources.clear();
|
|
179
|
-
this.sourceVersions.clear();
|
|
180
|
-
}
|
|
181
|
-
dispose() {
|
|
182
|
-
if (this.state === 3 /* DISPOSED */)
|
|
183
|
-
return;
|
|
184
|
-
this.state = 3 /* DISPOSED */;
|
|
185
|
-
this.cleanupSources();
|
|
186
|
-
this._subscribers.clear();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function computed(fn, options) {
|
|
190
|
-
const isInternal = options?.internal ?? false;
|
|
191
|
-
const customName = options?.name;
|
|
192
|
-
const c = new Computed(fn);
|
|
193
|
-
const accessor = () => c.get();
|
|
194
|
-
Object.defineProperties(accessor, {
|
|
195
|
-
[COMPUTED_BRAND]: { value: true },
|
|
196
|
-
get: { value: () => c.get() },
|
|
197
|
-
value: { get: () => c.get() }
|
|
198
|
-
});
|
|
199
|
-
if (!isInternal && typeof window !== "undefined" && window.__VISAGE_DEVTOOLS__) {
|
|
200
|
-
const devtools = window.__VISAGE_DEVTOOLS__;
|
|
201
|
-
const sigId = devtools.registerSignal({
|
|
202
|
-
name: customName,
|
|
203
|
-
type: "computed",
|
|
204
|
-
getValue: () => c.get(),
|
|
205
|
-
version: () => c.version,
|
|
206
|
-
subscribersCount: () => c._subscribers?.size ?? 0,
|
|
207
|
-
dependencies: () => Array.from(c.sources ?? []).map((src) => src._devId).filter(Boolean),
|
|
208
|
-
dependents: () => Array.from(c._subscribers ?? []).map((sub) => sub._devId).filter(Boolean)
|
|
209
|
-
});
|
|
210
|
-
c._devId = sigId;
|
|
211
|
-
if (currentScope) {
|
|
212
|
-
currentScope.addCleanup(() => {
|
|
213
|
-
devtools.unregisterSignal(sigId);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return accessor;
|
|
218
|
-
}
|
|
219
|
-
var createMemo = computed;
|
|
220
|
-
// src/style/cx.ts
|
|
221
|
-
function hasReactiveClass(val) {
|
|
222
|
-
if (typeof val === "function")
|
|
223
|
-
return true;
|
|
224
|
-
if (Array.isArray(val)) {
|
|
225
|
-
for (let i = 0;i < val.length; i++) {
|
|
226
|
-
if (hasReactiveClass(val[i]))
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
if (typeof val === "object" && val !== null) {
|
|
232
|
-
for (const k in val) {
|
|
233
|
-
if (typeof val[k] === "function")
|
|
234
|
-
return true;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
function normalizeClass(val) {
|
|
240
|
-
if (!val)
|
|
241
|
-
return "";
|
|
242
|
-
if (typeof val === "function")
|
|
243
|
-
return normalizeClass(val());
|
|
244
|
-
if (typeof val === "string")
|
|
245
|
-
return val.trim();
|
|
246
|
-
if (typeof val === "number")
|
|
247
|
-
return String(val);
|
|
248
|
-
if (Array.isArray(val)) {
|
|
249
|
-
let res = "";
|
|
250
|
-
for (let i = 0;i < val.length; i++) {
|
|
251
|
-
const item = typeof val[i] === "function" ? val[i]() : val[i];
|
|
252
|
-
const itemStr = normalizeClass(item);
|
|
253
|
-
if (itemStr) {
|
|
254
|
-
res = res ? `${res} ${itemStr}` : itemStr;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return res;
|
|
258
|
-
}
|
|
259
|
-
if (typeof val === "object") {
|
|
260
|
-
let res = "";
|
|
261
|
-
for (const key in val) {
|
|
262
|
-
const condition = typeof val[key] === "function" ? val[key]() : val[key];
|
|
263
|
-
if (condition) {
|
|
264
|
-
res = res ? `${res} ${key}` : key;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return res;
|
|
268
|
-
}
|
|
269
|
-
return "";
|
|
270
|
-
}
|
|
271
|
-
function cx(...args) {
|
|
272
|
-
return normalizeClass(args);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/style/scale.ts
|
|
276
|
-
var UNITLESS_PROPERTIES = new Set([
|
|
277
|
-
"animationIterationCount",
|
|
278
|
-
"aspectRatio",
|
|
279
|
-
"borderImageSlice",
|
|
280
|
-
"columnCount",
|
|
281
|
-
"columns",
|
|
282
|
-
"flex",
|
|
283
|
-
"flexGrow",
|
|
284
|
-
"flexShrink",
|
|
285
|
-
"flexOrder",
|
|
286
|
-
"fontWeight",
|
|
287
|
-
"lineHeight",
|
|
288
|
-
"opacity",
|
|
289
|
-
"order",
|
|
290
|
-
"orphans",
|
|
291
|
-
"scale",
|
|
292
|
-
"tabSize",
|
|
293
|
-
"widows",
|
|
294
|
-
"zIndex",
|
|
295
|
-
"zoom",
|
|
296
|
-
"fillOpacity",
|
|
297
|
-
"strokeOpacity"
|
|
298
|
-
]);
|
|
299
|
-
var DIMENSION_KEYWORDS = {
|
|
300
|
-
screen: "100dvh",
|
|
301
|
-
"screen-h": "100dvh",
|
|
302
|
-
"screen-w": "100dvw",
|
|
303
|
-
full: "100%",
|
|
304
|
-
half: "50%",
|
|
305
|
-
third: "33.333333%",
|
|
306
|
-
"two-thirds": "66.666667%",
|
|
307
|
-
quarter: "25%",
|
|
308
|
-
"three-quarters": "75%",
|
|
309
|
-
auto: "auto",
|
|
310
|
-
min: "min-content",
|
|
311
|
-
max: "max-content",
|
|
312
|
-
fit: "fit-content"
|
|
313
|
-
};
|
|
314
|
-
function space(val) {
|
|
315
|
-
if (val === undefined || val === null || val === "")
|
|
316
|
-
return "";
|
|
317
|
-
if (typeof val === "number") {
|
|
318
|
-
if (val === 0)
|
|
319
|
-
return "0px";
|
|
320
|
-
return `${val * 4}px`;
|
|
321
|
-
}
|
|
322
|
-
const str = String(val).trim();
|
|
323
|
-
if (str in DIMENSION_KEYWORDS) {
|
|
324
|
-
return DIMENSION_KEYWORDS[str];
|
|
325
|
-
}
|
|
326
|
-
return str;
|
|
327
|
-
}
|
|
328
|
-
function resolveDimension(val) {
|
|
329
|
-
if (val === undefined || val === null || val === "")
|
|
330
|
-
return "";
|
|
331
|
-
if (typeof val === "number") {
|
|
332
|
-
if (val === 0)
|
|
333
|
-
return "0px";
|
|
334
|
-
if (val > 48)
|
|
335
|
-
return `${val}px`;
|
|
336
|
-
return `${val * 4}px`;
|
|
337
|
-
}
|
|
338
|
-
const str = String(val).trim();
|
|
339
|
-
if (str in DIMENSION_KEYWORDS) {
|
|
340
|
-
return DIMENSION_KEYWORDS[str];
|
|
341
|
-
}
|
|
342
|
-
return str;
|
|
343
|
-
}
|
|
344
|
-
function px(val) {
|
|
345
|
-
return `${val}px`;
|
|
346
|
-
}
|
|
347
|
-
function rem(val) {
|
|
348
|
-
return `${val}rem`;
|
|
349
|
-
}
|
|
350
|
-
function em(val) {
|
|
351
|
-
return `${val}em`;
|
|
352
|
-
}
|
|
353
|
-
function fluid(minPx, maxPx, options) {
|
|
354
|
-
const minVw = options?.minVw ?? 375;
|
|
355
|
-
const maxVw = options?.maxVw ?? 1280;
|
|
356
|
-
const slope = (maxPx - minPx) / (maxVw - minVw);
|
|
357
|
-
const yIntercept = -minVw * slope + minPx;
|
|
358
|
-
const slopeVw = slope * 100;
|
|
359
|
-
const preferred = `${yIntercept.toFixed(2)}px + ${slopeVw.toFixed(2)}vw`;
|
|
360
|
-
const min = Math.min(minPx, maxPx);
|
|
361
|
-
const max = Math.max(minPx, maxPx);
|
|
362
|
-
return `clamp(${min}px, ${preferred}, ${max}px)`;
|
|
363
|
-
}
|
|
364
|
-
var SHADOW_PRESETS = {
|
|
365
|
-
none: "none",
|
|
366
|
-
sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
367
|
-
md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
368
|
-
lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
369
|
-
xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
|
|
370
|
-
soft: "0 8px 30px rgba(0, 0, 0, 0.06)",
|
|
371
|
-
glow: "0 0 24px rgba(168, 85, 247, 0.35)",
|
|
372
|
-
inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"
|
|
373
|
-
};
|
|
374
|
-
function shadow(variant) {
|
|
375
|
-
if (variant in SHADOW_PRESETS) {
|
|
376
|
-
return SHADOW_PRESETS[variant];
|
|
377
|
-
}
|
|
378
|
-
return variant;
|
|
379
|
-
}
|
|
380
|
-
var RADIUS_PRESETS = {
|
|
381
|
-
none: "0px",
|
|
382
|
-
sm: "4px",
|
|
383
|
-
md: "8px",
|
|
384
|
-
lg: "12px",
|
|
385
|
-
xl: "16px",
|
|
386
|
-
"2xl": "20px",
|
|
387
|
-
"3xl": "24px",
|
|
388
|
-
full: "9999px"
|
|
389
|
-
};
|
|
390
|
-
function radius(variant) {
|
|
391
|
-
if (typeof variant === "number") {
|
|
392
|
-
return `${variant}px`;
|
|
393
|
-
}
|
|
394
|
-
if (variant in RADIUS_PRESETS) {
|
|
395
|
-
return RADIUS_PRESETS[variant];
|
|
396
|
-
}
|
|
397
|
-
return String(variant);
|
|
398
|
-
}
|
|
399
|
-
function glass(options = {}) {
|
|
400
|
-
const blurVal = typeof options.blur === "number" ? `${options.blur}px` : options.blur ?? "20px";
|
|
401
|
-
const tintVal = options.tint ?? "rgba(255, 255, 255, 0.65)";
|
|
402
|
-
const borderVal = options.border ?? "1px solid rgba(255, 255, 255, 0.75)";
|
|
403
|
-
return {
|
|
404
|
-
backdropFilter: `blur(${blurVal})`,
|
|
405
|
-
WebkitBackdropFilter: `blur(${blurVal})`,
|
|
406
|
-
backgroundColor: tintVal,
|
|
407
|
-
border: borderVal
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
function formatStyleProp(prop, val) {
|
|
411
|
-
if (val === null || val === undefined || val === "")
|
|
412
|
-
return "";
|
|
413
|
-
if (typeof val === "number") {
|
|
414
|
-
if (val === 0 || UNITLESS_PROPERTIES.has(prop)) {
|
|
415
|
-
return String(val);
|
|
416
|
-
}
|
|
417
|
-
return `${val}px`;
|
|
418
|
-
}
|
|
419
|
-
const str = String(val).trim();
|
|
420
|
-
if (str in DIMENSION_KEYWORDS) {
|
|
421
|
-
const lowerProp = prop.toLowerCase();
|
|
422
|
-
if (str === "screen") {
|
|
423
|
-
if (lowerProp.includes("width"))
|
|
424
|
-
return "100dvw";
|
|
425
|
-
return "100dvh";
|
|
426
|
-
}
|
|
427
|
-
return DIMENSION_KEYWORDS[str];
|
|
428
|
-
}
|
|
429
|
-
return str;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// src/dom/render.ts
|
|
433
|
-
function isReactive(value) {
|
|
434
|
-
return isSignal(value) || typeof value === "function";
|
|
435
|
-
}
|
|
436
|
-
function resolveValue(val) {
|
|
437
|
-
if (typeof val === "function") {
|
|
438
|
-
return val();
|
|
439
|
-
}
|
|
440
|
-
return val;
|
|
441
|
-
}
|
|
442
|
-
function render(fn, container) {
|
|
443
|
-
return createRoot((dispose) => {
|
|
444
|
-
container.textContent = "";
|
|
445
|
-
const node = insertChild(container, fn());
|
|
446
|
-
onCleanup(() => {
|
|
447
|
-
if (node && node instanceof Node && node.parentNode === container) {
|
|
448
|
-
container.removeChild(node);
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
return dispose;
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
function setAttribute(el, key, value) {
|
|
455
|
-
if (key.startsWith("on") && typeof value === "function") {
|
|
456
|
-
const eventName = key.startsWith("onCapture") ? key.slice(9).toLowerCase() : key.slice(2).toLowerCase();
|
|
457
|
-
const useCapture = key.startsWith("onCapture");
|
|
458
|
-
el.addEventListener(eventName, value, useCapture);
|
|
459
|
-
onCleanup(() => {
|
|
460
|
-
el.removeEventListener(eventName, value, useCapture);
|
|
461
|
-
});
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
if (key === "ref" && typeof value === "function") {
|
|
465
|
-
value(el);
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
if (key === "class" || key === "className") {
|
|
469
|
-
if (hasReactiveClass(value)) {
|
|
470
|
-
effect(() => {
|
|
471
|
-
const cls = normalizeClass(value);
|
|
472
|
-
if (cls)
|
|
473
|
-
el.setAttribute("class", cls);
|
|
474
|
-
else
|
|
475
|
-
el.removeAttribute("class");
|
|
476
|
-
});
|
|
477
|
-
} else {
|
|
478
|
-
const cls = normalizeClass(value);
|
|
479
|
-
if (cls)
|
|
480
|
-
el.setAttribute("class", cls);
|
|
481
|
-
else
|
|
482
|
-
el.removeAttribute("class");
|
|
483
|
-
}
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
if (isReactive(value)) {
|
|
487
|
-
effect(() => {
|
|
488
|
-
const resolved = resolveValue(value);
|
|
489
|
-
applyProp(el, key, resolved);
|
|
490
|
-
});
|
|
491
|
-
} else {
|
|
492
|
-
applyProp(el, key, value);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function setStyleProperty(el, prop, val) {
|
|
496
|
-
const formatted = formatStyleProp(prop, val);
|
|
497
|
-
if (prop.startsWith("--") || prop.includes("-")) {
|
|
498
|
-
if (formatted === "") {
|
|
499
|
-
el.style.removeProperty(prop);
|
|
500
|
-
} else {
|
|
501
|
-
el.style.setProperty(prop, formatted);
|
|
502
|
-
}
|
|
503
|
-
} else {
|
|
504
|
-
el.style[prop] = formatted;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
function applyProp(el, key, value) {
|
|
508
|
-
if (value === null || value === undefined || value === false && !key.startsWith("aria-") && !key.startsWith("data-")) {
|
|
509
|
-
if (key === "className" || key === "class") {
|
|
510
|
-
el.removeAttribute("class");
|
|
511
|
-
} else if (key === "style" && typeof value === "string") {
|
|
512
|
-
el.removeAttribute("style");
|
|
513
|
-
} else if (key in el && !(el instanceof SVGElement)) {
|
|
514
|
-
try {
|
|
515
|
-
el[key] = typeof el[key] === "boolean" ? false : "";
|
|
516
|
-
} catch {
|
|
517
|
-
el.removeAttribute(key);
|
|
518
|
-
}
|
|
519
|
-
} else {
|
|
520
|
-
el.removeAttribute(key);
|
|
521
|
-
}
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
if (key === "className" || key === "class") {
|
|
525
|
-
const cls = normalizeClass(value);
|
|
526
|
-
if (cls) {
|
|
527
|
-
el.setAttribute("class", cls);
|
|
528
|
-
} else {
|
|
529
|
-
el.removeAttribute("class");
|
|
530
|
-
}
|
|
531
|
-
} else if (key === "style") {
|
|
532
|
-
if (typeof value === "string") {
|
|
533
|
-
el.setAttribute("style", value);
|
|
534
|
-
} else if (typeof value === "object" && value !== null) {
|
|
535
|
-
for (const styleKey in value) {
|
|
536
|
-
const styleVal = value[styleKey];
|
|
537
|
-
if (isReactive(styleVal)) {
|
|
538
|
-
effect(() => {
|
|
539
|
-
setStyleProperty(el, styleKey, resolveValue(styleVal));
|
|
540
|
-
});
|
|
541
|
-
} else {
|
|
542
|
-
setStyleProperty(el, styleKey, styleVal);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
} else if (key === "dangerouslySetInnerHTML" && value && typeof value.__html === "string") {
|
|
547
|
-
el.innerHTML = value.__html;
|
|
548
|
-
} else if (key in el && !(el instanceof SVGElement) && key !== "list" && key !== "form") {
|
|
549
|
-
try {
|
|
550
|
-
el[key] = value;
|
|
551
|
-
} catch {
|
|
552
|
-
el.setAttribute(key, String(value));
|
|
553
|
-
}
|
|
554
|
-
} else {
|
|
555
|
-
if (key.startsWith("aria-") || key.startsWith("data-")) {
|
|
556
|
-
el.setAttribute(key, String(value));
|
|
557
|
-
} else if (value === true) {
|
|
558
|
-
el.setAttribute(key, "");
|
|
559
|
-
} else {
|
|
560
|
-
el.setAttribute(key, String(value));
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function insertChild(parent, child, before = null) {
|
|
565
|
-
if (child === null || child === undefined || child === false || child === true) {
|
|
566
|
-
return null;
|
|
567
|
-
}
|
|
568
|
-
if (child instanceof Node) {
|
|
569
|
-
parent.insertBefore(child, before);
|
|
570
|
-
return child;
|
|
571
|
-
}
|
|
572
|
-
if (Array.isArray(child)) {
|
|
573
|
-
const fragment = document.createDocumentFragment();
|
|
574
|
-
for (const item of child) {
|
|
575
|
-
insertChild(fragment, item);
|
|
576
|
-
}
|
|
577
|
-
parent.insertBefore(fragment, before);
|
|
578
|
-
return fragment;
|
|
579
|
-
}
|
|
580
|
-
if (isReactive(child)) {
|
|
581
|
-
const marker = document.createTextNode("");
|
|
582
|
-
parent.insertBefore(marker, before);
|
|
583
|
-
let childScope = null;
|
|
584
|
-
let currentNodes = [];
|
|
585
|
-
effect(() => {
|
|
586
|
-
const resolved = resolveValue(child);
|
|
587
|
-
if ((typeof resolved === "string" || typeof resolved === "number") && currentNodes.length === 1 && currentNodes[0].nodeType === Node.TEXT_NODE) {
|
|
588
|
-
currentNodes[0].data = String(resolved);
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
if (childScope) {
|
|
592
|
-
childScope.dispose();
|
|
593
|
-
}
|
|
594
|
-
childScope = new Scope(getActiveScope());
|
|
595
|
-
runInScope(childScope, () => {
|
|
596
|
-
for (const node of currentNodes) {
|
|
597
|
-
if (node.parentNode) {
|
|
598
|
-
node.parentNode.removeChild(node);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
currentNodes = [];
|
|
602
|
-
if (resolved === null || resolved === undefined || resolved === false) {
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
const frag = document.createDocumentFragment();
|
|
606
|
-
if (typeof resolved === "string" || typeof resolved === "number" || typeof resolved === "boolean") {
|
|
607
|
-
frag.appendChild(document.createTextNode(String(resolved)));
|
|
608
|
-
} else {
|
|
609
|
-
insertChild(frag, resolved);
|
|
610
|
-
}
|
|
611
|
-
currentNodes = Array.from(frag.childNodes);
|
|
612
|
-
if (marker.parentNode) {
|
|
613
|
-
marker.parentNode.insertBefore(frag, marker);
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
onCleanup(() => {
|
|
618
|
-
if (childScope) {
|
|
619
|
-
childScope.dispose();
|
|
620
|
-
}
|
|
621
|
-
for (const node of currentNodes) {
|
|
622
|
-
if (node.parentNode) {
|
|
623
|
-
node.parentNode.removeChild(node);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
if (marker.parentNode) {
|
|
627
|
-
marker.parentNode.removeChild(marker);
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
return marker;
|
|
631
|
-
}
|
|
632
|
-
const textNode = document.createTextNode(String(child));
|
|
633
|
-
parent.insertBefore(textNode, before);
|
|
634
|
-
return textNode;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
// src/signals/scope.ts
|
|
638
|
-
class Scope {
|
|
639
|
-
subscribers = new Set;
|
|
640
|
-
cleanups = [];
|
|
641
|
-
parent = null;
|
|
642
|
-
isDisposed = false;
|
|
643
|
-
context;
|
|
644
|
-
constructor(parent = currentScope) {
|
|
645
|
-
this.parent = parent;
|
|
646
|
-
if (parent && !parent.isDisposed) {
|
|
647
|
-
parent.cleanups.push(() => this.dispose());
|
|
648
|
-
if (parent.context) {
|
|
649
|
-
this.context = new Map(parent.context);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
addSubscriber(sub) {
|
|
654
|
-
if (this.isDisposed)
|
|
655
|
-
return;
|
|
656
|
-
this.subscribers.add(sub);
|
|
657
|
-
}
|
|
658
|
-
addCleanup(fn) {
|
|
659
|
-
if (this.isDisposed) {
|
|
660
|
-
fn();
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
this.cleanups.push(fn);
|
|
664
|
-
}
|
|
665
|
-
dispose() {
|
|
666
|
-
if (this.isDisposed)
|
|
667
|
-
return;
|
|
668
|
-
this.isDisposed = true;
|
|
669
|
-
for (const sub of this.subscribers) {
|
|
670
|
-
sub.dispose();
|
|
671
|
-
}
|
|
672
|
-
this.subscribers.clear();
|
|
673
|
-
for (let i = this.cleanups.length - 1;i >= 0; i--) {
|
|
674
|
-
try {
|
|
675
|
-
this.cleanups[i]();
|
|
676
|
-
} catch (err) {
|
|
677
|
-
console.error("Error during cleanup:", err);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
this.cleanups = [];
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
function onCleanup(fn) {
|
|
684
|
-
if (currentSubscriber && "addCleanup" in currentSubscriber) {
|
|
685
|
-
currentSubscriber.addCleanup(fn);
|
|
686
|
-
} else if (currentScope) {
|
|
687
|
-
currentScope.addCleanup(fn);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
function createRoot(fn) {
|
|
691
|
-
const prevScope = currentScope;
|
|
692
|
-
const scope = new Scope(null);
|
|
693
|
-
setCurrentScope(scope);
|
|
694
|
-
try {
|
|
695
|
-
return fn(() => scope.dispose());
|
|
696
|
-
} finally {
|
|
697
|
-
setCurrentScope(prevScope);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
function runInScope(scope, fn) {
|
|
701
|
-
const prevScope = currentScope;
|
|
702
|
-
setCurrentScope(scope);
|
|
703
|
-
try {
|
|
704
|
-
return fn();
|
|
705
|
-
} finally {
|
|
706
|
-
setCurrentScope(prevScope);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
function getActiveScope() {
|
|
710
|
-
return getCurrentScope();
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/signals/context.ts
|
|
714
|
-
function createContext(defaultValue) {
|
|
715
|
-
const id = Symbol("visage.context");
|
|
716
|
-
const context = {
|
|
717
|
-
id,
|
|
718
|
-
defaultValue,
|
|
719
|
-
Provider: (props) => {
|
|
720
|
-
const parentScope = getActiveScope();
|
|
721
|
-
const scope = new Scope(parentScope);
|
|
722
|
-
if (!scope.context) {
|
|
723
|
-
scope.context = new Map(parentScope?.context);
|
|
724
|
-
}
|
|
725
|
-
scope.context.set(id, props.value);
|
|
726
|
-
return runInScope(scope, () => {
|
|
727
|
-
const content = typeof props.children === "function" ? untrack(() => props.children()) : props.children;
|
|
728
|
-
if (typeof document !== "undefined") {
|
|
729
|
-
const frag = document.createDocumentFragment();
|
|
730
|
-
insertChild(frag, content);
|
|
731
|
-
return frag;
|
|
732
|
-
}
|
|
733
|
-
return content;
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
return context;
|
|
738
|
-
}
|
|
739
|
-
function useContext(context) {
|
|
740
|
-
let scope = getActiveScope();
|
|
741
|
-
while (scope) {
|
|
742
|
-
if (scope.context?.has(context.id)) {
|
|
743
|
-
return scope.context.get(context.id);
|
|
744
|
-
}
|
|
745
|
-
scope = scope.parent;
|
|
746
|
-
}
|
|
747
|
-
return context.defaultValue;
|
|
748
|
-
}
|
|
749
|
-
// src/signals/effect.ts
|
|
750
|
-
class Effect {
|
|
751
|
-
_fn;
|
|
752
|
-
sources = new Set;
|
|
753
|
-
sourceVersions = new Map;
|
|
754
|
-
cleanups = [];
|
|
755
|
-
state = 2 /* DIRTY */;
|
|
756
|
-
scope;
|
|
757
|
-
constructor(fn) {
|
|
758
|
-
this._fn = fn;
|
|
759
|
-
this.scope = currentScope;
|
|
760
|
-
if (currentScope) {
|
|
761
|
-
currentScope.addSubscriber(this);
|
|
762
|
-
}
|
|
763
|
-
this.run();
|
|
764
|
-
}
|
|
765
|
-
addCleanup(fn) {
|
|
766
|
-
this.cleanups.push(fn);
|
|
767
|
-
}
|
|
768
|
-
runCleanups() {
|
|
769
|
-
for (let i = this.cleanups.length - 1;i >= 0; i--) {
|
|
770
|
-
try {
|
|
771
|
-
this.cleanups[i]();
|
|
772
|
-
} catch (e) {
|
|
773
|
-
console.error("Error in effect cleanup:", e);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
this.cleanups = [];
|
|
777
|
-
}
|
|
778
|
-
markDirty(targetState = 2 /* DIRTY */) {
|
|
779
|
-
if (this.state >= targetState || this.state === 3 /* DISPOSED */) {
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
this.state = targetState;
|
|
783
|
-
addPendingEffect(this);
|
|
784
|
-
if (batchDepth === 0) {
|
|
785
|
-
flushEffects();
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
run() {
|
|
789
|
-
if (this.state === 3 /* DISPOSED */)
|
|
790
|
-
return;
|
|
791
|
-
if (this.state === 1 /* CHECK_DIRTY */) {
|
|
792
|
-
let isDirty = false;
|
|
793
|
-
for (const source of this.sources) {
|
|
794
|
-
if (source instanceof Computed) {
|
|
795
|
-
source.updateIfNecessary();
|
|
796
|
-
}
|
|
797
|
-
const lastVersion = this.sourceVersions.get(source);
|
|
798
|
-
if (lastVersion !== undefined && lastVersion !== source.version) {
|
|
799
|
-
isDirty = true;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
if (!isDirty) {
|
|
803
|
-
this.state = 0 /* CLEAN */;
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
this.runCleanups();
|
|
808
|
-
this.cleanupSources();
|
|
809
|
-
const prevSubscriber = currentSubscriber;
|
|
810
|
-
setCurrentSubscriber(this);
|
|
811
|
-
const prevScope = currentScope;
|
|
812
|
-
setCurrentScope(this.scope);
|
|
813
|
-
try {
|
|
814
|
-
this.state = 0 /* CLEAN */;
|
|
815
|
-
const res = this._fn();
|
|
816
|
-
if (typeof res === "function") {
|
|
817
|
-
this.cleanups.push(res);
|
|
818
|
-
}
|
|
819
|
-
} finally {
|
|
820
|
-
setCurrentSubscriber(prevSubscriber);
|
|
821
|
-
setCurrentScope(prevScope);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
cleanupSources() {
|
|
825
|
-
for (const source of this.sources) {
|
|
826
|
-
source.removeSubscriber(this);
|
|
827
|
-
}
|
|
828
|
-
this.sources.clear();
|
|
829
|
-
this.sourceVersions.clear();
|
|
830
|
-
}
|
|
831
|
-
dispose() {
|
|
832
|
-
if (this.state === 3 /* DISPOSED */)
|
|
833
|
-
return;
|
|
834
|
-
this.state = 3 /* DISPOSED */;
|
|
835
|
-
this.runCleanups();
|
|
836
|
-
this.cleanupSources();
|
|
837
|
-
removePendingEffect(this);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
function effect(fn) {
|
|
841
|
-
const eff = new Effect(fn);
|
|
842
|
-
return () => eff.dispose();
|
|
843
|
-
}
|
|
844
|
-
var createEffect = effect;
|
|
845
|
-
// src/signals/signal.ts
|
|
846
|
-
class Signal {
|
|
847
|
-
[SIGNAL_BRAND] = true;
|
|
848
|
-
_value;
|
|
849
|
-
_subscribers = new Set;
|
|
850
|
-
_equals;
|
|
851
|
-
_onSet;
|
|
852
|
-
version = 0;
|
|
853
|
-
constructor(initialValue, equals, onSet) {
|
|
854
|
-
this._value = initialValue;
|
|
855
|
-
this._equals = equals ?? Object.is;
|
|
856
|
-
this._onSet = onSet;
|
|
857
|
-
}
|
|
858
|
-
get() {
|
|
859
|
-
if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
|
|
860
|
-
this._subscribers.add(currentSubscriber);
|
|
861
|
-
currentSubscriber.sources.add(this);
|
|
862
|
-
currentSubscriber.sourceVersions.set(this, this.version);
|
|
863
|
-
}
|
|
864
|
-
return this._value;
|
|
865
|
-
}
|
|
866
|
-
set(newValue) {
|
|
867
|
-
if (this._equals(this._value, newValue)) {
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
if (currentSubscriber !== null && this._subscribers.has(currentSubscriber)) {
|
|
871
|
-
if (!warnedCyclicSubscribers.has(currentSubscriber)) {
|
|
872
|
-
warnedCyclicSubscribers.add(currentSubscriber);
|
|
873
|
-
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
874
|
-
console.warn(`[Visage Reactivity] Cyclic update detected: An active subscriber modified a signal that it depends on. ` + `To read a signal inside an effect/computed without creating a circular dependency, wrap the read in untrack():
|
|
875
|
-
` + ` untrack(() => signal())`);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
this._value = newValue;
|
|
880
|
-
this.version++;
|
|
881
|
-
if (this._onSet) {
|
|
882
|
-
this._onSet(newValue);
|
|
883
|
-
}
|
|
884
|
-
batch(() => {
|
|
885
|
-
this.notify();
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
update(fn) {
|
|
889
|
-
this.set(fn(this._value));
|
|
890
|
-
}
|
|
891
|
-
get value() {
|
|
892
|
-
return this.get();
|
|
893
|
-
}
|
|
894
|
-
set value(val) {
|
|
895
|
-
this.set(val);
|
|
896
|
-
}
|
|
897
|
-
removeSubscriber(sub) {
|
|
898
|
-
this._subscribers.delete(sub);
|
|
899
|
-
}
|
|
900
|
-
notify() {
|
|
901
|
-
if (this._subscribers.size === 0)
|
|
902
|
-
return;
|
|
903
|
-
const subs = Array.from(this._subscribers);
|
|
904
|
-
for (const sub of subs) {
|
|
905
|
-
sub.markDirty(2 /* DIRTY */);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
function resolveStorage(storageOption) {
|
|
910
|
-
if (storageOption && typeof storageOption === "object") {
|
|
911
|
-
return storageOption;
|
|
912
|
-
}
|
|
913
|
-
if (storageOption === "session") {
|
|
914
|
-
try {
|
|
915
|
-
if (typeof sessionStorage !== "undefined")
|
|
916
|
-
return sessionStorage;
|
|
917
|
-
} catch {}
|
|
918
|
-
try {
|
|
919
|
-
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
920
|
-
return window.sessionStorage;
|
|
921
|
-
}
|
|
922
|
-
} catch {}
|
|
923
|
-
try {
|
|
924
|
-
if (typeof globalThis !== "undefined" && globalThis.sessionStorage) {
|
|
925
|
-
return globalThis.sessionStorage;
|
|
926
|
-
}
|
|
927
|
-
} catch {}
|
|
928
|
-
return null;
|
|
929
|
-
}
|
|
930
|
-
try {
|
|
931
|
-
if (typeof localStorage !== "undefined")
|
|
932
|
-
return localStorage;
|
|
933
|
-
} catch {}
|
|
934
|
-
try {
|
|
935
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
936
|
-
return window.localStorage;
|
|
937
|
-
}
|
|
938
|
-
} catch {}
|
|
939
|
-
try {
|
|
940
|
-
if (typeof globalThis !== "undefined" && globalThis.localStorage) {
|
|
941
|
-
return globalThis.localStorage;
|
|
942
|
-
}
|
|
943
|
-
} catch {}
|
|
944
|
-
return null;
|
|
945
|
-
}
|
|
946
|
-
function signal(initialValue, optionsOrEquals) {
|
|
947
|
-
const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
|
|
948
|
-
const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
|
|
949
|
-
const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
|
|
950
|
-
const persistOption = typeof optionsOrEquals === "object" ? optionsOrEquals?.persist : undefined;
|
|
951
|
-
const persistConfig = persistOption ? typeof persistOption === "string" ? { key: persistOption } : persistOption : undefined;
|
|
952
|
-
let effectiveInitial = initialValue;
|
|
953
|
-
const storage = persistConfig ? resolveStorage(persistConfig.storage) : null;
|
|
954
|
-
const serialize = persistConfig?.serialize ?? JSON.stringify;
|
|
955
|
-
const deserialize = persistConfig?.deserialize ?? JSON.parse;
|
|
956
|
-
if (persistConfig && storage) {
|
|
957
|
-
try {
|
|
958
|
-
const stored = storage.getItem(persistConfig.key);
|
|
959
|
-
if (stored !== null) {
|
|
960
|
-
effectiveInitial = deserialize(stored);
|
|
961
|
-
}
|
|
962
|
-
} catch {}
|
|
963
|
-
}
|
|
964
|
-
let isSyncing = false;
|
|
965
|
-
const onSet = persistConfig && storage ? (val) => {
|
|
966
|
-
if (isSyncing)
|
|
967
|
-
return;
|
|
968
|
-
try {
|
|
969
|
-
storage.setItem(persistConfig.key, serialize(val));
|
|
970
|
-
} catch {}
|
|
971
|
-
} : undefined;
|
|
972
|
-
const s = new Signal(effectiveInitial, equals, onSet);
|
|
973
|
-
if (persistConfig && storage && (persistConfig.syncTabs ?? true) && typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
974
|
-
const onStorage = (e) => {
|
|
975
|
-
if (e.key === persistConfig.key) {
|
|
976
|
-
try {
|
|
977
|
-
const nextVal = e.newValue !== null ? deserialize(e.newValue) : initialValue;
|
|
978
|
-
isSyncing = true;
|
|
979
|
-
try {
|
|
980
|
-
s.set(nextVal);
|
|
981
|
-
} finally {
|
|
982
|
-
isSyncing = false;
|
|
983
|
-
}
|
|
984
|
-
} catch {}
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
window.addEventListener("storage", onStorage);
|
|
988
|
-
if (currentScope) {
|
|
989
|
-
currentScope.addCleanup(() => {
|
|
990
|
-
window.removeEventListener("storage", onStorage);
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
const accessor = (...args) => {
|
|
995
|
-
if (args.length === 0) {
|
|
996
|
-
return s.get();
|
|
997
|
-
}
|
|
998
|
-
s.set(args[0]);
|
|
999
|
-
return args[0];
|
|
1000
|
-
};
|
|
1001
|
-
Object.defineProperties(accessor, {
|
|
1002
|
-
[SIGNAL_BRAND]: { value: true },
|
|
1003
|
-
get: { value: () => s.get() },
|
|
1004
|
-
set: { value: (v) => s.set(v) },
|
|
1005
|
-
update: { value: (fn) => s.update(fn) },
|
|
1006
|
-
value: {
|
|
1007
|
-
get: () => s.get(),
|
|
1008
|
-
set: (v) => s.set(v)
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
if (!isInternal && typeof window !== "undefined" && window.__VISAGE_DEVTOOLS__) {
|
|
1012
|
-
const devtools = window.__VISAGE_DEVTOOLS__;
|
|
1013
|
-
const sigId = devtools.registerSignal({
|
|
1014
|
-
name: customName,
|
|
1015
|
-
type: "signal",
|
|
1016
|
-
getValue: () => s.get(),
|
|
1017
|
-
version: () => s.version,
|
|
1018
|
-
subscribersCount: () => s._subscribers?.size ?? 0,
|
|
1019
|
-
dependents: () => Array.from(s._subscribers ?? []).map((sub) => sub._devId).filter(Boolean)
|
|
1020
|
-
});
|
|
1021
|
-
s._devId = sigId;
|
|
1022
|
-
if (currentScope) {
|
|
1023
|
-
currentScope.addCleanup(() => {
|
|
1024
|
-
devtools.unregisterSignal(sigId);
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
return accessor;
|
|
1029
|
-
}
|
|
1030
|
-
function createSignal(initialValue, optionsOrEquals) {
|
|
1031
|
-
const s = signal(initialValue, optionsOrEquals);
|
|
1032
|
-
const setter = (value) => {
|
|
1033
|
-
if (typeof value === "function") {
|
|
1034
|
-
s.update(value);
|
|
1035
|
-
} else {
|
|
1036
|
-
s.set(value);
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
return [s, setter];
|
|
1040
|
-
}
|
|
1041
|
-
// src/signals/store.ts
|
|
1042
|
-
var STORE_RAW = Symbol("visage.store.raw");
|
|
1043
|
-
var STORE_SIGNALS = Symbol("visage.store.signals");
|
|
1044
|
-
var STORE_PROXY = Symbol("visage.store.proxy");
|
|
1045
|
-
function isObject(val) {
|
|
1046
|
-
return typeof val === "object" && val !== null && (typeof Node === "undefined" || !(val instanceof Node)) && !isSignal(val);
|
|
1047
|
-
}
|
|
1048
|
-
function getOrCreatePropertySignal(target, prop) {
|
|
1049
|
-
let signalsMap = target[STORE_SIGNALS];
|
|
1050
|
-
if (!signalsMap) {
|
|
1051
|
-
signalsMap = new Map;
|
|
1052
|
-
Object.defineProperty(target, STORE_SIGNALS, {
|
|
1053
|
-
value: signalsMap,
|
|
1054
|
-
enumerable: false,
|
|
1055
|
-
writable: true
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
let sig = signalsMap.get(prop);
|
|
1059
|
-
if (!sig) {
|
|
1060
|
-
sig = new Signal(target[prop]);
|
|
1061
|
-
signalsMap.set(prop, sig);
|
|
1062
|
-
}
|
|
1063
|
-
return sig;
|
|
1064
|
-
}
|
|
1065
|
-
function createStoreProxy(target) {
|
|
1066
|
-
if (!isObject(target))
|
|
1067
|
-
return target;
|
|
1068
|
-
if (target[STORE_PROXY])
|
|
1069
|
-
return target[STORE_PROXY];
|
|
1070
|
-
const proxy = new Proxy(target, {
|
|
1071
|
-
get(target, prop, receiver) {
|
|
1072
|
-
if (prop === STORE_RAW)
|
|
1073
|
-
return target;
|
|
1074
|
-
if (prop === STORE_PROXY)
|
|
1075
|
-
return proxy;
|
|
1076
|
-
if (typeof prop === "string" || typeof prop === "symbol") {
|
|
1077
|
-
const sig = getOrCreatePropertySignal(target, prop);
|
|
1078
|
-
sig.get();
|
|
1079
|
-
}
|
|
1080
|
-
const value = Reflect.get(target, prop, receiver);
|
|
1081
|
-
if (isObject(value)) {
|
|
1082
|
-
return createStoreProxy(value);
|
|
1083
|
-
}
|
|
1084
|
-
return value;
|
|
1085
|
-
},
|
|
1086
|
-
set(target, prop, value, receiver) {
|
|
1087
|
-
const prevValue = Reflect.get(target, prop, receiver);
|
|
1088
|
-
if (Object.is(prevValue, value)) {
|
|
1089
|
-
return true;
|
|
1090
|
-
}
|
|
1091
|
-
const success = Reflect.set(target, prop, value, receiver);
|
|
1092
|
-
if (success) {
|
|
1093
|
-
const sig = getOrCreatePropertySignal(target, prop);
|
|
1094
|
-
sig.set(value);
|
|
1095
|
-
if (Array.isArray(target) && prop !== "length") {
|
|
1096
|
-
const lenSig = getOrCreatePropertySignal(target, "length");
|
|
1097
|
-
lenSig.set(target.length);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
return success;
|
|
1101
|
-
},
|
|
1102
|
-
deleteProperty(target, prop) {
|
|
1103
|
-
const hadProp = Reflect.has(target, prop);
|
|
1104
|
-
const success = Reflect.deleteProperty(target, prop);
|
|
1105
|
-
if (hadProp && success) {
|
|
1106
|
-
const sig = getOrCreatePropertySignal(target, prop);
|
|
1107
|
-
sig.set(undefined);
|
|
1108
|
-
}
|
|
1109
|
-
return success;
|
|
1110
|
-
}
|
|
1111
|
-
});
|
|
1112
|
-
Object.defineProperty(target, STORE_PROXY, {
|
|
1113
|
-
value: proxy,
|
|
1114
|
-
enumerable: false,
|
|
1115
|
-
writable: true
|
|
1116
|
-
});
|
|
1117
|
-
return proxy;
|
|
1118
|
-
}
|
|
1119
|
-
function createStore(initialState) {
|
|
1120
|
-
if (!isObject(initialState)) {
|
|
1121
|
-
throw new Error("createStore requires an object or array as initial state");
|
|
1122
|
-
}
|
|
1123
|
-
return createStoreProxy(initialState);
|
|
1124
|
-
}
|
|
1125
|
-
function mutateStore(store, mutator) {
|
|
1126
|
-
batch(() => {
|
|
1127
|
-
mutator(store);
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
function unwrapStore(store) {
|
|
1131
|
-
if (isObject(store) && store[STORE_RAW]) {
|
|
1132
|
-
return store[STORE_RAW];
|
|
1133
|
-
}
|
|
1134
|
-
return store;
|
|
1135
|
-
}
|
|
1136
|
-
// src/devtools/hub.ts
|
|
1137
|
-
class DevToolsHub {
|
|
1138
|
-
isOpen = signal(false, { internal: true });
|
|
1139
|
-
activeTab = signal("signals", { internal: true });
|
|
1140
|
-
highlightDOM = signal(false, { internal: true });
|
|
1141
|
-
searchQuery = signal("", { internal: true });
|
|
1142
|
-
_signalsMap = new Map;
|
|
1143
|
-
signalsList = signal([], { internal: true });
|
|
1144
|
-
_queriesMap = new Map;
|
|
1145
|
-
queriesList = signal([], { internal: true });
|
|
1146
|
-
rpcLogs = signal([], { internal: true });
|
|
1147
|
-
_queryClients = new Set;
|
|
1148
|
-
_signalCounter = 0;
|
|
1149
|
-
constructor() {
|
|
1150
|
-
if (typeof window !== "undefined") {
|
|
1151
|
-
window.__VISAGE_DEVTOOLS__ = this;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
toggle() {
|
|
1155
|
-
this.isOpen.update((v) => !v);
|
|
1156
|
-
}
|
|
1157
|
-
setTab(tab) {
|
|
1158
|
-
this.activeTab.set(tab);
|
|
1159
|
-
}
|
|
1160
|
-
registerSignal(options) {
|
|
1161
|
-
const id = options.id ?? `sig_${++this._signalCounter}`;
|
|
1162
|
-
const name = options.name ?? id;
|
|
1163
|
-
const type = options.type ?? "signal";
|
|
1164
|
-
const record = {
|
|
1165
|
-
id,
|
|
1166
|
-
name,
|
|
1167
|
-
type,
|
|
1168
|
-
getValue: options.getValue,
|
|
1169
|
-
version: options.version,
|
|
1170
|
-
dependencies: options.dependencies,
|
|
1171
|
-
dependents: options.dependents,
|
|
1172
|
-
subscribersCount: options.subscribersCount,
|
|
1173
|
-
lastUpdatedAt: Date.now()
|
|
1174
|
-
};
|
|
1175
|
-
this._signalsMap.set(id, record);
|
|
1176
|
-
this.refreshSignals();
|
|
1177
|
-
return id;
|
|
1178
|
-
}
|
|
1179
|
-
unregisterSignal(id) {
|
|
1180
|
-
if (this._signalsMap.delete(id)) {
|
|
1181
|
-
this.refreshSignals();
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
clearSignals() {
|
|
1185
|
-
this._signalsMap.clear();
|
|
1186
|
-
this._signalCounter = 0;
|
|
1187
|
-
this.refreshSignals();
|
|
1188
|
-
}
|
|
1189
|
-
clearQueries() {
|
|
1190
|
-
this._queriesMap.clear();
|
|
1191
|
-
this.queriesList.set([]);
|
|
1192
|
-
}
|
|
1193
|
-
clearAll() {
|
|
1194
|
-
this.clearSignals();
|
|
1195
|
-
this.clearQueries();
|
|
1196
|
-
this.clearLogs();
|
|
1197
|
-
}
|
|
1198
|
-
refreshSignals() {
|
|
1199
|
-
this.signalsList.set(Array.from(this._signalsMap.values()));
|
|
1200
|
-
}
|
|
1201
|
-
attachQueryClient(client) {
|
|
1202
|
-
if (this._queryClients.has(client))
|
|
1203
|
-
return;
|
|
1204
|
-
this._queryClients.add(client);
|
|
1205
|
-
const syncQueries = () => {
|
|
1206
|
-
const cache = client.getQueryCache();
|
|
1207
|
-
const allQueries = cache.getAll();
|
|
1208
|
-
const records = allQueries.map((q) => ({
|
|
1209
|
-
hash: q.queryHash,
|
|
1210
|
-
key: q.queryKey,
|
|
1211
|
-
status: () => q.status(),
|
|
1212
|
-
fetchStatus: () => q.fetchStatus(),
|
|
1213
|
-
data: () => q.data(),
|
|
1214
|
-
error: () => q.error(),
|
|
1215
|
-
dataUpdatedAt: () => q.dataUpdatedAt(),
|
|
1216
|
-
refetch: () => q.fetch(),
|
|
1217
|
-
invalidate: () => q.invalidate()
|
|
1218
|
-
}));
|
|
1219
|
-
this._queriesMap.clear();
|
|
1220
|
-
for (const r of records) {
|
|
1221
|
-
this._queriesMap.set(r.hash, r);
|
|
1222
|
-
}
|
|
1223
|
-
this.queriesList.set(records);
|
|
1224
|
-
};
|
|
1225
|
-
client.getQueryCache().subscribe(() => {
|
|
1226
|
-
syncQueries();
|
|
1227
|
-
});
|
|
1228
|
-
syncQueries();
|
|
1229
|
-
}
|
|
1230
|
-
logRpcCall(record) {
|
|
1231
|
-
const fullRecord = {
|
|
1232
|
-
...record,
|
|
1233
|
-
status: record.status ?? "pending",
|
|
1234
|
-
startTime: Date.now(),
|
|
1235
|
-
events: []
|
|
1236
|
-
};
|
|
1237
|
-
this.rpcLogs.update((prev) => [fullRecord, ...prev.slice(0, 99)]);
|
|
1238
|
-
return fullRecord.id;
|
|
1239
|
-
}
|
|
1240
|
-
updateRpcCall(id, updates) {
|
|
1241
|
-
this.rpcLogs.update((prev) => prev.map((item) => {
|
|
1242
|
-
if (item.id === id) {
|
|
1243
|
-
const duration = updates.duration ?? (updates.status ? Date.now() - item.startTime : item.duration);
|
|
1244
|
-
return { ...item, ...updates, duration };
|
|
1245
|
-
}
|
|
1246
|
-
return item;
|
|
1247
|
-
}));
|
|
1248
|
-
}
|
|
1249
|
-
logRpcEvent(id, data) {
|
|
1250
|
-
this.rpcLogs.update((prev) => prev.map((item) => {
|
|
1251
|
-
if (item.id === id) {
|
|
1252
|
-
const events = item.events ? [...item.events, { timestamp: Date.now(), data }] : [{ timestamp: Date.now(), data }];
|
|
1253
|
-
return { ...item, events, status: "streaming" };
|
|
1254
|
-
}
|
|
1255
|
-
return item;
|
|
1256
|
-
}));
|
|
1257
|
-
}
|
|
1258
|
-
clearLogs() {
|
|
1259
|
-
this.rpcLogs.set([]);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
var devtoolsHub = new DevToolsHub;
|
|
1263
|
-
|
|
1264
|
-
// src/style/hash.ts
|
|
1265
|
-
function hashString(str) {
|
|
1266
|
-
let hash = 2166136261;
|
|
1267
|
-
for (let i = 0;i < str.length; i++) {
|
|
1268
|
-
hash ^= str.charCodeAt(i);
|
|
1269
|
-
hash = Math.imul(hash, 16777619);
|
|
1270
|
-
}
|
|
1271
|
-
return (hash >>> 0).toString(36);
|
|
1272
|
-
}
|
|
1273
|
-
function getScopeId(css, prefix = "v") {
|
|
1274
|
-
const hash = hashString(css.trim());
|
|
1275
|
-
return `${prefix}-${hash}`;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
// src/style/manager.ts
|
|
1279
|
-
class StyleManager {
|
|
1280
|
-
_styles = new Map;
|
|
1281
|
-
_ssrStyles = new Set;
|
|
1282
|
-
inject(id, css) {
|
|
1283
|
-
let entry = this._styles.get(id);
|
|
1284
|
-
if (!entry) {
|
|
1285
|
-
entry = { id, css, count: 0 };
|
|
1286
|
-
this._styles.set(id, entry);
|
|
1287
|
-
if (typeof document !== "undefined") {
|
|
1288
|
-
const target = document.head || document.documentElement || document.body;
|
|
1289
|
-
if (target) {
|
|
1290
|
-
const styleEl = document.createElement("style");
|
|
1291
|
-
styleEl.id = `visage-style-${id}`;
|
|
1292
|
-
styleEl.setAttribute("data-visage-scope", id);
|
|
1293
|
-
styleEl.textContent = css;
|
|
1294
|
-
target.appendChild(styleEl);
|
|
1295
|
-
entry.element = styleEl;
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
this._ssrStyles.add(css);
|
|
1299
|
-
}
|
|
1300
|
-
entry.count++;
|
|
1301
|
-
return () => {
|
|
1302
|
-
if (!entry)
|
|
1303
|
-
return;
|
|
1304
|
-
entry.count--;
|
|
1305
|
-
if (entry.count <= 0) {
|
|
1306
|
-
if (entry.element?.parentNode) {
|
|
1307
|
-
entry.element.parentNode.removeChild(entry.element);
|
|
1308
|
-
}
|
|
1309
|
-
this._styles.delete(id);
|
|
1310
|
-
}
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
has(id) {
|
|
1314
|
-
return this._styles.has(id);
|
|
1315
|
-
}
|
|
1316
|
-
extractSSRStyles() {
|
|
1317
|
-
return Array.from(this._ssrStyles).join(`
|
|
1318
|
-
`);
|
|
1319
|
-
}
|
|
1320
|
-
clear() {
|
|
1321
|
-
for (const entry of this._styles.values()) {
|
|
1322
|
-
if (entry.element?.parentNode) {
|
|
1323
|
-
entry.element.parentNode.removeChild(entry.element);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
this._styles.clear();
|
|
1327
|
-
this._ssrStyles.clear();
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
var styleManager = new StyleManager;
|
|
1331
|
-
function extractStyleTags() {
|
|
1332
|
-
const css = styleManager.extractSSRStyles();
|
|
1333
|
-
return css ? `<style data-visage-ssr="true">${css}</style>` : "";
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
// src/style/parser.ts
|
|
1337
|
-
function scopeSelector(selector, options) {
|
|
1338
|
-
const { scopeId, passToChildren = false } = options;
|
|
1339
|
-
const scopeAttr = `[data-${scopeId}]`;
|
|
1340
|
-
const parts = splitSelectorList(selector);
|
|
1341
|
-
return parts.map((part) => {
|
|
1342
|
-
const trimmed = part.trim();
|
|
1343
|
-
if (!trimmed)
|
|
1344
|
-
return "";
|
|
1345
|
-
if (trimmed.includes(":global(") || trimmed.includes("::v-global(")) {
|
|
1346
|
-
return trimmed.replace(/(.*?)(?:::v-global|:global)\(([^)]+)\)(.*)/g, (_match, before, globalTarget, after) => {
|
|
1347
|
-
const prefix = before.trim();
|
|
1348
|
-
const scopedPrefix = prefix ? scopeCompoundSelector(prefix, scopeAttr) : "";
|
|
1349
|
-
if (scopedPrefix) {
|
|
1350
|
-
return `${scopedPrefix} ${globalTarget.trim()}${after}`;
|
|
1351
|
-
}
|
|
1352
|
-
return `${globalTarget.trim()}${after}`;
|
|
1353
|
-
}).trim();
|
|
1354
|
-
}
|
|
1355
|
-
if (trimmed.includes(":deep(") || trimmed.includes("::v-deep(")) {
|
|
1356
|
-
return trimmed.replace(/(.*?)(?:::v-deep|:deep)\(([^)]+)\)(.*)/g, (_match, before, deepTarget, after) => {
|
|
1357
|
-
const prefix = before.trim();
|
|
1358
|
-
const scopedPrefix = prefix ? scopeCompoundSelector(prefix, scopeAttr) : scopeAttr;
|
|
1359
|
-
return `${scopedPrefix} ${deepTarget.trim()}${after}`;
|
|
1360
|
-
}).trim();
|
|
1361
|
-
}
|
|
1362
|
-
if (passToChildren) {
|
|
1363
|
-
const compound = scopeCompoundSelector(trimmed, scopeAttr);
|
|
1364
|
-
return `${scopeAttr} ${trimmed}, ${compound}`;
|
|
1365
|
-
}
|
|
1366
|
-
return scopeCompoundSelector(trimmed, scopeAttr);
|
|
1367
|
-
}).filter(Boolean).join(", ");
|
|
1368
|
-
}
|
|
1369
|
-
function scopeCompoundSelector(selector, scopeAttr) {
|
|
1370
|
-
const combinatorRegex = /([ >+~]+)/;
|
|
1371
|
-
const tokens = selector.split(combinatorRegex);
|
|
1372
|
-
const scopedTokens = tokens.map((token, index) => {
|
|
1373
|
-
if (index % 2 === 1)
|
|
1374
|
-
return token;
|
|
1375
|
-
const piece = token.trim();
|
|
1376
|
-
if (!piece || piece === "*")
|
|
1377
|
-
return piece ? `${piece}${scopeAttr}` : "";
|
|
1378
|
-
const pseudoElemIdx = piece.indexOf("::");
|
|
1379
|
-
if (pseudoElemIdx !== -1) {
|
|
1380
|
-
const base = piece.slice(0, pseudoElemIdx);
|
|
1381
|
-
const pseudo = piece.slice(pseudoElemIdx);
|
|
1382
|
-
return `${base}${scopeAttr}${pseudo}`;
|
|
1383
|
-
}
|
|
1384
|
-
const pseudoClassIdx = piece.indexOf(":");
|
|
1385
|
-
if (pseudoClassIdx !== -1) {
|
|
1386
|
-
const base = piece.slice(0, pseudoClassIdx);
|
|
1387
|
-
const pseudo = piece.slice(pseudoClassIdx);
|
|
1388
|
-
return `${base}${scopeAttr}${pseudo}`;
|
|
1389
|
-
}
|
|
1390
|
-
return `${piece}${scopeAttr}`;
|
|
1391
|
-
});
|
|
1392
|
-
return scopedTokens.join("");
|
|
1393
|
-
}
|
|
1394
|
-
function splitSelectorList(selectorList) {
|
|
1395
|
-
const result = [];
|
|
1396
|
-
let depth = 0;
|
|
1397
|
-
let current = "";
|
|
1398
|
-
for (let i = 0;i < selectorList.length; i++) {
|
|
1399
|
-
const char = selectorList[i];
|
|
1400
|
-
if (char === "(") {
|
|
1401
|
-
depth++;
|
|
1402
|
-
current += char;
|
|
1403
|
-
} else if (char === ")") {
|
|
1404
|
-
depth = Math.max(0, depth - 1);
|
|
1405
|
-
current += char;
|
|
1406
|
-
} else if (char === "," && depth === 0) {
|
|
1407
|
-
if (current.trim())
|
|
1408
|
-
result.push(current.trim());
|
|
1409
|
-
current = "";
|
|
1410
|
-
} else {
|
|
1411
|
-
current += char;
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
if (current.trim())
|
|
1415
|
-
result.push(current.trim());
|
|
1416
|
-
return result;
|
|
1417
|
-
}
|
|
1418
|
-
function scopeCSS(css, options) {
|
|
1419
|
-
const { scopeId } = options;
|
|
1420
|
-
const keyframeNames = new Set;
|
|
1421
|
-
const keyframeRegex = /@(?:-webkit-)?keyframes\s+([a-zA-Z0-9_-]+)/g;
|
|
1422
|
-
let kMatch = keyframeRegex.exec(css);
|
|
1423
|
-
while (kMatch !== null) {
|
|
1424
|
-
if (kMatch[1]) {
|
|
1425
|
-
keyframeNames.add(kMatch[1]);
|
|
1426
|
-
}
|
|
1427
|
-
kMatch = keyframeRegex.exec(css);
|
|
1428
|
-
}
|
|
1429
|
-
let processed = css;
|
|
1430
|
-
for (const name of keyframeNames) {
|
|
1431
|
-
const scopedName = `${scopeId}-${name}`;
|
|
1432
|
-
const defRegex = new RegExp(`(@(?:-webkit-)?keyframes\\s+)${name}\\b`, "g");
|
|
1433
|
-
processed = processed.replace(defRegex, `$1${scopedName}`);
|
|
1434
|
-
}
|
|
1435
|
-
if (keyframeNames.size > 0) {
|
|
1436
|
-
for (const name of keyframeNames) {
|
|
1437
|
-
const scopedName = `${scopeId}-${name}`;
|
|
1438
|
-
const animRegex = new RegExp(`(animation(?:-name)?\\s*:[^;}]*?)\\b${name}\\b([^;}]*)`, "g");
|
|
1439
|
-
processed = processed.replace(animRegex, `$1${scopedName}$2`);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
return transformRules(processed, options);
|
|
1443
|
-
}
|
|
1444
|
-
function transformRules(css, options) {
|
|
1445
|
-
let output = "";
|
|
1446
|
-
let i = 0;
|
|
1447
|
-
const len = css.length;
|
|
1448
|
-
while (i < len) {
|
|
1449
|
-
while (i < len && /\s/.test(css[i])) {
|
|
1450
|
-
output += css[i];
|
|
1451
|
-
i++;
|
|
1452
|
-
}
|
|
1453
|
-
if (i >= len)
|
|
1454
|
-
break;
|
|
1455
|
-
if (css[i] === "/" && css[i + 1] === "*") {
|
|
1456
|
-
const endComment = css.indexOf("*/", i + 2);
|
|
1457
|
-
if (endComment === -1) {
|
|
1458
|
-
output += css.slice(i);
|
|
1459
|
-
break;
|
|
1460
|
-
}
|
|
1461
|
-
output += css.slice(i, endComment + 2);
|
|
1462
|
-
i = endComment + 2;
|
|
1463
|
-
continue;
|
|
1464
|
-
}
|
|
1465
|
-
const openBrace = css.indexOf("{", i);
|
|
1466
|
-
if (openBrace === -1) {
|
|
1467
|
-
output += css.slice(i);
|
|
1468
|
-
break;
|
|
1469
|
-
}
|
|
1470
|
-
const header = css.slice(i, openBrace).trim();
|
|
1471
|
-
if (header.startsWith("@")) {
|
|
1472
|
-
if (header.startsWith("@media") || header.startsWith("@supports") || header.startsWith("@container")) {
|
|
1473
|
-
const closeBrace = findMatchingBrace(css, openBrace);
|
|
1474
|
-
const innerContent = css.slice(openBrace + 1, closeBrace);
|
|
1475
|
-
const transformedInner = transformRules(innerContent, options);
|
|
1476
|
-
output += `${header} {
|
|
1477
|
-
${transformedInner}
|
|
1478
|
-
}`;
|
|
1479
|
-
i = closeBrace + 1;
|
|
1480
|
-
continue;
|
|
1481
|
-
}
|
|
1482
|
-
if (header.includes("keyframes") || header.startsWith("@font-face")) {
|
|
1483
|
-
const closeBrace = findMatchingBrace(css, openBrace);
|
|
1484
|
-
output += css.slice(i, closeBrace + 1);
|
|
1485
|
-
i = closeBrace + 1;
|
|
1486
|
-
continue;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
const closeBrace = css.indexOf("}", openBrace);
|
|
1490
|
-
if (closeBrace === -1) {
|
|
1491
|
-
output += css.slice(i);
|
|
1492
|
-
break;
|
|
1493
|
-
}
|
|
1494
|
-
const body = css.slice(openBrace + 1, closeBrace);
|
|
1495
|
-
const scopedSelector = scopeSelector(header, options);
|
|
1496
|
-
output += `${scopedSelector} {${body}}`;
|
|
1497
|
-
i = closeBrace + 1;
|
|
1498
|
-
}
|
|
1499
|
-
return output;
|
|
1500
|
-
}
|
|
1501
|
-
function findMatchingBrace(str, openIndex) {
|
|
1502
|
-
let depth = 0;
|
|
1503
|
-
for (let i = openIndex;i < str.length; i++) {
|
|
1504
|
-
if (str[i] === "{")
|
|
1505
|
-
depth++;
|
|
1506
|
-
else if (str[i] === "}") {
|
|
1507
|
-
depth--;
|
|
1508
|
-
if (depth === 0)
|
|
1509
|
-
return i;
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
return str.length - 1;
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
// src/style/create-style.ts
|
|
1516
|
-
function formatCSSValue(prop, val) {
|
|
1517
|
-
return formatStyleProp(prop, val);
|
|
1518
|
-
}
|
|
1519
|
-
function objectToCSS(classes) {
|
|
1520
|
-
let css = "";
|
|
1521
|
-
for (const [selector, rules] of Object.entries(classes)) {
|
|
1522
|
-
if (typeof rules !== "object" || rules === null)
|
|
1523
|
-
continue;
|
|
1524
|
-
const sel = selector.startsWith(".") || selector.startsWith("@") || selector.startsWith(":") || selector.includes(" ") || selector === "*" ? selector : `.${selector}`;
|
|
1525
|
-
let mainRules = "";
|
|
1526
|
-
let nestedRules = "";
|
|
1527
|
-
for (const [prop, val] of Object.entries(rules)) {
|
|
1528
|
-
if (typeof val === "object" && val !== null) {
|
|
1529
|
-
const nestedSel = prop.startsWith("&") ? prop.replace(/&/g, sel) : prop.startsWith(":") ? `${sel}${prop}` : `${sel} ${prop}`;
|
|
1530
|
-
nestedRules += `${nestedSel} {
|
|
1531
|
-
`;
|
|
1532
|
-
for (const [np, nv] of Object.entries(val)) {
|
|
1533
|
-
if (nv !== undefined && nv !== null) {
|
|
1534
|
-
const kebab = np.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
1535
|
-
nestedRules += ` ${kebab}: ${formatCSSValue(np, nv)};
|
|
1536
|
-
`;
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
nestedRules += `}
|
|
1540
|
-
`;
|
|
1541
|
-
} else if (val !== undefined && val !== null) {
|
|
1542
|
-
const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
1543
|
-
mainRules += ` ${kebab}: ${formatCSSValue(prop, val)};
|
|
1544
|
-
`;
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
if (mainRules) {
|
|
1548
|
-
css += `${sel} {
|
|
1549
|
-
${mainRules}}
|
|
1550
|
-
`;
|
|
1551
|
-
}
|
|
1552
|
-
if (nestedRules) {
|
|
1553
|
-
css += nestedRules;
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
return css;
|
|
1557
|
-
}
|
|
1558
|
-
function createStyle(templateOrObject, ...valuesOrOptions) {
|
|
1559
|
-
let cssInput = "";
|
|
1560
|
-
let options;
|
|
1561
|
-
if (typeof templateOrObject === "object" && !Array.isArray(templateOrObject)) {
|
|
1562
|
-
cssInput = objectToCSS(templateOrObject);
|
|
1563
|
-
options = valuesOrOptions[0];
|
|
1564
|
-
} else if (typeof templateOrObject === "string") {
|
|
1565
|
-
cssInput = templateOrObject;
|
|
1566
|
-
options = valuesOrOptions[0];
|
|
1567
|
-
} else {
|
|
1568
|
-
const template = templateOrObject;
|
|
1569
|
-
for (let i = 0;i < template.length; i++) {
|
|
1570
|
-
cssInput += template[i];
|
|
1571
|
-
if (i < valuesOrOptions.length) {
|
|
1572
|
-
cssInput += String(valuesOrOptions[i]);
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
const scopeId = options?.id ?? getScopeId(cssInput);
|
|
1577
|
-
const scopeAttr = `data-${scopeId}`;
|
|
1578
|
-
const classMap = {};
|
|
1579
|
-
const classRegex = /\.([a-zA-Z0-9_-]+)/g;
|
|
1580
|
-
let match = classRegex.exec(cssInput);
|
|
1581
|
-
while (match !== null) {
|
|
1582
|
-
const className = match[1];
|
|
1583
|
-
if (className && !classMap[className]) {
|
|
1584
|
-
classMap[className] = `${className}_${scopeId}`;
|
|
1585
|
-
}
|
|
1586
|
-
match = classRegex.exec(cssInput);
|
|
1587
|
-
}
|
|
1588
|
-
let transformedCSS = cssInput;
|
|
1589
|
-
for (const [orig, scoped] of Object.entries(classMap)) {
|
|
1590
|
-
const replaceRegex = new RegExp(`\\.${orig}\\b`, "g");
|
|
1591
|
-
transformedCSS = transformedCSS.replace(replaceRegex, `.${scoped}`);
|
|
1592
|
-
}
|
|
1593
|
-
const finalScopedCSS = scopeCSS(transformedCSS, {
|
|
1594
|
-
scopeId,
|
|
1595
|
-
passToChildren: options?.passToChildren ?? false
|
|
1596
|
-
});
|
|
1597
|
-
styleManager.inject(scopeId, finalScopedCSS);
|
|
1598
|
-
const result = {
|
|
1599
|
-
...classMap,
|
|
1600
|
-
scope: scopeId,
|
|
1601
|
-
scopeAttr,
|
|
1602
|
-
css: finalScopedCSS,
|
|
1603
|
-
cx: (...args) => cx(...args)
|
|
1604
|
-
};
|
|
1605
|
-
return result;
|
|
1606
|
-
}
|
|
1607
|
-
function css(strings, ...values) {
|
|
1608
|
-
let rawCSS = "";
|
|
1609
|
-
for (let i = 0;i < strings.length; i++) {
|
|
1610
|
-
rawCSS += strings[i];
|
|
1611
|
-
if (i < values.length) {
|
|
1612
|
-
rawCSS += String(values[i]);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
const scopeId = getScopeId(rawCSS, "cls");
|
|
1616
|
-
const className = `visage_${scopeId}`;
|
|
1617
|
-
const fullCSS = rawCSS.includes("&") ? rawCSS.replace(/&/g, `.${className}`) : `.${className} { ${rawCSS} }`;
|
|
1618
|
-
const scoped = scopeCSS(fullCSS, { scopeId });
|
|
1619
|
-
styleManager.inject(scopeId, scoped);
|
|
1620
|
-
return className;
|
|
1621
|
-
}
|
|
1622
|
-
function useStyle(cssInput, options) {
|
|
1623
|
-
const getRaw = () => {
|
|
1624
|
-
const val = typeof cssInput === "function" ? cssInput() : cssInput;
|
|
1625
|
-
return typeof val === "object" ? objectToCSS(val) : val;
|
|
1626
|
-
};
|
|
1627
|
-
const raw = getRaw();
|
|
1628
|
-
const scopeId = options?.id ?? getScopeId(raw);
|
|
1629
|
-
const scopedCSS = scopeCSS(raw, {
|
|
1630
|
-
scopeId,
|
|
1631
|
-
passToChildren: options?.passToChildren ?? false
|
|
1632
|
-
});
|
|
1633
|
-
const cleanup = styleManager.inject(scopeId, scopedCSS);
|
|
1634
|
-
onCleanup(() => {
|
|
1635
|
-
cleanup();
|
|
1636
|
-
});
|
|
1637
|
-
return scopeId;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
// src/style/component.tsx
|
|
1641
|
-
function Style(props) {
|
|
1642
|
-
const getRawCSS = () => {
|
|
1643
|
-
if (props.classes) {
|
|
1644
|
-
const cls = typeof props.classes === "function" ? props.classes() : props.classes;
|
|
1645
|
-
return objectToCSS(cls);
|
|
1646
|
-
}
|
|
1647
|
-
if (props.children) {
|
|
1648
|
-
const ch = typeof props.children === "function" ? props.children() : props.children;
|
|
1649
|
-
return typeof ch === "object" ? objectToCSS(ch) : ch;
|
|
1650
|
-
}
|
|
1651
|
-
return "";
|
|
1652
|
-
};
|
|
1653
|
-
const rawCSS = getRawCSS();
|
|
1654
|
-
const scopeId = props.id ?? getScopeId(rawCSS);
|
|
1655
|
-
const scopeAttr = `data-${scopeId}`;
|
|
1656
|
-
if (typeof document !== "undefined") {
|
|
1657
|
-
const marker = document.createTextNode("");
|
|
1658
|
-
let unsubscribe = null;
|
|
1659
|
-
effect(() => {
|
|
1660
|
-
const currentCSS = getRawCSS();
|
|
1661
|
-
const currentScopeId = props.id ?? getScopeId(currentCSS);
|
|
1662
|
-
const scoped = scopeCSS(currentCSS, {
|
|
1663
|
-
scopeId: currentScopeId,
|
|
1664
|
-
passToChildren: props.passToChildren ?? true
|
|
1665
|
-
});
|
|
1666
|
-
if (unsubscribe) {
|
|
1667
|
-
unsubscribe();
|
|
1668
|
-
}
|
|
1669
|
-
unsubscribe = styleManager.inject(currentScopeId, scoped);
|
|
1670
|
-
const attachScope = () => {
|
|
1671
|
-
const parent = marker.parentElement || marker.parentNode;
|
|
1672
|
-
if (parent && typeof parent.setAttribute === "function") {
|
|
1673
|
-
parent.setAttribute(`data-${currentScopeId}`, "");
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1676
|
-
attachScope();
|
|
1677
|
-
queueMicrotask(attachScope);
|
|
1678
|
-
});
|
|
1679
|
-
onCleanup(() => {
|
|
1680
|
-
if (unsubscribe) {
|
|
1681
|
-
unsubscribe();
|
|
1682
|
-
}
|
|
1683
|
-
const parent = marker.parentElement || marker.parentNode;
|
|
1684
|
-
if (parent && typeof parent.removeAttribute === "function") {
|
|
1685
|
-
parent.removeAttribute(scopeAttr);
|
|
1686
|
-
}
|
|
1687
|
-
});
|
|
1688
|
-
return marker;
|
|
1689
|
-
}
|
|
1690
|
-
const scoped = scopeCSS(rawCSS, {
|
|
1691
|
-
scopeId,
|
|
1692
|
-
passToChildren: props.passToChildren ?? true
|
|
1693
|
-
});
|
|
1694
|
-
styleManager.inject(scopeId, scoped);
|
|
1695
|
-
return null;
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
// src/dom/resource.ts
|
|
1699
|
-
var SuspenseContext = createContext(null);
|
|
1700
|
-
function createResource(sourceOrFetcher, maybeFetcher) {
|
|
1701
|
-
const isDirect = typeof maybeFetcher !== "function";
|
|
1702
|
-
const fetcher = isDirect ? sourceOrFetcher : maybeFetcher;
|
|
1703
|
-
const source = isDirect ? null : sourceOrFetcher;
|
|
1704
|
-
const data = signal(undefined);
|
|
1705
|
-
const loading = signal(true);
|
|
1706
|
-
const error = signal(null);
|
|
1707
|
-
let currentPromise = null;
|
|
1708
|
-
let requestId = 0;
|
|
1709
|
-
const load = async (arg) => {
|
|
1710
|
-
const currentReq = ++requestId;
|
|
1711
|
-
loading.set(true);
|
|
1712
|
-
error.set(null);
|
|
1713
|
-
const promise = isDirect ? fetcher() : fetcher(arg);
|
|
1714
|
-
currentPromise = promise;
|
|
1715
|
-
const suspense = useContext(SuspenseContext);
|
|
1716
|
-
if (suspense) {
|
|
1717
|
-
suspense.registerPromise(promise);
|
|
1718
|
-
}
|
|
1719
|
-
try {
|
|
1720
|
-
const res = await promise;
|
|
1721
|
-
if (currentReq === requestId) {
|
|
1722
|
-
data.set(res);
|
|
1723
|
-
loading.set(false);
|
|
1724
|
-
currentPromise = null;
|
|
1725
|
-
}
|
|
1726
|
-
return res;
|
|
1727
|
-
} catch (err) {
|
|
1728
|
-
if (currentReq === requestId) {
|
|
1729
|
-
error.set(err);
|
|
1730
|
-
loading.set(false);
|
|
1731
|
-
currentPromise = null;
|
|
1732
|
-
}
|
|
1733
|
-
throw err;
|
|
1734
|
-
}
|
|
1735
|
-
};
|
|
1736
|
-
if (source) {
|
|
1737
|
-
effect(() => {
|
|
1738
|
-
const sourceVal = resolveValue(source);
|
|
1739
|
-
if (sourceVal !== false && sourceVal !== null && sourceVal !== undefined) {
|
|
1740
|
-
load(sourceVal).catch(() => {});
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
} else {
|
|
1744
|
-
load().catch(() => {});
|
|
1745
|
-
}
|
|
1746
|
-
const accessor = () => {
|
|
1747
|
-
if (loading() && currentPromise) {
|
|
1748
|
-
const suspense = useContext(SuspenseContext);
|
|
1749
|
-
if (suspense) {
|
|
1750
|
-
suspense.registerPromise(currentPromise);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
return data();
|
|
1754
|
-
};
|
|
1755
|
-
Object.defineProperties(accessor, {
|
|
1756
|
-
loading: { get: () => loading },
|
|
1757
|
-
error: { get: () => error },
|
|
1758
|
-
mutate: { value: (val) => data.set(val) },
|
|
1759
|
-
refetch: { value: () => source ? load(resolveValue(source)) : load() }
|
|
1760
|
-
});
|
|
1761
|
-
return accessor;
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
// src/dom/lazy.ts
|
|
1765
|
-
function lazy(importer) {
|
|
1766
|
-
let loadedComponent = null;
|
|
1767
|
-
let loadingPromise = null;
|
|
1768
|
-
const preload = () => {
|
|
1769
|
-
if (loadedComponent) {
|
|
1770
|
-
return Promise.resolve(loadedComponent);
|
|
1771
|
-
}
|
|
1772
|
-
if (!loadingPromise) {
|
|
1773
|
-
loadingPromise = importer().then((mod) => {
|
|
1774
|
-
const comp = mod && typeof mod === "object" && "default" in mod ? mod.default : mod;
|
|
1775
|
-
loadedComponent = comp;
|
|
1776
|
-
return comp;
|
|
1777
|
-
}).catch((err) => {
|
|
1778
|
-
loadingPromise = null;
|
|
1779
|
-
throw err;
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
return loadingPromise;
|
|
1783
|
-
};
|
|
1784
|
-
const LazyWrapper = (props) => {
|
|
1785
|
-
if (loadedComponent) {
|
|
1786
|
-
return loadedComponent(props);
|
|
1787
|
-
}
|
|
1788
|
-
const promise = preload();
|
|
1789
|
-
const suspense = useContext(SuspenseContext);
|
|
1790
|
-
if (suspense) {
|
|
1791
|
-
suspense.registerPromise(promise);
|
|
1792
|
-
}
|
|
1793
|
-
const res = createResource(() => promise);
|
|
1794
|
-
return () => {
|
|
1795
|
-
const Comp = res();
|
|
1796
|
-
return Comp ? Comp(props) : null;
|
|
1797
|
-
};
|
|
1798
|
-
};
|
|
1799
|
-
LazyWrapper.preload = preload;
|
|
1800
|
-
return LazyWrapper;
|
|
1801
|
-
}
|
|
1802
|
-
// src/dom/async.ts
|
|
1803
|
-
function Suspense(props) {
|
|
1804
|
-
if (typeof document === "undefined") {
|
|
1805
|
-
return typeof props.children === "function" ? props.children() : props.children;
|
|
1806
|
-
}
|
|
1807
|
-
const marker = document.createTextNode("");
|
|
1808
|
-
const initialFrag = document.createDocumentFragment();
|
|
1809
|
-
const pendingCount = signal(0);
|
|
1810
|
-
let currentScope = null;
|
|
1811
|
-
let currentNodes = [];
|
|
1812
|
-
let isMounted = false;
|
|
1813
|
-
const suspenseValue = {
|
|
1814
|
-
registerPromise(p) {
|
|
1815
|
-
pendingCount.update((c) => c + 1);
|
|
1816
|
-
p.finally(() => {
|
|
1817
|
-
pendingCount.update((c) => Math.max(0, c - 1));
|
|
1818
|
-
});
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
const renderContent = (content) => {
|
|
1822
|
-
const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
|
|
1823
|
-
if (!parent)
|
|
1824
|
-
return;
|
|
1825
|
-
for (const n of currentNodes) {
|
|
1826
|
-
if (n.parentNode)
|
|
1827
|
-
n.parentNode.removeChild(n);
|
|
1828
|
-
}
|
|
1829
|
-
currentNodes = [];
|
|
1830
|
-
const frag = document.createDocumentFragment();
|
|
1831
|
-
insertChild(frag, content);
|
|
1832
|
-
currentNodes = Array.from(frag.childNodes);
|
|
1833
|
-
if (marker.parentNode) {
|
|
1834
|
-
marker.parentNode.insertBefore(frag, marker);
|
|
1835
|
-
} else if (!isMounted) {
|
|
1836
|
-
initialFrag.appendChild(frag);
|
|
1837
|
-
}
|
|
1838
|
-
};
|
|
1839
|
-
effect(() => {
|
|
1840
|
-
if (currentScope) {
|
|
1841
|
-
currentScope.dispose();
|
|
1842
|
-
currentScope = null;
|
|
1843
|
-
}
|
|
1844
|
-
currentScope = new Scope(getActiveScope());
|
|
1845
|
-
runInScope(currentScope, () => {
|
|
1846
|
-
let threwPromise = null;
|
|
1847
|
-
let rendered = null;
|
|
1848
|
-
try {
|
|
1849
|
-
const SuspenseProvider = SuspenseContext.Provider;
|
|
1850
|
-
rendered = SuspenseProvider({
|
|
1851
|
-
value: suspenseValue,
|
|
1852
|
-
children: props.children
|
|
1853
|
-
});
|
|
1854
|
-
} catch (err) {
|
|
1855
|
-
if (err && typeof err.then === "function") {
|
|
1856
|
-
threwPromise = err;
|
|
1857
|
-
suspenseValue.registerPromise(err);
|
|
1858
|
-
} else {
|
|
1859
|
-
throw err;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
if (pendingCount() > 0 || threwPromise) {
|
|
1863
|
-
renderContent(props.fallback);
|
|
1864
|
-
} else {
|
|
1865
|
-
renderContent(rendered);
|
|
1866
|
-
}
|
|
1867
|
-
});
|
|
1868
|
-
});
|
|
1869
|
-
isMounted = true;
|
|
1870
|
-
initialFrag.appendChild(marker);
|
|
1871
|
-
onCleanup(() => {
|
|
1872
|
-
if (currentScope)
|
|
1873
|
-
currentScope.dispose();
|
|
1874
|
-
});
|
|
1875
|
-
return initialFrag;
|
|
1876
|
-
}
|
|
1877
|
-
function ErrorBoundary(props) {
|
|
1878
|
-
if (typeof document === "undefined") {
|
|
1879
|
-
try {
|
|
1880
|
-
return typeof props.children === "function" ? props.children() : props.children;
|
|
1881
|
-
} catch (err) {
|
|
1882
|
-
return typeof props.fallback === "function" ? props.fallback(err, () => {}) : props.fallback;
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
const marker = document.createTextNode("");
|
|
1886
|
-
const initialFrag = document.createDocumentFragment();
|
|
1887
|
-
const currentError = signal(null);
|
|
1888
|
-
let currentScope = null;
|
|
1889
|
-
let currentNodes = [];
|
|
1890
|
-
let isMounted = false;
|
|
1891
|
-
const reset = () => {
|
|
1892
|
-
currentError.set(null);
|
|
1893
|
-
};
|
|
1894
|
-
const renderNodes = (child) => {
|
|
1895
|
-
const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
|
|
1896
|
-
if (!parent)
|
|
1897
|
-
return;
|
|
1898
|
-
for (const n of currentNodes) {
|
|
1899
|
-
if (n.parentNode)
|
|
1900
|
-
n.parentNode.removeChild(n);
|
|
1901
|
-
}
|
|
1902
|
-
currentNodes = [];
|
|
1903
|
-
const frag = document.createDocumentFragment();
|
|
1904
|
-
insertChild(frag, child);
|
|
1905
|
-
currentNodes = Array.from(frag.childNodes);
|
|
1906
|
-
if (marker.parentNode) {
|
|
1907
|
-
marker.parentNode.insertBefore(frag, marker);
|
|
1908
|
-
} else if (!isMounted) {
|
|
1909
|
-
initialFrag.appendChild(frag);
|
|
1910
|
-
}
|
|
1911
|
-
};
|
|
1912
|
-
effect(() => {
|
|
1913
|
-
const err = currentError();
|
|
1914
|
-
if (currentScope) {
|
|
1915
|
-
currentScope.dispose();
|
|
1916
|
-
currentScope = null;
|
|
1917
|
-
}
|
|
1918
|
-
currentScope = new Scope(getActiveScope());
|
|
1919
|
-
runInScope(currentScope, () => {
|
|
1920
|
-
if (err !== null) {
|
|
1921
|
-
const fallbackNode = typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
|
|
1922
|
-
renderNodes(fallbackNode);
|
|
1923
|
-
} else {
|
|
1924
|
-
try {
|
|
1925
|
-
const content = typeof props.children === "function" ? props.children() : props.children;
|
|
1926
|
-
renderNodes(content);
|
|
1927
|
-
} catch (catchedErr) {
|
|
1928
|
-
currentError.set(catchedErr);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
});
|
|
1932
|
-
});
|
|
1933
|
-
isMounted = true;
|
|
1934
|
-
initialFrag.appendChild(marker);
|
|
1935
|
-
onCleanup(() => {
|
|
1936
|
-
if (currentScope)
|
|
1937
|
-
currentScope.dispose();
|
|
1938
|
-
});
|
|
1939
|
-
return initialFrag;
|
|
1940
|
-
}
|
|
1941
|
-
// src/dom/control-flow.ts
|
|
1942
|
-
function Show(props) {
|
|
1943
|
-
if (typeof document === "undefined") {
|
|
1944
|
-
const condition = resolveValue(props.when);
|
|
1945
|
-
if (condition) {
|
|
1946
|
-
return typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue(props.when)) : typeof props.children === "function" ? props.children() : props.children;
|
|
1947
|
-
}
|
|
1948
|
-
return props.fallback ?? null;
|
|
1949
|
-
}
|
|
1950
|
-
const marker = document.createComment("visage-show");
|
|
1951
|
-
const initialFrag = document.createDocumentFragment();
|
|
1952
|
-
initialFrag.appendChild(marker);
|
|
1953
|
-
let currentScope = null;
|
|
1954
|
-
let currentContent = [];
|
|
1955
|
-
effect(() => {
|
|
1956
|
-
const condition = resolveValue(props.when);
|
|
1957
|
-
if (currentScope) {
|
|
1958
|
-
currentScope.dispose();
|
|
1959
|
-
currentScope = null;
|
|
1960
|
-
}
|
|
1961
|
-
for (const node of currentContent) {
|
|
1962
|
-
if (node.parentNode) {
|
|
1963
|
-
node.parentNode.removeChild(node);
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
currentContent = [];
|
|
1967
|
-
const frag = document.createDocumentFragment();
|
|
1968
|
-
if (condition) {
|
|
1969
|
-
currentScope = new Scope(getActiveScope());
|
|
1970
|
-
untrack(() => {
|
|
1971
|
-
runInScope(currentScope, () => {
|
|
1972
|
-
const childRes = typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue(props.when)) : typeof props.children === "function" ? props.children() : props.children;
|
|
1973
|
-
insertChild(frag, childRes);
|
|
1974
|
-
});
|
|
1975
|
-
});
|
|
1976
|
-
} else if (props.fallback !== undefined) {
|
|
1977
|
-
currentScope = new Scope(getActiveScope());
|
|
1978
|
-
untrack(() => {
|
|
1979
|
-
runInScope(currentScope, () => {
|
|
1980
|
-
const fallbackRes = typeof props.fallback === "function" ? props.fallback() : props.fallback;
|
|
1981
|
-
insertChild(frag, fallbackRes);
|
|
1982
|
-
});
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
currentContent = Array.from(frag.childNodes);
|
|
1986
|
-
const parent = marker.parentNode;
|
|
1987
|
-
if (parent) {
|
|
1988
|
-
parent.insertBefore(frag, marker);
|
|
1989
|
-
}
|
|
1990
|
-
});
|
|
1991
|
-
onCleanup(() => {
|
|
1992
|
-
if (currentScope) {
|
|
1993
|
-
currentScope.dispose();
|
|
1994
|
-
}
|
|
1995
|
-
for (const node of currentContent) {
|
|
1996
|
-
if (node.parentNode) {
|
|
1997
|
-
node.parentNode.removeChild(node);
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
if (marker.parentNode) {
|
|
2001
|
-
marker.parentNode.removeChild(marker);
|
|
2002
|
-
}
|
|
2003
|
-
});
|
|
2004
|
-
return initialFrag;
|
|
2005
|
-
}
|
|
2006
|
-
function For(props) {
|
|
2007
|
-
if (typeof document === "undefined") {
|
|
2008
|
-
const list = resolveValue(props.each) ?? [];
|
|
2009
|
-
if (list.length === 0) {
|
|
2010
|
-
return props.fallback ?? null;
|
|
2011
|
-
}
|
|
2012
|
-
return list.map((item, idx) => props.children(item, () => idx));
|
|
2013
|
-
}
|
|
2014
|
-
const marker = document.createTextNode("");
|
|
2015
|
-
const initialFrag = document.createDocumentFragment();
|
|
2016
|
-
let items = [];
|
|
2017
|
-
let fallbackScope = null;
|
|
2018
|
-
let fallbackNodes = [];
|
|
2019
|
-
let isMounted = false;
|
|
2020
|
-
effect(() => {
|
|
2021
|
-
const list = resolveValue(props.each) ?? [];
|
|
2022
|
-
const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
|
|
2023
|
-
if (list.length === 0) {
|
|
2024
|
-
for (const rec of items) {
|
|
2025
|
-
rec.scope.dispose();
|
|
2026
|
-
for (const node of rec.nodes) {
|
|
2027
|
-
if (node.parentNode)
|
|
2028
|
-
node.parentNode.removeChild(node);
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
items = [];
|
|
2032
|
-
if (props.fallback !== undefined && fallbackNodes.length === 0 && parent) {
|
|
2033
|
-
fallbackScope = new Scope(getActiveScope());
|
|
2034
|
-
untrack(() => {
|
|
2035
|
-
runInScope(fallbackScope, () => {
|
|
2036
|
-
const frag = document.createDocumentFragment();
|
|
2037
|
-
insertChild(frag, props.fallback);
|
|
2038
|
-
fallbackNodes = Array.from(frag.childNodes);
|
|
2039
|
-
if (marker.parentNode) {
|
|
2040
|
-
marker.parentNode.insertBefore(frag, marker);
|
|
2041
|
-
} else if (!isMounted) {
|
|
2042
|
-
initialFrag.appendChild(frag);
|
|
2043
|
-
}
|
|
2044
|
-
});
|
|
2045
|
-
});
|
|
2046
|
-
}
|
|
2047
|
-
return;
|
|
2048
|
-
}
|
|
2049
|
-
if (fallbackNodes.length > 0) {
|
|
2050
|
-
if (fallbackScope) {
|
|
2051
|
-
fallbackScope.dispose();
|
|
2052
|
-
fallbackScope = null;
|
|
2053
|
-
}
|
|
2054
|
-
for (const node of fallbackNodes) {
|
|
2055
|
-
if (node.parentNode)
|
|
2056
|
-
node.parentNode.removeChild(node);
|
|
2057
|
-
}
|
|
2058
|
-
fallbackNodes = [];
|
|
2059
|
-
}
|
|
2060
|
-
if (!parent)
|
|
2061
|
-
return;
|
|
2062
|
-
const newItems = [];
|
|
2063
|
-
const prevMap = new Map;
|
|
2064
|
-
for (const rec of items) {
|
|
2065
|
-
prevMap.set(rec.item, rec);
|
|
2066
|
-
}
|
|
2067
|
-
for (let i = 0;i < list.length; i++) {
|
|
2068
|
-
const item = list[i];
|
|
2069
|
-
const existing = prevMap.get(item);
|
|
2070
|
-
if (existing) {
|
|
2071
|
-
existing.indexSignal(i);
|
|
2072
|
-
newItems.push(existing);
|
|
2073
|
-
prevMap.delete(item);
|
|
2074
|
-
} else {
|
|
2075
|
-
let indexVal = i;
|
|
2076
|
-
const indexSubscribers = new Set;
|
|
2077
|
-
const indexSignal = (...args) => {
|
|
2078
|
-
if (args.length > 0 && args[0] !== undefined && args[0] !== indexVal) {
|
|
2079
|
-
indexVal = args[0];
|
|
2080
|
-
for (const sub of Array.from(indexSubscribers))
|
|
2081
|
-
sub();
|
|
2082
|
-
}
|
|
2083
|
-
return indexVal;
|
|
2084
|
-
};
|
|
2085
|
-
const itemScope = new Scope(getActiveScope());
|
|
2086
|
-
let itemNodes = [];
|
|
2087
|
-
untrack(() => {
|
|
2088
|
-
runInScope(itemScope, () => {
|
|
2089
|
-
const frag = document.createDocumentFragment();
|
|
2090
|
-
const child = props.children(item, indexSignal);
|
|
2091
|
-
insertChild(frag, child);
|
|
2092
|
-
itemNodes = Array.from(frag.childNodes);
|
|
2093
|
-
});
|
|
2094
|
-
});
|
|
2095
|
-
newItems.push({
|
|
2096
|
-
item,
|
|
2097
|
-
scope: itemScope,
|
|
2098
|
-
nodes: itemNodes,
|
|
2099
|
-
indexSignal
|
|
2100
|
-
});
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
for (const [, removed] of prevMap) {
|
|
2104
|
-
removed.scope.dispose();
|
|
2105
|
-
for (const node of removed.nodes) {
|
|
2106
|
-
if (node.parentNode)
|
|
2107
|
-
node.parentNode.removeChild(node);
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
if (marker.parentNode) {
|
|
2111
|
-
let currentMarker = marker;
|
|
2112
|
-
for (let i = newItems.length - 1;i >= 0; i--) {
|
|
2113
|
-
const rec = newItems[i];
|
|
2114
|
-
for (let j = rec.nodes.length - 1;j >= 0; j--) {
|
|
2115
|
-
const node = rec.nodes[j];
|
|
2116
|
-
if (node.nextSibling !== currentMarker) {
|
|
2117
|
-
marker.parentNode.insertBefore(node, currentMarker);
|
|
2118
|
-
}
|
|
2119
|
-
currentMarker = node;
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
} else if (!isMounted) {
|
|
2123
|
-
for (const rec of newItems) {
|
|
2124
|
-
for (const node of rec.nodes) {
|
|
2125
|
-
initialFrag.appendChild(node);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
items = newItems;
|
|
2130
|
-
});
|
|
2131
|
-
isMounted = true;
|
|
2132
|
-
initialFrag.appendChild(marker);
|
|
2133
|
-
onCleanup(() => {
|
|
2134
|
-
for (const rec of items) {
|
|
2135
|
-
rec.scope.dispose();
|
|
2136
|
-
}
|
|
2137
|
-
if (fallbackScope) {
|
|
2138
|
-
fallbackScope.dispose();
|
|
2139
|
-
}
|
|
2140
|
-
});
|
|
2141
|
-
return initialFrag;
|
|
2142
|
-
}
|
|
2143
|
-
function Portal(props) {
|
|
2144
|
-
if (typeof document === "undefined") {
|
|
2145
|
-
return null;
|
|
2146
|
-
}
|
|
2147
|
-
const marker = document.createTextNode("");
|
|
2148
|
-
let currentScope = null;
|
|
2149
|
-
let nodes = [];
|
|
2150
|
-
effect(() => {
|
|
2151
|
-
const target = props.mount ?? (typeof document !== "undefined" ? document.body : null);
|
|
2152
|
-
if (!target)
|
|
2153
|
-
return;
|
|
2154
|
-
if (currentScope) {
|
|
2155
|
-
currentScope.dispose();
|
|
2156
|
-
currentScope = null;
|
|
2157
|
-
}
|
|
2158
|
-
for (const node of nodes) {
|
|
2159
|
-
if (node.parentNode) {
|
|
2160
|
-
node.parentNode.removeChild(node);
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
nodes = [];
|
|
2164
|
-
currentScope = new Scope(getActiveScope());
|
|
2165
|
-
untrack(() => {
|
|
2166
|
-
runInScope(currentScope, () => {
|
|
2167
|
-
const childRes = typeof props.children === "function" ? props.children() : props.children;
|
|
2168
|
-
const frag = document.createDocumentFragment();
|
|
2169
|
-
insertChild(frag, childRes);
|
|
2170
|
-
nodes = Array.from(frag.childNodes);
|
|
2171
|
-
target.appendChild(frag);
|
|
2172
|
-
});
|
|
2173
|
-
});
|
|
2174
|
-
});
|
|
2175
|
-
onCleanup(() => {
|
|
2176
|
-
if (currentScope) {
|
|
2177
|
-
currentScope.dispose();
|
|
2178
|
-
currentScope = null;
|
|
2179
|
-
}
|
|
2180
|
-
for (const node of nodes) {
|
|
2181
|
-
if (node.parentNode) {
|
|
2182
|
-
node.parentNode.removeChild(node);
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
nodes = [];
|
|
2186
|
-
});
|
|
2187
|
-
return marker;
|
|
2188
|
-
}
|
|
2189
|
-
// src/jsx-runtime/index.ts
|
|
2190
|
-
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
2191
|
-
var SVG_TAGS = new Set([
|
|
2192
|
-
"svg",
|
|
2193
|
-
"path",
|
|
2194
|
-
"circle",
|
|
2195
|
-
"rect",
|
|
2196
|
-
"g",
|
|
2197
|
-
"line",
|
|
2198
|
-
"polyline",
|
|
2199
|
-
"polygon",
|
|
2200
|
-
"text",
|
|
2201
|
-
"defs",
|
|
2202
|
-
"clipPath",
|
|
2203
|
-
"linearGradient",
|
|
2204
|
-
"radialGradient",
|
|
2205
|
-
"stop"
|
|
2206
|
-
]);
|
|
2207
|
-
function Fragment(props) {
|
|
2208
|
-
if (typeof document === "undefined") {
|
|
2209
|
-
return props.children !== undefined ? props.children : [];
|
|
2210
|
-
}
|
|
2211
|
-
const fragment = document.createDocumentFragment();
|
|
2212
|
-
if (props.children !== undefined) {
|
|
2213
|
-
insertChild(fragment, props.children);
|
|
2214
|
-
}
|
|
2215
|
-
return fragment;
|
|
2216
|
-
}
|
|
2217
|
-
function jsx(type, props = {}, key) {
|
|
2218
|
-
if (typeof type === "function") {
|
|
2219
|
-
return type(props, key);
|
|
2220
|
-
}
|
|
2221
|
-
if (typeof type === "string") {
|
|
2222
|
-
const { children, ...restProps } = props;
|
|
2223
|
-
if (typeof document === "undefined") {
|
|
2224
|
-
const attributes = new Map;
|
|
2225
|
-
for (const propName in restProps) {
|
|
2226
|
-
const val = restProps[propName];
|
|
2227
|
-
if (propName === "className" || propName === "class") {
|
|
2228
|
-
const resolved = typeof val === "function" ? val() : val;
|
|
2229
|
-
if (resolved)
|
|
2230
|
-
attributes.set("class", resolved);
|
|
2231
|
-
} else if (propName === "style") {
|
|
2232
|
-
const val = restProps[propName];
|
|
2233
|
-
const resolved = resolveValue(val);
|
|
2234
|
-
if (typeof resolved === "string") {
|
|
2235
|
-
attributes.set("style", resolved);
|
|
2236
|
-
} else if (typeof resolved === "object" && resolved !== null) {
|
|
2237
|
-
const styleStr = Object.entries(resolved).map(([k, v]) => {
|
|
2238
|
-
const finalVal = resolveValue(v);
|
|
2239
|
-
const formatted = formatStyleProp(k, finalVal);
|
|
2240
|
-
if (!formatted)
|
|
2241
|
-
return "";
|
|
2242
|
-
const kebab = k.startsWith("--") ? k : k.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2243
|
-
return `${kebab}: ${formatted}`;
|
|
2244
|
-
}).filter(Boolean).join("; ");
|
|
2245
|
-
if (styleStr)
|
|
2246
|
-
attributes.set("style", styleStr);
|
|
2247
|
-
}
|
|
2248
|
-
} else if (!propName.startsWith("on")) {
|
|
2249
|
-
const resolved = typeof val === "function" ? val() : val;
|
|
2250
|
-
if (resolved === true) {
|
|
2251
|
-
attributes.set(propName, propName);
|
|
2252
|
-
} else if (resolved !== false && resolved !== null && resolved !== undefined) {
|
|
2253
|
-
attributes.set(propName, resolved);
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
const childNodes = children !== undefined ? Array.isArray(children) ? children : [children] : [];
|
|
2258
|
-
return {
|
|
2259
|
-
tagName: type,
|
|
2260
|
-
attributes,
|
|
2261
|
-
childNodes
|
|
2262
|
-
};
|
|
2263
|
-
}
|
|
2264
|
-
const isSvg = SVG_TAGS.has(type);
|
|
2265
|
-
const element = isSvg ? document.createElementNS(SVG_NS, type) : document.createElement(type);
|
|
2266
|
-
for (const propName in restProps) {
|
|
2267
|
-
setAttribute(element, propName, restProps[propName]);
|
|
2268
|
-
}
|
|
2269
|
-
if (children !== undefined) {
|
|
2270
|
-
insertChild(element, children);
|
|
2271
|
-
}
|
|
2272
|
-
return element;
|
|
2273
|
-
}
|
|
2274
|
-
return type;
|
|
2275
|
-
}
|
|
2276
|
-
var jsxs = jsx;
|
|
2277
|
-
var jsxDEV = jsx;
|
|
2278
|
-
|
|
2279
|
-
// src/ui/utils.ts
|
|
2280
|
-
var idCounter = 0;
|
|
2281
|
-
function createId(prefix = "visage") {
|
|
2282
|
-
return `${prefix}-${++idCounter}`;
|
|
2283
|
-
}
|
|
2284
|
-
function createControllableSignal(options) {
|
|
2285
|
-
const isControlled = typeof options.value === "function";
|
|
2286
|
-
const internal = signal(options.defaultValue, { internal: true });
|
|
2287
|
-
const getter = computed(() => {
|
|
2288
|
-
if (isControlled) {
|
|
2289
|
-
const externalVal = options.value();
|
|
2290
|
-
if (externalVal !== undefined)
|
|
2291
|
-
return externalVal;
|
|
2292
|
-
}
|
|
2293
|
-
return internal();
|
|
2294
|
-
}, { internal: true });
|
|
2295
|
-
const setter = (next) => {
|
|
2296
|
-
const currentVal = getter();
|
|
2297
|
-
const nextVal = typeof next === "function" ? next(currentVal) : next;
|
|
2298
|
-
if (!isControlled) {
|
|
2299
|
-
internal.set(nextVal);
|
|
2300
|
-
}
|
|
2301
|
-
if (options.onChange && nextVal !== currentVal) {
|
|
2302
|
-
options.onChange(nextVal);
|
|
2303
|
-
}
|
|
2304
|
-
};
|
|
2305
|
-
return [getter, setter];
|
|
2306
|
-
}
|
|
2307
|
-
function trapFocus(container, event) {
|
|
2308
|
-
if (event.key !== "Tab")
|
|
2309
|
-
return;
|
|
2310
|
-
const focusables = container.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
2311
|
-
if (focusables.length === 0) {
|
|
2312
|
-
event.preventDefault();
|
|
2313
|
-
return;
|
|
2314
|
-
}
|
|
2315
|
-
const first = focusables[0];
|
|
2316
|
-
const last = focusables[focusables.length - 1];
|
|
2317
|
-
if (event.shiftKey) {
|
|
2318
|
-
if (document.activeElement === first) {
|
|
2319
|
-
last.focus();
|
|
2320
|
-
event.preventDefault();
|
|
2321
|
-
}
|
|
2322
|
-
} else {
|
|
2323
|
-
if (document.activeElement === last) {
|
|
2324
|
-
first.focus();
|
|
2325
|
-
event.preventDefault();
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
function onClickOutside(elements, handler) {
|
|
2330
|
-
const listener = (event) => {
|
|
2331
|
-
const target = event.target;
|
|
2332
|
-
if (!target)
|
|
2333
|
-
return;
|
|
2334
|
-
const list = Array.isArray(elements) ? elements : [elements];
|
|
2335
|
-
const isInside = list.some((el) => el?.contains(target));
|
|
2336
|
-
if (!isInside) {
|
|
2337
|
-
handler(event);
|
|
2338
|
-
}
|
|
2339
|
-
};
|
|
2340
|
-
if (typeof document !== "undefined") {
|
|
2341
|
-
document.addEventListener("mousedown", listener, true);
|
|
2342
|
-
document.addEventListener("touchstart", listener, true);
|
|
2343
|
-
}
|
|
2344
|
-
return () => {
|
|
2345
|
-
if (typeof document !== "undefined") {
|
|
2346
|
-
document.removeEventListener("mousedown", listener, true);
|
|
2347
|
-
document.removeEventListener("touchstart", listener, true);
|
|
2348
|
-
}
|
|
2349
|
-
};
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
// src/ui/tabs.tsx
|
|
2353
|
-
var TabsContext = createContext(null);
|
|
2354
|
-
function useTabsContext() {
|
|
2355
|
-
return useContext(TabsContext);
|
|
2356
|
-
}
|
|
2357
|
-
function TabsRoot(props) {
|
|
2358
|
-
const [value, setValue] = createControllableSignal({
|
|
2359
|
-
value: props.value,
|
|
2360
|
-
defaultValue: props.defaultValue ?? (props.items && props.items.length > 0 ? props.items[0]?.value : ""),
|
|
2361
|
-
onChange: props.onValueChange
|
|
2362
|
-
});
|
|
2363
|
-
const baseId = createId("tabs");
|
|
2364
|
-
const orientation = props.orientation ?? "horizontal";
|
|
2365
|
-
const activationMode = props.activationMode ?? "automatic";
|
|
2366
|
-
const ctx = {
|
|
2367
|
-
value,
|
|
2368
|
-
setValue,
|
|
2369
|
-
orientation,
|
|
2370
|
-
activationMode,
|
|
2371
|
-
baseId
|
|
2372
|
-
};
|
|
2373
|
-
const {
|
|
2374
|
-
as: Tag = "div",
|
|
2375
|
-
value: _v,
|
|
2376
|
-
defaultValue: _dv,
|
|
2377
|
-
onValueChange: _ovc,
|
|
2378
|
-
orientation: _ori,
|
|
2379
|
-
activationMode: _am,
|
|
2380
|
-
items,
|
|
2381
|
-
listClass,
|
|
2382
|
-
triggerClass,
|
|
2383
|
-
contentClass,
|
|
2384
|
-
children,
|
|
2385
|
-
class: className,
|
|
2386
|
-
style,
|
|
2387
|
-
...rest
|
|
2388
|
-
} = props;
|
|
2389
|
-
return TabsContext.Provider({
|
|
2390
|
-
value: ctx,
|
|
2391
|
-
children: () => /* @__PURE__ */ jsxs(Tag, {
|
|
2392
|
-
"data-orientation": orientation,
|
|
2393
|
-
class: className,
|
|
2394
|
-
style,
|
|
2395
|
-
...rest,
|
|
2396
|
-
children: [
|
|
2397
|
-
items ? /* @__PURE__ */ jsxs(Fragment, {
|
|
2398
|
-
children: [
|
|
2399
|
-
/* @__PURE__ */ jsx(TabsList, {
|
|
2400
|
-
class: listClass,
|
|
2401
|
-
children: items.map((item) => /* @__PURE__ */ jsxs(TabsTrigger, {
|
|
2402
|
-
value: item.value,
|
|
2403
|
-
disabled: item.disabled,
|
|
2404
|
-
class: triggerClass,
|
|
2405
|
-
children: [
|
|
2406
|
-
item.icon ? /* @__PURE__ */ jsx("span", {
|
|
2407
|
-
class: "tab-icon",
|
|
2408
|
-
style: { display: "inline-flex", alignItems: "center" },
|
|
2409
|
-
children: typeof item.icon === "function" ? item.icon() : item.icon
|
|
2410
|
-
}) : null,
|
|
2411
|
-
typeof item.label === "function" ? item.label() : item.label
|
|
2412
|
-
]
|
|
2413
|
-
}))
|
|
2414
|
-
}),
|
|
2415
|
-
items.map((item) => /* @__PURE__ */ jsx(TabsContent, {
|
|
2416
|
-
value: item.value,
|
|
2417
|
-
class: contentClass,
|
|
2418
|
-
children: typeof item.content === "function" ? item.content() : item.content
|
|
2419
|
-
}))
|
|
2420
|
-
]
|
|
2421
|
-
}) : null,
|
|
2422
|
-
typeof children === "function" ? children() : children
|
|
2423
|
-
]
|
|
2424
|
-
})
|
|
2425
|
-
});
|
|
2426
|
-
}
|
|
2427
|
-
function TabsList(props) {
|
|
2428
|
-
const ctx = useContext(TabsContext);
|
|
2429
|
-
const handleKeyDown = (e) => {
|
|
2430
|
-
if (props.onKeyDown)
|
|
2431
|
-
props.onKeyDown(e);
|
|
2432
|
-
if (e.defaultPrevented)
|
|
2433
|
-
return;
|
|
2434
|
-
const target = e.target;
|
|
2435
|
-
if (target?.getAttribute("role") !== "tab")
|
|
2436
|
-
return;
|
|
2437
|
-
const list = target.closest('[role="tablist"]');
|
|
2438
|
-
if (!list)
|
|
2439
|
-
return;
|
|
2440
|
-
const tabs = Array.from(list.querySelectorAll('[role="tab"]:not([disabled])'));
|
|
2441
|
-
const index = tabs.indexOf(target);
|
|
2442
|
-
if (index === -1)
|
|
2443
|
-
return;
|
|
2444
|
-
let nextIndex = index;
|
|
2445
|
-
const isHorizontal = (ctx?.orientation ?? "horizontal") === "horizontal";
|
|
2446
|
-
const prevKey = isHorizontal ? "ArrowLeft" : "ArrowUp";
|
|
2447
|
-
const nextKey = isHorizontal ? "ArrowRight" : "ArrowDown";
|
|
2448
|
-
if (e.key === prevKey) {
|
|
2449
|
-
nextIndex = index === 0 ? tabs.length - 1 : index - 1;
|
|
2450
|
-
e.preventDefault();
|
|
2451
|
-
} else if (e.key === nextKey) {
|
|
2452
|
-
nextIndex = index === tabs.length - 1 ? 0 : index + 1;
|
|
2453
|
-
e.preventDefault();
|
|
2454
|
-
} else if (e.key === "Home") {
|
|
2455
|
-
nextIndex = 0;
|
|
2456
|
-
e.preventDefault();
|
|
2457
|
-
} else if (e.key === "End") {
|
|
2458
|
-
nextIndex = tabs.length - 1;
|
|
2459
|
-
e.preventDefault();
|
|
2460
|
-
}
|
|
2461
|
-
if (nextIndex !== index) {
|
|
2462
|
-
const nextTab = tabs[nextIndex];
|
|
2463
|
-
nextTab.focus();
|
|
2464
|
-
if (ctx?.activationMode === "automatic") {
|
|
2465
|
-
const val = nextTab.getAttribute("data-value");
|
|
2466
|
-
if (val)
|
|
2467
|
-
ctx.setValue(val);
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
};
|
|
2471
|
-
const { as: Tag = "div", children, onKeyDown, class: className, style, ...rest } = props;
|
|
2472
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2473
|
-
role: "tablist",
|
|
2474
|
-
"aria-orientation": ctx?.orientation ?? "horizontal",
|
|
2475
|
-
class: className,
|
|
2476
|
-
style,
|
|
2477
|
-
onKeyDown: handleKeyDown,
|
|
2478
|
-
...rest,
|
|
2479
|
-
children
|
|
2480
|
-
});
|
|
2481
|
-
}
|
|
2482
|
-
function TabsTrigger(props) {
|
|
2483
|
-
const ctx = useContext(TabsContext);
|
|
2484
|
-
const isSelected = () => ctx ? ctx.value() === props.value : false;
|
|
2485
|
-
const handleClick = (e) => {
|
|
2486
|
-
if (props.onClick)
|
|
2487
|
-
props.onClick(e);
|
|
2488
|
-
if (!e.defaultPrevented && ctx) {
|
|
2489
|
-
ctx.setValue(props.value);
|
|
2490
|
-
}
|
|
2491
|
-
};
|
|
2492
|
-
const {
|
|
2493
|
-
value,
|
|
2494
|
-
disabled,
|
|
2495
|
-
as: Tag = "button",
|
|
2496
|
-
children,
|
|
2497
|
-
onClick,
|
|
2498
|
-
class: className,
|
|
2499
|
-
style,
|
|
2500
|
-
...rest
|
|
2501
|
-
} = props;
|
|
2502
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2503
|
-
id: ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
|
|
2504
|
-
type: Tag === "button" ? "button" : undefined,
|
|
2505
|
-
role: "tab",
|
|
2506
|
-
"aria-selected": isSelected,
|
|
2507
|
-
"aria-controls": ctx ? `${ctx.baseId}-panel-${value}` : undefined,
|
|
2508
|
-
"data-state": () => isSelected() ? "active" : "inactive",
|
|
2509
|
-
"data-value": value,
|
|
2510
|
-
tabIndex: () => isSelected() ? 0 : -1,
|
|
2511
|
-
disabled,
|
|
2512
|
-
class: className,
|
|
2513
|
-
style,
|
|
2514
|
-
onClick: handleClick,
|
|
2515
|
-
...rest,
|
|
2516
|
-
children
|
|
2517
|
-
});
|
|
2518
|
-
}
|
|
2519
|
-
function TabsContent(props) {
|
|
2520
|
-
const ctx = useContext(TabsContext);
|
|
2521
|
-
const isSelected = () => ctx ? ctx.value() === props.value : false;
|
|
2522
|
-
const { value, forceMount, as: Tag = "div", children, class: className, style, ...rest } = props;
|
|
2523
|
-
if (forceMount) {
|
|
2524
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2525
|
-
id: ctx ? `${ctx.baseId}-panel-${value}` : undefined,
|
|
2526
|
-
role: "tabpanel",
|
|
2527
|
-
"aria-labelledby": ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
|
|
2528
|
-
"data-state": () => isSelected() ? "active" : "inactive",
|
|
2529
|
-
hidden: () => !isSelected(),
|
|
2530
|
-
tabIndex: 0,
|
|
2531
|
-
class: className,
|
|
2532
|
-
style,
|
|
2533
|
-
...rest,
|
|
2534
|
-
children
|
|
2535
|
-
});
|
|
2536
|
-
}
|
|
2537
|
-
return /* @__PURE__ */ jsx(Show, {
|
|
2538
|
-
when: isSelected,
|
|
2539
|
-
children: /* @__PURE__ */ jsx(Tag, {
|
|
2540
|
-
id: ctx ? `${ctx.baseId}-panel-${value}` : undefined,
|
|
2541
|
-
role: "tabpanel",
|
|
2542
|
-
"aria-labelledby": ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
|
|
2543
|
-
"data-state": "active",
|
|
2544
|
-
tabIndex: 0,
|
|
2545
|
-
class: className,
|
|
2546
|
-
style,
|
|
2547
|
-
...rest,
|
|
2548
|
-
children
|
|
2549
|
-
})
|
|
2550
|
-
});
|
|
2551
|
-
}
|
|
2552
|
-
var Tabs = Object.assign(TabsRoot, {
|
|
2553
|
-
Root: TabsRoot,
|
|
2554
|
-
List: TabsList,
|
|
2555
|
-
Trigger: TabsTrigger,
|
|
2556
|
-
Content: TabsContent
|
|
2557
|
-
});
|
|
2558
|
-
|
|
2559
|
-
// src/ui/tooltip.tsx
|
|
2560
|
-
var TooltipContext = createContext(null);
|
|
2561
|
-
function useTooltipContext() {
|
|
2562
|
-
return useContext(TooltipContext);
|
|
2563
|
-
}
|
|
2564
|
-
function TooltipRoot(props) {
|
|
2565
|
-
const [open, setOpen] = createControllableSignal({
|
|
2566
|
-
value: props.open,
|
|
2567
|
-
defaultValue: props.defaultOpen ?? false,
|
|
2568
|
-
onChange: props.onOpenChange
|
|
2569
|
-
});
|
|
2570
|
-
const tooltipId = createId("tooltip");
|
|
2571
|
-
const triggerRef = { current: null };
|
|
2572
|
-
const ctx = {
|
|
2573
|
-
open,
|
|
2574
|
-
setOpen,
|
|
2575
|
-
openDelay: props.openDelay ?? 150,
|
|
2576
|
-
closeDelay: props.closeDelay ?? 100,
|
|
2577
|
-
tooltipId,
|
|
2578
|
-
triggerRef
|
|
2579
|
-
};
|
|
2580
|
-
if (props.content !== undefined) {
|
|
2581
|
-
return TooltipContext.Provider({
|
|
2582
|
-
value: ctx,
|
|
2583
|
-
children: () => /* @__PURE__ */ jsxs("span", {
|
|
2584
|
-
class: "visage-tooltip-root",
|
|
2585
|
-
style: { position: "relative", display: "inline-flex", alignItems: "center" },
|
|
2586
|
-
children: [
|
|
2587
|
-
/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
2588
|
-
as: props.triggerAs ?? "button",
|
|
2589
|
-
class: props.triggerClass,
|
|
2590
|
-
style: {
|
|
2591
|
-
background: "transparent",
|
|
2592
|
-
border: "none",
|
|
2593
|
-
padding: 0,
|
|
2594
|
-
display: "inline-flex",
|
|
2595
|
-
alignItems: "center",
|
|
2596
|
-
cursor: "help"
|
|
2597
|
-
},
|
|
2598
|
-
children: typeof props.children === "function" ? props.children() : props.children
|
|
2599
|
-
}),
|
|
2600
|
-
/* @__PURE__ */ jsx(TooltipContent, {
|
|
2601
|
-
side: props.side,
|
|
2602
|
-
class: props.contentClass,
|
|
2603
|
-
style: props.contentStyle,
|
|
2604
|
-
portalled: props.portalled ?? false,
|
|
2605
|
-
children: typeof props.content === "function" ? props.content() : props.content
|
|
2606
|
-
})
|
|
2607
|
-
]
|
|
2608
|
-
})
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
return TooltipContext.Provider({
|
|
2612
|
-
value: ctx,
|
|
2613
|
-
children: props.children
|
|
2614
|
-
});
|
|
2615
|
-
}
|
|
2616
|
-
function TooltipTrigger(props) {
|
|
2617
|
-
const ctx = useContext(TooltipContext);
|
|
2618
|
-
let openTimer = null;
|
|
2619
|
-
let closeTimer = null;
|
|
2620
|
-
const clearTimers = () => {
|
|
2621
|
-
if (openTimer)
|
|
2622
|
-
clearTimeout(openTimer);
|
|
2623
|
-
if (closeTimer)
|
|
2624
|
-
clearTimeout(closeTimer);
|
|
2625
|
-
openTimer = null;
|
|
2626
|
-
closeTimer = null;
|
|
2627
|
-
};
|
|
2628
|
-
const handleMouseEnter = (e) => {
|
|
2629
|
-
if (props.onMouseEnter)
|
|
2630
|
-
props.onMouseEnter(e);
|
|
2631
|
-
clearTimers();
|
|
2632
|
-
if (!ctx)
|
|
2633
|
-
return;
|
|
2634
|
-
if (ctx.openDelay > 0) {
|
|
2635
|
-
openTimer = setTimeout(() => ctx.setOpen(true), ctx.openDelay);
|
|
2636
|
-
} else {
|
|
2637
|
-
ctx.setOpen(true);
|
|
2638
|
-
}
|
|
2639
|
-
};
|
|
2640
|
-
const handleMouseLeave = (e) => {
|
|
2641
|
-
if (props.onMouseLeave)
|
|
2642
|
-
props.onMouseLeave(e);
|
|
2643
|
-
clearTimers();
|
|
2644
|
-
if (!ctx)
|
|
2645
|
-
return;
|
|
2646
|
-
if (ctx.closeDelay > 0) {
|
|
2647
|
-
closeTimer = setTimeout(() => ctx.setOpen(false), ctx.closeDelay);
|
|
2648
|
-
} else {
|
|
2649
|
-
ctx.setOpen(false);
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2652
|
-
const handleFocus = (e) => {
|
|
2653
|
-
if (props.onFocus)
|
|
2654
|
-
props.onFocus(e);
|
|
2655
|
-
clearTimers();
|
|
2656
|
-
ctx?.setOpen(true);
|
|
2657
|
-
};
|
|
2658
|
-
const handleBlur = (e) => {
|
|
2659
|
-
if (props.onBlur)
|
|
2660
|
-
props.onBlur(e);
|
|
2661
|
-
clearTimers();
|
|
2662
|
-
ctx?.setOpen(false);
|
|
2663
|
-
};
|
|
2664
|
-
onCleanup(clearTimers);
|
|
2665
|
-
const {
|
|
2666
|
-
as: Tag = "button",
|
|
2667
|
-
children,
|
|
2668
|
-
onMouseEnter,
|
|
2669
|
-
onMouseLeave,
|
|
2670
|
-
onFocus,
|
|
2671
|
-
onBlur,
|
|
2672
|
-
class: className,
|
|
2673
|
-
style,
|
|
2674
|
-
...rest
|
|
2675
|
-
} = props;
|
|
2676
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2677
|
-
ref: (el) => {
|
|
2678
|
-
if (ctx)
|
|
2679
|
-
ctx.triggerRef.current = el;
|
|
2680
|
-
},
|
|
2681
|
-
type: Tag === "button" ? "button" : undefined,
|
|
2682
|
-
tabIndex: Tag === "button" ? undefined : 0,
|
|
2683
|
-
"aria-describedby": ctx?.tooltipId,
|
|
2684
|
-
"data-state": () => ctx?.open() ? "open" : "closed",
|
|
2685
|
-
class: className,
|
|
2686
|
-
style: { display: "inline-flex", alignItems: "center", ...style },
|
|
2687
|
-
onMouseEnter: handleMouseEnter,
|
|
2688
|
-
onMouseLeave: handleMouseLeave,
|
|
2689
|
-
onFocus: handleFocus,
|
|
2690
|
-
onBlur: handleBlur,
|
|
2691
|
-
...rest,
|
|
2692
|
-
children
|
|
2693
|
-
});
|
|
2694
|
-
}
|
|
2695
|
-
function TooltipPortal(props) {
|
|
2696
|
-
return /* @__PURE__ */ jsx(Portal, {
|
|
2697
|
-
mount: props.mount,
|
|
2698
|
-
children: props.children
|
|
2699
|
-
});
|
|
2700
|
-
}
|
|
2701
|
-
function TooltipContent(props) {
|
|
2702
|
-
const ctx = useContext(TooltipContext);
|
|
2703
|
-
const isOpen = () => ctx ? ctx.open() : false;
|
|
2704
|
-
const {
|
|
2705
|
-
forceMount,
|
|
2706
|
-
as: Tag = "div",
|
|
2707
|
-
children,
|
|
2708
|
-
class: className,
|
|
2709
|
-
style,
|
|
2710
|
-
portalled = true,
|
|
2711
|
-
mount,
|
|
2712
|
-
...rest
|
|
2713
|
-
} = props;
|
|
2714
|
-
const content = forceMount ? /* @__PURE__ */ jsx(Tag, {
|
|
2715
|
-
id: ctx?.tooltipId,
|
|
2716
|
-
role: "tooltip",
|
|
2717
|
-
"data-state": () => isOpen() ? "open" : "closed",
|
|
2718
|
-
hidden: () => !isOpen(),
|
|
2719
|
-
class: className,
|
|
2720
|
-
style,
|
|
2721
|
-
...rest,
|
|
2722
|
-
children
|
|
2723
|
-
}) : /* @__PURE__ */ jsx(Show, {
|
|
2724
|
-
when: isOpen,
|
|
2725
|
-
children: /* @__PURE__ */ jsx(Tag, {
|
|
2726
|
-
id: ctx?.tooltipId,
|
|
2727
|
-
role: "tooltip",
|
|
2728
|
-
"data-state": "open",
|
|
2729
|
-
class: className,
|
|
2730
|
-
style,
|
|
2731
|
-
...rest,
|
|
2732
|
-
children
|
|
2733
|
-
})
|
|
2734
|
-
});
|
|
2735
|
-
return portalled ? /* @__PURE__ */ jsx(Portal, {
|
|
2736
|
-
mount,
|
|
2737
|
-
children: content
|
|
2738
|
-
}) : content;
|
|
2739
|
-
}
|
|
2740
|
-
var Tooltip = Object.assign(TooltipRoot, {
|
|
2741
|
-
Root: TooltipRoot,
|
|
2742
|
-
Trigger: TooltipTrigger,
|
|
2743
|
-
Portal: TooltipPortal,
|
|
2744
|
-
Content: TooltipContent
|
|
2745
|
-
});
|
|
2746
|
-
|
|
2747
|
-
// src/ui/switch.tsx
|
|
2748
|
-
function SwitchRoot(props) {
|
|
2749
|
-
const [checked, setChecked] = createControllableSignal({
|
|
2750
|
-
value: props.checked,
|
|
2751
|
-
defaultValue: props.defaultChecked ?? false,
|
|
2752
|
-
onChange: props.onCheckedChange
|
|
2753
|
-
});
|
|
2754
|
-
const toggle = () => {
|
|
2755
|
-
const isDisabled = typeof props.disabled === "function" ? props.disabled() : Boolean(props.disabled);
|
|
2756
|
-
if (isDisabled)
|
|
2757
|
-
return;
|
|
2758
|
-
setChecked(!checked());
|
|
2759
|
-
};
|
|
2760
|
-
const handleClick = (e) => {
|
|
2761
|
-
if (props.onClick)
|
|
2762
|
-
props.onClick(e);
|
|
2763
|
-
if (!e.defaultPrevented) {
|
|
2764
|
-
toggle();
|
|
2765
|
-
}
|
|
2766
|
-
};
|
|
2767
|
-
const handleKeyDown = (e) => {
|
|
2768
|
-
if (props.onKeyDown)
|
|
2769
|
-
props.onKeyDown(e);
|
|
2770
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
2771
|
-
e.preventDefault();
|
|
2772
|
-
toggle();
|
|
2773
|
-
}
|
|
2774
|
-
};
|
|
2775
|
-
const {
|
|
2776
|
-
checked: _c,
|
|
2777
|
-
defaultChecked: _dc,
|
|
2778
|
-
onCheckedChange: _occ,
|
|
2779
|
-
disabled,
|
|
2780
|
-
required,
|
|
2781
|
-
name,
|
|
2782
|
-
value,
|
|
2783
|
-
thumbClass,
|
|
2784
|
-
thumbStyle,
|
|
2785
|
-
as: Tag = "button",
|
|
2786
|
-
children,
|
|
2787
|
-
onClick,
|
|
2788
|
-
onKeyDown,
|
|
2789
|
-
class: className,
|
|
2790
|
-
style,
|
|
2791
|
-
...rest
|
|
2792
|
-
} = props;
|
|
2793
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2794
|
-
type: Tag === "button" ? "button" : undefined,
|
|
2795
|
-
role: "switch",
|
|
2796
|
-
"aria-checked": checked,
|
|
2797
|
-
"data-state": () => checked() ? "checked" : "unchecked",
|
|
2798
|
-
disabled,
|
|
2799
|
-
class: className,
|
|
2800
|
-
style,
|
|
2801
|
-
onClick: handleClick,
|
|
2802
|
-
onKeyDown: handleKeyDown,
|
|
2803
|
-
...rest,
|
|
2804
|
-
children: children !== undefined ? typeof children === "function" ? children() : children : /* @__PURE__ */ jsx(SwitchThumb, {
|
|
2805
|
-
class: thumbClass,
|
|
2806
|
-
style: thumbStyle
|
|
2807
|
-
})
|
|
2808
|
-
});
|
|
2809
|
-
}
|
|
2810
|
-
function SwitchThumb(props) {
|
|
2811
|
-
const { as: Tag = "span", class: className, style, ...rest } = props;
|
|
2812
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
2813
|
-
class: className,
|
|
2814
|
-
style,
|
|
2815
|
-
...rest
|
|
2816
|
-
});
|
|
2817
|
-
}
|
|
2818
|
-
var Switch = Object.assign(SwitchRoot, {
|
|
2819
|
-
Root: SwitchRoot,
|
|
2820
|
-
Thumb: SwitchThumb
|
|
2821
|
-
});
|
|
2822
|
-
|
|
2823
|
-
// src/devtools/DomTab.tsx
|
|
2824
|
-
function DomTab(props) {
|
|
2825
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2826
|
-
style: { flex: 1, padding: "24px", overflowY: "auto", background: "#090d16" },
|
|
2827
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2828
|
-
style: { maxWidth: "700px", margin: "0 auto" },
|
|
2829
|
-
children: [
|
|
2830
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2831
|
-
style: {
|
|
2832
|
-
display: "flex",
|
|
2833
|
-
alignItems: "center",
|
|
2834
|
-
justifyContent: "space-between",
|
|
2835
|
-
marginBottom: "20px"
|
|
2836
|
-
},
|
|
2837
|
-
children: [
|
|
2838
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2839
|
-
children: [
|
|
2840
|
-
/* @__PURE__ */ jsx("h3", {
|
|
2841
|
-
style: { margin: "0 0 6px 0", color: "#f8fafc", fontSize: "16px", fontWeight: 700 },
|
|
2842
|
-
children: "Real-Time DOM Mutation Highlighter"
|
|
2843
|
-
}),
|
|
2844
|
-
/* @__PURE__ */ jsx("p", {
|
|
2845
|
-
style: { margin: 0, color: "#94a3b8", fontSize: "13px", lineHeight: 1.5 },
|
|
2846
|
-
children: "Visage uses zero Virtual DOM and fine-grained reactivity. Only exact text nodes and attributes update in-place."
|
|
2847
|
-
})
|
|
2848
|
-
]
|
|
2849
|
-
}),
|
|
2850
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2851
|
-
style: { display: "flex", alignItems: "center", gap: "10px" },
|
|
2852
|
-
children: [
|
|
2853
|
-
/* @__PURE__ */ jsx("span", {
|
|
2854
|
-
style: {
|
|
2855
|
-
fontSize: "11px",
|
|
2856
|
-
fontWeight: 700,
|
|
2857
|
-
letterSpacing: "0.04em",
|
|
2858
|
-
color: () => props.hub.highlightDOM() ? "#10b981" : "#64748b"
|
|
2859
|
-
},
|
|
2860
|
-
children: () => props.hub.highlightDOM() ? "ENABLED" : "DISABLED"
|
|
2861
|
-
}),
|
|
2862
|
-
/* @__PURE__ */ jsx(Switch, {
|
|
2863
|
-
checked: props.hub.highlightDOM,
|
|
2864
|
-
onCheckedChange: (val) => props.hub.highlightDOM.set(val)
|
|
2865
|
-
})
|
|
2866
|
-
]
|
|
2867
|
-
})
|
|
2868
|
-
]
|
|
2869
|
-
}),
|
|
2870
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2871
|
-
style: {
|
|
2872
|
-
background: "#0c111d",
|
|
2873
|
-
border: "1px solid #1e293b",
|
|
2874
|
-
borderRadius: "8px",
|
|
2875
|
-
padding: "16px",
|
|
2876
|
-
marginBottom: "20px"
|
|
2877
|
-
},
|
|
2878
|
-
children: [
|
|
2879
|
-
/* @__PURE__ */ jsx("h4", {
|
|
2880
|
-
style: { margin: "0 0 10px 0", color: "#38bdf8", fontSize: "13px", fontWeight: 600 },
|
|
2881
|
-
children: "Usage Instructions:"
|
|
2882
|
-
}),
|
|
2883
|
-
/* @__PURE__ */ jsxs("ul", {
|
|
2884
|
-
style: {
|
|
2885
|
-
margin: 0,
|
|
2886
|
-
paddingLeft: "20px",
|
|
2887
|
-
color: "#cbd5e1",
|
|
2888
|
-
fontSize: "13px",
|
|
2889
|
-
lineHeight: 1.6
|
|
2890
|
-
},
|
|
2891
|
-
children: [
|
|
2892
|
-
/* @__PURE__ */ jsx("li", {
|
|
2893
|
-
children: "Toggle the switch above to enable visual flashing outlines across your app."
|
|
2894
|
-
}),
|
|
2895
|
-
/* @__PURE__ */ jsx("li", {
|
|
2896
|
-
children: "Interact with buttons, form inputs, tabs, and modals in your application."
|
|
2897
|
-
}),
|
|
2898
|
-
/* @__PURE__ */ jsxs("li", {
|
|
2899
|
-
children: [
|
|
2900
|
-
"Notice that ",
|
|
2901
|
-
/* @__PURE__ */ jsx("strong", {
|
|
2902
|
-
children: "only the exact updated node flashes"
|
|
2903
|
-
}),
|
|
2904
|
-
" without re-rendering the whole component or tree."
|
|
2905
|
-
]
|
|
2906
|
-
})
|
|
2907
|
-
]
|
|
2908
|
-
})
|
|
2909
|
-
]
|
|
2910
|
-
}),
|
|
2911
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2912
|
-
style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "12px" },
|
|
2913
|
-
children: [
|
|
2914
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2915
|
-
style: {
|
|
2916
|
-
background: "#0c111d",
|
|
2917
|
-
border: "1px solid #1e293b",
|
|
2918
|
-
borderRadius: "8px",
|
|
2919
|
-
padding: "14px"
|
|
2920
|
-
},
|
|
2921
|
-
children: [
|
|
2922
|
-
/* @__PURE__ */ jsx("div", {
|
|
2923
|
-
style: {
|
|
2924
|
-
fontWeight: 700,
|
|
2925
|
-
color: "#f87171",
|
|
2926
|
-
marginBottom: "6px",
|
|
2927
|
-
fontSize: "12px",
|
|
2928
|
-
textTransform: "uppercase",
|
|
2929
|
-
letterSpacing: "0.04em"
|
|
2930
|
-
},
|
|
2931
|
-
children: "Virtual DOM Model"
|
|
2932
|
-
}),
|
|
2933
|
-
/* @__PURE__ */ jsx("p", {
|
|
2934
|
-
style: { margin: 0, color: "#94a3b8", fontSize: "12px", lineHeight: 1.5 },
|
|
2935
|
-
children: "State changes re-run entire component functions, allocate temporary Virtual DOM nodes, and diff tree structures."
|
|
2936
|
-
})
|
|
2937
|
-
]
|
|
2938
|
-
}),
|
|
2939
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2940
|
-
style: {
|
|
2941
|
-
background: "#0c111d",
|
|
2942
|
-
border: "1px solid #1e293b",
|
|
2943
|
-
borderRadius: "8px",
|
|
2944
|
-
padding: "14px"
|
|
2945
|
-
},
|
|
2946
|
-
children: [
|
|
2947
|
-
/* @__PURE__ */ jsx("div", {
|
|
2948
|
-
style: {
|
|
2949
|
-
fontWeight: 700,
|
|
2950
|
-
color: "#34d399",
|
|
2951
|
-
marginBottom: "6px",
|
|
2952
|
-
fontSize: "12px",
|
|
2953
|
-
textTransform: "uppercase",
|
|
2954
|
-
letterSpacing: "0.04em"
|
|
2955
|
-
},
|
|
2956
|
-
children: "Visage Reactive Engine"
|
|
2957
|
-
}),
|
|
2958
|
-
/* @__PURE__ */ jsx("p", {
|
|
2959
|
-
style: { margin: 0, color: "#94a3b8", fontSize: "12px", lineHeight: 1.5 },
|
|
2960
|
-
children: "Component functions execute once during mounting. Signals push direct in-place mutations at native DOM speed."
|
|
2961
|
-
})
|
|
2962
|
-
]
|
|
2963
|
-
})
|
|
2964
|
-
]
|
|
2965
|
-
})
|
|
2966
|
-
]
|
|
2967
|
-
})
|
|
2968
|
-
});
|
|
2969
|
-
}
|
|
2970
|
-
|
|
2971
|
-
// src/devtools/GraphInspector.tsx
|
|
2972
|
-
function GraphInspector(props) {
|
|
2973
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2974
|
-
style: {
|
|
2975
|
-
width: "320px",
|
|
2976
|
-
borderLeft: "1px solid #1e293b",
|
|
2977
|
-
background: "#090d16",
|
|
2978
|
-
padding: "16px",
|
|
2979
|
-
overflowY: "auto"
|
|
2980
|
-
},
|
|
2981
|
-
children: /* @__PURE__ */ jsx(Show, {
|
|
2982
|
-
when: props.selectedNode,
|
|
2983
|
-
fallback: /* @__PURE__ */ jsxs("div", {
|
|
2984
|
-
style: {
|
|
2985
|
-
color: "#64748b",
|
|
2986
|
-
textAlign: "center",
|
|
2987
|
-
marginTop: "30px",
|
|
2988
|
-
fontSize: "12px",
|
|
2989
|
-
lineHeight: 1.6
|
|
2990
|
-
},
|
|
2991
|
-
children: [
|
|
2992
|
-
/* @__PURE__ */ jsx("p", {
|
|
2993
|
-
children: "Select any DAG node to inspect live dependencies, downstream subscribers, and reactive version history."
|
|
2994
|
-
}),
|
|
2995
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2996
|
-
style: {
|
|
2997
|
-
marginTop: "16px",
|
|
2998
|
-
padding: "12px",
|
|
2999
|
-
background: "#0f172a",
|
|
3000
|
-
borderRadius: "6px",
|
|
3001
|
-
textAlign: "left"
|
|
3002
|
-
},
|
|
3003
|
-
children: [
|
|
3004
|
-
/* @__PURE__ */ jsx("div", {
|
|
3005
|
-
style: { color: "#94a3b8", fontWeight: 600, marginBottom: "4px", fontSize: "11px" },
|
|
3006
|
-
children: "Legend:"
|
|
3007
|
-
}),
|
|
3008
|
-
/* @__PURE__ */ jsx("div", {
|
|
3009
|
-
style: { color: "#38bdf8", fontSize: "11px" },
|
|
3010
|
-
children: "[SIG] Upstream Source Signals"
|
|
3011
|
-
}),
|
|
3012
|
-
/* @__PURE__ */ jsx("div", {
|
|
3013
|
-
style: { color: "#c084fc", fontSize: "11px" },
|
|
3014
|
-
children: "[CMP] Derived Computeds"
|
|
3015
|
-
})
|
|
3016
|
-
]
|
|
3017
|
-
})
|
|
3018
|
-
]
|
|
3019
|
-
}),
|
|
3020
|
-
children: (node) => {
|
|
3021
|
-
const deps = () => props.getDependencies(node());
|
|
3022
|
-
const targets = () => props.getDependents(node());
|
|
3023
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3024
|
-
children: [
|
|
3025
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3026
|
-
style: {
|
|
3027
|
-
display: "flex",
|
|
3028
|
-
justifyContent: "space-between",
|
|
3029
|
-
alignItems: "flex-start",
|
|
3030
|
-
marginBottom: "12px"
|
|
3031
|
-
},
|
|
3032
|
-
children: [
|
|
3033
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3034
|
-
children: [
|
|
3035
|
-
/* @__PURE__ */ jsx("h4", {
|
|
3036
|
-
style: { margin: "0 0 2px 0", color: "#f1f5f9", fontSize: "15px" },
|
|
3037
|
-
children: () => node().name
|
|
3038
|
-
}),
|
|
3039
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3040
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3041
|
-
children: [
|
|
3042
|
-
"ID: ",
|
|
3043
|
-
() => node().id
|
|
3044
|
-
]
|
|
3045
|
-
})
|
|
3046
|
-
]
|
|
3047
|
-
}),
|
|
3048
|
-
/* @__PURE__ */ jsx("button", {
|
|
3049
|
-
type: "button",
|
|
3050
|
-
class: "visage-devtools-btn",
|
|
3051
|
-
onClick: () => props.selectedId.set(null),
|
|
3052
|
-
title: "Clear Selection",
|
|
3053
|
-
children: "Clear"
|
|
3054
|
-
})
|
|
3055
|
-
]
|
|
3056
|
-
}),
|
|
3057
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3058
|
-
style: { display: "flex", gap: "6px", marginBottom: "16px" },
|
|
3059
|
-
children: [
|
|
3060
|
-
/* @__PURE__ */ jsx("span", {
|
|
3061
|
-
class: "visage-devtools-badge",
|
|
3062
|
-
style: {
|
|
3063
|
-
background: () => node().type === "computed" ? "#581c87" : "#0369a1",
|
|
3064
|
-
color: "#fff"
|
|
3065
|
-
},
|
|
3066
|
-
children: () => node().type.toUpperCase()
|
|
3067
|
-
}),
|
|
3068
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3069
|
-
class: "visage-devtools-badge",
|
|
3070
|
-
children: [
|
|
3071
|
-
"VERSION: ",
|
|
3072
|
-
() => node().version()
|
|
3073
|
-
]
|
|
3074
|
-
})
|
|
3075
|
-
]
|
|
3076
|
-
}),
|
|
3077
|
-
/* @__PURE__ */ jsx("div", {
|
|
3078
|
-
style: { fontSize: "12px", color: "#94a3b8", marginBottom: "6px" },
|
|
3079
|
-
children: "Live Value:"
|
|
3080
|
-
}),
|
|
3081
|
-
/* @__PURE__ */ jsx("pre", {
|
|
3082
|
-
class: "visage-devtools-json",
|
|
3083
|
-
style: { marginBottom: "16px" },
|
|
3084
|
-
children: () => props.formatJSON(node().getValue())
|
|
3085
|
-
}),
|
|
3086
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3087
|
-
style: { marginBottom: "16px" },
|
|
3088
|
-
children: [
|
|
3089
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3090
|
-
style: {
|
|
3091
|
-
fontSize: "11px",
|
|
3092
|
-
fontWeight: 700,
|
|
3093
|
-
textTransform: "uppercase",
|
|
3094
|
-
color: "#38bdf8",
|
|
3095
|
-
marginBottom: "6px"
|
|
3096
|
-
},
|
|
3097
|
-
children: [
|
|
3098
|
-
"Upstream Inputs (",
|
|
3099
|
-
() => deps().length,
|
|
3100
|
-
")"
|
|
3101
|
-
]
|
|
3102
|
-
}),
|
|
3103
|
-
() => deps().length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
3104
|
-
style: { display: "flex", flexDirection: "column", gap: "6px" },
|
|
3105
|
-
children: deps().map((d) => /* @__PURE__ */ jsxs("div", {
|
|
3106
|
-
class: "visage-graph-pill source",
|
|
3107
|
-
style: {
|
|
3108
|
-
width: "100%",
|
|
3109
|
-
justifyContent: "space-between",
|
|
3110
|
-
padding: "6px 8px"
|
|
3111
|
-
},
|
|
3112
|
-
onClick: () => props.selectedId.set(d.id),
|
|
3113
|
-
children: [
|
|
3114
|
-
/* @__PURE__ */ jsx("span", {
|
|
3115
|
-
children: d.name
|
|
3116
|
-
}),
|
|
3117
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3118
|
-
style: { color: "#94a3b8" },
|
|
3119
|
-
children: [
|
|
3120
|
-
"v",
|
|
3121
|
-
d.version()
|
|
3122
|
-
]
|
|
3123
|
-
})
|
|
3124
|
-
]
|
|
3125
|
-
}))
|
|
3126
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
3127
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3128
|
-
children: "None (Root Reactive Source)"
|
|
3129
|
-
})
|
|
3130
|
-
]
|
|
3131
|
-
}),
|
|
3132
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3133
|
-
children: [
|
|
3134
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3135
|
-
style: {
|
|
3136
|
-
fontSize: "11px",
|
|
3137
|
-
fontWeight: 700,
|
|
3138
|
-
textTransform: "uppercase",
|
|
3139
|
-
color: "#c084fc",
|
|
3140
|
-
marginBottom: "6px"
|
|
3141
|
-
},
|
|
3142
|
-
children: [
|
|
3143
|
-
"Downstream Consumers (",
|
|
3144
|
-
() => targets().length,
|
|
3145
|
-
")"
|
|
3146
|
-
]
|
|
3147
|
-
}),
|
|
3148
|
-
() => targets().length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
3149
|
-
style: { display: "flex", flexDirection: "column", gap: "6px" },
|
|
3150
|
-
children: targets().map((t) => /* @__PURE__ */ jsxs("div", {
|
|
3151
|
-
class: "visage-graph-pill target",
|
|
3152
|
-
style: {
|
|
3153
|
-
width: "100%",
|
|
3154
|
-
justifyContent: "space-between",
|
|
3155
|
-
padding: "6px 8px"
|
|
3156
|
-
},
|
|
3157
|
-
onClick: () => props.selectedId.set(t.id),
|
|
3158
|
-
children: [
|
|
3159
|
-
/* @__PURE__ */ jsx("span", {
|
|
3160
|
-
children: t.name
|
|
3161
|
-
}),
|
|
3162
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3163
|
-
style: { color: "#94a3b8" },
|
|
3164
|
-
children: [
|
|
3165
|
-
"v",
|
|
3166
|
-
t.version()
|
|
3167
|
-
]
|
|
3168
|
-
})
|
|
3169
|
-
]
|
|
3170
|
-
}))
|
|
3171
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
3172
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3173
|
-
children: "None (Leaf / UI Consumer)"
|
|
3174
|
-
})
|
|
3175
|
-
]
|
|
3176
|
-
})
|
|
3177
|
-
]
|
|
3178
|
-
});
|
|
3179
|
-
}
|
|
3180
|
-
})
|
|
3181
|
-
});
|
|
3182
|
-
}
|
|
3183
|
-
|
|
3184
|
-
// src/devtools/GraphTab.tsx
|
|
3185
|
-
function GraphTab(props) {
|
|
3186
|
-
const [filterType, setFilterType] = createSignal("all", {
|
|
3187
|
-
internal: true
|
|
3188
|
-
});
|
|
3189
|
-
const [hoveredId, setHoveredId] = createSignal(null, { internal: true });
|
|
3190
|
-
const allSignals = () => props.hub.signalsList();
|
|
3191
|
-
const getDependencies = (node) => {
|
|
3192
|
-
const depIds = node.dependencies ? node.dependencies() : [];
|
|
3193
|
-
if (depIds.length === 0)
|
|
3194
|
-
return [];
|
|
3195
|
-
return allSignals().filter((s) => depIds.includes(s.id));
|
|
3196
|
-
};
|
|
3197
|
-
const getDependents = (node) => {
|
|
3198
|
-
const directDependents = node.dependents ? node.dependents() : [];
|
|
3199
|
-
return allSignals().filter((s) => directDependents.includes(s.id) || s.dependencies?.().includes(node.id));
|
|
3200
|
-
};
|
|
3201
|
-
const activeFocusId = () => hoveredId() ?? props.selectedId();
|
|
3202
|
-
const focusedDeps = () => {
|
|
3203
|
-
const id = activeFocusId();
|
|
3204
|
-
if (!id)
|
|
3205
|
-
return [];
|
|
3206
|
-
const node = allSignals().find((s) => s.id === id);
|
|
3207
|
-
if (!node)
|
|
3208
|
-
return [];
|
|
3209
|
-
return getDependencies(node).map((s) => s.id);
|
|
3210
|
-
};
|
|
3211
|
-
const focusedTargets = () => {
|
|
3212
|
-
const id = activeFocusId();
|
|
3213
|
-
if (!id)
|
|
3214
|
-
return [];
|
|
3215
|
-
const node = allSignals().find((s) => s.id === id);
|
|
3216
|
-
if (!node)
|
|
3217
|
-
return [];
|
|
3218
|
-
return getDependents(node).map((s) => s.id);
|
|
3219
|
-
};
|
|
3220
|
-
const filteredSignals = () => allSignals().filter((s) => {
|
|
3221
|
-
const q = props.searchQuery().toLowerCase().trim();
|
|
3222
|
-
const matchQuery = !q || s.name.toLowerCase().includes(q) || s.id.toLowerCase().includes(q);
|
|
3223
|
-
const matchType = filterType() === "all" || s.type === filterType();
|
|
3224
|
-
return matchQuery && matchType;
|
|
3225
|
-
});
|
|
3226
|
-
const stateSignals = () => filteredSignals().filter((s) => s.type === "signal");
|
|
3227
|
-
const computedSignals = () => filteredSignals().filter((s) => s.type === "computed");
|
|
3228
|
-
const selectedNode = () => {
|
|
3229
|
-
const id = props.selectedId();
|
|
3230
|
-
if (!id)
|
|
3231
|
-
return null;
|
|
3232
|
-
return allSignals().find((s) => s.id === id) ?? null;
|
|
3233
|
-
};
|
|
3234
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3235
|
-
class: "visage-graph-container",
|
|
3236
|
-
children: [
|
|
3237
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3238
|
-
class: "visage-graph-toolbar",
|
|
3239
|
-
children: [
|
|
3240
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3241
|
-
style: { display: "flex", alignItems: "center", gap: "10px" },
|
|
3242
|
-
children: [
|
|
3243
|
-
/* @__PURE__ */ jsx("input", {
|
|
3244
|
-
class: "visage-devtools-input",
|
|
3245
|
-
style: { width: "200px" },
|
|
3246
|
-
placeholder: "Filter DAG graph...",
|
|
3247
|
-
value: props.searchQuery,
|
|
3248
|
-
onInput: (e) => props.searchQuery.set(e.target.value)
|
|
3249
|
-
}),
|
|
3250
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3251
|
-
style: { display: "flex", gap: "4px" },
|
|
3252
|
-
children: [
|
|
3253
|
-
/* @__PURE__ */ jsxs("button", {
|
|
3254
|
-
type: "button",
|
|
3255
|
-
class: () => `visage-devtools-btn ${filterType() === "all" ? "active" : ""}`,
|
|
3256
|
-
onClick: () => setFilterType("all"),
|
|
3257
|
-
children: [
|
|
3258
|
-
"All (",
|
|
3259
|
-
() => filteredSignals().length,
|
|
3260
|
-
")"
|
|
3261
|
-
]
|
|
3262
|
-
}),
|
|
3263
|
-
/* @__PURE__ */ jsxs("button", {
|
|
3264
|
-
type: "button",
|
|
3265
|
-
class: () => `visage-devtools-btn ${filterType() === "signal" ? "active" : ""}`,
|
|
3266
|
-
onClick: () => setFilterType("signal"),
|
|
3267
|
-
children: [
|
|
3268
|
-
"Signals (",
|
|
3269
|
-
() => stateSignals().length,
|
|
3270
|
-
")"
|
|
3271
|
-
]
|
|
3272
|
-
}),
|
|
3273
|
-
/* @__PURE__ */ jsxs("button", {
|
|
3274
|
-
type: "button",
|
|
3275
|
-
class: () => `visage-devtools-btn ${filterType() === "computed" ? "active" : ""}`,
|
|
3276
|
-
onClick: () => setFilterType("computed"),
|
|
3277
|
-
children: [
|
|
3278
|
-
"Computeds (",
|
|
3279
|
-
() => computedSignals().length,
|
|
3280
|
-
")"
|
|
3281
|
-
]
|
|
3282
|
-
})
|
|
3283
|
-
]
|
|
3284
|
-
})
|
|
3285
|
-
]
|
|
3286
|
-
}),
|
|
3287
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3288
|
-
style: {
|
|
3289
|
-
fontSize: "11px",
|
|
3290
|
-
color: "#64748b",
|
|
3291
|
-
display: "flex",
|
|
3292
|
-
gap: "14px",
|
|
3293
|
-
alignItems: "center"
|
|
3294
|
-
},
|
|
3295
|
-
children: [
|
|
3296
|
-
/* @__PURE__ */ jsx("span", {
|
|
3297
|
-
style: { color: "#38bdf8" },
|
|
3298
|
-
children: "[SIG] Upstream"
|
|
3299
|
-
}),
|
|
3300
|
-
/* @__PURE__ */ jsx("span", {
|
|
3301
|
-
style: { color: "#c084fc" },
|
|
3302
|
-
children: "[CMP] Derived"
|
|
3303
|
-
}),
|
|
3304
|
-
/* @__PURE__ */ jsx("span", {
|
|
3305
|
-
style: { color: "#10b981" },
|
|
3306
|
-
children: "Glitch-Free DAG"
|
|
3307
|
-
})
|
|
3308
|
-
]
|
|
3309
|
-
})
|
|
3310
|
-
]
|
|
3311
|
-
}),
|
|
3312
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3313
|
-
style: { flex: 1, display: "flex", overflow: "hidden" },
|
|
3314
|
-
children: [
|
|
3315
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3316
|
-
class: "visage-graph-canvas",
|
|
3317
|
-
children: [
|
|
3318
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3319
|
-
class: "visage-graph-column",
|
|
3320
|
-
children: [
|
|
3321
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3322
|
-
class: "visage-graph-col-header",
|
|
3323
|
-
children: [
|
|
3324
|
-
/* @__PURE__ */ jsx("span", {
|
|
3325
|
-
class: "visage-graph-pulse"
|
|
3326
|
-
}),
|
|
3327
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3328
|
-
children: [
|
|
3329
|
-
"Reactive Sources (",
|
|
3330
|
-
() => stateSignals().length,
|
|
3331
|
-
")"
|
|
3332
|
-
]
|
|
3333
|
-
})
|
|
3334
|
-
]
|
|
3335
|
-
}),
|
|
3336
|
-
/* @__PURE__ */ jsx(For, {
|
|
3337
|
-
each: stateSignals,
|
|
3338
|
-
children: (node) => {
|
|
3339
|
-
const isSelected = () => props.selectedId() === node.id;
|
|
3340
|
-
const isDep = () => focusedDeps().includes(node.id);
|
|
3341
|
-
const isTarget = () => focusedTargets().includes(node.id);
|
|
3342
|
-
const isDimmed = () => activeFocusId() !== null && !isSelected() && !isDep() && !isTarget();
|
|
3343
|
-
const dependents = () => getDependents(node);
|
|
3344
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3345
|
-
class: () => `visage-graph-node ${isSelected() ? "selected" : ""} ${isDep() ? "is-dependency" : ""} ${isTarget() ? "is-dependent" : ""} ${isDimmed() ? "is-dimmed" : ""}`,
|
|
3346
|
-
onClick: () => props.selectedId.set(node.id),
|
|
3347
|
-
onMouseEnter: () => setHoveredId(node.id),
|
|
3348
|
-
onMouseLeave: () => setHoveredId(null),
|
|
3349
|
-
children: [
|
|
3350
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3351
|
-
class: "visage-graph-node-title",
|
|
3352
|
-
children: [
|
|
3353
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3354
|
-
style: {
|
|
3355
|
-
color: "#f8fafc",
|
|
3356
|
-
display: "inline-flex",
|
|
3357
|
-
alignItems: "center",
|
|
3358
|
-
gap: "6px"
|
|
3359
|
-
},
|
|
3360
|
-
children: [
|
|
3361
|
-
/* @__PURE__ */ jsx("span", {
|
|
3362
|
-
style: {
|
|
3363
|
-
fontSize: "9px",
|
|
3364
|
-
fontWeight: 700,
|
|
3365
|
-
padding: "1px 4px",
|
|
3366
|
-
borderRadius: "3px",
|
|
3367
|
-
background: "#082f49",
|
|
3368
|
-
color: "#38bdf8",
|
|
3369
|
-
border: "1px solid #0369a1"
|
|
3370
|
-
},
|
|
3371
|
-
children: "SIG"
|
|
3372
|
-
}),
|
|
3373
|
-
/* @__PURE__ */ jsx("span", {
|
|
3374
|
-
children: node.name
|
|
3375
|
-
})
|
|
3376
|
-
]
|
|
3377
|
-
}),
|
|
3378
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3379
|
-
class: "visage-devtools-badge",
|
|
3380
|
-
children: [
|
|
3381
|
-
"v",
|
|
3382
|
-
() => node.version()
|
|
3383
|
-
]
|
|
3384
|
-
})
|
|
3385
|
-
]
|
|
3386
|
-
}),
|
|
3387
|
-
/* @__PURE__ */ jsx("div", {
|
|
3388
|
-
class: "visage-graph-node-val",
|
|
3389
|
-
children: () => JSON.stringify(node.getValue())
|
|
3390
|
-
}),
|
|
3391
|
-
/* @__PURE__ */ jsx("div", {
|
|
3392
|
-
style: { marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" },
|
|
3393
|
-
children: () => dependents().length > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
3394
|
-
style: { fontSize: "10px", color: "#94a3b8" },
|
|
3395
|
-
children: [
|
|
3396
|
-
dependents().length,
|
|
3397
|
-
" consumer",
|
|
3398
|
-
dependents().length > 1 ? "s" : ""
|
|
3399
|
-
]
|
|
3400
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
3401
|
-
style: { fontSize: "10px", color: "#475569" },
|
|
3402
|
-
children: "Root State"
|
|
3403
|
-
})
|
|
3404
|
-
})
|
|
3405
|
-
]
|
|
3406
|
-
});
|
|
3407
|
-
}
|
|
3408
|
-
})
|
|
3409
|
-
]
|
|
3410
|
-
}),
|
|
3411
|
-
/* @__PURE__ */ jsx("div", {
|
|
3412
|
-
style: {
|
|
3413
|
-
display: "flex",
|
|
3414
|
-
flexDirection: "column",
|
|
3415
|
-
justifyContent: "center",
|
|
3416
|
-
alignItems: "center",
|
|
3417
|
-
color: "#334155",
|
|
3418
|
-
fontSize: "14px",
|
|
3419
|
-
fontWeight: 700,
|
|
3420
|
-
padding: "0 10px"
|
|
3421
|
-
},
|
|
3422
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
3423
|
-
children: ">"
|
|
3424
|
-
})
|
|
3425
|
-
}),
|
|
3426
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3427
|
-
class: "visage-graph-column",
|
|
3428
|
-
children: [
|
|
3429
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3430
|
-
class: "visage-graph-col-header",
|
|
3431
|
-
children: [
|
|
3432
|
-
/* @__PURE__ */ jsx("span", {
|
|
3433
|
-
class: "visage-graph-pulse computed"
|
|
3434
|
-
}),
|
|
3435
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3436
|
-
children: [
|
|
3437
|
-
"Derived Computeds (",
|
|
3438
|
-
() => computedSignals().length,
|
|
3439
|
-
")"
|
|
3440
|
-
]
|
|
3441
|
-
})
|
|
3442
|
-
]
|
|
3443
|
-
}),
|
|
3444
|
-
/* @__PURE__ */ jsx(For, {
|
|
3445
|
-
each: computedSignals,
|
|
3446
|
-
children: (node) => {
|
|
3447
|
-
const isSelected = () => props.selectedId() === node.id;
|
|
3448
|
-
const isDep = () => focusedDeps().includes(node.id);
|
|
3449
|
-
const isTarget = () => focusedTargets().includes(node.id);
|
|
3450
|
-
const isDimmed = () => activeFocusId() !== null && !isSelected() && !isDep() && !isTarget();
|
|
3451
|
-
const deps = () => getDependencies(node);
|
|
3452
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3453
|
-
class: () => `visage-graph-node ${isSelected() ? "selected" : ""} ${isDep() ? "is-dependency" : ""} ${isTarget() ? "is-dependent" : ""} ${isDimmed() ? "is-dimmed" : ""}`,
|
|
3454
|
-
onClick: () => props.selectedId.set(node.id),
|
|
3455
|
-
onMouseEnter: () => setHoveredId(node.id),
|
|
3456
|
-
onMouseLeave: () => setHoveredId(null),
|
|
3457
|
-
children: [
|
|
3458
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3459
|
-
class: "visage-graph-node-title",
|
|
3460
|
-
children: [
|
|
3461
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3462
|
-
style: {
|
|
3463
|
-
color: "#f8fafc",
|
|
3464
|
-
display: "inline-flex",
|
|
3465
|
-
alignItems: "center",
|
|
3466
|
-
gap: "6px"
|
|
3467
|
-
},
|
|
3468
|
-
children: [
|
|
3469
|
-
/* @__PURE__ */ jsx("span", {
|
|
3470
|
-
style: {
|
|
3471
|
-
fontSize: "9px",
|
|
3472
|
-
fontWeight: 700,
|
|
3473
|
-
padding: "1px 4px",
|
|
3474
|
-
borderRadius: "3px",
|
|
3475
|
-
background: "#3b0764",
|
|
3476
|
-
color: "#c084fc",
|
|
3477
|
-
border: "1px solid #581c87"
|
|
3478
|
-
},
|
|
3479
|
-
children: "CMP"
|
|
3480
|
-
}),
|
|
3481
|
-
/* @__PURE__ */ jsx("span", {
|
|
3482
|
-
children: node.name
|
|
3483
|
-
})
|
|
3484
|
-
]
|
|
3485
|
-
}),
|
|
3486
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3487
|
-
class: "visage-devtools-badge",
|
|
3488
|
-
style: { background: "#581c87", color: "#fff" },
|
|
3489
|
-
children: [
|
|
3490
|
-
"v",
|
|
3491
|
-
() => node.version()
|
|
3492
|
-
]
|
|
3493
|
-
})
|
|
3494
|
-
]
|
|
3495
|
-
}),
|
|
3496
|
-
/* @__PURE__ */ jsx("div", {
|
|
3497
|
-
class: "visage-graph-node-val",
|
|
3498
|
-
children: () => JSON.stringify(node.getValue())
|
|
3499
|
-
}),
|
|
3500
|
-
/* @__PURE__ */ jsx("div", {
|
|
3501
|
-
style: { marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" },
|
|
3502
|
-
children: () => deps().length > 0 ? deps().map((d) => /* @__PURE__ */ jsxs("span", {
|
|
3503
|
-
class: "visage-graph-pill source",
|
|
3504
|
-
onClick: (e) => {
|
|
3505
|
-
e.stopPropagation();
|
|
3506
|
-
props.selectedId.set(d.id);
|
|
3507
|
-
},
|
|
3508
|
-
children: [
|
|
3509
|
-
"in: ",
|
|
3510
|
-
d.name
|
|
3511
|
-
]
|
|
3512
|
-
})) : /* @__PURE__ */ jsx("span", {
|
|
3513
|
-
style: { fontSize: "10px", color: "#64748b" },
|
|
3514
|
-
children: "Memoized"
|
|
3515
|
-
})
|
|
3516
|
-
})
|
|
3517
|
-
]
|
|
3518
|
-
});
|
|
3519
|
-
}
|
|
3520
|
-
})
|
|
3521
|
-
]
|
|
3522
|
-
})
|
|
3523
|
-
]
|
|
3524
|
-
}),
|
|
3525
|
-
/* @__PURE__ */ jsx(GraphInspector, {
|
|
3526
|
-
selectedNode,
|
|
3527
|
-
selectedId: props.selectedId,
|
|
3528
|
-
getDependencies,
|
|
3529
|
-
getDependents,
|
|
3530
|
-
formatJSON: props.formatJSON
|
|
3531
|
-
})
|
|
3532
|
-
]
|
|
3533
|
-
})
|
|
3534
|
-
]
|
|
3535
|
-
});
|
|
3536
|
-
}
|
|
3537
|
-
|
|
3538
|
-
// src/devtools/highlighter.ts
|
|
3539
|
-
var styleInjected = false;
|
|
3540
|
-
var activeTimeouts = new WeakMap;
|
|
3541
|
-
function injectHighlighterStyles() {
|
|
3542
|
-
if (styleInjected || typeof document === "undefined")
|
|
3543
|
-
return;
|
|
3544
|
-
const style = document.createElement("style");
|
|
3545
|
-
style.id = "visage-devtools-highlighter";
|
|
3546
|
-
style.textContent = `
|
|
3547
|
-
@keyframes visage-devtools-flash {
|
|
3548
|
-
0% {
|
|
3549
|
-
outline: 2px solid rgba(56, 189, 248, 0.9);
|
|
3550
|
-
box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
|
|
3551
|
-
}
|
|
3552
|
-
100% {
|
|
3553
|
-
outline: 2px solid transparent;
|
|
3554
|
-
box-shadow: none;
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
.visage-dev-highlight {
|
|
3558
|
-
outline-offset: -1px;
|
|
3559
|
-
animation: visage-devtools-flash 0.5s ease-out !important;
|
|
3560
|
-
}
|
|
3561
|
-
`;
|
|
3562
|
-
document.head.appendChild(style);
|
|
3563
|
-
styleInjected = true;
|
|
3564
|
-
}
|
|
3565
|
-
function highlightElement(element) {
|
|
3566
|
-
if (!element || typeof document === "undefined" || !(element instanceof Element))
|
|
3567
|
-
return;
|
|
3568
|
-
injectHighlighterStyles();
|
|
3569
|
-
const prevTimeout = activeTimeouts.get(element);
|
|
3570
|
-
if (prevTimeout) {
|
|
3571
|
-
clearTimeout(prevTimeout);
|
|
3572
|
-
}
|
|
3573
|
-
element.classList.remove("visage-dev-highlight");
|
|
3574
|
-
element.offsetWidth;
|
|
3575
|
-
element.classList.add("visage-dev-highlight");
|
|
3576
|
-
const timeout = setTimeout(() => {
|
|
3577
|
-
element.classList.remove("visage-dev-highlight");
|
|
3578
|
-
activeTimeouts.delete(element);
|
|
3579
|
-
}, 500);
|
|
3580
|
-
activeTimeouts.set(element, timeout);
|
|
3581
|
-
}
|
|
3582
|
-
var observer = null;
|
|
3583
|
-
function setupDomMutationHighlighter(enabledGetter) {
|
|
3584
|
-
if (typeof window === "undefined" || typeof MutationObserver === "undefined")
|
|
3585
|
-
return;
|
|
3586
|
-
const startObserver = () => {
|
|
3587
|
-
if (observer)
|
|
3588
|
-
return;
|
|
3589
|
-
injectHighlighterStyles();
|
|
3590
|
-
observer = new MutationObserver((mutations) => {
|
|
3591
|
-
if (!enabledGetter())
|
|
3592
|
-
return;
|
|
3593
|
-
const seen = new Set;
|
|
3594
|
-
for (const mutation of mutations) {
|
|
3595
|
-
const target = mutation.target;
|
|
3596
|
-
let el = null;
|
|
3597
|
-
if (target instanceof Element) {
|
|
3598
|
-
el = target;
|
|
3599
|
-
} else if (target.parentElement) {
|
|
3600
|
-
el = target.parentElement;
|
|
3601
|
-
}
|
|
3602
|
-
if (!el)
|
|
3603
|
-
continue;
|
|
3604
|
-
if (el.closest?.(".visage-devtools-root") || el.closest?.("#visage-devtools-highlighter")) {
|
|
3605
|
-
continue;
|
|
3606
|
-
}
|
|
3607
|
-
if (mutation.type === "attributes" && mutation.attributeName === "class") {
|
|
3608
|
-
const oldCls = (mutation.oldValue || "").replace(/\bvisage-dev-highlight\b/g, "").replace(/\s+/g, " ").trim();
|
|
3609
|
-
const newCls = (el.getAttribute("class") || "").replace(/\bvisage-dev-highlight\b/g, "").replace(/\s+/g, " ").trim();
|
|
3610
|
-
if (oldCls === newCls) {
|
|
3611
|
-
continue;
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
if (!seen.has(el)) {
|
|
3615
|
-
seen.add(el);
|
|
3616
|
-
highlightElement(el);
|
|
3617
|
-
}
|
|
3618
|
-
}
|
|
3619
|
-
});
|
|
3620
|
-
const targetNode = document.body || document.documentElement;
|
|
3621
|
-
if (targetNode) {
|
|
3622
|
-
observer.observe(targetNode, {
|
|
3623
|
-
childList: true,
|
|
3624
|
-
attributes: true,
|
|
3625
|
-
attributeOldValue: true,
|
|
3626
|
-
characterData: true,
|
|
3627
|
-
subtree: true
|
|
3628
|
-
});
|
|
3629
|
-
}
|
|
3630
|
-
};
|
|
3631
|
-
const stopObserver = () => {
|
|
3632
|
-
if (observer) {
|
|
3633
|
-
observer.disconnect();
|
|
3634
|
-
observer = null;
|
|
3635
|
-
}
|
|
3636
|
-
};
|
|
3637
|
-
effect(() => {
|
|
3638
|
-
if (enabledGetter()) {
|
|
3639
|
-
startObserver();
|
|
3640
|
-
} else {
|
|
3641
|
-
stopObserver();
|
|
3642
|
-
}
|
|
3643
|
-
});
|
|
3644
|
-
onCleanup(() => {
|
|
3645
|
-
stopObserver();
|
|
3646
|
-
});
|
|
3647
|
-
}
|
|
3648
|
-
|
|
3649
|
-
// src/devtools/QueryTab.tsx
|
|
3650
|
-
function QueryTab(props) {
|
|
3651
|
-
const filteredQueries = () => {
|
|
3652
|
-
const q = props.searchQuery().toLowerCase().trim();
|
|
3653
|
-
const list = props.hub.queriesList();
|
|
3654
|
-
if (!q)
|
|
3655
|
-
return list;
|
|
3656
|
-
return list.filter((item) => item.hash.toLowerCase().includes(q) || JSON.stringify(item.key).toLowerCase().includes(q));
|
|
3657
|
-
};
|
|
3658
|
-
const selectedQuery = () => {
|
|
3659
|
-
const id = props.selectedId();
|
|
3660
|
-
if (!id)
|
|
3661
|
-
return null;
|
|
3662
|
-
return props.hub.queriesList().find((qr) => qr.hash === id) ?? null;
|
|
3663
|
-
};
|
|
3664
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3665
|
-
style: { display: "flex", flex: 1, width: "100%", height: "100%", overflow: "hidden" },
|
|
3666
|
-
children: [
|
|
3667
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3668
|
-
class: "visage-devtools-sidebar",
|
|
3669
|
-
children: [
|
|
3670
|
-
/* @__PURE__ */ jsx("div", {
|
|
3671
|
-
class: "visage-devtools-search",
|
|
3672
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
3673
|
-
class: "visage-devtools-input",
|
|
3674
|
-
placeholder: "Search query cache...",
|
|
3675
|
-
value: props.searchQuery,
|
|
3676
|
-
onInput: (e) => props.searchQuery.set(e.target.value)
|
|
3677
|
-
})
|
|
3678
|
-
}),
|
|
3679
|
-
/* @__PURE__ */ jsx("div", {
|
|
3680
|
-
class: "visage-devtools-list",
|
|
3681
|
-
children: /* @__PURE__ */ jsx(For, {
|
|
3682
|
-
each: filteredQueries,
|
|
3683
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
3684
|
-
style: { padding: "12px", color: "#64748b", fontSize: "12px" },
|
|
3685
|
-
children: "No active queries in cache."
|
|
3686
|
-
}),
|
|
3687
|
-
children: (qr) => {
|
|
3688
|
-
const isSelected = () => props.selectedId() === qr.hash;
|
|
3689
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3690
|
-
class: () => `visage-devtools-item ${isSelected() ? "selected" : ""}`,
|
|
3691
|
-
onClick: () => props.selectedId.set(qr.hash),
|
|
3692
|
-
children: [
|
|
3693
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3694
|
-
style: {
|
|
3695
|
-
display: "flex",
|
|
3696
|
-
alignItems: "center",
|
|
3697
|
-
gap: "6px",
|
|
3698
|
-
overflow: "hidden"
|
|
3699
|
-
},
|
|
3700
|
-
children: [
|
|
3701
|
-
/* @__PURE__ */ jsx("span", {
|
|
3702
|
-
class: "visage-devtools-badge",
|
|
3703
|
-
style: {
|
|
3704
|
-
background: qr.status() === "success" ? "#065f46" : qr.status() === "error" ? "#991b1b" : "#854d0e",
|
|
3705
|
-
color: "#fff"
|
|
3706
|
-
},
|
|
3707
|
-
children: () => qr.status()
|
|
3708
|
-
}),
|
|
3709
|
-
/* @__PURE__ */ jsx("span", {
|
|
3710
|
-
style: {
|
|
3711
|
-
fontWeight: 500,
|
|
3712
|
-
overflow: "hidden",
|
|
3713
|
-
textOverflow: "ellipsis",
|
|
3714
|
-
whiteSpace: "nowrap"
|
|
3715
|
-
},
|
|
3716
|
-
children: JSON.stringify(qr.key)
|
|
3717
|
-
})
|
|
3718
|
-
]
|
|
3719
|
-
}),
|
|
3720
|
-
/* @__PURE__ */ jsx("span", {
|
|
3721
|
-
style: { fontSize: "10px", color: "#64748b" },
|
|
3722
|
-
children: () => qr.fetchStatus()
|
|
3723
|
-
})
|
|
3724
|
-
]
|
|
3725
|
-
});
|
|
3726
|
-
}
|
|
3727
|
-
})
|
|
3728
|
-
})
|
|
3729
|
-
]
|
|
3730
|
-
}),
|
|
3731
|
-
/* @__PURE__ */ jsx("div", {
|
|
3732
|
-
class: "visage-devtools-main",
|
|
3733
|
-
children: /* @__PURE__ */ jsx(Show, {
|
|
3734
|
-
when: selectedQuery,
|
|
3735
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
3736
|
-
style: { color: "#64748b", textAlign: "center", marginTop: "40px", fontSize: "13px" },
|
|
3737
|
-
children: "Select a query from the cache list to view live cached response and trigger manual refetches."
|
|
3738
|
-
}),
|
|
3739
|
-
children: (qr) => /* @__PURE__ */ jsxs("div", {
|
|
3740
|
-
children: [
|
|
3741
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3742
|
-
style: {
|
|
3743
|
-
display: "flex",
|
|
3744
|
-
alignItems: "center",
|
|
3745
|
-
justifyContent: "space-between",
|
|
3746
|
-
marginBottom: "16px"
|
|
3747
|
-
},
|
|
3748
|
-
children: [
|
|
3749
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3750
|
-
children: [
|
|
3751
|
-
/* @__PURE__ */ jsx("h3", {
|
|
3752
|
-
style: { margin: 0, fontSize: "15px", color: "#f8fafc" },
|
|
3753
|
-
children: () => JSON.stringify(qr().key)
|
|
3754
|
-
}),
|
|
3755
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3756
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3757
|
-
children: [
|
|
3758
|
-
"Hash: ",
|
|
3759
|
-
() => qr().hash
|
|
3760
|
-
]
|
|
3761
|
-
})
|
|
3762
|
-
]
|
|
3763
|
-
}),
|
|
3764
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3765
|
-
style: { display: "flex", gap: "8px" },
|
|
3766
|
-
children: [
|
|
3767
|
-
/* @__PURE__ */ jsx("button", {
|
|
3768
|
-
type: "button",
|
|
3769
|
-
class: "visage-devtools-btn",
|
|
3770
|
-
onClick: () => qr().refetch?.(),
|
|
3771
|
-
children: "Refetch"
|
|
3772
|
-
}),
|
|
3773
|
-
/* @__PURE__ */ jsx("button", {
|
|
3774
|
-
type: "button",
|
|
3775
|
-
class: "visage-devtools-btn",
|
|
3776
|
-
onClick: () => qr().invalidate?.(),
|
|
3777
|
-
children: "Invalidate Cache"
|
|
3778
|
-
})
|
|
3779
|
-
]
|
|
3780
|
-
})
|
|
3781
|
-
]
|
|
3782
|
-
}),
|
|
3783
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3784
|
-
style: {
|
|
3785
|
-
display: "grid",
|
|
3786
|
-
gridTemplateColumns: "1fr 1fr",
|
|
3787
|
-
gap: "10px",
|
|
3788
|
-
marginBottom: "16px"
|
|
3789
|
-
},
|
|
3790
|
-
children: [
|
|
3791
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3792
|
-
style: {
|
|
3793
|
-
background: "#0c111d",
|
|
3794
|
-
padding: "10px",
|
|
3795
|
-
borderRadius: "6px",
|
|
3796
|
-
border: "1px solid #1e293b"
|
|
3797
|
-
},
|
|
3798
|
-
children: [
|
|
3799
|
-
/* @__PURE__ */ jsx("div", {
|
|
3800
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3801
|
-
children: "STATUS"
|
|
3802
|
-
}),
|
|
3803
|
-
/* @__PURE__ */ jsx("div", {
|
|
3804
|
-
style: { fontWeight: 600, color: "#38bdf8" },
|
|
3805
|
-
children: () => `${qr().status()} (${qr().fetchStatus()})`
|
|
3806
|
-
})
|
|
3807
|
-
]
|
|
3808
|
-
}),
|
|
3809
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3810
|
-
style: {
|
|
3811
|
-
background: "#0c111d",
|
|
3812
|
-
padding: "10px",
|
|
3813
|
-
borderRadius: "6px",
|
|
3814
|
-
border: "1px solid #1e293b"
|
|
3815
|
-
},
|
|
3816
|
-
children: [
|
|
3817
|
-
/* @__PURE__ */ jsx("div", {
|
|
3818
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3819
|
-
children: "LAST UPDATED"
|
|
3820
|
-
}),
|
|
3821
|
-
/* @__PURE__ */ jsx("div", {
|
|
3822
|
-
style: { fontWeight: 600, color: "#f1f5f9" },
|
|
3823
|
-
children: () => qr().dataUpdatedAt() ? new Date(qr().dataUpdatedAt()).toLocaleTimeString() : "Never"
|
|
3824
|
-
})
|
|
3825
|
-
]
|
|
3826
|
-
})
|
|
3827
|
-
]
|
|
3828
|
-
}),
|
|
3829
|
-
/* @__PURE__ */ jsx("div", {
|
|
3830
|
-
style: { fontSize: "12px", color: "#94a3b8", marginBottom: "6px" },
|
|
3831
|
-
children: "Cached Response Payload:"
|
|
3832
|
-
}),
|
|
3833
|
-
/* @__PURE__ */ jsx("pre", {
|
|
3834
|
-
class: "visage-devtools-json",
|
|
3835
|
-
children: () => props.formatJSON(qr().data())
|
|
3836
|
-
})
|
|
3837
|
-
]
|
|
3838
|
-
})
|
|
3839
|
-
})
|
|
3840
|
-
})
|
|
3841
|
-
]
|
|
3842
|
-
});
|
|
3843
|
-
}
|
|
3844
|
-
|
|
3845
|
-
// src/devtools/RpcTab.tsx
|
|
3846
|
-
function RpcTab(props) {
|
|
3847
|
-
const filteredRpc = () => {
|
|
3848
|
-
const q = props.searchQuery().toLowerCase().trim();
|
|
3849
|
-
const list = props.hub.rpcLogs();
|
|
3850
|
-
if (!q)
|
|
3851
|
-
return list;
|
|
3852
|
-
return list.filter((r) => r.path.toLowerCase().includes(q) || r.type.toLowerCase().includes(q));
|
|
3853
|
-
};
|
|
3854
|
-
const selectedRpc = () => {
|
|
3855
|
-
const id = props.selectedId();
|
|
3856
|
-
if (!id)
|
|
3857
|
-
return null;
|
|
3858
|
-
return props.hub.rpcLogs().find((r) => r.id === id) ?? null;
|
|
3859
|
-
};
|
|
3860
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3861
|
-
style: { display: "flex", flex: 1, width: "100%", height: "100%", overflow: "hidden" },
|
|
3862
|
-
children: [
|
|
3863
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3864
|
-
class: "visage-devtools-sidebar",
|
|
3865
|
-
children: [
|
|
3866
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3867
|
-
class: "visage-devtools-search",
|
|
3868
|
-
style: { display: "flex", gap: "6px" },
|
|
3869
|
-
children: [
|
|
3870
|
-
/* @__PURE__ */ jsx("input", {
|
|
3871
|
-
class: "visage-devtools-input",
|
|
3872
|
-
placeholder: "Filter RPC routes...",
|
|
3873
|
-
value: props.searchQuery,
|
|
3874
|
-
onInput: (e) => props.searchQuery.set(e.target.value)
|
|
3875
|
-
}),
|
|
3876
|
-
/* @__PURE__ */ jsx("button", {
|
|
3877
|
-
type: "button",
|
|
3878
|
-
class: "visage-devtools-btn",
|
|
3879
|
-
onClick: () => props.hub.clearLogs(),
|
|
3880
|
-
title: "Clear RPC Logs",
|
|
3881
|
-
children: "Clear"
|
|
3882
|
-
})
|
|
3883
|
-
]
|
|
3884
|
-
}),
|
|
3885
|
-
/* @__PURE__ */ jsx("div", {
|
|
3886
|
-
class: "visage-devtools-list",
|
|
3887
|
-
children: /* @__PURE__ */ jsx(For, {
|
|
3888
|
-
each: filteredRpc,
|
|
3889
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
3890
|
-
style: { padding: "12px", color: "#64748b", fontSize: "12px" },
|
|
3891
|
-
children: "No RPC activity recorded yet."
|
|
3892
|
-
}),
|
|
3893
|
-
children: (r) => {
|
|
3894
|
-
const isSelected = () => props.selectedId() === r.id;
|
|
3895
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3896
|
-
class: () => `visage-devtools-item ${isSelected() ? "selected" : ""}`,
|
|
3897
|
-
onClick: () => props.selectedId.set(r.id),
|
|
3898
|
-
children: [
|
|
3899
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3900
|
-
style: {
|
|
3901
|
-
display: "flex",
|
|
3902
|
-
alignItems: "center",
|
|
3903
|
-
gap: "6px",
|
|
3904
|
-
overflow: "hidden"
|
|
3905
|
-
},
|
|
3906
|
-
children: [
|
|
3907
|
-
/* @__PURE__ */ jsx("span", {
|
|
3908
|
-
class: "visage-devtools-badge",
|
|
3909
|
-
style: {
|
|
3910
|
-
background: r.type === "mutation" ? "#c026d3" : r.type === "subscription" ? "#7c3aed" : "#0284c7",
|
|
3911
|
-
color: "#fff"
|
|
3912
|
-
},
|
|
3913
|
-
children: r.type.slice(0, 3).toUpperCase()
|
|
3914
|
-
}),
|
|
3915
|
-
/* @__PURE__ */ jsx("span", {
|
|
3916
|
-
style: {
|
|
3917
|
-
fontWeight: 500,
|
|
3918
|
-
overflow: "hidden",
|
|
3919
|
-
textOverflow: "ellipsis",
|
|
3920
|
-
whiteSpace: "nowrap"
|
|
3921
|
-
},
|
|
3922
|
-
children: r.path
|
|
3923
|
-
})
|
|
3924
|
-
]
|
|
3925
|
-
}),
|
|
3926
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3927
|
-
style: { display: "flex", alignItems: "center", gap: "6px" },
|
|
3928
|
-
children: [
|
|
3929
|
-
/* @__PURE__ */ jsx("span", {
|
|
3930
|
-
style: {
|
|
3931
|
-
fontSize: "11px",
|
|
3932
|
-
color: r.status === "success" ? "#10b981" : r.status === "error" ? "#ef4444" : "#f59e0b"
|
|
3933
|
-
},
|
|
3934
|
-
children: r.status
|
|
3935
|
-
}),
|
|
3936
|
-
r.duration !== undefined ? /* @__PURE__ */ jsxs("span", {
|
|
3937
|
-
style: { fontSize: "10px", color: "#64748b" },
|
|
3938
|
-
children: [
|
|
3939
|
-
r.duration,
|
|
3940
|
-
"ms"
|
|
3941
|
-
]
|
|
3942
|
-
}) : null
|
|
3943
|
-
]
|
|
3944
|
-
})
|
|
3945
|
-
]
|
|
3946
|
-
});
|
|
3947
|
-
}
|
|
3948
|
-
})
|
|
3949
|
-
})
|
|
3950
|
-
]
|
|
3951
|
-
}),
|
|
3952
|
-
/* @__PURE__ */ jsx("div", {
|
|
3953
|
-
class: "visage-devtools-main",
|
|
3954
|
-
children: /* @__PURE__ */ jsx(Show, {
|
|
3955
|
-
when: selectedRpc,
|
|
3956
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
3957
|
-
style: { color: "#64748b", textAlign: "center", marginTop: "40px", fontSize: "13px" },
|
|
3958
|
-
children: "Select an RPC procedure call from the left to inspect full payload, latency, and streaming SSE frames."
|
|
3959
|
-
}),
|
|
3960
|
-
children: (r) => /* @__PURE__ */ jsxs("div", {
|
|
3961
|
-
children: [
|
|
3962
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3963
|
-
style: {
|
|
3964
|
-
display: "flex",
|
|
3965
|
-
alignItems: "center",
|
|
3966
|
-
justifyContent: "space-between",
|
|
3967
|
-
marginBottom: "16px"
|
|
3968
|
-
},
|
|
3969
|
-
children: [
|
|
3970
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3971
|
-
children: [
|
|
3972
|
-
/* @__PURE__ */ jsx("h3", {
|
|
3973
|
-
style: { margin: 0, fontSize: "16px", color: "#f8fafc" },
|
|
3974
|
-
children: () => `${r().type.toUpperCase()}: ${r().path}`
|
|
3975
|
-
}),
|
|
3976
|
-
/* @__PURE__ */ jsxs("span", {
|
|
3977
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
3978
|
-
children: [
|
|
3979
|
-
"Call ID: ",
|
|
3980
|
-
() => r().id
|
|
3981
|
-
]
|
|
3982
|
-
})
|
|
3983
|
-
]
|
|
3984
|
-
}),
|
|
3985
|
-
/* @__PURE__ */ jsx("span", {
|
|
3986
|
-
class: "visage-devtools-badge",
|
|
3987
|
-
style: { fontSize: "12px", padding: "3px 8px" },
|
|
3988
|
-
children: () => r().duration !== undefined ? `${r().duration}ms` : "Active"
|
|
3989
|
-
})
|
|
3990
|
-
]
|
|
3991
|
-
}),
|
|
3992
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3993
|
-
style: { marginBottom: "12px" },
|
|
3994
|
-
children: [
|
|
3995
|
-
/* @__PURE__ */ jsx("div", {
|
|
3996
|
-
style: { fontSize: "12px", color: "#94a3b8", marginBottom: "4px" },
|
|
3997
|
-
children: "Input Parameters:"
|
|
3998
|
-
}),
|
|
3999
|
-
/* @__PURE__ */ jsx("pre", {
|
|
4000
|
-
class: "visage-devtools-json",
|
|
4001
|
-
children: () => props.formatJSON(r().input)
|
|
4002
|
-
})
|
|
4003
|
-
]
|
|
4004
|
-
}),
|
|
4005
|
-
/* @__PURE__ */ jsx(Show, {
|
|
4006
|
-
when: () => r().response !== undefined,
|
|
4007
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
4008
|
-
style: { marginBottom: "12px" },
|
|
4009
|
-
children: [
|
|
4010
|
-
/* @__PURE__ */ jsx("div", {
|
|
4011
|
-
style: { fontSize: "12px", color: "#94a3b8", marginBottom: "4px" },
|
|
4012
|
-
children: "Server Response:"
|
|
4013
|
-
}),
|
|
4014
|
-
/* @__PURE__ */ jsx("pre", {
|
|
4015
|
-
class: "visage-devtools-json",
|
|
4016
|
-
children: () => props.formatJSON(r().response)
|
|
4017
|
-
})
|
|
4018
|
-
]
|
|
4019
|
-
})
|
|
4020
|
-
}),
|
|
4021
|
-
/* @__PURE__ */ jsx(Show, {
|
|
4022
|
-
when: () => (r().events?.length ?? 0) > 0,
|
|
4023
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
4024
|
-
children: [
|
|
4025
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4026
|
-
style: { fontSize: "12px", color: "#94a3b8", marginBottom: "4px" },
|
|
4027
|
-
children: [
|
|
4028
|
-
"Live SSE Event Stream (",
|
|
4029
|
-
() => r().events?.length ?? 0,
|
|
4030
|
-
" frames):"
|
|
4031
|
-
]
|
|
4032
|
-
}),
|
|
4033
|
-
/* @__PURE__ */ jsx("pre", {
|
|
4034
|
-
class: "visage-devtools-json",
|
|
4035
|
-
children: () => props.formatJSON(r().events)
|
|
4036
|
-
})
|
|
4037
|
-
]
|
|
4038
|
-
})
|
|
4039
|
-
})
|
|
4040
|
-
]
|
|
4041
|
-
})
|
|
4042
|
-
})
|
|
4043
|
-
})
|
|
4044
|
-
]
|
|
4045
|
-
});
|
|
4046
|
-
}
|
|
4047
|
-
|
|
4048
|
-
// src/devtools/SignalsTab.tsx
|
|
4049
|
-
function SignalsTab(props) {
|
|
4050
|
-
const filteredSignals = () => {
|
|
4051
|
-
const q = props.searchQuery().toLowerCase().trim();
|
|
4052
|
-
const list = props.hub.signalsList();
|
|
4053
|
-
if (!q)
|
|
4054
|
-
return list;
|
|
4055
|
-
return list.filter((s) => s.name.toLowerCase().includes(q) || s.id.toLowerCase().includes(q));
|
|
4056
|
-
};
|
|
4057
|
-
const selectedSignal = () => {
|
|
4058
|
-
const id = props.selectedId();
|
|
4059
|
-
if (!id)
|
|
4060
|
-
return null;
|
|
4061
|
-
return props.hub.signalsList().find((s) => s.id === id) ?? null;
|
|
4062
|
-
};
|
|
4063
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
4064
|
-
style: { display: "flex", flex: 1, width: "100%", height: "100%", overflow: "hidden" },
|
|
4065
|
-
children: [
|
|
4066
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4067
|
-
class: "visage-devtools-sidebar",
|
|
4068
|
-
children: [
|
|
4069
|
-
/* @__PURE__ */ jsx("div", {
|
|
4070
|
-
class: "visage-devtools-search",
|
|
4071
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
4072
|
-
class: "visage-devtools-input",
|
|
4073
|
-
placeholder: "Search signals...",
|
|
4074
|
-
value: props.searchQuery,
|
|
4075
|
-
onInput: (e) => props.searchQuery.set(e.target.value)
|
|
4076
|
-
})
|
|
4077
|
-
}),
|
|
4078
|
-
/* @__PURE__ */ jsx("div", {
|
|
4079
|
-
class: "visage-devtools-list",
|
|
4080
|
-
children: /* @__PURE__ */ jsx(For, {
|
|
4081
|
-
each: filteredSignals,
|
|
4082
|
-
children: (sig) => {
|
|
4083
|
-
const isSelected = () => props.selectedId() === sig.id;
|
|
4084
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
4085
|
-
class: () => `visage-devtools-item ${sig.type} ${isSelected() ? "selected" : ""}`,
|
|
4086
|
-
onClick: () => props.selectedId.set(sig.id),
|
|
4087
|
-
children: [
|
|
4088
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4089
|
-
style: { display: "flex", alignItems: "center", gap: "8px" },
|
|
4090
|
-
children: [
|
|
4091
|
-
/* @__PURE__ */ jsx("span", {
|
|
4092
|
-
style: {
|
|
4093
|
-
fontSize: "9px",
|
|
4094
|
-
fontWeight: 700,
|
|
4095
|
-
padding: "1px 4px",
|
|
4096
|
-
borderRadius: "3px",
|
|
4097
|
-
background: sig.type === "computed" ? "#3b0764" : "#082f49",
|
|
4098
|
-
color: sig.type === "computed" ? "#c084fc" : "#38bdf8",
|
|
4099
|
-
border: `1px solid ${sig.type === "computed" ? "#581c87" : "#0369a1"}`
|
|
4100
|
-
},
|
|
4101
|
-
children: sig.type === "computed" ? "CMP" : "SIG"
|
|
4102
|
-
}),
|
|
4103
|
-
/* @__PURE__ */ jsx("span", {
|
|
4104
|
-
style: { fontWeight: 500, color: "#f1f5f9" },
|
|
4105
|
-
children: sig.name
|
|
4106
|
-
})
|
|
4107
|
-
]
|
|
4108
|
-
}),
|
|
4109
|
-
/* @__PURE__ */ jsxs("span", {
|
|
4110
|
-
class: "visage-devtools-badge",
|
|
4111
|
-
children: [
|
|
4112
|
-
"v",
|
|
4113
|
-
() => sig.version()
|
|
4114
|
-
]
|
|
4115
|
-
})
|
|
4116
|
-
]
|
|
4117
|
-
});
|
|
4118
|
-
}
|
|
4119
|
-
})
|
|
4120
|
-
})
|
|
4121
|
-
]
|
|
4122
|
-
}),
|
|
4123
|
-
/* @__PURE__ */ jsx("div", {
|
|
4124
|
-
class: "visage-devtools-main",
|
|
4125
|
-
children: /* @__PURE__ */ jsx(Show, {
|
|
4126
|
-
when: selectedSignal,
|
|
4127
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
4128
|
-
style: {
|
|
4129
|
-
color: "#64748b",
|
|
4130
|
-
textAlign: "center",
|
|
4131
|
-
marginTop: "40px",
|
|
4132
|
-
fontSize: "13px"
|
|
4133
|
-
},
|
|
4134
|
-
children: "Select a signal or computed from the left to inspect its live reactive value."
|
|
4135
|
-
}),
|
|
4136
|
-
children: (sig) => /* @__PURE__ */ jsxs("div", {
|
|
4137
|
-
children: [
|
|
4138
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4139
|
-
style: {
|
|
4140
|
-
display: "flex",
|
|
4141
|
-
alignItems: "center",
|
|
4142
|
-
justifyContent: "space-between",
|
|
4143
|
-
marginBottom: "16px"
|
|
4144
|
-
},
|
|
4145
|
-
children: [
|
|
4146
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4147
|
-
children: [
|
|
4148
|
-
/* @__PURE__ */ jsx("h3", {
|
|
4149
|
-
style: { margin: 0, fontSize: "16px", color: "#f8fafc" },
|
|
4150
|
-
children: () => sig().name
|
|
4151
|
-
}),
|
|
4152
|
-
/* @__PURE__ */ jsxs("span", {
|
|
4153
|
-
style: { fontSize: "11px", color: "#64748b" },
|
|
4154
|
-
children: [
|
|
4155
|
-
"ID: ",
|
|
4156
|
-
() => sig().id
|
|
4157
|
-
]
|
|
4158
|
-
})
|
|
4159
|
-
]
|
|
4160
|
-
}),
|
|
4161
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4162
|
-
style: { display: "flex", gap: "8px" },
|
|
4163
|
-
children: [
|
|
4164
|
-
/* @__PURE__ */ jsx("span", {
|
|
4165
|
-
class: "visage-devtools-badge",
|
|
4166
|
-
style: {
|
|
4167
|
-
background: () => sig().type === "computed" ? "#581c87" : "#0369a1",
|
|
4168
|
-
color: "#fff"
|
|
4169
|
-
},
|
|
4170
|
-
children: () => sig().type.toUpperCase()
|
|
4171
|
-
}),
|
|
4172
|
-
/* @__PURE__ */ jsxs("span", {
|
|
4173
|
-
class: "visage-devtools-badge",
|
|
4174
|
-
children: [
|
|
4175
|
-
"VERSION: ",
|
|
4176
|
-
() => sig().version()
|
|
4177
|
-
]
|
|
4178
|
-
})
|
|
4179
|
-
]
|
|
4180
|
-
})
|
|
4181
|
-
]
|
|
4182
|
-
}),
|
|
4183
|
-
/* @__PURE__ */ jsx("div", {
|
|
4184
|
-
style: { marginBottom: "12px", fontSize: "12px", color: "#94a3b8" },
|
|
4185
|
-
children: "Current Reactive Value:"
|
|
4186
|
-
}),
|
|
4187
|
-
/* @__PURE__ */ jsx("pre", {
|
|
4188
|
-
class: "visage-devtools-json",
|
|
4189
|
-
children: () => props.formatJSON(sig().getValue())
|
|
4190
|
-
})
|
|
4191
|
-
]
|
|
4192
|
-
})
|
|
4193
|
-
})
|
|
4194
|
-
})
|
|
4195
|
-
]
|
|
4196
|
-
});
|
|
4197
|
-
}
|
|
4198
|
-
|
|
4199
|
-
// src/devtools/styles.ts
|
|
4200
|
-
var devtoolsStyles = `
|
|
4201
|
-
.visage-devtools-root {
|
|
4202
|
-
position: fixed;
|
|
4203
|
-
z-index: 999999;
|
|
4204
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
4205
|
-
font-size: 13px;
|
|
4206
|
-
color: #f1f5f9;
|
|
4207
|
-
box-sizing: border-box;
|
|
4208
|
-
}
|
|
4209
|
-
.visage-devtools-root * {
|
|
4210
|
-
box-sizing: border-box;
|
|
4211
|
-
}
|
|
4212
|
-
.visage-devtools-trigger {
|
|
4213
|
-
position: fixed;
|
|
4214
|
-
bottom: 20px;
|
|
4215
|
-
left: 20px;
|
|
4216
|
-
background: #0f172a;
|
|
4217
|
-
color: #38bdf8;
|
|
4218
|
-
border: 1px solid #334155;
|
|
4219
|
-
border-radius: 9999px;
|
|
4220
|
-
padding: 8px 14px;
|
|
4221
|
-
display: flex;
|
|
4222
|
-
align-items: center;
|
|
4223
|
-
gap: 8px;
|
|
4224
|
-
cursor: pointer;
|
|
4225
|
-
font-weight: 600;
|
|
4226
|
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 0 10px rgba(56, 189, 248, 0.2);
|
|
4227
|
-
transition: all 0.2s ease;
|
|
4228
|
-
z-index: 999999;
|
|
4229
|
-
}
|
|
4230
|
-
.visage-devtools-trigger:hover {
|
|
4231
|
-
background: #1e293b;
|
|
4232
|
-
border-color: #38bdf8;
|
|
4233
|
-
transform: translateY(-2px);
|
|
4234
|
-
}
|
|
4235
|
-
.visage-devtools-drawer {
|
|
4236
|
-
position: fixed;
|
|
4237
|
-
bottom: 0;
|
|
4238
|
-
left: 0;
|
|
4239
|
-
right: 0;
|
|
4240
|
-
height: 420px;
|
|
4241
|
-
background: #090d16;
|
|
4242
|
-
border-top: 1px solid #1e293b;
|
|
4243
|
-
display: flex;
|
|
4244
|
-
flex-direction: column;
|
|
4245
|
-
box-shadow: 0 -20px 25px -5px rgba(0, 0, 0, 0.7);
|
|
4246
|
-
z-index: 999999;
|
|
4247
|
-
}
|
|
4248
|
-
.visage-devtools-header {
|
|
4249
|
-
display: flex;
|
|
4250
|
-
align-items: center;
|
|
4251
|
-
justify-content: space-between;
|
|
4252
|
-
padding: 8px 16px;
|
|
4253
|
-
background: #0f172a;
|
|
4254
|
-
border-bottom: 1px solid #1e293b;
|
|
4255
|
-
}
|
|
4256
|
-
.visage-devtools-tabs {
|
|
4257
|
-
display: flex;
|
|
4258
|
-
gap: 4px;
|
|
4259
|
-
}
|
|
4260
|
-
.visage-devtools-tab {
|
|
4261
|
-
background: transparent;
|
|
4262
|
-
border: none;
|
|
4263
|
-
color: #94a3b8;
|
|
4264
|
-
padding: 6px 12px;
|
|
4265
|
-
border-radius: 6px;
|
|
4266
|
-
cursor: pointer;
|
|
4267
|
-
font-size: 12px;
|
|
4268
|
-
font-weight: 500;
|
|
4269
|
-
display: flex;
|
|
4270
|
-
align-items: center;
|
|
4271
|
-
gap: 6px;
|
|
4272
|
-
}
|
|
4273
|
-
.visage-devtools-tab:hover {
|
|
4274
|
-
color: #f1f5f9;
|
|
4275
|
-
background: #1e293b;
|
|
4276
|
-
}
|
|
4277
|
-
.visage-devtools-tab.active {
|
|
4278
|
-
color: #38bdf8;
|
|
4279
|
-
background: #1e293b;
|
|
4280
|
-
font-weight: 600;
|
|
4281
|
-
}
|
|
4282
|
-
.visage-devtools-badge {
|
|
4283
|
-
background: #334155;
|
|
4284
|
-
color: #f1f5f9;
|
|
4285
|
-
padding: 1px 6px;
|
|
4286
|
-
border-radius: 9999px;
|
|
4287
|
-
font-size: 10px;
|
|
4288
|
-
font-weight: 600;
|
|
4289
|
-
}
|
|
4290
|
-
.visage-devtools-body {
|
|
4291
|
-
flex: 1;
|
|
4292
|
-
display: flex;
|
|
4293
|
-
overflow: hidden;
|
|
4294
|
-
}
|
|
4295
|
-
.visage-devtools-sidebar {
|
|
4296
|
-
width: 320px;
|
|
4297
|
-
border-right: 1px solid #1e293b;
|
|
4298
|
-
display: flex;
|
|
4299
|
-
flex-direction: column;
|
|
4300
|
-
background: #0c111d;
|
|
4301
|
-
}
|
|
4302
|
-
.visage-devtools-search {
|
|
4303
|
-
padding: 8px;
|
|
4304
|
-
border-bottom: 1px solid #1e293b;
|
|
4305
|
-
}
|
|
4306
|
-
.visage-devtools-input {
|
|
4307
|
-
width: 100%;
|
|
4308
|
-
background: #090d16;
|
|
4309
|
-
border: 1px solid #334155;
|
|
4310
|
-
border-radius: 6px;
|
|
4311
|
-
color: #f1f5f9;
|
|
4312
|
-
padding: 6px 10px;
|
|
4313
|
-
font-size: 12px;
|
|
4314
|
-
outline: none;
|
|
4315
|
-
}
|
|
4316
|
-
.visage-devtools-input:focus {
|
|
4317
|
-
border-color: #38bdf8;
|
|
4318
|
-
}
|
|
4319
|
-
.visage-devtools-list {
|
|
4320
|
-
flex: 1;
|
|
4321
|
-
overflow-y: auto;
|
|
4322
|
-
padding: 4px;
|
|
4323
|
-
}
|
|
4324
|
-
.visage-devtools-item {
|
|
4325
|
-
padding: 8px 10px;
|
|
4326
|
-
border-radius: 6px;
|
|
4327
|
-
cursor: pointer;
|
|
4328
|
-
display: flex;
|
|
4329
|
-
align-items: center;
|
|
4330
|
-
justify-content: space-between;
|
|
4331
|
-
margin-bottom: 2px;
|
|
4332
|
-
font-size: 12px;
|
|
4333
|
-
}
|
|
4334
|
-
.visage-devtools-item:hover {
|
|
4335
|
-
background: #1e293b;
|
|
4336
|
-
}
|
|
4337
|
-
.visage-devtools-item.selected {
|
|
4338
|
-
background: #1e293b;
|
|
4339
|
-
border-left: 3px solid #38bdf8;
|
|
4340
|
-
}
|
|
4341
|
-
.visage-devtools-main {
|
|
4342
|
-
flex: 1;
|
|
4343
|
-
padding: 16px;
|
|
4344
|
-
overflow-y: auto;
|
|
4345
|
-
background: #090d16;
|
|
4346
|
-
}
|
|
4347
|
-
.visage-devtools-json {
|
|
4348
|
-
background: #050811;
|
|
4349
|
-
border: 1px solid #1e293b;
|
|
4350
|
-
border-radius: 6px;
|
|
4351
|
-
padding: 12px;
|
|
4352
|
-
font-family: "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
|
|
4353
|
-
font-size: 12px;
|
|
4354
|
-
color: #38bdf8;
|
|
4355
|
-
overflow-x: auto;
|
|
4356
|
-
white-space: pre-wrap;
|
|
4357
|
-
}
|
|
4358
|
-
.visage-devtools-actions {
|
|
4359
|
-
display: flex;
|
|
4360
|
-
align-items: center;
|
|
4361
|
-
gap: 8px;
|
|
4362
|
-
}
|
|
4363
|
-
.visage-devtools-btn {
|
|
4364
|
-
background: #1e293b;
|
|
4365
|
-
border: 1px solid #334155;
|
|
4366
|
-
color: #f1f5f9;
|
|
4367
|
-
padding: 4px 10px;
|
|
4368
|
-
border-radius: 4px;
|
|
4369
|
-
font-size: 11px;
|
|
4370
|
-
cursor: pointer;
|
|
4371
|
-
font-weight: 500;
|
|
4372
|
-
}
|
|
4373
|
-
.visage-devtools-btn:hover {
|
|
4374
|
-
background: #334155;
|
|
4375
|
-
}
|
|
4376
|
-
.visage-devtools-btn.active {
|
|
4377
|
-
background: #0284c7;
|
|
4378
|
-
border-color: #38bdf8;
|
|
4379
|
-
}
|
|
4380
|
-
/* DAG Graph Visualization */
|
|
4381
|
-
.visage-graph-container {
|
|
4382
|
-
flex: 1;
|
|
4383
|
-
display: flex;
|
|
4384
|
-
flex-direction: column;
|
|
4385
|
-
overflow: hidden;
|
|
4386
|
-
background: #050811;
|
|
4387
|
-
position: relative;
|
|
4388
|
-
}
|
|
4389
|
-
.visage-graph-toolbar {
|
|
4390
|
-
padding: 8px 16px;
|
|
4391
|
-
background: #090d16;
|
|
4392
|
-
border-bottom: 1px solid #1e293b;
|
|
4393
|
-
display: flex;
|
|
4394
|
-
align-items: center;
|
|
4395
|
-
justify-content: space-between;
|
|
4396
|
-
gap: 12px;
|
|
4397
|
-
}
|
|
4398
|
-
.visage-graph-canvas {
|
|
4399
|
-
flex: 1;
|
|
4400
|
-
overflow: auto;
|
|
4401
|
-
padding: 24px;
|
|
4402
|
-
position: relative;
|
|
4403
|
-
display: flex;
|
|
4404
|
-
gap: 40px;
|
|
4405
|
-
}
|
|
4406
|
-
.visage-graph-column {
|
|
4407
|
-
display: flex;
|
|
4408
|
-
flex-direction: column;
|
|
4409
|
-
gap: 16px;
|
|
4410
|
-
min-width: 220px;
|
|
4411
|
-
}
|
|
4412
|
-
.visage-graph-col-header {
|
|
4413
|
-
font-size: 11px;
|
|
4414
|
-
font-weight: 700;
|
|
4415
|
-
text-transform: uppercase;
|
|
4416
|
-
letter-spacing: 0.05em;
|
|
4417
|
-
color: #64748b;
|
|
4418
|
-
margin-bottom: 4px;
|
|
4419
|
-
display: flex;
|
|
4420
|
-
align-items: center;
|
|
4421
|
-
gap: 6px;
|
|
4422
|
-
}
|
|
4423
|
-
.visage-graph-node {
|
|
4424
|
-
background: #0f172a;
|
|
4425
|
-
border: 1px solid #1e293b;
|
|
4426
|
-
border-radius: 8px;
|
|
4427
|
-
padding: 10px 12px;
|
|
4428
|
-
cursor: pointer;
|
|
4429
|
-
transition: all 0.2s ease;
|
|
4430
|
-
position: relative;
|
|
4431
|
-
}
|
|
4432
|
-
.visage-graph-node:hover {
|
|
4433
|
-
border-color: #38bdf8;
|
|
4434
|
-
transform: translateY(-2px);
|
|
4435
|
-
box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
|
|
4436
|
-
}
|
|
4437
|
-
.visage-graph-node.selected {
|
|
4438
|
-
border-color: #38bdf8;
|
|
4439
|
-
box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4);
|
|
4440
|
-
background: #131d35;
|
|
4441
|
-
}
|
|
4442
|
-
.visage-graph-node.is-dependency {
|
|
4443
|
-
border-color: #38bdf8;
|
|
4444
|
-
box-shadow: 0 0 0 1px #38bdf8, 0 2px 8px rgba(56, 189, 248, 0.25);
|
|
4445
|
-
background: #082f49;
|
|
4446
|
-
}
|
|
4447
|
-
.visage-graph-node.is-dependent {
|
|
4448
|
-
border-color: #c084fc;
|
|
4449
|
-
box-shadow: 0 0 0 1px #c084fc, 0 2px 8px rgba(192, 132, 252, 0.25);
|
|
4450
|
-
background: #3b0764;
|
|
4451
|
-
}
|
|
4452
|
-
.visage-graph-node.is-dimmed {
|
|
4453
|
-
opacity: 0.3;
|
|
4454
|
-
filter: grayscale(0.5);
|
|
4455
|
-
}
|
|
4456
|
-
.visage-graph-node-title {
|
|
4457
|
-
font-weight: 600;
|
|
4458
|
-
font-size: 12px;
|
|
4459
|
-
color: #f8fafc;
|
|
4460
|
-
margin-bottom: 4px;
|
|
4461
|
-
display: flex;
|
|
4462
|
-
align-items: center;
|
|
4463
|
-
justify-content: space-between;
|
|
4464
|
-
}
|
|
4465
|
-
.visage-graph-node-val {
|
|
4466
|
-
font-family: monospace;
|
|
4467
|
-
font-size: 11px;
|
|
4468
|
-
color: #94a3b8;
|
|
4469
|
-
overflow: hidden;
|
|
4470
|
-
text-overflow: ellipsis;
|
|
4471
|
-
white-space: nowrap;
|
|
4472
|
-
max-width: 190px;
|
|
4473
|
-
}
|
|
4474
|
-
.visage-graph-pulse {
|
|
4475
|
-
display: inline-block;
|
|
4476
|
-
width: 8px;
|
|
4477
|
-
height: 8px;
|
|
4478
|
-
border-radius: 50%;
|
|
4479
|
-
background: #10b981;
|
|
4480
|
-
box-shadow: 0 0 8px #10b981;
|
|
4481
|
-
}
|
|
4482
|
-
.visage-graph-pulse.computed {
|
|
4483
|
-
background: #a855f7;
|
|
4484
|
-
box-shadow: 0 0 8px #a855f7;
|
|
4485
|
-
}
|
|
4486
|
-
.visage-graph-pill {
|
|
4487
|
-
display: inline-flex;
|
|
4488
|
-
align-items: center;
|
|
4489
|
-
gap: 4px;
|
|
4490
|
-
background: #1e293b;
|
|
4491
|
-
color: #cbd5e1;
|
|
4492
|
-
padding: 3px 8px;
|
|
4493
|
-
border-radius: 4px;
|
|
4494
|
-
font-size: 11px;
|
|
4495
|
-
cursor: pointer;
|
|
4496
|
-
border: 1px solid #334155;
|
|
4497
|
-
transition: all 0.15s ease;
|
|
4498
|
-
}
|
|
4499
|
-
.visage-graph-pill:hover {
|
|
4500
|
-
background: #334155;
|
|
4501
|
-
color: #fff;
|
|
4502
|
-
border-color: #38bdf8;
|
|
4503
|
-
}
|
|
4504
|
-
.visage-graph-pill.source {
|
|
4505
|
-
border-color: #0369a1;
|
|
4506
|
-
color: #7dd3fc;
|
|
4507
|
-
}
|
|
4508
|
-
.visage-graph-pill.target {
|
|
4509
|
-
border-color: #7e22ce;
|
|
4510
|
-
color: #d8b4fe;
|
|
4511
|
-
}
|
|
4512
|
-
`;
|
|
4513
|
-
|
|
4514
|
-
// src/devtools/component.tsx
|
|
4515
|
-
function VisageDevTools(props = {}) {
|
|
4516
|
-
if (typeof window === "undefined") {
|
|
4517
|
-
return null;
|
|
4518
|
-
}
|
|
4519
|
-
const hub = devtoolsHub;
|
|
4520
|
-
if (typeof window !== "undefined" && !window.__VISAGE_DEVTOOLS__) {
|
|
4521
|
-
window.__VISAGE_DEVTOOLS__ = hub;
|
|
4522
|
-
}
|
|
4523
|
-
if (props.initialOpen !== undefined) {
|
|
4524
|
-
hub.isOpen.set(props.initialOpen);
|
|
4525
|
-
}
|
|
4526
|
-
if (props.initialTab !== undefined) {
|
|
4527
|
-
hub.activeTab.set(props.initialTab);
|
|
4528
|
-
}
|
|
4529
|
-
if (props.highlightDOM !== undefined) {
|
|
4530
|
-
hub.highlightDOM.set(props.highlightDOM);
|
|
4531
|
-
}
|
|
4532
|
-
setupDomMutationHighlighter(() => hub.highlightDOM());
|
|
4533
|
-
const selectedId = signal(null, { internal: true });
|
|
4534
|
-
const searchQuery = signal("", { internal: true });
|
|
4535
|
-
if (typeof window !== "undefined") {
|
|
4536
|
-
const handleKeyDown = (e) => {
|
|
4537
|
-
if (e.shiftKey && e.altKey && e.key.toLowerCase() === "v") {
|
|
4538
|
-
e.preventDefault();
|
|
4539
|
-
hub.toggle();
|
|
4540
|
-
}
|
|
4541
|
-
};
|
|
4542
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
4543
|
-
onCleanup(() => window.removeEventListener("keydown", handleKeyDown));
|
|
4544
|
-
}
|
|
4545
|
-
const formatJSON = (val) => {
|
|
4546
|
-
try {
|
|
4547
|
-
if (val === undefined)
|
|
4548
|
-
return "undefined";
|
|
4549
|
-
return JSON.stringify(val, null, 2);
|
|
4550
|
-
} catch {
|
|
4551
|
-
return String(val);
|
|
4552
|
-
}
|
|
4553
|
-
};
|
|
4554
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
4555
|
-
class: "visage-devtools-root",
|
|
4556
|
-
children: [
|
|
4557
|
-
/* @__PURE__ */ jsx(Style, {
|
|
4558
|
-
children: devtoolsStyles
|
|
4559
|
-
}),
|
|
4560
|
-
() => !hub.isOpen() ? /* @__PURE__ */ jsx(Tooltip, {
|
|
4561
|
-
content: "Press Shift+Alt+V to toggle Visage DevTools",
|
|
4562
|
-
side: "top",
|
|
4563
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
4564
|
-
type: "button",
|
|
4565
|
-
class: "visage-devtools-trigger",
|
|
4566
|
-
onClick: () => hub.toggle(),
|
|
4567
|
-
"aria-label": "Open Visage DevTools",
|
|
4568
|
-
children: [
|
|
4569
|
-
/* @__PURE__ */ jsx("svg", {
|
|
4570
|
-
"aria-hidden": "true",
|
|
4571
|
-
width: "14",
|
|
4572
|
-
height: "14",
|
|
4573
|
-
viewBox: "0 0 24 24",
|
|
4574
|
-
fill: "none",
|
|
4575
|
-
stroke: "currentColor",
|
|
4576
|
-
"stroke-width": "2",
|
|
4577
|
-
"stroke-linecap": "round",
|
|
4578
|
-
"stroke-linejoin": "round",
|
|
4579
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
4580
|
-
d: "M13 2L3 14h9l-1 8 10-12h-9l1-8z"
|
|
4581
|
-
})
|
|
4582
|
-
}),
|
|
4583
|
-
/* @__PURE__ */ jsx("span", {
|
|
4584
|
-
children: "DevTools"
|
|
4585
|
-
})
|
|
4586
|
-
]
|
|
4587
|
-
})
|
|
4588
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
4589
|
-
class: "visage-devtools-drawer",
|
|
4590
|
-
role: "dialog",
|
|
4591
|
-
"aria-label": "Visage In-Browser DevTools",
|
|
4592
|
-
children: [
|
|
4593
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4594
|
-
class: "visage-devtools-header",
|
|
4595
|
-
children: [
|
|
4596
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4597
|
-
style: { display: "flex", alignItems: "center", gap: "8px" },
|
|
4598
|
-
children: [
|
|
4599
|
-
/* @__PURE__ */ jsx("svg", {
|
|
4600
|
-
"aria-hidden": "true",
|
|
4601
|
-
width: "14",
|
|
4602
|
-
height: "14",
|
|
4603
|
-
viewBox: "0 0 24 24",
|
|
4604
|
-
fill: "none",
|
|
4605
|
-
stroke: "#38bdf8",
|
|
4606
|
-
"stroke-width": "2",
|
|
4607
|
-
"stroke-linecap": "round",
|
|
4608
|
-
"stroke-linejoin": "round",
|
|
4609
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
4610
|
-
d: "M13 2L3 14h9l-1 8 10-12h-9l1-8z"
|
|
4611
|
-
})
|
|
4612
|
-
}),
|
|
4613
|
-
/* @__PURE__ */ jsx("strong", {
|
|
4614
|
-
style: {
|
|
4615
|
-
fontSize: "12px",
|
|
4616
|
-
letterSpacing: "0.04em",
|
|
4617
|
-
color: "#f8fafc",
|
|
4618
|
-
fontWeight: 700
|
|
4619
|
-
},
|
|
4620
|
-
children: "VISAGE"
|
|
4621
|
-
})
|
|
4622
|
-
]
|
|
4623
|
-
}),
|
|
4624
|
-
/* @__PURE__ */ jsx(Tabs, {
|
|
4625
|
-
value: () => hub.activeTab(),
|
|
4626
|
-
onValueChange: (val) => {
|
|
4627
|
-
hub.setTab(val);
|
|
4628
|
-
selectedId.set(null);
|
|
4629
|
-
},
|
|
4630
|
-
listClass: "visage-devtools-tabs",
|
|
4631
|
-
items: [
|
|
4632
|
-
{
|
|
4633
|
-
value: "signals",
|
|
4634
|
-
label: () => /* @__PURE__ */ jsxs("span", {
|
|
4635
|
-
style: { display: "inline-flex", alignItems: "center", gap: "6px" },
|
|
4636
|
-
children: [
|
|
4637
|
-
/* @__PURE__ */ jsx("span", {
|
|
4638
|
-
children: "Signals"
|
|
4639
|
-
}),
|
|
4640
|
-
/* @__PURE__ */ jsx("span", {
|
|
4641
|
-
class: "visage-devtools-badge",
|
|
4642
|
-
children: () => hub.signalsList().length
|
|
4643
|
-
})
|
|
4644
|
-
]
|
|
4645
|
-
})
|
|
4646
|
-
},
|
|
4647
|
-
{
|
|
4648
|
-
value: "graph",
|
|
4649
|
-
label: () => /* @__PURE__ */ jsxs("span", {
|
|
4650
|
-
style: { display: "inline-flex", alignItems: "center", gap: "6px" },
|
|
4651
|
-
children: [
|
|
4652
|
-
/* @__PURE__ */ jsx("span", {
|
|
4653
|
-
children: "DAG Graph"
|
|
4654
|
-
}),
|
|
4655
|
-
/* @__PURE__ */ jsx("span", {
|
|
4656
|
-
class: "visage-devtools-badge",
|
|
4657
|
-
style: { background: "#581c87", color: "#fff" },
|
|
4658
|
-
children: "LIVE"
|
|
4659
|
-
})
|
|
4660
|
-
]
|
|
4661
|
-
})
|
|
4662
|
-
},
|
|
4663
|
-
{
|
|
4664
|
-
value: "query",
|
|
4665
|
-
label: () => /* @__PURE__ */ jsxs("span", {
|
|
4666
|
-
style: { display: "inline-flex", alignItems: "center", gap: "6px" },
|
|
4667
|
-
children: [
|
|
4668
|
-
/* @__PURE__ */ jsx("span", {
|
|
4669
|
-
children: "Query Cache"
|
|
4670
|
-
}),
|
|
4671
|
-
/* @__PURE__ */ jsx("span", {
|
|
4672
|
-
class: "visage-devtools-badge",
|
|
4673
|
-
children: () => hub.queriesList().length
|
|
4674
|
-
})
|
|
4675
|
-
]
|
|
4676
|
-
})
|
|
4677
|
-
},
|
|
4678
|
-
{
|
|
4679
|
-
value: "rpc",
|
|
4680
|
-
label: () => /* @__PURE__ */ jsxs("span", {
|
|
4681
|
-
style: { display: "inline-flex", alignItems: "center", gap: "6px" },
|
|
4682
|
-
children: [
|
|
4683
|
-
/* @__PURE__ */ jsx("span", {
|
|
4684
|
-
children: "RPC"
|
|
4685
|
-
}),
|
|
4686
|
-
/* @__PURE__ */ jsx("span", {
|
|
4687
|
-
class: "visage-devtools-badge",
|
|
4688
|
-
children: () => hub.rpcLogs().length
|
|
4689
|
-
})
|
|
4690
|
-
]
|
|
4691
|
-
})
|
|
4692
|
-
},
|
|
4693
|
-
{
|
|
4694
|
-
value: "dom",
|
|
4695
|
-
label: "DOM Inspector"
|
|
4696
|
-
}
|
|
4697
|
-
]
|
|
4698
|
-
}),
|
|
4699
|
-
/* @__PURE__ */ jsx("div", {
|
|
4700
|
-
class: "visage-devtools-actions",
|
|
4701
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
4702
|
-
type: "button",
|
|
4703
|
-
class: "visage-devtools-btn",
|
|
4704
|
-
onClick: () => hub.isOpen.set(false),
|
|
4705
|
-
title: "Close DevTools (Shift+Alt+V)",
|
|
4706
|
-
children: "Close"
|
|
4707
|
-
})
|
|
4708
|
-
})
|
|
4709
|
-
]
|
|
4710
|
-
}),
|
|
4711
|
-
/* @__PURE__ */ jsx("div", {
|
|
4712
|
-
class: "visage-devtools-body",
|
|
4713
|
-
children: () => {
|
|
4714
|
-
const tab = hub.activeTab();
|
|
4715
|
-
if (tab === "signals") {
|
|
4716
|
-
return /* @__PURE__ */ jsx(SignalsTab, {
|
|
4717
|
-
hub,
|
|
4718
|
-
selectedId,
|
|
4719
|
-
searchQuery,
|
|
4720
|
-
formatJSON
|
|
4721
|
-
});
|
|
4722
|
-
}
|
|
4723
|
-
if (tab === "graph") {
|
|
4724
|
-
return /* @__PURE__ */ jsx(GraphTab, {
|
|
4725
|
-
hub,
|
|
4726
|
-
selectedId,
|
|
4727
|
-
searchQuery,
|
|
4728
|
-
formatJSON
|
|
4729
|
-
});
|
|
4730
|
-
}
|
|
4731
|
-
if (tab === "query") {
|
|
4732
|
-
return /* @__PURE__ */ jsx(QueryTab, {
|
|
4733
|
-
hub,
|
|
4734
|
-
selectedId,
|
|
4735
|
-
searchQuery,
|
|
4736
|
-
formatJSON
|
|
4737
|
-
});
|
|
4738
|
-
}
|
|
4739
|
-
if (tab === "rpc") {
|
|
4740
|
-
return /* @__PURE__ */ jsx(RpcTab, {
|
|
4741
|
-
hub,
|
|
4742
|
-
selectedId,
|
|
4743
|
-
searchQuery,
|
|
4744
|
-
formatJSON
|
|
4745
|
-
});
|
|
4746
|
-
}
|
|
4747
|
-
return /* @__PURE__ */ jsx(DomTab, {
|
|
4748
|
-
hub
|
|
4749
|
-
});
|
|
4750
|
-
}
|
|
4751
|
-
})
|
|
4752
|
-
]
|
|
4753
|
-
})
|
|
4754
|
-
]
|
|
4755
|
-
});
|
|
4756
|
-
}
|
|
4757
|
-
|
|
4758
|
-
// src/devtools/index.ts
|
|
4759
|
-
function connectDevTools(client) {
|
|
4760
|
-
devtoolsHub.attachQueryClient(client);
|
|
4761
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DevToolsHub2,
|
|
3
|
+
devtoolsHub2,
|
|
4
|
+
highlightElement2,
|
|
5
|
+
VisageDevTools2,
|
|
6
|
+
connectDevTools2
|
|
7
|
+
} from "../index-zr6cvset.js";
|
|
8
|
+
import"../index-8x8xz80v.js";
|
|
9
|
+
import"../index-0madxn60.js";
|
|
10
|
+
import"../index-9fvarkrx.js";
|
|
11
|
+
import"../index-5s255b3w.js";
|
|
12
|
+
import"../index-a4xns6cc.js";
|
|
13
|
+
import"../index-6kfe1nr4.js";
|
|
4762
14
|
export {
|
|
4763
|
-
DevToolsHub,
|
|
4764
|
-
VisageDevTools,
|
|
4765
|
-
connectDevTools,
|
|
4766
|
-
devtoolsHub,
|
|
4767
|
-
highlightElement
|
|
15
|
+
DevToolsHub2 as DevToolsHub,
|
|
16
|
+
VisageDevTools2 as VisageDevTools,
|
|
17
|
+
connectDevTools2 as connectDevTools,
|
|
18
|
+
devtoolsHub2 as devtoolsHub,
|
|
19
|
+
highlightElement2 as highlightElement
|
|
4768
20
|
};
|