vestjs-runtime 1.7.0 → 2.0.2

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.
Files changed (136) hide show
  1. package/IsolateSerializer/package.json +12 -8
  2. package/README.md +3 -1
  3. package/dist/IsolateKeys-B21aPuBk.mjs +23 -0
  4. package/dist/IsolateKeys-B21aPuBk.mjs.map +1 -0
  5. package/dist/IsolateKeys-CCvALpZC.cjs +35 -0
  6. package/dist/IsolateKeys-CCvALpZC.cjs.map +1 -0
  7. package/dist/IsolateSerializer-B1hE3gmT.mjs +1004 -0
  8. package/dist/IsolateSerializer-B1hE3gmT.mjs.map +1 -0
  9. package/dist/IsolateSerializer-pbEf5gB2.cjs +1121 -0
  10. package/dist/IsolateSerializer-pbEf5gB2.cjs.map +1 -0
  11. package/dist/chunk-CLMFDpHK.mjs +18 -0
  12. package/dist/exports/IsolateSerializer.cjs +4 -0
  13. package/dist/exports/IsolateSerializer.mjs +4 -0
  14. package/dist/exports/test-utils.cjs +21 -0
  15. package/dist/exports/test-utils.cjs.map +1 -0
  16. package/dist/exports/test-utils.mjs +21 -0
  17. package/dist/exports/test-utils.mjs.map +1 -0
  18. package/dist/vestjs-runtime.cjs +153 -0
  19. package/dist/vestjs-runtime.cjs.map +1 -0
  20. package/dist/vestjs-runtime.mjs +117 -0
  21. package/dist/vestjs-runtime.mjs.map +1 -0
  22. package/docs/IsolateRegistry.docs.md +146 -0
  23. package/docs/Isolates.md +97 -0
  24. package/package.json +43 -88
  25. package/src/Bus.ts +46 -0
  26. package/src/Isolate/Isolate.ts +163 -0
  27. package/src/Isolate/IsolateFocused.ts +93 -0
  28. package/src/Isolate/IsolateIndexer.ts +42 -0
  29. package/src/Isolate/IsolateInspector.ts +93 -0
  30. package/src/Isolate/IsolateKeys.ts +18 -0
  31. package/src/Isolate/IsolateMutator.ts +165 -0
  32. package/src/Isolate/IsolateRegistry.ts +176 -0
  33. package/src/Isolate/IsolateReorderable.ts +11 -0
  34. package/src/Isolate/IsolateSelectors.ts +25 -0
  35. package/src/Isolate/IsolateStateMachine.ts +30 -0
  36. package/src/Isolate/IsolateStatus.ts +8 -0
  37. package/src/Isolate/IsolateTransient.ts +27 -0
  38. package/src/Isolate/IsolateTypes.ts +33 -0
  39. package/src/Isolate/__tests__/Isolate.test.ts +123 -0
  40. package/src/Isolate/__tests__/IsolateFocused.test.ts +199 -0
  41. package/src/Isolate/__tests__/IsolateInspector.test.ts +136 -0
  42. package/src/Isolate/__tests__/IsolateMutator.test.ts +164 -0
  43. package/src/Isolate/__tests__/IsolatePropagation.test.ts +170 -0
  44. package/src/Isolate/__tests__/IsolateReorderable.test.ts +111 -0
  45. package/src/Isolate/__tests__/IsolateSelectors.test.ts +72 -0
  46. package/src/Isolate/__tests__/IsolateStatus.test.ts +44 -0
  47. package/src/Isolate/__tests__/IsolateTransient.test.ts +58 -0
  48. package/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap +71 -0
  49. package/src/Isolate/__tests__/asyncIsolate.test.ts +85 -0
  50. package/src/IsolateWalker.ts +359 -0
  51. package/src/Orchestrator/RuntimeStates.ts +4 -0
  52. package/src/Reconciler.ts +178 -0
  53. package/src/RuntimeEvents.ts +9 -0
  54. package/src/VestRuntime.ts +421 -0
  55. package/src/__tests__/Bus.test.ts +57 -0
  56. package/src/__tests__/IsolateWalker.iterative.test.ts +77 -0
  57. package/src/__tests__/IsolateWalker.test.ts +418 -0
  58. package/src/__tests__/Reconciler.test.ts +193 -0
  59. package/src/__tests__/Reconciler.transient.test.ts +166 -0
  60. package/src/__tests__/VestRuntime.test.ts +212 -0
  61. package/src/__tests__/VestRuntimeStateMachine.test.ts +36 -0
  62. package/src/__tests__/vestjs-runtime.test.ts +19 -0
  63. package/src/errors/ErrorStrings.ts +6 -0
  64. package/src/exports/IsolateSerializer.ts +131 -0
  65. package/src/exports/__tests__/IsolateSerializer.test.ts +334 -0
  66. package/src/exports/__tests__/IsolateSerializer.transient.test.ts +101 -0
  67. package/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap +5 -0
  68. package/src/exports/test-utils.ts +17 -0
  69. package/src/vestjs-runtime.ts +28 -0
  70. package/test-utils/package.json +12 -8
  71. package/types/Isolate-DChR7h5K.d.mts +58 -0
  72. package/types/Isolate-DChR7h5K.d.mts.map +1 -0
  73. package/types/Isolate-HYIh82M8.d.cts +58 -0
  74. package/types/Isolate-HYIh82M8.d.cts.map +1 -0
  75. package/types/IsolateSerializer-BCg01Px5.d.mts +13 -0
  76. package/types/IsolateSerializer-BCg01Px5.d.mts.map +1 -0
  77. package/types/IsolateSerializer-CQpP6A4m.d.cts +13 -0
  78. package/types/IsolateSerializer-CQpP6A4m.d.cts.map +1 -0
  79. package/types/exports/IsolateSerializer.d.cts +3 -0
  80. package/types/exports/IsolateSerializer.d.mts +3 -0
  81. package/types/exports/test-utils.d.cts +7 -0
  82. package/types/exports/test-utils.d.cts.map +1 -0
  83. package/types/exports/test-utils.d.mts +7 -0
  84. package/types/exports/test-utils.d.mts.map +1 -0
  85. package/types/vestjs-runtime.d.cts +372 -0
  86. package/types/vestjs-runtime.d.cts.map +1 -0
  87. package/types/vestjs-runtime.d.mts +370 -0
  88. package/types/vestjs-runtime.d.mts.map +1 -0
  89. package/types/vestjs-runtime.d.ts +351 -257
  90. package/vitest.config.ts +9 -17
  91. package/dist/cjs/IsolateSerializer.development.js +0 -135
  92. package/dist/cjs/IsolateSerializer.development.js.map +0 -1
  93. package/dist/cjs/IsolateSerializer.js +0 -6
  94. package/dist/cjs/IsolateSerializer.production.js +0 -2
  95. package/dist/cjs/IsolateSerializer.production.js.map +0 -1
  96. package/dist/cjs/package.json +0 -1
  97. package/dist/cjs/test-utils.development.js +0 -61
  98. package/dist/cjs/test-utils.development.js.map +0 -1
  99. package/dist/cjs/test-utils.js +0 -6
  100. package/dist/cjs/test-utils.production.js +0 -2
  101. package/dist/cjs/test-utils.production.js.map +0 -1
  102. package/dist/cjs/vestjs-runtime.development.js +0 -686
  103. package/dist/cjs/vestjs-runtime.development.js.map +0 -1
  104. package/dist/cjs/vestjs-runtime.js +0 -6
  105. package/dist/cjs/vestjs-runtime.production.js +0 -2
  106. package/dist/cjs/vestjs-runtime.production.js.map +0 -1
  107. package/dist/es/IsolateSerializer.development.js +0 -133
  108. package/dist/es/IsolateSerializer.development.js.map +0 -1
  109. package/dist/es/IsolateSerializer.production.js +0 -2
  110. package/dist/es/IsolateSerializer.production.js.map +0 -1
  111. package/dist/es/package.json +0 -1
  112. package/dist/es/test-utils.development.js +0 -59
  113. package/dist/es/test-utils.development.js.map +0 -1
  114. package/dist/es/test-utils.production.js +0 -2
  115. package/dist/es/test-utils.production.js.map +0 -1
  116. package/dist/es/vestjs-runtime.development.js +0 -675
  117. package/dist/es/vestjs-runtime.development.js.map +0 -1
  118. package/dist/es/vestjs-runtime.production.js +0 -2
  119. package/dist/es/vestjs-runtime.production.js.map +0 -1
  120. package/dist/umd/IsolateSerializer.development.js +0 -138
  121. package/dist/umd/IsolateSerializer.development.js.map +0 -1
  122. package/dist/umd/IsolateSerializer.production.js +0 -2
  123. package/dist/umd/IsolateSerializer.production.js.map +0 -1
  124. package/dist/umd/test-utils.development.js +0 -67
  125. package/dist/umd/test-utils.development.js.map +0 -1
  126. package/dist/umd/test-utils.production.js +0 -2
  127. package/dist/umd/test-utils.production.js.map +0 -1
  128. package/dist/umd/vestjs-runtime.development.js +0 -688
  129. package/dist/umd/vestjs-runtime.development.js.map +0 -1
  130. package/dist/umd/vestjs-runtime.production.js +0 -2
  131. package/dist/umd/vestjs-runtime.production.js.map +0 -1
  132. package/types/IsolateSerializer.d.ts +0 -42
  133. package/types/IsolateSerializer.d.ts.map +0 -1
  134. package/types/test-utils.d.ts +0 -37
  135. package/types/test-utils.d.ts.map +0 -1
  136. package/types/vestjs-runtime.d.ts.map +0 -1
