sibujs 4.6.0 → 4.8.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/README.md +1 -1
- package/dist/browser.cjs +62 -8
- package/dist/browser.d.cts +23 -0
- package/dist/browser.d.ts +23 -0
- package/dist/browser.js +6 -5
- package/dist/build.cjs +2388 -1004
- package/dist/build.d.cts +147 -44
- package/dist/build.d.ts +147 -44
- package/dist/build.js +1410 -564
- package/dist/cdn.dev.global.js +14 -12
- package/dist/cdn.full.dev.global.js +15 -13
- package/dist/cdn.full.global.js +14 -12
- package/dist/cdn.global.js +12 -10
- package/dist/chunk-3ACAAQIN.js +224 -0
- package/dist/{chunk-7NCARGJW.js → chunk-44MTL7ED.js} +6 -6
- package/dist/{chunk-BAAG6ZTI.js → chunk-4WMSTZ7J.js} +8 -5
- package/dist/{chunk-H3SRKIYX.js → chunk-62BDYGAG.js} +8 -0
- package/dist/{chunk-DKGBBKOF.js → chunk-C5PEWEGH.js} +20 -5
- package/dist/{chunk-3ISI6ACU.js → chunk-C7AA2CZX.js} +1 -1
- package/dist/{chunk-UZQ6ALFS.js → chunk-CZPRSWSS.js} +1 -1
- package/dist/{chunk-D33YTSX5.js → chunk-DSID757X.js} +5 -4
- package/dist/{chunk-OXUY2A6L.js → chunk-EGUQLBHE.js} +22 -8
- package/dist/{chunk-2INLLLMZ.js → chunk-EXXSN3BW.js} +202 -26
- package/dist/{chunk-HURREPU2.js → chunk-FC6KCJSA.js} +87 -150
- package/dist/{chunk-HYXDKS4N.js → chunk-GSGNX35Q.js} +5 -5
- package/dist/{chunk-7GQCWFOE.js → chunk-J3YQ457H.js} +171 -85
- package/dist/{chunk-ORMZXBKQ.js → chunk-JUTFX2RM.js} +18 -10
- package/dist/{chunk-QE4TTDU3.js → chunk-KJ3UKABJ.js} +12 -11
- package/dist/{chunk-XRRZKZYX.js → chunk-LI4W3U6C.js} +1 -1
- package/dist/{chunk-47M47FOM.js → chunk-O6TRVMJI.js} +58 -6
- package/dist/{chunk-JSXPZCET.js → chunk-Q5J2LVKH.js} +1 -1
- package/dist/{chunk-5MT6SJ3P.js → chunk-QGMSESDD.js} +10 -5
- package/dist/{chunk-AIF3Z2T7.js → chunk-RGLPEBDE.js} +13 -10
- package/dist/{chunk-5Q4R7HCL.js → chunk-TQQUN4WR.js} +11 -2
- package/dist/{chunk-PK6FK2G2.js → chunk-UCNP3HVM.js} +183 -30
- package/dist/{chunk-XC4MEKGA.js → chunk-V3LHZSU5.js} +8 -2
- package/dist/{chunk-VVWPJ543.js → chunk-VWT3VXPL.js} +55 -20
- package/dist/{chunk-SXXVZMKZ.js → chunk-ZVLHNEEL.js} +17 -35
- package/dist/{contracts-DRIuclVT.d.cts → contracts-CLqzJnOV.d.ts} +28 -17
- package/dist/{contracts-DRIuclVT.d.ts → contracts-CTOJXu-x.d.cts} +28 -17
- package/dist/{customElement-MmInOW1U.d.ts → customElement-pYDKUzWl.d.cts} +11 -3
- package/dist/{customElement-MmInOW1U.d.cts → customElement-pYDKUzWl.d.ts} +11 -3
- package/dist/data.cjs +205 -39
- package/dist/data.d.cts +119 -3
- package/dist/data.d.ts +119 -3
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +18 -5
- package/dist/devtools.js +5 -5
- package/dist/ecosystem.cjs +462 -58
- package/dist/ecosystem.d.cts +2 -1
- package/dist/ecosystem.d.ts +2 -1
- package/dist/ecosystem.js +9 -8
- package/dist/extras.cjs +852 -296
- package/dist/extras.d.cts +5 -4
- package/dist/extras.d.ts +5 -4
- package/dist/extras.js +24 -23
- package/dist/index.cjs +721 -176
- package/dist/index.d.cts +220 -169
- package/dist/index.d.ts +220 -169
- package/dist/index.js +16 -12
- package/dist/motion.cjs +12 -4
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +37 -21
- package/dist/patterns.d.cts +2 -1
- package/dist/patterns.d.ts +2 -1
- package/dist/patterns.js +6 -6
- package/dist/performance.cjs +48 -6
- package/dist/performance.d.cts +12 -2
- package/dist/performance.d.ts +12 -2
- package/dist/performance.js +8 -6
- package/dist/plugins.cjs +672 -261
- package/dist/plugins.d.cts +131 -13
- package/dist/plugins.d.ts +131 -13
- package/dist/plugins.js +83 -47
- package/dist/{ssr-XOTUASDO.js → ssr-5OWAH3U2.js} +4 -2
- package/dist/{ssr-Bli9XRW5.d.cts → ssr-C8hgIAw7.d.cts} +6 -0
- package/dist/{ssr-Bli9XRW5.d.ts → ssr-C8hgIAw7.d.ts} +6 -0
- package/dist/ssr.cjs +509 -142
- package/dist/ssr.d.cts +55 -5
- package/dist/ssr.d.ts +55 -5
- package/dist/ssr.js +11 -9
- package/dist/{tagFactory-DFstCLQV.d.cts → tagFactory-8qL9LCIx.d.cts} +58 -19
- package/dist/{tagFactory-DkaNVUNV.d.ts → tagFactory-BL2fymez.d.ts} +58 -19
- package/dist/testing.cjs +17 -4
- package/dist/testing.js +4 -4
- package/dist/types-CJFViL6Q.d.cts +26 -0
- package/dist/types-CJFViL6Q.d.ts +26 -0
- package/dist/ui.cjs +635 -254
- package/dist/ui.d.cts +3 -2
- package/dist/ui.d.ts +3 -2
- package/dist/ui.js +9 -8
- package/dist/widgets.cjs +22 -14
- package/dist/widgets.js +7 -7
- package/package.json +8 -5
package/dist/data.d.ts
CHANGED
|
@@ -57,6 +57,43 @@ declare function calculateDelay(attempt: number, strategy: "exponential" | "line
|
|
|
57
57
|
*/
|
|
58
58
|
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions, onRetry?: (error: unknown, attempt: number, delay: number) => void, signal?: AbortSignal): Promise<T>;
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Structural sharing for the data layer.
|
|
62
|
+
*
|
|
63
|
+
* A refetch almost always produces a brand-new object graph, even when the
|
|
64
|
+
* server sent back exactly what it sent last time. Committing that graph to a
|
|
65
|
+
* signal notifies every subscriber — signals compare with `Object.is` — so a
|
|
66
|
+
* background refresh that changed nothing still re-ran every binding reading
|
|
67
|
+
* the data, and a `when(() => q.data(), …)` or a `() => q.data() && Form()`
|
|
68
|
+
* child rebuilt its subtree and threw away whatever the user was typing.
|
|
69
|
+
*
|
|
70
|
+
* `replaceEqualDeep(prev, next)` reconciles the new graph against the old one:
|
|
71
|
+
*
|
|
72
|
+
* - deeply equal → returns `prev` itself, so the signal write is a no-op and
|
|
73
|
+
* nothing is notified;
|
|
74
|
+
* - partially equal → returns a new container in which every unchanged
|
|
75
|
+
* subtree is the OLD reference, so an `each()` keyed by reference, a
|
|
76
|
+
* `derived` over one branch, or an `equals`-less signal holding a sub-object
|
|
77
|
+
* stays stable while only the changed path gets fresh identities.
|
|
78
|
+
*
|
|
79
|
+
* Only plain objects (prototype `Object.prototype` or `null`) and arrays are
|
|
80
|
+
* reconciled. Everything else — Date, Map, Set, class instances — is opaque
|
|
81
|
+
* and compared by identity: its enumerable keys say nothing about its state,
|
|
82
|
+
* and rebuilding it as a plain object would change its type.
|
|
83
|
+
*
|
|
84
|
+
* Internal to the data layer; not re-exported from `data.ts`.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* The public knob shared by `query()` and `resource()`.
|
|
88
|
+
*
|
|
89
|
+
* - `true` (default) — reconcile with {@link replaceEqualDeep}.
|
|
90
|
+
* - `false` — commit every result as-is (a fresh reference notifies).
|
|
91
|
+
* - a function — custom reconciliation. It receives the previously committed
|
|
92
|
+
* value and the new one and returns what to commit; returning `prev` means
|
|
93
|
+
* "unchanged" and notifies nobody.
|
|
94
|
+
*/
|
|
95
|
+
type StructuralSharingOption<T> = boolean | ((prev: T, next: T) => T);
|
|
96
|
+
|
|
60
97
|
/**
|
|
61
98
|
* ## Callback semantics
|
|
62
99
|
*
|
|
@@ -118,8 +155,52 @@ interface QueryOptions<T> {
|
|
|
118
155
|
onError?: (error: Error) => void;
|
|
119
156
|
/** Called on fetch settle (success or error) */
|
|
120
157
|
onSettled?: () => void;
|
|
121
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Transform fetched data before returning to consumers. Cache stores raw data.
|
|
160
|
+
*
|
|
161
|
+
* Runs in this observer's own reactive computation: it re-runs when the
|
|
162
|
+
* cached value changes, and when a signal it reads changes — without
|
|
163
|
+
* re-running the key effect, so such a signal never triggers a refetch. It
|
|
164
|
+
* runs once per fetch that changed the data, and its output is structurally
|
|
165
|
+
* shared against this observer's previous output for the same key, so an
|
|
166
|
+
* identical refetch notifies nobody.
|
|
167
|
+
*/
|
|
122
168
|
select?: (data: T) => T;
|
|
169
|
+
/**
|
|
170
|
+
* Keep data referentially stable across refetches. Default: `true`.
|
|
171
|
+
*
|
|
172
|
+
* Every refetch — `refetchInterval`, window focus, reconnect,
|
|
173
|
+
* `invalidateQueries` — produces a new object graph even when the server
|
|
174
|
+
* returned the same thing. With structural sharing on, the new result is
|
|
175
|
+
* reconciled against the previous value of the same key: if it is deeply
|
|
176
|
+
* equal the previous reference is kept and `data` subscribers are not
|
|
177
|
+
* notified at all; if only part of it changed, every unchanged nested object
|
|
178
|
+
* or array keeps its old reference, so `each()` rows and deriveds over
|
|
179
|
+
* untouched branches stay put. Only plain objects and arrays are compared —
|
|
180
|
+
* Date, Map, Set and class instances compare by identity. Cyclic data is
|
|
181
|
+
* safe: the containers on a cycle are taken as-is.
|
|
182
|
+
*
|
|
183
|
+
* Every observer of a key using the default holds the SAME reference.
|
|
184
|
+
*
|
|
185
|
+
* `setQueryData()` is an explicit write, not a fetch: when it hands over a
|
|
186
|
+
* new top-level reference, observers always receive a new top-level
|
|
187
|
+
* reference and are notified — even if every child is unchanged, as after
|
|
188
|
+
* `prev.items.push(x); return { ...prev }`. Unchanged nested subtrees are
|
|
189
|
+
* still reused beneath it.
|
|
190
|
+
*
|
|
191
|
+
* The option applies to this observer only; observers of one key may use
|
|
192
|
+
* different settings.
|
|
193
|
+
*
|
|
194
|
+
* - `false` commits every result as-is (each refetch notifies).
|
|
195
|
+
* - A function `(prev, next) => T` replaces the default reconciliation;
|
|
196
|
+
* `prev` is this observer's previous value for the same key. Return `prev`
|
|
197
|
+
* to report "unchanged" (ignored for an explicit write of a new
|
|
198
|
+
* reference). It must not throw — if it does, the error is reported and
|
|
199
|
+
* `next` is committed unshared.
|
|
200
|
+
*
|
|
201
|
+
* Also applied to this observer's `select` output.
|
|
202
|
+
*/
|
|
203
|
+
structuralSharing?: StructuralSharingOption<T>;
|
|
123
204
|
}
|
|
124
205
|
interface QueryResult<T> {
|
|
125
206
|
/** Reactive getter for the cached data */
|
|
@@ -143,9 +224,20 @@ declare function query<T>(key: string | (() => string), fetcher: (ctx: {
|
|
|
143
224
|
}) => Promise<T>, options?: QueryOptions<T>): QueryResult<T>;
|
|
144
225
|
/** Invalidate queries matching a key or predicate, triggering refetch for active subscribers */
|
|
145
226
|
declare function invalidateQueries(keyOrPredicate: string | ((key: string) => boolean)): void;
|
|
146
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Get cached data for a query key — the same reference every observer using
|
|
229
|
+
* the default `structuralSharing` holds.
|
|
230
|
+
*/
|
|
147
231
|
declare function getQueryData<T>(key: string): T | undefined;
|
|
148
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Set cached data for a query key, notifying subscribers.
|
|
234
|
+
*
|
|
235
|
+
* An explicit write: a value (or updater result) that is a new top-level
|
|
236
|
+
* reference reaches every observer as a new top-level reference, even when it
|
|
237
|
+
* is deeply equal to the previous value — so `prev.items.push(x); return
|
|
238
|
+
* { ...prev }` is never dropped. Unchanged nested subtrees are still reused.
|
|
239
|
+
* Returning `prev` itself changes nothing.
|
|
240
|
+
*/
|
|
149
241
|
declare function setQueryData<T>(key: string, data: T | ((prev: T | undefined) => T)): void;
|
|
150
242
|
/** Clear the entire query cache */
|
|
151
243
|
declare function clearQueryCache(): void;
|
|
@@ -354,6 +446,30 @@ interface ResourceOptions<T> {
|
|
|
354
446
|
onError?: (error: Error) => void;
|
|
355
447
|
/** Called on fetch settle (success or error) */
|
|
356
448
|
onSettled?: () => void;
|
|
449
|
+
/**
|
|
450
|
+
* Keep data referentially stable across refetches. Default: `true`.
|
|
451
|
+
*
|
|
452
|
+
* Each fetched result — from `refetch()` or a source change — is
|
|
453
|
+
* reconciled against the value already held: a deeply equal result keeps
|
|
454
|
+
* the previous reference and notifies nobody, and a partially changed one
|
|
455
|
+
* reuses every unchanged nested object or array. Only plain objects and
|
|
456
|
+
* arrays are compared; Date, Map, Set and class instances compare by
|
|
457
|
+
* identity. Cyclic data is safe: the containers on a cycle are taken as-is.
|
|
458
|
+
* Same contract as `QueryOptions.structuralSharing`.
|
|
459
|
+
*
|
|
460
|
+
* `mutate()` is an explicit write, not a fetch: when it hands over a new
|
|
461
|
+
* top-level reference, `data` always becomes a new top-level reference and
|
|
462
|
+
* notifies — even if every child is unchanged, as after
|
|
463
|
+
* `prev.items.push(x); return { ...prev }`. Unchanged nested subtrees are
|
|
464
|
+
* still reused beneath it.
|
|
465
|
+
*
|
|
466
|
+
* - `false` commits every result as-is.
|
|
467
|
+
* - A function `(prev, next) => T` replaces the default reconciliation;
|
|
468
|
+
* return `prev` to report "unchanged" (ignored for a `mutate()` of a new
|
|
469
|
+
* reference). If it throws, the error is reported and `next` is committed
|
|
470
|
+
* unshared.
|
|
471
|
+
*/
|
|
472
|
+
structuralSharing?: StructuralSharingOption<T>;
|
|
357
473
|
}
|
|
358
474
|
interface Resource<T> {
|
|
359
475
|
/** Reactive getter for the fetched data */
|
package/dist/data.js
CHANGED
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
throttle,
|
|
23
23
|
withLoader,
|
|
24
24
|
withRetry
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-2INLLLMZ.js";
|
|
25
|
+
} from "./chunk-UCNP3HVM.js";
|
|
26
|
+
import "./chunk-KJ3UKABJ.js";
|
|
28
27
|
import "./chunk-7ZHH77QA.js";
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-V3LHZSU5.js";
|
|
29
|
+
import "./chunk-EXXSN3BW.js";
|
|
30
30
|
import "./chunk-7XHATCIH.js";
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-DSID757X.js";
|
|
32
|
+
import "./chunk-TQQUN4WR.js";
|
|
33
33
|
import "./chunk-NYNYSPK7.js";
|
|
34
34
|
export {
|
|
35
35
|
__resetQueryCache,
|
package/dist/devtools.cjs
CHANGED
|
@@ -844,7 +844,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
844
844
|
}
|
|
845
845
|
|
|
846
846
|
// src/reactivity/track.ts
|
|
847
|
-
var _runtimeVersion = true ? "4.
|
|
847
|
+
var _runtimeVersion = true ? "4.8.0" : "dev";
|
|
848
848
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
849
849
|
function resolveReactiveApi() {
|
|
850
850
|
const g = globalThis;
|
|
@@ -950,6 +950,14 @@ var batch = API2.batch;
|
|
|
950
950
|
var enqueueBatchedSignal = API2.enqueueBatchedSignal;
|
|
951
951
|
var isBatching = API2.isBatching;
|
|
952
952
|
|
|
953
|
+
// src/core/devtoolsHook.ts
|
|
954
|
+
function emitDevtools(hook, event, payload) {
|
|
955
|
+
try {
|
|
956
|
+
hook.emit(event, payload);
|
|
957
|
+
} catch {
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
953
961
|
// src/core/signals/signal.ts
|
|
954
962
|
var _g = globalThis;
|
|
955
963
|
function signal(initial, options) {
|
|
@@ -983,7 +991,7 @@ function signal(initial, options) {
|
|
|
983
991
|
state2.__v++;
|
|
984
992
|
if (DEV) {
|
|
985
993
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
986
|
-
if (hook) hook
|
|
994
|
+
if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
|
|
987
995
|
}
|
|
988
996
|
if (!enqueueBatchedSignal(state2)) {
|
|
989
997
|
notifySubscribers2(state2);
|
|
@@ -997,7 +1005,7 @@ function signal(initial, options) {
|
|
|
997
1005
|
state2.value = newValue;
|
|
998
1006
|
state2.__v++;
|
|
999
1007
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
1000
|
-
if (hook) hook
|
|
1008
|
+
if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
|
|
1001
1009
|
if (!enqueueBatchedSignal(state2)) {
|
|
1002
1010
|
notifySubscribers2(state2);
|
|
1003
1011
|
}
|
|
@@ -1016,7 +1024,7 @@ function signal(initial, options) {
|
|
|
1016
1024
|
}
|
|
1017
1025
|
if (DEV) {
|
|
1018
1026
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
1019
|
-
if (hook) hook
|
|
1027
|
+
if (hook) emitDevtools(hook, "signal:create", { signal: state2, name: debugName, getter: get, initial });
|
|
1020
1028
|
}
|
|
1021
1029
|
return [get, set];
|
|
1022
1030
|
}
|
|
@@ -2164,12 +2172,17 @@ function effect(effectFn, options) {
|
|
|
2164
2172
|
try {
|
|
2165
2173
|
retrack2(ctx.bodyFn, ctx.subscriber);
|
|
2166
2174
|
if (ctx.rerunPending) drainReruns(ctx);
|
|
2175
|
+
} catch (err) {
|
|
2176
|
+
ctx.disposed = true;
|
|
2177
|
+
if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
|
|
2178
|
+
cleanup2(ctx.subscriber);
|
|
2179
|
+
throw err;
|
|
2167
2180
|
} finally {
|
|
2168
2181
|
ctx.running = false;
|
|
2169
2182
|
ctx.rerunPending = false;
|
|
2170
2183
|
}
|
|
2171
2184
|
const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
2172
|
-
if (hook) hook
|
|
2185
|
+
if (hook) emitDevtools(hook, "effect:create", { effectFn });
|
|
2173
2186
|
return () => disposeEffect(ctx);
|
|
2174
2187
|
}
|
|
2175
2188
|
|
package/dist/devtools.js
CHANGED
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
trackCleanup,
|
|
36
36
|
walkDependencyGraph,
|
|
37
37
|
withErrorTracking
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-2INLLLMZ.js";
|
|
38
|
+
} from "./chunk-44MTL7ED.js";
|
|
40
39
|
import "./chunk-7ZHH77QA.js";
|
|
41
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-V3LHZSU5.js";
|
|
41
|
+
import "./chunk-EXXSN3BW.js";
|
|
42
42
|
import "./chunk-7XHATCIH.js";
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-DSID757X.js";
|
|
44
|
+
import "./chunk-TQQUN4WR.js";
|
|
45
45
|
import {
|
|
46
46
|
isDev
|
|
47
47
|
} from "./chunk-NYNYSPK7.js";
|