@tsparticles/plugin-sounds 3.0.0-alpha.0 → 3.0.0-beta.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/README.md +15 -11
- package/browser/Options/Classes/SoundsAudio.js +2 -1
- package/browser/Options/Classes/SoundsEvent.js +4 -3
- package/browser/Options/Classes/SoundsVolume.js +2 -1
- package/browser/SoundsInstance.js +300 -279
- package/browser/index.js +6 -8
- package/browser/utils.js +0 -1
- package/cjs/Options/Classes/SoundsAudio.js +2 -1
- package/cjs/Options/Classes/SoundsEvent.js +4 -3
- package/cjs/Options/Classes/SoundsVolume.js +2 -1
- package/cjs/SoundsInstance.js +283 -281
- package/cjs/index.js +6 -19
- package/cjs/utils.js +0 -1
- package/esm/Options/Classes/SoundsAudio.js +2 -1
- package/esm/Options/Classes/SoundsEvent.js +4 -3
- package/esm/Options/Classes/SoundsVolume.js +2 -1
- package/esm/SoundsInstance.js +300 -279
- package/esm/index.js +6 -8
- package/esm/utils.js +0 -1
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.plugin.sounds.js +343 -305
- package/tsparticles.plugin.sounds.min.js +1 -1
- package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/SoundsAudio.d.ts +1 -1
- package/types/Options/Classes/SoundsEvent.d.ts +1 -1
- package/types/Options/Classes/SoundsVolume.d.ts +1 -1
- package/types/SoundsInstance.d.ts +15 -15
- package/types/enums.d.ts +4 -0
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +16 -0
- package/umd/Options/Classes/SoundsAudio.js +3 -2
- package/umd/Options/Classes/SoundsEvent.js +5 -4
- package/umd/Options/Classes/SoundsVolume.js +3 -2
- package/umd/SoundsInstance.js +301 -280
- package/umd/index.js +6 -8
- package/umd/utils.js +0 -1
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Sounds Plugin
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-sounds)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-sounds)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-sounds) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) plugin for particles sounds effect.
|
|
10
10
|
|
|
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the plugin like thi
|
|
|
42
42
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
|
-
$ npm install tsparticles
|
|
45
|
+
$ npm install @tsparticles/plugin-sounds
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
or
|
|
49
49
|
|
|
50
50
|
```shell
|
|
51
|
-
$ yarn add tsparticles
|
|
51
|
+
$ yarn add @tsparticles/plugin-sounds
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Then you need to import it in the app, like this:
|
|
55
55
|
|
|
56
56
|
```javascript
|
|
57
|
-
const { tsParticles } = require("tsparticles
|
|
58
|
-
const { loadSoundsPlugin } = require("tsparticles
|
|
57
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
58
|
+
const { loadSoundsPlugin } = require("@tsparticles/plugin-sounds");
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
(async () => {
|
|
61
|
+
await loadSoundsPlugin(tsParticles);
|
|
62
|
+
})();
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
or
|
|
64
66
|
|
|
65
67
|
```javascript
|
|
66
|
-
import { tsParticles } from "tsparticles
|
|
67
|
-
import { loadSoundsPlugin } from "tsparticles
|
|
68
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
69
|
+
import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
(async () => {
|
|
72
|
+
await loadSoundsPlugin(tsParticles);
|
|
73
|
+
})();
|
|
70
74
|
```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObject } from "@tsparticles/engine";
|
|
1
2
|
export class SoundsAudio {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.loop = false;
|
|
@@ -7,7 +8,7 @@ export class SoundsAudio {
|
|
|
7
8
|
if (data === undefined) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
if (
|
|
11
|
+
if (isObject(data)) {
|
|
11
12
|
if (data.loop !== undefined) {
|
|
12
13
|
this.loop = data.loop;
|
|
13
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArray, isFunction, isString, } from "@tsparticles/engine";
|
|
1
2
|
import { SoundsAudio } from "./SoundsAudio";
|
|
2
3
|
import { SoundsMelody } from "./SoundsMelody";
|
|
3
4
|
import { SoundsNote } from "./SoundsNote";
|
|
@@ -14,7 +15,7 @@ export class SoundsEvent {
|
|
|
14
15
|
this.event = data.event;
|
|
15
16
|
}
|
|
16
17
|
if (data.audio !== undefined) {
|
|
17
|
-
if (data.audio
|
|
18
|
+
if (isArray(data.audio)) {
|
|
18
19
|
this.audio = data.audio.map((s) => {
|
|
19
20
|
const tmp = new SoundsAudio();
|
|
20
21
|
tmp.load(s);
|
|
@@ -41,8 +42,8 @@ export class SoundsEvent {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
if (data.filter !== undefined) {
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
45
|
+
if (isString(data.filter)) {
|
|
46
|
+
if (isFunction(window[data.filter])) {
|
|
46
47
|
this.filter = window[data.filter];
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObject } from "@tsparticles/engine";
|
|
1
2
|
export class SoundsVolume {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.value = 100;
|
|
@@ -9,7 +10,7 @@ export class SoundsVolume {
|
|
|
9
10
|
if (data === undefined) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
|
-
if (
|
|
13
|
+
if (isObject(data)) {
|
|
13
14
|
if (data.max !== undefined) {
|
|
14
15
|
this.max = data.max;
|
|
15
16
|
}
|