@tsparticles/plugin-sounds 3.0.3 → 3.2.0
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/265.min.js +2 -0
- package/265.min.js.LICENSE.txt +1 -0
- package/714.min.js +2 -0
- package/714.min.js.LICENSE.txt +1 -0
- package/browser/Options/Classes/Sounds.js +4 -0
- package/browser/Options/Classes/SoundsEvent.js +4 -3
- package/browser/Options/Classes/SoundsIcon.js +1 -0
- package/browser/Options/Classes/SoundsIcons.js +4 -0
- package/browser/SoundsInstance.js +130 -69
- package/browser/SoundsPlugin.js +37 -0
- package/browser/index.js +1 -24
- package/browser/utils.js +11 -4
- package/cjs/Options/Classes/Sounds.js +4 -0
- package/cjs/Options/Classes/SoundsEvent.js +4 -3
- package/cjs/Options/Classes/SoundsIcon.js +1 -0
- package/cjs/Options/Classes/SoundsIcons.js +4 -0
- package/cjs/SoundsInstance.js +128 -67
- package/cjs/SoundsPlugin.js +64 -0
- package/cjs/index.js +24 -24
- package/cjs/utils.js +14 -5
- package/dist_browser_SoundsInstance_js.js +30 -0
- package/dist_browser_SoundsPlugin_js.js +120 -0
- package/esm/Options/Classes/Sounds.js +4 -0
- package/esm/Options/Classes/SoundsEvent.js +4 -3
- package/esm/Options/Classes/SoundsIcon.js +1 -0
- package/esm/Options/Classes/SoundsIcons.js +4 -0
- package/esm/SoundsInstance.js +130 -69
- package/esm/SoundsPlugin.js +37 -0
- package/esm/index.js +1 -24
- package/esm/utils.js +11 -4
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.sounds.js +241 -738
- package/tsparticles.plugin.sounds.min.js +1 -1
- package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -1
- package/types/Options/Classes/Sounds.d.ts +1 -0
- package/types/Options/Classes/SoundsEvent.d.ts +0 -5
- package/types/Options/Classes/SoundsIcon.d.ts +1 -0
- package/types/Options/Classes/SoundsIcons.d.ts +1 -0
- package/types/Options/Interfaces/ISounds.d.ts +1 -0
- package/types/Options/Interfaces/ISoundsIcon.d.ts +1 -0
- package/types/Options/Interfaces/ISoundsIcons.d.ts +1 -0
- package/types/SoundsInstance.d.ts +6 -0
- package/types/SoundsPlugin.d.ts +11 -0
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +5 -5
- package/types/utils.d.ts +2 -0
- package/umd/Options/Classes/Sounds.js +4 -0
- package/umd/Options/Classes/SoundsEvent.js +4 -3
- package/umd/Options/Classes/SoundsIcon.js +1 -0
- package/umd/Options/Classes/SoundsIcons.js +4 -0
- package/umd/SoundsInstance.js +128 -67
- package/umd/SoundsPlugin.js +75 -0
- package/umd/index.js +26 -25
- package/umd/utils.js +14 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
(function (factory) {
|
|
25
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
26
|
+
var v = factory(require, exports);
|
|
27
|
+
if (v !== undefined) module.exports = v;
|
|
28
|
+
}
|
|
29
|
+
else if (typeof define === "function" && define.amd) {
|
|
30
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Sounds.js", "./utils.js"], factory);
|
|
31
|
+
}
|
|
32
|
+
})(function (require, exports) {
|
|
33
|
+
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SoundsPlugin = void 0;
|
|
37
|
+
const engine_1 = require("@tsparticles/engine");
|
|
38
|
+
const Sounds_js_1 = require("./Options/Classes/Sounds.js");
|
|
39
|
+
const utils_js_1 = require("./utils.js");
|
|
40
|
+
const generalFirstClickHandler = () => {
|
|
41
|
+
removeEventListener(engine_1.mouseDownEvent, generalFirstClickHandler);
|
|
42
|
+
removeEventListener(engine_1.touchStartEvent, generalFirstClickHandler);
|
|
43
|
+
(0, utils_js_1.unmuteWindow)();
|
|
44
|
+
};
|
|
45
|
+
class SoundsPlugin {
|
|
46
|
+
constructor(engine) {
|
|
47
|
+
this.id = "sounds";
|
|
48
|
+
this._engine = engine;
|
|
49
|
+
const listenerOptions = {
|
|
50
|
+
capture: true,
|
|
51
|
+
once: true,
|
|
52
|
+
};
|
|
53
|
+
addEventListener(engine_1.mouseDownEvent, generalFirstClickHandler, listenerOptions);
|
|
54
|
+
addEventListener(engine_1.touchStartEvent, generalFirstClickHandler, listenerOptions);
|
|
55
|
+
}
|
|
56
|
+
async getPlugin(container) {
|
|
57
|
+
const { SoundsInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SoundsInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./SoundsInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
58
|
+
return new SoundsInstance(container, this._engine);
|
|
59
|
+
}
|
|
60
|
+
loadOptions(options, source) {
|
|
61
|
+
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let soundsOptions = options.sounds;
|
|
65
|
+
if (soundsOptions?.load === undefined) {
|
|
66
|
+
options.sounds = soundsOptions = new Sounds_js_1.Sounds();
|
|
67
|
+
}
|
|
68
|
+
soundsOptions.load(source?.sounds);
|
|
69
|
+
}
|
|
70
|
+
needsPlugin(options) {
|
|
71
|
+
return options?.sounds?.enable ?? false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.SoundsPlugin = SoundsPlugin;
|
|
75
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
1
24
|
(function (factory) {
|
|
2
25
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
26
|
var v = factory(require, exports);
|
|
4
27
|
if (v !== undefined) module.exports = v;
|
|
5
28
|
}
|
|
6
29
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"
|
|
30
|
+
define(["require", "exports"], factory);
|
|
8
31
|
}
|
|
9
32
|
})(function (require, exports) {
|
|
10
33
|
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
36
|
exports.loadSoundsPlugin = void 0;
|
|
13
|
-
const Sounds_js_1 = require("./Options/Classes/Sounds.js");
|
|
14
|
-
const SoundsInstance_js_1 = require("./SoundsInstance.js");
|
|
15
|
-
class SoundsPlugin {
|
|
16
|
-
constructor(engine) {
|
|
17
|
-
this.id = "sounds";
|
|
18
|
-
this._engine = engine;
|
|
19
|
-
}
|
|
20
|
-
getPlugin(container) {
|
|
21
|
-
return new SoundsInstance_js_1.SoundsInstance(container, this._engine);
|
|
22
|
-
}
|
|
23
|
-
loadOptions(options, source) {
|
|
24
|
-
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let soundsOptions = options.sounds;
|
|
28
|
-
if (soundsOptions?.load === undefined) {
|
|
29
|
-
options.sounds = soundsOptions = new Sounds_js_1.Sounds();
|
|
30
|
-
}
|
|
31
|
-
soundsOptions.load(source?.sounds);
|
|
32
|
-
}
|
|
33
|
-
needsPlugin(options) {
|
|
34
|
-
return options?.sounds?.enable ?? false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
37
|
async function loadSoundsPlugin(engine, refresh = true) {
|
|
38
|
+
const { SoundsPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SoundsPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./SoundsPlugin.js"], resolve_1, reject_1); }).then(__importStar));
|
|
38
39
|
await engine.addPlugin(new SoundsPlugin(engine), refresh);
|
|
39
40
|
}
|
|
40
41
|
exports.loadSoundsPlugin = loadSoundsPlugin;
|
package/umd/utils.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getNoteFrequency = void 0;
|
|
12
|
+
exports.unmuteWindow = exports.isWindowMuted = exports.getNoteFrequency = void 0;
|
|
13
13
|
const notes = new Map();
|
|
14
14
|
notes.set("C", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);
|
|
15
15
|
notes.set("Db", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);
|
|
@@ -25,15 +25,24 @@
|
|
|
25
25
|
notes.set("B", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);
|
|
26
26
|
notes.set("pause", [0]);
|
|
27
27
|
function getNoteFrequency(note) {
|
|
28
|
-
const regex = /(([A-G]b?)(\d))|pause/i, result = regex.exec(note);
|
|
29
|
-
if (!result
|
|
28
|
+
const regex = /(([A-G]b?)(\d))|pause/i, result = regex.exec(note), groupKey = 2, defaultMatchKey = 0, innerGroupKey = 3;
|
|
29
|
+
if (!result?.length) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const noteKey = result[
|
|
32
|
+
const noteKey = result[groupKey] || result[defaultMatchKey], noteItem = notes.get(noteKey);
|
|
33
33
|
if (!noteItem) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
return noteItem[parseInt(result[
|
|
36
|
+
return noteItem[parseInt(result[innerGroupKey] || "0")];
|
|
37
37
|
}
|
|
38
38
|
exports.getNoteFrequency = getNoteFrequency;
|
|
39
|
+
let muted = true;
|
|
40
|
+
const isWindowMuted = () => {
|
|
41
|
+
return muted;
|
|
42
|
+
};
|
|
43
|
+
exports.isWindowMuted = isWindowMuted;
|
|
44
|
+
const unmuteWindow = () => {
|
|
45
|
+
muted = false;
|
|
46
|
+
};
|
|
47
|
+
exports.unmuteWindow = unmuteWindow;
|
|
39
48
|
});
|