@vobs/devtools-ui 1.2.0 → 1.2.2
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/index.cjs +613 -1948
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -1393
- package/dist/index.js.map +1 -1
- package/dist/panel.cjs +589 -1836
- package/dist/panel.cjs.map +1 -1
- package/dist/panel.js +12 -1279
- package/dist/panel.js.map +1 -1
- package/dist/widget.cjs +608 -1945
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.js +35 -1392
- package/dist/widget.js.map +1 -1
- package/package.json +10 -6
package/dist/index.js
CHANGED
|
@@ -1,1376 +1,14 @@
|
|
|
1
|
-
import 'axios';
|
|
2
|
-
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
3
|
|
|
6
|
-
// packages/reactivity/src/debug.ts
|
|
7
|
-
var activeDebugHooks = null;
|
|
8
|
-
var signalNames = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
function hasDebugHooks() {
|
|
10
|
-
return activeDebugHooks !== null;
|
|
11
|
-
}
|
|
12
|
-
__name(hasDebugHooks, "hasDebugHooks");
|
|
13
|
-
function setSignalDebugName(signal, name) {
|
|
14
|
-
signalNames.set(signal, name);
|
|
15
|
-
invokeDebug("signalNamed", signal, name);
|
|
16
|
-
}
|
|
17
|
-
__name(setSignalDebugName, "setSignalDebugName");
|
|
18
|
-
function invokeDebug(name, ...args) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
__name(invokeDebug, "invokeDebug");
|
|
22
|
-
|
|
23
|
-
// packages/reactivity/src/owner.ts
|
|
24
|
-
var currentOwner = null;
|
|
25
|
-
var nextOwnerId = 1;
|
|
26
|
-
var ownerNames = /* @__PURE__ */ new WeakMap();
|
|
27
|
-
function createOwner() {
|
|
28
|
-
const parent = currentOwner;
|
|
29
|
-
let disposed = parent?.disposed ?? false;
|
|
30
|
-
const children = [];
|
|
31
|
-
const cleanups = [];
|
|
32
|
-
const errorHandlers = /* @__PURE__ */ new Set();
|
|
33
|
-
const owner = {
|
|
34
|
-
id: `owner-${nextOwnerId++}`,
|
|
35
|
-
parent,
|
|
36
|
-
children,
|
|
37
|
-
depth: (parent?.depth ?? -1) + 1,
|
|
38
|
-
get disposed() {
|
|
39
|
-
return disposed;
|
|
40
|
-
},
|
|
41
|
-
run(fn) {
|
|
42
|
-
if (disposed) throw new Error("Vobs: \u5DF2\u9500\u6BC1\u7684 Owner \u4E0D\u80FD\u7EE7\u7EED\u8FD0\u884C");
|
|
43
|
-
const previous = currentOwner;
|
|
44
|
-
currentOwner = owner;
|
|
45
|
-
try {
|
|
46
|
-
return fn();
|
|
47
|
-
} finally {
|
|
48
|
-
currentOwner = previous;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
addCleanup(cleanup) {
|
|
52
|
-
if (disposed) {
|
|
53
|
-
cleanup();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
cleanups.push(cleanup);
|
|
57
|
-
},
|
|
58
|
-
onDispose(cleanup) {
|
|
59
|
-
owner.addCleanup(cleanup);
|
|
60
|
-
},
|
|
61
|
-
onError(handler) {
|
|
62
|
-
errorHandlers.add(handler);
|
|
63
|
-
const remove = /* @__PURE__ */ __name(() => errorHandlers.delete(handler), "remove");
|
|
64
|
-
owner.addCleanup(remove);
|
|
65
|
-
return remove;
|
|
66
|
-
},
|
|
67
|
-
handleError(error) {
|
|
68
|
-
for (const handler of [...errorHandlers].reverse()) {
|
|
69
|
-
try {
|
|
70
|
-
handler(error);
|
|
71
|
-
return true;
|
|
72
|
-
} catch (handlerError) {
|
|
73
|
-
return parent?.handleError(handlerError) ?? false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return parent?.handleError(error) ?? false;
|
|
77
|
-
},
|
|
78
|
-
dispose() {
|
|
79
|
-
if (disposed) return;
|
|
80
|
-
disposed = true;
|
|
81
|
-
for (const child of [...children]) child.dispose();
|
|
82
|
-
children.length = 0;
|
|
83
|
-
let firstError;
|
|
84
|
-
for (let index = cleanups.length - 1; index >= 0; index--) {
|
|
85
|
-
try {
|
|
86
|
-
cleanups[index]();
|
|
87
|
-
} catch (error) {
|
|
88
|
-
firstError ?? (firstError = error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
cleanups.length = 0;
|
|
92
|
-
if (parent) {
|
|
93
|
-
const index = parent.children.indexOf(owner);
|
|
94
|
-
if (index >= 0) parent.children.splice(index, 1);
|
|
95
|
-
}
|
|
96
|
-
if (firstError) throw firstError;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
if (parent && !parent.disposed) parent.children.push(owner);
|
|
100
|
-
return owner;
|
|
101
|
-
}
|
|
102
|
-
__name(createOwner, "createOwner");
|
|
103
|
-
function setOwnerDebugName(owner, name) {
|
|
104
|
-
ownerNames.set(owner, name);
|
|
105
|
-
}
|
|
106
|
-
__name(setOwnerDebugName, "setOwnerDebugName");
|
|
107
|
-
function getCurrentOwner() {
|
|
108
|
-
return currentOwner;
|
|
109
|
-
}
|
|
110
|
-
__name(getCurrentOwner, "getCurrentOwner");
|
|
111
|
-
function onDispose(cleanup) {
|
|
112
|
-
const owner = getCurrentOwner();
|
|
113
|
-
if (!owner) throw new Error("Vobs: onDispose \u5FC5\u987B\u5728 Owner \u4F5C\u7528\u57DF\u5185\u8C03\u7528");
|
|
114
|
-
owner.onDispose(cleanup);
|
|
115
|
-
}
|
|
116
|
-
__name(onDispose, "onDispose");
|
|
117
|
-
|
|
118
|
-
// packages/reactivity/src/signal.ts
|
|
119
|
-
var currentSubscriber = null;
|
|
120
|
-
function getCurrentSubscriber() {
|
|
121
|
-
return currentSubscriber;
|
|
122
|
-
}
|
|
123
|
-
__name(getCurrentSubscriber, "getCurrentSubscriber");
|
|
124
|
-
function setCurrentSubscriber(subscriber) {
|
|
125
|
-
currentSubscriber = subscriber;
|
|
126
|
-
}
|
|
127
|
-
__name(setCurrentSubscriber, "setCurrentSubscriber");
|
|
128
|
-
function trackDependency(dependency) {
|
|
129
|
-
if (!currentSubscriber || currentSubscriber.disposed) return;
|
|
130
|
-
!currentSubscriber.dependencies.has(dependency);
|
|
131
|
-
currentSubscriber.dependencies.add(dependency);
|
|
132
|
-
}
|
|
133
|
-
__name(trackDependency, "trackDependency");
|
|
134
|
-
function state(initialValue, debugName) {
|
|
135
|
-
let value = initialValue;
|
|
136
|
-
let disposed = false;
|
|
137
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
138
|
-
const signalInstance = {
|
|
139
|
-
get value() {
|
|
140
|
-
const subscriber = getCurrentSubscriber();
|
|
141
|
-
if (subscriber && !subscriber.disposed) {
|
|
142
|
-
subscribers.add(subscriber);
|
|
143
|
-
trackDependency(signalInstance);
|
|
144
|
-
}
|
|
145
|
-
return value;
|
|
146
|
-
},
|
|
147
|
-
set value(nextValue) {
|
|
148
|
-
if (disposed || Object.is(value, nextValue)) return;
|
|
149
|
-
value = nextValue;
|
|
150
|
-
for (const subscriber of [...subscribers]) subscriber.notify();
|
|
151
|
-
},
|
|
152
|
-
unsubscribe(subscriber) {
|
|
153
|
-
subscribers.delete(subscriber);
|
|
154
|
-
},
|
|
155
|
-
// 与 `.value =` 赋值同一条路径:判等短路、debug hook、notify 全部一致。
|
|
156
|
-
// 以闭包实现,可安全地作为回调直接传递(无 this 绑定问题)。
|
|
157
|
-
set(next) {
|
|
158
|
-
signalInstance.value = next;
|
|
159
|
-
},
|
|
160
|
-
dispose() {
|
|
161
|
-
if (disposed) return;
|
|
162
|
-
disposed = true;
|
|
163
|
-
subscribers.clear();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const owner = getCurrentOwner();
|
|
167
|
-
owner?.addCleanup(signalInstance.dispose);
|
|
168
|
-
if (debugName?.trim()) setSignalDebugName(signalInstance, debugName.trim());
|
|
169
|
-
return signalInstance;
|
|
170
|
-
}
|
|
171
|
-
__name(state, "state");
|
|
172
|
-
|
|
173
|
-
// packages/reactivity/src/scheduler.ts
|
|
174
|
-
var _Scheduler = class _Scheduler {
|
|
175
|
-
constructor() {
|
|
176
|
-
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
177
|
-
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
178
|
-
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
179
|
-
this.normalBuffer = [];
|
|
180
|
-
this.lowBuffer = [];
|
|
181
|
-
this.flushing = false;
|
|
182
|
-
this.scheduled = false;
|
|
183
|
-
this.batchDepth = 0;
|
|
184
|
-
}
|
|
185
|
-
schedule(effect2) {
|
|
186
|
-
if (effect2.disposed) return;
|
|
187
|
-
this.dirtyEffects.add(effect2);
|
|
188
|
-
this.lowPriorityEffects.delete(effect2);
|
|
189
|
-
this.ensureScheduled();
|
|
190
|
-
}
|
|
191
|
-
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
192
|
-
scheduleLow(effect2) {
|
|
193
|
-
if (effect2.disposed) return;
|
|
194
|
-
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
195
|
-
this.ensureScheduled();
|
|
196
|
-
}
|
|
197
|
-
ensureScheduled() {
|
|
198
|
-
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
199
|
-
this.scheduled = true;
|
|
200
|
-
queueMicrotask(() => {
|
|
201
|
-
this.scheduled = false;
|
|
202
|
-
this.flush();
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
remove(effect2) {
|
|
207
|
-
this.dirtyEffects.delete(effect2);
|
|
208
|
-
this.lowPriorityEffects.delete(effect2);
|
|
209
|
-
}
|
|
210
|
-
batch(fn) {
|
|
211
|
-
this.batchDepth++;
|
|
212
|
-
try {
|
|
213
|
-
return fn();
|
|
214
|
-
} finally {
|
|
215
|
-
this.batchDepth--;
|
|
216
|
-
if (this.batchDepth === 0) this.flush();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
flush() {
|
|
220
|
-
if (this.flushing || this.batchDepth > 0) return;
|
|
221
|
-
this.flushing = true;
|
|
222
|
-
let rounds = 0;
|
|
223
|
-
let firstError;
|
|
224
|
-
let hasError = false;
|
|
225
|
-
try {
|
|
226
|
-
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
227
|
-
if (++rounds > 100) {
|
|
228
|
-
this.dirtyEffects.clear();
|
|
229
|
-
this.lowPriorityEffects.clear();
|
|
230
|
-
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
231
|
-
}
|
|
232
|
-
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
233
|
-
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
234
|
-
sortEffects(this.normalBuffer);
|
|
235
|
-
sortEffects(this.lowBuffer);
|
|
236
|
-
for (const effect2 of this.normalBuffer) {
|
|
237
|
-
try {
|
|
238
|
-
effect2.run();
|
|
239
|
-
} catch (error) {
|
|
240
|
-
if (!hasError) {
|
|
241
|
-
firstError = error;
|
|
242
|
-
hasError = true;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
for (const effect2 of this.lowBuffer) {
|
|
247
|
-
try {
|
|
248
|
-
effect2.run();
|
|
249
|
-
} catch (error) {
|
|
250
|
-
if (!hasError) {
|
|
251
|
-
firstError = error;
|
|
252
|
-
hasError = true;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
this.normalBuffer.length = 0;
|
|
257
|
-
this.lowBuffer.length = 0;
|
|
258
|
-
}
|
|
259
|
-
} finally {
|
|
260
|
-
this.normalBuffer.length = 0;
|
|
261
|
-
this.lowBuffer.length = 0;
|
|
262
|
-
this.flushing = false;
|
|
263
|
-
}
|
|
264
|
-
if (hasError) throw firstError;
|
|
265
|
-
}
|
|
266
|
-
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
267
|
-
collectRunnable(source, target) {
|
|
268
|
-
for (const effect2 of source) {
|
|
269
|
-
if (!effect2.disposed) target.push(effect2);
|
|
270
|
-
}
|
|
271
|
-
source.clear();
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
__name(_Scheduler, "Scheduler");
|
|
275
|
-
var Scheduler = _Scheduler;
|
|
276
|
-
function sortEffects(effects) {
|
|
277
|
-
if (effects.length > 1) {
|
|
278
|
-
effects.sort((a, b) => b.depth - a.depth || a.order - b.order);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
__name(sortEffects, "sortEffects");
|
|
282
|
-
var scheduler = new Scheduler();
|
|
283
|
-
|
|
284
|
-
// packages/reactivity/src/effect.ts
|
|
285
|
-
var nextEffectOrder = 1;
|
|
286
|
-
function cleanupDependencies(subscriber) {
|
|
287
|
-
for (const dependency of subscriber.dependencies) {
|
|
288
|
-
dependency.unsubscribe(subscriber);
|
|
289
|
-
}
|
|
290
|
-
subscriber.dependencies.clear();
|
|
291
|
-
}
|
|
292
|
-
__name(cleanupDependencies, "cleanupDependencies");
|
|
293
|
-
function effect(callback) {
|
|
294
|
-
const owner = getCurrentOwner();
|
|
295
|
-
let cleanup;
|
|
296
|
-
let dirty = true;
|
|
297
|
-
let disposed = false;
|
|
298
|
-
const eff = {
|
|
299
|
-
order: nextEffectOrder++,
|
|
300
|
-
depth: owner?.depth ?? 0,
|
|
301
|
-
dependencies: /* @__PURE__ */ new Set(),
|
|
302
|
-
get disposed() {
|
|
303
|
-
return disposed;
|
|
304
|
-
},
|
|
305
|
-
notify() {
|
|
306
|
-
if (disposed || dirty) return;
|
|
307
|
-
dirty = true;
|
|
308
|
-
scheduler.schedule(eff);
|
|
309
|
-
},
|
|
310
|
-
run() {
|
|
311
|
-
if (disposed || !dirty) return;
|
|
312
|
-
dirty = false;
|
|
313
|
-
const previousCleanup = cleanup;
|
|
314
|
-
cleanup = void 0;
|
|
315
|
-
let cleanupError;
|
|
316
|
-
if (previousCleanup) {
|
|
317
|
-
try {
|
|
318
|
-
previousCleanup();
|
|
319
|
-
} catch (error) {
|
|
320
|
-
const handled2 = owner?.handleError(error) ?? false;
|
|
321
|
-
if (!handled2) cleanupError = error;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
cleanupDependencies(eff);
|
|
325
|
-
const previous = getCurrentSubscriber();
|
|
326
|
-
setCurrentSubscriber(eff);
|
|
327
|
-
let thrown;
|
|
328
|
-
let handled = false;
|
|
329
|
-
try {
|
|
330
|
-
const result = owner ? owner.run(callback) : callback();
|
|
331
|
-
cleanup = typeof result === "function" ? result : void 0;
|
|
332
|
-
} catch (error) {
|
|
333
|
-
thrown = error;
|
|
334
|
-
handled = owner?.handleError(error) ?? false;
|
|
335
|
-
if (!handled) throw error;
|
|
336
|
-
} finally {
|
|
337
|
-
setCurrentSubscriber(previous);
|
|
338
|
-
}
|
|
339
|
-
if (cleanupError && !thrown) throw cleanupError;
|
|
340
|
-
},
|
|
341
|
-
scheduleLow() {
|
|
342
|
-
if (disposed || dirty) return;
|
|
343
|
-
dirty = true;
|
|
344
|
-
scheduler.scheduleLow(eff);
|
|
345
|
-
},
|
|
346
|
-
dispose() {
|
|
347
|
-
if (disposed) return;
|
|
348
|
-
disposed = true;
|
|
349
|
-
dirty = false;
|
|
350
|
-
scheduler.remove(eff);
|
|
351
|
-
const previousCleanup = cleanup;
|
|
352
|
-
cleanup = void 0;
|
|
353
|
-
let cleanupError;
|
|
354
|
-
if (previousCleanup) {
|
|
355
|
-
try {
|
|
356
|
-
previousCleanup();
|
|
357
|
-
} catch (error) {
|
|
358
|
-
const handled = owner?.handleError(error) ?? false;
|
|
359
|
-
if (!handled) cleanupError = error;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
cleanupDependencies(eff);
|
|
363
|
-
if (cleanupError) throw cleanupError;
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
owner?.addCleanup(eff.dispose);
|
|
367
|
-
eff.run();
|
|
368
|
-
return eff;
|
|
369
|
-
}
|
|
370
|
-
__name(effect, "effect");
|
|
371
|
-
|
|
372
|
-
// packages/runtime/src/debug.ts
|
|
373
|
-
var activeRuntimeDebugHooks = null;
|
|
374
|
-
function getRuntimeDebugHooks() {
|
|
375
|
-
return activeRuntimeDebugHooks;
|
|
376
|
-
}
|
|
377
|
-
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
378
|
-
function invokeRuntimeDebug(name, ...args) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
__name(invokeRuntimeDebug, "invokeRuntimeDebug");
|
|
382
|
-
function readDebugValue(read) {
|
|
383
|
-
try {
|
|
384
|
-
return read();
|
|
385
|
-
} catch {
|
|
386
|
-
return "[Uninspectable]";
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
__name(readDebugValue, "readDebugValue");
|
|
390
|
-
function describeDebugNode(node) {
|
|
391
|
-
if (!node || typeof node !== "object") return "node";
|
|
392
|
-
const value = node;
|
|
393
|
-
const name = typeof value.tagName === "string" ? value.tagName.toLowerCase() : typeof value.nodeName === "string" ? value.nodeName.toLowerCase() : "node";
|
|
394
|
-
const id = typeof value.id === "string" && value.id ? `#${value.id}` : "";
|
|
395
|
-
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().split(/\s+/).filter(Boolean).join(".")}` : "";
|
|
396
|
-
return `${name}${id}${className}`;
|
|
397
|
-
}
|
|
398
|
-
__name(describeDebugNode, "describeDebugNode");
|
|
399
|
-
|
|
400
|
-
// packages/runtime/src/hmr.ts
|
|
401
|
-
var globalTarget = globalThis;
|
|
402
|
-
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
403
|
-
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
404
|
-
function registerHmrInstance(moduleId, instance) {
|
|
405
|
-
const instances = getModule(moduleId).instances;
|
|
406
|
-
instances.add(instance);
|
|
407
|
-
return () => instances.delete(instance);
|
|
408
|
-
}
|
|
409
|
-
__name(registerHmrInstance, "registerHmrInstance");
|
|
410
|
-
function markHmrInstanceMounted(node, parent) {
|
|
411
|
-
const instance = hmrInstances.get(node);
|
|
412
|
-
if (instance) instance.parent = parent;
|
|
413
|
-
}
|
|
414
|
-
__name(markHmrInstanceMounted, "markHmrInstanceMounted");
|
|
415
|
-
function getModule(moduleId) {
|
|
416
|
-
let module = hmrGlobal.modules.get(moduleId);
|
|
417
|
-
if (!module) {
|
|
418
|
-
module = { components: /* @__PURE__ */ new Map(), state: /* @__PURE__ */ new Map(), instances: /* @__PURE__ */ new Set() };
|
|
419
|
-
hmrGlobal.modules.set(moduleId, module);
|
|
420
|
-
}
|
|
421
|
-
return module;
|
|
422
|
-
}
|
|
423
|
-
__name(getModule, "getModule");
|
|
424
|
-
var hmrInstances = /* @__PURE__ */ new WeakMap();
|
|
425
|
-
function associateHmrInstance(node, instance) {
|
|
426
|
-
hmrInstances.set(node, instance);
|
|
427
|
-
}
|
|
428
|
-
__name(associateHmrInstance, "associateHmrInstance");
|
|
429
|
-
var nodeOwners = /* @__PURE__ */ new WeakMap();
|
|
430
|
-
var eventBindings = /* @__PURE__ */ new WeakMap();
|
|
431
|
-
function getRenderer() {
|
|
432
|
-
{
|
|
433
|
-
throw new Error("\u6E32\u67D3\u5668\u672A\u521D\u59CB\u5316");
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
__name(getRenderer, "getRenderer");
|
|
437
|
-
function createText(content) {
|
|
438
|
-
return getRenderer().createText(content);
|
|
439
|
-
}
|
|
440
|
-
__name(createText, "createText");
|
|
441
|
-
function createElement(tag) {
|
|
442
|
-
return getRenderer().createElement(tag);
|
|
443
|
-
}
|
|
444
|
-
__name(createElement, "createElement");
|
|
445
|
-
function createComment(content) {
|
|
446
|
-
return getRenderer().createComment(content);
|
|
447
|
-
}
|
|
448
|
-
__name(createComment, "createComment");
|
|
449
|
-
function insertBefore(parent, child, anchor) {
|
|
450
|
-
if (isVobsFragment(child)) {
|
|
451
|
-
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
455
|
-
markHmrInstanceMounted(child, parent);
|
|
456
|
-
}
|
|
457
|
-
__name(insertBefore, "insertBefore");
|
|
458
|
-
function removeChild(parent, child) {
|
|
459
|
-
disposeNodeOwner(child);
|
|
460
|
-
if (isVobsFragment(child)) {
|
|
461
|
-
child.unmount(parent);
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
getRenderer().removeChild(parent, child);
|
|
465
|
-
}
|
|
466
|
-
__name(removeChild, "removeChild");
|
|
467
|
-
function setTextContent(node, content) {
|
|
468
|
-
getRenderer().setTextContent(node, content);
|
|
469
|
-
}
|
|
470
|
-
__name(setTextContent, "setTextContent");
|
|
471
|
-
function setProperty(node, key, value) {
|
|
472
|
-
getRenderer().setProperty(node, key, value);
|
|
473
|
-
}
|
|
474
|
-
__name(setProperty, "setProperty");
|
|
475
|
-
function setAttribute(node, key, value) {
|
|
476
|
-
getRenderer().setAttribute(node, key, value);
|
|
477
|
-
}
|
|
478
|
-
__name(setAttribute, "setAttribute");
|
|
479
|
-
function addEventListener(node, event, handler) {
|
|
480
|
-
const renderer = getRenderer();
|
|
481
|
-
const owner = getCurrentOwner();
|
|
482
|
-
let bindings = eventBindings.get(node);
|
|
483
|
-
if (!bindings) {
|
|
484
|
-
bindings = /* @__PURE__ */ new Map();
|
|
485
|
-
eventBindings.set(node, bindings);
|
|
486
|
-
}
|
|
487
|
-
const previous = bindings.get(event);
|
|
488
|
-
if (previous && previous.original === handler && previous.owner === owner) return;
|
|
489
|
-
if (previous) renderer.removeEventListener(node, event, previous.handler);
|
|
490
|
-
const listener = owner ? (reason) => {
|
|
491
|
-
try {
|
|
492
|
-
owner.run(() => handler(reason));
|
|
493
|
-
} catch (error) {
|
|
494
|
-
const handled = owner.handleError(error);
|
|
495
|
-
invokeRuntimeDebug("error", {
|
|
496
|
-
error,
|
|
497
|
-
owner,
|
|
498
|
-
phase: "event",
|
|
499
|
-
handled,
|
|
500
|
-
recovery: handled ? "handled" : "propagated"
|
|
501
|
-
});
|
|
502
|
-
if (!handled) throw error;
|
|
503
|
-
}
|
|
504
|
-
} : handler;
|
|
505
|
-
const binding = { handler: listener, owner, original: handler };
|
|
506
|
-
bindings.set(event, binding);
|
|
507
|
-
renderer.addEventListener(node, event, listener);
|
|
508
|
-
owner?.onDispose(() => {
|
|
509
|
-
if (bindings?.get(event) !== binding) return;
|
|
510
|
-
bindings.delete(event);
|
|
511
|
-
renderer.removeEventListener(node, event, listener);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
__name(addEventListener, "addEventListener");
|
|
515
|
-
function createComponent(component, props, source) {
|
|
516
|
-
const owner = createOwner();
|
|
517
|
-
const componentName = component.displayName || component.name || "anonymous";
|
|
518
|
-
setOwnerDebugName(owner, source ? `${componentName} (${source.file}:${source.line}:${source.column})` : componentName);
|
|
519
|
-
owner.onError((reason) => {
|
|
520
|
-
attachSourceLocation(reason, source);
|
|
521
|
-
attachComponentContext(reason, componentName, owner.id);
|
|
522
|
-
throw reason;
|
|
523
|
-
});
|
|
524
|
-
let node;
|
|
525
|
-
try {
|
|
526
|
-
node = owner.run(() => component(props));
|
|
527
|
-
} catch (error) {
|
|
528
|
-
owner.dispose();
|
|
529
|
-
attachSourceLocation(error, source);
|
|
530
|
-
attachComponentContext(error, componentName, owner.id);
|
|
531
|
-
throw error;
|
|
532
|
-
}
|
|
533
|
-
associateNodeOwner(node, owner);
|
|
534
|
-
const hmrKey = component.hmrKey;
|
|
535
|
-
if (hmrKey) {
|
|
536
|
-
const instance = {
|
|
537
|
-
node,
|
|
538
|
-
parent: null,
|
|
539
|
-
refresh() {
|
|
540
|
-
const previous = instance.node;
|
|
541
|
-
const next = owner.run(() => component(props));
|
|
542
|
-
if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {
|
|
543
|
-
getRenderer().insertBefore(instance.parent, next, previous);
|
|
544
|
-
getRenderer().removeChild(instance.parent, previous);
|
|
545
|
-
}
|
|
546
|
-
nodeOwners.delete(previous);
|
|
547
|
-
nodeOwners.set(next, owner);
|
|
548
|
-
associateHmrInstance(next, instance);
|
|
549
|
-
instance.node = next;
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
associateHmrInstance(node, instance);
|
|
553
|
-
const separator = hmrKey.lastIndexOf(":");
|
|
554
|
-
const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator);
|
|
555
|
-
const cleanup = registerHmrInstance(moduleId, instance);
|
|
556
|
-
owner.onDispose(cleanup);
|
|
557
|
-
}
|
|
558
|
-
return node;
|
|
559
|
-
}
|
|
560
|
-
__name(createComponent, "createComponent");
|
|
561
|
-
function attachSourceLocation(reason, source) {
|
|
562
|
-
if (!source || (!reason || typeof reason !== "object" && typeof reason !== "function")) return;
|
|
563
|
-
const error = reason;
|
|
564
|
-
if (error.vobsSource) return;
|
|
565
|
-
try {
|
|
566
|
-
Object.defineProperty(error, "vobsSource", {
|
|
567
|
-
configurable: true,
|
|
568
|
-
enumerable: false,
|
|
569
|
-
value: source,
|
|
570
|
-
writable: false
|
|
571
|
-
});
|
|
572
|
-
} catch {
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
__name(attachSourceLocation, "attachSourceLocation");
|
|
576
|
-
function attachComponentContext(reason, component, ownerId) {
|
|
577
|
-
if (!reason || typeof reason !== "object" && typeof reason !== "function") return;
|
|
578
|
-
const error = reason;
|
|
579
|
-
try {
|
|
580
|
-
if (!error.vobsComponent) Object.defineProperty(error, "vobsComponent", { configurable: true, enumerable: false, value: component, writable: false });
|
|
581
|
-
if (!error.vobsOwnerId) Object.defineProperty(error, "vobsOwnerId", { configurable: true, enumerable: false, value: ownerId, writable: false });
|
|
582
|
-
} catch {
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
__name(attachComponentContext, "attachComponentContext");
|
|
586
|
-
function createBlock(factory) {
|
|
587
|
-
const owner = createOwner();
|
|
588
|
-
setOwnerDebugName(owner, "dynamic");
|
|
589
|
-
let node;
|
|
590
|
-
try {
|
|
591
|
-
node = owner.run(factory);
|
|
592
|
-
} catch (error) {
|
|
593
|
-
owner.dispose();
|
|
594
|
-
throw error;
|
|
595
|
-
}
|
|
596
|
-
if (!node) {
|
|
597
|
-
owner.dispose();
|
|
598
|
-
return null;
|
|
599
|
-
}
|
|
600
|
-
associateNodeOwner(node, owner);
|
|
601
|
-
return node;
|
|
602
|
-
}
|
|
603
|
-
__name(createBlock, "createBlock");
|
|
604
|
-
function associateNodeOwner(node, owner) {
|
|
605
|
-
nodeOwners.set(node, owner);
|
|
606
|
-
}
|
|
607
|
-
__name(associateNodeOwner, "associateNodeOwner");
|
|
608
|
-
function disposeNodeOwner(node) {
|
|
609
|
-
const owner = nodeOwners.get(node);
|
|
610
|
-
if (!owner) return;
|
|
611
|
-
nodeOwners.delete(node);
|
|
612
|
-
owner.dispose();
|
|
613
|
-
}
|
|
614
|
-
__name(disposeNodeOwner, "disposeNodeOwner");
|
|
615
|
-
|
|
616
|
-
// packages/runtime/src/fragment.ts
|
|
617
|
-
function createFragment(factory) {
|
|
618
|
-
const start = createComment("vobs:fragment:start");
|
|
619
|
-
const end = createComment("vobs:fragment:end");
|
|
620
|
-
let parent = null;
|
|
621
|
-
let initialized = false;
|
|
622
|
-
const owner = getCurrentOwner();
|
|
623
|
-
const fragment = {
|
|
624
|
-
kind: "vobs-fragment",
|
|
625
|
-
start,
|
|
626
|
-
end,
|
|
627
|
-
mount(nextParent, anchor) {
|
|
628
|
-
if (parent && parent !== nextParent) {
|
|
629
|
-
throw new Error("Vobs Fragment: \u4E0D\u80FD\u8DE8\u7236\u8282\u70B9\u79FB\u52A8 Fragment");
|
|
630
|
-
}
|
|
631
|
-
if (initialized) {
|
|
632
|
-
moveRange(nextParent, start, end, anchor);
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
const renderer = getRenderer();
|
|
636
|
-
renderer.insertBefore(nextParent, start, anchor);
|
|
637
|
-
renderer.insertBefore(nextParent, end, anchor);
|
|
638
|
-
parent = nextParent;
|
|
639
|
-
initialized = true;
|
|
640
|
-
if (owner) owner.run(() => factory(nextParent, end));
|
|
641
|
-
else factory(nextParent, end);
|
|
642
|
-
},
|
|
643
|
-
unmount(nextParent) {
|
|
644
|
-
if (!initialized || parent !== nextParent) {
|
|
645
|
-
throw new Error("Vobs Fragment: Fragment \u4E0D\u5C5E\u4E8E\u6307\u5B9A\u7236\u8282\u70B9");
|
|
646
|
-
}
|
|
647
|
-
const renderer = getRenderer();
|
|
648
|
-
let current = renderer.nextSibling(start);
|
|
649
|
-
while (current && current !== end) {
|
|
650
|
-
const next = renderer.nextSibling(current);
|
|
651
|
-
renderer.removeChild(nextParent, current);
|
|
652
|
-
current = next;
|
|
653
|
-
}
|
|
654
|
-
renderer.removeChild(nextParent, start);
|
|
655
|
-
renderer.removeChild(nextParent, end);
|
|
656
|
-
parent = null;
|
|
657
|
-
initialized = false;
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
return fragment;
|
|
661
|
-
}
|
|
662
|
-
__name(createFragment, "createFragment");
|
|
663
|
-
function isVobsFragment(value) {
|
|
664
|
-
return Boolean(value) && typeof value === "object" && value.kind === "vobs-fragment";
|
|
665
|
-
}
|
|
666
|
-
__name(isVobsFragment, "isVobsFragment");
|
|
667
|
-
function moveRange(parent, start, end, anchor) {
|
|
668
|
-
const renderer = getRenderer();
|
|
669
|
-
const nodes = [start];
|
|
670
|
-
let current = renderer.nextSibling(start);
|
|
671
|
-
while (current) {
|
|
672
|
-
nodes.push(current);
|
|
673
|
-
if (current === end) break;
|
|
674
|
-
current = renderer.nextSibling(current);
|
|
675
|
-
}
|
|
676
|
-
if (nodes[nodes.length - 1] !== end) {
|
|
677
|
-
throw new Error("Vobs Fragment: \u627E\u4E0D\u5230\u7ED3\u675F\u951A\u70B9");
|
|
678
|
-
}
|
|
679
|
-
for (const node of nodes) renderer.insertBefore(parent, node, anchor);
|
|
680
|
-
}
|
|
681
|
-
__name(moveRange, "moveRange");
|
|
682
|
-
|
|
683
|
-
// packages/runtime/src/dynamic.ts
|
|
684
|
-
function insertDynamic(parent, anchor, factory) {
|
|
685
|
-
const marker = createComment("vobs:dynamic");
|
|
686
|
-
insertBefore(parent, marker, anchor);
|
|
687
|
-
let current = null;
|
|
688
|
-
effect(() => {
|
|
689
|
-
const next = createBlock(factory);
|
|
690
|
-
if (next === current) return;
|
|
691
|
-
if (current) removeChild(parent, current);
|
|
692
|
-
current = next;
|
|
693
|
-
if (current) insertBefore(parent, current, marker);
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
__name(insertDynamic, "insertDynamic");
|
|
697
|
-
|
|
698
|
-
// packages/vobs/src/context.ts
|
|
699
|
-
var ownerProviders = /* @__PURE__ */ new WeakMap();
|
|
700
|
-
function inject(key, fallback) {
|
|
701
|
-
const owner = getCurrentOwner();
|
|
702
|
-
const value = owner ? injectFromOwner(owner, key) : void 0;
|
|
703
|
-
return value === void 0 ? fallback : value;
|
|
704
|
-
}
|
|
705
|
-
__name(inject, "inject");
|
|
706
|
-
function injectFromOwner(owner, key) {
|
|
707
|
-
let current = owner;
|
|
708
|
-
while (current) {
|
|
709
|
-
const providers = ownerProviders.get(current);
|
|
710
|
-
if (providers?.has(key)) return providers.get(key);
|
|
711
|
-
current = current.parent;
|
|
712
|
-
}
|
|
713
|
-
return void 0;
|
|
714
|
-
}
|
|
715
|
-
__name(injectFromOwner, "injectFromOwner");
|
|
716
|
-
|
|
717
|
-
// packages/vobs/src/app.ts
|
|
718
|
-
function createInjectionKey(description) {
|
|
719
|
-
return Symbol(description);
|
|
720
|
-
}
|
|
721
|
-
__name(createInjectionKey, "createInjectionKey");
|
|
722
|
-
var HTTP_KEY = createInjectionKey("vobs.http");
|
|
723
|
-
var activeDevTools = null;
|
|
724
|
-
function getDevTools() {
|
|
725
|
-
return activeDevTools;
|
|
726
|
-
}
|
|
727
|
-
__name(getDevTools, "getDevTools");
|
|
728
|
-
|
|
729
|
-
// packages/ui/src/utils.ts
|
|
730
|
-
function classNames(...values) {
|
|
731
|
-
return values.flatMap((value) => typeof value === "string" ? value.trim().split(/\s+/u) : []).filter(Boolean).join(" ");
|
|
732
|
-
}
|
|
733
|
-
__name(classNames, "classNames");
|
|
734
|
-
function readProp(props, name, fallback) {
|
|
735
|
-
const value = Reflect.get(props, name);
|
|
736
|
-
return value === void 0 ? fallback : value;
|
|
737
|
-
}
|
|
738
|
-
__name(readProp, "readProp");
|
|
739
|
-
function hasProp(props, name) {
|
|
740
|
-
return name in props;
|
|
741
|
-
}
|
|
742
|
-
__name(hasProp, "hasProp");
|
|
743
|
-
function bindClassList(root, props, readBaseClasses) {
|
|
744
|
-
effect(() => {
|
|
745
|
-
setAttribute(root, "class", classNames(
|
|
746
|
-
...readBaseClasses(),
|
|
747
|
-
readString(props, "class"),
|
|
748
|
-
readString(props, "className")
|
|
749
|
-
));
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
__name(bindClassList, "bindClassList");
|
|
753
|
-
function bindCommonAttributes(root, props, skip = [], options = {}) {
|
|
754
|
-
const ignored = new Set(skip);
|
|
755
|
-
ignored.add("class");
|
|
756
|
-
ignored.add("className");
|
|
757
|
-
ignored.add("children");
|
|
758
|
-
ignored.add("style");
|
|
759
|
-
effect(() => {
|
|
760
|
-
const next = /* @__PURE__ */ new Map();
|
|
761
|
-
for (const name of Object.keys(props)) {
|
|
762
|
-
if (ignored.has(name) || name.startsWith("on")) continue;
|
|
763
|
-
if (!isCommonAttribute(name)) continue;
|
|
764
|
-
if (options.includeDataAria === false && (name.startsWith("aria-") || name.startsWith("data-"))) continue;
|
|
765
|
-
const value = Reflect.get(props, name);
|
|
766
|
-
const normalized = normalizeAttribute(name, value);
|
|
767
|
-
if (normalized !== void 0) next.set(normalized.name, normalized.value);
|
|
768
|
-
}
|
|
769
|
-
const managed = getManagedAttributes(root);
|
|
770
|
-
for (const name of managed) {
|
|
771
|
-
if (!next.has(name)) removeAttribute(root, name);
|
|
772
|
-
}
|
|
773
|
-
for (const [name, value] of next) setAttribute(root, name, value);
|
|
774
|
-
setManagedAttributes(root, next.keys());
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
__name(bindCommonAttributes, "bindCommonAttributes");
|
|
778
|
-
function bindUserStyle(root, props) {
|
|
779
|
-
bindStyle(root, props, () => "");
|
|
780
|
-
}
|
|
781
|
-
__name(bindUserStyle, "bindUserStyle");
|
|
782
|
-
function bindStyle(root, props, createStyle) {
|
|
783
|
-
effect(() => {
|
|
784
|
-
const userStyle = readString(props, "style");
|
|
785
|
-
const internalStyle = createStyle();
|
|
786
|
-
const style = [internalStyle, userStyle].filter(Boolean).join("; ");
|
|
787
|
-
if (style) setAttribute(root, "style", style);
|
|
788
|
-
else removeAttribute(root, "style");
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
__name(bindStyle, "bindStyle");
|
|
792
|
-
function bindTextContent(node, read) {
|
|
793
|
-
effect(() => {
|
|
794
|
-
setTextContent(node, String(read() ?? ""));
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
__name(bindTextContent, "bindTextContent");
|
|
798
|
-
function bindPropertyValue(node, name, read) {
|
|
799
|
-
effect(() => setProperty(node, name, read()));
|
|
800
|
-
}
|
|
801
|
-
__name(bindPropertyValue, "bindPropertyValue");
|
|
802
|
-
function listen(root, event, props, propName, disabled) {
|
|
803
|
-
addEventListener(root, event, (reason) => {
|
|
804
|
-
if (disabled?.()) return;
|
|
805
|
-
const handler = Reflect.get(props, propName);
|
|
806
|
-
if (typeof handler === "function") handler(reason);
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
__name(listen, "listen");
|
|
810
|
-
function mountSlot(parent, props, propName) {
|
|
811
|
-
insertDynamic(parent, null, () => resolveSlot(Reflect.get(props, propName)));
|
|
812
|
-
}
|
|
813
|
-
__name(mountSlot, "mountSlot");
|
|
814
|
-
function resolveSlot(value) {
|
|
815
|
-
const resolved = typeof value === "function" ? value() : value;
|
|
816
|
-
if (resolved === void 0 || resolved === null || resolved === false) return null;
|
|
817
|
-
if (typeof resolved === "string" || typeof resolved === "number") return createText(String(resolved));
|
|
818
|
-
if (Array.isArray(resolved)) {
|
|
819
|
-
const children = resolved;
|
|
820
|
-
return createFragment((parent, anchor) => {
|
|
821
|
-
for (const child of children) {
|
|
822
|
-
const node = resolveSlot(child);
|
|
823
|
-
if (node) insertBefore(parent, node, anchor);
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
return resolved;
|
|
828
|
-
}
|
|
829
|
-
__name(resolveSlot, "resolveSlot");
|
|
830
|
-
function setOptionalAttribute(node, name, value) {
|
|
831
|
-
if (value === void 0 || value === null || value === false || value === "") {
|
|
832
|
-
removeAttribute(node, name);
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
setAttribute(node, name, String(value));
|
|
836
|
-
}
|
|
837
|
-
__name(setOptionalAttribute, "setOptionalAttribute");
|
|
838
|
-
function setOptionalProperty(node, name, value) {
|
|
839
|
-
if (value === void 0 || value === null) return;
|
|
840
|
-
setProperty(node, name, value);
|
|
841
|
-
}
|
|
842
|
-
__name(setOptionalProperty, "setOptionalProperty");
|
|
843
|
-
function readString(props, name) {
|
|
844
|
-
const value = Reflect.get(props, name);
|
|
845
|
-
return typeof value === "string" ? value : void 0;
|
|
846
|
-
}
|
|
847
|
-
__name(readString, "readString");
|
|
848
|
-
function isCommonAttribute(name) {
|
|
849
|
-
return name === "id" || name === "title" || name === "role" || name === "tabIndex" || name.startsWith("aria-") || name.startsWith("data-");
|
|
850
|
-
}
|
|
851
|
-
__name(isCommonAttribute, "isCommonAttribute");
|
|
852
|
-
function normalizeAttribute(name, value) {
|
|
853
|
-
if (value === void 0 || value === null) return void 0;
|
|
854
|
-
if (value === false && !name.startsWith("aria-") && !name.startsWith("data-")) return void 0;
|
|
855
|
-
return { name: name === "tabIndex" ? "tabindex" : name, value: String(value) };
|
|
856
|
-
}
|
|
857
|
-
__name(normalizeAttribute, "normalizeAttribute");
|
|
858
|
-
var managedAttributes = /* @__PURE__ */ new WeakMap();
|
|
859
|
-
function getManagedAttributes(node) {
|
|
860
|
-
return managedAttributes.get(node) ?? /* @__PURE__ */ new Set();
|
|
861
|
-
}
|
|
862
|
-
__name(getManagedAttributes, "getManagedAttributes");
|
|
863
|
-
function setManagedAttributes(node, names) {
|
|
864
|
-
managedAttributes.set(node, new Set(names));
|
|
865
|
-
}
|
|
866
|
-
__name(setManagedAttributes, "setManagedAttributes");
|
|
867
|
-
function removeAttribute(node, name) {
|
|
868
|
-
const candidate = node;
|
|
869
|
-
candidate.removeAttribute?.(name);
|
|
870
|
-
}
|
|
871
|
-
__name(removeAttribute, "removeAttribute");
|
|
872
|
-
|
|
873
|
-
// packages/ui/src/button.ts
|
|
874
|
-
function Button(props = {}) {
|
|
875
|
-
const root = createElement("button");
|
|
876
|
-
bindClassList(root, props, () => [
|
|
877
|
-
"vui-btn",
|
|
878
|
-
`vui-btn--${readProp(props, "variant", "primary")}`,
|
|
879
|
-
`vui-btn--${readProp(props, "size", "md")}`,
|
|
880
|
-
readProp(props, "iconOnly", false) ? "vui-btn--icon" : void 0
|
|
881
|
-
]);
|
|
882
|
-
bindCommonAttributes(root, props, [
|
|
883
|
-
"variant",
|
|
884
|
-
"size",
|
|
885
|
-
"type",
|
|
886
|
-
"disabled",
|
|
887
|
-
"loading",
|
|
888
|
-
"iconOnly",
|
|
889
|
-
"icon",
|
|
890
|
-
"onClick"
|
|
891
|
-
]);
|
|
892
|
-
effect(() => {
|
|
893
|
-
const disabled = readProp(props, "disabled", false) || readProp(props, "loading", false);
|
|
894
|
-
setOptionalProperty(root, "disabled", disabled);
|
|
895
|
-
setOptionalAttribute(root, "type", readProp(props, "type", "button"));
|
|
896
|
-
setOptionalAttribute(root, "aria-disabled", disabled ? "true" : void 0);
|
|
897
|
-
setOptionalAttribute(root, "aria-busy", readProp(props, "loading", false) ? "true" : void 0);
|
|
898
|
-
});
|
|
899
|
-
listen(root, "click", props, "onClick", () => readProp(props, "disabled", false) || readProp(props, "loading", false));
|
|
900
|
-
if (hasProp(props, "icon")) mountSlot(root, props, "icon");
|
|
901
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
902
|
-
return root;
|
|
903
|
-
}
|
|
904
|
-
__name(Button, "Button");
|
|
905
|
-
|
|
906
|
-
// packages/ui/src/forms.ts
|
|
907
|
-
function bindSignalProp(props) {
|
|
908
|
-
const value = readProp(props, "bind", void 0);
|
|
909
|
-
return value && typeof value === "object" && "value" in value ? value : void 0;
|
|
910
|
-
}
|
|
911
|
-
__name(bindSignalProp, "bindSignalProp");
|
|
912
|
-
function Select(props = {}) {
|
|
913
|
-
const root = createElement("select");
|
|
914
|
-
bindClassList(root, props, () => ["vui-select"]);
|
|
915
|
-
bindCommonAttributes(root, props, [
|
|
916
|
-
"name",
|
|
917
|
-
"value",
|
|
918
|
-
"disabled",
|
|
919
|
-
"required",
|
|
920
|
-
"multiple",
|
|
921
|
-
"size",
|
|
922
|
-
"onChange"
|
|
923
|
-
]);
|
|
924
|
-
effect(() => {
|
|
925
|
-
setOptionalAttribute(root, "name", readProp(props, "name", void 0));
|
|
926
|
-
setOptionalProperty(root, "disabled", readProp(props, "disabled", false));
|
|
927
|
-
setOptionalProperty(root, "required", readProp(props, "required", false));
|
|
928
|
-
setOptionalProperty(root, "multiple", readProp(props, "multiple", false));
|
|
929
|
-
setOptionalAttribute(root, "size", readProp(props, "size", void 0));
|
|
930
|
-
});
|
|
931
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
932
|
-
const bind = bindSignalProp(props);
|
|
933
|
-
if (bind) {
|
|
934
|
-
bindPropertyValue(root, "value", () => String(bind.value ?? ""));
|
|
935
|
-
listen(root, "change", { onChange: /* @__PURE__ */ __name((event) => {
|
|
936
|
-
bind.value = event.target.value;
|
|
937
|
-
}, "onChange") }, "onChange", () => readProp(props, "disabled", false));
|
|
938
|
-
} else if (hasProp(props, "value")) {
|
|
939
|
-
bindPropertyValue(root, "value", () => readProp(props, "value", void 0) ?? "");
|
|
940
|
-
}
|
|
941
|
-
listen(root, "change", props, "onChange", () => readProp(props, "disabled", false));
|
|
942
|
-
return root;
|
|
943
|
-
}
|
|
944
|
-
__name(Select, "Select");
|
|
945
|
-
|
|
946
|
-
// packages/ui/src/card.ts
|
|
947
|
-
function Card(props = {}) {
|
|
948
|
-
const root = createElement("div");
|
|
949
|
-
bindClassList(root, props, () => ["vui-card"]);
|
|
950
|
-
bindCommonAttributes(root, props, ["title", "description"]);
|
|
951
|
-
bindUserStyle(root, props);
|
|
952
|
-
if (hasProp(props, "title")) {
|
|
953
|
-
const title = createElement("div");
|
|
954
|
-
const text = createText("");
|
|
955
|
-
setAttribute(title, "class", "vui-card__title");
|
|
956
|
-
bindTextContent(text, () => readProp(props, "title", ""));
|
|
957
|
-
insertBefore(title, text, null);
|
|
958
|
-
insertBefore(root, title, null);
|
|
959
|
-
}
|
|
960
|
-
if (hasProp(props, "description")) {
|
|
961
|
-
const description = createElement("p");
|
|
962
|
-
const text = createText("");
|
|
963
|
-
setAttribute(description, "class", "vui-card__desc");
|
|
964
|
-
bindTextContent(text, () => readProp(props, "description", ""));
|
|
965
|
-
insertBefore(description, text, null);
|
|
966
|
-
insertBefore(root, description, null);
|
|
967
|
-
}
|
|
968
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
969
|
-
return root;
|
|
970
|
-
}
|
|
971
|
-
__name(Card, "Card");
|
|
972
|
-
|
|
973
|
-
// packages/ui/src/tag.ts
|
|
974
|
-
function Tag(props = {}) {
|
|
975
|
-
const root = createElement("span");
|
|
976
|
-
bindClassList(root, props, () => [
|
|
977
|
-
"vui-tag",
|
|
978
|
-
readProp(props, "tone", "default") === "default" ? void 0 : `vui-tag--${readProp(props, "tone", "default")}`
|
|
979
|
-
]);
|
|
980
|
-
bindCommonAttributes(root, props, ["tone"]);
|
|
981
|
-
bindUserStyle(root, props);
|
|
982
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
983
|
-
return root;
|
|
984
|
-
}
|
|
985
|
-
__name(Tag, "Tag");
|
|
986
|
-
|
|
987
|
-
// packages/ui/src/alert.ts
|
|
988
|
-
function Alert(props = {}) {
|
|
989
|
-
const root = createElement("div");
|
|
990
|
-
bindClassList(root, props, () => [
|
|
991
|
-
"vui-alert",
|
|
992
|
-
`vui-alert--${readProp(props, "tone", "info")}`
|
|
993
|
-
]);
|
|
994
|
-
bindCommonAttributes(root, props, ["tone", "title", "description", "icon", "role"]);
|
|
995
|
-
bindUserStyle(root, props);
|
|
996
|
-
setAttribute(root, "role", "alert");
|
|
997
|
-
if (hasProp(props, "icon")) {
|
|
998
|
-
const icon = createElement("span");
|
|
999
|
-
setAttribute(icon, "class", "vui-alert__icon");
|
|
1000
|
-
mountSlot(icon, props, "icon");
|
|
1001
|
-
insertBefore(root, icon, null);
|
|
1002
|
-
}
|
|
1003
|
-
const content = createElement("div");
|
|
1004
|
-
if (hasProp(props, "title")) {
|
|
1005
|
-
const title = createElement("div");
|
|
1006
|
-
const text = createText("");
|
|
1007
|
-
setAttribute(title, "class", "vui-alert__title");
|
|
1008
|
-
bindTextContent(text, () => readProp(props, "title", ""));
|
|
1009
|
-
insertBefore(title, text, null);
|
|
1010
|
-
insertBefore(content, title, null);
|
|
1011
|
-
}
|
|
1012
|
-
if (hasProp(props, "description")) {
|
|
1013
|
-
const description = createElement("div");
|
|
1014
|
-
const text = createText("");
|
|
1015
|
-
setAttribute(description, "class", "vui-alert__desc");
|
|
1016
|
-
bindTextContent(text, () => readProp(props, "description", ""));
|
|
1017
|
-
insertBefore(description, text, null);
|
|
1018
|
-
insertBefore(content, description, null);
|
|
1019
|
-
}
|
|
1020
|
-
if (hasProp(props, "children")) mountSlot(content, props, "children");
|
|
1021
|
-
insertBefore(root, content, null);
|
|
1022
|
-
return root;
|
|
1023
|
-
}
|
|
1024
|
-
__name(Alert, "Alert");
|
|
1025
|
-
|
|
1026
|
-
// packages/ui/src/tabs.ts
|
|
1027
|
-
function Tabs(props) {
|
|
1028
|
-
const root = createElement("div");
|
|
1029
|
-
const tablist = createElement("div");
|
|
1030
|
-
const panel = createElement("div");
|
|
1031
|
-
const internalValue = state(void 0);
|
|
1032
|
-
bindClassList(root, props, () => ["vui-tabs-root"]);
|
|
1033
|
-
bindCommonAttributes(root, props, ["items", "value", "variant", "onChange"]);
|
|
1034
|
-
setAttribute(tablist, "role", "tablist");
|
|
1035
|
-
effect(() => {
|
|
1036
|
-
const variant = readProp(props, "variant", "default");
|
|
1037
|
-
setAttribute(tablist, "class", `vui-tabs${variant === "filled" ? " vui-tabs--filled" : ""}`);
|
|
1038
|
-
});
|
|
1039
|
-
setAttribute(panel, "class", "vui-tabs__panel");
|
|
1040
|
-
insertDynamic(tablist, null, () => createTabButtons(props, internalValue));
|
|
1041
|
-
insertDynamic(panel, null, () => {
|
|
1042
|
-
const item = activeItem(readProp(props, "items", []), activeId(props, internalValue));
|
|
1043
|
-
return item?.content === void 0 ? null : resolveSlot(item.content);
|
|
1044
|
-
});
|
|
1045
|
-
insertBefore(root, tablist, null);
|
|
1046
|
-
insertBefore(root, panel, null);
|
|
1047
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
1048
|
-
return root;
|
|
1049
|
-
}
|
|
1050
|
-
__name(Tabs, "Tabs");
|
|
1051
|
-
function createTabButtons(props, internalValue) {
|
|
1052
|
-
const items = readProp(props, "items", []);
|
|
1053
|
-
const selected = activeId(props, internalValue);
|
|
1054
|
-
return createFragment((parent, anchor) => {
|
|
1055
|
-
for (const item of items) {
|
|
1056
|
-
const button = createElement("button");
|
|
1057
|
-
const isActive = item.id === selected;
|
|
1058
|
-
setAttribute(button, "class", `vui-tab${isActive ? " is-active" : ""}`);
|
|
1059
|
-
setAttribute(button, "role", "tab");
|
|
1060
|
-
setAttribute(button, "type", "button");
|
|
1061
|
-
setAttribute(button, "aria-selected", isActive ? "true" : "false");
|
|
1062
|
-
setAttribute(button, "data-tab-id", item.id);
|
|
1063
|
-
if (item.disabled === true) {
|
|
1064
|
-
setAttribute(button, "aria-disabled", "true");
|
|
1065
|
-
setProperty(button, "disabled", true);
|
|
1066
|
-
}
|
|
1067
|
-
insertBefore(button, createText(item.label), null);
|
|
1068
|
-
addEventListener(button, "click", () => {
|
|
1069
|
-
if (item.disabled === true) return;
|
|
1070
|
-
if (readProp(props, "value", void 0) === void 0) internalValue.value = item.id;
|
|
1071
|
-
const onChange = readProp(props, "onChange", void 0);
|
|
1072
|
-
if (typeof onChange === "function") onChange(item.id);
|
|
1073
|
-
});
|
|
1074
|
-
insertBefore(parent, button, anchor);
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
__name(createTabButtons, "createTabButtons");
|
|
1079
|
-
function activeId(props, internalValue) {
|
|
1080
|
-
const controlled = readProp(props, "value", void 0);
|
|
1081
|
-
if (controlled !== void 0) return controlled;
|
|
1082
|
-
if (internalValue.value !== void 0) return internalValue.value;
|
|
1083
|
-
return readProp(props, "items", []).find((item) => item.disabled !== true)?.id;
|
|
1084
|
-
}
|
|
1085
|
-
__name(activeId, "activeId");
|
|
1086
|
-
function activeItem(items, id) {
|
|
1087
|
-
return items.find((item) => item.id === id);
|
|
1088
|
-
}
|
|
1089
|
-
__name(activeItem, "activeItem");
|
|
1090
|
-
|
|
1091
|
-
// packages/ui/src/overlay.ts
|
|
1092
|
-
function createPortal(node, adapter, target) {
|
|
1093
|
-
const placeholder = createComment("vui:portal");
|
|
1094
|
-
const owner = getCurrentOwner();
|
|
1095
|
-
if (!owner) throw new Error("Vobs UI: createPortal \u5FC5\u987B\u5728\u7EC4\u4EF6 Owner \u4F5C\u7528\u57DF\u5185\u8C03\u7528");
|
|
1096
|
-
adapter.mount(node, target);
|
|
1097
|
-
const cleanup = /* @__PURE__ */ __name(() => adapter.unmount(node, target), "cleanup");
|
|
1098
|
-
owner.onDispose(cleanup);
|
|
1099
|
-
return placeholder;
|
|
1100
|
-
}
|
|
1101
|
-
__name(createPortal, "createPortal");
|
|
1102
|
-
|
|
1103
|
-
// packages/ui/src/dialog.ts
|
|
1104
|
-
function Dialog(props = {}) {
|
|
1105
|
-
const root = createElement("div");
|
|
1106
|
-
const surface = createElement("section");
|
|
1107
|
-
const body = createElement("div");
|
|
1108
|
-
bindClassList(root, props, () => ["vui-backdrop"]);
|
|
1109
|
-
bindUserStyle(root, props);
|
|
1110
|
-
bindCommonAttributes(surface, props, [
|
|
1111
|
-
"open",
|
|
1112
|
-
"title",
|
|
1113
|
-
"headerActions",
|
|
1114
|
-
"size",
|
|
1115
|
-
"modal",
|
|
1116
|
-
"closeOnBackdrop",
|
|
1117
|
-
"closeOnEscape",
|
|
1118
|
-
"titleId",
|
|
1119
|
-
"descriptionId",
|
|
1120
|
-
"closeLabel",
|
|
1121
|
-
"onClose",
|
|
1122
|
-
"portal",
|
|
1123
|
-
"portalTarget"
|
|
1124
|
-
]);
|
|
1125
|
-
setAttribute(root, "role", "presentation");
|
|
1126
|
-
setAttribute(surface, "class", "vui-dialog");
|
|
1127
|
-
setAttribute(surface, "role", "dialog");
|
|
1128
|
-
setAttribute(body, "class", "vui-dialog__body");
|
|
1129
|
-
effect(() => {
|
|
1130
|
-
const open = readProp(props, "open", false);
|
|
1131
|
-
const modal = readProp(props, "modal", true);
|
|
1132
|
-
setOptionalProperty(root, "hidden", !open);
|
|
1133
|
-
setOptionalAttribute(root, "data-state", open ? "open" : "closed");
|
|
1134
|
-
setOptionalAttribute(surface, "aria-modal", modal ? "true" : "false");
|
|
1135
|
-
setOptionalAttribute(surface, "aria-labelledby", readProp(props, "titleId", void 0));
|
|
1136
|
-
setOptionalAttribute(surface, "aria-describedby", readProp(props, "descriptionId", void 0));
|
|
1137
|
-
setOptionalAttribute(surface, "data-size", readProp(props, "size", "md"));
|
|
1138
|
-
});
|
|
1139
|
-
if (hasProp(props, "title") || hasProp(props, "headerActions") || hasProp(props, "onClose")) {
|
|
1140
|
-
const head = createElement("header");
|
|
1141
|
-
setAttribute(head, "class", "vui-dialog__head");
|
|
1142
|
-
if (hasProp(props, "title")) {
|
|
1143
|
-
const title = createElement("div");
|
|
1144
|
-
const text = createText("");
|
|
1145
|
-
setAttribute(title, "class", "vui-dialog__title");
|
|
1146
|
-
bindTextContent(text, () => readProp(props, "title", ""));
|
|
1147
|
-
insertBefore(title, text, null);
|
|
1148
|
-
insertBefore(head, title, null);
|
|
1149
|
-
}
|
|
1150
|
-
if (hasProp(props, "headerActions")) mountSlot(head, props, "headerActions");
|
|
1151
|
-
if (hasProp(props, "onClose")) {
|
|
1152
|
-
const close = createElement("button");
|
|
1153
|
-
setAttribute(close, "class", "vui-dialog__close");
|
|
1154
|
-
setAttribute(close, "type", "button");
|
|
1155
|
-
setAttribute(close, "aria-label", readProp(props, "closeLabel", "Close"));
|
|
1156
|
-
insertBefore(close, createText("x"), null);
|
|
1157
|
-
addEventListener(close, "click", () => emitClose(props, "close-button"));
|
|
1158
|
-
insertBefore(head, close, null);
|
|
1159
|
-
}
|
|
1160
|
-
insertBefore(surface, head, null);
|
|
1161
|
-
}
|
|
1162
|
-
if (hasProp(props, "children")) mountSlot(body, props, "children");
|
|
1163
|
-
insertBefore(surface, body, null);
|
|
1164
|
-
insertBefore(root, surface, null);
|
|
1165
|
-
addEventListener(root, "click", (event) => {
|
|
1166
|
-
if (event.target !== root) return;
|
|
1167
|
-
if (readProp(props, "closeOnBackdrop", true)) emitClose(props, "backdrop");
|
|
1168
|
-
});
|
|
1169
|
-
addEventListener(root, "keydown", (event) => {
|
|
1170
|
-
if (event.key !== "Escape") return;
|
|
1171
|
-
if (readProp(props, "closeOnEscape", true)) emitClose(props, "escape");
|
|
1172
|
-
});
|
|
1173
|
-
const portal = readProp(props, "portal", void 0);
|
|
1174
|
-
return portal ? createPortal(root, portal, readProp(props, "portalTarget", void 0)) : root;
|
|
1175
|
-
}
|
|
1176
|
-
__name(Dialog, "Dialog");
|
|
1177
|
-
function emitClose(props, reason) {
|
|
1178
|
-
if (!readProp(props, "open", false)) return;
|
|
1179
|
-
const handler = readProp(props, "onClose", void 0);
|
|
1180
|
-
if (typeof handler === "function") handler(reason);
|
|
1181
|
-
}
|
|
1182
|
-
__name(emitClose, "emitClose");
|
|
1183
|
-
|
|
1184
|
-
// packages/icon-core/src/index.ts
|
|
1185
|
-
function createSvgIconNode(source, props = {}, options = {}) {
|
|
1186
|
-
const root = createElement("span");
|
|
1187
|
-
effect(() => {
|
|
1188
|
-
updateSvgIconNode(root, typeof source === "function" ? source() : source, props, options);
|
|
1189
|
-
});
|
|
1190
|
-
return root;
|
|
1191
|
-
}
|
|
1192
|
-
__name(createSvgIconNode, "createSvgIconNode");
|
|
1193
|
-
function updateSvgIconNode(root, definition, props, options) {
|
|
1194
|
-
const size = readProp2(props, "size", void 0);
|
|
1195
|
-
const width = readProp2(props, "width", size);
|
|
1196
|
-
const height = readProp2(props, "height", size);
|
|
1197
|
-
const normalizedWidth = normalizeSvgLength(width);
|
|
1198
|
-
const normalizedHeight = normalizeSvgLength(height);
|
|
1199
|
-
const userClass = [
|
|
1200
|
-
readProp2(props, "class", void 0),
|
|
1201
|
-
readProp2(props, "className", void 0)
|
|
1202
|
-
].filter(hasText).join(" ");
|
|
1203
|
-
const className = [options.class, options.className, userClass].filter(hasText).join(" ");
|
|
1204
|
-
setAttribute(root, "class", className);
|
|
1205
|
-
const internalStyle = size === void 0 ? "" : `width: ${normalizeCssLength(size)}; height: ${normalizeCssLength(size)}`;
|
|
1206
|
-
const userStyle = readProp2(props, "style", void 0);
|
|
1207
|
-
const style = [internalStyle, userStyle].filter(hasText).join("; ");
|
|
1208
|
-
setOptionalAttribute2(root, "style", style || void 0);
|
|
1209
|
-
const managedAttributes2 = /* @__PURE__ */ new Map();
|
|
1210
|
-
for (const name of Object.keys(props)) {
|
|
1211
|
-
if (name === "class" || name === "className" || name === "style" || name === "children") continue;
|
|
1212
|
-
if (!name.startsWith("aria-") && !name.startsWith("data-") && !["id", "title", "role", "tabIndex"].includes(name)) continue;
|
|
1213
|
-
const value = Reflect.get(props, name);
|
|
1214
|
-
if (value === void 0 || value === null || value === false) continue;
|
|
1215
|
-
managedAttributes2.set(name === "tabIndex" ? "tabindex" : name, String(value));
|
|
1216
|
-
}
|
|
1217
|
-
for (const [name, value] of managedAttributes2) setAttribute(root, name, value);
|
|
1218
|
-
clearStaleAttributes(root, managedAttributes2);
|
|
1219
|
-
const title = readProp2(props, "title", void 0);
|
|
1220
|
-
const ariaLabel = Reflect.get(props, "aria-label");
|
|
1221
|
-
const decorative = readProp2(props, "decorative", title === void 0 && ariaLabel === void 0);
|
|
1222
|
-
setOptionalAttribute2(root, "aria-hidden", decorative ? "true" : void 0);
|
|
1223
|
-
setOptionalAttribute2(root, "aria-label", ariaLabel === void 0 ? title : void 0);
|
|
1224
|
-
setOptionalAttribute2(root, "data-icon-name", options.dataIconName ?? definition?.name);
|
|
1225
|
-
setOptionalAttribute2(root, "color", readProp2(props, "color", void 0));
|
|
1226
|
-
if (!definition) {
|
|
1227
|
-
setProperty(root, "innerHTML", "");
|
|
1228
|
-
return;
|
|
1229
|
-
}
|
|
1230
|
-
const svgAttributes = {
|
|
1231
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1232
|
-
viewBox: definition.viewBox ?? "0 0 24 24",
|
|
1233
|
-
...options.defaultSvgAttributes,
|
|
1234
|
-
...definition.attributes,
|
|
1235
|
-
...normalizedWidth === void 0 ? {} : { width: normalizedWidth },
|
|
1236
|
-
...normalizedHeight === void 0 ? {} : { height: normalizedHeight },
|
|
1237
|
-
...readProp2(props, "color", void 0) === void 0 ? {} : { color: readProp2(props, "color", void 0) },
|
|
1238
|
-
...readProp2(props, "stroke", void 0) === void 0 ? {} : { stroke: readProp2(props, "stroke", void 0) },
|
|
1239
|
-
...readProp2(props, "fill", void 0) === void 0 ? {} : { fill: readProp2(props, "fill", void 0) },
|
|
1240
|
-
...readProp2(props, "strokeWidth", void 0) === void 0 ? {} : { "stroke-width": readProp2(props, "strokeWidth", void 0) }
|
|
1241
|
-
};
|
|
1242
|
-
const markup = Object.entries(svgAttributes).filter(([, value]) => value !== void 0).map(([name, value]) => `${name}="${escapeXml(String(value))}"`).join(" ");
|
|
1243
|
-
const titleMarkup = title === void 0 ? "" : `<title>${escapeXml(title)}</title>`;
|
|
1244
|
-
setProperty(root, "innerHTML", `<svg ${markup} aria-hidden="true">${titleMarkup}${definition.body}</svg>`);
|
|
1245
|
-
}
|
|
1246
|
-
__name(updateSvgIconNode, "updateSvgIconNode");
|
|
1247
|
-
function readProp2(props, name, fallback) {
|
|
1248
|
-
const value = Reflect.get(props, name);
|
|
1249
|
-
return value === void 0 ? fallback : value;
|
|
1250
|
-
}
|
|
1251
|
-
__name(readProp2, "readProp");
|
|
1252
|
-
function hasText(value) {
|
|
1253
|
-
return value !== void 0 && value.trim() !== "";
|
|
1254
|
-
}
|
|
1255
|
-
__name(hasText, "hasText");
|
|
1256
|
-
function normalizeSvgLength(value) {
|
|
1257
|
-
if (value === void 0) return void 0;
|
|
1258
|
-
return typeof value === "number" ? String(value) : value;
|
|
1259
|
-
}
|
|
1260
|
-
__name(normalizeSvgLength, "normalizeSvgLength");
|
|
1261
|
-
function normalizeCssLength(value) {
|
|
1262
|
-
return typeof value === "number" || /^\d+(?:\.\d+)?$/u.test(value) ? `${value}px` : value;
|
|
1263
|
-
}
|
|
1264
|
-
__name(normalizeCssLength, "normalizeCssLength");
|
|
1265
|
-
function setOptionalAttribute2(node, name, value) {
|
|
1266
|
-
if (value === void 0 || value === null || value === false || value === "") {
|
|
1267
|
-
node.removeAttribute(name);
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
setAttribute(node, name, String(value));
|
|
1271
|
-
}
|
|
1272
|
-
__name(setOptionalAttribute2, "setOptionalAttribute");
|
|
1273
|
-
function clearStaleAttributes(node, next) {
|
|
1274
|
-
const previous = node.__vobsIconAttributes ?? /* @__PURE__ */ new Set();
|
|
1275
|
-
for (const name of previous) {
|
|
1276
|
-
if (!next.has(name)) node.removeAttribute(name);
|
|
1277
|
-
}
|
|
1278
|
-
node.__vobsIconAttributes = new Set(next.keys());
|
|
1279
|
-
}
|
|
1280
|
-
__name(clearStaleAttributes, "clearStaleAttributes");
|
|
1281
|
-
function escapeXml(value) {
|
|
1282
|
-
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
1283
|
-
}
|
|
1284
|
-
__name(escapeXml, "escapeXml");
|
|
1285
|
-
|
|
1286
|
-
// packages/ui/src/icon.ts
|
|
1287
|
-
function Icon(props = {}) {
|
|
1288
|
-
const root = createSvgIconNode(() => {
|
|
1289
|
-
const definition = resolveIcon(
|
|
1290
|
-
readProp(props, "icon", void 0) ?? readProp(props, "name", void 0)
|
|
1291
|
-
);
|
|
1292
|
-
if (!definition) {
|
|
1293
|
-
if (hasProp(props, "children")) return void 0;
|
|
1294
|
-
throw new Error("Vobs UI: Icon requires a registered `name` or an `icon` definition");
|
|
1295
|
-
}
|
|
1296
|
-
return iconDefinitionToSvg(definition);
|
|
1297
|
-
}, props, {
|
|
1298
|
-
class: "vui-icon icon",
|
|
1299
|
-
defaultSvgAttributes: {
|
|
1300
|
-
fill: "none",
|
|
1301
|
-
stroke: "currentColor",
|
|
1302
|
-
"stroke-width": 2,
|
|
1303
|
-
"stroke-linecap": "butt",
|
|
1304
|
-
"stroke-linejoin": "miter"
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
if (hasProp(props, "children")) mountSlot(root, props, "children");
|
|
1308
|
-
return root;
|
|
1309
|
-
}
|
|
1310
|
-
__name(Icon, "Icon");
|
|
1311
|
-
function iconDefinitionToSvg(definition) {
|
|
1312
|
-
return {
|
|
1313
|
-
name: definition.name,
|
|
1314
|
-
body: definition.path,
|
|
1315
|
-
viewBox: definition.viewBox
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
__name(iconDefinitionToSvg, "iconDefinitionToSvg");
|
|
1319
|
-
var VUI_ICON_PATHS = {
|
|
1320
|
-
search: '<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',
|
|
1321
|
-
check: '<polyline points="4 12 10 18 20 6"/>',
|
|
1322
|
-
x: '<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',
|
|
1323
|
-
plus: '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
|
1324
|
-
minus: '<line x1="5" y1="12" x2="19" y2="12"/>',
|
|
1325
|
-
"chevron-right": '<polyline points="9 6 15 12 9 18"/>',
|
|
1326
|
-
"chevron-down": '<polyline points="6 9 12 15 18 9"/>',
|
|
1327
|
-
"chevron-up": '<polyline points="6 15 12 9 18 15"/>',
|
|
1328
|
-
"chevron-left": '<polyline points="15 6 9 12 15 18"/>',
|
|
1329
|
-
"arrow-left": '<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',
|
|
1330
|
-
"arrow-right": '<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',
|
|
1331
|
-
"arrow-up": '<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',
|
|
1332
|
-
"arrow-down": '<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',
|
|
1333
|
-
atom: '<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',
|
|
1334
|
-
globe: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/>',
|
|
1335
|
-
"arrow-expand": '<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',
|
|
1336
|
-
"arrow-minimize": '<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',
|
|
1337
|
-
"check-circle": '<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',
|
|
1338
|
-
"alert-circle": '<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',
|
|
1339
|
-
"alert-triangle": '<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',
|
|
1340
|
-
info: '<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',
|
|
1341
|
-
home: '<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',
|
|
1342
|
-
user: '<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',
|
|
1343
|
-
settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',
|
|
1344
|
-
menu: '<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',
|
|
1345
|
-
"more-h": '<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',
|
|
1346
|
-
calendar: '<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',
|
|
1347
|
-
filter: '<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',
|
|
1348
|
-
sort: '<path d="M8 20V4"/><polyline points="4 8 8 4 12 8"/><path d="M16 4v16"/><polyline points="12 16 16 20 20 16"/>',
|
|
1349
|
-
edit: '<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',
|
|
1350
|
-
trash: '<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',
|
|
1351
|
-
download: '<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',
|
|
1352
|
-
upload: '<path d="M12 21V6"/><polyline points="7 11 12 6 17 11"/><line x1="3" y1="21" x2="21" y2="21"/>',
|
|
1353
|
-
pause: '<line x1="9" y1="5" x2="9" y2="19"/><line x1="15" y1="5" x2="15" y2="19"/>',
|
|
1354
|
-
play: '<polygon points="8 5 19 12 8 19 8 5"/>',
|
|
1355
|
-
refresh: '<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',
|
|
1356
|
-
bell: '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',
|
|
1357
|
-
folder: '<path d="M3 6h6l2 3h10v10H3z"/>',
|
|
1358
|
-
code: '<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',
|
|
1359
|
-
sparkles: '<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',
|
|
1360
|
-
zap: '<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',
|
|
1361
|
-
sun: '<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',
|
|
1362
|
-
moon: '<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',
|
|
1363
|
-
terminal: '<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>'
|
|
1364
|
-
};
|
|
1365
|
-
var iconRegistry = new Map(
|
|
1366
|
-
Object.entries(VUI_ICON_PATHS).map(([name, path]) => [name, { name, path }])
|
|
1367
|
-
);
|
|
1368
|
-
function resolveIcon(icon) {
|
|
1369
|
-
return typeof icon === "string" ? iconRegistry.get(icon) : icon;
|
|
1370
|
-
}
|
|
1371
|
-
__name(resolveIcon, "resolveIcon");
|
|
1372
|
-
|
|
1373
4
|
// packages/devtools-ui/src/panel.tsx
|
|
5
|
+
import {
|
|
6
|
+
getDevTools
|
|
7
|
+
} from "@vobs/devtools";
|
|
8
|
+
import { HTTP_KEY } from "@vobs/http";
|
|
9
|
+
import { effect } from "@vobs/reactivity";
|
|
10
|
+
import { createComponent, createElement, createFragment, createText, inject, insertBefore, insertDynamic, onDispose, setAttribute, setProperty, state } from "@vobs/vobs";
|
|
11
|
+
import { Alert, Button, Card, Icon, Select, Tabs, Tag } from "@vobs/ui";
|
|
1374
12
|
var EMPTY_SNAPSHOT = {
|
|
1375
13
|
api: null,
|
|
1376
14
|
tree: [],
|
|
@@ -2006,7 +644,7 @@ function renderRouterSection(router, activeRouterTab, activeRouteView) {
|
|
|
2006
644
|
const root = createElement("div");
|
|
2007
645
|
setAttribute(root, "class", "vobs-devtools-router");
|
|
2008
646
|
const current = devtools.getCurrentRoute();
|
|
2009
|
-
const
|
|
647
|
+
const state3 = devtools.getNavigationState();
|
|
2010
648
|
const metrics = devtools.getPerformanceMetrics();
|
|
2011
649
|
const activeRequests = devtools.getDataRequests().filter((request) => request.route === current.fullPath || request.key.startsWith(`${current.fullPath}#`));
|
|
2012
650
|
const activeErrors = devtools.getErrors().filter((error) => error.route === current.fullPath);
|
|
@@ -2019,7 +657,7 @@ function renderRouterSection(router, activeRouterTab, activeRouteView) {
|
|
|
2019
657
|
class: "vobs-devtools-router-tabs",
|
|
2020
658
|
variant: "filled",
|
|
2021
659
|
items: [
|
|
2022
|
-
{ id: "context", label: "Context", content: /* @__PURE__ */ __name(() => createRouterContextPanel(current,
|
|
660
|
+
{ id: "context", label: "Context", content: /* @__PURE__ */ __name(() => createRouterContextPanel(current, state3), "content") },
|
|
2023
661
|
{ id: "requests", label: `Requests${activeRequests.length ? ` (${activeRequests.length})` : ""}`, content: /* @__PURE__ */ __name(() => createComponent(Card, { title: `Data requests for ${current.path}`, description: "Loader, action and fetcher traces for the active route.", children: /* @__PURE__ */ __name(() => renderDataRequests(activeRequests), "children") }), "content") },
|
|
2024
662
|
{ id: "errors", label: `Errors${activeErrors.length ? ` (${activeErrors.length})` : ""}`, content: /* @__PURE__ */ __name(() => createComponent(Card, { title: `Errors for ${current.path}`, description: `${activeErrors.length} errors captured for the active route.`, children: /* @__PURE__ */ __name(() => renderRouterErrors(activeErrors), "children") }), "content") },
|
|
2025
663
|
{ id: "history", label: "History", content: /* @__PURE__ */ __name(() => createComponent(Card, { title: "Navigation history", description: `${metrics.navigationCount} recorded navigations \xB7 ${metrics.averageNavigationDuration.toFixed(2)} ms average`, children: /* @__PURE__ */ __name(() => renderNavigationHistory(devtools.getNavigationHistory(), router), "children") }), "content") },
|
|
@@ -2044,9 +682,9 @@ function renderRouterSection(router, activeRouterTab, activeRouteView) {
|
|
|
2044
682
|
return root;
|
|
2045
683
|
}
|
|
2046
684
|
__name(renderRouterSection, "renderRouterSection");
|
|
2047
|
-
function createRouterContextPanel(current,
|
|
685
|
+
function createRouterContextPanel(current, state3) {
|
|
2048
686
|
return createFragment((parent, anchor) => {
|
|
2049
|
-
insertBefore(parent, createComponent(Card, { title: "Active route", children: /* @__PURE__ */ __name(() => renderRouterLocation(current,
|
|
687
|
+
insertBefore(parent, createComponent(Card, { title: "Active route", children: /* @__PURE__ */ __name(() => renderRouterLocation(current, state3), "children") }), anchor);
|
|
2050
688
|
insertBefore(parent, createComponent(Card, { title: "Matched route structure", children: /* @__PURE__ */ __name(() => renderMatchedRoutes(current.matched), "children") }), anchor);
|
|
2051
689
|
});
|
|
2052
690
|
}
|
|
@@ -2087,15 +725,15 @@ function renderRouterErrors(errors) {
|
|
|
2087
725
|
return root;
|
|
2088
726
|
}
|
|
2089
727
|
__name(renderRouterErrors, "renderRouterErrors");
|
|
2090
|
-
function renderRouterLocation(route,
|
|
728
|
+
function renderRouterLocation(route, state3) {
|
|
2091
729
|
const root = createElement("div");
|
|
2092
730
|
setAttribute(root, "class", "vobs-devtools-list");
|
|
2093
731
|
const statusRow = createElement("div");
|
|
2094
732
|
setAttribute(statusRow, "class", "vobs-devtools-list__row");
|
|
2095
733
|
appendText(statusRow, route.fullPath, "vobs-devtools-list__name");
|
|
2096
|
-
insertBefore(statusRow, createComponent(Tag, { tone:
|
|
2097
|
-
if (
|
|
2098
|
-
if (
|
|
734
|
+
insertBefore(statusRow, createComponent(Tag, { tone: state3.status === "error" ? "danger" : state3.status === "loading" ? "warning" : "success", children: /* @__PURE__ */ __name(() => state3.status, "children") }), null);
|
|
735
|
+
if (state3.status === "loading") appendText(statusRow, `to ${state3.to}`);
|
|
736
|
+
if (state3.error) appendText(statusRow, state3.error);
|
|
2099
737
|
insertBefore(root, statusRow, null);
|
|
2100
738
|
insertBefore(root, renderInspectableValue("Params", route.params), null);
|
|
2101
739
|
insertBefore(root, renderInspectableValue("Query", route.query), null);
|
|
@@ -3272,13 +1910,16 @@ function previewValue(value) {
|
|
|
3272
1910
|
__name(previewValue, "previewValue");
|
|
3273
1911
|
|
|
3274
1912
|
// packages/devtools-ui/src/widget.tsx
|
|
1913
|
+
import { createComponent as createComponent2, createElement as createElement2, createFragment as createFragment2, insertBefore as insertBefore2, insertDynamic as insertDynamic2, setAttribute as setAttribute2, state as state2 } from "@vobs/vobs";
|
|
1914
|
+
import { getDevTools as getDevTools2 } from "@vobs/devtools";
|
|
1915
|
+
import { Button as Button2, Dialog, Icon as Icon2 } from "@vobs/ui";
|
|
3275
1916
|
function DevToolsWidget(props = {}) {
|
|
3276
|
-
const open =
|
|
3277
|
-
const maximized =
|
|
3278
|
-
const query =
|
|
1917
|
+
const open = state2(false);
|
|
1918
|
+
const maximized = state2(false);
|
|
1919
|
+
const query = state2("");
|
|
3279
1920
|
const toolbarProps = {
|
|
3280
1921
|
get api() {
|
|
3281
|
-
return props.api === void 0 ?
|
|
1922
|
+
return props.api === void 0 ? getDevTools2() : props.api ?? null;
|
|
3282
1923
|
},
|
|
3283
1924
|
query,
|
|
3284
1925
|
get maximized() {
|
|
@@ -3288,34 +1929,34 @@ function DevToolsWidget(props = {}) {
|
|
|
3288
1929
|
maximized.value = !maximized.value;
|
|
3289
1930
|
}, "onToggleMaximize")
|
|
3290
1931
|
};
|
|
3291
|
-
return
|
|
3292
|
-
const launcher =
|
|
3293
|
-
|
|
3294
|
-
|
|
1932
|
+
return createFragment2((parent, anchor) => {
|
|
1933
|
+
const launcher = createElement2("div");
|
|
1934
|
+
setAttribute2(launcher, "class", "vobs-devtools-widget");
|
|
1935
|
+
insertBefore2(launcher, createComponent2(Button2, {
|
|
3295
1936
|
variant: "brand",
|
|
3296
1937
|
iconOnly: true,
|
|
3297
|
-
icon:
|
|
1938
|
+
icon: createComponent2(Icon2, { name: "code" }),
|
|
3298
1939
|
"aria-label": props.label ?? "Open DevTools",
|
|
3299
1940
|
title: props.label ?? "Open DevTools",
|
|
3300
1941
|
onClick: /* @__PURE__ */ __name(() => {
|
|
3301
1942
|
open.value = true;
|
|
3302
1943
|
}, "onClick")
|
|
3303
1944
|
}), null);
|
|
3304
|
-
|
|
3305
|
-
|
|
1945
|
+
insertBefore2(parent, launcher, anchor);
|
|
1946
|
+
insertDynamic2(parent, anchor, () => open.value ? createComponent2(Dialog, {
|
|
3306
1947
|
get class() {
|
|
3307
1948
|
return `vobs-devtools-widget__dialog${maximized.value ? " is-maximized" : ""}`;
|
|
3308
1949
|
},
|
|
3309
1950
|
open: true,
|
|
3310
1951
|
title: "Runtime DevTools",
|
|
3311
|
-
headerActions: /* @__PURE__ */ __name(() =>
|
|
1952
|
+
headerActions: /* @__PURE__ */ __name(() => createComponent2(DevToolsToolbar, toolbarProps), "headerActions"),
|
|
3312
1953
|
size: "lg",
|
|
3313
1954
|
closeLabel: "Close DevTools",
|
|
3314
1955
|
onClose: /* @__PURE__ */ __name(() => {
|
|
3315
1956
|
open.value = false;
|
|
3316
1957
|
maximized.value = false;
|
|
3317
1958
|
}, "onClose"),
|
|
3318
|
-
children: /* @__PURE__ */ __name(() =>
|
|
1959
|
+
children: /* @__PURE__ */ __name(() => createComponent2(DevToolsPanel, {
|
|
3319
1960
|
api: props.api,
|
|
3320
1961
|
router: props.router,
|
|
3321
1962
|
http: props.http,
|
|
@@ -3326,7 +1967,9 @@ function DevToolsWidget(props = {}) {
|
|
|
3326
1967
|
});
|
|
3327
1968
|
}
|
|
3328
1969
|
__name(DevToolsWidget, "DevToolsWidget");
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
1970
|
+
export {
|
|
1971
|
+
DevToolsPanel,
|
|
1972
|
+
DevToolsWidget,
|
|
1973
|
+
readDevToolsSnapshot
|
|
1974
|
+
};
|
|
3332
1975
|
//# sourceMappingURL=index.js.map
|