dcp-client 4.4.23 → 4.4.24

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file worker/evaluator-lib/access-lists.js
3
3
  *
4
- * This file applies access lists and polyfills to the global object.
4
+ * Applies access lists to the global object.
5
5
  *
6
6
  * @author Sam Cantor, sam@kingsds.network
7
7
  * @date Sept 2020
@@ -83,6 +83,7 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
83
83
  'toString',
84
84
  'TypeError',
85
85
  'URIError',
86
+ 'URL',
86
87
  'Uint16Array',
87
88
  'Uint32Array',
88
89
  'Uint8Array',
@@ -156,492 +157,6 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
156
157
  'userAgentData',
157
158
  ]);
158
159
 
159
- // Origin time for performance polyfill
160
- const pt0 = new Date().getTime();
161
-
162
- // Add polyfills for any non-allowed symbols
163
- const polyfills = {
164
- location: {
165
- search: "",
166
- href: 'DCP Worker',
167
- },
168
- // Assumption that if performance exists, performance.now must exist
169
- performance: typeof performance !== 'undefined' ? performance : {
170
- now: ()=>{
171
- const res = new Date().getTime() - pt0;
172
- return res;
173
- }
174
- },
175
- importScripts: function () {
176
- throw new Error('importScripts is not supported on DCP');
177
- },
178
- globalThis: typeof globalThis === 'undefined' ? self : globalThis,
179
- WorkerGlobalScope: typeof globalThis === 'undefined' ? self : globalThis,
180
- // For browsers/SA-workers that don't support btoa/atob, modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
181
- btoa: function (string) {
182
- var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
183
-
184
- string = String(string);
185
- var bitmap, a, b, c,
186
- result = "", i = 0,
187
- rest = string.length % 3;
188
-
189
- for (; i < string.length;) {
190
- if ((a = string.charCodeAt(i++)) > 255
191
- || (b = string.charCodeAt(i++)) > 255
192
- || (c = string.charCodeAt(i++)) > 255)
193
- throw new TypeError("Failed to execute 'btoa': The string to be encoded contains characters outside of the Latin1 range.");
194
-
195
- bitmap = (a << 16) | (b << 8) | c;
196
- result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63)
197
- + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
198
- }
199
-
200
- // If there's need of padding, replace the last 'A's with equal signs
201
- return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result;
202
- },
203
- atob: function (string) {
204
- var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
205
- string = String(string).replace(/[\t\n\f\r ]+/g, "");
206
-
207
- // Adding the padding if missing, for semplicity
208
- string += "==".slice(2 - (string.length & 3));
209
- var bitmap, result = "", r1, r2, i = 0;
210
- for (; i < string.length;) {
211
- bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12
212
- | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
213
-
214
- result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
215
- : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
216
- : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
217
- }
218
- return result;
219
- },
220
- // Polyfill for Blob
221
- Blob: class Blob {
222
- /** @type {Array.<(Blob|Uint8Array)>} */
223
- #parts = [];
224
- #type = '';
225
- #size = 0;
226
- #endings = 'transparent';
227
-
228
- /**
229
- * The Blob() constructor returns a new Blob object. The content
230
- * of the blob consists of the concatenation of the values given
231
- * in the parameter array.
232
- *
233
- * @param {*} blobParts
234
- * @param {{ type?: string, endings?: string }} [options]
235
- */
236
- constructor (blobParts = [], options = {}) {
237
- if (typeof blobParts !== 'object' || blobParts === null) {
238
- throw new TypeError('Failed to construct \'Blob\': The provided value cannot be converted to a sequence.');
239
- }
240
-
241
- if (typeof blobParts[Symbol.iterator] !== 'function') {
242
- throw new TypeError('Failed to construct \'Blob\': The object must have a callable @@iterator property.');
243
- }
244
-
245
- if (typeof options !== 'object' && typeof options !== 'function') {
246
- throw new TypeError('Failed to construct \'Blob\': parameter 2 cannot convert to dictionary.');
247
- }
248
-
249
- if (options === null) options = {};
250
-
251
- const encoder = new TextEncoder();
252
-
253
- for (const element of blobParts) {
254
- let part;
255
-
256
- if (ArrayBuffer.isView(element)) {
257
- part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
258
- } else if (element instanceof ArrayBuffer) {
259
- part = new Uint8Array(element.slice(0));
260
- } else if (element instanceof Blob) {
261
- part = element;
262
- } else {
263
- part = encoder.encode(`${element}`);
264
- }
265
-
266
- const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
267
- // Avoid pushing empty parts into the array to better GC them
268
- if (size) {
269
- this.#size += size;
270
- this.#parts.push(part);
271
- }
272
- }
273
-
274
- this.#endings = `${options.endings === undefined ? 'transparent' : options.endings}`;
275
- const type = options.type === undefined ? '' : String(options.type);
276
- this.#type = /^[\x20-\x7E]*$/.test(type) ? type : '';
277
- }
278
-
279
- /**
280
- * The Blob interface's size property returns the
281
- * size of the Blob in bytes.
282
- */
283
- get size() {
284
- return this.#size;
285
- }
286
-
287
- /**
288
- * The type property of a Blob object returns the MIME type of the file.
289
- */
290
- get type() {
291
- return this.#type;
292
- }
293
-
294
- /**
295
- * The text() method in the Blob interface returns a Promise
296
- * that resolves with a string containing the contents of
297
- * the blob, interpreted as UTF-8.
298
- *
299
- * @return {Promise<string>}
300
- */
301
- async text() {
302
- debugger;
303
- // More optimized than using this.arrayBuffer()
304
- // that requires twice as much ram
305
- const decoder = new TextDecoder();
306
- let str = '';
307
-
308
- for await (const part of toIterator(this.#parts, false)) {
309
- str += decoder.decode(part, { stream: true });
310
- }
311
-
312
- // Remaining
313
- str += decoder.decode();
314
- return str;
315
- }
316
-
317
- /**
318
- * The arrayBuffer() method in the Blob interface returns a
319
- * Promise that resolves with the contents of the blob as
320
- * binary data contained in an ArrayBuffer.
321
- *
322
- * @return {Promise<ArrayBuffer>}
323
- */
324
- async arrayBuffer() {
325
- // Easier way... Just a unnecessary overhead
326
- // const view = new Uint8Array(this.size);
327
- // await this.stream().getReader({mode: 'byob'}).read(view);
328
- // return view.buffer;
329
-
330
- const data = new Uint8Array(this.size);
331
- let offset = 0;
332
-
333
- for await (const chunk of toIterator(this.#parts, false)) {
334
- data.set(chunk, offset);
335
- offset += chunk.length;
336
- }
337
-
338
- return data.buffer;
339
- }
340
-
341
- /**
342
- * stream() requires a polyfill for "ReadableStream" so leave it NYI for
343
- * now, in case of feature testing
344
- */
345
- // stream() {
346
- // }
347
-
348
- /**
349
- * The Blob interface's slice() method creates and returns a
350
- * new Blob object which contains data from a subset of the
351
- * blob on which it's called.
352
- *
353
- * @param {number} [start]
354
- * @param {number} [end]
355
- * @param {string} [type]
356
- */
357
- slice(start = 0, end = this.size, type = '') {
358
- const { size } = this;
359
-
360
- let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
361
- let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
362
-
363
- const span = Math.max(relativeEnd - relativeStart, 0);
364
- const parts = this.#parts;
365
- const blobParts = [];
366
- let added = 0;
367
-
368
- for (const part of parts) {
369
- // don't add the overflow to new blobParts
370
- if (added >= span) {
371
- break;
372
- }
373
-
374
- const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
375
- if (relativeStart && size <= relativeStart) {
376
- // Skip the beginning and change the relative
377
- // start & end position as we skip the unwanted parts
378
- relativeStart -= size;
379
- relativeEnd -= size;
380
- } else {
381
- let chunk;
382
-
383
- if (ArrayBuffer.isView(part)) {
384
- chunk = part.subarray(relativeStart, Math.min(size, relativeEnd));
385
- added += chunk.byteLength;
386
- } else {
387
- chunk = part.slice(relativeStart, Math.min(size, relativeEnd));
388
- added += chunk.size;
389
- }
390
-
391
- relativeEnd -= size;
392
- blobParts.push(chunk);
393
- relativeStart = 0; // All next sequential parts should start at 0
394
- }
395
- }
396
-
397
- const blob = new Blob([], { type: String(type).toLowerCase() });
398
- blob.#size = span;
399
- blob.#parts = blobParts;
400
-
401
- return blob;
402
- }
403
-
404
- get[Symbol.toStringTag]() {
405
- return 'Blob';
406
- }
407
-
408
- static[Symbol.hasInstance](object) {
409
- return (
410
- object &&
411
- typeof object === 'object' &&
412
- typeof object.constructor === 'function' &&
413
- (
414
- typeof object.stream === 'function' ||
415
- typeof object.arrayBuffer === 'function'
416
- ) &&
417
- /^(Blob|File)$/.test(object[Symbol.toStringTag])
418
- );
419
- }
420
- }
421
- };
422
-
423
- /** @param {(Blob | Uint8Array)[]} parts */
424
- async function * toIterator (parts, clone = true) {
425
- for (const part of parts) {
426
- if ('stream' in part) {
427
- yield * (/** @type {AsyncIterableIterator<Uint8Array>} */ (part.stream()))
428
- } else if (ArrayBuffer.isView(part)) {
429
- if (clone) {
430
- let position = part.byteOffset
431
- const end = part.byteOffset + part.byteLength
432
- while (position !== end) {
433
- const size = Math.min(end - position, POOL_SIZE)
434
- const chunk = part.buffer.slice(position, position + size)
435
- position += chunk.byteLength
436
- yield new Uint8Array(chunk)
437
- }
438
- } else {
439
- yield part
440
- }
441
- /* c8 ignore next 10 */
442
- } else {
443
- // For blobs that have arrayBuffer but no stream method (nodes buffer.Blob)
444
- let position = 0, b = (/** @type {Blob} */ (part))
445
- while (position !== b.size) {
446
- const chunk = b.slice(position, Math.min(b.size, position + POOL_SIZE))
447
- const buffer = await chunk.arrayBuffer()
448
- position += buffer.byteLength
449
- yield new Uint8Array(buffer)
450
- }
451
- }
452
- }
453
- }
454
-
455
- // Polyfill for TextEncoder/Decoder
456
- var fromCharCode = String.fromCharCode;
457
- var Object_prototype_toString = ({}).toString;
458
- var sharedArrayBufferString = Object_prototype_toString.call(self["SharedArrayBuffer"]);
459
- var undefinedObjectString = '[object Undefined]';
460
- var NativeUint8Array = self.Uint8Array;
461
- var patchedU8Array = NativeUint8Array || Array;
462
- var nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;
463
- var arrayBuffer_isView = nativeArrayBuffer.isView || function(x) {return x && "length" in x};
464
- var arrayBufferString = Object_prototype_toString.call(nativeArrayBuffer.prototype);
465
- var tmpBufferU16 = new (NativeUint8Array ? Uint16Array : patchedU8Array)(32);
466
-
467
- if (typeof TextEncoder === "undefined") {
468
- self.TextEncoder = function TextEncoder(){};
469
- var TextEncoderPrototype = TextEncoder["prototype"];
470
- TextEncoderPrototype["encode"] = function(inputString){
471
- // 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
472
- // 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
473
- var encodedString = inputString === void 0 ? "" : ("" + inputString), len=encodedString.length|0;
474
- var result=new patchedU8Array((len << 1) + 8|0), tmpResult;
475
- var i=0, pos=0, point=0, nextcode=0;
476
- var upgradededArraySize=!NativeUint8Array; // normal arrays are auto-expanding
477
- for (i=0; i<len; i=i+1|0, pos=pos+1|0) {
478
- point = encodedString.charCodeAt(i)|0;
479
- if (point <= 0x007f) {
480
- result[pos] = point;
481
- } else if (point <= 0x07ff) {
482
- result[pos] = (0x6<<5)|(point>>6);
483
- result[pos=pos+1|0] = (0x2<<6)|(point&0x3f);
484
- } else {
485
- widenCheck: {
486
- if (0xD800 <= point) {
487
- if (point <= 0xDBFF) {
488
- nextcode = encodedString.charCodeAt(i=i+1|0)|0; // defaults to 0 when NaN, causing null replacement character
489
-
490
- if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
491
- //point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
492
- point = (point<<10) + nextcode - 0x35fdc00|0;
493
- if (point > 0xffff) {
494
- result[pos] = (0x1e/*0b11110*/<<3) | (point>>18);
495
- result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/);
496
- result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
497
- result[pos=pos+1|0] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
498
- continue;
499
- }
500
- break widenCheck;
501
- }
502
- point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
503
- } else if (point <= 0xDFFF) {
504
- point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
505
- }
506
- }
507
- if (!upgradededArraySize && (i << 1) < pos && (i << 1) < (pos - 7|0)) {
508
- upgradededArraySize = true;
509
- tmpResult = new patchedU8Array(len * 3);
510
- tmpResult.set( result );
511
- result = tmpResult;
512
- }
513
- }
514
- result[pos] = (0xe/*0b1110*/<<4) | (point>>12);
515
- result[pos=pos+1|0] =(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
516
- result[pos=pos+1|0] =(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
517
- }
518
- }
519
- return NativeUint8Array ? result.subarray(0, pos) : result.slice(0, pos);
520
- };
521
- }
522
-
523
- if (typeof TextDecoder === "undefined") {
524
- self.TextDecoder = function TextDecoder(){};
525
- TextDecoder["prototype"]["decode"] = function(inputArrayOrBuffer){
526
- var inputAs8 = inputArrayOrBuffer, asObjectString;
527
- if (!arrayBuffer_isView(inputAs8)) {
528
- asObjectString = Object_prototype_toString.call(inputAs8);
529
- if (asObjectString !== arrayBufferString && asObjectString !== sharedArrayBufferString && asObjectString !== undefinedObjectString)
530
- throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
531
- inputAs8 = NativeUint8Array ? new patchedU8Array(inputAs8) : inputAs8 || [];
532
- }
533
-
534
- var resultingString = "", tmpStr = "", index = 0, len = inputAs8.length | 0, lenMinus32 = len - 32 | 0, nextEnd = 0, nextStop = 0, cp0 = 0, codePoint = 0, minBits = 0, cp1 = 0, pos = 0, tmp = -1;
535
- // Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
536
- for (; index < len;) {
537
- nextEnd = index <= lenMinus32 ? 32 : len - index | 0;
538
- for (; pos < nextEnd; index = index + 1 | 0, pos = pos + 1 | 0) {
539
- cp0 = inputAs8[index] & 0xff;
540
- switch (cp0 >> 4) {
541
- case 15:
542
- cp1 = inputAs8[index = index + 1 | 0] & 0xff;
543
- if ((cp1 >> 6) !== 2 || 247 < cp0) {
544
- index = index - 1 | 0;
545
- break;
546
- }
547
- codePoint = ((cp0 & 7) << 6) | (cp1 & 63);
548
- minBits = 5; // 20 ensures it never passes -> all invalid replacements
549
- cp0 = 0x100; // keep track of th bit size
550
- case 14:
551
- cp1 = inputAs8[index = index + 1 | 0] & 0xff;
552
- codePoint <<= 6;
553
- codePoint |= ((cp0 & 15) << 6) | (cp1 & 63);
554
- minBits = (cp1 >> 6) === 2 ? minBits + 4 | 0 : 24; // 24 ensures it never passes -> all invalid replacements
555
- cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
556
- case 13:
557
- case 12:
558
- cp1 = inputAs8[index = index + 1 | 0] & 0xff;
559
- codePoint <<= 6;
560
- codePoint |= ((cp0 & 31) << 6) | cp1 & 63;
561
- minBits = minBits + 7 | 0;
562
-
563
- // Now, process the code point
564
- if (index < len && (cp1 >> 6) === 2 && (codePoint >> minBits) && codePoint < 0x110000) {
565
- cp0 = codePoint;
566
- codePoint = codePoint - 0x10000 | 0;
567
- if (0 <= codePoint/*0xffff < codePoint*/) { // BMP code point
568
- //nextEnd = nextEnd - 1|0;
569
-
570
- tmp = (codePoint >> 10) + 0xD800 | 0; // highSurrogate
571
- cp0 = (codePoint & 0x3ff) + 0xDC00 | 0; // lowSurrogate (will be inserted later in the switch-statement)
572
-
573
- if (pos < 31) { // notice 31 instead of 32
574
- tmpBufferU16[pos] = tmp;
575
- pos = pos + 1 | 0;
576
- tmp = -1;
577
- } else {// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
578
- // NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
579
- cp1 = tmp;
580
- tmp = cp0;
581
- cp0 = cp1;
582
- }
583
- } else nextEnd = nextEnd + 1 | 0; // because we are advancing i without advancing pos
584
- } else {
585
- // invalid code point means replacing the whole thing with null replacement characters
586
- cp0 >>= 8;
587
- index = index - cp0 - 1 | 0; // reset index back to what it was before
588
- cp0 = 0xfffd;
589
- }
590
- // Finally, reset the variables for the next go-around
591
- minBits = 0;
592
- codePoint = 0;
593
- nextEnd = index <= lenMinus32 ? 32 : len - index | 0;
594
- /*case 11:
595
- case 10:
596
- case 9:
597
- case 8:
598
- codePoint ? codePoint = 0 : cp0 = 0xfffd; // fill with invalid replacement character
599
- case 7:
600
- case 6:
601
- case 5:
602
- case 4:
603
- case 3:
604
- case 2:
605
- case 1:
606
- case 0:
607
- tmpBufferU16[pos] = cp0;
608
- continue;*/
609
- default:
610
- tmpBufferU16[pos] = cp0; // fill with invalid replacement character
611
- continue;
612
- case 11:
613
- case 10:
614
- case 9:
615
- case 8:
616
- }
617
- tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
618
- }
619
- tmpStr += fromCharCode(
620
- tmpBufferU16[0], tmpBufferU16[1], tmpBufferU16[2], tmpBufferU16[3], tmpBufferU16[4], tmpBufferU16[5], tmpBufferU16[6], tmpBufferU16[7],
621
- tmpBufferU16[8], tmpBufferU16[9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15],
622
- tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23],
623
- tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]
624
- );
625
- if (pos < 32) tmpStr = tmpStr.slice(0, pos - 32 | 0);//-(32-pos));
626
- if (index < len) {
627
- //fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
628
- tmpBufferU16[0] = tmp;
629
- pos = (~tmp) >>> 31;//tmp !== -1 ? 1 : 0;
630
- tmp = -1;
631
-
632
- if (tmpStr.length < resultingString.length) continue;
633
- } else if (tmp !== -1) {
634
- tmpStr += fromCharCode(tmp);
635
- }
636
-
637
- resultingString += tmpStr;
638
- tmpStr = "";
639
- }
640
-
641
- return resultingString;
642
- }
643
- }
644
-
645
160
  const webGLSymbols = [
646
161
  'WebGL2RenderingContext',
647
162
  'WebGLTexture',
@@ -862,28 +377,6 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
862
377
  });
