@tsparticles/angular 4.4.0 → 4.5.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.
@@ -1,154 +1,201 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, PLATFORM_ID, Output, Input, Inject, Component, NgModule } from '@angular/core';
3
- import { isPlatformServer } from '@angular/common';
4
- import { tsParticles } from '@tsparticles/engine';
5
-
1
+ import * as i0 from "@angular/core";
2
+ import { Component, EventEmitter, Inject, Injectable, Input, NgModule, Output, PLATFORM_ID } from "@angular/core";
3
+ import { isPlatformServer } from "@angular/common";
4
+ import { tsParticles } from "@tsparticles/engine";
6
5
  let initialized = false;
7
6
  let initPromise;
8
7
  let initCallback;
9
- class NgParticlesService {
10
- get loaded() {
11
- return initialized;
12
- }
13
- assertInitialized() {
14
- if (!initialized) {
15
- throw new Error("NgParticlesService.init(...) must be called once before rendering ngx-particles components.");
16
- }
17
- }
18
- async init(particlesInit) {
19
- if (initialized) {
20
- return;
21
- }
22
- if (initPromise) {
23
- if (initCallback !== particlesInit) {
24
- throw new Error("NgParticlesService init callback must be stable across the app lifecycle.");
25
- }
26
- await initPromise;
27
- return;
28
- }
29
- initCallback = particlesInit;
30
- initPromise = (async () => {
31
- if (particlesInit) {
32
- await particlesInit(tsParticles);
33
- }
34
- await tsParticles.init();
35
- initialized = true;
36
- })().catch((error) => {
37
- initPromise = undefined;
38
- initCallback = undefined;
39
- initialized = false;
40
- throw error;
41
- });
42
- await initPromise;
43
- }
44
- async waitForInitialization() {
45
- await (initPromise ?? Promise.resolve());
46
- }
47
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgParticlesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
48
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgParticlesService, providedIn: "root" });
49
- }
50
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgParticlesService, decorators: [{
51
- type: Injectable,
52
- args: [{
53
- providedIn: "root",
54
- }]
55
- }] });
56
-
57
- class NgxParticlesComponent {
58
- platformId;
59
- options;
60
- url;
61
- id = "tsparticles";
62
- theme;
63
- particlesLoaded = new EventEmitter();
64
- #container;
65
- #loadingPromise;
66
- #particlesService;
67
- constructor(platformId, particlesService) {
68
- this.platformId = platformId;
69
- this.#particlesService = particlesService;
70
- }
71
- ngAfterViewInit() {
72
- if (isPlatformServer(this.platformId)) {
73
- return;
74
- }
75
- this.#loadingPromise = this.#loadParticles();
76
- }
77
- ngOnChanges(changes) {
78
- if (isPlatformServer(this.platformId)) {
79
- return;
80
- }
81
- if (!this.#container) {
82
- return;
83
- }
84
- if (changes["id"] || changes["options"] || changes["url"]) {
85
- void this.#loadParticles();
86
- }
87
- if (changes["theme"]) {
88
- this.#container.loadTheme?.(changes["theme"].currentValue);
89
- }
90
- }
91
- ngOnDestroy() {
92
- this.#container?.destroy();
93
- this.#loadingPromise = undefined;
94
- }
95
- async #loadParticles() {
96
- await this.#particlesService.waitForInitialization();
97
- this.#particlesService.assertInitialized();
98
- this.#container?.destroy();
99
- const container = await tsParticles.load({ id: this.id, options: this.options, url: this.url });
100
- this.#container = container;
101
- if (container && this.theme) {
102
- container.loadTheme?.(this.theme);
103
- }
104
- this.particlesLoaded.emit(container);
105
- }
106
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesComponent, deps: [{ token: PLATFORM_ID }, { token: NgParticlesService }], target: i0.ɵɵFactoryTarget.Component });
107
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.1", type: NgxParticlesComponent, isStandalone: false, selector: "ngx-particles", inputs: { options: "options", url: "url", id: "id", theme: "theme" }, outputs: { particlesLoaded: "particlesLoaded" }, usesOnChanges: true, ngImport: i0, template: '<div [id]="id"></div>', isInline: true });
108
- }
109
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesComponent, decorators: [{
110
- type: Component,
111
- args: [{
112
- selector: "ngx-particles",
113
- standalone: false,
114
- template: '<div [id]="id"></div>',
115
- }]
116
- }], ctorParameters: () => [{ type: undefined, decorators: [{
117
- type: Inject,
118
- args: [PLATFORM_ID]
119
- }] }, { type: NgParticlesService }], propDecorators: { options: [{
120
- type: Input
121
- }], url: [{
122
- type: Input
123
- }], id: [{
124
- type: Input
125
- }], theme: [{
126
- type: Input
127
- }], particlesLoaded: [{
128
- type: Output
129
- }] } });
130
-
131
- class NgxParticlesModule {
132
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
133
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesModule, declarations: [NgxParticlesComponent], exports: [NgxParticlesComponent] });
134
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesModule, providers: [NgParticlesService] });
135
- }
136
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgxParticlesModule, decorators: [{
137
- type: NgModule,
138
- args: [{
139
- declarations: [NgxParticlesComponent],
140
- exports: [NgxParticlesComponent],
141
- providers: [NgParticlesService],
142
- }]
143
- }] });
144
-
145
- /*
146
- * Public API Surface of ng-particles
147
- */
148
-
149
- /**
150
- * Generated bundle index. Do not edit.
151
- */
152
-
8
+ var NgParticlesService = class NgParticlesService {
9
+ get loaded() {
10
+ return initialized;
11
+ }
12
+ assertInitialized() {
13
+ if (!initialized) throw new Error("NgParticlesService.init(...) must be called once before rendering ngx-particles components.");
14
+ }
15
+ async init(particlesInit) {
16
+ if (initialized) return;
17
+ if (initPromise) {
18
+ if (initCallback !== particlesInit) throw new Error("NgParticlesService init callback must be stable across the app lifecycle.");
19
+ await initPromise;
20
+ return;
21
+ }
22
+ initCallback = particlesInit;
23
+ initPromise = (async () => {
24
+ if (particlesInit) await particlesInit(tsParticles);
25
+ await tsParticles.init();
26
+ initialized = true;
27
+ })().catch((error) => {
28
+ initPromise = void 0;
29
+ initCallback = void 0;
30
+ initialized = false;
31
+ throw error;
32
+ });
33
+ await initPromise;
34
+ }
35
+ async waitForInitialization() {
36
+ await (initPromise ?? Promise.resolve());
37
+ }
38
+ static ɵfac = i0.ɵɵngDeclareFactory({
39
+ minVersion: "12.0.0",
40
+ version: "22.2.3",
41
+ ngImport: i0,
42
+ type: NgParticlesService,
43
+ deps: [],
44
+ target: i0.ɵɵFactoryTarget.Injectable
45
+ });
46
+ static ɵprov = i0.ɵɵngDeclareInjectable({
47
+ minVersion: "12.0.0",
48
+ version: "22.2.3",
49
+ ngImport: i0,
50
+ type: NgParticlesService,
51
+ providedIn: "root"
52
+ });
53
+ };
54
+ i0.ɵɵngDeclareClassMetadata({
55
+ minVersion: "12.0.0",
56
+ version: "22.2.3",
57
+ ngImport: i0,
58
+ type: NgParticlesService,
59
+ decorators: [{
60
+ type: Injectable,
61
+ args: [{ providedIn: "root" }]
62
+ }]
63
+ });
64
+ var NgxParticlesComponent = class NgxParticlesComponent {
65
+ platformId;
66
+ options;
67
+ url;
68
+ id = "tsparticles";
69
+ theme;
70
+ particlesLoaded = new EventEmitter();
71
+ #container;
72
+ #loadingPromise;
73
+ #particlesService;
74
+ constructor(platformId, particlesService) {
75
+ this.platformId = platformId;
76
+ this.#particlesService = particlesService;
77
+ }
78
+ ngAfterViewInit() {
79
+ if (isPlatformServer(this.platformId)) return;
80
+ this.#loadingPromise = this.#loadParticles();
81
+ }
82
+ ngOnChanges(changes) {
83
+ if (isPlatformServer(this.platformId)) return;
84
+ if (!this.#container) return;
85
+ if (changes["id"] || changes["options"] || changes["url"]) this.#loadParticles();
86
+ if (changes["theme"]) this.#container.loadTheme?.(changes["theme"].currentValue);
87
+ }
88
+ ngOnDestroy() {
89
+ this.#container?.destroy();
90
+ this.#loadingPromise = void 0;
91
+ }
92
+ async #loadParticles() {
93
+ await this.#particlesService.waitForInitialization();
94
+ this.#particlesService.assertInitialized();
95
+ this.#container?.destroy();
96
+ const container = await tsParticles.load({
97
+ id: this.id,
98
+ options: this.options,
99
+ url: this.url
100
+ });
101
+ this.#container = container;
102
+ if (container && this.theme) container.loadTheme?.(this.theme);
103
+ this.particlesLoaded.emit(container);
104
+ }
105
+ static ɵfac = i0.ɵɵngDeclareFactory({
106
+ minVersion: "12.0.0",
107
+ version: "22.2.3",
108
+ ngImport: i0,
109
+ type: NgxParticlesComponent,
110
+ deps: [{ token: PLATFORM_ID }, { token: NgParticlesService }],
111
+ target: i0.ɵɵFactoryTarget.Component
112
+ });
113
+ static ɵcmp = i0.ɵɵngDeclareComponent({
114
+ minVersion: "14.0.0",
115
+ version: "22.2.3",
116
+ type: NgxParticlesComponent,
117
+ isStandalone: false,
118
+ selector: "ngx-particles",
119
+ inputs: {
120
+ options: "options",
121
+ url: "url",
122
+ id: "id",
123
+ theme: "theme"
124
+ },
125
+ outputs: { particlesLoaded: "particlesLoaded" },
126
+ usesOnChanges: true,
127
+ ngImport: i0,
128
+ template: "<div [id]=\"id\"></div>",
129
+ isInline: true
130
+ });
131
+ };
132
+ i0.ɵɵngDeclareClassMetadata({
133
+ minVersion: "12.0.0",
134
+ version: "22.2.3",
135
+ ngImport: i0,
136
+ type: NgxParticlesComponent,
137
+ decorators: [{
138
+ type: Component,
139
+ args: [{
140
+ selector: "ngx-particles",
141
+ standalone: false,
142
+ template: "<div [id]=\"id\"></div>"
143
+ }]
144
+ }],
145
+ ctorParameters: () => [{
146
+ type: void 0,
147
+ decorators: [{
148
+ type: Inject,
149
+ args: [PLATFORM_ID]
150
+ }]
151
+ }, { type: NgParticlesService }],
152
+ propDecorators: {
153
+ options: [{ type: Input }],
154
+ url: [{ type: Input }],
155
+ id: [{ type: Input }],
156
+ theme: [{ type: Input }],
157
+ particlesLoaded: [{ type: Output }]
158
+ }
159
+ });
160
+ var NgxParticlesModule = class NgxParticlesModule {
161
+ static ɵfac = i0.ɵɵngDeclareFactory({
162
+ minVersion: "12.0.0",
163
+ version: "22.2.3",
164
+ ngImport: i0,
165
+ type: NgxParticlesModule,
166
+ deps: [],
167
+ target: i0.ɵɵFactoryTarget.NgModule
168
+ });
169
+ static ɵmod = i0.ɵɵngDeclareNgModule({
170
+ minVersion: "14.0.0",
171
+ version: "22.2.3",
172
+ ngImport: i0,
173
+ type: NgxParticlesModule,
174
+ declarations: [NgxParticlesComponent],
175
+ exports: [NgxParticlesComponent]
176
+ });
177
+ static ɵinj = i0.ɵɵngDeclareInjector({
178
+ minVersion: "12.0.0",
179
+ version: "22.2.3",
180
+ ngImport: i0,
181
+ type: NgxParticlesModule,
182
+ providers: [NgParticlesService]
183
+ });
184
+ };
185
+ i0.ɵɵngDeclareClassMetadata({
186
+ minVersion: "12.0.0",
187
+ version: "22.2.3",
188
+ ngImport: i0,
189
+ type: NgxParticlesModule,
190
+ decorators: [{
191
+ type: NgModule,
192
+ args: [{
193
+ declarations: [NgxParticlesComponent],
194
+ exports: [NgxParticlesComponent],
195
+ providers: [NgParticlesService]
196
+ }]
197
+ }]
198
+ });
153
199
  export { NgParticlesService, NgxParticlesComponent, NgxParticlesModule };
