sibujs 1.0.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +53 -18
  4. package/dist/build.js +17 -10
  5. package/dist/cdn.global.js +6 -6
  6. package/dist/chunk-23VV7YD3.js +107 -0
  7. package/dist/chunk-3ARAQO7B.js +398 -0
  8. package/dist/chunk-6SA3QQES.js +61 -0
  9. package/dist/chunk-7BF6TK55.js +1097 -0
  10. package/dist/chunk-B7SWRFUT.js +332 -0
  11. package/dist/chunk-BW3WT46K.js +937 -0
  12. package/dist/chunk-C6KFWOFV.js +616 -0
  13. package/dist/chunk-EVCZO745.js +365 -0
  14. package/dist/chunk-GCOK2LC3.js +282 -0
  15. package/dist/chunk-L6JRBDNS.js +60 -0
  16. package/dist/chunk-LA6KQEDU.js +712 -0
  17. package/dist/chunk-MK4ERFYL.js +2249 -0
  18. package/dist/chunk-NHUC2QWH.js +282 -0
  19. package/dist/chunk-OUZZEE4S.js +365 -0
  20. package/dist/chunk-P6W3STU4.js +2249 -0
  21. package/dist/chunk-RQGQSLQK.js +725 -0
  22. package/dist/chunk-TNQWPPE6.js +37 -0
  23. package/dist/chunk-UNXCEF6S.js +21 -0
  24. package/dist/chunk-V2XTI523.js +347 -0
  25. package/dist/chunk-VMVDTCXB.js +712 -0
  26. package/dist/chunk-WADYRCO2.js +304 -0
  27. package/dist/chunk-WILQZRO4.js +282 -0
  28. package/dist/chunk-WR5D4EGH.js +26 -0
  29. package/dist/chunk-WUHJISPP.js +298 -0
  30. package/dist/chunk-YUTWTI4B.js +654 -0
  31. package/dist/chunk-Z6POF5YC.js +975 -0
  32. package/dist/chunk-ZBJP6WFL.js +482 -0
  33. package/dist/data.cjs +1 -1
  34. package/dist/data.js +6 -6
  35. package/dist/devtools.cjs +1 -1
  36. package/dist/devtools.js +4 -4
  37. package/dist/ecosystem.cjs +46 -18
  38. package/dist/ecosystem.js +7 -7
  39. package/dist/extras.cjs +53 -19
  40. package/dist/extras.js +21 -21
  41. package/dist/index.cjs +46 -18
  42. package/dist/index.d.cts +24 -8
  43. package/dist/index.d.ts +24 -8
  44. package/dist/index.js +10 -10
  45. package/dist/motion.cjs +1 -1
  46. package/dist/motion.js +3 -3
  47. package/dist/patterns.cjs +8 -2
  48. package/dist/patterns.js +5 -5
  49. package/dist/performance.cjs +1 -1
  50. package/dist/performance.js +3 -3
  51. package/dist/plugins.cjs +46 -18
  52. package/dist/plugins.js +9 -9
  53. package/dist/ssr-3RXHP5ES.js +38 -0
  54. package/dist/ssr.cjs +46 -18
  55. package/dist/ssr.d.cts +9 -0
  56. package/dist/ssr.d.ts +9 -0
  57. package/dist/ssr.js +8 -8
  58. package/dist/ui.cjs +1 -1
  59. package/dist/ui.js +6 -6
  60. package/dist/widgets.cjs +1 -1
  61. package/dist/widgets.js +5 -5
  62. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ import {
2
+ isSSR
3
+ } from "./chunk-CHJ27IGK.js";
4
+ import {
5
+ track
6
+ } from "./chunk-V2XTI523.js";
7
+ import {
8
+ devAssert
9
+ } from "./chunk-UNXCEF6S.js";
10
+
11
+ // src/core/signals/watch.ts
12
+ function watch(getter, callback) {
13
+ devAssert(typeof getter === "function", "watch: first argument must be a getter function.");
14
+ devAssert(typeof callback === "function", "watch: second argument must be a callback function.");
15
+ if (isSSR()) return () => {
16
+ };
17
+ let oldValue;
18
+ let first = true;
19
+ const subscriber = () => {
20
+ const newValue = getter();
21
+ if (first) {
22
+ oldValue = newValue;
23
+ first = false;
24
+ return;
25
+ }
26
+ if (!Object.is(newValue, oldValue)) {
27
+ callback(newValue, oldValue);
28
+ oldValue = newValue;
29
+ }
30
+ };
31
+ const teardown = track(subscriber);
32
+ return teardown;
33
+ }
34
+
35
+ export {
36
+ watch
37
+ };
@@ -0,0 +1,21 @@
1
+ // src/core/dev.ts
2
+ function isDev() {
3
+ return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
4
+ }
5
+ var _isDev = isDev();
6
+ function devAssert(condition, message) {
7
+ if (_isDev && !condition) {
8
+ throw new Error(`[Sibu] ${message}`);
9
+ }
10
+ }
11
+ function devWarn(message) {
12
+ if (_isDev) {
13
+ console.warn(`[Sibu] ${message}`);
14
+ }
15
+ }
16
+
17
+ export {
18
+ isDev,
19
+ devAssert,
20
+ devWarn
21
+ };
@@ -0,0 +1,347 @@
1
+ import {
2
+ devWarn,
3
+ isDev
4
+ } from "./chunk-UNXCEF6S.js";
5
+
6
+ // src/reactivity/track.ts
7
+ var _isDev = isDev();
8
+ var subscriberStack = new Array(32);
9
+ var stackCapacity = 32;
10
+ var stackTop = -1;
11
+ var currentSubscriber = null;
12
+ var signalSubscribers = /* @__PURE__ */ new WeakMap();
13
+ var SUBS = "__s";
14
+ var notifyDepth = 0;
15
+ var pendingQueue = [];
16
+ var pendingSet = /* @__PURE__ */ new Set();
17
+ function safeInvoke(sub) {
18
+ try {
19
+ sub();
20
+ } catch (err) {
21
+ if (_isDev) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
22
+ }
23
+ }
24
+ var suspendDepth = 0;
25
+ var trackingSuspended = false;
26
+ function track(effectFn, subscriber) {
27
+ if (!subscriber) subscriber = effectFn;
28
+ cleanup(subscriber);
29
+ ++stackTop;
30
+ if (stackTop >= stackCapacity) {
31
+ stackCapacity *= 2;
32
+ subscriberStack.length = stackCapacity;
33
+ }
34
+ subscriberStack[stackTop] = subscriber;
35
+ currentSubscriber = subscriber;
36
+ try {
37
+ effectFn();
38
+ } finally {
39
+ stackTop--;
40
+ currentSubscriber = stackTop >= 0 ? subscriberStack[stackTop] : null;
41
+ }
42
+ return () => cleanup(subscriber);
43
+ }
44
+ function suspendTracking() {
45
+ if (suspendDepth === 0) {
46
+ ++stackTop;
47
+ if (stackTop >= stackCapacity) {
48
+ stackCapacity *= 2;
49
+ subscriberStack.length = stackCapacity;
50
+ }
51
+ subscriberStack[stackTop] = null;
52
+ currentSubscriber = null;
53
+ trackingSuspended = true;
54
+ }
55
+ suspendDepth++;
56
+ }
57
+ function resumeTracking() {
58
+ suspendDepth--;
59
+ if (suspendDepth === 0) {
60
+ stackTop--;
61
+ currentSubscriber = stackTop >= 0 ? subscriberStack[stackTop] : null;
62
+ trackingSuspended = false;
63
+ }
64
+ }
65
+ function untracked(fn) {
66
+ suspendTracking();
67
+ try {
68
+ return fn();
69
+ } finally {
70
+ resumeTracking();
71
+ }
72
+ }
73
+ function recordDependency(signal2) {
74
+ if (!currentSubscriber) return;
75
+ const sub = currentSubscriber;
76
+ if (sub._dep === signal2) return;
77
+ const deps = sub._deps;
78
+ if (deps) {
79
+ if (deps.has(signal2)) return;
80
+ deps.add(signal2);
81
+ } else if (sub._dep !== void 0) {
82
+ const set = /* @__PURE__ */ new Set();
83
+ set.add(sub._dep);
84
+ set.add(signal2);
85
+ sub._deps = set;
86
+ sub._dep = void 0;
87
+ } else {
88
+ sub._dep = signal2;
89
+ }
90
+ let subs = signal2[SUBS];
91
+ if (!subs) {
92
+ subs = /* @__PURE__ */ new Set();
93
+ signalSubscribers.set(signal2, subs);
94
+ signal2[SUBS] = subs;
95
+ }
96
+ subs.add(currentSubscriber);
97
+ if (subs.size === 1) {
98
+ signal2.__f = currentSubscriber;
99
+ } else if (signal2.__f !== void 0) {
100
+ signal2.__f = void 0;
101
+ }
102
+ }
103
+ function queueSignalNotification(signal2) {
104
+ const subs = signal2[SUBS];
105
+ if (!subs) return;
106
+ for (const sub of subs) {
107
+ if (sub._c) {
108
+ propagateDirty(sub);
109
+ } else if (!pendingSet.has(sub)) {
110
+ pendingSet.add(sub);
111
+ pendingQueue.push(sub);
112
+ }
113
+ }
114
+ }
115
+ function drainNotificationQueue() {
116
+ if (notifyDepth > 0) return;
117
+ notifyDepth++;
118
+ try {
119
+ let i = 0;
120
+ while (i < pendingQueue.length) {
121
+ safeInvoke(pendingQueue[i]);
122
+ i++;
123
+ }
124
+ } finally {
125
+ pendingQueue.length = 0;
126
+ pendingSet.clear();
127
+ notifyDepth--;
128
+ }
129
+ }
130
+ function propagateDirty(sub) {
131
+ sub();
132
+ let sig = sub._sig;
133
+ while (sig) {
134
+ const first = sig.__f;
135
+ if (first) {
136
+ if (first._c) {
137
+ const nSig = first._sig;
138
+ nSig._d = true;
139
+ sig = nSig;
140
+ continue;
141
+ }
142
+ if (!pendingSet.has(first)) {
143
+ pendingSet.add(first);
144
+ pendingQueue.push(first);
145
+ }
146
+ break;
147
+ }
148
+ const subs = sig[SUBS];
149
+ if (!subs) break;
150
+ let nextSig;
151
+ for (const s of subs) {
152
+ if (s._c) {
153
+ s();
154
+ const nSig = s._sig;
155
+ if (nSig && !nextSig) {
156
+ nextSig = nSig;
157
+ } else if (nSig) {
158
+ propagateDirty(s);
159
+ }
160
+ } else if (!pendingSet.has(s)) {
161
+ pendingSet.add(s);
162
+ pendingQueue.push(s);
163
+ }
164
+ }
165
+ sig = nextSig;
166
+ }
167
+ }
168
+ function notifySubscribers(signal2) {
169
+ const first = signal2.__f;
170
+ if (first) {
171
+ if (notifyDepth > 0) {
172
+ if (first._c) {
173
+ propagateDirty(first);
174
+ } else if (!pendingSet.has(first)) {
175
+ pendingSet.add(first);
176
+ pendingQueue.push(first);
177
+ }
178
+ return;
179
+ }
180
+ notifyDepth++;
181
+ try {
182
+ if (first._c) {
183
+ propagateDirty(first);
184
+ } else {
185
+ safeInvoke(first);
186
+ }
187
+ let i = 0;
188
+ while (i < pendingQueue.length) {
189
+ safeInvoke(pendingQueue[i]);
190
+ i++;
191
+ }
192
+ } finally {
193
+ pendingQueue.length = 0;
194
+ pendingSet.clear();
195
+ notifyDepth--;
196
+ }
197
+ return;
198
+ }
199
+ const subs = signal2[SUBS];
200
+ if (!subs || subs.size === 0) return;
201
+ if (notifyDepth > 0) {
202
+ for (const sub of subs) {
203
+ if (sub._c) {
204
+ propagateDirty(sub);
205
+ } else if (!pendingSet.has(sub)) {
206
+ pendingSet.add(sub);
207
+ pendingQueue.push(sub);
208
+ }
209
+ }
210
+ return;
211
+ }
212
+ notifyDepth++;
213
+ try {
214
+ let directCount = 0;
215
+ for (const sub of subs) {
216
+ pendingQueue[directCount++] = sub;
217
+ }
218
+ for (let i2 = 0; i2 < directCount; i2++) {
219
+ if (pendingQueue[i2]._c) {
220
+ propagateDirty(pendingQueue[i2]);
221
+ }
222
+ }
223
+ for (let i2 = 0; i2 < directCount; i2++) {
224
+ if (!pendingQueue[i2]._c) {
225
+ if (!pendingSet.has(pendingQueue[i2])) {
226
+ safeInvoke(pendingQueue[i2]);
227
+ }
228
+ }
229
+ }
230
+ let i = directCount;
231
+ while (i < pendingQueue.length) {
232
+ safeInvoke(pendingQueue[i]);
233
+ i++;
234
+ }
235
+ } finally {
236
+ pendingQueue.length = 0;
237
+ pendingSet.clear();
238
+ notifyDepth--;
239
+ }
240
+ }
241
+ function cleanup(subscriber) {
242
+ const sub = subscriber;
243
+ const singleDep = sub._dep;
244
+ if (singleDep !== void 0) {
245
+ const subs = singleDep[SUBS];
246
+ if (subs) {
247
+ subs.delete(subscriber);
248
+ if (singleDep.__f === subscriber) {
249
+ singleDep.__f = void 0;
250
+ }
251
+ }
252
+ sub._dep = void 0;
253
+ return;
254
+ }
255
+ const deps = sub._deps;
256
+ if (!deps || deps.size === 0) return;
257
+ for (const signal2 of deps) {
258
+ const subs = signal2[SUBS];
259
+ if (subs) {
260
+ subs.delete(subscriber);
261
+ if (signal2.__f === subscriber) {
262
+ signal2.__f = void 0;
263
+ }
264
+ }
265
+ }
266
+ deps.clear();
267
+ }
268
+
269
+ // src/reactivity/batch.ts
270
+ var batchDepth = 0;
271
+ var pendingSignals = /* @__PURE__ */ new Set();
272
+ function batch(fn) {
273
+ batchDepth++;
274
+ try {
275
+ return fn();
276
+ } finally {
277
+ batchDepth--;
278
+ if (batchDepth === 0) {
279
+ flushBatch();
280
+ }
281
+ }
282
+ }
283
+ function enqueueBatchedSignal(signal2) {
284
+ if (batchDepth === 0) return false;
285
+ pendingSignals.add(signal2);
286
+ return true;
287
+ }
288
+ function isBatching() {
289
+ return batchDepth > 0;
290
+ }
291
+ function flushBatch() {
292
+ for (const signal2 of pendingSignals) {
293
+ queueSignalNotification(signal2);
294
+ }
295
+ pendingSignals.clear();
296
+ drainNotificationQueue();
297
+ }
298
+
299
+ // src/core/signals/signal.ts
300
+ var _g = globalThis;
301
+ var _isDev2 = isDev();
302
+ function signal(initial, options) {
303
+ const state = { value: initial };
304
+ const debugName = _isDev2 ? options?.name : void 0;
305
+ const equalsFn = options?.equals;
306
+ if (debugName) {
307
+ state.__name = debugName;
308
+ }
309
+ function get() {
310
+ recordDependency(state);
311
+ return state.value;
312
+ }
313
+ get.__signal = state;
314
+ if (debugName) get.__name = debugName;
315
+ function set(next) {
316
+ const newValue = typeof next === "function" ? next(state.value) : next;
317
+ if (equalsFn ? equalsFn(state.value, newValue) : Object.is(newValue, state.value)) return;
318
+ if (_isDev2) {
319
+ const oldValue = state.value;
320
+ state.value = newValue;
321
+ const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
322
+ if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue, newValue });
323
+ } else {
324
+ state.value = newValue;
325
+ }
326
+ if (!enqueueBatchedSignal(state)) {
327
+ notifySubscribers(state);
328
+ }
329
+ }
330
+ if (_isDev2) {
331
+ const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
332
+ if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
333
+ }
334
+ return [get, set];
335
+ }
336
+
337
+ export {
338
+ trackingSuspended,
339
+ track,
340
+ untracked,
341
+ recordDependency,
342
+ notifySubscribers,
343
+ batch,
344
+ enqueueBatchedSignal,
345
+ isBatching,
346
+ signal
347
+ };