@@ -1,278 +1,372 @@
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;
1
+ import { a as IsolateStatus, i as TIsolate, n as IsolateKey, o as IsolateKeys, r as IsolatePayload, t as Isolate } from "./Isolate-HYIh82M8.cjs";
2
+ import { t as IsolateSerializer } from "./IsolateSerializer-CQpP6A4m.cjs";
3
+ import { BusType, CB, DynamicValue, Maybe, Nullable, Nullish, OneOrMoreOf, Result, TinyState } from "vest-utils";
4
+
5
+ //#region rolldown:runtime
6
+ //#endregion
7
+ //#region src/RuntimeEvents.d.ts
8
+ type RuntimeEvents = {
9
+ ASYNC_ISOLATE_DONE: TIsolate;
10
+ ISOLATE_DONE: TIsolate;
11
+ ISOLATE_ENTER: TIsolate;
12
+ ISOLATE_PENDING: TIsolate;
13
+ ISOLATE_RECONCILED: TIsolate;
8
14
  };
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
- }
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>;
15
+ //#endregion
16
+ //#region src/Reconciler.d.ts
17
+ interface IReconciler<I = any> {
18
+ (currentNode: I, historyNode: I): Nullable<I>;
52
19
  }
53
20
  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;
21
+ /**
22
+ * Reconciles the current isolate with the history isolate.
23
+ * If the current isolate is of a different type than the history isolate,
24
+ * the current isolate is returned.
25
+ * Otherwise, the reconciler function is called to determine the next isolate.
26
+ * If the reconciler function returns null or undefined, the base reconciler is used.
27
+ * If no history isolate exists, the current isolate is returned.
28
+ * @param node The current isolate to reconcile.
29
+ * @returns The next isolate after reconciliation.
30
+ */
31
+ static reconcile(node: TIsolate): TIsolate;
32
+ static dropNextNodesOnReorder<I extends TIsolate>(reorderLogic: (newNode: I, prevNode: Maybe<TIsolate>) => boolean, newNode: I, prevNode: Maybe<TIsolate>): boolean;
33
+ static handleIsolateNodeWithKey<I extends TIsolate>(node: TIsolate, revoke: ((node: I) => boolean) | false): TIsolate;
69
34
  }
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;
35
+ declare namespace IsolateWalker_d_exports {
36
+ export { closest, closestExists, every, find, findAll, findClosest, has, mapFirst, pluck, reduce, some, walk };
140
37
  }
