sibujs 2.0.0 → 2.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 +369 -276
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +411 -300
  4. package/dist/build.js +10 -10
  5. package/dist/cdn.global.js +8 -8
  6. package/dist/{chunk-JA6667UN.js → chunk-2JQUV4Y3.js} +4 -4
  7. package/dist/{chunk-3NSGB5JN.js → chunk-2KM2724A.js} +2 -2
  8. package/dist/{chunk-52YJLLRO.js → chunk-4YTVESDX.js} +1 -1
  9. package/dist/chunk-5WD7BYTZ.js +152 -0
  10. package/dist/{chunk-CC65Y57T.js → chunk-6QZO7MMG.js} +48 -16
  11. package/dist/{chunk-54EDRCEF.js → chunk-DF3GTP4Q.js} +7 -2
  12. package/dist/{chunk-ND2664SF.js → chunk-J63GPPCJ.js} +13 -9
  13. package/dist/{chunk-O2MNQFLP.js → chunk-KH4OE6WY.js} +5 -5
  14. package/dist/{chunk-3LR7GLWQ.js → chunk-KZA7ANXP.js} +3 -3
  15. package/dist/chunk-L4DAT4WU.js +400 -0
  16. package/dist/{chunk-WOMYAHHI.js → chunk-L52H775O.js} +4 -4
  17. package/dist/{chunk-ITX6OO3F.js → chunk-NEWH4O5U.js} +1 -1
  18. package/dist/{chunk-7JDB7I65.js → chunk-RJIRT46U.js} +4 -4
  19. package/dist/{chunk-KLRMB5ZS.js → chunk-STFTTMO2.js} +2 -2
  20. package/dist/{chunk-DFPFITST.js → chunk-UKMXT5T6.js} +1 -1
  21. package/dist/{chunk-SAHNHTFC.js → chunk-V65KTDZW.js} +3 -3
  22. package/dist/{chunk-R73P76YZ.js → chunk-VSNLICTS.js} +1 -1
  23. package/dist/{chunk-MIUAXB7K.js → chunk-XDKP4T7G.js} +2 -2
  24. package/dist/{chunk-JXMMDLBY.js → chunk-XVYB3J6C.js} +27 -29
  25. package/dist/{chunk-GTBNNBJ6.js → chunk-YMOIAHWA.js} +1 -1
  26. package/dist/data.cjs +382 -274
  27. package/dist/data.js +6 -6
  28. package/dist/devtools.cjs +398 -284
  29. package/dist/devtools.d.cts +1 -1
  30. package/dist/devtools.d.ts +1 -1
  31. package/dist/devtools.js +4 -4
  32. package/dist/ecosystem.cjs +382 -274
  33. package/dist/ecosystem.js +7 -7
  34. package/dist/extras.cjs +421 -299
  35. package/dist/extras.d.cts +1 -1
  36. package/dist/extras.d.ts +1 -1
  37. package/dist/extras.js +19 -19
  38. package/dist/index.cjs +413 -300
  39. package/dist/index.d.cts +16 -11
  40. package/dist/index.d.ts +16 -11
  41. package/dist/index.js +14 -10
  42. package/dist/{introspect-cY2pg9pW.d.ts → introspect-BZWKvQUZ.d.ts} +2 -1
  43. package/dist/{introspect-BWNjNw64.d.cts → introspect-DsJlDD2T.d.cts} +2 -1
  44. package/dist/motion.cjs +189 -149
  45. package/dist/motion.js +3 -3
  46. package/dist/patterns.cjs +382 -274
  47. package/dist/patterns.js +5 -5
  48. package/dist/performance.cjs +360 -260
  49. package/dist/performance.js +4 -4
  50. package/dist/plugins.cjs +376 -257
  51. package/dist/plugins.js +6 -6
  52. package/dist/ssr.cjs +383 -271
  53. package/dist/ssr.js +7 -7
  54. package/dist/testing.cjs +168 -109
  55. package/dist/testing.js +2 -2
  56. package/dist/ui.cjs +373 -258
  57. package/dist/ui.js +6 -6
  58. package/dist/widgets.cjs +382 -274
  59. package/dist/widgets.js +6 -6
  60. package/package.json +1 -1
  61. package/dist/chunk-HB24TBAF.js +0 -121
  62. package/dist/chunk-VLPPXTYG.js +0 -332
package/dist/widgets.js CHANGED
@@ -8,14 +8,14 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-7JDB7I65.js";
12
- import "./chunk-ITX6OO3F.js";
13
- import "./chunk-54EDRCEF.js";
11
+ } from "./chunk-RJIRT46U.js";
12
+ import "./chunk-NEWH4O5U.js";
13
+ import "./chunk-DF3GTP4Q.js";
14
14
  import "./chunk-UCS6AMJ7.js";