154
- //# sourceMappingURL=tsparticles-angular.mjs.map
200
+
201
+ //# sourceMappingURL=tsparticles-angular.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsparticles-angular.mjs","sources":["../../../projects/ng-particles/src/lib/ng-particles.service.ts","../../../projects/ng-particles/src/lib/ng-particles.component.ts","../../../projects/ng-particles/src/lib/ng-particles.module.ts","../../../projects/ng-particles/src/public-api.ts","../../../projects/ng-particles/src/tsparticles-angular.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\nimport { Engine, tsParticles } from \"@tsparticles/engine\";\n\nexport type ParticlesPluginRegistrar = (engine: Engine) => Promise<void> | void;\n\nlet initialized = false;\nlet initPromise: Promise<void> | undefined;\nlet initCallback: ParticlesPluginRegistrar | undefined;\n\n@Injectable({\n providedIn: \"root\",\n})\nexport class NgParticlesService {\n public get loaded(): boolean {\n return initialized;\n }\n\n public assertInitialized(): void {\n if (!initialized) {\n throw new Error(\"NgParticlesService.init(...) must be called once before rendering ngx-particles components.\");\n }\n }\n\n public async init(particlesInit?: ParticlesPluginRegistrar): Promise<void> {\n if (initialized) {\n return;\n }\n\n if (initPromise) {\n if (initCallback !== particlesInit) {\n throw new Error(\"NgParticlesService init callback must be stable across the app lifecycle.\");\n }\n\n await initPromise;\n\n return;\n }\n\n initCallback = particlesInit;\n initPromise = (async () => {\n if (particlesInit) {\n await particlesInit(tsParticles);\n }\n\n await tsParticles.init();\n\n initialized = true;\n })().catch((error: unknown) => {\n initPromise = undefined;\n initCallback = undefined;\n initialized = false;\n\n throw error;\n });\n\n await initPromise;\n }\n\n public async waitForInitialization(): Promise<void> {\n await (initPromise ?? Promise.resolve());\n }\n}\n","import {\n AfterViewInit,\n Component,\n EventEmitter,\n Inject,\n Input,\n OnChanges,\n OnDestroy,\n Output,\n PLATFORM_ID,\n SimpleChanges,\n} from \"@angular/core\";\nimport { isPlatformServer } from \"@angular/common\";\nimport { tsParticles } from \"@tsparticles/engine\";\nimport type { Container } from \"@tsparticles/engine\";\nimport { IParticlesProps } from \"./ng-particles.module\";\nimport { NgParticlesService } from \"./ng-particles.service\";\n\n@Component({\n selector: \"ngx-particles\",\n standalone: false,\n template: '<div [id]=\"id\"></div>',\n})\nexport class NgxParticlesComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: IParticlesProps;\n @Input() url?: string;\n @Input() id = \"tsparticles\";\n @Input() theme?: string;\n @Output() particlesLoaded: EventEmitter<Container | undefined> = new EventEmitter<Container | undefined>();\n\n #container?: Container;\n #loadingPromise?: Promise<void>;\n readonly #particlesService: NgParticlesService;\n\n constructor(\n @Inject(PLATFORM_ID) protected platformId: string,\n particlesService: NgParticlesService,\n ) {\n this.#particlesService = particlesService;\n }\n\n public ngAfterViewInit(): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n this.#loadingPromise = this.#loadParticles();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n if (!this.#container) {\n return;\n }\n\n if (changes[\"id\"] || changes[\"options\"] || changes[\"url\"]) {\n void this.#loadParticles();\n }\n\n if (changes[\"theme\"]) {\n (this.#container as unknown as { loadTheme?: (name?: string) => Promise<void> }).loadTheme?.(\n changes[\"theme\"].currentValue,\n );\n }\n }\n\n public ngOnDestroy(): void {\n this.#container?.destroy();\n\n this.#loadingPromise = undefined;\n }\n\n async #loadParticles(): Promise<void> {\n await this.#particlesService.waitForInitialization();\n this.#particlesService.assertInitialized();\n\n this.#container?.destroy();\n\n const container = await tsParticles.load({ id: this.id, options: this.options, url: this.url });\n\n this.#container = container;\n\n if (container && this.theme) {\n (container as unknown as { loadTheme?: (name?: string) => Promise<void> }).loadTheme?.(this.theme);\n }\n\n this.particlesLoaded.emit(container);\n }\n}\n","import { NgModule } from \"@angular/core\";\nimport { NgxParticlesComponent } from \"./ng-particles.component\";\nimport type { ISourceOptions } from \"@tsparticles/engine\";\nimport { NgParticlesService } from \"./ng-particles.service\";\n\n@NgModule({\n declarations: [NgxParticlesComponent],\n exports: [NgxParticlesComponent],\n providers: [NgParticlesService],\n})\nexport class NgxParticlesModule {}\n\nexport type IParticlesProps = ISourceOptions;\nexport { NgParticlesService };\n","/*\n * Public API Surface of ng-particles\n */\n\nexport * from \"./lib/ng-particles.component\";\nexport * from \"./lib/ng-particles.module\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.NgParticlesService"],"mappings":";;;;;AAKA,IAAI,WAAW,GAAG,KAAK;AACvB,IAAI,WAAsC;AAC1C,IAAI,YAAkD;MAKzC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I,MAAM;2BAAC,WAAW;;sBAXpB;;sBACA;;sBACA;;sBACA;;sBACA;;;MClBU,kBAAkB,CAAA;uGAAlB,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAlB,kBAAkB,EAAA,YAAA,EAAA,CAJd,qBAAqB,CAAA,EAAA,OAAA,EAAA,CAC1B,qBAAqB,CAAA,EAAA,CAAA;wGAGpB,kBAAkB,EAAA,SAAA,EAFlB,CAAC,kBAAkB,CAAC,EAAA,CAAA;;2FAEpB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,YAAY,EAAE,CAAC,qBAAqB,CAAC;oBACrC,OAAO,EAAE,CAAC,qBAAqB,CAAC;oBAChC,SAAS,EAAE,CAAC,kBAAkB,CAAC;AAChC,iBAAA;;;ACTD;;AAEG;;ACFH;;AAEG;;"}
1
+ {"version":3,"file":"tsparticles-angular.mjs","names":[],"sources":["../../../projects/ng-particles/src/lib/ng-particles.service.ts","../../../projects/ng-particles/src/lib/ng-particles.component.ts","../../../projects/ng-particles/src/lib/ng-particles.module.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\nimport { Engine, tsParticles } from \"@tsparticles/engine\";\n\nexport type ParticlesPluginRegistrar = (engine: Engine) => Promise<void> | void;\n\nlet initialized = false;\nlet initPromise: Promise<void> | undefined;\nlet initCallback: ParticlesPluginRegistrar | undefined;\n\n@Injectable({\n providedIn: \"root\",\n})\nexport class NgParticlesService {\n public get loaded(): boolean {\n return initialized;\n }\n\n public assertInitialized(): void {\n if (!initialized) {\n throw new Error(\"NgParticlesService.init(...) must be called once before rendering ngx-particles components.\");\n }\n }\n\n public async init(particlesInit?: ParticlesPluginRegistrar): Promise<void> {\n if (initialized) {\n return;\n }\n\n if (initPromise) {\n if (initCallback !== particlesInit) {\n throw new Error(\"NgParticlesService init callback must be stable across the app lifecycle.\");\n }\n\n await initPromise;\n\n return;\n }\n\n initCallback = particlesInit;\n initPromise = (async () => {\n if (particlesInit) {\n await particlesInit(tsParticles);\n }\n\n await tsParticles.init();\n\n initialized = true;\n })().catch((error: unknown) => {\n initPromise = undefined;\n initCallback = undefined;\n initialized = false;\n\n throw error;\n });\n\n await initPromise;\n }\n\n public async waitForInitialization(): Promise<void> {\n await (initPromise ?? Promise.resolve());\n }\n}\n","import {\n AfterViewInit,\n Component,\n EventEmitter,\n Inject,\n Input,\n OnChanges,\n OnDestroy,\n Output,\n PLATFORM_ID,\n SimpleChanges,\n} from \"@angular/core\";\nimport { isPlatformServer } from \"@angular/common\";\nimport { tsParticles } from \"@tsparticles/engine\";\nimport type { Container } from \"@tsparticles/engine\";\nimport { IParticlesProps } from \"./ng-particles.module\";\nimport { NgParticlesService } from \"./ng-particles.service\";\n\n@Component({\n selector: \"ngx-particles\",\n standalone: false,\n template: '<div [id]=\"id\"></div>',\n})\nexport class NgxParticlesComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: IParticlesProps;\n @Input() url?: string;\n @Input() id = \"tsparticles\";\n @Input() theme?: string;\n @Output() particlesLoaded: EventEmitter<Container | undefined> = new EventEmitter<Container | undefined>();\n\n #container?: Container;\n #loadingPromise?: Promise<void>;\n readonly #particlesService: NgParticlesService;\n\n constructor(\n @Inject(PLATFORM_ID) protected platformId: string,\n particlesService: NgParticlesService,\n ) {\n this.#particlesService = particlesService;\n }\n\n public ngAfterViewInit(): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n this.#loadingPromise = this.#loadParticles();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n if (!this.#container) {\n return;\n }\n\n if (changes[\"id\"] || changes[\"options\"] || changes[\"url\"]) {\n void this.#loadParticles();\n }\n\n if (changes[\"theme\"]) {\n (this.#container as unknown as { loadTheme?: (name?: string) => Promise<void> }).loadTheme?.(\n changes[\"theme\"].currentValue,\n );\n }\n }\n\n public ngOnDestroy(): void {\n this.#container?.destroy();\n\n this.#loadingPromise = undefined;\n }\n\n async #loadParticles(): Promise<void> {\n await this.#particlesService.waitForInitialization();\n this.#particlesService.assertInitialized();\n\n this.#container?.destroy();\n\n const container = await tsParticles.load({ id: this.id, options: this.options, url: this.url });\n\n this.#container = container;\n\n if (container && this.theme) {\n (container as unknown as { loadTheme?: (name?: string) => Promise<void> }).loadTheme?.(this.theme);\n }\n\n this.particlesLoaded.emit(container);\n }\n}\n","import { NgModule } from \"@angular/core\";\nimport { NgxParticlesComponent } from \"./ng-particles.component\";\nimport type { ISourceOptions } from \"@tsparticles/engine\";\nimport { NgParticlesService } from \"./ng-particles.service\";\n\n@NgModule({\n declarations: [NgxParticlesComponent],\n exports: [NgxParticlesComponent],\n providers: [NgParticlesService],\n})\nexport class NgxParticlesModule {}\n\nexport type IParticlesProps = ISourceOptions;\nexport { NgParticlesService };\n"],"mappings":";;;;AAKA,IAAI,cAAc;AAClB,IAAI;AACJ,IAAI;AAKJ,IAAa,qBAAb,MAAa,mBAAkB;CAC7B,IAAW,SAAM;EACf,OAAO;CACT;CAEO,oBAAiB;EACtB,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,6FAA6F;CAEjH;CAEO,MAAM,KAAK,eAAwC;EACxD,IAAI,aACF;EAGF,IAAI,aAAa;GACf,IAAI,iBAAiB,eACnB,MAAM,IAAI,MAAM,2EAA2E;GAG7F,MAAM;GAEN;EACF;EAEA,eAAe;EACf,eAAe,YAAW;GACxB,IAAI,eACF,MAAM,cAAc,WAAW;GAGjC,MAAM,YAAY,KAAI;GAEtB,cAAc;EAChB,EAAA,CAAE,CAAE,CAAC,OAAO,UAAkB;GAC5B,cAAc;GACd,eAAe;GACf,cAAc;GAEd,MAAM;EACR,CAAC;EAED,MAAM;CACR;CAEO,MAAM,wBAAqB;EAChC,OAAO,eAAe,QAAQ,QAAO;CACvC;CAhDW,OAAA,OAAA,GAAA,mBAAA;EA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,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAkB,WAFlB,CAAC,kBAAkB;CAAC,CAAA;;AAEpB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAkB,YAAA,CAAA;EAL9B,MAAA;EAAS,MAAA,CAAA;GACR,cAAc,CAAC,qBAAqB;GACpC,SAAS,CAAC,qBAAqB;GAC/B,WAAW,CAAC,kBAAkB;EAC/B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/angular",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Official tsParticles Angular 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://particles.js.org",
6
6
  "repository": {
@@ -88,7 +88,7 @@
88
88
  "@angular/common": ">=12.0.0",
89
89
  "@angular/core": ">=12.0.0",
90
90
  "rxjs": ">=7.0.0",
91
- "@tsparticles/engine": "^4.4.0"
91
+ "@tsparticles/engine": "^4.5.0"
92
92
  },
93
93
  "dependencies": {
94
94
  "tslib": "^2.8.1"
@@ -1,39 +1,53 @@
1
- import * as i0 from '@angular/core';
2
- import { AfterViewInit, OnChanges, OnDestroy, EventEmitter, SimpleChanges } from '@angular/core';
3
- import { Engine, ISourceOptions, Container } from '@tsparticles/engine';
4
-
1
+ import * as i0 from "@angular/core";
2
+ import { AfterViewInit, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
3
+ import { Container, Engine, ISourceOptions } from "@tsparticles/engine";
5
4
  type ParticlesPluginRegistrar = (engine: Engine) => Promise<void> | void;
6
- declare class NgParticlesService {
7
- get loaded(): boolean;
8
- assertInitialized(): void;
9
- init(particlesInit?: ParticlesPluginRegistrar): Promise<void>;
10
- waitForInitialization(): Promise<void>;
11
- static ɵfac: i0.ɵɵFactoryDeclaration<NgParticlesService, never>;
12
- static ɵprov: i0.ɵɵInjectableDeclaration<NgParticlesService>;
5
+ export declare class NgParticlesService {
6
+ get loaded(): boolean;
7
+ assertInitialized(): void;
8
+ init(particlesInit?: ParticlesPluginRegistrar): Promise<void>;
9
+ waitForInitialization(): Promise<void>;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgParticlesService, never>;
11
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
13
12
  }
14
-
15
- declare class NgxParticlesModule {
16
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxParticlesModule, never>;
17
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxParticlesModule, [typeof NgxParticlesComponent], never, [typeof NgxParticlesComponent]>;
18
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxParticlesModule>;
13
+ export declare class NgxParticlesModule {
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxParticlesModule, never>;
15
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxParticlesModule, [typeof NgxParticlesComponent], never, [typeof NgxParticlesComponent]>;
16
+ static ɵinj: i0.ɵɵInjectorDeclaration<NgxParticlesModule>;
19
17
  }
20
- type IParticlesProps = ISourceOptions;
21
-
22
- declare class NgxParticlesComponent implements AfterViewInit, OnChanges, OnDestroy {
23
- #private;
24
- protected platformId: string;
25
- options?: IParticlesProps;
26
- url?: string;
27
- id: string;
28
- theme?: string;
29
- particlesLoaded: EventEmitter<Container | undefined>;
30
- constructor(platformId: string, particlesService: NgParticlesService);
31
- ngAfterViewInit(): void;
32
- ngOnChanges(changes: SimpleChanges): void;
33
- ngOnDestroy(): void;
34
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxParticlesComponent, never>;
35
- static ɵcmp: i0.ɵɵComponentDeclaration<NgxParticlesComponent, "ngx-particles", never, { "options": { "alias": "options"; "required": false; }; "url": { "alias": "url"; "required": false; }; "id": { "alias": "id"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; }, { "particlesLoaded": "particlesLoaded"; }, never, never, false, never>;
18
+ export type IParticlesProps = ISourceOptions;
19
+ export declare class NgxParticlesComponent implements AfterViewInit, OnChanges, OnDestroy {
20
+ #private;
21
+ protected platformId: string;
22
+ options?: IParticlesProps;
23
+ url?: string;
24
+ id: string;
25
+ theme?: string;
26
+ particlesLoaded: EventEmitter<Container | undefined>;
27
+ constructor(platformId: string, particlesService: NgParticlesService);
28
+ ngAfterViewInit(): void;
29
+ ngOnChanges(changes: SimpleChanges): void;
30
+ ngOnDestroy(): void;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxParticlesComponent, never>;
32
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxParticlesComponent, "ngx-particles", never, {
33
+ "options": {
34
+ "alias": "options";
35
+ "required": false;
36
+ };
37
+ "url": {
38
+ "alias": "url";
39
+ "required": false;
40
+ };
41
+ "id": {
42
+ "alias": "id";
43
+ "required": false;
44
+ };
45
+ "theme": {
46
+ "alias": "theme";
47
+ "required": false;
48
+ };
49
+ }, {
50
+ "particlesLoaded": "particlesLoaded";
51
+ }, never, never, false, never>;
36
52
  }
37
-
38
- export { NgParticlesService, NgxParticlesComponent, NgxParticlesModule };
39
- export type { IParticlesProps };
53
+ export {};