141
- type CTXType = StateRefType & {
142
- historyNode: Nullable<TIsolate>;
143
- runtimeNode: Nullable<TIsolate>;
144
- runtimeRoot: Nullable<TIsolate>;
145
- stateRef: StateRefType;
146
- };
38
+ type VisitOnlyPredicate = (isolate: TIsolate) => boolean;
39
+ /**
40
+ * Walks the isolate tree starting from the given node.
41
+ * @param startNode - The starting node for the traversal.
42
+ * @param callback - The callback function to be called for each visited node.
43
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
44
+ */
45
+ declare function walk(startNode: TIsolate, callback: (isolate: TIsolate) => Result<void>, visitOnly?: VisitOnlyPredicate): Result<void>;
46
+ /**
47
+ * Reduces the isolate tree to a single value.
48
+ * @param startNode - The starting node for the traversal.
49
+ * @param callback - The reducer function.
50
+ * @param initialValue - The initial value for the accumulator.
51
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
52
+ * @returns The final accumulated value.
53
+ */
54
+ declare function reduce<T>(startNode: TIsolate, callback: (acc: T, isolate: TIsolate) => Result<T>, initialValue: T, visitOnly?: VisitOnlyPredicate): T;
55
+ /**
56
+ * Checks if any node in the tree satisfies the predicate.
57
+ * @param startNode - The starting node for the traversal.
58
+ * @param predicate - The predicate function to test each node.
59
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
60
+ * @returns True if any node satisfies the predicate, false otherwise.
61
+ */
62
+ declare function some(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): boolean;
63
+ /**
64
+ * Checks if the tree contains a node that matches the predicate.
65
+ * @param startNode - The starting node for the traversal.
66
+ * @param match - The predicate function to match nodes.
67
+ * @returns True if a matching node is found, false otherwise.
68
+ */
69
+ declare function has(startNode: TIsolate, match: VisitOnlyPredicate): boolean;
70
+ /**
71
+ * Traverses up the tree to find the closest ancestor that satisfies the predicate,
72
+ * then returns the first direct descendant of that ancestor that satisfies the predicate.
73
+ * @param startNode - The starting node.
74
+ * @param predicate - The predicate to match.
75
+ * @returns The found node or null.
76
+ */
77
+ declare function findClosest<I extends TIsolate = TIsolate>(startNode: TIsolate, predicate: (node: TIsolate) => boolean): Nullable<I>;
78
+ /**
79
+ * Finds the first node in the tree that satisfies the predicate.
80
+ * @param startNode - The starting node.
81
+ * @param predicate - The predicate to match.
82
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
83
+ * @returns The found node or null.
84
+ */
85
+ declare function find(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): Nullable<TIsolate>;
86
+ /**
87
+ * Finds all nodes in the tree that satisfy the predicate.
88
+ * @param startNode - The starting node.
89
+ * @param predicate - The predicate to match.
90
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
91
+ * @returns An array of found nodes.
92
+ */
93
+ declare function findAll(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): TIsolate[];
94
+ /**
95
+ * Checks if every node in the tree satisfies the predicate.
96
+ * @param startNode - The starting node.
97
+ * @param predicate - The predicate to match.
98
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
99
+ * @returns True if all nodes satisfy the predicate, false otherwise.
100
+ */
101
+ declare function every(startNode: TIsolate, predicate: (node: TIsolate) => boolean, visitOnly?: VisitOnlyPredicate): boolean;
102
+ /**
103
+ * Removes nodes from the tree that satisfy the predicate.
104
+ * @param startNode - The starting node.
105
+ * @param predicate - The predicate to match nodes to remove.
106
+ * @param visitOnly - Optional predicate to filter which nodes to visit.
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",
133
+ }
134
+ //#endregion
135
+ //#region src/VestRuntime.d.ts
136
+ /**
137
+ * The state reference type for the Vest runtime.
138
+ * Holds all mutable state for the runtime instance.
139
+ */
147
140
  type StateRefType = {
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;
141
+ Bus: BusType<RuntimeEvents>;
142
+ appData: Record<string, any>;
143
+ historyRoot: TinyState<Nullable<TIsolate>>;
144
+ Reconciler: IReconciler;
145
+ implicitOnlyNodes: Set<TIsolate>;
164
146
  };
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
+ */
165
158
  declare function useXAppData<T = object>(): T;
