nucleus-core-ts 0.10.264 → 0.10.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-ok +1 -1
- package/dist/fe/components/AuthGuard/types.d.ts +1 -1
- package/dist/fe/components/Replay/_types/frame.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/controller.js +1 -0
- package/dist/fe/components/Replay/_utils/controllerSeek.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/controllerSeek.js +3 -0
- package/dist/fe/components/Replay/_utils/frameBridge.js +5 -2
- package/dist/fe/components/Replay/_utils/framePrelude.d.ts +4 -7
- package/dist/fe/components/Replay/_utils/framePrelude.js +11 -1
- package/dist/fe/components/Replay/_utils/preludeBeat.d.ts +9 -0
- package/dist/fe/components/Replay/_utils/preludeBeat.js +9 -0
- package/package.json +1 -1
package/dist/.build-ok
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.10.
|
|
1
|
+
0.10.266
|
|
@@ -25,6 +25,8 @@ export interface ReplayFrameOptions {
|
|
|
25
25
|
startChapter?: string | null;
|
|
26
26
|
typingDelayMs?: number;
|
|
27
27
|
tickMs?: number;
|
|
28
|
+
/** How often a frame that is rebuilding its starting state tells the parent it is alive (default 2 s). */
|
|
29
|
+
heartbeatMs?: number;
|
|
28
30
|
pointTimeoutMs?: number;
|
|
29
31
|
targetTimeoutMs?: number;
|
|
30
32
|
visible?: VisibleCheck;
|
|
@@ -93,6 +93,7 @@ const realClock = {
|
|
|
93
93
|
if (recordingId !== store.manifest?.id) return;
|
|
94
94
|
if (preparing) {
|
|
95
95
|
if (!ready) handshake.rearm(); // alive but not ready: the wait starts over, play and seek stay queued
|
|
96
|
+
else seek.frameAlive(); // a reloaded frame still rebuilding its prelude: the reload guard starts over
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
99
|
const first = !ready;
|
|
@@ -17,6 +17,8 @@ export interface SeekGate {
|
|
|
17
17
|
acknowledged: (reloading: boolean) => void;
|
|
18
18
|
/** A frame reported ready: whatever seek was in flight is done. */
|
|
19
19
|
frameReady: () => void;
|
|
20
|
+
/** A reloaded frame reported it is still rebuilding: the wait for its `ready` starts over (progress, not silence). */
|
|
21
|
+
frameAlive: () => void;
|
|
20
22
|
/** True between the seek and its acknowledgement: ticks in that window predate the seek. */
|
|
21
23
|
isStale: () => boolean;
|
|
22
24
|
}
|
|
@@ -194,7 +194,7 @@ const MAX_KEY_LENGTH = 200;
|
|
|
194
194
|
const earlier = start ? steps.filter((step)=>step.at < start.from) : [];
|
|
195
195
|
if (start && earlier.some((step)=>step.actions.length > 0)) {
|
|
196
196
|
preluding = true;
|
|
197
|
-
const { navigate, visible, targetTimeoutMs } = options;
|
|
197
|
+
const { navigate, visible, targetTimeoutMs, heartbeatMs } = options;
|
|
198
198
|
const attribute = manifest.targetAttribute;
|
|
199
199
|
void runPrelude({
|
|
200
200
|
...{
|
|
@@ -208,10 +208,13 @@ const MAX_KEY_LENGTH = 200;
|
|
|
208
208
|
navigate,
|
|
209
209
|
visible,
|
|
210
210
|
targetTimeoutMs,
|
|
211
|
+
heartbeatMs,
|
|
211
212
|
settle,
|
|
212
213
|
cancelled: ()=>stopped
|
|
213
214
|
},
|
|
214
|
-
onSkip: options.skipFailedSteps === false ? undefined : reportSkip
|
|
215
|
+
onSkip: options.skipFailedSteps === false ? undefined : reportSkip,
|
|
216
|
+
// A reloaded frame gets no hello (the parent stopped at its first ready): a `preparing` heartbeat keeps its guard alive.
|
|
217
|
+
onHeartbeat: announce
|
|
215
218
|
}).then(()=>{
|
|
216
219
|
preluding = false;
|
|
217
220
|
if (!stopped) begin();
|
|
@@ -13,14 +13,11 @@ export interface FramePreludeOptions {
|
|
|
13
13
|
settle: () => Promise<void>;
|
|
14
14
|
/** Told of a step the prelude dropped (its target never appeared); `actionIndex` is the action that failed. */
|
|
15
15
|
onSkip?: (stepId: string, actionIndex: number, reason: FailureReason) => void;
|
|
16
|
+
/** Called every `heartbeatMs` while the prelude runs (never once cancelled): the frame is rebuilding, not hung. */
|
|
17
|
+
onHeartbeat?: () => void;
|
|
18
|
+
heartbeatMs?: number;
|
|
16
19
|
/** True once the frame was stopped: the prelude ends at the next action. */
|
|
17
20
|
cancelled: () => boolean;
|
|
18
21
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Rebuilds the product's state at a chapter start. A frame that starts at chapter N (a seek reloads it there) has
|
|
21
|
-
* none of what the earlier chapters' steps did: the conversation was never opened, the workspace never chosen. So
|
|
22
|
-
* every earlier step's state-changing actions run again at once, with no cursor, no typing delay and no waiting: the
|
|
23
|
-
* paused playhead jumps to each step's time (the recorded answers and stream frames due by then arrive on the way)
|
|
24
|
-
* and a wait inside a step becomes a jump. A step that does not apply (its target never appears) is skipped, not fatal.
|
|
25
|
-
*/
|
|
22
|
+
/** `rebuild` with a heartbeat on top: the parent hears from the frame for exactly as long as the prelude runs. */
|
|
26
23
|
export declare function runPrelude(options: FramePreludeOptions): Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { runStep } from '../../../../src/Client/Replay';
|
|
2
|
+
import { startPreludeBeat } from './preludeBeat';
|
|
2
3
|
/** Waiting for a target longer than this in a prelude means the step does not apply here; the prelude moves on. */ const PRELUDE_TARGET_TIMEOUT_MS = 3000;
|
|
3
4
|
/** Actions that read or wait rather than change what the screen holds; a prelude leaves them out. */ function changesState(action) {
|
|
4
5
|
return action.kind !== 'scrollTo' && action.kind !== 'waitFor';
|
|
@@ -9,7 +10,7 @@ import { runStep } from '../../../../src/Client/Replay';
|
|
|
9
10
|
* every earlier step's state-changing actions run again at once, with no cursor, no typing delay and no waiting: the
|
|
10
11
|
* paused playhead jumps to each step's time (the recorded answers and stream frames due by then arrive on the way)
|
|
11
12
|
* and a wait inside a step becomes a jump. A step that does not apply (its target never appears) is skipped, not fatal.
|
|
12
|
-
*/
|
|
13
|
+
*/ async function rebuild(options) {
|
|
13
14
|
const { timeline } = options;
|
|
14
15
|
timeline.pause();
|
|
15
16
|
for (const step of options.steps){
|
|
@@ -35,3 +36,12 @@ import { runStep } from '../../../../src/Client/Replay';
|
|
|
35
36
|
if (!result.ok) options.onSkip?.(step.id, result.actionIndex, result.reason);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
/** `rebuild` with a heartbeat on top: the parent hears from the frame for exactly as long as the prelude runs. */ export async function runPrelude(options) {
|
|
40
|
+
const { onHeartbeat } = options;
|
|
41
|
+
const stopBeat = onHeartbeat ? startPreludeBeat(options.win, ()=>options.cancelled() || onHeartbeat(), options.heartbeatMs) : ()=>{};
|
|
42
|
+
try {
|
|
43
|
+
await rebuild(options);
|
|
44
|
+
} finally{
|
|
45
|
+
stopBeat();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Win } from '../../../../src/Client/Replay';
|
|
2
|
+
/** A step can sit silent for tens of seconds (many absent targets at 3 s each); the parent's reload guard is 20 s. */
|
|
3
|
+
export declare const PRELUDE_HEARTBEAT_MS = 2000;
|
|
4
|
+
/**
|
|
5
|
+
* Calls `beat` on a fixed interval until the returned function runs. The prelude's own steps report nothing while
|
|
6
|
+
* they wait, so progress is time-driven: a frame that is still rebuilding keeps beating, a frame that stopped
|
|
7
|
+
* (cancelled, crashed, torn down) beats no more and the parent's guard then fails it as it should.
|
|
8
|
+
*/
|
|
9
|
+
export declare function startPreludeBeat(win: Win, beat: () => void, everyMs?: number): () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A step can sit silent for tens of seconds (many absent targets at 3 s each); the parent's reload guard is 20 s. */ export const PRELUDE_HEARTBEAT_MS = 2000;
|
|
2
|
+
/**
|
|
3
|
+
* Calls `beat` on a fixed interval until the returned function runs. The prelude's own steps report nothing while
|
|
4
|
+
* they wait, so progress is time-driven: a frame that is still rebuilding keeps beating, a frame that stopped
|
|
5
|
+
* (cancelled, crashed, torn down) beats no more and the parent's guard then fails it as it should.
|
|
6
|
+
*/ export function startPreludeBeat(win, beat, everyMs = PRELUDE_HEARTBEAT_MS) {
|
|
7
|
+
const id = win.setInterval(beat, everyMs);
|
|
8
|
+
return ()=>win.clearInterval(id);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.266",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|