@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.
Files changed (37) hide show
  1. package/README.md +15 -11
  2. package/browser/Options/Classes/SoundsAudio.js +2 -1
  3. package/browser/Options/Classes/SoundsEvent.js +4 -3
  4. package/browser/Options/Classes/SoundsVolume.js +2 -1
  5. package/browser/SoundsInstance.js +300 -279
  6. package/browser/index.js +6 -8
  7. package/browser/utils.js +0 -1
  8. package/cjs/Options/Classes/SoundsAudio.js +2 -1
  9. package/cjs/Options/Classes/SoundsEvent.js +4 -3
  10. package/cjs/Options/Classes/SoundsVolume.js +2 -1
  11. package/cjs/SoundsInstance.js +283 -281
  12. package/cjs/index.js +6 -19
  13. package/cjs/utils.js +0 -1
  14. package/esm/Options/Classes/SoundsAudio.js +2 -1
  15. package/esm/Options/Classes/SoundsEvent.js +4 -3
  16. package/esm/Options/Classes/SoundsVolume.js +2 -1
  17. package/esm/SoundsInstance.js +300 -279
  18. package/esm/index.js +6 -8
  19. package/esm/utils.js +0 -1
  20. package/package.json +6 -5
  21. package/report.html +4 -4
  22. package/tsparticles.plugin.sounds.js +343 -305
  23. package/tsparticles.plugin.sounds.min.js +1 -1
  24. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -8
  25. package/types/Options/Classes/SoundsAudio.d.ts +1 -1
  26. package/types/Options/Classes/SoundsEvent.d.ts +1 -1
  27. package/types/Options/Classes/SoundsVolume.d.ts +1 -1
  28. package/types/SoundsInstance.d.ts +15 -15
  29. package/types/enums.d.ts +4 -0
  30. package/types/index.d.ts +1 -1
  31. package/types/types.d.ts +16 -0
  32. package/umd/Options/Classes/SoundsAudio.js +3 -2
  33. package/umd/Options/Classes/SoundsEvent.js +5 -4
  34. package/umd/Options/Classes/SoundsVolume.js +3 -2
  35. package/umd/SoundsInstance.js +301 -280
  36. package/umd/index.js +6 -8
  37. package/umd/utils.js +0 -1
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles Sounds Plugin
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-plugin-sounds/badge)](https://www.jsdelivr.com/package/npm/tsparticles-plugin-sounds)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-plugin-sounds.svg)](https://www.npmjs.com/package/tsparticles-plugin-sounds)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-plugin-sounds)](https://www.npmjs.com/package/tsparticles-plugin-sounds) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-sounds/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-sounds)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-sounds.svg)](https://www.npmjs.com/package/@tsparticles/plugin-sounds)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-sounds)](https://www.npmjs.com/package/@tsparticles/plugin-sounds) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](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-plugin-sounds
45
+ $ npm install @tsparticles/plugin-sounds
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-plugin-sounds
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-engine");
58
- const { loadSoundsPlugin } = require("tsparticles-plugin-sounds");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadSoundsPlugin } = require("@tsparticles/plugin-sounds");
59
59
 
60
- loadSoundsPlugin(tsParticles); // awaitable
60
+ (async () => {
61
+ await loadSoundsPlugin(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadSoundsPlugin } from "tsparticles-plugin-sounds";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
68
70
 
69
- loadSoundsPlugin(tsParticles); // awaitable
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 (typeof data === "object") {
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 instanceof Array) {
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 (typeof data.filter === "string") {
45
- if (typeof window[data.filter] === "function") {
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 (typeof data === "object") {
13
+ if (isObject(data)) {
13
14
  if (data.max !== undefined) {
14
15
  this.max = data.max;
15
16
  }