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.
Files changed (136) hide show
  1. package/IsolateSerializer/package.json +8 -12
  2. package/README.md +1 -3
  3. package/dist/cjs/IsolateSerializer.development.js +135 -0
  4. package/dist/cjs/IsolateSerializer.development.js.map +1 -0
  5. package/dist/cjs/IsolateSerializer.js +6 -0
  6. package/dist/cjs/IsolateSerializer.production.js +2 -0
  7. package/dist/cjs/IsolateSerializer.production.js.map +1 -0
  8. package/dist/cjs/package.json +1 -0
  9. package/dist/cjs/test-utils.development.js +61 -0
  10. package/dist/cjs/test-utils.development.js.map +1 -0
  11. package/dist/cjs/test-utils.js +6 -0
  12. package/dist/cjs/test-utils.production.js +2 -0
  13. package/dist/cjs/test-utils.production.js.map +1 -0
  14. package/dist/cjs/vestjs-runtime.development.js +686 -0
  15. package/dist/cjs/vestjs-runtime.development.js.map +1 -0
  16. package/dist/cjs/vestjs-runtime.js +6 -0
  17. package/dist/cjs/vestjs-runtime.production.js +2 -0
  18. package/dist/cjs/vestjs-runtime.production.js.map +1 -0
  19. package/dist/es/IsolateSerializer.development.js +133 -0
  20. package/dist/es/IsolateSerializer.development.js.map +1 -0
  21. package/dist/es/IsolateSerializer.production.js +2 -0
  22. package/dist/es/IsolateSerializer.production.js.map +1 -0
  23. package/dist/es/package.json +1 -0
  24. package/dist/es/test-utils.development.js +59 -0
  25. package/dist/es/test-utils.development.js.map +1 -0
  26. package/dist/es/test-utils.production.js +2 -0
  27. package/dist/es/test-utils.production.js.map +1 -0
  28. package/dist/es/vestjs-runtime.development.js +675 -0
  29. package/dist/es/vestjs-runtime.development.js.map +1 -0
  30. package/dist/es/vestjs-runtime.production.js +2 -0
  31. package/dist/es/vestjs-runtime.production.js.map +1 -0
  32. package/dist/umd/IsolateSerializer.development.js +138 -0
  33. package/dist/umd/IsolateSerializer.development.js.map +1 -0
  34. package/dist/umd/IsolateSerializer.production.js +2 -0
  35. package/dist/umd/IsolateSerializer.production.js.map +1 -0
  36. package/dist/umd/test-utils.development.js +67 -0
  37. package/dist/umd/test-utils.development.js.map +1 -0
  38. package/dist/umd/test-utils.production.js +2 -0
  39. package/dist/umd/test-utils.production.js.map +1 -0
  40. package/dist/umd/vestjs-runtime.development.js +688 -0
  41. package/dist/umd/vestjs-runtime.development.js.map +1 -0
  42. package/dist/umd/vestjs-runtime.production.js +2 -0
  43. package/dist/umd/vestjs-runtime.production.js.map +1 -0
  44. package/package.json +87 -42
  45. package/test-utils/package.json +8 -12
  46. package/types/IsolateSerializer.d.ts +42 -0
  47. package/types/IsolateSerializer.d.ts.map +1 -0
  48. package/types/test-utils.d.ts +37 -0
  49. package/types/test-utils.d.ts.map +1 -0
  50. package/types/vestjs-runtime.d.ts +257 -351
  51. package/types/vestjs-runtime.d.ts.map +1 -0
  52. package/vitest.config.ts +17 -9
  53. package/dist/IsolateKeys-B21aPuBk.mjs +0 -23
  54. package/dist/IsolateKeys-B21aPuBk.mjs.map +0 -1
  55. package/dist/IsolateKeys-CCvALpZC.cjs +0 -35
  56. package/dist/IsolateKeys-CCvALpZC.cjs.map +0 -1
  57. package/dist/IsolateSerializer-B1hE3gmT.mjs +0 -1004
  58. package/dist/IsolateSerializer-B1hE3gmT.mjs.map +0 -1
  59. package/dist/IsolateSerializer-pbEf5gB2.cjs +0 -1121
  60. package/dist/IsolateSerializer-pbEf5gB2.cjs.map +0 -1
  61. package/dist/chunk-CLMFDpHK.mjs +0 -18
  62. package/dist/exports/IsolateSerializer.cjs +0 -4
  63. package/dist/exports/IsolateSerializer.mjs +0 -4
  64. package/dist/exports/test-utils.cjs +0 -21
  65. package/dist/exports/test-utils.cjs.map +0 -1
  66. package/dist/exports/test-utils.mjs +0 -21
  67. package/dist/exports/test-utils.mjs.map +0 -1
  68. package/dist/vestjs-runtime.cjs +0 -153
  69. package/dist/vestjs-runtime.cjs.map +0 -1
  70. package/dist/vestjs-runtime.mjs +0 -117
  71. package/dist/vestjs-runtime.mjs.map +0 -1
  72. package/docs/IsolateRegistry.docs.md +0 -146
  73. package/docs/Isolates.md +0 -97
  74. package/src/Bus.ts +0 -46
  75. package/src/Isolate/Isolate.ts +0 -163
  76. package/src/Isolate/IsolateFocused.ts +0 -93
  77. package/src/Isolate/IsolateIndexer.ts +0 -42
  78. package/src/Isolate/IsolateInspector.ts +0 -93
  79. package/src/Isolate/IsolateKeys.ts +0 -18
  80. package/src/Isolate/IsolateMutator.ts +0 -165
  81. package/src/Isolate/IsolateRegistry.ts +0 -176
  82. package/src/Isolate/IsolateReorderable.ts +0 -11
  83. package/src/Isolate/IsolateSelectors.ts +0 -25
  84. package/src/Isolate/IsolateStateMachine.ts +0 -30
  85. package/src/Isolate/IsolateStatus.ts +0 -8
  86. package/src/Isolate/IsolateTransient.ts +0 -27
  87. package/src/Isolate/IsolateTypes.ts +0 -33
  88. package/src/Isolate/__tests__/Isolate.test.ts +0 -123
  89. package/src/Isolate/__tests__/IsolateFocused.test.ts +0 -199
  90. package/src/Isolate/__tests__/IsolateInspector.test.ts +0 -136
  91. package/src/Isolate/__tests__/IsolateMutator.test.ts +0 -164
  92. package/src/Isolate/__tests__/IsolatePropagation.test.ts +0 -170
  93. package/src/Isolate/__tests__/IsolateReorderable.test.ts +0 -111
  94. package/src/Isolate/__tests__/IsolateSelectors.test.ts +0 -72
  95. package/src/Isolate/__tests__/IsolateStatus.test.ts +0 -44
  96. package/src/Isolate/__tests__/IsolateTransient.test.ts +0 -58
  97. package/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap +0 -71
  98. package/src/Isolate/__tests__/asyncIsolate.test.ts +0 -85
  99. package/src/IsolateWalker.ts +0 -359
  100. package/src/Orchestrator/RuntimeStates.ts +0 -4
  101. package/src/Reconciler.ts +0 -178
  102. package/src/RuntimeEvents.ts +0 -9
  103. package/src/VestRuntime.ts +0 -421
  104. package/src/__tests__/Bus.test.ts +0 -57
  105. package/src/__tests__/IsolateWalker.iterative.test.ts +0 -77
  106. package/src/__tests__/IsolateWalker.test.ts +0 -418
  107. package/src/__tests__/Reconciler.test.ts +0 -193
  108. package/src/__tests__/Reconciler.transient.test.ts +0 -166
  109. package/src/__tests__/VestRuntime.test.ts +0 -212
  110. package/src/__tests__/VestRuntimeStateMachine.test.ts +0 -36
  111. package/src/__tests__/vestjs-runtime.test.ts +0 -19
  112. package/src/errors/ErrorStrings.ts +0 -6
  113. package/src/exports/IsolateSerializer.ts +0 -131
  114. package/src/exports/__tests__/IsolateSerializer.test.ts +0 -334
  115. package/src/exports/__tests__/IsolateSerializer.transient.test.ts +0 -101
  116. package/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap +0 -5
  117. package/src/exports/test-utils.ts +0 -17
  118. package/src/vestjs-runtime.ts +0 -28
  119. package/types/Isolate-DChR7h5K.d.mts +0 -58
  120. package/types/Isolate-DChR7h5K.d.mts.map +0 -1
  121. package/types/Isolate-HYIh82M8.d.cts +0 -58
  122. package/types/Isolate-HYIh82M8.d.cts.map +0 -1
  123. package/types/IsolateSerializer-BCg01Px5.d.mts +0 -13
  124. package/types/IsolateSerializer-BCg01Px5.d.mts.map +0 -1
  125. package/types/IsolateSerializer-CQpP6A4m.d.cts +0 -13
  126. package/types/IsolateSerializer-CQpP6A4m.d.cts.map +0 -1
  127. package/types/exports/IsolateSerializer.d.cts +0 -3
  128. package/types/exports/IsolateSerializer.d.mts +0 -3
  129. package/types/exports/test-utils.d.cts +0 -7
  130. package/types/exports/test-utils.d.cts.map +0 -1
  131. package/types/exports/test-utils.d.mts +0 -7
  132. package/types/exports/test-utils.d.mts.map +0 -1
  133. package/types/vestjs-runtime.d.cts +0 -372
  134. package/types/vestjs-runtime.d.cts.map +0 -1
  135. package/types/vestjs-runtime.d.mts +0 -370
  136. package/types/vestjs-runtime.d.mts.map +0 -1
