File size: 2,519 Bytes
8086c81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
(window["webpackJsonpGUI"] = window["webpackJsonpGUI"] || []).push([["addon-entry-editor-sounds"],{

/***/ "./src/addons/addons/editor-sounds/_runtime_entry.js":
/*!***********************************************************!*\
  !*** ./src/addons/addons/editor-sounds/_runtime_entry.js ***!
  \***********************************************************/
/*! exports provided: resources */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resources", function() { return resources; });
/* harmony import */ var _userscript_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./userscript.js */ "./src/addons/addons/editor-sounds/userscript.js");
/* generated by pull.js */

const resources = {
  "userscript.js": _userscript_js__WEBPACK_IMPORTED_MODULE_0__["default"]
};

/***/ }),

/***/ "./src/addons/addons/editor-sounds/userscript.js":
/*!*******************************************************!*\
  !*** ./src/addons/addons/editor-sounds/userscript.js ***!
  \*******************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = (async function (_ref) {
  let {
    addon,
    console
  } = _ref;
  const ScratchBlocks = await addon.tab.traps.getBlockly();
  const injectCurrent = () => {
    const workspace = Blockly.getMainWorkspace();
    const pathToMedia = workspace.options.pathToMedia;
    ScratchBlocks.inject.loadSounds_(pathToMedia, workspace);
  };

  // Add sounds to the current workspace
  injectCurrent();

  // Add sounds to all future workspaces
  const originalInit = ScratchBlocks.init_;
  ScratchBlocks.init_ = function () {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    const wksp = args[0];
    wksp.options.hasSounds = true;
    return originalInit.call(this, ...args);
  };
  addon.self.addEventListener("disabled", () => {
    const workspace = Blockly.getMainWorkspace();
    const audio = workspace.getAudioManager();
    delete audio.SOUNDS_.click;
    delete audio.SOUNDS_.delete;
  });
  addon.self.addEventListener("reenabled", injectCurrent);
});

/***/ })

}]);
//# sourceMappingURL=addon-entry-editor-sounds.js.map