@tsparticles/plugin-sounds 3.0.0-alpha.1 → 3.0.0-beta.1

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 (61) hide show
  1. package/README.md +15 -11
  2. package/browser/Options/Classes/Sounds.js +3 -3
  3. package/browser/Options/Classes/SoundsAudio.js +2 -1
  4. package/browser/Options/Classes/SoundsEvent.js +7 -6
  5. package/browser/Options/Classes/SoundsIcons.js +1 -1
  6. package/browser/Options/Classes/SoundsMelody.js +1 -1
  7. package/browser/Options/Classes/SoundsVolume.js +2 -1
  8. package/browser/SoundsInstance.js +301 -280
  9. package/browser/index.js +8 -10
  10. package/browser/package.json +1 -0
  11. package/browser/utils.js +0 -1
  12. package/cjs/Options/Classes/Sounds.js +6 -6
  13. package/cjs/Options/Classes/SoundsAudio.js +2 -1
  14. package/cjs/Options/Classes/SoundsEvent.js +11 -10
  15. package/cjs/Options/Classes/SoundsIcons.js +5 -5
  16. package/cjs/Options/Classes/SoundsMelody.js +2 -2
  17. package/cjs/Options/Classes/SoundsVolume.js +2 -1
  18. package/cjs/SoundsInstance.js +285 -283
  19. package/cjs/index.js +10 -23
  20. package/cjs/package.json +1 -0
  21. package/cjs/utils.js +0 -1
  22. package/esm/Options/Classes/Sounds.js +3 -3
  23. package/esm/Options/Classes/SoundsAudio.js +2 -1
  24. package/esm/Options/Classes/SoundsEvent.js +7 -6
  25. package/esm/Options/Classes/SoundsIcons.js +1 -1
  26. package/esm/Options/Classes/SoundsMelody.js +1 -1
  27. package/esm/Options/Classes/SoundsVolume.js +2 -1
  28. package/esm/SoundsInstance.js +301 -280
  29. package/esm/index.js +8 -10
  30. package/esm/package.json +1 -0
  31. package/esm/utils.js +0 -1
  32. package/package.json +19 -6
  33. package/report.html +4 -4
  34. package/tsparticles.plugin.sounds.js +343 -305
  35. package/tsparticles.plugin.sounds.min.js +1 -1
  36. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -8
  37. package/types/Options/Classes/Sounds.d.ts +4 -4
  38. package/types/Options/Classes/SoundsAudio.d.ts +2 -2
  39. package/types/Options/Classes/SoundsEvent.d.ts +6 -6
  40. package/types/Options/Classes/SoundsIcon.d.ts +1 -1
  41. package/types/Options/Classes/SoundsIcons.d.ts +2 -2
  42. package/types/Options/Classes/SoundsMelody.d.ts +2 -2
  43. package/types/Options/Classes/SoundsNote.d.ts +1 -1
  44. package/types/Options/Classes/SoundsVolume.d.ts +2 -2
  45. package/types/Options/Interfaces/ISounds.d.ts +3 -3
  46. package/types/Options/Interfaces/ISoundsEvent.d.ts +4 -4
  47. package/types/Options/Interfaces/ISoundsIcons.d.ts +1 -1
  48. package/types/Options/Interfaces/ISoundsMelody.d.ts +1 -1
  49. package/types/SoundsInstance.d.ts +16 -16
  50. package/types/enums.d.ts +4 -0
  51. package/types/index.d.ts +1 -1
  52. package/types/types.d.ts +18 -2
  53. package/umd/Options/Classes/Sounds.js +7 -7
  54. package/umd/Options/Classes/SoundsAudio.js +3 -2
  55. package/umd/Options/Classes/SoundsEvent.js +12 -11
  56. package/umd/Options/Classes/SoundsIcons.js +6 -6
  57. package/umd/Options/Classes/SoundsMelody.js +3 -3
  58. package/umd/Options/Classes/SoundsVolume.js +3 -2
  59. package/umd/SoundsInstance.js +302 -281
  60. package/umd/index.js +11 -13
  61. 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,6 +1,6 @@
1
- import { SoundsEvent } from "./SoundsEvent";
2
- import { SoundsIcons } from "./SoundsIcons";
3
- import { SoundsVolume } from "./SoundsVolume";
1
+ import { SoundsEvent } from "./SoundsEvent.js";
2
+ import { SoundsIcons } from "./SoundsIcons.js";
3
+ import { SoundsVolume } from "./SoundsVolume.js";
4
4
  export class Sounds {
5
5
  constructor() {
6
6
  this.enable = false;
@@ -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,6 +1,7 @@
1
- import { SoundsAudio } from "./SoundsAudio";
2
- import { SoundsMelody } from "./SoundsMelody";
3
- import { SoundsNote } from "./SoundsNote";
1
+ import { isArray, isFunction, isString, } from "@tsparticles/engine";
2
+ import { SoundsAudio } from "./SoundsAudio.js";
3
+ import { SoundsMelody } from "./SoundsMelody.js";
4
+ import { SoundsNote } from "./SoundsNote.js";
4
5
  export class SoundsEvent {
5
6
  constructor() {
6
7
  this.event = [];
@@ -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,4 +1,4 @@
1
- import { SoundsIcon } from "./SoundsIcon";
1
+ import { SoundsIcon } from "./SoundsIcon.js";
2
2
  export class SoundsIcons {
3
3
  constructor() {
4
4
  this.mute = new SoundsIcon();
@@ -1,4 +1,4 @@
1
- import { SoundsNote } from "./SoundsNote";
1
+ import { SoundsNote } from "./SoundsNote.js";
2
2
  export class SoundsMelody {
3
3
  constructor() {
4
4
  this.loop = false;
@@ -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
  }