vestjs-runtime 1.6.0 → 1.7.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/IsolateSerializer/package.json +8 -12
- package/README.md +1 -3
- package/dist/cjs/IsolateSerializer.development.js +135 -0
- package/dist/cjs/IsolateSerializer.development.js.map +1 -0
- package/dist/cjs/IsolateSerializer.js +6 -0
- package/dist/cjs/IsolateSerializer.production.js +2 -0
- package/dist/cjs/IsolateSerializer.production.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test-utils.development.js +61 -0
- package/dist/cjs/test-utils.development.js.map +1 -0
- package/dist/cjs/test-utils.js +6 -0
- package/dist/cjs/test-utils.production.js +2 -0
- package/dist/cjs/test-utils.production.js.map +1 -0
- package/dist/cjs/vestjs-runtime.development.js +686 -0
- package/dist/cjs/vestjs-runtime.development.js.map +1 -0
- package/dist/cjs/vestjs-runtime.js +6 -0
- package/dist/cjs/vestjs-runtime.production.js +2 -0
- package/dist/cjs/vestjs-runtime.production.js.map +1 -0
- package/dist/es/IsolateSerializer.development.js +133 -0
- package/dist/es/IsolateSerializer.development.js.map +1 -0
- package/dist/es/IsolateSerializer.production.js +2 -0
- package/dist/es/IsolateSerializer.production.js.map +1 -0
- package/dist/es/package.json +1 -0
- package/dist/es/test-utils.development.js +59 -0
- package/dist/es/test-utils.development.js.map +1 -0
- package/dist/es/test-utils.production.js +2 -0
- package/dist/es/test-utils.production.js.map +1 -0
- package/dist/es/vestjs-runtime.development.js +675 -0
- package/dist/es/vestjs-runtime.development.js.map +1 -0
- package/dist/es/vestjs-runtime.production.js +2 -0
- package/dist/es/vestjs-runtime.production.js.map +1 -0
- package/dist/umd/IsolateSerializer.development.js +138 -0
- package/dist/umd/IsolateSerializer.development.js.map +1 -0
- package/dist/umd/IsolateSerializer.production.js +2 -0
- package/dist/umd/IsolateSerializer.production.js.map +1 -0
- package/dist/umd/test-utils.development.js +67 -0
- package/dist/umd/test-utils.development.js.map +1 -0
- package/dist/umd/test-utils.production.js +2 -0
- package/dist/umd/test-utils.production.js.map +1 -0
- package/dist/umd/vestjs-runtime.development.js +688 -0
- package/dist/umd/vestjs-runtime.development.js.map +1 -0
- package/dist/umd/vestjs-runtime.production.js +2 -0
- package/dist/umd/vestjs-runtime.production.js.map +1 -0
- package/package.json +87 -42
- package/test-utils/package.json +8 -12
- package/types/IsolateSerializer.d.ts +42 -0
- package/types/IsolateSerializer.d.ts.map +1 -0
- package/types/test-utils.d.ts +37 -0
- package/types/test-utils.d.ts.map +1 -0
- package/types/vestjs-runtime.d.ts +257 -351
- package/types/vestjs-runtime.d.ts.map +1 -0
- package/vitest.config.ts +17 -9
- package/dist/IsolateKeys-B21aPuBk.mjs +0 -23
- package/dist/IsolateKeys-B21aPuBk.mjs.map +0 -1
- package/dist/IsolateKeys-CCvALpZC.cjs +0 -35
- package/dist/IsolateKeys-CCvALpZC.cjs.map +0 -1
- package/dist/IsolateSerializer-B1hE3gmT.mjs +0 -1004
- package/dist/IsolateSerializer-B1hE3gmT.mjs.map +0 -1
- package/dist/IsolateSerializer-pbEf5gB2.cjs +0 -1121
- package/dist/IsolateSerializer-pbEf5gB2.cjs.map +0 -1
- package/dist/chunk-CLMFDpHK.mjs +0 -18
- package/dist/exports/IsolateSerializer.cjs +0 -4
- package/dist/exports/IsolateSerializer.mjs +0 -4
- package/dist/exports/test-utils.cjs +0 -21
- package/dist/exports/test-utils.cjs.map +0 -1
- package/dist/exports/test-utils.mjs +0 -21
- package/dist/exports/test-utils.mjs.map +0 -1
- package/dist/vestjs-runtime.cjs +0 -153
- package/dist/vestjs-runtime.cjs.map +0 -1
- package/dist/vestjs-runtime.mjs +0 -117
- package/dist/vestjs-runtime.mjs.map +0 -1
- package/docs/IsolateRegistry.docs.md +0 -146
- package/docs/Isolates.md +0 -97
- package/src/Bus.ts +0 -46
- package/src/Isolate/Isolate.ts +0 -163
- package/src/Isolate/IsolateFocused.ts +0 -93
- package/src/Isolate/IsolateIndexer.ts +0 -42
- package/src/Isolate/IsolateInspector.ts +0 -93
- package/src/Isolate/IsolateKeys.ts +0 -18
- package/src/Isolate/IsolateMutator.ts +0 -165
- package/src/Isolate/IsolateRegistry.ts +0 -176
- package/src/Isolate/IsolateReorderable.ts +0 -11
- package/src/Isolate/IsolateSelectors.ts +0 -25
- package/src/Isolate/IsolateStateMachine.ts +0 -30
- package/src/Isolate/IsolateStatus.ts +0 -8
- package/src/Isolate/IsolateTransient.ts +0 -27
- package/src/Isolate/IsolateTypes.ts +0 -33
- package/src/Isolate/__tests__/Isolate.test.ts +0 -123
- package/src/Isolate/__tests__/IsolateFocused.test.ts +0 -199
- package/src/Isolate/__tests__/IsolateInspector.test.ts +0 -136
- package/src/Isolate/__tests__/IsolateMutator.test.ts +0 -164
- package/src/Isolate/__tests__/IsolatePropagation.test.ts +0 -170
- package/src/Isolate/__tests__/IsolateReorderable.test.ts +0 -111
- package/src/Isolate/__tests__/IsolateSelectors.test.ts +0 -72
- package/src/Isolate/__tests__/IsolateStatus.test.ts +0 -44
- package/src/Isolate/__tests__/IsolateTransient.test.ts +0 -58
- package/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap +0 -71
- package/src/Isolate/__tests__/asyncIsolate.test.ts +0 -85
- package/src/IsolateWalker.ts +0 -359
- package/src/Orchestrator/RuntimeStates.ts +0 -4
- package/src/Reconciler.ts +0 -178
- package/src/RuntimeEvents.ts +0 -9
- package/src/VestRuntime.ts +0 -421
- package/src/__tests__/Bus.test.ts +0 -57
- package/src/__tests__/IsolateWalker.iterative.test.ts +0 -77
- package/src/__tests__/IsolateWalker.test.ts +0 -418
- package/src/__tests__/Reconciler.test.ts +0 -193
- package/src/__tests__/Reconciler.transient.test.ts +0 -166
- package/src/__tests__/VestRuntime.test.ts +0 -212
- package/src/__tests__/VestRuntimeStateMachine.test.ts +0 -36
- package/src/__tests__/vestjs-runtime.test.ts +0 -19
- package/src/errors/ErrorStrings.ts +0 -6
- package/src/exports/IsolateSerializer.ts +0 -131
- package/src/exports/__tests__/IsolateSerializer.test.ts +0 -334
- package/src/exports/__tests__/IsolateSerializer.transient.test.ts +0 -101
- package/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap +0 -5
- package/src/exports/test-utils.ts +0 -17
- package/src/vestjs-runtime.ts +0 -28
- package/types/Isolate-DChR7h5K.d.mts +0 -58
- package/types/Isolate-DChR7h5K.d.mts.map +0 -1
- package/types/Isolate-HYIh82M8.d.cts +0 -58
- package/types/Isolate-HYIh82M8.d.cts.map +0 -1
- package/types/IsolateSerializer-BCg01Px5.d.mts +0 -13
- package/types/IsolateSerializer-BCg01Px5.d.mts.map +0 -1
- package/types/IsolateSerializer-CQpP6A4m.d.cts +0 -13
- package/types/IsolateSerializer-CQpP6A4m.d.cts.map +0 -1
- package/types/exports/IsolateSerializer.d.cts +0 -3
- package/types/exports/IsolateSerializer.d.mts +0 -3
- package/types/exports/test-utils.d.cts +0 -7
- package/types/exports/test-utils.d.cts.map +0 -1
- package/types/exports/test-utils.d.mts +0 -7
- package/types/exports/test-utils.d.mts.map +0 -1
- package/types/vestjs-runtime.d.cts +0 -372
- package/types/vestjs-runtime.d.cts.map +0 -1
- package/types/vestjs-runtime.d.mts +0 -370
- package/types/vestjs-runtime.d.mts.map +0 -1
|
@@ -1,372 +1,278 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type RuntimeEvents = {
|
|
9
|
-
ASYNC_ISOLATE_DONE: TIsolate;
|
|
10
|
-
ISOLATE_DONE: TIsolate;
|
|
11
|
-
ISOLATE_ENTER: TIsolate;
|
|
12
|
-
ISOLATE_PENDING: TIsolate;
|
|
13
|
-
ISOLATE_RECONCILED: TIsolate;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CB, Maybe, Nullable, TinyState, BusType, DynamicValue } from "vest-utils";
|
|
3
|
+
declare const RuntimeEvents: {
|
|
4
|
+
ASYNC_ISOLATE_DONE: string;
|
|
5
|
+
ISOLATE_DONE: string;
|
|
6
|
+
ISOLATE_ENTER: string;
|
|
7
|
+
ISOLATE_PENDING: string;
|
|
14
8
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
declare enum IsolateKeys {
|
|
10
|
+
Type = "$type",
|
|
11
|
+
Keys = "keys",
|
|
12
|
+
Key = "key",
|
|
13
|
+
Parent = "parent",
|
|
14
|
+
Data = "data",
|
|
15
|
+
AllowReorder = "allowReorder",
|
|
16
|
+
Status = "status",
|
|
17
|
+
AbortController = "abortController",
|
|
18
|
+
Children = "children"
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
type IsolateKey = Nullable<string>;
|
|
21
|
+
type TIsolate<P extends IsolatePayload = IsolatePayload> = {
|
|
22
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
23
|
+
[IsolateKeys.Parent]: Nullable<TIsolate>;
|
|
24
|
+
[IsolateKeys.Type]: string;
|
|
25
|
+
[IsolateKeys.Keys]: Nullable<Record<string, TIsolate>>;
|
|
26
|
+
[IsolateKeys.Data]: DataOnly<P>;
|
|
27
|
+
[IsolateKeys.Status]?: string;
|
|
28
|
+
[IsolateKeys.AbortController]: AbortController;
|
|
29
|
+
children: Nullable<TIsolate[]>;
|
|
30
|
+
key: IsolateKey;
|
|
31
|
+
output: any;
|
|
32
|
+
} & UsedFeaturesOnly<P>;
|
|
33
|
+
type DataOnly<P extends IsolatePayload> = Omit<P, keyof IsolateFeatures>;
|
|
34
|
+
type UsedFeaturesOnly<P extends IsolatePayload> = Pick<P, keyof IsolateFeatures>;
|
|
35
|
+
declare class Isolate {
|
|
36
|
+
// eslint-disable-next-line max-statements
|
|
37
|
+
static create<Payload extends IsolatePayload>(type: string, callback: CB, payload?: Maybe<Payload>, key?: IsolateKey): TIsolate<Payload>;
|
|
38
|
+
static isIsolate(node: any): node is TIsolate;
|
|
39
|
+
}
|
|
40
|
+
type IsolateData = Record<string, any>;
|
|
41
|
+
type IsolatePayload = IsolateData & IsolateFeatures;
|
|
42
|
+
type IsolateFeatures = {
|
|
43
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
44
|
+
[IsolateKeys.Status]?: string;
|
|
45
|
+
};
|
|
46
|
+
// import { isSameIsolateType } from 'IsolateSelectors';
|
|
47
|
+
// I would rather not use `any` here, but instead use `Isolate`.
|
|
48
|
+
// The problem is that it breaks the actual implementation of `Isolate` in `IsolateTest`
|
|
49
|
+
// As it is not properly extending `Isolate`.
|
|
50
|
+
interface IRecociler<I = any> {
|
|
51
|
+
(currentNode: I, historyNode: I): Nullable<I>;
|
|
34
52
|
}
|
|
35
|
-
declare
|
|
36
|
-
|
|
53
|
+
declare class Reconciler {
|
|
54
|
+
/**
|
|
55
|
+
* Reconciles the current isolate with the history isolate.
|
|
56
|
+
* If the current isolate is of a different type than the history isolate,
|
|
57
|
+
* the current isolate is returned.
|
|
58
|
+
* Otherwise, the reconciler function is called to determine the next isolate.
|
|
59
|
+
* If the reconciler function returns null or undefined, the base reconciler is used.
|
|
60
|
+
* If no history isolate exists, the current isolate is returned.
|
|
61
|
+
* @param node The current isolate to reconcile.
|
|
62
|
+
* @returns The next isolate after reconciliation.
|
|
63
|
+
*/
|
|
64
|
+
static reconcile(node: TIsolate): TIsolate;
|
|
65
|
+
static dropNextNodesOnReorder<I extends TIsolate>(reorderLogic: (newNode: I, prevNode: Maybe<TIsolate>) => boolean, newNode: I, prevNode: Maybe<TIsolate>): boolean;
|
|
66
|
+
static handleIsolateNodeWithKey<I extends TIsolate>(node: TIsolate,
|
|
67
|
+
// The revoke function allows the caller to revoke the previous node
|
|
68
|
+
revoke: ((node: I) => boolean) | false): TIsolate;
|
|
37
69
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
declare function pluck(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): void;
|
|
109
|
-
/**
|
|
110
|
-
* Finds the closest ancestor of the startNode that satisfies the predicate.
|
|
111
|
-
* @param startNode - The starting node.
|
|
112
|
-
* @param predicate - The predicate to match.
|
|
113
|
-
* @returns The found ancestor or null.
|
|
114
|
-
*/
|
|
115
|
-
declare function closest<I extends TIsolate = TIsolate>(startNode: TIsolate, predicate: (node: TIsolate) => boolean): Nullable<I>;
|
|
116
|
-
/**
|
|
117
|
-
* Checks if an ancestor satisfying the predicate exists.
|
|
118
|
-
* @param startNode - The starting node.
|
|
119
|
-
* @param predicate - The predicate to match.
|
|
120
|
-
* @returns True if such an ancestor exists, false otherwise.
|
|
121
|
-
*/
|
|
122
|
-
declare function closestExists(startNode: TIsolate, predicate: (node: TIsolate) => boolean): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Traverses the tree and returns the first non-nullish value returned by the callback.
|
|
125
|
-
* It optimizes traversal by only visiting nodes that have pending isolates or are pending themselves.
|
|
126
|
-
*/
|
|
127
|
-
declare function mapFirst<T>(startNode: TIsolate, callback: (isolate: TIsolate, breakout: (value: T) => void) => void): T | null;
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/Orchestrator/RuntimeStates.d.ts
|
|
130
|
-
declare enum RuntimeState {
|
|
131
|
-
PENDING = "PENDING",
|
|
132
|
-
STABLE = "STABLE",
|
|
70
|
+
declare namespace Walker {
|
|
71
|
+
enum IsolateKeys {
|
|
72
|
+
Type = "$type",
|
|
73
|
+
Keys = "keys",
|
|
74
|
+
Key = "key",
|
|
75
|
+
Parent = "parent",
|
|
76
|
+
Data = "data",
|
|
77
|
+
AllowReorder = "allowReorder",
|
|
78
|
+
Status = "status",
|
|
79
|
+
AbortController = "abortController",
|
|
80
|
+
Children = "children"
|
|
81
|
+
}
|
|
82
|
+
const ExcludedFromDump: Set<IsolateKeys>;
|
|
83
|
+
type IsolateKey = Nullable<string>;
|
|
84
|
+
type TIsolate<P extends IsolatePayload = IsolatePayload> = {
|
|
85
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
86
|
+
[IsolateKeys.Parent]: Nullable<TIsolate>;
|
|
87
|
+
[IsolateKeys.Type]: string;
|
|
88
|
+
[IsolateKeys.Keys]: Nullable<Record<string, TIsolate>>;
|
|
89
|
+
[IsolateKeys.Data]: DataOnly<P>;
|
|
90
|
+
[IsolateKeys.Status]?: string;
|
|
91
|
+
[IsolateKeys.AbortController]: AbortController;
|
|
92
|
+
children: Nullable<TIsolate[]>;
|
|
93
|
+
key: IsolateKey;
|
|
94
|
+
output: any;
|
|
95
|
+
} & UsedFeaturesOnly<P>;
|
|
96
|
+
type DataOnly<P extends IsolatePayload> = Omit<P, keyof IsolateFeatures>;
|
|
97
|
+
type UsedFeaturesOnly<P extends IsolatePayload> = Pick<P, keyof IsolateFeatures>;
|
|
98
|
+
class Isolate {
|
|
99
|
+
// eslint-disable-next-line max-statements
|
|
100
|
+
static create<Payload extends IsolatePayload>(type: string, callback: CB, payload?: Maybe<Payload>, key?: IsolateKey): TIsolate<Payload>;
|
|
101
|
+
static isIsolate(node: any): node is TIsolate;
|
|
102
|
+
}
|
|
103
|
+
type IsolateData = Record<string, any>;
|
|
104
|
+
type IsolatePayload = IsolateData & IsolateFeatures;
|
|
105
|
+
type IsolateFeatures = {
|
|
106
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
107
|
+
[IsolateKeys.Status]?: string;
|
|
108
|
+
};
|
|
109
|
+
type VisitOnlyPredicate = (isolate: TIsolate) => boolean;
|
|
110
|
+
// eslint-disable-next-line
|
|
111
|
+
function walk(startNode: TIsolate, callback: (isolate: TIsolate, breakout: CB<void>) => void, visitOnly?: VisitOnlyPredicate): void;
|
|
112
|
+
function reduce<T>(startNode: TIsolate, callback: (acc: T, isolate: TIsolate, breakout: CB<void>) => T, initialValue: T, visitOnly?: VisitOnlyPredicate): T;
|
|
113
|
+
// This function returns true if the given predicate function returns true for any Isolate object in the tree.
|
|
114
|
+
// If visitOnly is provided, only Isolate objects that satisfy the predicate are visited.
|
|
115
|
+
function some(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): boolean;
|
|
116
|
+
// This function returns true if the given predicate function returns true for any Isolate object in the tree.
|
|
117
|
+
// If visitOnly is provided, only Isolate objects that satisfy the predicate are visited.
|
|
118
|
+
function has(startNode: TIsolate, match: VisitOnlyPredicate): boolean;
|
|
119
|
+
// traverses up to a parent node that satisfies the predicate
|
|
120
|
+
// and returns the first direct descendant that satisfies the predicate
|
|
121
|
+
function findClosest<I extends TIsolate = TIsolate>(startNode: TIsolate, predicate: (node: TIsolate) => boolean): Nullable<I>;
|
|
122
|
+
// This function returns the first Isolate object in the tree that satisfies the given predicate function.
|
|
123
|
+
// If visitOnly is provided, only Isolate objects that satisfy the predicate are visited.
|
|
124
|
+
function find(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): Nullable<TIsolate>;
|
|
125
|
+
// this function acts like find, but returns an array of all matching nodes
|
|
126
|
+
function findAll(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): TIsolate[];
|
|
127
|
+
// This function returns true if the given predicate function returns true for every Isolate object in the tree.
|
|
128
|
+
// If visitOnly is provided, only Isolate objects that satisfy the predicate are visited.
|
|
129
|
+
function every(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): boolean;
|
|
130
|
+
// This function removes all Isolate objects in the tree that
|
|
131
|
+
// satisfy the given predicate function and have a parent.
|
|
132
|
+
// If visitOnly is provided, only Isolate objects that satisfy the predicate are visited.
|
|
133
|
+
function pluck(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): void;
|
|
134
|
+
// Returns the closest ancestor Isolate object of the given
|
|
135
|
+
//startNode that satisfies the given predicate function.
|
|
136
|
+
function closest(startNode: TIsolate, predicate: (node: TIsolate) => boolean): Nullable<TIsolate>;
|
|
137
|
+
// This function returns true if the closest ancestor Isolates of the
|
|
138
|
+
// given startNode that satisfies the given predicate function exists.
|
|
139
|
+
function closestExists(startNode: TIsolate, predicate: (node: TIsolate) => boolean): boolean;
|
|
133
140
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
type CTXType = StateRefType & {
|
|
142
|
+
historyNode: Nullable<TIsolate>;
|
|
143
|
+
runtimeNode: Nullable<TIsolate>;
|
|
144
|
+
runtimeRoot: Nullable<TIsolate>;
|
|
145
|
+
stateRef: StateRefType;
|
|
146
|
+
};
|
|
140
147
|
type StateRefType = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
Bus: BusType;
|
|
149
|
+
appData: Record<string, any>;
|
|
150
|
+
historyRoot: TinyState<Nullable<TIsolate>>;
|
|
151
|
+
Reconciler: IRecociler;
|
|
152
|
+
};
|
|
153
|
+
declare const RuntimeApi: {
|
|
154
|
+
Run: <R>(value: Partial<CTXType>, fn: () => R) => R;
|
|
155
|
+
createRef: typeof createRef;
|
|
156
|
+
persist: typeof persist;
|
|
157
|
+
reset: typeof reset;
|
|
158
|
+
useAvailableRoot: typeof useAvailableRoot;
|
|
159
|
+
useCurrentCursor: typeof useCurrentCursor;
|
|
160
|
+
useHistoryRoot: typeof useHistoryRoot;
|
|
161
|
+
useSetHistoryRoot: typeof useSetHistoryRoot;
|
|
162
|
+
useSetNextIsolateChild: typeof useSetNextIsolateChild;
|
|
163
|
+
useXAppData: typeof useXAppData;
|
|
146
164
|
};
|
|
147
|
-
/**
|
|
148
|
-
* Retrieves the current runtime state (e.g., STABLE, PENDING).
|
|
149
|
-
*/
|
|
150
|
-
declare function useRuntimeState(): RuntimeState;
|
|
151
|
-
/**
|
|
152
|
-
* Checks if the runtime is currently stable (no pending tests).
|
|
153
|
-
*/
|
|
154
|
-
declare function useIsStable(): boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Retrieves the application-specific data stored in the runtime.
|
|
157
|
-
*/
|
|
158
165
|
declare function useXAppData<T = object>(): T;
|
|
159
|
-
|
|
160
|
-
* Creates a new state reference for such as the history root, pending isolates, and the current runtime state.
|
|
161
|
-
*/
|
|
162
|
-
declare function createRef(Reconciler: IReconciler, setter: DynamicValue<Record<string, any>>): StateRefType;
|
|
163
|
-
/**
|
|
164
|
-
* Dispatches a runtime event to the internal Bus.
|
|
165
|
-
* This is used to trigger state changes and notifications.
|
|
166
|
-
*/
|
|
167
|
-
declare function dispatch<T extends keyof RuntimeEvents>(event: RuntimeEvents[T] extends void ? {
|
|
168
|
-
type: T;
|
|
169
|
-
payload?: void;
|
|
170
|
-
} : {
|
|
171
|
-
type: T;
|
|
172
|
-
payload: RuntimeEvents[T];
|
|
173
|
-
}): void;
|
|
174
|
-
/**
|
|
175
|
-
* Registers an isolate as pending.
|
|
176
|
-
* This is used to track async tests and other async operations.
|
|
177
|
-
*/
|
|
178
|
-
declare function registerPending(isolate: TIsolate): void;
|
|
179
|
-
/**
|
|
180
|
-
* Removes an isolate from the pending set.
|
|
181
|
-
* This is used when an async test or operation completes.
|
|
182
|
-
*/
|
|
183
|
-
declare function removePending(isolate: TIsolate): void;
|
|
184
|
-
/**
|
|
185
|
-
* Persists the current runtime context to a callback function.
|
|
186
|
-
* This allows the callback to be executed later (e.g. in an async operation)
|
|
187
|
-
* while still having access to the correct runtime context.
|
|
188
|
-
*/
|
|
166
|
+
declare function createRef(Reconciler: IRecociler, setter: DynamicValue<Record<string, any>>): StateRefType;
|
|
189
167
|
declare function persist<T extends (...args: any[]) => any>(cb: T): T;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
168
|
+
declare function useHistoryRoot(): [
|
|
169
|
+
value: Nullable<TIsolate<{
|
|
170
|
+
[x: string]: any;
|
|
171
|
+
} & {
|
|
172
|
+
allowReorder?: boolean | undefined;
|
|
173
|
+
status?: string | undefined;
|
|
174
|
+
}>>,
|
|
175
|
+
setValue: (next: Nullable<TIsolate<{
|
|
176
|
+
[x: string]: any;
|
|
177
|
+
} & {
|
|
178
|
+
allowReorder?: boolean | undefined;
|
|
179
|
+
status?: string | undefined;
|
|
180
|
+
}>> | import("vest-utils").CB<Nullable<TIsolate<{
|
|
181
|
+
[x: string]: any;
|
|
182
|
+
} & {
|
|
183
|
+
allowReorder?: boolean | undefined;
|
|
184
|
+
status?: string | undefined;
|
|
185
|
+
}>>, [
|
|
186
|
+
prev: Nullable<TIsolate<{
|
|
187
|
+
[x: string]: any;
|
|
188
|
+
} & {
|
|
189
|
+
allowReorder?: boolean | undefined;
|
|
190
|
+
status?: string | undefined;
|
|
191
|
+
}>>
|
|
192
|
+
]>) => void,
|
|
193
|
+
resetValue: () => void
|
|
194
|
+
];
|
|
198
195
|
declare function useSetHistoryRoot(history: TIsolate): void;
|
|
199
|
-
/**
|
|
200
|
-
* Retrieves the current cursor position within the active isolate.
|
|
201
|
-
*/
|
|
202
196
|
declare function useCurrentCursor(): number;
|
|
203
|
-
/**
|
|
204
|
-
* Adds a child isolate to the current isolate and sets the parent-child relationship.
|
|
205
|
-
*/
|
|
206
197
|
declare function useSetNextIsolateChild(child: TIsolate): void;
|
|
207
|
-
/**
|
|
208
|
-
* Returns the available root isolate.
|
|
209
|
-
* If a runtime root exists (i.e. we are currently running a suite), it returns that.
|
|
210
|
-
* Otherwise, it returns the history root (i.e. the result of the last run).
|
|
211
|
-
*/
|
|
212
198
|
declare function useAvailableRoot<I extends TIsolate = TIsolate>(): I;
|
|
213
|
-
/**
|
|
214
|
-
* Checks whether a specific key is heavily focused out.
|
|
215
|
-
*/
|
|
216
|
-
declare function useIsFocusedOut(key?: string): boolean;
|
|
217
|
-
declare function hasImplicitOnly(): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Resets the history root.
|
|
220
|
-
*/
|
|
221
199
|
declare function reset(): void;
|
|
222
|
-
declare const RuntimeApi: {
|
|
223
|
-
Run: any;
|
|
224
|
-
createRef: typeof createRef;
|
|
225
|
-
dispatch: typeof dispatch;
|
|
226
|
-
hasImplicitOnly: typeof hasImplicitOnly;
|
|
227
|
-
persist: typeof persist;
|
|
228
|
-
registerPending: typeof registerPending;
|
|
229
|
-
removePending: typeof removePending;
|
|
230
|
-
reset: typeof reset;
|
|
231
|
-
useAvailableRoot: typeof useAvailableRoot;
|
|
232
|
-
useCurrentCursor: typeof useCurrentCursor;
|
|
233
|
-
useHistoryRoot: typeof useHistoryRoot;
|
|
234
|
-
useIsFocusedOut: typeof useIsFocusedOut;
|
|
235
|
-
useIsStable: typeof useIsStable;
|
|
236
|
-
useRuntimeState: typeof useRuntimeState;
|
|
237
|
-
useSetHistoryRoot: typeof useSetHistoryRoot;
|
|
238
|
-
useSetNextIsolateChild: typeof useSetNextIsolateChild;
|
|
239
|
-
useXAppData: typeof useXAppData;
|
|
240
|
-
};
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/Isolate/IsolateInspector.d.ts
|
|
243
200
|
declare class IsolateInspector {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
static getStatus(isolate: Nullable<TIsolate>): IsolateStatus;
|
|
251
|
-
static statusEquals(isolate: Nullable<TIsolate>, status: IsolateStatus): boolean;
|
|
252
|
-
static isPending(isolate: Nullable<TIsolate>): boolean;
|
|
253
|
-
static isHasPending(isolate: Nullable<TIsolate>): boolean;
|
|
254
|
-
static hasPending(isolate: Nullable<TIsolate>): boolean;
|
|
255
|
-
static hasActiveChildren(isolate: Nullable<TIsolate>): boolean;
|
|
256
|
-
static getParent(isolate: Nullable<TIsolate>): Nullable<TIsolate>;
|
|
201
|
+
static at(isolate: Nullable<TIsolate>, at: number): Nullable<TIsolate>;
|
|
202
|
+
static cursor(isolate: Nullable<TIsolate>): number;
|
|
203
|
+
static canReorder<I extends TIsolate>(isolate: Nullable<I>): boolean;
|
|
204
|
+
static allowsReorder<I extends Record<any, any>>(isolate: Nullable<I>): boolean;
|
|
205
|
+
static usesKey(isolate: Nullable<TIsolate>): boolean;
|
|
206
|
+
static getChildByKey(isolate: Nullable<TIsolate>, key: string): Nullable<TIsolate>;
|
|
257
207
|
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/Isolate/IsolateMutator.d.ts
|
|
260
208
|
declare class IsolateMutator {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
static setStatus(isolate: TIsolate, status: IsolateStatus, payload?: any): Result<IsolateStatus, string>;
|
|
271
|
-
static setPending(isolate: TIsolate): void;
|
|
272
|
-
static setHasPending(isolate: TIsolate): Result<IsolateStatus, string>;
|
|
273
|
-
static setDone(isolate: TIsolate): void;
|
|
274
|
-
}
|
|
275
|
-
declare namespace Bus_d_exports {
|
|
276
|
-
export { useBus, useEmit, usePrepareEmitter };
|
|
209
|
+
static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate;
|
|
210
|
+
static saveOutput(isolate: TIsolate, output: any): TIsolate;
|
|
211
|
+
static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate;
|
|
212
|
+
static addChild(isolate: TIsolate, child: TIsolate): void;
|
|
213
|
+
static removeChild(isolate: TIsolate, node: TIsolate): void;
|
|
214
|
+
static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void;
|
|
215
|
+
static slice(isolate: TIsolate, at: number): void;
|
|
216
|
+
static setData(isolate: TIsolate, data: any): void;
|
|
217
|
+
static abort(isolate: TIsolate, reason?: string): void;
|
|
277
218
|
}
|
|
278
|
-
declare
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
219
|
+
declare namespace Bus {
|
|
220
|
+
function useBus(): import("vest-utils").BusType;
|
|
221
|
+
/*
|
|
222
|
+
Returns an emitter, but it also has a shortcut for emitting an event immediately
|
|
223
|
+
by passing an event name.
|
|
224
|
+
*/
|
|
225
|
+
function useEmit(event?: string, data?: any): (event: string, data?: any) => void;
|
|
226
|
+
function usePrepareEmitter<T = void>(event: string): (arg: T) => void;
|
|
284
227
|
}
|
|
285
|
-
declare
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
228
|
+
declare namespace IsolateSelectors {
|
|
229
|
+
enum IsolateKeys {
|
|
230
|
+
Type = "$type",
|
|
231
|
+
Keys = "keys",
|
|
232
|
+
Key = "key",
|
|
233
|
+
Parent = "parent",
|
|
234
|
+
Data = "data",
|
|
235
|
+
AllowReorder = "allowReorder",
|
|
236
|
+
Status = "status",
|
|
237
|
+
AbortController = "abortController",
|
|
238
|
+
Children = "children"
|
|
239
|
+
}
|
|
240
|
+
const ExcludedFromDump: Set<IsolateKeys>;
|
|
241
|
+
type IsolateKey = Nullable<string>;
|
|
242
|
+
type TIsolate<P extends IsolatePayload = IsolatePayload> = {
|
|
243
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
244
|
+
[IsolateKeys.Parent]: Nullable<TIsolate>;
|
|
245
|
+
[IsolateKeys.Type]: string;
|
|
246
|
+
[IsolateKeys.Keys]: Nullable<Record<string, TIsolate>>;
|
|
247
|
+
[IsolateKeys.Data]: DataOnly<P>;
|
|
248
|
+
[IsolateKeys.Status]?: string;
|
|
249
|
+
[IsolateKeys.AbortController]: AbortController;
|
|
250
|
+
children: Nullable<TIsolate[]>;
|
|
251
|
+
key: IsolateKey;
|
|
252
|
+
output: any;
|
|
253
|
+
} & UsedFeaturesOnly<P>;
|
|
254
|
+
type DataOnly<P extends IsolatePayload> = Omit<P, keyof IsolateFeatures>;
|
|
255
|
+
type UsedFeaturesOnly<P extends IsolatePayload> = Pick<P, keyof IsolateFeatures>;
|
|
256
|
+
class Isolate {
|
|
257
|
+
// eslint-disable-next-line max-statements
|
|
258
|
+
static create<Payload extends IsolatePayload>(type: string, callback: CB, payload?: Maybe<Payload>, key?: IsolateKey): TIsolate<Payload>;
|
|
259
|
+
static isIsolate(node: any): node is TIsolate;
|
|
260
|
+
}
|
|
261
|
+
type IsolateData = Record<string, any>;
|
|
262
|
+
type IsolatePayload = IsolateData & IsolateFeatures;
|
|
263
|
+
type IsolateFeatures = {
|
|
264
|
+
[IsolateKeys.AllowReorder]?: boolean;
|
|
265
|
+
[IsolateKeys.Status]?: string;
|
|
266
|
+
};
|
|
267
|
+
function isIsolateType<I extends TIsolate>(node: Maybe<TIsolate>, type: string): node is I;
|
|
268
|
+
function isSameIsolateType<A extends TIsolate, B extends TIsolate>(a: A, b: B): boolean;
|
|
269
|
+
function isSameIsolateIdentity<A extends TIsolate, B extends TIsolate>(a: A, b: B): boolean;
|
|
293
270
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* Configuration for a registry category.
|
|
300
|
-
*/
|
|
301
|
-
type RegistryCategoryConfig = {
|
|
302
|
-
predicate: (isolate: TIsolate) => boolean;
|
|
303
|
-
getKey: (isolate: TIsolate) => string;
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* Updates the registration of an isolate in all relevant indices based on provided predicates.
|
|
307
|
-
*
|
|
308
|
-
* @param isolate - The isolate node to update.
|
|
309
|
-
* @param predicates - A record of category keys and their corresponding predicate configurations.
|
|
310
|
-
*/
|
|
311
|
-
declare function useUpdateRegistry(isolate: TIsolate, predicates: Record<string, RegistryCategoryConfig>): void;
|
|
312
|
-
/**
|
|
313
|
-
* Retrieves isolates from the registry based on a category and an optional key.
|
|
314
|
-
*/
|
|
315
|
-
declare function useGetFromRegistry(category: string, key?: string): Set<TIsolate>;
|
|
316
|
-
/**
|
|
317
|
-
* Checks if the registry contains any isolates for a given category and optional key.
|
|
318
|
-
*/
|
|
319
|
-
declare function useHasFromRegistry(category: string, key?: string): boolean;
|
|
320
|
-
/**
|
|
321
|
-
* Removes all entries for a specific key from the registry.
|
|
322
|
-
*/
|
|
323
|
-
declare function useRemoveFieldFromRegistry(key: string): void;
|
|
324
|
-
/**
|
|
325
|
-
* Clears all registry entries from the root isolate.
|
|
326
|
-
*/
|
|
327
|
-
declare function useClearRegistry(root: TIsolate): void;
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region src/Isolate/IsolateReorderable.d.ts
|
|
330
|
-
declare function IsolateReorderable(callback: CB, type?: string, payload?: Record<string, any>): TIsolate<IsolatePayload<Record<string, any>>>;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region src/Isolate/IsolateTransient.d.ts
|
|
333
|
-
/**
|
|
334
|
-
* Creates a transient isolate.
|
|
335
|
-
*
|
|
336
|
-
* Transient isolates are isolates that:
|
|
337
|
-
* 1. Do not persist in the history tree.
|
|
338
|
-
* 2. Are not reconciled with previous runs.
|
|
339
|
-
* 3. Do not appear in the serialized suite dump.
|
|
340
|
-
* 4. Do not interfere with the index of their siblings (they are skipped by the reconciler).
|
|
341
|
-
*
|
|
342
|
-
* This is useful for "structural" isolates that are used for control flow or grouping
|
|
343
|
-
* but do not hold state that needs to be preserved between runs, such as `focused` (skip/only) isolates.
|
|
344
|
-
*/
|
|
345
|
-
declare function IsolateTransient<Payload extends IsolatePayload>(callback: CB, type?: string, payload?: Payload): TIsolate<Payload>;
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region src/Isolate/IsolateFocused.d.ts
|
|
348
|
-
declare enum FocusModes {
|
|
349
|
-
SKIP = "skip",
|
|
350
|
-
ONLY = "only",
|
|
351
|
-
}
|
|
352
|
-
type FocusMatchExclusion = Maybe<OneOrMoreOf<string>>;
|
|
353
|
-
type TIsolateFocused = TIsolate<IsolateFocusedPayload>;
|
|
354
|
-
type IsolateFocusedPayload = {
|
|
355
|
-
focusMode: FocusModes;
|
|
356
|
-
match: FocusMatchExclusion;
|
|
357
|
-
matchAll: boolean;
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* Creates a focused isolate.
|
|
361
|
-
* Focused isolates are transient because they only affect the current run
|
|
362
|
-
* and do not need to be preserved in history or appearing in the suite result.
|
|
363
|
-
*/
|
|
364
|
-
declare function IsolateFocused(focusMode: FocusModes, match?: true | FocusMatchExclusion): TIsolateFocused | undefined;
|
|
365
|
-
declare class FocusSelectors {
|
|
366
|
-
static isSkipFocused(focus: Nullish<TIsolateFocused>, fieldName?: string): boolean;
|
|
367
|
-
static isOnlyFocused(focus: Nullish<TIsolateFocused>, fieldName?: string): boolean;
|
|
368
|
-
static isIsolateFocused(isolate: TIsolate): isolate is TIsolateFocused;
|
|
271
|
+
declare class IsolateSerializer {
|
|
272
|
+
// eslint-disable-next-line max-statements, complexity, max-lines-per-function
|
|
273
|
+
static deserialize(node: Record<string, any> | TIsolate | string): TIsolate;
|
|
274
|
+
static serialize(isolate: Nullable<TIsolate>, replacer: (value: any, key: string) => any): string;
|
|
275
|
+
static validateIsolate(node: Record<string, any> | TIsolate): asserts node is TIsolate;
|
|
369
276
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
//# sourceMappingURL=vestjs-runtime.d.cts.map
|
|
277
|
+
export { RuntimeEvents, IsolateKey, TIsolate, Isolate, Reconciler, IRecociler, Walker, RuntimeApi as VestRuntime, IsolateInspector, IsolateMutator, Bus, IsolateSelectors, IsolateSerializer };
|
|
278
|
+
//# sourceMappingURL=vestjs-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vestjs-runtime.d.ts","sourceRoot":"","sources":["../src/vestjs-runtime.ts","../src/RuntimeEvents.ts","../src/errors/ErrorStrings.ts","../src/Isolate/IsolateInspector.ts","../src/Isolate/IsolateMutator.ts","../src/Isolate/IsolateKeys.ts","../src/Isolate/IsolateSelectors.ts","../src/Reconciler.ts","../src/VestRuntime.ts","../src/Bus.ts","../src/Isolate/Isolate.ts","../src/IsolateWalker.ts","../src/exports/IsolateSerializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,uLAAiB,CAAsB"}
|