angular-fireworks 4.3.2 → 4.4.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.
@@ -6,10 +6,12 @@ import { fireworks } from '@tsparticles/fireworks';
6
6
  class NgxFireworksComponent {
7
7
  #fireworksInstance;
8
8
  #destroyed;
9
+ #loadId;
9
10
  constructor(platformId) {
10
11
  this.platformId = platformId;
11
12
  this.id = "tsparticles";
12
13
  this.#destroyed = false;
14
+ this.#loadId = 0;
13
15
  }
14
16
  ngAfterViewInit() {
15
17
  if (isPlatformServer(this.platformId)) {
@@ -21,7 +23,7 @@ class NgxFireworksComponent {
21
23
  if (isPlatformServer(this.platformId)) {
22
24
  return;
23
25
  }
24
- if (this.#destroyed) {
26
+ if (this.#destroyed || !this.#fireworksInstance) {
25
27
  return;
26
28
  }
27
29
  if (changes["options"] || changes["id"]) {
@@ -30,19 +32,26 @@ class NgxFireworksComponent {
30
32
  }
31
33
  ngOnDestroy() {
32
34
  this.#destroyed = true;
35
+ ++this.#loadId;
33
36
  this.#fireworksInstance?.destroy();
34
37
  this.#fireworksInstance = undefined;
35
38
  }
36
39
  async #startFireworks() {
37
40
  this.#fireworksInstance?.destroy();
38
41
  this.#fireworksInstance = undefined;
39
- this.#fireworksInstance = await fireworks(this.id, this.options);
42
+ const currentLoadId = ++this.#loadId;
43
+ const instance = await fireworks(this.id, this.options);
44
+ if (currentLoadId !== this.#loadId) {
45
+ instance?.destroy();
46
+ return;
47
+ }
48
+ this.#fireworksInstance = instance;
40
49
  this.#fireworksInstance?.play();
41
50
  }
42
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksComponent, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
43
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.4", type: NgxFireworksComponent, isStandalone: false, selector: "ngx-fireworks", inputs: { options: "options", id: "id" }, usesOnChanges: true, ngImport: i0, template: ` <div [id]="id"></div>`, isInline: true }); }
51
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksComponent, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
52
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.1", type: NgxFireworksComponent, isStandalone: false, selector: "ngx-fireworks", inputs: { options: "options", id: "id" }, usesOnChanges: true, ngImport: i0, template: ` <div [id]="id"></div>`, isInline: true }); }
44
53
  }
45
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksComponent, decorators: [{
54
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksComponent, decorators: [{
46
55
  type: Component,
47
56
  args: [{ selector: "ngx-fireworks", standalone: false, template: ` <div [id]="id"></div>` }]
48
57
  }], ctorParameters: () => [{ type: undefined, decorators: [{
@@ -59,11 +68,11 @@ class NgxFireworksModule {
59
68
  /* Register fireworks plugins before tsParticles.init() is called */
60
69
  void fireworks.init();
61
70
  }
62
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksModule, declarations: [NgxFireworksComponent], exports: [NgxFireworksComponent] }); }
64
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksModule }); }
71
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
72
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksModule, declarations: [NgxFireworksComponent], exports: [NgxFireworksComponent] }); }
73
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksModule }); }
65
74
  }
