nucleus-core-ts 0.10.241 → 0.10.243
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.10.
|
|
1
|
+
0.10.243
|
|
@@ -15,6 +15,19 @@ const MAX_KEY_LENGTH = 200;
|
|
|
15
15
|
].sort((a, b)=>a.at - b.at);
|
|
16
16
|
let generation = 0;
|
|
17
17
|
let abortWait = ()=>{};
|
|
18
|
+
// A hold pauses the clock for an action and plays it again after, unless the visitor paused meanwhile.
|
|
19
|
+
let held = false;
|
|
20
|
+
let resumeAfterHold = false;
|
|
21
|
+
const hold = ()=>{
|
|
22
|
+
if (held || !timeline.isPlaying()) return ()=>{};
|
|
23
|
+
held = true;
|
|
24
|
+
resumeAfterHold = true;
|
|
25
|
+
timeline.pause();
|
|
26
|
+
return ()=>{
|
|
27
|
+
held = false;
|
|
28
|
+
if (resumeAfterHold) timeline.play();
|
|
29
|
+
};
|
|
30
|
+
};
|
|
18
31
|
const send = (build)=>{
|
|
19
32
|
sendMessage(options.parent, options.origin, build(envelopeFor(options.nonce)));
|
|
20
33
|
};
|
|
@@ -65,7 +78,8 @@ const MAX_KEY_LENGTH = 200;
|
|
|
65
78
|
settle: options.settle ?? (()=>new Promise((resolve)=>void win.setTimeout(resolve, 0))),
|
|
66
79
|
navigate: options.navigate,
|
|
67
80
|
waitForFrame: options.waitForFrame,
|
|
68
|
-
waitUntil: (at)=>timeline.waitUntil(at)
|
|
81
|
+
waitUntil: (at)=>timeline.waitUntil(at),
|
|
82
|
+
hold
|
|
69
83
|
});
|
|
70
84
|
if (gen !== generation) return false;
|
|
71
85
|
if (result.ok) {
|
|
@@ -122,9 +136,11 @@ const MAX_KEY_LENGTH = 200;
|
|
|
122
136
|
announce();
|
|
123
137
|
break;
|
|
124
138
|
case 'play':
|
|
125
|
-
|
|
139
|
+
if (held) resumeAfterHold = true;
|
|
140
|
+
else timeline.play();
|
|
126
141
|
break;
|
|
127
142
|
case 'pause':
|
|
143
|
+
resumeAfterHold = false;
|
|
128
144
|
timeline.pause();
|
|
129
145
|
break;
|
|
130
146
|
case 'rate':
|
|
@@ -29,5 +29,14 @@ function seen(entry, clock) {
|
|
|
29
29
|
const past = queue.entries.filter((entry)=>seen(entry, clock));
|
|
30
30
|
return [
|
|
31
31
|
...past
|
|
32
|
-
].reverse().find((entry)=>entry.payload === payload) ?? queue.last ?? past.at(-1) ?? queue.entries.find((entry)=>entry.at === undefined);
|
|
32
|
+
].reverse().find((entry)=>entry.payload === payload) ?? queue.last ?? past.at(-1) ?? queue.entries.find((entry)=>entry.at === undefined) ?? earliestAhead(queue.entries, payload, clock);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A call made before the first recorded answer of its key: the recorded call was made before its answer arrived too
|
|
36
|
+
* (`at` is when the answer came), so a page that asks at load gets the first answer ahead, the one for the same payload
|
|
37
|
+
* when there is one. Without it the page's first `ME` at 0 ms found its answer recorded at 388 ms "not due" and
|
|
38
|
+
* the replayed app took itself for signed out. A write recorded after other writes still waits for them.
|
|
39
|
+
*/ function earliestAhead(entries, payload, clock) {
|
|
40
|
+
const ahead = entries.filter((entry)=>entry.at !== undefined && entry.at > clock.playhead && !(entry.write && entry.served)).sort((a, b)=>(a.at ?? 0) - (b.at ?? 0));
|
|
41
|
+
return ahead.find((entry)=>entry.payload === payload) ?? ahead[0];
|
|
33
42
|
}
|
|
@@ -18,6 +18,12 @@ export interface RunDeps {
|
|
|
18
18
|
waitForFrame: (stream: string, seq: number) => Promise<void>;
|
|
19
19
|
/** Owned by the timeline: resolves when the playhead reaches `at`. */
|
|
20
20
|
waitUntil: (at: number) => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Stops the recorded clock while a found target is pointed at, clicked or typed into, and returns the release. The
|
|
23
|
+
* recorded person did it in an instant; the drawn cursor and the typing take seconds, and a stream frame due in
|
|
24
|
+
* those seconds (the server's answer to that very click) would otherwise take the control away first.
|
|
25
|
+
*/
|
|
26
|
+
hold?: () => () => void;
|
|
21
27
|
}
|
|
22
28
|
export type RunResult = {
|
|
23
29
|
ok: true;
|
|
@@ -18,6 +18,14 @@ async function runTargeted(deps, action) {
|
|
|
18
18
|
timeoutMs: deps.targetTimeoutMs ?? DEFAULT_TARGET_TIMEOUT_MS
|
|
19
19
|
});
|
|
20
20
|
if (!element) return 'target_timeout';
|
|
21
|
+
const release = deps.hold?.() ?? (()=>{});
|
|
22
|
+
try {
|
|
23
|
+
return await actOn(deps, action, element);
|
|
24
|
+
} finally{
|
|
25
|
+
release();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function actOn(deps, action, element) {
|
|
21
29
|
if (isPointerAction(action)) {
|
|
22
30
|
bringIntoView(deps.win, element);
|
|
23
31
|
await deps.onPoint(boxOf(deps.win, await settledBox(deps.win, element)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.243",
|
|
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",
|