elements-kit 0.0.11 → 0.0.13
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/{element-MXzFk4G2.mjs → element-C_4VbkvQ.mjs} +1 -1
- package/dist/{index-Cvdhuy6Y.d.mts → index-DUshSQ_6.d.mts} +11 -7
- package/dist/index.mjs +2 -2
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +1 -1
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/signals/index.d.mts +2 -2
- package/dist/signals/index.mjs +2 -2
- package/dist/{signals-DcgXhkU2.mjs → signals-BHmWX6ox.mjs} +86 -76
- package/dist/slot.d.mts +2 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +1 -1
- package/dist/utilities/debounced.test.mjs +1 -1
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +1 -1
- package/dist/utilities/element-rect.test.mjs +1 -1
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/element-scroll.mjs +1 -1
- package/dist/utilities/element-scroll.test.mjs +1 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +10 -8
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +1 -1
- package/dist/utilities/event-listener.test.mjs +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +1 -1
- package/dist/utilities/focus-within.test.mjs +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +1 -1
- package/dist/utilities/hover.test.mjs +1 -1
- package/dist/utilities/intersection-observer.mjs +1 -1
- package/dist/utilities/intersection-observer.test.mjs +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +1 -1
- package/dist/utilities/interval.test.mjs +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +1 -1
- package/dist/utilities/long-press.test.mjs +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +1 -1
- package/dist/utilities/media-devices.test.mjs +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-player.test.mjs +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +1 -1
- package/dist/utilities/mutation-observer.mjs +1 -1
- package/dist/utilities/mutation-observer.test.mjs +1 -1
- package/dist/utilities/on-click-outside.test.mjs +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +1 -1
- package/dist/utilities/previous.test.mjs +1 -1
- package/dist/utilities/resize-observer.mjs +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/search-params.test.mjs +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/storage.test.mjs +1 -1
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/throttled.mjs +1 -1
- package/dist/utilities/throttled.test.mjs +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +1 -1
- package/dist/utilities/timeout.test.mjs +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +1 -1
- package/package.json +3 -13
- package/dist/builder/dom.d.mts +0 -212
- package/dist/builder/dom.mjs +0 -205
- package/dist/builder/index.d.mts +0 -88
- package/dist/builder/index.mjs +0 -114
- /package/dist/{lib-BYJ5jPTG.d.mts → lib-JA05lzCN.d.mts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as effectScope, g as onCleanup, t as isReactive, u as effect, y as untracked } from "./signals-BHmWX6ox.mjs";
|
|
2
2
|
import "./polyfill-B1lNNcum.mjs";
|
|
3
3
|
import { i as resolveNode$1, n as Slot, r as Slots, t as $slots } from "./slot-Cydy7-0L.mjs";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
//#region src/signals/lib.d.ts
|
|
2
|
+
declare const $signal: unique symbol;
|
|
3
|
+
declare const $computed: unique symbol;
|
|
4
|
+
declare const $effect: unique symbol;
|
|
5
|
+
declare const $effectScope: unique symbol;
|
|
2
6
|
/**
|
|
3
7
|
* Returns `true` if `fn` is a signal handle created by {@link signal}.
|
|
4
8
|
*
|
|
5
|
-
* Relies on `
|
|
9
|
+
* Relies on `$signal` matching the internal `signalOper` function name.
|
|
6
10
|
*/
|
|
7
|
-
declare function isSignal(fn:
|
|
11
|
+
declare function isSignal(fn: unknown): boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Returns `true` if `fn` is a computed handle created by {@link computed}.
|
|
10
14
|
*
|
|
11
|
-
* Relies on `
|
|
15
|
+
* Relies on `$computed` matching the internal `computedOper` function name.
|
|
12
16
|
*/
|
|
13
|
-
declare function isComputed(fn:
|
|
17
|
+
declare function isComputed(fn: unknown): boolean;
|
|
14
18
|
/**
|
|
15
19
|
* Returns `true` if `fn` is an effect cleanup handle created by {@link effect}.
|
|
16
20
|
*
|
|
17
|
-
* Relies on
|
|
21
|
+
* Relies on the $effect symbol branding.
|
|
18
22
|
*/
|
|
19
|
-
declare function isEffect(fn:
|
|
23
|
+
declare function isEffect(fn: unknown): boolean;
|
|
20
24
|
/**
|
|
21
25
|
* Returns `true` if `fn` is an effectScope cleanup handle created by
|
|
22
26
|
* {@link effectScope}.
|
|
@@ -258,4 +262,4 @@ type MaybeReactive<T> = T | Computed<T>;
|
|
|
258
262
|
*/
|
|
259
263
|
declare function resolve<T>(value: MaybeReactive<T>): T;
|
|
260
264
|
//#endregion
|
|
261
|
-
export {
|
|
265
|
+
export { untracked as C, trigger as S, isEffect as _, isReactive as a, onCleanup as b, $computed as c, $signal as d, batch as f, isComputed as g, effectScope as h, Updater as i, $effect as l, effect as m, MaybeReactive as n, reactive as o, computed as p, Signal as r, resolve as s, Computed as t, $effectScope as u, isEffectScope as v, signal as x, isSignal as y };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as disposeElement } from "./element-
|
|
2
|
-
import {
|
|
1
|
+
import { n as disposeElement } from "./element-C_4VbkvQ.mjs";
|
|
2
|
+
import { _ as signal, g as onCleanup, u as effect, v as trigger, y as untracked } from "./signals-BHmWX6ox.mjs";
|
|
3
3
|
//#region src/jsx-runtime/for.ts
|
|
4
4
|
/**
|
|
5
5
|
* Keyed list renderer. Reconciles a reactive array into the DOM using a key
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as signal, d as effectScope, u as effect } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
3
|
//#region src/integrations/react.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createElement } from "../element-
|
|
2
|
-
import {
|
|
1
|
+
import { t as createElement } from "../element-C_4VbkvQ.mjs";
|
|
2
|
+
import { g as onCleanup } from "../signals-BHmWX6ox.mjs";
|
|
3
3
|
//#region src/jsx-runtime/fragment.ts
|
|
4
4
|
/**
|
|
5
5
|
* Used by the JSX transform for `<>...</>` fragments.
|
package/dist/signals/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { Computed, MaybeReactive, Signal, Updater, batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, signal, trigger, untracked };
|
|
1
|
+
import { C as untracked, S as trigger, _ as isEffect, a as isReactive, b as onCleanup, c as $computed, d as $signal, f as batch, g as isComputed, h as effectScope, i as Updater, l as $effect, m as effect, n as MaybeReactive, o as reactive, p as computed, r as Signal, s as resolve, t as Computed, u as $effectScope, v as isEffectScope, x as signal, y as isSignal } from "../index-DUshSQ_6.mjs";
|
|
2
|
+
export { $computed, $effect, $effectScope, $signal, Computed, MaybeReactive, Signal, Updater, batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, signal, trigger, untracked };
|
package/dist/signals/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, signal, trigger, untracked };
|
|
1
|
+
import { _ as signal, a as $effect, c as batch, d as effectScope, f as isComputed, g as onCleanup, h as isSignal, i as $computed, l as computed, m as isEffectScope, n as reactive, o as $effectScope, p as isEffect, r as resolve, s as $signal, t as isReactive, u as effect, v as trigger, y as untracked } from "../signals-BHmWX6ox.mjs";
|
|
2
|
+
export { $computed, $effect, $effectScope, $signal, batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, signal, trigger, untracked };
|
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
import "./polyfill-B1lNNcum.mjs";
|
|
2
2
|
//#region src/signals/system.ts
|
|
3
3
|
/**
|
|
4
|
-
* Bitmask flags that encode the current state of a {@link ReactiveNode}.
|
|
5
|
-
*
|
|
6
|
-
* | Flag | Meaning |
|
|
7
|
-
* |-----------------|---------|
|
|
8
|
-
* | `None` | Clean, not tracking. |
|
|
9
|
-
* | `Mutable` | Node can propagate value changes downstream (signal / computed). |
|
|
10
|
-
* | `Watching` | Node is actively watching for changes and should be notified (effect). |
|
|
11
|
-
* | `RecursedCheck` | Node is mid-execution; used to detect self-referential cycles. |
|
|
12
|
-
* | `Recursed` | Node was found to be recursed during propagation. |
|
|
13
|
-
* | `Dirty` | Node's value is known to be stale; must recompute before reading. |
|
|
14
|
-
* | `Pending` | A dep *might* be dirty; check before deciding whether to recompute. |
|
|
15
|
-
*/
|
|
16
|
-
let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
17
|
-
ReactiveFlags[ReactiveFlags["None"] = 0] = "None";
|
|
18
|
-
ReactiveFlags[ReactiveFlags["Mutable"] = 1] = "Mutable";
|
|
19
|
-
ReactiveFlags[ReactiveFlags["Watching"] = 2] = "Watching";
|
|
20
|
-
ReactiveFlags[ReactiveFlags["RecursedCheck"] = 4] = "RecursedCheck";
|
|
21
|
-
ReactiveFlags[ReactiveFlags["Recursed"] = 8] = "Recursed";
|
|
22
|
-
ReactiveFlags[ReactiveFlags["Dirty"] = 16] = "Dirty";
|
|
23
|
-
ReactiveFlags[ReactiveFlags["Pending"] = 32] = "Pending";
|
|
24
|
-
return ReactiveFlags;
|
|
25
|
-
}({});
|
|
26
|
-
/**
|
|
27
4
|
* Creates and returns the five core graph-manipulation functions that together
|
|
28
5
|
* implement push-pull reactive dependency tracking.
|
|
29
6
|
*
|
|
@@ -132,15 +109,15 @@ function createReactiveSystem({ update, notify, unwatched }) {
|
|
|
132
109
|
top: do {
|
|
133
110
|
const sub = link.sub;
|
|
134
111
|
let flags = sub.flags;
|
|
135
|
-
if (!(flags &
|
|
136
|
-
else if (!(flags &
|
|
137
|
-
else if (!(flags &
|
|
138
|
-
else if (!(flags &
|
|
139
|
-
sub.flags = flags |
|
|
140
|
-
flags &=
|
|
141
|
-
} else flags =
|
|
142
|
-
if (flags &
|
|
143
|
-
if (flags &
|
|
112
|
+
if (!(flags & 60)) sub.flags = flags | 32;
|
|
113
|
+
else if (!(flags & 12)) flags = 0;
|
|
114
|
+
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
115
|
+
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
116
|
+
sub.flags = flags | 40;
|
|
117
|
+
flags &= 1;
|
|
118
|
+
} else flags = 0;
|
|
119
|
+
if (flags & 2) notify(sub);
|
|
120
|
+
if (flags & 1) {
|
|
144
121
|
const subSubs = sub.subs;
|
|
145
122
|
if (subSubs !== void 0) {
|
|
146
123
|
const nextSub = (link = subSubs).nextSub;
|
|
@@ -189,14 +166,14 @@ function createReactiveSystem({ update, notify, unwatched }) {
|
|
|
189
166
|
top: do {
|
|
190
167
|
const dep = link.dep;
|
|
191
168
|
const flags = dep.flags;
|
|
192
|
-
if (sub.flags &
|
|
193
|
-
else if ((flags &
|
|
169
|
+
if (sub.flags & 16) dirty = true;
|
|
170
|
+
else if ((flags & 17) === 17) {
|
|
194
171
|
if (update(dep)) {
|
|
195
172
|
const subs = dep.subs;
|
|
196
173
|
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
197
174
|
dirty = true;
|
|
198
175
|
}
|
|
199
|
-
} else if ((flags &
|
|
176
|
+
} else if ((flags & 33) === 33) {
|
|
200
177
|
if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
|
|
201
178
|
value: link,
|
|
202
179
|
prev: stack
|
|
@@ -227,7 +204,7 @@ function createReactiveSystem({ update, notify, unwatched }) {
|
|
|
227
204
|
continue;
|
|
228
205
|
}
|
|
229
206
|
dirty = false;
|
|
230
|
-
} else sub.flags &=
|
|
207
|
+
} else sub.flags &= -33;
|
|
231
208
|
sub = link.sub;
|
|
232
209
|
const nextDep = link.nextDep;
|
|
233
210
|
if (nextDep !== void 0) {
|
|
@@ -251,9 +228,9 @@ function createReactiveSystem({ update, notify, unwatched }) {
|
|
|
251
228
|
do {
|
|
252
229
|
const sub = link.sub;
|
|
253
230
|
const flags = sub.flags;
|
|
254
|
-
if ((flags &
|
|
255
|
-
sub.flags = flags |
|
|
256
|
-
if ((flags &
|
|
231
|
+
if ((flags & 48) === 32) {
|
|
232
|
+
sub.flags = flags | 16;
|
|
233
|
+
if ((flags & 6) === 2) notify(sub);
|
|
257
234
|
}
|
|
258
235
|
} while ((link = link.nextSub) !== void 0);
|
|
259
236
|
}
|
|
@@ -298,6 +275,10 @@ let activeSub;
|
|
|
298
275
|
let activeOwner;
|
|
299
276
|
/** Ring-buffer of effects waiting to be flushed. */
|
|
300
277
|
const queued = [];
|
|
278
|
+
const $signal = Symbol("signal");
|
|
279
|
+
const $computed = Symbol("computed");
|
|
280
|
+
const $effect = Symbol("effect");
|
|
281
|
+
const $effectScope = Symbol("effectScope");
|
|
301
282
|
const { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({
|
|
302
283
|
update(node) {
|
|
303
284
|
if (node.depsTail !== void 0) return updateComputed(node);
|
|
@@ -308,9 +289,9 @@ const { link, unlink, propagate, checkDirty, shallowPropagate } = createReactive
|
|
|
308
289
|
let firstInsertedIndex = insertIndex;
|
|
309
290
|
do {
|
|
310
291
|
queued[insertIndex++] = effect;
|
|
311
|
-
effect.flags &=
|
|
292
|
+
effect.flags &= -3;
|
|
312
293
|
effect = effect.subs?.sub;
|
|
313
|
-
if (effect === void 0 || !(effect.flags &
|
|
294
|
+
if (effect === void 0 || !(effect.flags & 2)) break;
|
|
314
295
|
} while (true);
|
|
315
296
|
queuedLength = insertIndex;
|
|
316
297
|
while (firstInsertedIndex < --insertIndex) {
|
|
@@ -320,10 +301,18 @@ const { link, unlink, propagate, checkDirty, shallowPropagate } = createReactive
|
|
|
320
301
|
}
|
|
321
302
|
},
|
|
322
303
|
unwatched(node) {
|
|
323
|
-
if (!(node.flags &
|
|
304
|
+
if (!(node.flags & 1)) effectScopeOper.call(node);
|
|
324
305
|
else if (node.depsTail !== void 0) {
|
|
306
|
+
const c = node;
|
|
307
|
+
if (c.onCleanup !== void 0) {
|
|
308
|
+
const fns = c.onCleanup;
|
|
309
|
+
c.onCleanup = void 0;
|
|
310
|
+
untracked(() => {
|
|
311
|
+
for (const fn of fns) fn();
|
|
312
|
+
});
|
|
313
|
+
}
|
|
325
314
|
node.depsTail = void 0;
|
|
326
|
-
node.flags =
|
|
315
|
+
node.flags = 17;
|
|
327
316
|
purgeDeps(node);
|
|
328
317
|
}
|
|
329
318
|
}
|
|
@@ -364,26 +353,26 @@ function endBatch() {
|
|
|
364
353
|
/**
|
|
365
354
|
* Returns `true` if `fn` is a signal handle created by {@link signal}.
|
|
366
355
|
*
|
|
367
|
-
* Relies on `
|
|
356
|
+
* Relies on `$signal` matching the internal `signalOper` function name.
|
|
368
357
|
*/
|
|
369
358
|
function isSignal(fn) {
|
|
370
|
-
return fn
|
|
359
|
+
return fn != null && fn[$signal] === true;
|
|
371
360
|
}
|
|
372
361
|
/**
|
|
373
362
|
* Returns `true` if `fn` is a computed handle created by {@link computed}.
|
|
374
363
|
*
|
|
375
|
-
* Relies on `
|
|
364
|
+
* Relies on `$computed` matching the internal `computedOper` function name.
|
|
376
365
|
*/
|
|
377
366
|
function isComputed(fn) {
|
|
378
|
-
return fn
|
|
367
|
+
return fn != null && fn[$computed] === true;
|
|
379
368
|
}
|
|
380
369
|
/**
|
|
381
370
|
* Returns `true` if `fn` is an effect cleanup handle created by {@link effect}.
|
|
382
371
|
*
|
|
383
|
-
* Relies on
|
|
372
|
+
* Relies on the $effect symbol branding.
|
|
384
373
|
*/
|
|
385
374
|
function isEffect(fn) {
|
|
386
|
-
return fn
|
|
375
|
+
return fn != null && fn[$effect] === true;
|
|
387
376
|
}
|
|
388
377
|
/**
|
|
389
378
|
* Returns `true` if `fn` is an effectScope cleanup handle created by
|
|
@@ -395,13 +384,15 @@ function isEffectScope(fn) {
|
|
|
395
384
|
return fn.name === "bound " + effectScopeOper.name;
|
|
396
385
|
}
|
|
397
386
|
function signal(initialValue) {
|
|
398
|
-
|
|
387
|
+
const handle = signalOper.bind({
|
|
399
388
|
currentValue: initialValue,
|
|
400
389
|
pendingValue: initialValue,
|
|
401
390
|
subs: void 0,
|
|
402
391
|
subsTail: void 0,
|
|
403
|
-
flags:
|
|
392
|
+
flags: 1
|
|
404
393
|
});
|
|
394
|
+
Object.defineProperty(handle, $signal, { value: true });
|
|
395
|
+
return handle;
|
|
405
396
|
}
|
|
406
397
|
/**
|
|
407
398
|
* Creates a lazily-evaluated computed value.
|
|
@@ -427,15 +418,17 @@ function signal(initialValue) {
|
|
|
427
418
|
* ```
|
|
428
419
|
*/
|
|
429
420
|
function computed(getter) {
|
|
430
|
-
|
|
421
|
+
const handle = computedOper.bind({
|
|
431
422
|
value: void 0,
|
|
432
423
|
subs: void 0,
|
|
433
424
|
subsTail: void 0,
|
|
434
425
|
deps: void 0,
|
|
435
426
|
depsTail: void 0,
|
|
436
|
-
flags:
|
|
427
|
+
flags: 0,
|
|
437
428
|
getter
|
|
438
429
|
});
|
|
430
|
+
Object.defineProperty(handle, $computed, { value: true });
|
|
431
|
+
return handle;
|
|
439
432
|
}
|
|
440
433
|
/**
|
|
441
434
|
* Creates a reactive side-effect that runs immediately and re-runs whenever
|
|
@@ -474,7 +467,7 @@ function effect(fn) {
|
|
|
474
467
|
subsTail: void 0,
|
|
475
468
|
deps: void 0,
|
|
476
469
|
depsTail: void 0,
|
|
477
|
-
flags:
|
|
470
|
+
flags: 6
|
|
478
471
|
};
|
|
479
472
|
const prevSub = setActiveSub(e);
|
|
480
473
|
const prevOwner = activeOwner;
|
|
@@ -485,9 +478,11 @@ function effect(fn) {
|
|
|
485
478
|
} finally {
|
|
486
479
|
activeSub = prevSub;
|
|
487
480
|
activeOwner = prevOwner;
|
|
488
|
-
e.flags &=
|
|
481
|
+
e.flags &= -5;
|
|
489
482
|
}
|
|
490
|
-
|
|
483
|
+
const handle = effectOper.bind(e);
|
|
484
|
+
Object.defineProperty(handle, $effect, { value: true });
|
|
485
|
+
return handle;
|
|
491
486
|
}
|
|
492
487
|
/**
|
|
493
488
|
* Creates an ownership scope that groups reactive effects so they can all be
|
|
@@ -519,7 +514,7 @@ function effectScope(fn) {
|
|
|
519
514
|
depsTail: void 0,
|
|
520
515
|
subs: void 0,
|
|
521
516
|
subsTail: void 0,
|
|
522
|
-
flags:
|
|
517
|
+
flags: 0
|
|
523
518
|
};
|
|
524
519
|
const prevSub = setActiveSub(e);
|
|
525
520
|
const prevOwner = activeOwner;
|
|
@@ -531,7 +526,9 @@ function effectScope(fn) {
|
|
|
531
526
|
activeSub = prevSub;
|
|
532
527
|
activeOwner = prevOwner;
|
|
533
528
|
}
|
|
534
|
-
|
|
529
|
+
const handle = effectScopeOper.bind(e);
|
|
530
|
+
Object.defineProperty(handle, $effectScope, { value: true });
|
|
531
|
+
return handle;
|
|
535
532
|
}
|
|
536
533
|
/**
|
|
537
534
|
* Registers a cleanup callback for the currently executing effect or scope.
|
|
@@ -651,7 +648,7 @@ function trigger(fn) {
|
|
|
651
648
|
const sub = {
|
|
652
649
|
deps: void 0,
|
|
653
650
|
depsTail: void 0,
|
|
654
|
-
flags:
|
|
651
|
+
flags: 2
|
|
655
652
|
};
|
|
656
653
|
const prevSub = setActiveSub(sub);
|
|
657
654
|
try {
|
|
@@ -664,7 +661,7 @@ function trigger(fn) {
|
|
|
664
661
|
link = unlink(link, sub);
|
|
665
662
|
const subs = dep.subs;
|
|
666
663
|
if (subs !== void 0) {
|
|
667
|
-
sub.flags =
|
|
664
|
+
sub.flags = 0;
|
|
668
665
|
propagate(subs);
|
|
669
666
|
shallowPropagate(subs);
|
|
670
667
|
}
|
|
@@ -680,15 +677,25 @@ function trigger(fn) {
|
|
|
680
677
|
*/
|
|
681
678
|
function updateComputed(c) {
|
|
682
679
|
++cycle;
|
|
680
|
+
if (c.onCleanup !== void 0) {
|
|
681
|
+
const cleanups = c.onCleanup;
|
|
682
|
+
c.onCleanup = void 0;
|
|
683
|
+
untracked(() => {
|
|
684
|
+
for (const fn of cleanups) fn();
|
|
685
|
+
});
|
|
686
|
+
}
|
|
683
687
|
c.depsTail = void 0;
|
|
684
|
-
c.flags =
|
|
688
|
+
c.flags = 5;
|
|
685
689
|
const prevSub = setActiveSub(c);
|
|
690
|
+
const prevOwner = activeOwner;
|
|
691
|
+
activeOwner = c;
|
|
686
692
|
try {
|
|
687
693
|
const oldValue = c.value;
|
|
688
694
|
return oldValue !== (c.value = c.getter(oldValue));
|
|
689
695
|
} finally {
|
|
690
696
|
activeSub = prevSub;
|
|
691
|
-
|
|
697
|
+
activeOwner = prevOwner;
|
|
698
|
+
c.flags &= -5;
|
|
692
699
|
purgeDeps(c);
|
|
693
700
|
}
|
|
694
701
|
}
|
|
@@ -698,7 +705,7 @@ function updateComputed(c) {
|
|
|
698
705
|
* @internal
|
|
699
706
|
*/
|
|
700
707
|
function updateSignal(s) {
|
|
701
|
-
s.flags =
|
|
708
|
+
s.flags = 1;
|
|
702
709
|
return s.currentValue !== (s.currentValue = s.pendingValue);
|
|
703
710
|
}
|
|
704
711
|
/**
|
|
@@ -711,7 +718,7 @@ function updateSignal(s) {
|
|
|
711
718
|
*/
|
|
712
719
|
function run(e) {
|
|
713
720
|
const flags = e.flags;
|
|
714
|
-
if (flags &
|
|
721
|
+
if (flags & 16 || flags & 32 && checkDirty(e.deps, e)) {
|
|
715
722
|
++cycle;
|
|
716
723
|
if (e.onCleanup !== void 0) {
|
|
717
724
|
const cleanups = e.onCleanup;
|
|
@@ -721,7 +728,7 @@ function run(e) {
|
|
|
721
728
|
});
|
|
722
729
|
}
|
|
723
730
|
e.depsTail = void 0;
|
|
724
|
-
e.flags =
|
|
731
|
+
e.flags = 6;
|
|
725
732
|
const prevSub = setActiveSub(e);
|
|
726
733
|
const prevOwner = activeOwner;
|
|
727
734
|
activeOwner = e;
|
|
@@ -730,10 +737,10 @@ function run(e) {
|
|
|
730
737
|
} finally {
|
|
731
738
|
activeSub = prevSub;
|
|
732
739
|
activeOwner = prevOwner;
|
|
733
|
-
e.flags &=
|
|
740
|
+
e.flags &= -5;
|
|
734
741
|
purgeDeps(e);
|
|
735
742
|
}
|
|
736
|
-
} else e.flags =
|
|
743
|
+
} else e.flags = 2;
|
|
737
744
|
}
|
|
738
745
|
/**
|
|
739
746
|
* Drains the queued-effects array, running each effect in order.
|
|
@@ -754,7 +761,7 @@ function flush() {
|
|
|
754
761
|
while (notifyIndex < queuedLength) {
|
|
755
762
|
const effect = queued[notifyIndex];
|
|
756
763
|
queued[notifyIndex++] = void 0;
|
|
757
|
-
effect.flags |=
|
|
764
|
+
effect.flags |= 10;
|
|
758
765
|
}
|
|
759
766
|
notifyIndex = 0;
|
|
760
767
|
queuedLength = 0;
|
|
@@ -773,19 +780,22 @@ function flush() {
|
|
|
773
780
|
*/
|
|
774
781
|
function computedOper() {
|
|
775
782
|
const flags = this.flags;
|
|
776
|
-
if (flags &
|
|
783
|
+
if (flags & 16 || flags & 32 && (checkDirty(this.deps, this) || (this.flags = flags & -33, false))) {
|
|
777
784
|
if (updateComputed(this)) {
|
|
778
785
|
const subs = this.subs;
|
|
779
786
|
if (subs !== void 0) shallowPropagate(subs);
|
|
780
787
|
}
|
|
781
788
|
} else if (!flags) {
|
|
782
|
-
this.flags =
|
|
789
|
+
this.flags = 5;
|
|
783
790
|
const prevSub = setActiveSub(this);
|
|
791
|
+
const prevOwner = activeOwner;
|
|
792
|
+
activeOwner = this;
|
|
784
793
|
try {
|
|
785
794
|
this.value = this.getter();
|
|
786
795
|
} finally {
|
|
787
796
|
activeSub = prevSub;
|
|
788
|
-
|
|
797
|
+
activeOwner = prevOwner;
|
|
798
|
+
this.flags &= -5;
|
|
789
799
|
}
|
|
790
800
|
}
|
|
791
801
|
const sub = activeSub;
|
|
@@ -807,7 +817,7 @@ function computedOper() {
|
|
|
807
817
|
function signalOper(...value) {
|
|
808
818
|
if (value.length) {
|
|
809
819
|
if (this.pendingValue !== (this.pendingValue = value[0])) {
|
|
810
|
-
this.flags =
|
|
820
|
+
this.flags = 17;
|
|
811
821
|
const subs = this.subs;
|
|
812
822
|
if (subs !== void 0) {
|
|
813
823
|
propagate(subs);
|
|
@@ -815,7 +825,7 @@ function signalOper(...value) {
|
|
|
815
825
|
}
|
|
816
826
|
}
|
|
817
827
|
} else {
|
|
818
|
-
if (this.flags &
|
|
828
|
+
if (this.flags & 16) {
|
|
819
829
|
if (updateSignal(this)) {
|
|
820
830
|
const subs = this.subs;
|
|
821
831
|
if (subs !== void 0) shallowPropagate(subs);
|
|
@@ -823,7 +833,7 @@ function signalOper(...value) {
|
|
|
823
833
|
}
|
|
824
834
|
let sub = activeSub;
|
|
825
835
|
while (sub !== void 0) {
|
|
826
|
-
if (sub.flags &
|
|
836
|
+
if (sub.flags & 3) {
|
|
827
837
|
link(this, sub, cycle);
|
|
828
838
|
break;
|
|
829
839
|
}
|
|
@@ -878,7 +888,7 @@ function effectScopeOper() {
|
|
|
878
888
|
});
|
|
879
889
|
}
|
|
880
890
|
this.depsTail = void 0;
|
|
881
|
-
this.flags =
|
|
891
|
+
this.flags = 0;
|
|
882
892
|
purgeDeps(this);
|
|
883
893
|
const sub = this.subs;
|
|
884
894
|
if (sub !== void 0) unlink(sub);
|
|
@@ -961,4 +971,4 @@ function resolve(value) {
|
|
|
961
971
|
return isReactive(value) ? value() : value;
|
|
962
972
|
}
|
|
963
973
|
//#endregion
|
|
964
|
-
export {
|
|
974
|
+
export { signal as _, $effect as a, batch as c, effectScope as d, isComputed as f, onCleanup as g, isSignal as h, $computed as i, computed as l, isEffectScope as m, reactive as n, $effectScope as o, isEffect as p, resolve as r, $signal as s, isReactive as t, effect as u, trigger as v, untracked as y };
|
package/dist/slot.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as signal, d as effectScope } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
import { a as beforeEach, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
|
|
3
3
|
import { createDebounced } from "./debounced.mjs";
|
|
4
4
|
//#region src/utilities/debounced.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as effectScope } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
|
|
3
3
|
import { createElementRect } from "./element-rect.mjs";
|
|
4
4
|
//#region src/utilities/element-rect.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as effectScope } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
|
|
3
3
|
import { createElementScroll } from "./element-scroll.mjs";
|
|
4
4
|
//#region src/utilities/element-scroll.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as signal, g as onCleanup, l as computed, s as $signal, v as trigger } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
//#region src/utilities/event-driven.ts
|
|
3
3
|
/**
|
|
4
4
|
* Returns a `Subscribe` for one or more DOM events on a target.
|
|
@@ -24,15 +24,17 @@ function sync(subscribe, getter, setter) {
|
|
|
24
24
|
value();
|
|
25
25
|
const cleanup = subscribe(() => trigger(tick));
|
|
26
26
|
onCleanup(cleanup);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const factory = () => {
|
|
28
|
+
if (!setter) return value;
|
|
29
|
+
function proxy(v) {
|
|
30
|
+
if (arguments.length === 0 || !setter) return value();
|
|
30
31
|
setter(v);
|
|
31
32
|
return v;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(proxy, $signal, { value: true });
|
|
35
|
+
return proxy;
|
|
36
|
+
};
|
|
37
|
+
return [factory(), cleanup];
|
|
36
38
|
}
|
|
37
39
|
//#endregion
|
|
38
40
|
export { fromEvent, sync };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as onCleanup, u as effect } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
//#region src/utilities/event-listener.ts
|
|
3
3
|
function on(target, type, handler, options) {
|
|
4
4
|
const add = (t) => options !== void 0 ? t.addEventListener(type, handler, options) : t.addEventListener(type, handler);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as signal, d as effectScope, u as effect } from "../signals-BHmWX6ox.mjs";
|
|
2
2
|
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
|
|
3
3
|
import { on } from "./event-listener.mjs";
|
|
4
4
|
//#region src/utilities/event-listener.test.ts
|