66
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxFireworksModule, decorators: [{
75
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxFireworksModule, decorators: [{
67
76
  type: NgModule,
68
77
  args: [{
69
78
  declarations: [NgxFireworksComponent],
@@ -1 +1 @@
1
- {"version":3,"file":"angular-fireworks.mjs","sources":["../../../projects/ng-fireworks/src/lib/ng-fireworks.component.ts","../../../projects/ng-fireworks/src/lib/ng-fireworks.module.ts","../../../projects/ng-fireworks/src/public-api.ts","../../../projects/ng-fireworks/src/angular-fireworks.ts"],"sourcesContent":["import { isPlatformServer } from \"@angular/common\";\nimport {\n AfterViewInit,\n Component,\n Inject,\n Input,\n OnChanges,\n OnDestroy,\n PLATFORM_ID,\n SimpleChanges,\n} from \"@angular/core\";\nimport { FireworkOptions, fireworks } from \"@tsparticles/fireworks\";\n\n@Component({\n selector: \"ngx-fireworks\",\n standalone: false,\n template: ` <div [id]=\"id\"></div>`,\n styles: [],\n})\nexport class NgxFireworksComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: FireworkOptions;\n @Input() id = \"tsparticles\";\n\n #fireworksInstance?: Awaited<ReturnType<typeof fireworks>>;\n #destroyed = false;\n\n constructor(@Inject(PLATFORM_ID) protected platformId: string) {}\n\n public ngAfterViewInit(): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n void this.#startFireworks();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n if (this.#destroyed) {\n return;\n }\n\n if (changes[\"options\"] || changes[\"id\"]) {\n void this.#startFireworks();\n }\n }\n\n public ngOnDestroy(): void {\n this.#destroyed = true;\n\n this.#fireworksInstance?.destroy();\n\n this.#fireworksInstance = undefined;\n }\n\n async #startFireworks(): Promise<void> {\n this.#fireworksInstance?.destroy();\n\n this.#fireworksInstance = undefined;\n\n this.#fireworksInstance = await fireworks(this.id, this.options);\n\n this.#fireworksInstance?.play();\n }\n}\n","import { NgModule } from \"@angular/core\";\nimport { fireworks } from \"@tsparticles/fireworks\";\nimport { NgxFireworksComponent } from \"./ng-fireworks.component\";\n\n@NgModule({\n declarations: [NgxFireworksComponent],\n imports: [],\n exports: [NgxFireworksComponent],\n})\nexport class NgxFireworksModule {\n constructor() {\n /* Register fireworks plugins before tsParticles.init() is called */\n void (fireworks as unknown as { init: () => Promise<void> }).init();\n }\n}\n","/*\n * Public API Surface of ng-fireworks\n */\n\nexport * from \"./lib/ng-fireworks.component\";\nexport * from \"./lib/ng-fireworks.module\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAmBa,qBAAqB,CAAA;AAIhC,IAAA,kBAAkB;AAClB,IAAA,UAAU;AAEV,IAAA,WAAA,CAA2C,UAAkB,EAAA;QAAlB,IAAA,CAAA,UAAU,GAAV,UAAU;QAL5C,IAAA,CAAA,EAAE,GAAG,aAAa;QAG3B,IAAA,CAAA,UAAU,GAAG,KAAK;IAE8C;IAEzD,eAAe,GAAA;AACpB,QAAA,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACrC;QACF;AAEA,QAAA,KAAK,IAAI,CAAC,eAAe,EAAE;IAC7B;AAEO,IAAA,WAAW,CAAC,OAAsB,EAAA;AACvC,QAAA,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACrC;QACF;AAEA,QAAA,IAAI,IAAI,CAAC,UAAU,EAAE;YAC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;sBACA;;;MCZU,kBAAkB,CAAA;AAC7B,IAAA,WAAA,GAAA;;AAEE,QAAA,KAAM,SAAsD,CAAC,IAAI,EAAE;IACrE;8GAJW,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAlB,kBAAkB,EAAA,YAAA,EAAA,CAJd,qBAAqB,CAAA,EAAA,OAAA,EAAA,CAE1B,qBAAqB,CAAA,EAAA,CAAA,CAAA;+GAEpB,kBAAkB,EAAA,CAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,YAAY,EAAE,CAAC,qBAAqB,CAAC;AACrC,oBAAA,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC,qBAAqB,CAAC;AACjC,iBAAA;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"angular-fireworks.mjs","sources":["../../../projects/ng-fireworks/src/lib/ng-fireworks.component.ts","../../../projects/ng-fireworks/src/lib/ng-fireworks.module.ts","../../../projects/ng-fireworks/src/public-api.ts","../../../projects/ng-fireworks/src/angular-fireworks.ts"],"sourcesContent":["import { isPlatformServer } from \"@angular/common\";\nimport {\n AfterViewInit,\n Component,\n Inject,\n Input,\n OnChanges,\n OnDestroy,\n PLATFORM_ID,\n SimpleChanges,\n} from \"@angular/core\";\nimport { FireworkOptions, fireworks } from \"@tsparticles/fireworks\";\n\n@Component({\n selector: \"ngx-fireworks\",\n standalone: false,\n template: ` <div [id]=\"id\"></div>`,\n styles: [],\n})\nexport class NgxFireworksComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: FireworkOptions;\n @Input() id = \"tsparticles\";\n\n #fireworksInstance?: Awaited<ReturnType<typeof fireworks>>;\n #destroyed = false;\n #loadId = 0;\n\n constructor(@Inject(PLATFORM_ID) protected platformId: string) {}\n\n public ngAfterViewInit(): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n void this.#startFireworks();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n if (this.#destroyed || !this.#fireworksInstance) {\n return;\n }\n\n if (changes[\"options\"] || changes[\"id\"]) {\n void this.#startFireworks();\n }\n }\n\n public ngOnDestroy(): void {\n this.#destroyed = true;\n ++this.#loadId;\n\n this.#fireworksInstance?.destroy();\n\n this.#fireworksInstance = undefined;\n }\n\n async #startFireworks(): Promise<void> {\n this.#fireworksInstance?.destroy();\n this.#fireworksInstance = undefined;\n\n const currentLoadId = ++this.#loadId;\n const instance = await fireworks(this.id, this.options);\n\n if (currentLoadId !== this.#loadId) {\n instance?.destroy();\n return;\n }\n\n this.#fireworksInstance = instance;\n this.#fireworksInstance?.play();\n }\n}\n","import { NgModule } from \"@angular/core\";\nimport { fireworks } from \"@tsparticles/fireworks\";\nimport { NgxFireworksComponent } from \"./ng-fireworks.component\";\n\n@NgModule({\n declarations: [NgxFireworksComponent],\n imports: [],\n exports: [NgxFireworksComponent],\n})\nexport class NgxFireworksModule {\n constructor() {\n /* Register fireworks plugins before tsParticles.init() is called */\n void (fireworks as unknown as { init: () => Promise<void> }).init();\n }\n}\n","/*\n * Public API Surface of ng-fireworks\n */\n\nexport * from \"./lib/ng-fireworks.component\";\nexport * from \"./lib/ng-fireworks.module\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAmBa,qBAAqB,CAAA;AAIhC,IAAA,kBAAkB;AAClB,IAAA,UAAU;AACV,IAAA,OAAO;AAEP,IAAA,WAAA,CAA2C,UAAkB,EAAA;QAAlB,IAAA,CAAA,UAAU,GAAV,UAAU;QAN5C,IAAA,CAAA,EAAE,GAAG,aAAa;QAG3B,IAAA,CAAA,UAAU,GAAG,KAAK;QAClB,IAAA,CAAA,OAAO,GAAG,CAAC;IAEqD;IAEzD,eA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
4
4
  "description": "Official tsParticles Angular Confetti Component - Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for Web Components, React, Vue.js (2.x and 3.x), Svelte, jQuery, Preact, Riot.js, Solid.js, Inferno.",
5
5
  "homepage": "https://confetti.js.org",
6
6
  "repository": {
@@ -85,8 +85,8 @@
85
85
  "@angular/common": ">=12.0.0",
86
86
  "@angular/core": ">=12.0.0",
87
87
  "rxjs": ">=7.0.0",
88
- "@tsparticles/fireworks": "^4.3.2",
89
- "@tsparticles/engine": "^4.3.2"
88
+ "@tsparticles/fireworks": "^4.4.0",
89
+ "@tsparticles/engine": "^4.4.0"
90
90
  },
91
91
  "dependencies": {
92
92
  "tslib": "^2.8.1"
package/.npmignore DELETED
@@ -1,2 +0,0 @@
1
- # Nested package.json's are only needed for development.
2
- **/package.json