sibujs 1.0.0-beta.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +47 -67
- package/dist/browser.js +3 -3
- package/dist/build.cjs +251 -84
- package/dist/build.js +9 -9
- package/dist/cdn.global.js +4 -4
- package/dist/chunk-2GLUWW3D.js +567 -0
- package/dist/chunk-3GZTRYSY.js +33 -0
- package/dist/chunk-526ENZ77.js +58 -0
- package/dist/chunk-5KBEED6D.js +361 -0
- package/dist/chunk-5LJMSKBB.js +26 -0
- package/dist/chunk-5M7LJFWV.js +271 -0
- package/dist/chunk-5ZFVYPDG.js +97 -0
- package/dist/chunk-6EYXAMBN.js +1857 -0
- package/dist/chunk-6J6S4NI7.js +398 -0
- package/dist/chunk-6NBHAKHS.js +1997 -0
- package/dist/chunk-7LS3ITZB.js +567 -0
- package/dist/chunk-ANRSGGFC.js +725 -0
- package/dist/chunk-B4ASD5VC.js +295 -0
- package/dist/chunk-BG3HMX4C.js +271 -0
- package/dist/chunk-BS6ETCJ7.js +949 -0
- package/dist/chunk-BTTBAGD3.js +365 -0
- package/dist/chunk-BWBWJYBK.js +271 -0
- package/dist/chunk-DB243LB7.js +877 -0
- package/dist/chunk-DEQLPROY.js +1094 -0
- package/dist/chunk-DGUYCZJH.js +654 -0
- package/dist/chunk-DLWLJZB3.js +712 -0
- package/dist/chunk-EJMSUPXQ.js +346 -0
- package/dist/chunk-FYIGTFXO.js +712 -0
- package/dist/chunk-GXIM4TC3.js +346 -0
- package/dist/chunk-HKUNBYN6.js +949 -0
- package/dist/chunk-HZWNWUPJ.js +466 -0
- package/dist/chunk-I6EZTMPB.js +949 -0
- package/dist/chunk-IK3NFZOA.js +466 -0
- package/dist/chunk-JRWAHOMS.js +41 -0
- package/dist/chunk-KALKXPC3.js +297 -0
- package/dist/chunk-KKUV25KB.js +361 -0
- package/dist/chunk-LHI25KS2.js +654 -0
- package/dist/chunk-LHNJSLC6.js +297 -0
- package/dist/chunk-M3ZKZQNY.js +282 -0
- package/dist/chunk-MBINISSE.js +35 -0
- package/dist/chunk-MGYRVG2A.js +282 -0
- package/dist/chunk-MLN3JZ2E.js +398 -0
- package/dist/chunk-N7UVR6SG.js +877 -0
- package/dist/chunk-NMTRH4Q3.js +97 -0
- package/dist/chunk-OEGAHDEU.js +1094 -0
- package/dist/chunk-OXYMB6VB.js +466 -0
- package/dist/chunk-OZS4YOOP.js +59 -0
- package/dist/chunk-PMVU6BI4.js +1847 -0
- package/dist/chunk-QLNWSBWK.js +567 -0
- package/dist/chunk-QUGIYF3F.js +712 -0
- package/dist/chunk-QYSW3K7A.js +282 -0
- package/dist/chunk-QZWTKX5K.js +321 -0
- package/dist/chunk-RUAJTILD.js +26 -0
- package/dist/chunk-S6YEHFC7.js +654 -0
- package/dist/chunk-SU63HSUU.js +58 -0
- package/dist/chunk-T2SPHHYU.js +365 -0
- package/dist/chunk-TCWKKKPP.js +90 -0
- package/dist/chunk-UATXXETW.js +278 -0
- package/dist/chunk-UXDIPRCG.js +26 -0
- package/dist/chunk-UZZFP2EE.js +35 -0
- package/dist/chunk-V4G5Y6YM.js +1094 -0
- package/dist/chunk-VAA4FG3Z.js +365 -0
- package/dist/chunk-VUXB655T.js +1999 -0
- package/dist/chunk-XJ3MNGY5.js +58 -0
- package/dist/chunk-XZGY5ZJ4.js +35 -0
- package/dist/chunk-Z6GZHJW5.js +877 -0
- package/dist/customElement-BKQfbSZQ.d.cts +262 -0
- package/dist/customElement-BKQfbSZQ.d.ts +262 -0
- package/dist/data.cjs +50 -72
- package/dist/data.js +5 -5
- package/dist/devtools.cjs +45 -65
- package/dist/devtools.js +3 -3
- package/dist/ecosystem.cjs +59 -76
- package/dist/ecosystem.js +6 -6
- package/dist/extras.cjs +140 -81
- package/dist/extras.d.cts +2 -2
- package/dist/extras.d.ts +2 -2
- package/dist/extras.js +22 -20
- package/dist/index.cjs +261 -85
- package/dist/index.d.cts +199 -8
- package/dist/index.d.ts +199 -8
- package/dist/index.js +31 -13
- package/dist/motion.cjs +80 -57
- package/dist/motion.d.cts +43 -1
- package/dist/motion.d.ts +43 -1
- package/dist/motion.js +4 -2
- package/dist/patterns.cjs +48 -70
- package/dist/patterns.js +4 -4
- package/dist/performance.cjs +27 -57
- package/dist/performance.js +2 -2
- package/dist/plugins.cjs +82 -74
- package/dist/plugins.js +8 -8
- package/dist/ssr-GEOEYQV7.js +35 -0
- package/dist/ssr.cjs +84 -76
- package/dist/ssr.js +7 -7
- package/dist/ui.cjs +87 -71
- package/dist/ui.d.cts +25 -261
- package/dist/ui.d.ts +25 -261
- package/dist/ui.js +41 -5
- package/dist/widgets.cjs +39 -69
- package/dist/widgets.js +4 -4
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
|
@@ -36,7 +36,24 @@ __export(browser_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(browser_exports);
|
|
38
38
|
|
|
39
|
+
// src/core/dev.ts
|
|
40
|
+
function isDev() {
|
|
41
|
+
return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : true;
|
|
42
|
+
}
|
|
43
|
+
var _isDev = isDev();
|
|
44
|
+
function devAssert(condition, message) {
|
|
45
|
+
if (_isDev && !condition) {
|
|
46
|
+
throw new Error(`[Sibu] ${message}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function devWarn(message) {
|
|
50
|
+
if (_isDev) {
|
|
51
|
+
console.warn(`[Sibu] ${message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
// src/reactivity/track.ts
|
|
56
|
+
var _isDev2 = isDev();
|
|
40
57
|
var subscriberStack = new Array(32);
|
|
41
58
|
var stackCapacity = 32;
|
|
42
59
|
var stackTop = -1;
|
|
@@ -46,8 +63,13 @@ var SUBS = "__s";
|
|
|
46
63
|
var notifyDepth = 0;
|
|
47
64
|
var pendingQueue = [];
|
|
48
65
|
var pendingSet = /* @__PURE__ */ new Set();
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
function safeInvoke(sub) {
|
|
67
|
+
try {
|
|
68
|
+
sub();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
51
73
|
function track(effectFn, subscriber) {
|
|
52
74
|
if (!subscriber) subscriber = effectFn;
|
|
53
75
|
cleanup(subscriber);
|
|
@@ -66,27 +88,6 @@ function track(effectFn, subscriber) {
|
|
|
66
88
|
}
|
|
67
89
|
return () => cleanup(subscriber);
|
|
68
90
|
}
|
|
69
|
-
function suspendTracking() {
|
|
70
|
-
if (suspendDepth === 0) {
|
|
71
|
-
++stackTop;
|
|
72
|
-
if (stackTop >= stackCapacity) {
|
|
73
|
-
stackCapacity *= 2;
|
|
74
|
-
subscriberStack.length = stackCapacity;
|
|
75
|
-
}
|
|
76
|
-
subscriberStack[stackTop] = null;
|
|
77
|
-
currentSubscriber = null;
|
|
78
|
-
trackingSuspended = true;
|
|
79
|
-
}
|
|
80
|
-
suspendDepth++;
|
|
81
|
-
}
|
|
82
|
-
function resumeTracking() {
|
|
83
|
-
suspendDepth--;
|
|
84
|
-
if (suspendDepth === 0) {
|
|
85
|
-
stackTop--;
|
|
86
|
-
currentSubscriber = stackTop >= 0 ? subscriberStack[stackTop] : null;
|
|
87
|
-
trackingSuspended = false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
91
|
function recordDependency(signal2) {
|
|
91
92
|
if (!currentSubscriber) return;
|
|
92
93
|
const sub = currentSubscriber;
|
|
@@ -135,7 +136,7 @@ function drainNotificationQueue() {
|
|
|
135
136
|
try {
|
|
136
137
|
let i = 0;
|
|
137
138
|
while (i < pendingQueue.length) {
|
|
138
|
-
pendingQueue[i]
|
|
139
|
+
safeInvoke(pendingQueue[i]);
|
|
139
140
|
i++;
|
|
140
141
|
}
|
|
141
142
|
} finally {
|
|
@@ -147,30 +148,12 @@ function drainNotificationQueue() {
|
|
|
147
148
|
function propagateDirty(sub) {
|
|
148
149
|
sub();
|
|
149
150
|
let sig = sub._sig;
|
|
150
|
-
let suspended = false;
|
|
151
|
-
if (sig && sig._g) {
|
|
152
|
-
const isSingleDep = sub._dep !== void 0 || sub._deps && sub._deps.size === 1;
|
|
153
|
-
if (isSingleDep) {
|
|
154
|
-
suspendTracking();
|
|
155
|
-
suspended = true;
|
|
156
|
-
const s = sig;
|
|
157
|
-
s._d = false;
|
|
158
|
-
s._v = s._g();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
151
|
while (sig) {
|
|
162
152
|
const first = sig.__f;
|
|
163
153
|
if (first) {
|
|
164
154
|
if (first._c) {
|
|
165
155
|
const nSig = first._sig;
|
|
166
156
|
nSig._d = true;
|
|
167
|
-
if (suspended && nSig._g) {
|
|
168
|
-
const fSingleDep = first._dep !== void 0 || first._deps && first._deps.size === 1;
|
|
169
|
-
if (fSingleDep) {
|
|
170
|
-
nSig._d = false;
|
|
171
|
-
nSig._v = nSig._g();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
157
|
sig = nSig;
|
|
175
158
|
continue;
|
|
176
159
|
}
|
|
@@ -199,7 +182,6 @@ function propagateDirty(sub) {
|
|
|
199
182
|
}
|
|
200
183
|
sig = nextSig;
|
|
201
184
|
}
|
|
202
|
-
if (suspended) resumeTracking();
|
|
203
185
|
}
|
|
204
186
|
function notifySubscribers(signal2) {
|
|
205
187
|
const first = signal2.__f;
|
|
@@ -218,11 +200,11 @@ function notifySubscribers(signal2) {
|
|
|
218
200
|
if (first._c) {
|
|
219
201
|
propagateDirty(first);
|
|
220
202
|
} else {
|
|
221
|
-
first
|
|
203
|
+
safeInvoke(first);
|
|
222
204
|
}
|
|
223
205
|
let i = 0;
|
|
224
206
|
while (i < pendingQueue.length) {
|
|
225
|
-
pendingQueue[i]
|
|
207
|
+
safeInvoke(pendingQueue[i]);
|
|
226
208
|
i++;
|
|
227
209
|
}
|
|
228
210
|
} finally {
|
|
@@ -259,13 +241,13 @@ function notifySubscribers(signal2) {
|
|
|
259
241
|
for (let i2 = 0; i2 < directCount; i2++) {
|
|
260
242
|
if (!pendingQueue[i2]._c) {
|
|
261
243
|
if (!pendingSet.has(pendingQueue[i2])) {
|
|
262
|
-
pendingQueue[i2]
|
|
244
|
+
safeInvoke(pendingQueue[i2]);
|
|
263
245
|
}
|
|
264
246
|
}
|
|
265
247
|
}
|
|
266
248
|
let i = directCount;
|
|
267
249
|
while (i < pendingQueue.length) {
|
|
268
|
-
pendingQueue[i]
|
|
250
|
+
safeInvoke(pendingQueue[i]);
|
|
269
251
|
i++;
|
|
270
252
|
}
|
|
271
253
|
} finally {
|
|
@@ -308,7 +290,7 @@ var pendingSignals = /* @__PURE__ */ new Set();
|
|
|
308
290
|
function batch(fn) {
|
|
309
291
|
batchDepth++;
|
|
310
292
|
try {
|
|
311
|
-
fn();
|
|
293
|
+
return fn();
|
|
312
294
|
} finally {
|
|
313
295
|
batchDepth--;
|
|
314
296
|
if (batchDepth === 0) {
|
|
@@ -329,23 +311,13 @@ function flushBatch() {
|
|
|
329
311
|
drainNotificationQueue();
|
|
330
312
|
}
|
|
331
313
|
|
|
332
|
-
// src/core/dev.ts
|
|
333
|
-
function isDev() {
|
|
334
|
-
return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : true;
|
|
335
|
-
}
|
|
336
|
-
var _isDev = isDev();
|
|
337
|
-
function devAssert(condition, message) {
|
|
338
|
-
if (_isDev && !condition) {
|
|
339
|
-
throw new Error(`[Sibu] ${message}`);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
314
|
// src/core/signals/signal.ts
|
|
344
315
|
var _g = globalThis;
|
|
345
|
-
var
|
|
316
|
+
var _isDev3 = isDev();
|
|
346
317
|
function signal(initial, options) {
|
|
347
318
|
const state = { value: initial };
|
|
348
|
-
const debugName =
|
|
319
|
+
const debugName = _isDev3 ? options?.name : void 0;
|
|
320
|
+
const equalsFn = options?.equals;
|
|
349
321
|
if (debugName) {
|
|
350
322
|
state.__name = debugName;
|
|
351
323
|
}
|
|
@@ -357,8 +329,8 @@ function signal(initial, options) {
|
|
|
357
329
|
if (debugName) get.__name = debugName;
|
|
358
330
|
function set(next) {
|
|
359
331
|
const newValue = typeof next === "function" ? next(state.value) : next;
|
|
360
|
-
if (Object.is(newValue, state.value)) return;
|
|
361
|
-
if (
|
|
332
|
+
if (equalsFn ? equalsFn(state.value, newValue) : Object.is(newValue, state.value)) return;
|
|
333
|
+
if (_isDev3) {
|
|
362
334
|
const oldValue = state.value;
|
|
363
335
|
state.value = newValue;
|
|
364
336
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
@@ -370,7 +342,7 @@ function signal(initial, options) {
|
|
|
370
342
|
notifySubscribers(state);
|
|
371
343
|
}
|
|
372
344
|
}
|
|
373
|
-
if (
|
|
345
|
+
if (_isDev3) {
|
|
374
346
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
375
347
|
if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
|
|
376
348
|
}
|
|
@@ -404,17 +376,25 @@ function isSSR() {
|
|
|
404
376
|
|
|
405
377
|
// src/core/signals/effect.ts
|
|
406
378
|
var _g2 = globalThis;
|
|
407
|
-
function effect(effectFn) {
|
|
379
|
+
function effect(effectFn, options) {
|
|
408
380
|
devAssert(typeof effectFn === "function", "effect: argument must be a function.");
|
|
409
381
|
if (isSSR()) return () => {
|
|
410
382
|
};
|
|
383
|
+
const onError = options?.onError;
|
|
384
|
+
const wrappedFn = onError ? () => {
|
|
385
|
+
try {
|
|
386
|
+
effectFn();
|
|
387
|
+
} catch (err) {
|
|
388
|
+
onError(err);
|
|
389
|
+
}
|
|
390
|
+
} : effectFn;
|
|
411
391
|
let cleanupHandle = () => {
|
|
412
392
|
};
|
|
413
393
|
const subscriber = () => {
|
|
414
394
|
cleanupHandle();
|
|
415
|
-
cleanupHandle = track(
|
|
395
|
+
cleanupHandle = track(wrappedFn, subscriber);
|
|
416
396
|
};
|
|
417
|
-
cleanupHandle = track(
|
|
397
|
+
cleanupHandle = track(wrappedFn, subscriber);
|
|
418
398
|
const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
419
399
|
if (hook) hook.emit("effect:create", { effectFn });
|
|
420
400
|
return () => {
|
package/dist/browser.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
resize,
|
|
13
13
|
scroll,
|
|
14
14
|
title
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-IK3NFZOA.js";
|
|
16
|
+
import "./chunk-OZS4YOOP.js";
|
|
17
17
|
import "./chunk-CHJ27IGK.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-KKUV25KB.js";
|
|
19
19
|
import "./chunk-MLKGABMK.js";
|
|
20
20
|
export {
|
|
21
21
|
battery,
|