863
378
  }
864
379
 
865
- /**
866
- * Assigns each property from some polyfill object to another object, inserting or replacing for each property
867
- *
868
- * @param {Object} obj - The object to add properties on
869
- * @param {Object} polyfills - An object of properties to create/polyfill
870
- */
871
- function applyPolyfills(obj, polyfills) {
872
- // Apply symbols from polyfill object
873
- for (let prop in polyfills) {
874
- let propValue = polyfills[prop];
875
- Object.defineProperty(obj, prop, {
876
- get: function getPolyfill() {
877
- return propValue;
878
- },
879
- set: function setPolyfill(value) {
880
- propValue = value;
881
- },
882
- configurable: false
883
- });
884
- }
885
- }
886
-
887
380
  /**
888
381
  * Applies the allowList.
889
382
  * This must be called after the requirements are assigned to the sandbox
@@ -938,11 +431,6 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
938
431
  navigator.userAgent = 'not-a-browser';
939
432
  }
940
433
 
941
- /* Polyfill section of workerBootstrap */
942
-
943
- // Define properties for symbols that are not present in the global object
944
- applyPolyfills(global, polyfills);
945
-
946
434
  // At time of writing, Chrome defines requestAnimationFrame inside web workers, but
947
435
  // Firefox doesn't.
948
436
  if (typeof requestAnimationFrame == 'undefined') {
@@ -346,7 +346,7 @@ prepPyodide`);
346
346
  /* Report an error from the work function to the supervisor */
347
347
  function reportError (error, metrics)
348
348
  {
349
- let err = { message: 'initial state', name: 'initial state' };
349
+ let err = new Error('initial state');
350
350
 
351
351
  for (let prop of [ 'message', 'name', 'code', 'stack', 'lineNumber', 'columnNumber' ])
352
352
  {