15
- import "./chunk-HB24TBAF.js";
15
+ import "./chunk-5WD7BYTZ.js";
16
16
  import "./chunk-2RA7SHDA.js";
17
- import "./chunk-CC65Y57T.js";
18
- import "./chunk-VLPPXTYG.js";
17
+ import "./chunk-6QZO7MMG.js";
18
+ import "./chunk-L4DAT4WU.js";
19
19
  import "./chunk-LMLD24FC.js";
20
20
  export {
21
21
  accordion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "A lightweight, function-based frontend framework that combines the best of React, Svelte, and Vue — with zero VDOM and maximum simplicity. Designed for developers who want fine-grained reactivity and full control without compilation or magic.",
5
5
  "keywords": [
6
6
  "frontend",
@@ -1,121 +0,0 @@
1
- import {
2
- isSSR
3
- } from "./chunk-2RA7SHDA.js";
4
- import {
5
- track,
6
- untracked
7
- } from "./chunk-VLPPXTYG.js";
8
- import {
9
- devAssert
10
- } from "./chunk-LMLD24FC.js";
11
-
12
- // src/core/signals/effect.ts
13
- var _g = globalThis;
14
- function on(deps, handler) {
15
- let prev;
16
- let first = true;
17
- return () => {
18
- const value = deps();
19
- if (first) {
20
- first = false;
21
- prev = value;
22
- untracked(() => handler(value, void 0));
23
- } else {
24
- const p = prev;
25
- prev = value;
26
- untracked(() => handler(value, p));
27
- }
28
- };
29
- }
30
- function effect(effectFn, options) {
31
- devAssert(typeof effectFn === "function", "effect: argument must be a function.");
32
- if (isSSR()) return () => {
33
- };
34
- const onError = options?.onError;
35
- let userCleanups = [];
36
- const onCleanup = (fn) => {
37
- userCleanups.push(fn);
38
- };
39
- const runUserCleanups = () => {
40
- if (userCleanups.length === 0) return;
41
- const list = userCleanups;
42
- userCleanups = [];
43
- for (let i = list.length - 1; i >= 0; i--) {
44
- try {
45
- list[i]();
46
- } catch (err) {
47
- if (typeof console !== "undefined") {
48
- console.warn("[SibuJS effect] onCleanup threw:", err);
49
- }
50
- }
51
- }
52
- };
53
- const invokeBody = () => effectFn(onCleanup);
54
- const wrappedFn = onError ? () => {
55
- try {
56
- invokeBody();
57
- } catch (err) {
58
- onError(err);
59
- }
60
- } : invokeBody;
61
- let cleanupHandle = () => {
62
- };
63
- let running = false;
64
- const subscriber = () => {
65
- if (running) {
66
- if (_g.__SIBU_DEV_WARN__ !== false && typeof console !== "undefined") {
67
- console.warn(
68
- "[SibuJS] effect re-entered itself while running \u2014 the triggering update will be ignored. Wrap mutual writes in `batch()` or split the effect to avoid this."
69
- );
70
- }
71
- return;
72
- }
73
- running = true;
74
- try {
75
- runUserCleanups();
76
- cleanupHandle();
77
- cleanupHandle = track(wrappedFn, subscriber);
78
- } finally {
79
- running = false;
80
- }
81
- };
82
- running = true;
83
- try {
84
- cleanupHandle = track(wrappedFn, subscriber);
85
- } finally {
86
- running = false;
87
- }
88
- const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
89
- if (hook) hook.emit("effect:create", { effectFn });
90
- let disposed = false;
91
- return () => {
92
- if (disposed) return;
93
- disposed = true;
94
- const h = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
95
- if (h) {
96
- try {
97
- h.emit("effect:destroy", { effectFn });
98
- } catch {
99
- }
100
- }
101
- try {
102
- runUserCleanups();
103
- } catch (err) {
104
- if (typeof console !== "undefined") {
105
- console.warn("[SibuJS effect] onCleanup threw during dispose:", err);
106
- }
107
- }
108
- try {
109
- cleanupHandle();
110
- } catch (err) {
111
- if (typeof console !== "undefined") {
112
- console.warn("[SibuJS effect] dispose threw:", err);
113
- }
114
- }
115
- };
116
- }
117
-
118
- export {
119
- on,
120
- effect
121
- };
@@ -1,332 +0,0 @@
1
- import {
2
- devWarn,
3
- isDev
4
- } from "./chunk-LMLD24FC.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 SUBS = "__s";
13
- var notifyDepth = 0;
14
- var pendingQueue = [];
15
- var pendingSet = /* @__PURE__ */ new Set();
16
- var propagateStack = [];
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 retrack(effectFn, subscriber) {
27
- const prev = currentSubscriber;
28
- currentSubscriber = subscriber;
29
- try {
30
- effectFn();
31
- } finally {
32
- currentSubscriber = prev;
33
- }
34
- }
35
- function track(effectFn, subscriber) {
36
- if (!subscriber) subscriber = effectFn;
37
- cleanup(subscriber);
38
- ++stackTop;
39
- if (stackTop >= stackCapacity) {
40
- stackCapacity *= 2;
41
- subscriberStack.length = stackCapacity;
42
- }
43
- subscriberStack[stackTop] = subscriber;
44
- currentSubscriber = subscriber;
45
- try {
46
- effectFn();
47
- } finally {
48
- stackTop--;
49
- currentSubscriber = stackTop >= 0 ? subscriberStack[stackTop] : null;
50
- }
51
- return () => cleanup(subscriber);
52
- }
53
- function suspendTracking() {
54
- if (suspendDepth === 0) {
55
- ++stackTop;
56
- if (stackTop >= stackCapacity) {
57
- stackCapacity *= 2;
58
- subscriberStack.length = stackCapacity;
59
- }
60
- subscriberStack[stackTop] = null;
61
- currentSubscriber = null;
62
- trackingSuspended = true;
63
- }
64
- suspendDepth++;
65
- }
66
- function resumeTracking() {
67
- suspendDepth--;
68
- if (suspendDepth === 0) {
69
- stackTop--;
70
- currentSubscriber = stackTop >= 0 ? subscriberStack[stackTop] : null;
71
- trackingSuspended = false;
72
- }
73
- }
74
- function untracked(fn) {
75
- suspendTracking();
76
- try {
77
- return fn();
78
- } finally {
79
- resumeTracking();
80
- }
81
- }
82
- function recordDependency(signal) {
83
- if (!currentSubscriber) return;
84
- const sub = currentSubscriber;
85
- if (sub._dep === signal) return;
86
- const deps = sub._deps;
87
- if (deps) {
88
- if (deps.has(signal)) return;
89
- deps.add(signal);
90
- } else if (sub._dep !== void 0) {
91
- const set = /* @__PURE__ */ new Set();
92
- set.add(sub._dep);
93
- set.add(signal);
94
- sub._deps = set;
95
- sub._dep = void 0;
96
- } else {
97
- sub._dep = signal;
98
- }
99
- let subs = signal[SUBS];
100
- if (!subs) {
101
- subs = /* @__PURE__ */ new Set();
102
- signal[SUBS] = subs;
103
- }
104
- subs.add(currentSubscriber);
105
- if (subs.size === 1) {
106
- signal.__f = currentSubscriber;
107
- } else if (signal.__f !== void 0) {
108
- signal.__f = void 0;
109
- }
110
- }
111
- function queueSignalNotification(signal) {
112
- const subs = signal[SUBS];
113
- if (!subs) return;
114
- for (const sub of subs) {
115
- if (sub._c) {
116
- propagateDirty(sub);
117
- } else if (!pendingSet.has(sub)) {
118
- pendingSet.add(sub);
119
- pendingQueue.push(sub);
120
- }
121
- }
122
- }
123
- var maxDrainIterations = 1e5;
124
- function drainNotificationQueue() {
125
- if (notifyDepth > 0) return;
126
- notifyDepth++;
127
- try {
128
- let i = 0;
129
- while (i < pendingQueue.length) {
130
- if (i >= maxDrainIterations) {
131
- if (typeof console !== "undefined") {
132
- console.error(
133
- `[SibuJS] Notification queue exceeded ${maxDrainIterations} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
134
- );
135
- }
136
- break;
137
- }
138
- safeInvoke(pendingQueue[i]);
139
- i++;
140
- }
141
- } finally {
142
- notifyDepth--;
143
- if (notifyDepth === 0) {
144
- pendingQueue.length = 0;
145
- pendingSet.clear();
146
- }
147
- }
148
- }
149
- function propagateDirty(sub) {
150
- sub();
151
- const rootSig = sub._sig;
152
- if (!rootSig) return;
153
- const stack = propagateStack;
154
- const baseLen = stack.length;
155
- stack.push(rootSig);
156
- while (stack.length > baseLen) {
157
- const sig = stack.pop();
158
- const first = sig.__f;
159
- if (first) {
160
- if (first._c) {
161
- const nSig = first._sig;
162
- if (!nSig._d) {
163
- nSig._d = true;
164
- stack.push(nSig);
165
- }
166
- } else if (!pendingSet.has(first)) {
167
- pendingSet.add(first);
168
- pendingQueue.push(first);
169
- }
170
- continue;
171
- }
172
- const subs = sig[SUBS];
173
- if (!subs) continue;
174
- for (const s of subs) {
175
- if (s._c) {
176
- const nSig = s._sig;
177
- if (nSig && !nSig._d) {
178
- nSig._d = true;
179
- stack.push(nSig);
180
- } else if (!nSig) {
181
- s();
182
- }
183
- } else if (!pendingSet.has(s)) {
184
- pendingSet.add(s);
185
- pendingQueue.push(s);
186
- }
187
- }
188
- }
189
- }
190
- function notifySubscribers(signal) {
191
- const first = signal.__f;
192
- if (first) {
193
- if (notifyDepth > 0) {
194
- if (first._c) {
195
- propagateDirty(first);
196
- } else if (!pendingSet.has(first)) {
197
- pendingSet.add(first);
198
- pendingQueue.push(first);
199
- }
200
- return;
201
- }
202
- notifyDepth++;
203
- try {
204
- if (first._c) {
205
- propagateDirty(first);
206
- } else {
207
- safeInvoke(first);
208
- }
209
- let i = 0;
210
- while (i < pendingQueue.length) {
211
- if (i >= maxDrainIterations) {
212
- if (typeof console !== "undefined") {
213
- console.error(
214
- `[SibuJS] Notification queue exceeded ${maxDrainIterations} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
215
- );
216
- }
217
- break;
218
- }
219
- safeInvoke(pendingQueue[i]);
220
- i++;
221
- }
222
- } finally {
223
- notifyDepth--;
224
- if (notifyDepth === 0) {
225
- pendingQueue.length = 0;
226
- pendingSet.clear();
227
- }
228
- }
229
- return;
230
- }
231
- const subs = signal[SUBS];
232
- if (!subs || subs.size === 0) return;
233
- if (notifyDepth > 0) {
234
- for (const sub of subs) {
235
- if (sub._c) {
236
- propagateDirty(sub);
237
- } else if (!pendingSet.has(sub)) {
238
- pendingSet.add(sub);
239
- pendingQueue.push(sub);
240
- }
241
- }
242
- return;
243
- }
244
- notifyDepth++;
245
- try {
246
- let directCount = 0;
247
- let hasComputedSub = false;
248
- for (const sub of subs) {
249
- if (sub._c) hasComputedSub = true;
250
- pendingQueue[directCount++] = sub;
251
- }
252
- if (!hasComputedSub) {
253
- for (let i2 = 0; i2 < directCount; i2++) {
254
- safeInvoke(pendingQueue[i2]);
255
- }
256
- } else {
257
- for (let i2 = 0; i2 < directCount; i2++) {
258
- if (pendingQueue[i2]._c) {
259
- propagateDirty(pendingQueue[i2]);
260
- }
261
- }
262
- for (let i2 = 0; i2 < directCount; i2++) {
263
- const sub = pendingQueue[i2];
264
- if (!sub._c && !pendingSet.has(sub)) {
265
- pendingSet.add(sub);
266
- safeInvoke(sub);
267
- }
268
- }
269
- }
270
- let i = directCount;
271
- while (i < pendingQueue.length) {
272
- if (i - directCount >= maxDrainIterations) {
273
- if (typeof console !== "undefined") {
274
- console.error(
275
- `[SibuJS] Notification queue exceeded ${maxDrainIterations} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
276
- );
277
- }
278
- break;
279
- }
280
- safeInvoke(pendingQueue[i]);
281
- i++;
282
- }
283
- } finally {
284
- notifyDepth--;
285
- if (notifyDepth === 0) {
286
- pendingQueue.length = 0;
287
- pendingSet.clear();
288
- }
289
- }
290
- }
291
- function cleanup(subscriber) {
292
- const sub = subscriber;
293
- const singleDep = sub._dep;
294
- if (singleDep !== void 0) {
295
- const subs = singleDep[SUBS];
296
- if (subs) {
297
- subs.delete(subscriber);
298
- if (singleDep.__f === subscriber) {
299
- singleDep.__f = subs.size === 1 ? subs.values().next().value : void 0;
300
- } else if (subs.size === 1 && singleDep.__f === void 0) {
301
- singleDep.__f = subs.values().next().value;
302
- }
303
- }
304
- sub._dep = void 0;
305
- return;
306
- }
307
- const deps = sub._deps;
308
- if (!deps || deps.size === 0) return;
309
- for (const signal of deps) {
310
- const subs = signal[SUBS];
311
- if (subs) {
312
- subs.delete(subscriber);
313
- if (signal.__f === subscriber) {
314
- signal.__f = subs.size === 1 ? subs.values().next().value : void 0;
315
- } else if (subs.size === 1 && signal.__f === void 0) {
316
- signal.__f = subs.values().next().value;
317
- }
318
- }
319
- }
320
- deps.clear();
321
- }
322
-
323
- export {
324
- trackingSuspended,
325
- retrack,
326
- track,
327
- untracked,
328
- recordDependency,
329
- queueSignalNotification,
330
- drainNotificationQueue,
331
- notifySubscribers
332
- };