-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension-worker.js
1402 lines (1233 loc) · 58.6 KB
/
extension-worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./node_modules/babel-loader/lib/index.js?!./node_modules/scratch-vm/src/extension-support/extension-worker.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/scratch-vm/src/extension-support/extension-worker.js":
/*!*******************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib??ref--4!./node_modules/scratch-vm/src/extension-support/extension-worker.js ***!
\*******************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/* eslint-env worker */
var ArgumentType = __webpack_require__(/*! ../extension-support/argument-type */ "./node_modules/scratch-vm/src/extension-support/argument-type.js");
var BlockType = __webpack_require__(/*! ../extension-support/block-type */ "./node_modules/scratch-vm/src/extension-support/block-type.js");
var dispatch = __webpack_require__(/*! ../dispatch/worker-dispatch */ "./node_modules/scratch-vm/src/dispatch/worker-dispatch.js");
var TargetType = __webpack_require__(/*! ../extension-support/target-type */ "./node_modules/scratch-vm/src/extension-support/target-type.js");
var ExtensionWorker = /*#__PURE__*/function () {
function ExtensionWorker() {
var _this = this;
_classCallCheck(this, ExtensionWorker);
this.nextExtensionId = 0;
this.initialRegistrations = [];
dispatch.waitForConnection.then(function () {
dispatch.call('extensions', 'allocateWorker').then(function (x) {
var _x2 = _slicedToArray(x, 2),
id = _x2[0],
extension = _x2[1];
_this.workerId = id;
try {
importScripts(extension);
var initialRegistrations = _this.initialRegistrations;
_this.initialRegistrations = null;
Promise.all(initialRegistrations).then(function () {
return dispatch.call('extensions', 'onWorkerInit', id);
});
} catch (e) {
dispatch.call('extensions', 'onWorkerInit', id, e);
}
});
});
this.extensions = [];
}
_createClass(ExtensionWorker, [{
key: "register",
value: function register(extensionObject) {
var extensionId = this.nextExtensionId++;
this.extensions.push(extensionObject);
var serviceName = "extension.".concat(this.workerId, ".").concat(extensionId);
var promise = dispatch.setService(serviceName, extensionObject).then(function () {
return dispatch.call('extensions', 'registerExtensionService', serviceName);
});
if (this.initialRegistrations) {
this.initialRegistrations.push(promise);
}
return promise;
}
}]);
return ExtensionWorker;
}();
global.Scratch = global.Scratch || {};
global.Scratch.ArgumentType = ArgumentType;
global.Scratch.BlockType = BlockType;
global.Scratch.TargetType = TargetType;
/**
* Expose only specific parts of the worker to extensions.
*/
var extensionWorker = new ExtensionWorker();
global.Scratch.extensions = {
register: extensionWorker.register.bind(extensionWorker)
};
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/microee/index.js":
/*!***************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/microee/index.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function M() { this._events = {}; }
M.prototype = {
on: function(ev, cb) {
this._events || (this._events = {});
var e = this._events;
(e[ev] || (e[ev] = [])).push(cb);
return this;
},
removeListener: function(ev, cb) {
var e = this._events[ev] || [], i;
for(i = e.length-1; i >= 0 && e[i]; i--){
if(e[i] === cb || e[i].cb === cb) { e.splice(i, 1); }
}
},
removeAllListeners: function(ev) {
if(!ev) { this._events = {}; }
else { this._events[ev] && (this._events[ev] = []); }
},
listeners: function(ev) {
return (this._events ? this._events[ev] || [] : []);
},
emit: function(ev) {
this._events || (this._events = {});
var args = Array.prototype.slice.call(arguments, 1), i, e = this._events[ev] || [];
for(i = e.length-1; i >= 0 && e[i]; i--){
e[i].apply(this, args);
}
return this;
},
when: function(ev, cb) {
return this.once(ev, cb, true);
},
once: function(ev, cb, when) {
if(!cb) return this;
function c() {
if(!when) this.removeListener(ev, c);
if(cb.apply(this, arguments) && when) this.removeListener(ev, c);
}
c.cb = cb;
this.on(ev, c);
return this;
}
};
M.mixin = function(dest) {
var o = M.prototype, k;
for (k in o) {
o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
}
};
module.exports = M;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/common/filter.js":
/*!***************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/common/filter.js ***!
\***************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// default filter
var Transform = __webpack_require__(/*! ./transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js");
var levelMap = { debug: 1, info: 2, warn: 3, error: 4 };
function Filter() {
this.enabled = true;
this.defaultResult = true;
this.clear();
}
Transform.mixin(Filter);
// allow all matching, with level >= given level
Filter.prototype.allow = function(name, level) {
this._white.push({ n: name, l: levelMap[level] });
return this;
};
// deny all matching, with level <= given level
Filter.prototype.deny = function(name, level) {
this._black.push({ n: name, l: levelMap[level] });
return this;
};
Filter.prototype.clear = function() {
this._white = [];
this._black = [];
return this;
};
function test(rule, name) {
// use .test for RegExps
return (rule.n.test ? rule.n.test(name) : rule.n == name);
};
Filter.prototype.test = function(name, level) {
var i, len = Math.max(this._white.length, this._black.length);
for(i = 0; i < len; i++) {
if(this._white[i] && test(this._white[i], name) && levelMap[level] >= this._white[i].l) {
return true;
}
if(this._black[i] && test(this._black[i], name) && levelMap[level] <= this._black[i].l) {
return false;
}
}
return this.defaultResult;
};
Filter.prototype.write = function(name, level, args) {
if(!this.enabled || this.test(name, level)) {
return this.emit('item', name, level, args);
}
};
module.exports = Filter;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/common/minilog.js":
/*!****************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/common/minilog.js ***!
\****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ./transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js"),
Filter = __webpack_require__(/*! ./filter.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/filter.js");
var log = new Transform(),
slice = Array.prototype.slice;
exports = module.exports = function create(name) {
var o = function() { log.write(name, undefined, slice.call(arguments)); return o; };
o.debug = function() { log.write(name, 'debug', slice.call(arguments)); return o; };
o.info = function() { log.write(name, 'info', slice.call(arguments)); return o; };
o.warn = function() { log.write(name, 'warn', slice.call(arguments)); return o; };
o.error = function() { log.write(name, 'error', slice.call(arguments)); return o; };
o.log = o.debug; // for interface compliance with Node and browser consoles
o.suggest = exports.suggest;
o.format = log.format;
return o;
};
// filled in separately
exports.defaultBackend = exports.defaultFormatter = null;
exports.pipe = function(dest) {
return log.pipe(dest);
};
exports.end = exports.unpipe = exports.disable = function(from) {
return log.unpipe(from);
};
exports.Transform = Transform;
exports.Filter = Filter;
// this is the default filter that's applied when .enable() is called normally
// you can bypass it completely and set up your own pipes
exports.suggest = new Filter();
exports.enable = function() {
if(exports.defaultFormatter) {
return log.pipe(exports.suggest) // filter
.pipe(exports.defaultFormatter) // formatter
.pipe(exports.defaultBackend); // backend
}
return log.pipe(exports.suggest) // filter
.pipe(exports.defaultBackend); // formatter
};
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js":
/*!******************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js ***!
\******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var microee = __webpack_require__(/*! microee */ "./node_modules/scratch-vm/node_modules/microee/index.js");
// Implements a subset of Node's stream.Transform - in a cross-platform manner.
function Transform() {}
microee.mixin(Transform);
// The write() signature is different from Node's
// --> makes it much easier to work with objects in logs.
// One of the lessons from v1 was that it's better to target
// a good browser rather than the lowest common denominator
// internally.
// If you want to use external streams, pipe() to ./stringify.js first.
Transform.prototype.write = function(name, level, args) {
this.emit('item', name, level, args);
};
Transform.prototype.end = function() {
this.emit('end');
this.removeAllListeners();
};
Transform.prototype.pipe = function(dest) {
var s = this;
// prevent double piping
s.emit('unpipe', dest);
// tell the dest that it's being piped to
dest.emit('pipe', s);
function onItem() {
dest.write.apply(dest, Array.prototype.slice.call(arguments));
}
function onEnd() { !dest._isStdio && dest.end(); }
s.on('item', onItem);
s.on('end', onEnd);
s.when('unpipe', function(from) {
var match = (from === dest) || typeof from == 'undefined';
if(match) {
s.removeListener('item', onItem);
s.removeListener('end', onEnd);
dest.emit('unpipe');
}
return match;
});
return dest;
};
Transform.prototype.unpipe = function(from) {
this.emit('unpipe', from);
return this;
};
Transform.prototype.format = function(dest) {
throw new Error([
'Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:',
'var Minilog = require(\'minilog\');',
'Minilog',
' .pipe(Minilog.backends.console.formatClean)',
' .pipe(Minilog.backends.console);'].join('\n'));
};
Transform.mixin = function(dest) {
var o = Transform.prototype, k;
for (k in o) {
o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
}
};
module.exports = Transform;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/array.js":
/*!***********************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/array.js ***!
\***********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js"),
cache = [ ];
var logger = new Transform();
logger.write = function(name, level, args) {
cache.push([ name, level, args ]);
};
// utility functions
logger.get = function() { return cache; };
logger.empty = function() { cache = []; };
module.exports = logger;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/console.js":
/*!*************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/console.js ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js");
var newlines = /\n+$/,
logger = new Transform();
logger.write = function(name, level, args) {
var i = args.length-1;
if (typeof console === 'undefined' || !console.log) {
return;
}
if(console.log.apply) {
return console.log.apply(console, [name, level].concat(args));
} else if(JSON && JSON.stringify) {
// console.log.apply is undefined in IE8 and IE9
// for IE8/9: make console.log at least a bit less awful
if(args[i] && typeof args[i] == 'string') {
args[i] = args[i].replace(newlines, '');
}
try {
for(i = 0; i < args.length; i++) {
args[i] = JSON.stringify(args[i]);
}
} catch(e) {}
console.log(args.join(' '));
}
};
logger.formatters = ['color', 'minilog'];
logger.color = __webpack_require__(/*! ./formatters/color.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/color.js");
logger.minilog = __webpack_require__(/*! ./formatters/minilog.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/minilog.js");
module.exports = logger;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/color.js":
/*!**********************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/color.js ***!
\**********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js"),
color = __webpack_require__(/*! ./util.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/util.js");
var colors = { debug: ['cyan'], info: ['purple' ], warn: [ 'yellow', true ], error: [ 'red', true ] },
logger = new Transform();
logger.write = function(name, level, args) {
var fn = console.log;
if(console[level] && console[level].apply) {
fn = console[level];
fn.apply(console, [ '%c'+name+' %c'+level, color('gray'), color.apply(color, colors[level])].concat(args));
}
};
// NOP, because piping the formatted logs can only cause trouble.
logger.pipe = function() { };
module.exports = logger;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/minilog.js":
/*!************************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/minilog.js ***!
\************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js"),
color = __webpack_require__(/*! ./util.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/util.js"),
colors = { debug: ['gray'], info: ['purple' ], warn: [ 'yellow', true ], error: [ 'red', true ] },
logger = new Transform();
logger.write = function(name, level, args) {
var fn = console.log;
if(level != 'debug' && console[level]) {
fn = console[level];
}
var subset = [], i = 0;
if(level != 'info') {
for(; i < args.length; i++) {
if(typeof args[i] != 'string') break;
}
fn.apply(console, [ '%c'+name +' '+ args.slice(0, i).join(' '), color.apply(color, colors[level]) ].concat(args.slice(i)));
} else {
fn.apply(console, [ '%c'+name, color.apply(color, colors[level]) ].concat(args));
}
};
// NOP, because piping the formatted logs can only cause trouble.
logger.pipe = function() { };
module.exports = logger;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/util.js":
/*!*********************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/formatters/util.js ***!
\*********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
var hex = {
black: '#000',
red: '#c23621',
green: '#25bc26',
yellow: '#bbbb00',
blue: '#492ee1',
magenta: '#d338d3',
cyan: '#33bbc8',
gray: '#808080',
purple: '#708'
};
function color(fg, isInverse) {
if(isInverse) {
return 'color: #fff; background: '+hex[fg]+';';
} else {
return 'color: '+hex[fg]+';';
}
}
module.exports = color;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/index.js":
/*!***********************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/index.js ***!
\***********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Minilog = __webpack_require__(/*! ../common/minilog.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/minilog.js");
var oldEnable = Minilog.enable,
oldDisable = Minilog.disable,
isChrome = (typeof navigator != 'undefined' && /chrome/i.test(navigator.userAgent)),
console = __webpack_require__(/*! ./console.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/console.js");
// Use a more capable logging backend if on Chrome
Minilog.defaultBackend = (isChrome ? console.minilog : console);
// apply enable inputs from localStorage and from the URL
if(typeof window != 'undefined') {
try {
Minilog.enable(JSON.parse(window.localStorage['minilogSettings']));
} catch(e) {}
if(window.location && window.location.search) {
var match = RegExp('[?&]minilog=([^&]*)').exec(window.location.search);
match && Minilog.enable(decodeURIComponent(match[1]));
}
}
// Make enable also add to localStorage
Minilog.enable = function() {
oldEnable.call(Minilog, true);
try { window.localStorage['minilogSettings'] = JSON.stringify(true); } catch(e) {}
return this;
};
Minilog.disable = function() {
oldDisable.call(Minilog);
try { delete window.localStorage.minilogSettings; } catch(e) {}
return this;
};
exports = module.exports = Minilog;
exports.backends = {
array: __webpack_require__(/*! ./array.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/array.js"),
browser: Minilog.defaultBackend,
localStorage: __webpack_require__(/*! ./localstorage.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/localstorage.js"),
jQuery: __webpack_require__(/*! ./jquery_simple.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/web/jquery_simple.js")
};
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/jquery_simple.js":
/*!*******************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/jquery_simple.js ***!
\*******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js");
var cid = new Date().valueOf().toString(36);
function AjaxLogger(options) {
this.url = options.url || '';
this.cache = [];
this.timer = null;
this.interval = options.interval || 30*1000;
this.enabled = true;
this.jQuery = window.jQuery;
this.extras = {};
}
Transform.mixin(AjaxLogger);
AjaxLogger.prototype.write = function(name, level, args) {
if(!this.timer) { this.init(); }
this.cache.push([name, level].concat(args));
};
AjaxLogger.prototype.init = function() {
if(!this.enabled || !this.jQuery) return;
var self = this;
this.timer = setTimeout(function() {
var i, logs = [], ajaxData, url = self.url;
if(self.cache.length == 0) return self.init();
// Test each log line and only log the ones that are valid (e.g. don't have circular references).
// Slight performance hit but benefit is we log all valid lines.
for(i = 0; i < self.cache.length; i++) {
try {
JSON.stringify(self.cache[i]);
logs.push(self.cache[i]);
} catch(e) { }
}
if(self.jQuery.isEmptyObject(self.extras)) {
ajaxData = JSON.stringify({ logs: logs });
url = self.url + '?client_id=' + cid;
} else {
ajaxData = JSON.stringify(self.jQuery.extend({logs: logs}, self.extras));
}
self.jQuery.ajax(url, {
type: 'POST',
cache: false,
processData: false,
data: ajaxData,
contentType: 'application/json',
timeout: 10000
}).success(function(data, status, jqxhr) {
if(data.interval) {
self.interval = Math.max(1000, data.interval);
}
}).error(function() {
self.interval = 30000;
}).always(function() {
self.init();
});
self.cache = [];
}, this.interval);
};
AjaxLogger.prototype.end = function() {};
// wait until jQuery is defined. Useful if you don't control the load order.
AjaxLogger.jQueryWait = function(onDone) {
if(typeof window !== 'undefined' && (window.jQuery || window.$)) {
return onDone(window.jQuery || window.$);
} else if (typeof window !== 'undefined') {
setTimeout(function() { AjaxLogger.jQueryWait(onDone); }, 200);
}
};
module.exports = AjaxLogger;
/***/ }),
/***/ "./node_modules/scratch-vm/node_modules/minilog/lib/web/localstorage.js":
/*!******************************************************************************!*\
!*** ./node_modules/scratch-vm/node_modules/minilog/lib/web/localstorage.js ***!
\******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/scratch-vm/node_modules/minilog/lib/common/transform.js"),
cache = false;
var logger = new Transform();
logger.write = function(name, level, args) {
if(typeof window == 'undefined' || typeof JSON == 'undefined' || !JSON.stringify || !JSON.parse) return;
try {
if(!cache) { cache = (window.localStorage.minilog ? JSON.parse(window.localStorage.minilog) : []); }
cache.push([ new Date().toString(), name, level, args ]);
window.localStorage.minilog = JSON.stringify(cache);
} catch(e) {}
};
module.exports = logger;
/***/ }),
/***/ "./node_modules/scratch-vm/src/dispatch/shared-dispatch.js":
/*!*****************************************************************!*\
!*** ./node_modules/scratch-vm/src/dispatch/shared-dispatch.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var log = __webpack_require__(/*! ../util/log */ "./node_modules/scratch-vm/src/util/log.js");
/**
* @typedef {object} DispatchCallMessage - a message to the dispatch system representing a service method call
* @property {*} responseId - send a response message with this response ID. See {@link DispatchResponseMessage}
* @property {string} service - the name of the service to be called
* @property {string} method - the name of the method to be called
* @property {Array|undefined} args - the arguments to be passed to the method
*/
/**
* @typedef {object} DispatchResponseMessage - a message to the dispatch system representing the results of a call
* @property {*} responseId - a copy of the response ID from the call which generated this response
* @property {*|undefined} error - if this is truthy, then it contains results from a failed call (such as an exception)
* @property {*|undefined} result - if error is not truthy, then this contains the return value of the call (if any)
*/
/**
* @typedef {DispatchCallMessage|DispatchResponseMessage} DispatchMessage
* Any message to the dispatch system.
*/
/**
* The SharedDispatch class is responsible for dispatch features shared by
* {@link CentralDispatch} and {@link WorkerDispatch}.
*/
var SharedDispatch = /*#__PURE__*/function () {
function SharedDispatch() {
_classCallCheck(this, SharedDispatch);
/**
* List of callback registrations for promises waiting for a response from a call to a service on another
* worker. A callback registration is an array of [resolve,reject] Promise functions.
* Calls to local services don't enter this list.
* @type {Array.<Function[]>}
*/
this.callbacks = [];
/**
* The next response ID to be used.
* @type {int}
*/
this.nextResponseId = 0;
}
/**
* Call a particular method on a particular service, regardless of whether that service is provided locally or on
* a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone
* algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be
* transferred to the worker, and they should not be used after this call.
* @example
* dispatcher.call('vm', 'setData', 'cat', 42);
* // this finds the worker for the 'vm' service, then on that worker calls:
* vm.setData('cat', 42);
* @param {string} service - the name of the service.
* @param {string} method - the name of the method.
* @param {*} [args] - the arguments to be copied to the method, if any.
* @returns {Promise} - a promise for the return value of the service method.
*/
_createClass(SharedDispatch, [{
key: "call",
value: function call(service, method) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return this.transferCall.apply(this, [service, method, null].concat(args));
}
/**
* Call a particular method on a particular service, regardless of whether that service is provided locally or on
* a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone
* algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be
* transferred to the worker, and they should not be used after this call.
* @example
* dispatcher.transferCall('vm', 'setData', [myArrayBuffer], 'cat', myArrayBuffer);
* // this finds the worker for the 'vm' service, transfers `myArrayBuffer` to it, then on that worker calls:
* vm.setData('cat', myArrayBuffer);
* @param {string} service - the name of the service.
* @param {string} method - the name of the method.
* @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful.
* @param {*} [args] - the arguments to be copied to the method, if any.
* @returns {Promise} - a promise for the return value of the service method.
*/
}, {
key: "transferCall",
value: function transferCall(service, method, transfer) {
try {
var _this$_getServiceProv = this._getServiceProvider(service),
provider = _this$_getServiceProv.provider,
isRemote = _this$_getServiceProv.isRemote;
if (provider) {
for (var _len2 = arguments.length, args = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
args[_key2 - 3] = arguments[_key2];
}
if (isRemote) {
return this._remoteTransferCall.apply(this, [provider, service, method, transfer].concat(args));
}
var result = provider[method].apply(provider, args);
return Promise.resolve(result);
}
return Promise.reject(new Error("Service not found: ".concat(service)));
} catch (e) {
return Promise.reject(e);
}
}
/**
* Check if a particular service lives on another worker.
* @param {string} service - the service to check.
* @returns {boolean} - true if the service is remote (calls must cross a Worker boundary), false otherwise.
* @private
*/
}, {
key: "_isRemoteService",
value: function _isRemoteService(service) {
return this._getServiceProvider(service).isRemote;
}
/**
* Like {@link call}, but force the call to be posted through a particular communication channel.
* @param {object} provider - send the call through this object's `postMessage` function.
* @param {string} service - the name of the service.
* @param {string} method - the name of the method.
* @param {*} [args] - the arguments to be copied to the method, if any.
* @returns {Promise} - a promise for the return value of the service method.
*/
}, {
key: "_remoteCall",
value: function _remoteCall(provider, service, method) {
for (var _len3 = arguments.length, args = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
args[_key3 - 3] = arguments[_key3];
}
return this._remoteTransferCall.apply(this, [provider, service, method, null].concat(args));
}
/**
* Like {@link transferCall}, but force the call to be posted through a particular communication channel.
* @param {object} provider - send the call through this object's `postMessage` function.
* @param {string} service - the name of the service.
* @param {string} method - the name of the method.
* @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful.
* @param {*} [args] - the arguments to be copied to the method, if any.
* @returns {Promise} - a promise for the return value of the service method.
*/
}, {
key: "_remoteTransferCall",
value: function _remoteTransferCall(provider, service, method, transfer) {
var _this = this;
for (var _len4 = arguments.length, args = new Array(_len4 > 4 ? _len4 - 4 : 0), _key4 = 4; _key4 < _len4; _key4++) {
args[_key4 - 4] = arguments[_key4];
}
return new Promise(function (resolve, reject) {
var responseId = _this._storeCallbacks(resolve, reject);
/** @TODO: remove this hack! this is just here so we don't try to send `util` to a worker */
if (args.length > 0 && typeof args[args.length - 1].yield === 'function') {
args.pop();
}
if (transfer) {
provider.postMessage({
service: service,
method: method,
responseId: responseId,
args: args
}, transfer);
} else {
provider.postMessage({
service: service,
method: method,
responseId: responseId,
args: args
});
}
});
}
/**
* Store callback functions pending a response message.
* @param {Function} resolve - function to call if the service method returns.
* @param {Function} reject - function to call if the service method throws.
* @returns {*} - a unique response ID for this set of callbacks. See {@link _deliverResponse}.
* @protected
*/
}, {
key: "_storeCallbacks",
value: function _storeCallbacks(resolve, reject) {
var responseId = this.nextResponseId++;
this.callbacks[responseId] = [resolve, reject];
return responseId;
}
/**
* Deliver call response from a worker. This should only be called as the result of a message from a worker.
* @param {int} responseId - the response ID of the callback set to call.
* @param {DispatchResponseMessage} message - the message containing the response value(s).
* @protected
*/
}, {
key: "_deliverResponse",
value: function _deliverResponse(responseId, message) {
try {
var _this$callbacks$respo = _slicedToArray(this.callbacks[responseId], 2),
resolve = _this$callbacks$respo[0],
reject = _this$callbacks$respo[1];
delete this.callbacks[responseId];
if (message.error) {
reject(message.error);
} else {
resolve(message.result);
}
} catch (e) {