166
- declare function createRef(Reconciler: IRecociler, setter: DynamicValue<Record<string, any>>): StateRefType;
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
+ */
167
189
  declare function persist<T extends (...args: any[]) => any>(cb: T): T;
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
- ];
190
+ /**
191
+ * Retrieves the history root state.
192
+ */
193
+ declare function useHistoryRoot(): any;
194
+ /**
195
+ * Sets the history root for the runtime.
196
+ * This is used to hydrate the runtime with previous results.
197
+ */
195
198
  declare function useSetHistoryRoot(history: TIsolate): void;
199
+ /**
200
+ * Retrieves the current cursor position within the active isolate.
201
+ */
196
202
  declare function useCurrentCursor(): number;
203
+ /**
204
+ * Adds a child isolate to the current isolate and sets the parent-child relationship.
205
+ */
197
206
  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
+ */
198
212
  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
+ */
199
221
  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
200
243
  declare class IsolateInspector {
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>;
244
+ static at(isolate: Nullable<TIsolate>, at: number): Nullable<TIsolate>;
245
+ static cursor(isolate: Nullable<TIsolate>): number;
246
+ static canReorder<I extends TIsolate>(isolate: Nullable<I>): boolean;
247
+ static allowsReorder<I extends Record<any, any>>(isolate: Nullable<I>): boolean;
248
+ static usesKey(isolate: Nullable<TIsolate>): boolean;
249
+ static getChildByKey(isolate: Nullable<TIsolate>, key: string): Nullable<TIsolate>;
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>;
207
257
  }
