@askrjs/askr 0.2.4 → 0.3.1
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/CHANGELOG.md +30 -0
- package/dist/access-CEA2pOry.js +1046 -0
- package/dist/actions/index.d.ts +16 -2
- package/dist/actions/index.js +5 -5
- package/dist/{activity-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
- package/dist/benchmark.js +8 -9
- package/dist/boot/index.d.ts +19 -9
- package/dist/boot/index.js +1 -1
- package/dist/{boot-tWyF6121.js → boot-DLplW9h4.js} +700 -441
- package/dist/capabilities-Bbf0mlp9.js +42 -0
- package/dist/components/index.d.ts +11 -8
- package/dist/components/index.js +1 -1
- package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
- package/dist/control/index.d.ts +20 -2
- package/dist/control/index.js +1 -1
- package/dist/{control-C-wSaq9V.js → control-BR_mrX__.js} +4 -4
- package/dist/core.d.ts +163 -0
- package/dist/csp-nonce-BfFWcd0w.js +173 -0
- package/dist/data/index.d.ts +74 -2
- package/dist/data/index.js +3 -3
- package/dist/{data-ghKopAbp.js → data-2edW0jhF.js} +108 -122
- package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
- package/dist/{deferred-CxjWCkIn.js → deferred-CbgNhf67.js} +5 -5
- package/dist/dom-renderer.d.ts +77 -0
- package/dist/domains/actions.d.ts +70 -0
- package/dist/domains/component.d.ts +119 -0
- package/dist/domains/context.d.ts +73 -0
- package/dist/domains/control.d.ts +328 -0
- package/dist/domains/data.d.ts +461 -0
- package/dist/domains/diagnostics.d.ts +21 -0
- package/dist/domains/lifecycle.d.ts +112 -0
- package/dist/domains/refs.d.ts +18 -0
- package/dist/domains/renderer.d.ts +127 -0
- package/dist/domains/routing.d.ts +501 -0
- package/dist/domains/scheduler.d.ts +79 -0
- package/dist/domains/server.d.ts +112 -0
- package/dist/domains/state.d.ts +129 -0
- package/dist/domains/telemetry.d.ts +29 -0
- package/dist/eager-control.d.ts +8 -0
- package/dist/{effect-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
- package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
- package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
- package/dist/foundations/icon/index.d.ts +67 -16
- package/dist/foundations/icon/index.js +1 -1
- package/dist/foundations/index.d.ts +26 -3
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/index.d.ts +73 -34
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +12 -5
- package/dist/foundations/state/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +44 -3
- package/dist/foundations/structures/index.js +1 -1
- package/dist/foundations/utilities/index.d.ts +34 -3
- package/dist/foundations/utilities/index.js +1 -1
- package/dist/fx/index.d.ts +72 -25
- package/dist/fx/index.js +8 -8
- package/dist/index.d.ts +121 -4
- package/dist/index.js +316 -47
- package/dist/{component-internal-C4hKKQBF.js → instance-VAFYVJOa.js} +495 -283
- package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +51 -11
- package/dist/jsx-globals.d.ts +2 -0
- package/dist/jsx-runtime-CPJXAOBF.js +43 -0
- package/dist/jsx-runtime.d.ts +17 -3
- package/dist/jsx-runtime.js +2 -42
- package/dist/jsx.d.ts +108 -0
- package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
- package/dist/{navigate-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
- package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
- package/dist/{readable-Di1fzSwm.js → notify-DxxuDPeY.js} +96 -34
- package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
- package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
- package/dist/{ssr-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
- package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
- package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
- package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
- package/dist/resources/index.d.ts +64 -12
- package/dist/resources/index.js +214 -8
- package/dist/route-activity.d.ts +21 -0
- package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
- package/dist/router/index.d.ts +378 -79
- package/dist/router/index.js +9 -9
- package/dist/router-internal-7nuNEHfG.js +36 -0
- package/dist/scope-Cq_iYbTR.js +403 -0
- package/dist/{selector-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
- package/dist/{shared-CYBH3F8I.js → shared-kU8yvryp.js} +3 -6
- package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
- package/dist/ssg/index.d.ts +51 -15
- package/dist/ssg/index.js +269 -209
- package/dist/ssr/index.d.ts +121 -68
- package/dist/ssr/index.js +2 -1
- package/dist/ssr-CiNm6Vzl.js +393 -0
- package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
- package/dist/{state-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
- package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
- package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
- package/dist/testing/index.d.ts +123 -24
- package/dist/testing/index.js +24 -61
- package/dist/timer-C7uqnJVt.js +85 -0
- package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
- package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
- package/package.json +12 -14
- package/dist/access-BucjYZcX.js +0 -509
- package/dist/activity-DooIuxQO.d.ts +0 -14
- package/dist/benchmark.d.ts +0 -26
- package/dist/cleanup-TXSsApEl.js +0 -535
- package/dist/component-cleanup-jdbgjkT1.js +0 -143
- package/dist/component-scope-4I3yEMkb.js +0 -195
- package/dist/control-Cxag1yqV.d.ts +0 -8
- package/dist/csp-nonce-9NFUb7hJ.js +0 -72
- package/dist/css-BuPaTOfe.js +0 -70
- package/dist/fastlane-BKZduiBQ.js +0 -166
- package/dist/index-Dgjbo2gU.d.ts +0 -1456
- package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
- package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
- package/dist/lifecycle-batch-63aXFf2S.js +0 -253
- package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { JSXElementType, JSXElement, Props } from '../elements.js';
|
|
2
|
+
import '../jsx-globals.js';
|
|
3
|
+
import { AuthContext, AuthRequirement } from '@askrjs/auth';
|
|
4
|
+
import { InferSchema, ObjectSchema } from '@askrjs/schema';
|
|
5
|
+
import { State, state } from './state.js';
|
|
6
|
+
import { ComponentFunction, ContextFrame, OwnedChildScope } from './context.js';
|
|
7
|
+
import { DataRuntime } from './data.js';
|
|
8
|
+
import { RouteAuthOptions, RouteRegistry } from './routing.js';
|
|
9
|
+
|
|
10
|
+
interface AppRenderRuntime {
|
|
11
|
+
framework: Readonly<Record<string, unknown>>;
|
|
12
|
+
route: unknown;
|
|
13
|
+
hasRoute: boolean;
|
|
14
|
+
dataRuntime?: DataRuntime;
|
|
15
|
+
routeRegistry?: RouteRegistry;
|
|
16
|
+
routeAuth?: RouteAuthOptions;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ComponentInstance {
|
|
20
|
+
id: string;
|
|
21
|
+
fn: ComponentFunction;
|
|
22
|
+
props: Props;
|
|
23
|
+
target: Element | null;
|
|
24
|
+
parentInstance: ComponentInstance | null;
|
|
25
|
+
portalScope: object | null;
|
|
26
|
+
mounted: boolean;
|
|
27
|
+
abortController: AbortController | null;
|
|
28
|
+
ssr?: boolean;
|
|
29
|
+
cleanupStrict?: boolean;
|
|
30
|
+
/** @internal Private resource-ownership identity for the active mount. */
|
|
31
|
+
_ownershipGeneration: object;
|
|
32
|
+
stateValues?: State<unknown>[];
|
|
33
|
+
evaluationGeneration: number;
|
|
34
|
+
notifyUpdate: (() => void) | null;
|
|
35
|
+
_pendingFlushTask?: () => void;
|
|
36
|
+
_pendingRunTask?: () => void;
|
|
37
|
+
_enqueueRun?: () => void;
|
|
38
|
+
stateIndexCheck: number;
|
|
39
|
+
expectedStateIndices?: number[];
|
|
40
|
+
firstRenderComplete: boolean;
|
|
41
|
+
mountOperations?: Array<
|
|
42
|
+
() => void | (() => void) | PromiseLike<void | (() => void)>
|
|
43
|
+
>;
|
|
44
|
+
commitOperations?: Array<
|
|
45
|
+
() => void | (() => void) | PromiseLike<void | (() => void)>
|
|
46
|
+
>;
|
|
47
|
+
cleanupFns?: Array<() => void>;
|
|
48
|
+
lifecycleSlots?: unknown[];
|
|
49
|
+
lifecycleGeneration: number;
|
|
50
|
+
hasPendingUpdate: boolean;
|
|
51
|
+
ownerFrame: ContextFrame | null;
|
|
52
|
+
isRoot?: boolean;
|
|
53
|
+
_rootComponentFn?: ComponentFunction;
|
|
54
|
+
/** @internal Browser-owned hydration and route state for this app root. */
|
|
55
|
+
_appRenderRuntime?: AppRenderRuntime;
|
|
56
|
+
/** @internal CSP nonce retained across browser route navigation. */
|
|
57
|
+
_cspNonce?: string;
|
|
58
|
+
_vnodeOwner?: object;
|
|
59
|
+
_vnodeParent?: ComponentInstance | null;
|
|
60
|
+
_vnodeParentGeneration?: object;
|
|
61
|
+
_vnodeKey?: string | number;
|
|
62
|
+
_vnodePosition?: number;
|
|
63
|
+
_wrapperDepth?: number;
|
|
64
|
+
_currentRenderToken?: number;
|
|
65
|
+
lastRenderToken?: number;
|
|
66
|
+
_pendingReadSources?: Set<ReadableSource<unknown>>;
|
|
67
|
+
_pendingReadSourceVersions?: Map<ReadableSource<unknown>, number>;
|
|
68
|
+
_lastReadSources?: Set<ReadableSource<unknown>>;
|
|
69
|
+
devWarningsEmitted?: Set<string>;
|
|
70
|
+
_placeholder?: Comment;
|
|
71
|
+
_ownedChildScopes?: Set<OwnedChildScope>;
|
|
72
|
+
errorBoundaryState?: {
|
|
73
|
+
error: unknown | null;
|
|
74
|
+
resetKey: unknown;
|
|
75
|
+
notified: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** @internal Logical error ancestry for content materialized by a portal host. */
|
|
78
|
+
_portalErrorParent?: ComponentInstance | null;
|
|
79
|
+
/** @internal Ownership identity paired with `_portalErrorParent`. */
|
|
80
|
+
_portalErrorParentGeneration?: object;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get the abort signal for the current component.
|
|
85
|
+
*
|
|
86
|
+
* The signal is guaranteed to be aborted when:
|
|
87
|
+
* - Component unmounts
|
|
88
|
+
* - Navigation occurs (different route)
|
|
89
|
+
* - Parent is destroyed
|
|
90
|
+
*/
|
|
91
|
+
declare function getSignal(): AbortSignal;
|
|
92
|
+
|
|
93
|
+
interface DerivedSubscriber {
|
|
94
|
+
_markDirty(): void;
|
|
95
|
+
_pendingDependencySources?: Set<ReadableSource<unknown>>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface ReadableSource<T = unknown> {
|
|
99
|
+
(): T;
|
|
100
|
+
_hasBeenRead?: boolean;
|
|
101
|
+
_hasEverBeenRead?: boolean;
|
|
102
|
+
_unusedStateDiagnosticEligible?: boolean;
|
|
103
|
+
_readers?: Map<
|
|
104
|
+
ComponentInstance,
|
|
105
|
+
{
|
|
106
|
+
token: number;
|
|
107
|
+
generation: object;
|
|
108
|
+
}
|
|
109
|
+
>;
|
|
110
|
+
_derivedSubscribers?: Set<DerivedSubscriber>;
|
|
111
|
+
_version?: number;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
AppRenderRuntime,
|
|
115
|
+
ComponentInstance,
|
|
116
|
+
getSignal,
|
|
117
|
+
DerivedSubscriber,
|
|
118
|
+
ReadableSource,
|
|
119
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { JSXElementType, JSXElement, Props } from '../elements.js';
|
|
2
|
+
import '../jsx-globals.js';
|
|
3
|
+
import { AuthContext, AuthRequirement } from '@askrjs/auth';
|
|
4
|
+
import { InferSchema, ObjectSchema } from '@askrjs/schema';
|
|
5
|
+
import { SSRContext } from './server.js';
|
|
6
|
+
import { ControlBoundaryState } from './control.js';
|
|
7
|
+
|
|
8
|
+
interface DOMElement {
|
|
9
|
+
type: JSXElementType;
|
|
10
|
+
props?: Props;
|
|
11
|
+
children?: VNode[];
|
|
12
|
+
key?: string | number | null;
|
|
13
|
+
[Symbol.iterator]?: never;
|
|
14
|
+
_controlState?: ControlBoundaryState;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type VNode = DOMElement | string | number | boolean | null | undefined;
|
|
18
|
+
|
|
19
|
+
type RenderableChild = VNode | JSXElement | readonly RenderableChild[];
|
|
20
|
+
|
|
21
|
+
type ComponentContext = {
|
|
22
|
+
signal: AbortSignal;
|
|
23
|
+
ssr?: SSRContext;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type ComponentFunction = (
|
|
27
|
+
props: Props,
|
|
28
|
+
context?: ComponentContext
|
|
29
|
+
) => JSXElement | VNode;
|
|
30
|
+
|
|
31
|
+
type ContextKey = symbol;
|
|
32
|
+
|
|
33
|
+
type Renderable = RenderableChild;
|
|
34
|
+
|
|
35
|
+
type ContextScopeChildren = Renderable | (() => Renderable);
|
|
36
|
+
|
|
37
|
+
/** A lexical scope created by {@link defineScope}; render it as a provider component, read it with {@link readScope}. */
|
|
38
|
+
interface Scope<T> {
|
|
39
|
+
(props: { value: T; children?: ContextScopeChildren }): JSXElement;
|
|
40
|
+
readonly key: ContextKey;
|
|
41
|
+
readonly defaultValue: T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface ContextFrame {
|
|
45
|
+
parent: ContextFrame | null;
|
|
46
|
+
values: Map<ContextKey, unknown> | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Create a new lexical {@link Scope} with `defaultValue`, readable via {@link readScope}. */
|
|
50
|
+
declare function defineScope<T>(defaultValue: T): Scope<T>;
|
|
51
|
+
|
|
52
|
+
/** Read the current value of a {@link Scope} during component render or an async resource. */
|
|
53
|
+
declare function readScope<T>(context: Scope<T>): T;
|
|
54
|
+
|
|
55
|
+
type OwnedChildScope = {
|
|
56
|
+
key: string | number;
|
|
57
|
+
dispose(): void;
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
DOMElement,
|
|
61
|
+
VNode,
|
|
62
|
+
RenderableChild,
|
|
63
|
+
ComponentContext,
|
|
64
|
+
ComponentFunction,
|
|
65
|
+
ContextKey,
|
|
66
|
+
Renderable,
|
|
67
|
+
ContextScopeChildren,
|
|
68
|
+
Scope,
|
|
69
|
+
ContextFrame,
|
|
70
|
+
defineScope,
|
|
71
|
+
readScope,
|
|
72
|
+
OwnedChildScope,
|
|
73
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { JSXElementType, JSXElement, Props } from '../elements.js';
|
|
2
|
+
import '../jsx-globals.js';
|
|
3
|
+
import { AuthContext, AuthRequirement } from '@askrjs/auth';
|
|
4
|
+
import { InferSchema, ObjectSchema } from '@askrjs/schema';
|
|
5
|
+
import { state, selector } from './state.js';
|
|
6
|
+
import { VNode, RenderableChild, ContextFrame } from './context.js';
|
|
7
|
+
import { ComponentInstance, ReadableSource } from './component.js';
|
|
8
|
+
import {
|
|
9
|
+
DOMRange,
|
|
10
|
+
ChildScope,
|
|
11
|
+
ChildScopeOwnership,
|
|
12
|
+
ChildScopeTransactionSnapshot,
|
|
13
|
+
} from './renderer.js';
|
|
14
|
+
import { on } from './lifecycle.js';
|
|
15
|
+
|
|
16
|
+
type ForItemSignal<T> = ReadableSource<T> &
|
|
17
|
+
(() => T) & {
|
|
18
|
+
peek(): T;
|
|
19
|
+
set(newValue: T, notifyReaders?: boolean): void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ForItemPropertySignal = ReadableSource<unknown> &
|
|
23
|
+
(() => unknown) & {
|
|
24
|
+
peek(): unknown;
|
|
25
|
+
set(newValue: unknown, notifyReaders?: boolean): void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type ForIndexSignal = ReadableSource<number> &
|
|
29
|
+
(() => number) & {
|
|
30
|
+
peek(): number;
|
|
31
|
+
set(
|
|
32
|
+
newValue: number | ((prev: number) => number),
|
|
33
|
+
notifyReaders?: boolean
|
|
34
|
+
): void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
interface ReactiveForItemState<T> {
|
|
38
|
+
currentItem: T;
|
|
39
|
+
itemSignal: ForItemSignal<T> | null;
|
|
40
|
+
propertySignals: Map<PropertyKey, ForItemPropertySignal> | null;
|
|
41
|
+
coalescedProperties: PropertyKey | PropertyKey[] | null;
|
|
42
|
+
coalescedProperty2: PropertyKey | null;
|
|
43
|
+
wholeItemRead: boolean;
|
|
44
|
+
proxy: T;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ForItemInstance<T> {
|
|
48
|
+
key: string | number;
|
|
49
|
+
item: T;
|
|
50
|
+
reactiveItem: T;
|
|
51
|
+
reactiveItemState: ReactiveForItemState<T> | null;
|
|
52
|
+
indexSignal: ForIndexSignal;
|
|
53
|
+
scope: ChildScope;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface FineGrainedEffectHandle<T> {
|
|
57
|
+
cleanup(): void;
|
|
58
|
+
updateCompute(nextCompute: () => T): void;
|
|
59
|
+
flush(): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type ForEachSource<T> = readonly T[] | (() => readonly T[]);
|
|
63
|
+
|
|
64
|
+
type ForKeySelector<T> = (item: T, index: number) => string | number;
|
|
65
|
+
|
|
66
|
+
type ForRenderItem<T> = (item: T, index: () => number) => VNode;
|
|
67
|
+
|
|
68
|
+
type ForCommitStrategy =
|
|
69
|
+
| 'APPEND'
|
|
70
|
+
| 'INSERT_ONE'
|
|
71
|
+
| 'REMOVE_ONE'
|
|
72
|
+
| 'TRUNCATE'
|
|
73
|
+
| 'NO_REORDER'
|
|
74
|
+
| 'SWAP'
|
|
75
|
+
| 'FULL_KEYED';
|
|
76
|
+
|
|
77
|
+
interface ForState<T> {
|
|
78
|
+
kind: 'for';
|
|
79
|
+
_contextFrame: ContextFrame | null;
|
|
80
|
+
_contextFrameChanged: boolean;
|
|
81
|
+
currentItems: readonly T[];
|
|
82
|
+
_committedItems: readonly T[];
|
|
83
|
+
eachSource: ForEachSource<T>;
|
|
84
|
+
fallback: VNode | null;
|
|
85
|
+
fallbackScope: ChildScope | null;
|
|
86
|
+
items: Map<string | number, ForItemInstance<T>>;
|
|
87
|
+
orderedKeys: Array<string | number>;
|
|
88
|
+
orderedItems: ForItemInstance<T>[];
|
|
89
|
+
orderedVNodes: VNode[];
|
|
90
|
+
byFn: ForKeySelector<T>;
|
|
91
|
+
renderFn: ForRenderItem<T>;
|
|
92
|
+
parentInstance: ComponentInstance | null;
|
|
93
|
+
lastCommitStrategy: ForCommitStrategy;
|
|
94
|
+
lastRemovedNodes: Node[];
|
|
95
|
+
lastRemovedRanges: DOMRange[];
|
|
96
|
+
pendingDirtyIndices: number[] | null;
|
|
97
|
+
pendingSwapIndices: [number, number] | null;
|
|
98
|
+
pendingMoveOnly: boolean;
|
|
99
|
+
pendingInsertedIndex: number | null;
|
|
100
|
+
pendingRemovedKey: string | number | null;
|
|
101
|
+
pendingAppendStart: number | null;
|
|
102
|
+
_hasResolvedItemDom: boolean;
|
|
103
|
+
_needsSourceReconcile: boolean;
|
|
104
|
+
_sourceEffect: FineGrainedEffectHandle<readonly T[]> | null;
|
|
105
|
+
_suspendSourceCommit: boolean;
|
|
106
|
+
_enqueueBoundaryCommit?: (() => void) | null;
|
|
107
|
+
_hasPendingBoundaryCommit?: boolean;
|
|
108
|
+
devKeyKinds?: Map<string | number, 'number' | 'string'>;
|
|
109
|
+
_transaction?: ForTransaction<T> | null;
|
|
110
|
+
_scopeOwnership: ChildScopeOwnership;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface ForItemTransactionSnapshot<T> {
|
|
114
|
+
item: T;
|
|
115
|
+
itemSignalExists: boolean;
|
|
116
|
+
itemSignalValue: T | undefined;
|
|
117
|
+
itemSignalHasBeenRead: boolean;
|
|
118
|
+
indexValue: number;
|
|
119
|
+
indexHasBeenRead: boolean;
|
|
120
|
+
propertySignalStore: Map<PropertyKey, ForItemPropertySignal> | null;
|
|
121
|
+
propertySignals: Map<
|
|
122
|
+
PropertyKey,
|
|
123
|
+
{
|
|
124
|
+
signal: ForItemPropertySignal;
|
|
125
|
+
value: unknown;
|
|
126
|
+
hasBeenRead: boolean;
|
|
127
|
+
}
|
|
128
|
+
> | null;
|
|
129
|
+
scope: ChildScopeTransactionSnapshot;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface ForTransaction<T> {
|
|
133
|
+
collectionSnapshotMode: 'copy' | 'reset-empty' | 'preserve-clear' | 'reuse';
|
|
134
|
+
currentItems: readonly T[];
|
|
135
|
+
items: Map<string | number, ForItemInstance<T>>;
|
|
136
|
+
orderedKeys: Array<string | number>;
|
|
137
|
+
orderedItems: ForItemInstance<T>[];
|
|
138
|
+
orderedVNodes: VNode[];
|
|
139
|
+
fallbackScope: ChildScope | null;
|
|
140
|
+
lastCommitStrategy: ForCommitStrategy;
|
|
141
|
+
lastRemovedNodes: Node[];
|
|
142
|
+
lastRemovedRanges: DOMRange[];
|
|
143
|
+
pendingDirtyIndices: number[] | null;
|
|
144
|
+
pendingSwapIndices: [number, number] | null;
|
|
145
|
+
pendingMoveOnly: boolean;
|
|
146
|
+
pendingInsertedIndex: number | null;
|
|
147
|
+
pendingRemovedKey: string | number | null;
|
|
148
|
+
pendingAppendStart: number | null;
|
|
149
|
+
hasResolvedItemDom: boolean;
|
|
150
|
+
needsSourceReconcile: boolean;
|
|
151
|
+
devKeyKinds?: Map<string | number, 'number' | 'string'>;
|
|
152
|
+
itemSnapshots: Map<ForItemInstance<T>, ForItemTransactionSnapshot<T>> | null;
|
|
153
|
+
unreadIndexSnapshots: Map<ForIndexSignal, number> | null;
|
|
154
|
+
fallbackScopeSnapshot: ChildScopeTransactionSnapshot | null;
|
|
155
|
+
removedScopes: ChildScope[] | null;
|
|
156
|
+
removedScopeNodes: Node[] | null;
|
|
157
|
+
removeAllItems: boolean;
|
|
158
|
+
signalEffects: Map<
|
|
159
|
+
ReadableSource<unknown>,
|
|
160
|
+
{
|
|
161
|
+
parentInstance: ComponentInstance | null;
|
|
162
|
+
notify: boolean;
|
|
163
|
+
skipInstance: ComponentInstance | null;
|
|
164
|
+
skipOwnedBy: ComponentInstance | null;
|
|
165
|
+
}
|
|
166
|
+
> | null;
|
|
167
|
+
shouldClearDomUpdateState: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface MatchBranch {
|
|
171
|
+
key: string | number;
|
|
172
|
+
render: () => VNode;
|
|
173
|
+
when: unknown;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface BranchControlStateBase {
|
|
177
|
+
_contextFrame: ContextFrame | null;
|
|
178
|
+
activeKey: string | number | null;
|
|
179
|
+
activeScope: ChildScope | null;
|
|
180
|
+
activeVNodes: VNode[];
|
|
181
|
+
lastRemovedNodes: Node[];
|
|
182
|
+
lastRemovedRanges: DOMRange[];
|
|
183
|
+
parentInstance: ComponentInstance | null;
|
|
184
|
+
_enqueueBoundaryCommit?: (() => void) | null;
|
|
185
|
+
_hasPendingBoundaryCommit?: boolean;
|
|
186
|
+
_transaction?: ControlTransaction | null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface ShowState extends BranchControlStateBase {
|
|
190
|
+
kind: 'show';
|
|
191
|
+
fallbackScope: ChildScope | null;
|
|
192
|
+
renderFallback: (() => VNode) | null;
|
|
193
|
+
renderTruthy: ((value: unknown) => VNode) | (() => VNode);
|
|
194
|
+
selectedValue: unknown;
|
|
195
|
+
truthyScope: ChildScope | null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface CaseState extends BranchControlStateBase {
|
|
199
|
+
kind: 'case';
|
|
200
|
+
fallback: (() => VNode) | null;
|
|
201
|
+
matches: MatchBranch[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
type ControlBoundaryState = ForState<unknown> | ShowState | CaseState;
|
|
205
|
+
|
|
206
|
+
type BranchStateSnapshot = {
|
|
207
|
+
activeKey: string | number | null;
|
|
208
|
+
activeScope: ChildScope | null;
|
|
209
|
+
activeVNodes: VNode[];
|
|
210
|
+
lastRemovedNodes: Node[];
|
|
211
|
+
lastRemovedRanges: DOMRange[];
|
|
212
|
+
scopeSnapshots: Map<ChildScope, ChildScopeTransactionSnapshot>;
|
|
213
|
+
fallbackScope?: ChildScope | null;
|
|
214
|
+
truthyScope?: ChildScope | null;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
interface ControlTransaction {
|
|
218
|
+
state: ShowState | CaseState;
|
|
219
|
+
snapshot: BranchStateSnapshot;
|
|
220
|
+
removedScopes: ChildScope[];
|
|
221
|
+
shouldClearDomUpdateState: boolean;
|
|
222
|
+
registered: boolean;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
type BoundaryChild = RenderableChild;
|
|
226
|
+
|
|
227
|
+
type ForBaseProps<T> = {
|
|
228
|
+
each: ForEachSource<T>;
|
|
229
|
+
fallback?: BoundaryChild;
|
|
230
|
+
/**
|
|
231
|
+
* Row renderer. Parent reactive reads must use `selector()` or thunk props;
|
|
232
|
+
* closure-captured values are snapshotted when the row is created or
|
|
233
|
+
* reconciled; changing the parent source does not rerun an existing row.
|
|
234
|
+
*/
|
|
235
|
+
children: (item: T, index: () => number) => VNode;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
type KeyedForProps<T, K extends string | number> = ForBaseProps<T> & {
|
|
239
|
+
by: (item: T, index: number) => K;
|
|
240
|
+
byIndex?: never;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
type IndexedForProps<T> = ForBaseProps<T> & {
|
|
244
|
+
by?: never;
|
|
245
|
+
byIndex: true;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/** Props for {@link For}. */
|
|
249
|
+
type ForProps<T, K extends string | number = string | number> =
|
|
250
|
+
| KeyedForProps<T, K>
|
|
251
|
+
| IndexedForProps<T>;
|
|
252
|
+
|
|
253
|
+
/** Render a keyed or indexed list, reconciling items by key instead of position. */
|
|
254
|
+
declare const For: <T, K extends string | number = string | number>(
|
|
255
|
+
props: ForProps<T, K>
|
|
256
|
+
) => JSXElement;
|
|
257
|
+
|
|
258
|
+
type ShowSource<T> = T | (() => T);
|
|
259
|
+
|
|
260
|
+
type Truthy<T> = T extends false | '' | 0 | 0n | null | undefined ? never : T;
|
|
261
|
+
|
|
262
|
+
/** Props for {@link Show}. */
|
|
263
|
+
type ShowProps<T> = {
|
|
264
|
+
when: ShowSource<T>;
|
|
265
|
+
fallback?: BoundaryChild;
|
|
266
|
+
children: BoundaryChild | ((value: Truthy<T>) => BoundaryChild);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/** Conditionally render children based on `when`, narrowing truthy values for the render function form. */
|
|
270
|
+
declare const Show: <T>(props: ShowProps<T>) => JSXElement;
|
|
271
|
+
|
|
272
|
+
type MatchChild = BoundaryChild | (() => BoundaryChild);
|
|
273
|
+
|
|
274
|
+
/** Props for {@link Match}, valid only as a direct child of {@link Case}. */
|
|
275
|
+
type MatchProps = {
|
|
276
|
+
key?: string | number | null;
|
|
277
|
+
when: unknown;
|
|
278
|
+
children: MatchChild;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/** Props for {@link Case}. */
|
|
282
|
+
type CaseProps = {
|
|
283
|
+
fallback?: BoundaryChild;
|
|
284
|
+
children?: unknown;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
/** Declares one branch of a {@link Case}; only valid as its direct child. */
|
|
288
|
+
declare function Match(_props: MatchProps): null;
|
|
289
|
+
|
|
290
|
+
/** Render the first matching {@link Match} child (by `when`), or `fallback` if none match. */
|
|
291
|
+
declare const Case: (props: CaseProps) => JSXElement;
|
|
292
|
+
export {
|
|
293
|
+
ForItemSignal,
|
|
294
|
+
ForItemPropertySignal,
|
|
295
|
+
ForIndexSignal,
|
|
296
|
+
ReactiveForItemState,
|
|
297
|
+
ForItemInstance,
|
|
298
|
+
FineGrainedEffectHandle,
|
|
299
|
+
ForEachSource,
|
|
300
|
+
ForKeySelector,
|
|
301
|
+
ForRenderItem,
|
|
302
|
+
ForCommitStrategy,
|
|
303
|
+
ForState,
|
|
304
|
+
ForItemTransactionSnapshot,
|
|
305
|
+
ForTransaction,
|
|
306
|
+
MatchBranch,
|
|
307
|
+
BranchControlStateBase,
|
|
308
|
+
ShowState,
|
|
309
|
+
CaseState,
|
|
310
|
+
ControlBoundaryState,
|
|
311
|
+
BranchStateSnapshot,
|
|
312
|
+
ControlTransaction,
|
|
313
|
+
BoundaryChild,
|
|
314
|
+
ForBaseProps,
|
|
315
|
+
KeyedForProps,
|
|
316
|
+
IndexedForProps,
|
|
317
|
+
ForProps,
|
|
318
|
+
For,
|
|
319
|
+
ShowSource,
|
|
320
|
+
Truthy,
|
|
321
|
+
ShowProps,
|
|
322
|
+
Show,
|
|
323
|
+
MatchChild,
|
|
324
|
+
MatchProps,
|
|
325
|
+
CaseProps,
|
|
326
|
+
Match,
|
|
327
|
+
Case,
|
|
328
|
+
};
|