nucleus-core-ts 0.10.242 → 0.10.244

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.242
1
+ 0.10.244
@@ -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
- timeline.play();
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':