258
+ //#endregion
259
+ //#region src/Isolate/IsolateMutator.d.ts
208
260
  declare class IsolateMutator {
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;
261
+ static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate;
262
+ static saveOutput(isolate: TIsolate, output: any): TIsolate;
263
+ static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate;
264
+ static addChild(isolate: TIsolate, child: TIsolate): void;
265
+ static removeChild(isolate: TIsolate, node: TIsolate): void;
266
+ static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void;
267
+ static slice(isolate: TIsolate, at: number): void;
268
+ static setData(isolate: TIsolate, data: any): void;
269
+ static abort(isolate: TIsolate, reason?: string): void;
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 };
218
277
  }
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;
278
+ declare function useBus<E extends Record<string, any> = RuntimeEvents>(): BusType<E>;
279
+ declare function useEmit<E extends Record<string, any> = RuntimeEvents, T extends keyof E = keyof E>(event: T, ...args: E[T] extends void ? [payload?: E[T]] : [payload: E[T]]): void;
280
+ declare function useEmit<_E extends Record<string, any> = RuntimeEvents>(): (event: string, data?: any) => void;
281
+ declare function usePrepareEmitter<E extends Record<string, any> = RuntimeEvents, T extends keyof E = keyof E>(event: T): (arg: E[T]) => void;
282
+ declare namespace IsolateSelectors_d_exports {
283
+ export { isIsolateType, isSameIsolateIdentity, isSameIsolateType };
227
284
  }
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;
285
+ declare function isIsolateType<I extends TIsolate>(node: Maybe<TIsolate>, type: string): node is I;
286
+ declare function isSameIsolateType<A extends TIsolate, B extends TIsolate>(a: A, b: B): boolean;
287
+ declare function isSameIsolateIdentity<A extends TIsolate, B extends TIsolate>(a: A, b: B): boolean;
288
+ //#endregion
289
+ //#region src/Isolate/IsolateStateMachine.d.ts
290
+ declare const IsolateStateMachine: any;
291
+ declare namespace IsolateRegistry_d_exports {
292
+ export { RegistryCategoryConfig, RegistryIndex, useClearRegistry, useGetFromRegistry, useHasFromRegistry, useRemoveFieldFromRegistry, useUpdateRegistry };
270
293
  }
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;
294
+ /**
295
+ * A registry index, mapping group keys (like field names) to sets of isolates.
296
+ */
297
+ type RegistryIndex = Map<string, Set<TIsolate>>;
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;
276
369
  }
277
- export { RuntimeEvents, IsolateKey, TIsolate, Isolate, Reconciler, IRecociler, Walker, RuntimeApi as VestRuntime, IsolateInspector, IsolateMutator, Bus, IsolateSelectors, IsolateSerializer };
278
- //# sourceMappingURL=vestjs-runtime.d.ts.map
370
+ //#endregion
371
+ export { Bus_d_exports as Bus, FocusModes, FocusSelectors, type IReconciler, Isolate, IsolateFocused, IsolateInspector, type IsolateKey, IsolateKeys, IsolateMutator, IsolateRegistry_d_exports as IsolateRegistry, IsolateReorderable, IsolateSelectors_d_exports as IsolateSelectors, IsolateSerializer, IsolateStateMachine, IsolateStatus, IsolateTransient, Reconciler, type RegistryCategoryConfig, type RegistryIndex, type RuntimeEvents, type TIsolate, type TIsolateFocused, RuntimeApi as VestRuntime, IsolateWalker_d_exports as Walker };
372
+ //# sourceMappingURL=vestjs-runtime.d.cts.map