@solidjs/signals 2.0.0-rc.17 → 2.0.0-rc.18
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/dev-shared.js +296 -191
- package/dist/dev.attribution.js +16 -16
- package/dist/dev.js +527 -311
- package/dist/observe/core/async.js +148 -115
- package/dist/observe/core/constants.js +3 -1
- package/dist/observe/core/core.js +27 -27
- package/dist/observe/core/effect.js +29 -32
- package/dist/observe/core/graph.js +5 -5
- package/dist/observe/core/owner.js +7 -7
- package/dist/observe/core/scheduler.js +23 -12
- package/dist/observe/core/verdict.js +2 -2
- package/dist/observe/deferred.js +16 -13
- package/dist/observe/from.js +248 -0
- package/dist/observe/index.js +2 -0
- package/dist/observe/store/reconcile.js +137 -121
- package/dist/observe/store/store.js +595 -618
- package/dist/observe/store/target.js +1 -5
- package/dist/prod/core/async.js +209 -176
- package/dist/prod/core/constants.js +3 -1
- package/dist/prod/core/core.js +33 -33
- package/dist/prod/core/effect.js +24 -27
- package/dist/prod/core/graph.js +2 -2
- package/dist/prod/core/lanes.js +14 -14
- package/dist/prod/core/scheduler.js +35 -24
- package/dist/prod/core/truth.js +4 -4
- package/dist/prod/core/verdict.js +7 -7
- package/dist/prod/deferred.js +17 -14
- package/dist/prod/from.js +248 -0
- package/dist/prod/index.js +2 -0
- package/dist/prod/store/optimistic.js +1 -1
- package/dist/prod/store/reconcile.js +137 -121
- package/dist/prod/store/store.js +94 -117
- package/dist/prod/store/target.js +13 -17
- package/dist/types/core/async.d.ts +12 -2
- package/dist/types/core/constants.d.ts +5 -0
- package/dist/types/core/core.d.ts +19 -3
- package/dist/types/core/scheduler.d.ts +15 -3
- package/dist/types/from.d.ts +47 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -219,3 +219,8 @@ export declare const $REFRESH: unique symbol;
|
|
|
219
219
|
export type Refreshable<T> = T & {
|
|
220
220
|
readonly [$REFRESH]: any;
|
|
221
221
|
};
|
|
222
|
+
/** `Set` under a module binding. Bundlers mark a bare `new Set()` pure with
|
|
223
|
+
* a `/* @__PURE__ *\/` comment that survives minification (16 bytes a site);
|
|
224
|
+
* a construction through a binding carries none. Same constructor, so the
|
|
225
|
+
* same objects. */
|
|
226
|
+
export declare const NewSet: SetConstructor;
|
|
@@ -68,13 +68,13 @@ export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val:
|
|
|
68
68
|
* channel (`_x._notifyStatus`) went with them; effects are the only
|
|
69
69
|
* display consumers.
|
|
70
70
|
*/
|
|
71
|
-
export declare let effectStatusNotify: ((this: any
|
|
71
|
+
export declare let effectStatusNotify: ((this: any) => void) | null;
|
|
72
72
|
export declare function setEffectStatusNotify(fn: NonNullable<typeof effectStatusNotify>): void;
|
|
73
73
|
/** Resolve a node's status notifier: effect nodes (`_type` — EFFECT_PURE is
|
|
74
74
|
* 0, and only effect literals carry the field) get the shared notifier.
|
|
75
75
|
* Presence doubles as the "display consumer" membership test in the status
|
|
76
76
|
* walks, exactly as the per-node field did when every effect carried one. */
|
|
77
|
-
export declare function statusNotifierOf(el: any): ((this: any
|
|
77
|
+
export declare function statusNotifierOf(el: any): ((this: any) => void) | null;
|
|
78
78
|
export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
79
79
|
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
80
80
|
/** A store slot node (CONFIG_SLOT_NODE): the whole node in ONE literal — the
|
|
@@ -128,7 +128,23 @@ export declare let disposalDepth: number;
|
|
|
128
128
|
export declare function enterDisposal(): void;
|
|
129
129
|
export declare function exitDisposal(): void;
|
|
130
130
|
export declare function resetDisposalDepth(): void;
|
|
131
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Dev-only: the DOM event being dispatched when the open strict-read window
|
|
133
|
+
* opened (`globalThis.event`; null between dispatches and off the main
|
|
134
|
+
* thread's Window), or `ANY_EVENT` when the window did not record one. A DOM
|
|
135
|
+
* call made in an effect callback that dispatches events synchronously
|
|
136
|
+
* (`el.focus()`, `el.click()`, `dialog.showModal()`) runs that event's
|
|
137
|
+
* handlers inside the window; a handler is a one-shot snapshot whoever
|
|
138
|
+
* dispatched the event, so a read made while a different event is current is
|
|
139
|
+
* outside the window (#4235). Only queued effect runs record the event, read
|
|
140
|
+
* once per queue (the getter is costly under jsdom); `strictReadActive` is
|
|
141
|
+
* the check.
|
|
142
|
+
*/
|
|
143
|
+
export declare let strictReadEvent: unknown;
|
|
144
|
+
export declare const dispatchingEvent: () => unknown;
|
|
145
|
+
export declare function setStrictRead(v: string | false, event?: unknown): string | false;
|
|
146
|
+
/** Dev-only: is the strict-read window open for a read made now? */
|
|
147
|
+
export declare function strictReadActive(): boolean;
|
|
132
148
|
/**
|
|
133
149
|
* Runs `fn` outside of any reactive tracking — reads inside `fn` will not
|
|
134
150
|
* subscribe the current scope. Returns whatever `fn` returns.
|
|
@@ -212,7 +212,14 @@ export declare function setQuestion(q: number): void;
|
|
|
212
212
|
export declare function nextQuestion(): number;
|
|
213
213
|
export declare const MAINLINE_QUESTION = 2147483647;
|
|
214
214
|
export declare let inEffectCallback: boolean;
|
|
215
|
-
|
|
215
|
+
/** Dev-only: matches no event, so a window or phase holding it applies
|
|
216
|
+
* whatever event is current (see `strictReadEvent`, core.ts). */
|
|
217
|
+
export declare const ANY_EVENT: {};
|
|
218
|
+
/** Dev-only: the DOM event current when the effect phase was entered. A
|
|
219
|
+
* handler dispatched synchronously from that phase (`el.focus()`) runs under
|
|
220
|
+
* a different event and is not in it (#4235). */
|
|
221
|
+
export declare let effectCallbackEvent: unknown;
|
|
222
|
+
export declare function setEffectCallback(value: boolean, event?: unknown): void;
|
|
216
223
|
export type QueueCallback = (type: number) => void;
|
|
217
224
|
export declare function schedule(): void;
|
|
218
225
|
/**
|
|
@@ -313,8 +320,8 @@ export declare class GlobalQueue implements IQueue {
|
|
|
313
320
|
* or without the held read) owes nothing. A run this transaction stashed
|
|
314
321
|
* for it is void (#3322: an effect has one value slot, and the stale pass
|
|
315
322
|
* overwrote the value that run was for) — the re-derivation's run replaces
|
|
316
|
-
* it. */
|
|
317
|
-
export declare function reruns(u: Transaction):
|
|
323
|
+
* it. Truthy when an effect re-derives (`land`). */
|
|
324
|
+
export declare function reruns(u: Transaction): unknown;
|
|
318
325
|
/** The held runs join this flush's effect phase after its own runs (the
|
|
319
326
|
* landing's re-passes, in height order): the frame's effects run as one
|
|
320
327
|
* pass would have queued them — a shell re-derived at the landing before a
|
|
@@ -383,3 +390,8 @@ export declare const globalQueue: GlobalQueue;
|
|
|
383
390
|
*/
|
|
384
391
|
export declare function flush(): void;
|
|
385
392
|
export declare function flush<T>(fn: () => T): T;
|
|
393
|
+
/** Dev-only: the DOM event current when the running effect queue started,
|
|
394
|
+
* or `ANY_EVENT` outside one. Read once per queue rather than once per
|
|
395
|
+
* effect (the getter is costly under jsdom); no event starts or ends between
|
|
396
|
+
* two effects of one synchronous queue (#4235). */
|
|
397
|
+
export declare let queueEvent: unknown;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The observer a `subscribe` call receives. */
|
|
2
|
+
type FromObserver<T> = {
|
|
3
|
+
next(value: T): void;
|
|
4
|
+
error(err: unknown): void;
|
|
5
|
+
complete(): void;
|
|
6
|
+
};
|
|
7
|
+
type Teardown = (() => void) | {
|
|
8
|
+
unsubscribe(): void;
|
|
9
|
+
} | void;
|
|
10
|
+
/**
|
|
11
|
+
* Anything `from` accepts: a subscribe function
|
|
12
|
+
* (`(next, error, complete) => unsubscribe`), an object with
|
|
13
|
+
* `subscribe(observer)` (RxJS and TC39 Observables, including
|
|
14
|
+
* `Symbol.observable` / `"@@observable"` interop), or an AsyncIterable.
|
|
15
|
+
*/
|
|
16
|
+
export type FromSource<T> = ((next: (value: T) => void, error: (err: unknown) => void, complete: () => void) => Teardown) | {
|
|
17
|
+
subscribe(observer: FromObserver<T>): Teardown;
|
|
18
|
+
} | AsyncIterable<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a callback subscription, an Observable or an AsyncIterable into an
|
|
21
|
+
* AsyncIterable for a Solid computation. A subscription keeps only the latest
|
|
22
|
+
* value, and a value the source emits during `subscribe` is served without a
|
|
23
|
+
* loading frame; an AsyncIterable streams every value through.
|
|
24
|
+
*
|
|
25
|
+
* The source closes on supersede — the owning computation re-running — and
|
|
26
|
+
* on owner disposal. Inside an async generator memo that holds for a
|
|
27
|
+
* `for await` that starts before the first `await`; one that starts after it
|
|
28
|
+
* has no owner to bind to, so its source closes only when the loop ends.
|
|
29
|
+
* Prefer returning `from(...)` from its own memo, with awaited inputs read
|
|
30
|
+
* from upstream memos and transforms done in a downstream memo.
|
|
31
|
+
*
|
|
32
|
+
* Iterate the result with `for await` or return it from a computation: its
|
|
33
|
+
* `next()` returns an already-buffered value as a bare result, not a promise.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const position = createMemo(() =>
|
|
38
|
+
* from<Position>((next, error) => {
|
|
39
|
+
* const id = navigator.geolocation.watchPosition(next, error);
|
|
40
|
+
* return () => navigator.geolocation.clearWatch(id);
|
|
41
|
+
* })
|
|
42
|
+
* );
|
|
43
|
+
* const ticks = createMemo(() => from(interval$(rate())));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function from<T>(source: FromSource<T>): AsyncIterable<T>;
|
|
47
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export { mapArray, repeat, type Maybe } from "./map.js";
|
|
|
26
26
|
export * from "./store/index.js";
|
|
27
27
|
export { affects } from "./affects.js";
|
|
28
28
|
export { createDeferred } from "./deferred.js";
|
|
29
|
+
export { from, type FromSource } from "./from.js";
|
|
29
30
|
export { flatten } from "./flatten.js";
|
|
30
31
|
export { createLoadingBoundary, createErrorBoundary } from "./boundaries.js";
|
|
31
32
|
export { createRevealOrder, type RevealOrder } from "./reveal.js";
|
package/package.json
CHANGED