@vobs/ui 1.2.1 → 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/activity-rail.cjs +65 -629
- package/dist/activity-rail.cjs.map +1 -1
- package/dist/activity-rail.js +44 -612
- package/dist/activity-rail.js.map +1 -1
- package/dist/alert.cjs +58 -536
- package/dist/alert.cjs.map +1 -1
- package/dist/alert.js +33 -519
- package/dist/alert.js.map +1 -1
- package/dist/avatar.cjs +45 -519
- package/dist/avatar.cjs.map +1 -1
- package/dist/avatar.js +26 -508
- package/dist/avatar.js.map +1 -1
- package/dist/button.cjs +46 -559
- package/dist/button.cjs.map +1 -1
- package/dist/button.js +21 -545
- package/dist/button.js.map +1 -1
- package/dist/card.cjs +55 -532
- package/dist/card.cjs.map +1 -1
- package/dist/card.js +30 -515
- package/dist/card.js.map +1 -1
- package/dist/chat-composer.cjs +84 -602
- package/dist/chat-composer.cjs.map +1 -1
- package/dist/chat-composer.js +52 -576
- package/dist/chat-composer.js.map +1 -1
- package/dist/dialog.cjs +88 -591
- package/dist/dialog.cjs.map +1 -1
- package/dist/dialog.js +63 -569
- package/dist/dialog.js.map +1 -1
- package/dist/drawer.cjs +91 -594
- package/dist/drawer.cjs.map +1 -1
- package/dist/drawer.js +65 -571
- package/dist/drawer.js.map +1 -1
- package/dist/editor-tabs.cjs +75 -635
- package/dist/editor-tabs.cjs.map +1 -1
- package/dist/editor-tabs.js +51 -616
- package/dist/editor-tabs.js.map +1 -1
- package/dist/file-tree.cjs +70 -634
- package/dist/file-tree.cjs.map +1 -1
- package/dist/file-tree.js +49 -617
- package/dist/file-tree.js.map +1 -1
- package/dist/forms.cjs +80 -589
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +41 -559
- package/dist/forms.js.map +1 -1
- package/dist/icon.cjs +44 -624
- package/dist/icon.cjs.map +1 -1
- package/dist/icon.js +25 -615
- package/dist/icon.js.map +1 -1
- package/dist/icons.cjs +2 -3
- package/dist/icons.cjs.map +1 -1
- package/dist/icons.js +0 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.cjs +735 -1586
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +811 -1517
- package/dist/index.js.map +1 -1
- package/dist/kbd.cjs +53 -525
- package/dist/kbd.cjs.map +1 -1
- package/dist/kbd.js +30 -509
- package/dist/kbd.js.map +1 -1
- package/dist/menu.cjs +68 -582
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.js +47 -565
- package/dist/menu.js.map +1 -1
- package/dist/nav-list.cjs +71 -635
- package/dist/nav-list.cjs.map +1 -1
- package/dist/nav-list.js +50 -618
- package/dist/nav-list.js.map +1 -1
- package/dist/overlay.cjs +43 -197
- package/dist/overlay.cjs.map +1 -1
- package/dist/overlay.js +20 -192
- package/dist/overlay.js.map +1 -1
- package/dist/page-header.cjs +68 -585
- package/dist/page-header.cjs.map +1 -1
- package/dist/page-header.js +42 -565
- package/dist/page-header.js.map +1 -1
- package/dist/pagination.cjs +70 -585
- package/dist/pagination.cjs.map +1 -1
- package/dist/pagination.js +53 -572
- package/dist/pagination.js.map +1 -1
- package/dist/stat-card.cjs +62 -538
- package/dist/stat-card.cjs.map +1 -1
- package/dist/stat-card.js +36 -519
- package/dist/stat-card.js.map +1 -1
- package/dist/status-bar.cjs +65 -576
- package/dist/status-bar.cjs.map +1 -1
- package/dist/status-bar.js +43 -560
- package/dist/status-bar.js.map +1 -1
- package/dist/table.cjs +87 -605
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +57 -579
- package/dist/table.js.map +1 -1
- package/dist/tabs.cjs +62 -626
- package/dist/tabs.cjs.map +1 -1
- package/dist/tabs.js +45 -613
- package/dist/tabs.js.map +1 -1
- package/dist/tag.cjs +40 -514
- package/dist/tag.cjs.map +1 -1
- package/dist/tag.js +18 -503
- package/dist/tag.js.map +1 -1
- package/dist/toast.cjs +95 -1001
- package/dist/toast.cjs.map +1 -1
- package/dist/toast.js +74 -980
- package/dist/toast.js.map +1 -1
- package/dist/types.cjs +18 -2
- package/dist/types.cjs.map +1 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +77 -580
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +29 -545
- package/dist/utils.js.map +1 -1
- package/dist/workbench-titlebar.cjs +83 -598
- package/dist/workbench-titlebar.cjs.map +1 -1
- package/dist/workbench-titlebar.js +55 -575
- package/dist/workbench-titlebar.js.map +1 -1
- package/package.json +5 -5
package/dist/toast.js
CHANGED
|
@@ -1,969 +1,44 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// packages/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
__name(setSignalDebugName, "setSignalDebugName");
|
|
16
|
-
function invokeDebug(name, ...args) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
__name(invokeDebug, "invokeDebug");
|
|
20
|
-
|
|
21
|
-
// packages/reactivity/src/owner.ts
|
|
22
|
-
var currentOwner = null;
|
|
23
|
-
var nextOwnerId = 1;
|
|
24
|
-
var ownerNames = /* @__PURE__ */ new WeakMap();
|
|
25
|
-
function createOwner() {
|
|
26
|
-
const parent = currentOwner;
|
|
27
|
-
let disposed = parent?.disposed ?? false;
|
|
28
|
-
const children = [];
|
|
29
|
-
const cleanups = [];
|
|
30
|
-
const errorHandlers = /* @__PURE__ */ new Set();
|
|
31
|
-
const owner = {
|
|
32
|
-
id: `owner-${nextOwnerId++}`,
|
|
33
|
-
parent,
|
|
34
|
-
children,
|
|
35
|
-
depth: (parent?.depth ?? -1) + 1,
|
|
36
|
-
get disposed() {
|
|
37
|
-
return disposed;
|
|
38
|
-
},
|
|
39
|
-
run(fn) {
|
|
40
|
-
if (disposed) throw new Error("Vobs: \u5DF2\u9500\u6BC1\u7684 Owner \u4E0D\u80FD\u7EE7\u7EED\u8FD0\u884C");
|
|
41
|
-
const previous = currentOwner;
|
|
42
|
-
currentOwner = owner;
|
|
43
|
-
try {
|
|
44
|
-
return fn();
|
|
45
|
-
} finally {
|
|
46
|
-
currentOwner = previous;
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
addCleanup(cleanup) {
|
|
50
|
-
if (disposed) {
|
|
51
|
-
cleanup();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
cleanups.push(cleanup);
|
|
55
|
-
},
|
|
56
|
-
onDispose(cleanup) {
|
|
57
|
-
owner.addCleanup(cleanup);
|
|
58
|
-
},
|
|
59
|
-
onError(handler) {
|
|
60
|
-
errorHandlers.add(handler);
|
|
61
|
-
const remove = /* @__PURE__ */ __name(() => errorHandlers.delete(handler), "remove");
|
|
62
|
-
owner.addCleanup(remove);
|
|
63
|
-
return remove;
|
|
64
|
-
},
|
|
65
|
-
handleError(error) {
|
|
66
|
-
for (const handler of [...errorHandlers].reverse()) {
|
|
67
|
-
try {
|
|
68
|
-
handler(error);
|
|
69
|
-
return true;
|
|
70
|
-
} catch (handlerError) {
|
|
71
|
-
return parent?.handleError(handlerError) ?? false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return parent?.handleError(error) ?? false;
|
|
75
|
-
},
|
|
76
|
-
dispose() {
|
|
77
|
-
if (disposed) return;
|
|
78
|
-
disposed = true;
|
|
79
|
-
for (const child of [...children]) child.dispose();
|
|
80
|
-
children.length = 0;
|
|
81
|
-
let firstError;
|
|
82
|
-
for (let index = cleanups.length - 1; index >= 0; index--) {
|
|
83
|
-
try {
|
|
84
|
-
cleanups[index]();
|
|
85
|
-
} catch (error) {
|
|
86
|
-
firstError ?? (firstError = error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
cleanups.length = 0;
|
|
90
|
-
if (parent) {
|
|
91
|
-
const index = parent.children.indexOf(owner);
|
|
92
|
-
if (index >= 0) parent.children.splice(index, 1);
|
|
93
|
-
}
|
|
94
|
-
if (firstError) throw firstError;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
if (parent && !parent.disposed) parent.children.push(owner);
|
|
98
|
-
return owner;
|
|
99
|
-
}
|
|
100
|
-
__name(createOwner, "createOwner");
|
|
101
|
-
function setOwnerDebugName(owner, name) {
|
|
102
|
-
ownerNames.set(owner, name);
|
|
103
|
-
}
|
|
104
|
-
__name(setOwnerDebugName, "setOwnerDebugName");
|
|
105
|
-
function getCurrentOwner() {
|
|
106
|
-
return currentOwner;
|
|
107
|
-
}
|
|
108
|
-
__name(getCurrentOwner, "getCurrentOwner");
|
|
109
|
-
|
|
110
|
-
// packages/reactivity/src/signal.ts
|
|
111
|
-
var currentSubscriber = null;
|
|
112
|
-
function getCurrentSubscriber() {
|
|
113
|
-
return currentSubscriber;
|
|
114
|
-
}
|
|
115
|
-
__name(getCurrentSubscriber, "getCurrentSubscriber");
|
|
116
|
-
function setCurrentSubscriber(subscriber) {
|
|
117
|
-
currentSubscriber = subscriber;
|
|
118
|
-
}
|
|
119
|
-
__name(setCurrentSubscriber, "setCurrentSubscriber");
|
|
120
|
-
function trackDependency(dependency) {
|
|
121
|
-
if (!currentSubscriber || currentSubscriber.disposed) return;
|
|
122
|
-
!currentSubscriber.dependencies.has(dependency);
|
|
123
|
-
currentSubscriber.dependencies.add(dependency);
|
|
124
|
-
}
|
|
125
|
-
__name(trackDependency, "trackDependency");
|
|
126
|
-
function state(initialValue, debugName) {
|
|
127
|
-
let value = initialValue;
|
|
128
|
-
let disposed = false;
|
|
129
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
130
|
-
const signalInstance = {
|
|
131
|
-
get value() {
|
|
132
|
-
const subscriber = getCurrentSubscriber();
|
|
133
|
-
if (subscriber && !subscriber.disposed) {
|
|
134
|
-
subscribers.add(subscriber);
|
|
135
|
-
trackDependency(signalInstance);
|
|
136
|
-
}
|
|
137
|
-
return value;
|
|
138
|
-
},
|
|
139
|
-
set value(nextValue) {
|
|
140
|
-
if (disposed || Object.is(value, nextValue)) return;
|
|
141
|
-
value = nextValue;
|
|
142
|
-
for (const subscriber of [...subscribers]) subscriber.notify();
|
|
143
|
-
},
|
|
144
|
-
unsubscribe(subscriber) {
|
|
145
|
-
subscribers.delete(subscriber);
|
|
146
|
-
},
|
|
147
|
-
// 与 `.value =` 赋值同一条路径:判等短路、debug hook、notify 全部一致。
|
|
148
|
-
// 以闭包实现,可安全地作为回调直接传递(无 this 绑定问题)。
|
|
149
|
-
set(next) {
|
|
150
|
-
signalInstance.value = next;
|
|
151
|
-
},
|
|
152
|
-
dispose() {
|
|
153
|
-
if (disposed) return;
|
|
154
|
-
disposed = true;
|
|
155
|
-
subscribers.clear();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const owner = getCurrentOwner();
|
|
159
|
-
owner?.addCleanup(signalInstance.dispose);
|
|
160
|
-
if (debugName?.trim()) setSignalDebugName(signalInstance, debugName.trim());
|
|
161
|
-
return signalInstance;
|
|
162
|
-
}
|
|
163
|
-
__name(state, "state");
|
|
164
|
-
|
|
165
|
-
// packages/reactivity/src/scheduler.ts
|
|
166
|
-
var _Scheduler = class _Scheduler {
|
|
167
|
-
constructor() {
|
|
168
|
-
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
169
|
-
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
170
|
-
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
171
|
-
this.normalBuffer = [];
|
|
172
|
-
this.lowBuffer = [];
|
|
173
|
-
this.flushing = false;
|
|
174
|
-
this.scheduled = false;
|
|
175
|
-
this.batchDepth = 0;
|
|
176
|
-
}
|
|
177
|
-
schedule(effect2) {
|
|
178
|
-
if (effect2.disposed) return;
|
|
179
|
-
this.dirtyEffects.add(effect2);
|
|
180
|
-
this.lowPriorityEffects.delete(effect2);
|
|
181
|
-
this.ensureScheduled();
|
|
182
|
-
}
|
|
183
|
-
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
184
|
-
scheduleLow(effect2) {
|
|
185
|
-
if (effect2.disposed) return;
|
|
186
|
-
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
187
|
-
this.ensureScheduled();
|
|
188
|
-
}
|
|
189
|
-
ensureScheduled() {
|
|
190
|
-
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
191
|
-
this.scheduled = true;
|
|
192
|
-
queueMicrotask(() => {
|
|
193
|
-
this.scheduled = false;
|
|
194
|
-
this.flush();
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
remove(effect2) {
|
|
199
|
-
this.dirtyEffects.delete(effect2);
|
|
200
|
-
this.lowPriorityEffects.delete(effect2);
|
|
201
|
-
}
|
|
202
|
-
batch(fn) {
|
|
203
|
-
this.batchDepth++;
|
|
204
|
-
try {
|
|
205
|
-
return fn();
|
|
206
|
-
} finally {
|
|
207
|
-
this.batchDepth--;
|
|
208
|
-
if (this.batchDepth === 0) this.flush();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
flush() {
|
|
212
|
-
if (this.flushing || this.batchDepth > 0) return;
|
|
213
|
-
this.flushing = true;
|
|
214
|
-
let rounds = 0;
|
|
215
|
-
let firstError;
|
|
216
|
-
let hasError = false;
|
|
217
|
-
try {
|
|
218
|
-
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
219
|
-
if (++rounds > 100) {
|
|
220
|
-
this.dirtyEffects.clear();
|
|
221
|
-
this.lowPriorityEffects.clear();
|
|
222
|
-
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
223
|
-
}
|
|
224
|
-
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
225
|
-
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
226
|
-
sortEffects(this.normalBuffer);
|
|
227
|
-
sortEffects(this.lowBuffer);
|
|
228
|
-
for (const effect2 of this.normalBuffer) {
|
|
229
|
-
try {
|
|
230
|
-
effect2.run();
|
|
231
|
-
} catch (error) {
|
|
232
|
-
if (!hasError) {
|
|
233
|
-
firstError = error;
|
|
234
|
-
hasError = true;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
for (const effect2 of this.lowBuffer) {
|
|
239
|
-
try {
|
|
240
|
-
effect2.run();
|
|
241
|
-
} catch (error) {
|
|
242
|
-
if (!hasError) {
|
|
243
|
-
firstError = error;
|
|
244
|
-
hasError = true;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
this.normalBuffer.length = 0;
|
|
249
|
-
this.lowBuffer.length = 0;
|
|
250
|
-
}
|
|
251
|
-
} finally {
|
|
252
|
-
this.normalBuffer.length = 0;
|
|
253
|
-
this.lowBuffer.length = 0;
|
|
254
|
-
this.flushing = false;
|
|
255
|
-
}
|
|
256
|
-
if (hasError) throw firstError;
|
|
257
|
-
}
|
|
258
|
-
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
259
|
-
collectRunnable(source, target) {
|
|
260
|
-
for (const effect2 of source) {
|
|
261
|
-
if (!effect2.disposed) target.push(effect2);
|
|
262
|
-
}
|
|
263
|
-
source.clear();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
__name(_Scheduler, "Scheduler");
|
|
267
|
-
var Scheduler = _Scheduler;
|
|
268
|
-
function sortEffects(effects) {
|
|
269
|
-
if (effects.length > 1) {
|
|
270
|
-
effects.sort((a, b) => b.depth - a.depth || a.order - b.order);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
__name(sortEffects, "sortEffects");
|
|
274
|
-
var scheduler = new Scheduler();
|
|
275
|
-
|
|
276
|
-
// packages/reactivity/src/effect.ts
|
|
277
|
-
var nextEffectOrder = 1;
|
|
278
|
-
function cleanupDependencies(subscriber) {
|
|
279
|
-
for (const dependency of subscriber.dependencies) {
|
|
280
|
-
dependency.unsubscribe(subscriber);
|
|
281
|
-
}
|
|
282
|
-
subscriber.dependencies.clear();
|
|
283
|
-
}
|
|
284
|
-
__name(cleanupDependencies, "cleanupDependencies");
|
|
285
|
-
function effect(callback) {
|
|
286
|
-
const owner = getCurrentOwner();
|
|
287
|
-
let cleanup;
|
|
288
|
-
let dirty = true;
|
|
289
|
-
let disposed = false;
|
|
290
|
-
const eff = {
|
|
291
|
-
order: nextEffectOrder++,
|
|
292
|
-
depth: owner?.depth ?? 0,
|
|
293
|
-
dependencies: /* @__PURE__ */ new Set(),
|
|
294
|
-
get disposed() {
|
|
295
|
-
return disposed;
|
|
296
|
-
},
|
|
297
|
-
notify() {
|
|
298
|
-
if (disposed || dirty) return;
|
|
299
|
-
dirty = true;
|
|
300
|
-
scheduler.schedule(eff);
|
|
301
|
-
},
|
|
302
|
-
run() {
|
|
303
|
-
if (disposed || !dirty) return;
|
|
304
|
-
dirty = false;
|
|
305
|
-
const previousCleanup = cleanup;
|
|
306
|
-
cleanup = void 0;
|
|
307
|
-
let cleanupError;
|
|
308
|
-
if (previousCleanup) {
|
|
309
|
-
try {
|
|
310
|
-
previousCleanup();
|
|
311
|
-
} catch (error) {
|
|
312
|
-
const handled2 = owner?.handleError(error) ?? false;
|
|
313
|
-
if (!handled2) cleanupError = error;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
cleanupDependencies(eff);
|
|
317
|
-
const previous = getCurrentSubscriber();
|
|
318
|
-
setCurrentSubscriber(eff);
|
|
319
|
-
let thrown;
|
|
320
|
-
let handled = false;
|
|
321
|
-
try {
|
|
322
|
-
const result = owner ? owner.run(callback) : callback();
|
|
323
|
-
cleanup = typeof result === "function" ? result : void 0;
|
|
324
|
-
} catch (error) {
|
|
325
|
-
thrown = error;
|
|
326
|
-
handled = owner?.handleError(error) ?? false;
|
|
327
|
-
if (!handled) throw error;
|
|
328
|
-
} finally {
|
|
329
|
-
setCurrentSubscriber(previous);
|
|
330
|
-
}
|
|
331
|
-
if (cleanupError && !thrown) throw cleanupError;
|
|
332
|
-
},
|
|
333
|
-
scheduleLow() {
|
|
334
|
-
if (disposed || dirty) return;
|
|
335
|
-
dirty = true;
|
|
336
|
-
scheduler.scheduleLow(eff);
|
|
337
|
-
},
|
|
338
|
-
dispose() {
|
|
339
|
-
if (disposed) return;
|
|
340
|
-
disposed = true;
|
|
341
|
-
dirty = false;
|
|
342
|
-
scheduler.remove(eff);
|
|
343
|
-
const previousCleanup = cleanup;
|
|
344
|
-
cleanup = void 0;
|
|
345
|
-
let cleanupError;
|
|
346
|
-
if (previousCleanup) {
|
|
347
|
-
try {
|
|
348
|
-
previousCleanup();
|
|
349
|
-
} catch (error) {
|
|
350
|
-
const handled = owner?.handleError(error) ?? false;
|
|
351
|
-
if (!handled) cleanupError = error;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
cleanupDependencies(eff);
|
|
355
|
-
if (cleanupError) throw cleanupError;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
owner?.addCleanup(eff.dispose);
|
|
359
|
-
eff.run();
|
|
360
|
-
return eff;
|
|
361
|
-
}
|
|
362
|
-
__name(effect, "effect");
|
|
363
|
-
|
|
364
|
-
// packages/runtime/src/debug.ts
|
|
365
|
-
var activeRuntimeDebugHooks = null;
|
|
366
|
-
function getRuntimeDebugHooks() {
|
|
367
|
-
return activeRuntimeDebugHooks;
|
|
368
|
-
}
|
|
369
|
-
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
370
|
-
function invokeRuntimeDebug(name, ...args) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
__name(invokeRuntimeDebug, "invokeRuntimeDebug");
|
|
374
|
-
function readDebugValue(read) {
|
|
375
|
-
try {
|
|
376
|
-
return read();
|
|
377
|
-
} catch {
|
|
378
|
-
return "[Uninspectable]";
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
__name(readDebugValue, "readDebugValue");
|
|
382
|
-
function describeDebugNode(node) {
|
|
383
|
-
if (!node || typeof node !== "object") return "node";
|
|
384
|
-
const value = node;
|
|
385
|
-
const name = typeof value.tagName === "string" ? value.tagName.toLowerCase() : typeof value.nodeName === "string" ? value.nodeName.toLowerCase() : "node";
|
|
386
|
-
const id = typeof value.id === "string" && value.id ? `#${value.id}` : "";
|
|
387
|
-
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().split(/\s+/).filter(Boolean).join(".")}` : "";
|
|
388
|
-
return `${name}${id}${className}`;
|
|
389
|
-
}
|
|
390
|
-
__name(describeDebugNode, "describeDebugNode");
|
|
391
|
-
|
|
392
|
-
// packages/runtime/src/hmr.ts
|
|
393
|
-
var globalTarget = globalThis;
|
|
394
|
-
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
395
|
-
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
396
|
-
function markHmrInstanceMounted(node, parent) {
|
|
397
|
-
const instance = hmrInstances.get(node);
|
|
398
|
-
if (instance) instance.parent = parent;
|
|
399
|
-
}
|
|
400
|
-
__name(markHmrInstanceMounted, "markHmrInstanceMounted");
|
|
401
|
-
var hmrInstances = /* @__PURE__ */ new WeakMap();
|
|
402
|
-
var nodeOwners = /* @__PURE__ */ new WeakMap();
|
|
403
|
-
var eventBindings = /* @__PURE__ */ new WeakMap();
|
|
404
|
-
function getRenderer() {
|
|
405
|
-
{
|
|
406
|
-
throw new Error("\u6E32\u67D3\u5668\u672A\u521D\u59CB\u5316");
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
__name(getRenderer, "getRenderer");
|
|
410
|
-
function createText(content) {
|
|
411
|
-
return getRenderer().createText(content);
|
|
412
|
-
}
|
|
413
|
-
__name(createText, "createText");
|
|
414
|
-
function createElement(tag) {
|
|
415
|
-
return getRenderer().createElement(tag);
|
|
416
|
-
}
|
|
417
|
-
__name(createElement, "createElement");
|
|
418
|
-
function createComment(content) {
|
|
419
|
-
return getRenderer().createComment(content);
|
|
420
|
-
}
|
|
421
|
-
__name(createComment, "createComment");
|
|
422
|
-
function insertBefore(parent, child, anchor) {
|
|
423
|
-
if (isVobsFragment(child)) {
|
|
424
|
-
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
428
|
-
markHmrInstanceMounted(child, parent);
|
|
429
|
-
}
|
|
430
|
-
__name(insertBefore, "insertBefore");
|
|
431
|
-
function removeChild(parent, child) {
|
|
432
|
-
disposeNodeOwner(child);
|
|
433
|
-
if (isVobsFragment(child)) {
|
|
434
|
-
child.unmount(parent);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
getRenderer().removeChild(parent, child);
|
|
438
|
-
}
|
|
439
|
-
__name(removeChild, "removeChild");
|
|
440
|
-
function setProperty(node, key, value) {
|
|
441
|
-
getRenderer().setProperty(node, key, value);
|
|
442
|
-
}
|
|
443
|
-
__name(setProperty, "setProperty");
|
|
444
|
-
function setAttribute(node, key, value) {
|
|
445
|
-
getRenderer().setAttribute(node, key, value);
|
|
446
|
-
}
|
|
447
|
-
__name(setAttribute, "setAttribute");
|
|
448
|
-
function addEventListener(node, event, handler) {
|
|
449
|
-
const renderer = getRenderer();
|
|
450
|
-
const owner = getCurrentOwner();
|
|
451
|
-
let bindings = eventBindings.get(node);
|
|
452
|
-
if (!bindings) {
|
|
453
|
-
bindings = /* @__PURE__ */ new Map();
|
|
454
|
-
eventBindings.set(node, bindings);
|
|
455
|
-
}
|
|
456
|
-
const previous = bindings.get(event);
|
|
457
|
-
if (previous && previous.original === handler && previous.owner === owner) return;
|
|
458
|
-
if (previous) renderer.removeEventListener(node, event, previous.handler);
|
|
459
|
-
const listener = owner ? (reason) => {
|
|
460
|
-
try {
|
|
461
|
-
owner.run(() => handler(reason));
|
|
462
|
-
} catch (error) {
|
|
463
|
-
const handled = owner.handleError(error);
|
|
464
|
-
invokeRuntimeDebug("error", {
|
|
465
|
-
error,
|
|
466
|
-
owner,
|
|
467
|
-
phase: "event",
|
|
468
|
-
handled,
|
|
469
|
-
recovery: handled ? "handled" : "propagated"
|
|
470
|
-
});
|
|
471
|
-
if (!handled) throw error;
|
|
472
|
-
}
|
|
473
|
-
} : handler;
|
|
474
|
-
const binding = { handler: listener, owner, original: handler };
|
|
475
|
-
bindings.set(event, binding);
|
|
476
|
-
renderer.addEventListener(node, event, listener);
|
|
477
|
-
owner?.onDispose(() => {
|
|
478
|
-
if (bindings?.get(event) !== binding) return;
|
|
479
|
-
bindings.delete(event);
|
|
480
|
-
renderer.removeEventListener(node, event, listener);
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
__name(addEventListener, "addEventListener");
|
|
484
|
-
function createBlock(factory) {
|
|
485
|
-
const owner = createOwner();
|
|
486
|
-
setOwnerDebugName(owner, "dynamic");
|
|
487
|
-
let node;
|
|
488
|
-
try {
|
|
489
|
-
node = owner.run(factory);
|
|
490
|
-
} catch (error) {
|
|
491
|
-
owner.dispose();
|
|
492
|
-
throw error;
|
|
493
|
-
}
|
|
494
|
-
if (!node) {
|
|
495
|
-
owner.dispose();
|
|
496
|
-
return null;
|
|
497
|
-
}
|
|
498
|
-
associateNodeOwner(node, owner);
|
|
499
|
-
return node;
|
|
500
|
-
}
|
|
501
|
-
__name(createBlock, "createBlock");
|
|
502
|
-
function associateNodeOwner(node, owner) {
|
|
503
|
-
nodeOwners.set(node, owner);
|
|
504
|
-
}
|
|
505
|
-
__name(associateNodeOwner, "associateNodeOwner");
|
|
506
|
-
function disposeNodeOwner(node) {
|
|
507
|
-
const owner = nodeOwners.get(node);
|
|
508
|
-
if (!owner) return;
|
|
509
|
-
nodeOwners.delete(node);
|
|
510
|
-
owner.dispose();
|
|
511
|
-
}
|
|
512
|
-
__name(disposeNodeOwner, "disposeNodeOwner");
|
|
513
|
-
|
|
514
|
-
// packages/runtime/src/fragment.ts
|
|
515
|
-
function createFragment(factory) {
|
|
516
|
-
const start = createComment("vobs:fragment:start");
|
|
517
|
-
const end = createComment("vobs:fragment:end");
|
|
518
|
-
let parent = null;
|
|
519
|
-
let initialized = false;
|
|
520
|
-
const owner = getCurrentOwner();
|
|
521
|
-
const fragment = {
|
|
522
|
-
kind: "vobs-fragment",
|
|
523
|
-
start,
|
|
524
|
-
end,
|
|
525
|
-
mount(nextParent, anchor) {
|
|
526
|
-
if (parent && parent !== nextParent) {
|
|
527
|
-
throw new Error("Vobs Fragment: \u4E0D\u80FD\u8DE8\u7236\u8282\u70B9\u79FB\u52A8 Fragment");
|
|
528
|
-
}
|
|
529
|
-
if (initialized) {
|
|
530
|
-
moveRange(nextParent, start, end, anchor);
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
const renderer = getRenderer();
|
|
534
|
-
renderer.insertBefore(nextParent, start, anchor);
|
|
535
|
-
renderer.insertBefore(nextParent, end, anchor);
|
|
536
|
-
parent = nextParent;
|
|
537
|
-
initialized = true;
|
|
538
|
-
if (owner) owner.run(() => factory(nextParent, end));
|
|
539
|
-
else factory(nextParent, end);
|
|
540
|
-
},
|
|
541
|
-
unmount(nextParent) {
|
|
542
|
-
if (!initialized || parent !== nextParent) {
|
|
543
|
-
throw new Error("Vobs Fragment: Fragment \u4E0D\u5C5E\u4E8E\u6307\u5B9A\u7236\u8282\u70B9");
|
|
544
|
-
}
|
|
545
|
-
const renderer = getRenderer();
|
|
546
|
-
let current = renderer.nextSibling(start);
|
|
547
|
-
while (current && current !== end) {
|
|
548
|
-
const next = renderer.nextSibling(current);
|
|
549
|
-
renderer.removeChild(nextParent, current);
|
|
550
|
-
current = next;
|
|
551
|
-
}
|
|
552
|
-
renderer.removeChild(nextParent, start);
|
|
553
|
-
renderer.removeChild(nextParent, end);
|
|
554
|
-
parent = null;
|
|
555
|
-
initialized = false;
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
return fragment;
|
|
559
|
-
}
|
|
560
|
-
__name(createFragment, "createFragment");
|
|
561
|
-
function isVobsFragment(value) {
|
|
562
|
-
return Boolean(value) && typeof value === "object" && value.kind === "vobs-fragment";
|
|
563
|
-
}
|
|
564
|
-
__name(isVobsFragment, "isVobsFragment");
|
|
565
|
-
function moveRange(parent, start, end, anchor) {
|
|
566
|
-
const renderer = getRenderer();
|
|
567
|
-
const nodes = [start];
|
|
568
|
-
let current = renderer.nextSibling(start);
|
|
569
|
-
while (current) {
|
|
570
|
-
nodes.push(current);
|
|
571
|
-
if (current === end) break;
|
|
572
|
-
current = renderer.nextSibling(current);
|
|
573
|
-
}
|
|
574
|
-
if (nodes[nodes.length - 1] !== end) {
|
|
575
|
-
throw new Error("Vobs Fragment: \u627E\u4E0D\u5230\u7ED3\u675F\u951A\u70B9");
|
|
576
|
-
}
|
|
577
|
-
for (const node of nodes) renderer.insertBefore(parent, node, anchor);
|
|
578
|
-
}
|
|
579
|
-
__name(moveRange, "moveRange");
|
|
580
|
-
|
|
581
|
-
// packages/runtime/src/dynamic.ts
|
|
582
|
-
function insertDynamic(parent, anchor, factory) {
|
|
583
|
-
const marker = createComment("vobs:dynamic");
|
|
584
|
-
insertBefore(parent, marker, anchor);
|
|
585
|
-
let current = null;
|
|
586
|
-
effect(() => {
|
|
587
|
-
const next = createBlock(factory);
|
|
588
|
-
if (next === current) return;
|
|
589
|
-
if (current) removeChild(parent, current);
|
|
590
|
-
current = next;
|
|
591
|
-
if (current) insertBefore(parent, current, marker);
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
__name(insertDynamic, "insertDynamic");
|
|
595
|
-
function insertList(parent, anchor, source, renderItem, keyOf) {
|
|
596
|
-
const marker = createComment("vobs:list");
|
|
597
|
-
insertBefore(parent, marker, anchor);
|
|
598
|
-
let entries = [];
|
|
599
|
-
const tracksIndex = renderItem.length >= 2;
|
|
600
|
-
effect(() => {
|
|
601
|
-
const items = source();
|
|
602
|
-
let keys = null;
|
|
603
|
-
if (keyOf) {
|
|
604
|
-
keys = new Array(items.length);
|
|
605
|
-
let allKeyed = items.length > 0;
|
|
606
|
-
for (let index = 0; index < items.length; index++) {
|
|
607
|
-
const key = keyOf(items[index], index);
|
|
608
|
-
if (key == null) {
|
|
609
|
-
allKeyed = false;
|
|
610
|
-
break;
|
|
611
|
-
}
|
|
612
|
-
keys[index] = key;
|
|
613
|
-
}
|
|
614
|
-
if (!allKeyed) keys = null;
|
|
615
|
-
}
|
|
616
|
-
const nextEntries = keys ? reconcileKeyed(items, keys, entries, renderItem) : reconcileIndexed(items, entries, renderItem);
|
|
617
|
-
const refreshed = tracksIndex ? /* @__PURE__ */ new Set() : null;
|
|
618
|
-
for (let index = 0; index < nextEntries.length; index++) {
|
|
619
|
-
const entry = nextEntries[index];
|
|
620
|
-
if (tracksIndex) {
|
|
621
|
-
if (entry.index !== index) {
|
|
622
|
-
refreshListEntry(parent, entry, index, renderItem);
|
|
623
|
-
refreshed.add(entry);
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
entry.index = index;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const retained = new Set(nextEntries);
|
|
630
|
-
for (const entry of entries) {
|
|
631
|
-
if (!retained.has(entry)) disposeEntry(parent, entry);
|
|
632
|
-
}
|
|
633
|
-
reorderListEntries(parent, marker, entries, nextEntries, refreshed);
|
|
634
|
-
entries = nextEntries;
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
__name(insertList, "insertList");
|
|
638
|
-
function reorderListEntries(parent, marker, previous, nextEntries, forceInsert) {
|
|
639
|
-
const count = nextEntries.length;
|
|
640
|
-
if (count === 0) return;
|
|
641
|
-
if (previous.length === 0) {
|
|
642
|
-
let reference2 = marker;
|
|
643
|
-
for (let index = count - 1; index >= 0; index--) {
|
|
644
|
-
const node = nextEntries[index].node;
|
|
645
|
-
insertBefore(parent, node, reference2);
|
|
646
|
-
reference2 = node;
|
|
647
|
-
}
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
const oldIndexOf = /* @__PURE__ */ new Map();
|
|
651
|
-
for (let index = 0; index < previous.length; index++) oldIndexOf.set(previous[index], index);
|
|
652
|
-
const seq = new Array(count);
|
|
653
|
-
for (let index = 0; index < count; index++) {
|
|
654
|
-
const entry = nextEntries[index];
|
|
655
|
-
seq[index] = forceInsert?.has(entry) ? -1 : oldIndexOf.get(entry) ?? -1;
|
|
656
|
-
}
|
|
657
|
-
const keep = computeKeptByLis(seq);
|
|
658
|
-
let reference = marker;
|
|
659
|
-
for (let index = count - 1; index >= 0; index--) {
|
|
660
|
-
const node = nextEntries[index].node;
|
|
661
|
-
if (keep[index]) {
|
|
662
|
-
reference = node;
|
|
663
|
-
continue;
|
|
664
|
-
}
|
|
665
|
-
insertBefore(parent, node, reference);
|
|
666
|
-
reference = node;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
__name(reorderListEntries, "reorderListEntries");
|
|
670
|
-
function computeKeptByLis(seq) {
|
|
671
|
-
const count = seq.length;
|
|
672
|
-
const keep = new Array(count).fill(false);
|
|
673
|
-
const tailsIndex = [];
|
|
674
|
-
const tailsValue = [];
|
|
675
|
-
const prev = new Array(count).fill(-1);
|
|
676
|
-
for (let i = 0; i < count; i++) {
|
|
677
|
-
const value = seq[i];
|
|
678
|
-
if (value < 0) continue;
|
|
679
|
-
let lo = 0;
|
|
680
|
-
let hi = tailsValue.length;
|
|
681
|
-
while (lo < hi) {
|
|
682
|
-
const mid = lo + hi >> 1;
|
|
683
|
-
if (tailsValue[mid] < value) lo = mid + 1;
|
|
684
|
-
else hi = mid;
|
|
685
|
-
}
|
|
686
|
-
if (lo === tailsValue.length) {
|
|
687
|
-
tailsValue.push(value);
|
|
688
|
-
tailsIndex.push(i);
|
|
689
|
-
} else {
|
|
690
|
-
tailsValue[lo] = value;
|
|
691
|
-
tailsIndex[lo] = i;
|
|
692
|
-
}
|
|
693
|
-
prev[i] = lo > 0 ? tailsIndex[lo - 1] : -1;
|
|
694
|
-
}
|
|
695
|
-
let cursor = tailsIndex.length > 0 ? tailsIndex[tailsIndex.length - 1] : -1;
|
|
696
|
-
while (cursor >= 0) {
|
|
697
|
-
keep[cursor] = true;
|
|
698
|
-
cursor = prev[cursor];
|
|
699
|
-
}
|
|
700
|
-
return keep;
|
|
701
|
-
}
|
|
702
|
-
__name(computeKeptByLis, "computeKeptByLis");
|
|
703
|
-
function reconcileKeyed(items, keys, entries, renderItem) {
|
|
704
|
-
const previous = new Map(entries.map((entry) => [entry.key, entry]));
|
|
705
|
-
const seen = /* @__PURE__ */ new Set();
|
|
706
|
-
const nextEntries = [];
|
|
707
|
-
for (let index = 0; index < items.length; index++) {
|
|
708
|
-
const item = items[index];
|
|
709
|
-
const key = keys[index];
|
|
710
|
-
if (seen.has(key)) {
|
|
711
|
-
console.warn(`Vobs: \u68C0\u6D4B\u5230\u91CD\u590D\u7684\u5217\u8868 key: ${String(key)}`);
|
|
712
|
-
}
|
|
713
|
-
seen.add(key);
|
|
714
|
-
const entry = previous.get(key);
|
|
715
|
-
if (entry) {
|
|
716
|
-
previous.delete(key);
|
|
717
|
-
if (isPrimitiveItem(item) && !Object.is(entry.value, item)) {
|
|
718
|
-
nextEntries.push(createListEntry(item, index, key, renderItem));
|
|
719
|
-
continue;
|
|
720
|
-
}
|
|
721
|
-
entry.item.value = item;
|
|
722
|
-
entry.value = item;
|
|
723
|
-
nextEntries.push(entry);
|
|
724
|
-
continue;
|
|
725
|
-
}
|
|
726
|
-
nextEntries.push(createListEntry(item, index, key, renderItem));
|
|
727
|
-
}
|
|
728
|
-
return nextEntries;
|
|
729
|
-
}
|
|
730
|
-
__name(reconcileKeyed, "reconcileKeyed");
|
|
731
|
-
function reconcileIndexed(items, entries, renderItem) {
|
|
732
|
-
const nextEntries = [];
|
|
733
|
-
for (let index = 0; index < items.length; index++) {
|
|
734
|
-
const item = items[index];
|
|
735
|
-
const entry = entries[index];
|
|
736
|
-
if (entry && isPrimitiveItem(item) && !Object.is(entry.value, item)) {
|
|
737
|
-
nextEntries.push(createListEntry(item, index, index, renderItem));
|
|
738
|
-
continue;
|
|
739
|
-
}
|
|
740
|
-
if (entry) {
|
|
741
|
-
entry.item.value = item;
|
|
742
|
-
entry.value = item;
|
|
743
|
-
nextEntries.push(entry);
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
nextEntries.push(createListEntry(item, index, index, renderItem));
|
|
747
|
-
}
|
|
748
|
-
return nextEntries;
|
|
749
|
-
}
|
|
750
|
-
__name(reconcileIndexed, "reconcileIndexed");
|
|
751
|
-
function isPrimitiveItem(item) {
|
|
752
|
-
return item === null || typeof item !== "object";
|
|
753
|
-
}
|
|
754
|
-
__name(isPrimitiveItem, "isPrimitiveItem");
|
|
755
|
-
function createListEntry(item, index, key, renderItem) {
|
|
756
|
-
const owner = createOwner();
|
|
757
|
-
let itemSignal;
|
|
758
|
-
let viewOwner;
|
|
759
|
-
let node;
|
|
760
|
-
owner.run(() => {
|
|
761
|
-
itemSignal = state(item);
|
|
762
|
-
viewOwner = createOwner();
|
|
763
|
-
node = viewOwner.run(() => renderItem(toReactiveItem(itemSignal, item), index));
|
|
764
|
-
});
|
|
765
|
-
associateNodeOwner(node, viewOwner);
|
|
766
|
-
return { key, node, owner, viewOwner, item: itemSignal, value: item, index };
|
|
767
|
-
}
|
|
768
|
-
__name(createListEntry, "createListEntry");
|
|
769
|
-
function refreshListEntry(parent, entry, index, renderItem) {
|
|
770
|
-
removeChild(parent, entry.node);
|
|
771
|
-
entry.index = index;
|
|
772
|
-
const previousView = entry.viewOwner;
|
|
773
|
-
entry.owner.run(() => {
|
|
774
|
-
entry.viewOwner = createOwner();
|
|
775
|
-
entry.node = entry.viewOwner.run(() => renderItem(
|
|
776
|
-
toReactiveItem(entry.item, entry.value),
|
|
777
|
-
index
|
|
778
|
-
));
|
|
779
|
-
});
|
|
780
|
-
previousView.dispose();
|
|
781
|
-
associateNodeOwner(entry.node, entry.viewOwner);
|
|
782
|
-
}
|
|
783
|
-
__name(refreshListEntry, "refreshListEntry");
|
|
784
|
-
function toReactiveItem(item, initialValue) {
|
|
785
|
-
if (typeof initialValue !== "object" || initialValue === null) {
|
|
786
|
-
return initialValue;
|
|
787
|
-
}
|
|
788
|
-
return new Proxy(initialValue, {
|
|
789
|
-
get(_target, property, receiver) {
|
|
790
|
-
return Reflect.get(item.value, property, receiver);
|
|
791
|
-
},
|
|
792
|
-
has(_target, property) {
|
|
793
|
-
return property in item.value;
|
|
794
|
-
},
|
|
795
|
-
ownKeys() {
|
|
796
|
-
return Reflect.ownKeys(item.value);
|
|
797
|
-
},
|
|
798
|
-
getOwnPropertyDescriptor(_target, property) {
|
|
799
|
-
return Object.getOwnPropertyDescriptor(item.value, property);
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
__name(toReactiveItem, "toReactiveItem");
|
|
804
|
-
function disposeEntry(parent, entry) {
|
|
805
|
-
removeChild(parent, entry.node);
|
|
806
|
-
entry.owner.dispose();
|
|
807
|
-
}
|
|
808
|
-
__name(disposeEntry, "disposeEntry");
|
|
809
|
-
|
|
810
|
-
// packages/vobs/src/context.ts
|
|
811
|
-
var ownerProviders = /* @__PURE__ */ new WeakMap();
|
|
812
|
-
function inject(key, fallback) {
|
|
813
|
-
const owner = getCurrentOwner();
|
|
814
|
-
const value = owner ? injectFromOwner(owner, key) : void 0;
|
|
815
|
-
return value === void 0 ? fallback : value;
|
|
816
|
-
}
|
|
817
|
-
__name(inject, "inject");
|
|
818
|
-
function injectFromOwner(owner, key) {
|
|
819
|
-
let current = owner;
|
|
820
|
-
while (current) {
|
|
821
|
-
const providers = ownerProviders.get(current);
|
|
822
|
-
if (providers?.has(key)) return providers.get(key);
|
|
823
|
-
current = current.parent;
|
|
824
|
-
}
|
|
825
|
-
return void 0;
|
|
826
|
-
}
|
|
827
|
-
__name(injectFromOwner, "injectFromOwner");
|
|
828
|
-
|
|
829
|
-
// packages/vobs/src/app.ts
|
|
830
|
-
function createInjectionKey(description) {
|
|
831
|
-
return Symbol(description);
|
|
832
|
-
}
|
|
833
|
-
__name(createInjectionKey, "createInjectionKey");
|
|
834
|
-
|
|
835
|
-
// packages/notification/src/index.ts
|
|
836
|
-
var _NotificationError = class _NotificationError extends Error {
|
|
837
|
-
constructor(code, message) {
|
|
838
|
-
super(message);
|
|
839
|
-
this.name = "NotificationError";
|
|
840
|
-
this.code = code;
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
__name(_NotificationError, "NotificationError");
|
|
844
|
-
var NotificationError = _NotificationError;
|
|
845
|
-
var NOTIFICATION_KEY = createInjectionKey("vobs.notification");
|
|
846
|
-
function useNotification() {
|
|
847
|
-
const notification = inject(NOTIFICATION_KEY);
|
|
848
|
-
if (!notification) {
|
|
849
|
-
throw new NotificationError("NOTIFICATION_CONTEXT_MISSING", "Vobs Notification: \u627E\u4E0D\u5230\u4E0A\u4E0B\u6587\uFF0C\u8BF7\u5B89\u88C5 notificationPlugin");
|
|
850
|
-
}
|
|
851
|
-
return notification;
|
|
852
|
-
}
|
|
853
|
-
__name(useNotification, "useNotification");
|
|
4
|
+
// packages/ui/src/toast.ts
|
|
5
|
+
import { insertList } from "@vobs/vobs";
|
|
6
|
+
import {
|
|
7
|
+
addEventListener as addEventListener2,
|
|
8
|
+
createElement,
|
|
9
|
+
createText as createText2,
|
|
10
|
+
insertBefore as insertBefore3,
|
|
11
|
+
setAttribute as setAttribute2
|
|
12
|
+
} from "@vobs/vobs";
|
|
13
|
+
import { useNotification } from "@vobs/notification";
|
|
854
14
|
|
|
855
|
-
// packages/
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
});
|
|
861
|
-
return root;
|
|
862
|
-
}
|
|
863
|
-
__name(createSvgIconNode, "createSvgIconNode");
|
|
864
|
-
function updateSvgIconNode(root, definition, props, options) {
|
|
865
|
-
const size = readProp(props, "size", void 0);
|
|
866
|
-
const width = readProp(props, "width", size);
|
|
867
|
-
const height = readProp(props, "height", size);
|
|
868
|
-
const normalizedWidth = normalizeSvgLength(width);
|
|
869
|
-
const normalizedHeight = normalizeSvgLength(height);
|
|
870
|
-
const userClass = [
|
|
871
|
-
readProp(props, "class", void 0),
|
|
872
|
-
readProp(props, "className", void 0)
|
|
873
|
-
].filter(hasText).join(" ");
|
|
874
|
-
const className = [options.class, options.className, userClass].filter(hasText).join(" ");
|
|
875
|
-
setAttribute(root, "class", className);
|
|
876
|
-
const internalStyle = size === void 0 ? "" : `width: ${normalizeCssLength(size)}; height: ${normalizeCssLength(size)}`;
|
|
877
|
-
const userStyle = readProp(props, "style", void 0);
|
|
878
|
-
const style = [internalStyle, userStyle].filter(hasText).join("; ");
|
|
879
|
-
setOptionalAttribute(root, "style", style || void 0);
|
|
880
|
-
const managedAttributes2 = /* @__PURE__ */ new Map();
|
|
881
|
-
for (const name of Object.keys(props)) {
|
|
882
|
-
if (name === "class" || name === "className" || name === "style" || name === "children") continue;
|
|
883
|
-
if (!name.startsWith("aria-") && !name.startsWith("data-") && !["id", "title", "role", "tabIndex"].includes(name)) continue;
|
|
884
|
-
const value = Reflect.get(props, name);
|
|
885
|
-
if (value === void 0 || value === null || value === false) continue;
|
|
886
|
-
managedAttributes2.set(name === "tabIndex" ? "tabindex" : name, String(value));
|
|
887
|
-
}
|
|
888
|
-
for (const [name, value] of managedAttributes2) setAttribute(root, name, value);
|
|
889
|
-
clearStaleAttributes(root, managedAttributes2);
|
|
890
|
-
const title = readProp(props, "title", void 0);
|
|
891
|
-
const ariaLabel = Reflect.get(props, "aria-label");
|
|
892
|
-
const decorative = readProp(props, "decorative", title === void 0 && ariaLabel === void 0);
|
|
893
|
-
setOptionalAttribute(root, "aria-hidden", decorative ? "true" : void 0);
|
|
894
|
-
setOptionalAttribute(root, "aria-label", ariaLabel === void 0 ? title : void 0);
|
|
895
|
-
setOptionalAttribute(root, "data-icon-name", options.dataIconName ?? definition?.name);
|
|
896
|
-
setOptionalAttribute(root, "color", readProp(props, "color", void 0));
|
|
897
|
-
if (!definition) {
|
|
898
|
-
setProperty(root, "innerHTML", "");
|
|
899
|
-
return;
|
|
900
|
-
}
|
|
901
|
-
const svgAttributes = {
|
|
902
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
903
|
-
viewBox: definition.viewBox ?? "0 0 24 24",
|
|
904
|
-
...options.defaultSvgAttributes,
|
|
905
|
-
...definition.attributes,
|
|
906
|
-
...normalizedWidth === void 0 ? {} : { width: normalizedWidth },
|
|
907
|
-
...normalizedHeight === void 0 ? {} : { height: normalizedHeight },
|
|
908
|
-
...readProp(props, "color", void 0) === void 0 ? {} : { color: readProp(props, "color", void 0) },
|
|
909
|
-
...readProp(props, "stroke", void 0) === void 0 ? {} : { stroke: readProp(props, "stroke", void 0) },
|
|
910
|
-
...readProp(props, "fill", void 0) === void 0 ? {} : { fill: readProp(props, "fill", void 0) },
|
|
911
|
-
...readProp(props, "strokeWidth", void 0) === void 0 ? {} : { "stroke-width": readProp(props, "strokeWidth", void 0) }
|
|
912
|
-
};
|
|
913
|
-
const markup = Object.entries(svgAttributes).filter(([, value]) => value !== void 0).map(([name, value]) => `${name}="${escapeXml(String(value))}"`).join(" ");
|
|
914
|
-
const titleMarkup = title === void 0 ? "" : `<title>${escapeXml(title)}</title>`;
|
|
915
|
-
setProperty(root, "innerHTML", `<svg ${markup} aria-hidden="true">${titleMarkup}${definition.body}</svg>`);
|
|
916
|
-
}
|
|
917
|
-
__name(updateSvgIconNode, "updateSvgIconNode");
|
|
918
|
-
function readProp(props, name, fallback) {
|
|
919
|
-
const value = Reflect.get(props, name);
|
|
920
|
-
return value === void 0 ? fallback : value;
|
|
921
|
-
}
|
|
922
|
-
__name(readProp, "readProp");
|
|
923
|
-
function hasText(value) {
|
|
924
|
-
return value !== void 0 && value.trim() !== "";
|
|
925
|
-
}
|
|
926
|
-
__name(hasText, "hasText");
|
|
927
|
-
function normalizeSvgLength(value) {
|
|
928
|
-
if (value === void 0) return void 0;
|
|
929
|
-
return typeof value === "number" ? String(value) : value;
|
|
930
|
-
}
|
|
931
|
-
__name(normalizeSvgLength, "normalizeSvgLength");
|
|
932
|
-
function normalizeCssLength(value) {
|
|
933
|
-
return typeof value === "number" || /^\d+(?:\.\d+)?$/u.test(value) ? `${value}px` : value;
|
|
934
|
-
}
|
|
935
|
-
__name(normalizeCssLength, "normalizeCssLength");
|
|
936
|
-
function setOptionalAttribute(node, name, value) {
|
|
937
|
-
if (value === void 0 || value === null || value === false || value === "") {
|
|
938
|
-
node.removeAttribute(name);
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
setAttribute(node, name, String(value));
|
|
942
|
-
}
|
|
943
|
-
__name(setOptionalAttribute, "setOptionalAttribute");
|
|
944
|
-
function clearStaleAttributes(node, next) {
|
|
945
|
-
const previous = node.__vobsIconAttributes ?? /* @__PURE__ */ new Set();
|
|
946
|
-
for (const name of previous) {
|
|
947
|
-
if (!next.has(name)) node.removeAttribute(name);
|
|
948
|
-
}
|
|
949
|
-
node.__vobsIconAttributes = new Set(next.keys());
|
|
950
|
-
}
|
|
951
|
-
__name(clearStaleAttributes, "clearStaleAttributes");
|
|
952
|
-
function escapeXml(value) {
|
|
953
|
-
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
954
|
-
}
|
|
955
|
-
__name(escapeXml, "escapeXml");
|
|
15
|
+
// packages/ui/src/icon.ts
|
|
16
|
+
import {
|
|
17
|
+
createIcon,
|
|
18
|
+
createSvgIconNode
|
|
19
|
+
} from "@vobs/icon-core";
|
|
956
20
|
|
|
957
21
|
// packages/ui/src/utils.ts
|
|
22
|
+
import { effect } from "@vobs/reactivity";
|
|
23
|
+
import {
|
|
24
|
+
addEventListener,
|
|
25
|
+
createFragment,
|
|
26
|
+
createText,
|
|
27
|
+
insertBefore,
|
|
28
|
+
insertDynamic,
|
|
29
|
+
setAttribute,
|
|
30
|
+
setProperty,
|
|
31
|
+
setTextContent
|
|
32
|
+
} from "@vobs/vobs";
|
|
958
33
|
function classNames(...values) {
|
|
959
34
|
return values.flatMap((value) => typeof value === "string" ? value.trim().split(/\s+/u) : []).filter(Boolean).join(" ");
|
|
960
35
|
}
|
|
961
36
|
__name(classNames, "classNames");
|
|
962
|
-
function
|
|
37
|
+
function readProp(props, name, fallback) {
|
|
963
38
|
const value = Reflect.get(props, name);
|
|
964
39
|
return value === void 0 ? fallback : value;
|
|
965
40
|
}
|
|
966
|
-
__name(
|
|
41
|
+
__name(readProp, "readProp");
|
|
967
42
|
function hasProp(props, name) {
|
|
968
43
|
return name in props;
|
|
969
44
|
}
|
|
@@ -1071,7 +146,7 @@ __name(removeAttribute, "removeAttribute");
|
|
|
1071
146
|
function Icon(props = {}) {
|
|
1072
147
|
const root = createSvgIconNode(() => {
|
|
1073
148
|
const definition = resolveIcon(
|
|
1074
|
-
|
|
149
|
+
readProp(props, "icon", void 0) ?? readProp(props, "name", void 0)
|
|
1075
150
|
);
|
|
1076
151
|
if (!definition) {
|
|
1077
152
|
if (hasProp(props, "children")) return void 0;
|
|
@@ -1155,6 +230,12 @@ function resolveIcon(icon) {
|
|
|
1155
230
|
__name(resolveIcon, "resolveIcon");
|
|
1156
231
|
|
|
1157
232
|
// packages/ui/src/overlay.ts
|
|
233
|
+
import { getCurrentOwner, onDispose } from "@vobs/reactivity";
|
|
234
|
+
import {
|
|
235
|
+
createComment,
|
|
236
|
+
insertBefore as insertBefore2,
|
|
237
|
+
isVobsFragment
|
|
238
|
+
} from "@vobs/vobs";
|
|
1158
239
|
function createPortal(node, adapter, target) {
|
|
1159
240
|
const placeholder = createComment("vui:portal");
|
|
1160
241
|
const owner = getCurrentOwner();
|
|
@@ -1165,6 +246,19 @@ function createPortal(node, adapter, target) {
|
|
|
1165
246
|
return placeholder;
|
|
1166
247
|
}
|
|
1167
248
|
__name(createPortal, "createPortal");
|
|
249
|
+
var FOCUSABLE_SELECTOR = [
|
|
250
|
+
"a[href]",
|
|
251
|
+
"area[href]",
|
|
252
|
+
"button",
|
|
253
|
+
"input",
|
|
254
|
+
"select",
|
|
255
|
+
"textarea",
|
|
256
|
+
"iframe",
|
|
257
|
+
"object",
|
|
258
|
+
"embed",
|
|
259
|
+
"[contenteditable]",
|
|
260
|
+
"[tabindex]"
|
|
261
|
+
].join(",");
|
|
1168
262
|
|
|
1169
263
|
// packages/ui/src/toast.ts
|
|
1170
264
|
function ToastHost(props = {}) {
|
|
@@ -1172,46 +266,46 @@ function ToastHost(props = {}) {
|
|
|
1172
266
|
const root = createElement("ol");
|
|
1173
267
|
bindClassList(root, props, () => [
|
|
1174
268
|
"vui-toast-host",
|
|
1175
|
-
`vui-toast-host--${
|
|
269
|
+
`vui-toast-host--${readProp(props, "position", "top-right")}`
|
|
1176
270
|
]);
|
|
1177
271
|
bindCommonAttributes(root, props, ["notification", "position", "closeLabel", "portal", "portalTarget"]);
|
|
1178
272
|
bindUserStyle(root, props);
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
insertList(root, null, () => notification.notifications.value, (entry) => createToast(entry, notification,
|
|
1182
|
-
const portal =
|
|
1183
|
-
return portal ? createPortal(root, portal,
|
|
273
|
+
setAttribute2(root, "aria-label", "Notifications");
|
|
274
|
+
setAttribute2(root, "role", "region");
|
|
275
|
+
insertList(root, null, () => notification.notifications.value, (entry) => createToast(entry, notification, readProp(props, "closeLabel", "Dismiss notification")), (entry) => entry.id);
|
|
276
|
+
const portal = readProp(props, "portal", void 0);
|
|
277
|
+
return portal ? createPortal(root, portal, readProp(props, "portalTarget", void 0)) : root;
|
|
1184
278
|
}
|
|
1185
279
|
__name(ToastHost, "ToastHost");
|
|
1186
280
|
function createToast(notification, context, closeLabel) {
|
|
1187
281
|
const item = createElement("li");
|
|
1188
282
|
const content = createElement("div");
|
|
1189
283
|
const close = createElement("button");
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
284
|
+
setAttribute2(item, "class", `vui-toast vui-toast--${notification.type}`);
|
|
285
|
+
setAttribute2(item, "data-notification-id", notification.id);
|
|
286
|
+
setAttribute2(item, "role", notification.type === "error" ? "alert" : "status");
|
|
287
|
+
setAttribute2(content, "class", "vui-toast__content");
|
|
288
|
+
setAttribute2(close, "class", "vui-toast__close");
|
|
289
|
+
setAttribute2(close, "type", "button");
|
|
290
|
+
setAttribute2(close, "aria-label", closeLabel);
|
|
291
|
+
addEventListener2(close, "click", () => context.dismiss(notification.id));
|
|
1198
292
|
if (notification.title) {
|
|
1199
293
|
const title = createElement("div");
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
294
|
+
setAttribute2(title, "class", "vui-toast__title");
|
|
295
|
+
insertBefore3(title, createText2(notification.title), null);
|
|
296
|
+
insertBefore3(content, title, null);
|
|
1203
297
|
}
|
|
1204
298
|
const message = createElement("div");
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
299
|
+
setAttribute2(message, "class", "vui-toast__message");
|
|
300
|
+
insertBefore3(message, createText2(notification.content), null);
|
|
301
|
+
insertBefore3(content, message, null);
|
|
302
|
+
insertBefore3(close, Icon({ name: "x", size: 16, decorative: true }), null);
|
|
303
|
+
insertBefore3(item, content, null);
|
|
304
|
+
insertBefore3(item, close, null);
|
|
1211
305
|
return item;
|
|
1212
306
|
}
|
|
1213
307
|
__name(createToast, "createToast");
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
308
|
+
export {
|
|
309
|
+
ToastHost
|
|
310
|
+
};
|
|
1217
311
|
//# sourceMappingURL=toast.js.map
|