dcp-client 4.4.15 → 4.4.16

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.
@@ -186,7 +186,25 @@ self.wrapScriptLoading({ scriptName: 'bootstrap', finalScript: true }, function
186
186
  * `protectedStorage.dispatchSameConsoleMessage()` for the events triggering
187
187
  * their dispatch.
188
188
  */
189
+ const consoleBuffer = [];
190
+ protectedStorage.emitConsoleMessages = false;
191
+
189
192
  function workerBootstrap$console(level, ...args)
193
+ {
194
+ consoleBuffer.push({ level, args });
195
+ if (protectedStorage.emitConsoleMessages)
196
+ workerBootstrap$flushConsole()
197
+ }
198
+
199
+ protectedStorage.flushConsoleBuffer = workerBootstrap$flushConsole;
200
+ function workerBootstrap$flushConsole()
201
+ {
202
+ for (let console of consoleBuffer)
203
+ workerBootstrap$emitConsole(console.level, console.args);
204
+ consoleBuffer.length = 0;
205
+ }
206
+
207
+ function workerBootstrap$emitConsole(level, args)
190
208
  {
191
209
  const newConsoleLog = { level, message: args };
192
210
 
@@ -398,6 +398,8 @@ prepPyodide`);
398
398
  var rejection = false;
399
399
  var result;
400
400
  let metrics;
401
+ protectedStorage.emitConsoleMessages = true;
402
+ protectedStorage.flushConsoleBuffer();
401
403
  try
402
404
  {
403
405
  /* module.main.job is the work function; left by assign message */
@@ -408,9 +410,6 @@ prepPyodide`);
408
410
  rejection = error;
409
411
  }
410
412
 
411
-
412
- // flush any pending console events, especially in the case of a repeating message that hasn't been emitted yet
413
- try { protectedStorage.dispatchSameConsoleMessage(); } catch(e) {};
414
413
  try {
415
414
  // reset the device states and flush all pending tasks
416
415
  protectedStorage.lockTimers(); // lock timers so no new timeouts will be run.
@@ -421,6 +420,11 @@ prepPyodide`);
421
420
  // only the microtask could trigger new code, so waiting for a setTimeout guarantees everything's done
422
421
  await new Promise((r) => protectedStorage.realSetTimeout.call(globalThis, r, 1));
423
422
 
423
+ // flush any pending console events, especially in the case of a repeating message that hasn't been emitted yet
424
+ // then, disable emission of any more console messages
425
+ try { protectedStorage.dispatchSameConsoleMessage(); } catch(e) {};
426
+ protectedStorage.emitConsoleMessages = false;
427
+
424
428
  metrics = await protectedStorage.bigBrother.globalTrackers.getMetrics();
425
429
 
426
430
  await protectedStorage.bigBrother.globalTrackers.reset();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcp-client",
3
- "version": "4.4.15",
3
+ "version": "4.4.16",
4
4
  "description": "Core libraries for accessing DCP network",
5
5
  "keywords": [
6
6
  "dcp"