@@ -1,111 +0,0 @@
1
- import { CB } from 'vest-utils';
2
- import { describe, it, expect, beforeEach, vi } from 'vitest';
3
-
4
- import { IsolateReorderable } from '../IsolateReorderable';
5
- import { IsolateInspector } from '../IsolateInspector';
6
- import { IsolateKeys } from '../IsolateKeys';
7
- import { VestRuntime, IReconciler, Isolate } from '../../vestjs-runtime';
8
-
9
- describe('IsolateReorderable', () => {
10
- let stateRef: any;
11
- // Mock reconciler to test reordering enforcement
12
- const testReconciler = vi.fn((currentNode: any, historyNode: any) => {
13
- // Simple check: if keys don't match, verify if reorder is allowed
14
- if (currentNode.key !== historyNode.key) {
15
- if (!IsolateInspector.canReorder(currentNode)) {
16
- throw new Error('Reorder violation');
17
- }
18
- }
19
- return currentNode;
20
- });
21
-
22
- beforeEach(() => {
23
- testReconciler.mockClear();
24
- stateRef = VestRuntime.createRef(
25
- testReconciler as unknown as IReconciler,
26
- v => v,
27
- );
28
- });
29
-
30
- function withRunTime<T>(fn: CB<T>) {
31
- return VestRuntime.Run(stateRef, () => {
32
- return fn();
33
- });
34
- }
35
-
36
- it('Should return an isolate with allowReorder set to true', () => {
37
- const isolate = withRunTime(() => IsolateReorderable(() => {}));
38
- expect(isolate[IsolateKeys.AllowReorder]).toBe(true);
39
- });
40
-
41
- it('Should set the type to "Reorderable" by default', () => {
42
- const isolate = withRunTime(() => IsolateReorderable(() => {}));
43
- expect(isolate[IsolateKeys.Type]).toBe('Reorderable');
44
- });
45
-
46
- it('Should allow overriding the type', () => {
47
- const isolate = withRunTime(() =>
48
- IsolateReorderable(() => {}, 'CustomType'),
49
- );
50
- expect(isolate[IsolateKeys.Type]).toBe('CustomType');
51
- });
52
-
53
- it('Should set the payload', () => {
54
- const payload = { foo: 'bar' };
55
- const isolate = withRunTime(() =>
56
- IsolateReorderable(() => {}, 'Type', payload),
57
- );
58
- expect(isolate[IsolateKeys.Data]).toMatchObject(payload);
59
- });
60
-
61
- it('Should run the callback', () => {
62
- const spy = vi.fn();
63
- withRunTime(() => IsolateReorderable(spy));
64
- expect(spy).toHaveBeenCalled();
65
- });
66
-
67
- describe('Reordering', () => {
68
- describe('When the isolate is reorderable', () => {
69
- it('Should allow reordering', () => {
70
- withRunTime(() => {
71
- IsolateReorderable(() => {
72
- Isolate.create('Child', () => {}, {}, 'A');
73
- Isolate.create('Child', () => {}, {}, 'B');
74
- });
75
- });
76
-
77
- expect(() => {
78
- withRunTime(() => {
79
- IsolateReorderable(() => {
80
- // Swapped order
81
- Isolate.create('Child', () => {}, {}, 'B');
82
- Isolate.create('Child', () => {}, {}, 'A');
83
- });
84
- });
85
- }).not.toThrow();
86
- });
87
- });
88
-
89
- describe('Sanity (Failure case)', () => {
90
- it('Should NOT allow reordering when parent is not Reorderable', () => {
91
- withRunTime(() => {
92
- // Standard Isolate does not allow reordering
93
- Isolate.create('Parent', () => {
94
- Isolate.create('Child', () => {}, {}, 'A');
95
- Isolate.create('Child', () => {}, {}, 'B');
96
- });
97
- });
98
-
99
- expect(() => {
100
- withRunTime(() => {
101
- Isolate.create('Parent', () => {
102
- // Swapped order
103
- Isolate.create('Child', () => {}, {}, 'B');
104
- Isolate.create('Child', () => {}, {}, 'A');
105
- });
106
- });
107
- }).toThrow('Reorder violation');
108
- });
109
- });
110
- });
111
- });
@@ -1,72 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import {
3
- isIsolateType,
4
- isSameIsolateType,
5
- isSameIsolateIdentity,
6
- } from '../IsolateSelectors';
7
- import { IsolateKeys } from '../IsolateKeys';
8
-
9
- describe('IsolateSelectors', () => {
10
- const type = 'TEST_TYPE';
11
- const otherType = 'OTHER_TYPE';
12
-
13
- const isolate1 = { [IsolateKeys.Type]: type, key: 'key1' };
14
- const isolate2 = { [IsolateKeys.Type]: type, key: 'key1' };
15
- const isolate3 = { [IsolateKeys.Type]: type, key: 'key2' };
16
- const isolate4 = { [IsolateKeys.Type]: otherType, key: 'key1' };
17
- const nullIsolate = null;
18
- const undefinedIsolate = undefined;
19
-
20
- describe('isIsolateType', () => {
21
- it('should return true if type matches', () => {
22
- // @ts-ignore
23
- expect(isIsolateType(isolate1, type)).toBe(true);
24
- });
25
-
26
- it('should return false if type matches', () => {
27
- // @ts-ignore
28
- expect(isIsolateType(isolate1, otherType)).toBe(false);
29
- });
30
-
31
- it('should return false if node is null/undefined', () => {
32
- // @ts-ignore
33
- expect(isIsolateType(nullIsolate, type)).toBe(false);
34
- // @ts-ignore
35
- expect(isIsolateType(undefinedIsolate, type)).toBe(false);
36
- });
37
- });
38
-
39
- describe('isSameIsolateType', () => {
40
- it('should return true if type matches', () => {
41
- // @ts-ignore
42
- expect(isSameIsolateType(isolate1, isolate2)).toBe(true);
43
- });
44
-
45
- it('should return false if type matches', () => {
46
- // @ts-ignore
47
- expect(isSameIsolateType(isolate1, isolate4)).toBe(false);
48
- });
49
- });
50
-
51
- describe('isSameIsolateIdentity', () => {
52
- it('should return true if strictly equal', () => {
53
- // @ts-ignore
54
- expect(isSameIsolateIdentity(isolate1, isolate1)).toBe(true);
55
- });
56
-
57
- it('should return true if type and key match', () => {
58
- // @ts-ignore
59
- expect(isSameIsolateIdentity(isolate1, isolate2)).toBe(true);
60
- });
61
-
62
- it('should return false if keys differ', () => {
63
- // @ts-ignore
64
- expect(isSameIsolateIdentity(isolate1, isolate3)).toBe(false);
65
- });
66
-
67
- it('should return false if types differ', () => {
68
- // @ts-ignore
69
- expect(isSameIsolateIdentity(isolate1, isolate4)).toBe(false);
70
- });
71
- });
72
- });
@@ -1,44 +0,0 @@
1
- import { Isolate, IsolateStatus, TIsolate, VestRuntime } from 'vestjs-runtime';
2
- import { describe, it, expect } from 'vitest';
3
-
4
- describe('Isolate Status Transitions', () => {
5
- it('Should initialize with INITIAL status', () => {
6
- VestRuntime.Run(VestRuntime.createRef({} as any, {} as any), () => {
7
- Isolate.create('Test', isolate => {
8
- expect(isolate.status).toBe(IsolateStatus.INITIAL);
9
- });
10
- });
11
- });
12
-
13
- it('Should transition to DONE for sync callbacks', () => {
14
- VestRuntime.Run(VestRuntime.createRef({} as any, {} as any), () => {
15
- const isolate = Isolate.create('Test', () => {});
16
- expect(isolate.status).toBe(IsolateStatus.DONE);
17
- });
18
- });
19
-
20
- it('Should transition to PENDING then DONE for async callbacks', async () => {
21
- let resolve: (_value?: unknown) => void = () => {};
22
- const promise = new Promise(r => (resolve = r));
23
- const isolate = await new Promise<TIsolate>(done => {
24
- VestRuntime.Run(VestRuntime.createRef({} as any, {} as any), () => {
25
- const createdIsolate = Isolate.create('AsyncTest', async () => {
26
- await promise;
27
- });
28
- done(createdIsolate);
29
- });
30
- });
31
-
32
- // Since Isolate.create runs the callback, for async it returns the isolate
33
- // which should be PENDING state before the promise resolves
34
- expect(isolate.status).toBe(IsolateStatus.PENDING);
35
-
36
- resolve();
37
- await promise;
38
-
39
- // Wait for microtasks
40
- await new Promise(process.nextTick);
41
-
42
- expect(isolate.status).toBe(IsolateStatus.DONE);
43
- });
44
- });
@@ -1,58 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { CB } from 'vest-utils';
3
-
4
- import { IReconciler } from '../../Reconciler';
5
- import { IsolateTransient } from '../IsolateTransient';
6
- import * as VestRuntime from '../../VestRuntime';
7
- import { IsolateKeys } from '../IsolateKeys';
8
- import { Isolate } from '../Isolate';
9
-
10
- describe('IsolateTransient', () => {
11
- function withRunTime<T>(fn: CB<T>) {
12
- return VestRuntime.Run(
13
- VestRuntime.createRef((() => null) as unknown as IReconciler, v => v),
14
- () => fn(),
15
- );
16
- }
17
-
18
- it('should create an isolate with transient flag set to true', () => {
19
- let node: any;
20
- withRunTime(() => {
21
- Isolate.create('Root', () => {
22
- node = IsolateTransient(() => {});
23
- });
24
- });
25
- expect(node[IsolateKeys.Transient]).toBe(true);
26
- });
27
-
28
- it('should use default type "Transient" when no type is provided', () => {
29
- let node: any;
30
- withRunTime(() => {
31
- Isolate.create('Root', () => {
32
- node = IsolateTransient(() => {});
33
- });
34
- });
35
- expect(node[IsolateKeys.Type]).toBe('Transient');
36
- });
37
-
38
- it('should accept a custom type', () => {
39
- let node: any;
40
- withRunTime(() => {
41
- Isolate.create('Root', () => {
42
- node = IsolateTransient(() => {}, 'Debounce');
43
- });
44
- });
45
- expect(node[IsolateKeys.Type]).toBe('Debounce');
46
- });
47
-
48
- it('should merge custom payload with transient flag', () => {
49
- let node: any;
50
- withRunTime(() => {
51
- Isolate.create('Root', () => {
52
- node = IsolateTransient(() => {}, 'Custom', { myData: 42 });
53
- });
54
- });
55
- expect(node[IsolateKeys.Transient]).toBe(true);
56
- expect(node[IsolateKeys.Data]).toEqual({ myData: 42 });
57
- });
58
- });
@@ -1,71 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`AsyncIsolate > It should resolve async isolate into the parent 2`] = `
4
- IsolateInstance {
5
- "$type": "URoot",
6
- "abortController": null,
7
- "allowReorder": undefined,
8
- "children": [
9
- IsolateInstance {
10
- "$type": "UChild_1",
11
- "abortController": null,
12
- "allowReorder": undefined,
13
- "children": [
14
- IsolateInstance {
15
- "$type": "UGrandChild_1",
16
- "abortController": null,
17
- "allowReorder": undefined,
18
- "children": null,
19
- "data": {},
20
- "key": null,
21
- "keys": null,
22
- "output": undefined,
23
- "parent": [Circular],
24
- "status": "DONE",
25
- "transient": undefined,
26
- },
27
- IsolateInstance {
28
- "$type": "UGrandChild_2",
29
- "abortController": null,
30
- "allowReorder": undefined,
31
- "children": null,
32
- "data": {},
33
- "key": null,
34
- "keys": null,
35
- "output": undefined,
36
- "parent": [Circular],
37
- "status": "DONE",
38
- "transient": undefined,
39
- },
40
- IsolateInstance {
41
- "$type": "UGrandChild_3",
42
- "abortController": null,
43
- "allowReorder": undefined,
44
- "children": null,
45
- "data": {},
46
- "key": null,
47
- "keys": null,
48
- "output": undefined,
49
- "parent": [Circular],
50
- "status": "DONE",
51
- "transient": undefined,
52
- },
53
- ],
54
- "data": {},
55
- "key": null,
56
- "keys": null,
57
- "output": undefined,
58
- "parent": [Circular],
59
- "status": "DONE",
60
- "transient": undefined,
61
- },
62
- ],
63
- "data": {},
64
- "key": null,
65
- "keys": null,
66
- "output": Promise {},
67
- "parent": null,
68
- "status": "DONE",
69
- "transient": undefined,
70
- }
71
- `;
@@ -1,85 +0,0 @@
1
- import { useBus } from '../../Bus';
2
- import { Isolate, TIsolate } from '../Isolate';
3
- import { CB } from 'vest-utils';
4
- import { describe, vi, it, expect, test } from 'vitest';
5
- import wait from 'wait';
6
-
7
- import { VestRuntime, IReconciler } from '../../vestjs-runtime';
8
-
9
- describe('AsyncIsolate', () => {
10
- test('It should resolve async isolate into the parent', async () => {
11
- let root = {} as TIsolate;
12
- withRunTime(() => {
13
- // Create root isolate from which all others will be created
14
- root = Isolate.create('URoot', genChildren);
15
- });
16
- expect(root).toMatchInlineSnapshot(`
17
- IsolateInstance {
18
- "$type": "URoot",
19
- "abortController": null,
20
- "allowReorder": undefined,
21
- "children": null,
22
- "data": {},
23
- "key": null,
24
- "keys": null,
25
- "output": Promise {},
26
- "parent": null,
27
- "status": "PENDING",
28
- "transient": undefined,
29
- }
30
- `);
31
- await wait(10);
32
- expect(root?.children?.[0]?.$type).toBe('UChild_1');
33
- expect(root?.children?.[0].parent).toBe(root);
34
- expect(root?.children?.[0]?.children?.[0]?.$type).toBe('UGrandChild_1');
35
- expect(root?.children?.[0]?.children?.[0].parent).toBe(root?.children?.[0]);
36
- expect(root?.children?.[0]?.children?.[1]?.$type).toBe('UGrandChild_2');
37
- expect(root?.children?.[0]?.children?.[1].parent).toBe(root?.children?.[0]);
38
- expect(root?.children?.[0]?.children?.[2]?.$type).toBe('UGrandChild_3');
39
- expect(root?.children?.[0]?.children?.[2].parent).toBe(root?.children?.[0]);
40
- expect(root).toMatchSnapshot();
41
- });
42
-
43
- it('Should emit an event when an async isolate is done running', async () => {
44
- const cb = vi.fn();
45
- let child = {} as TIsolate;
46
- withRunTime(() => {
47
- // Create root isolate from which all others will be created
48
- Isolate.create('URoot', () => {
49
- const bus = useBus();
50
- bus.on('ISOLATE_DONE', cb);
51
-
52
- expect(cb).not.toHaveBeenCalled();
53
- child = Isolate.create('UChild_1', async () => {
54
- await wait(10);
55
- });
56
- expect(cb).not.toHaveBeenCalled();
57
- });
58
- });
59
- expect(cb).not.toHaveBeenCalledWith(child);
60
- await wait(10);
61
- expect(cb).toHaveBeenCalledWith(child);
62
- });
63
- });
64
-
65
- function withRunTime<T>(fn: CB<T>) {
66
- return VestRuntime.Run(
67
- VestRuntime.createRef({} as IReconciler, v => v),
68
- () => {
69
- return fn();
70
- },
71
- );
72
- }
73
-
74
- async function genChildren() {
75
- await wait(10);
76
- // Create first child isolate
77
- return withRunTime(() =>
78
- Isolate.create('UChild_1', () => {
79
- // Create three grandchildren
80
- Isolate.create('UGrandChild_1', () => {});
81
- Isolate.create('UGrandChild_2', () => {});
82
- Isolate.create('UGrandChild_3', () => {});
83
- }),
84
- );
85
- }