angular-confetti 4.5.0 → 4.5.2
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.
|
@@ -2,8 +2,45 @@ import { isPlatformServer } from "@angular/common";
|
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
import { Component, Inject, Input, NgModule, PLATFORM_ID } from "@angular/core";
|
|
4
4
|
import { confetti } from "@tsparticles/confetti";
|
|
5
|
+
const containerOwners = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const pendingContainerRequests = /* @__PURE__ */ new Map();
|
|
7
|
+
const pendingContainerDestructions = /* @__PURE__ */ new Map();
|
|
8
|
+
function retainContainer(container) {
|
|
9
|
+
containerOwners.set(container, (containerOwners.get(container) ?? 0) + 1);
|
|
10
|
+
}
|
|
11
|
+
function retainPendingContainerRequest(id) {
|
|
12
|
+
pendingContainerRequests.set(id, (pendingContainerRequests.get(id) ?? 0) + 1);
|
|
13
|
+
}
|
|
14
|
+
function releasePendingContainerRequest(id) {
|
|
15
|
+
const pending = pendingContainerRequests.get(id);
|
|
16
|
+
if (pending === 1) {
|
|
17
|
+
pendingContainerRequests.delete(id);
|
|
18
|
+
const containers = pendingContainerDestructions.get(id);
|
|
19
|
+
if (containers) {
|
|
20
|
+
for (const container of containers) if (!containerOwners.has(container) && !container.destroyed) container.destroy();
|
|
21
|
+
pendingContainerDestructions.delete(id);
|
|
22
|
+
}
|
|
23
|
+
} else if (pending !== void 0) pendingContainerRequests.set(id, pending - 1);
|
|
24
|
+
}
|
|
25
|
+
function deferContainerDestruction(id, container) {
|
|
26
|
+
if (containerOwners.has(container)) return;
|
|
27
|
+
if (pendingContainerRequests.has(id)) {
|
|
28
|
+
let containers = pendingContainerDestructions.get(id);
|
|
29
|
+
if (!containers) pendingContainerDestructions.set(id, containers = /* @__PURE__ */ new Set());
|
|
30
|
+
containers.add(container);
|
|
31
|
+
} else if (!container.destroyed) container.destroy();
|
|
32
|
+
}
|
|
33
|
+
function releaseContainer(container, id) {
|
|
34
|
+
const owners = containerOwners.get(container);
|
|
35
|
+
if (owners === void 0) return;
|
|
36
|
+
if (owners === 1) {
|
|
37
|
+
containerOwners.delete(container);
|
|
38
|
+
deferContainerDestruction(id, container);
|
|
39
|
+
} else containerOwners.set(container, owners - 1);
|
|
40
|
+
}
|
|
5
41
|
var NgxConfettiComponent = class NgxConfettiComponent {
|
|
6
42
|
#container;
|
|
43
|
+
#containerId;
|
|
7
44
|
#renderId;
|
|
8
45
|
constructor(platformId) {
|
|
9
46
|
this.platformId = platformId;
|
|
@@ -22,22 +59,35 @@ var NgxConfettiComponent = class NgxConfettiComponent {
|
|
|
22
59
|
}
|
|
23
60
|
ngOnDestroy() {
|
|
24
61
|
this.#renderId++;
|
|
25
|
-
this.#container
|
|
62
|
+
const container = this.#container, id = this.#containerId;
|
|
26
63
|
this.#container = void 0;
|
|
64
|
+
this.#containerId = void 0;
|
|
65
|
+
if (container && id !== void 0) releaseContainer(container, id);
|
|
27
66
|
}
|
|
28
67
|
async #tryFire() {
|
|
29
|
-
const currentRenderId = ++this.#renderId;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
container
|
|
33
|
-
|
|
68
|
+
const currentRenderId = ++this.#renderId, id = this.id;
|
|
69
|
+
retainPendingContainerRequest(id);
|
|
70
|
+
try {
|
|
71
|
+
const container = await confetti(id, this.options);
|
|
72
|
+
if (currentRenderId !== this.#renderId) {
|
|
73
|
+
if (container) deferContainerDestruction(id, container);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const previousContainer = this.#container, previousId = this.#containerId;
|
|
77
|
+
if (container !== previousContainer) {
|
|
78
|
+
if (container) retainContainer(container);
|
|
79
|
+
this.#container = container;
|
|
80
|
+
this.#containerId = container ? id : void 0;
|
|
81
|
+
if (previousContainer && previousId !== void 0) releaseContainer(previousContainer, previousId);
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
releasePendingContainerRequest(id);
|
|
34
85
|
}
|
|
35
|
-
this.#container = container;
|
|
36
86
|
}
|
|
37
87
|
static {
|
|
38
88
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
39
89
|
minVersion: "12.0.0",
|
|
40
|
-
version: "22.2.
|
|
90
|
+
version: "22.2.4",
|
|
41
91
|
ngImport: i0,
|
|
42
92
|
type: NgxConfettiComponent,
|
|
43
93
|
deps: [{ token: PLATFORM_ID }],
|
|
@@ -47,7 +97,7 @@ var NgxConfettiComponent = class NgxConfettiComponent {
|
|
|
47
97
|
static {
|
|
48
98
|
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
49
99
|
minVersion: "14.0.0",
|
|
50
|
-
version: "22.2.
|
|
100
|
+
version: "22.2.4",
|
|
51
101
|
type: NgxConfettiComponent,
|
|
52
102
|
isStandalone: false,
|
|
53
103
|
selector: "ngx-confetti",
|
|
@@ -65,7 +115,7 @@ var NgxConfettiComponent = class NgxConfettiComponent {
|
|
|
65
115
|
};
|
|
66
116
|
i0.ɵɵngDeclareClassMetadata({
|
|
67
117
|
minVersion: "12.0.0",
|
|
68
|
-
version: "22.2.
|
|
118
|
+
version: "22.2.4",
|
|
69
119
|
ngImport: i0,
|
|
70
120
|
type: NgxConfettiComponent,
|
|
71
121
|
decorators: [{
|
|
@@ -96,7 +146,7 @@ var NgxConfettiModule = class NgxConfettiModule {
|
|
|
96
146
|
static {
|
|
97
147
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
98
148
|
minVersion: "12.0.0",
|
|
99
|
-
version: "22.2.
|
|
149
|
+
version: "22.2.4",
|
|
100
150
|
ngImport: i0,
|
|
101
151
|
type: NgxConfettiModule,
|
|
102
152
|
deps: [],
|
|
@@ -106,7 +156,7 @@ var NgxConfettiModule = class NgxConfettiModule {
|
|
|
106
156
|
static {
|
|
107
157
|
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
108
158
|
minVersion: "14.0.0",
|
|
109
|
-
version: "22.2.
|
|
159
|
+
version: "22.2.4",
|
|
110
160
|
ngImport: i0,
|
|
111
161
|
type: NgxConfettiModule,
|
|
112
162
|
declarations: [NgxConfettiComponent],
|
|
@@ -116,7 +166,7 @@ var NgxConfettiModule = class NgxConfettiModule {
|
|
|
116
166
|
static {
|
|
117
167
|
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
118
168
|
minVersion: "12.0.0",
|
|
119
|
-
version: "22.2.
|
|
169
|
+
version: "22.2.4",
|
|
120
170
|
ngImport: i0,
|
|
121
171
|
type: NgxConfettiModule
|
|
122
172
|
});
|
|
@@ -124,7 +174,7 @@ var NgxConfettiModule = class NgxConfettiModule {
|
|
|
124
174
|
};
|
|
125
175
|
i0.ɵɵngDeclareClassMetadata({
|
|
126
176
|
minVersion: "12.0.0",
|
|
127
|
-
version: "22.2.
|
|
177
|
+
version: "22.2.4",
|
|
128
178
|
ngImport: i0,
|
|
129
179
|
type: NgxConfettiModule,
|
|
130
180
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-confetti.mjs","names":[],"sources":["../../../projects/ng-confetti/src/lib/ng-confetti.component.ts","../../../projects/ng-confetti/src/lib/ng-confetti.module.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 { confetti, ConfettiOptions } from \"@tsparticles/confetti\";\nimport type { Container } from \"@tsparticles/engine\";\n\n@Component({\n selector: \"ngx-confetti\",\n standalone: false,\n template: '<div [id]=\"id\"></div>',\n})\nexport class NgxConfettiComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: ConfettiOptions;\n @Input() id = \"tsparticles\";\n @Input() fire: boolean | number = true;\n\n #container?: Container;\n #renderId = 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.#tryFire();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n const fireChanges = changes[\"fire\"];\n\n if (this.fire && fireChanges && fireChanges.previousValue !== fireChanges.currentValue) {\n void this.#tryFire();\n }\n }\n\n public ngOnDestroy(): void {\n this.#renderId++;\n this.#container
|
|
1
|
+
{"version":3,"file":"angular-confetti.mjs","names":[],"sources":["../../../projects/ng-confetti/src/lib/ng-confetti.component.ts","../../../projects/ng-confetti/src/lib/ng-confetti.module.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 { confetti, ConfettiOptions } from \"@tsparticles/confetti\";\nimport type { Container } from \"@tsparticles/engine\";\n\nconst containerOwners = new WeakMap<Container, number>();\nconst pendingContainerRequests = new Map<string, number>();\nconst pendingContainerDestructions = new Map<string, Set<Container>>();\n\n/**\n * Adds an owner reference for a shared container.\n * @param container - The container being retained\n */\nfunction retainContainer(container: Container): void {\n containerOwners.set(container, (containerOwners.get(container) ?? 0) + 1);\n}\n\n/**\n * Records an in-flight request for a container identifier.\n * @param id - The requested container identifier\n */\nfunction retainPendingContainerRequest(id: string): void {\n pendingContainerRequests.set(id, (pendingContainerRequests.get(id) ?? 0) + 1);\n}\n\n/**\n * Releases an in-flight request and destroys any unowned deferred containers.\n * @param id - The completed container identifier\n */\nfunction releasePendingContainerRequest(id: string): void {\n const pending = pendingContainerRequests.get(id);\n\n if (pending === 1) {\n pendingContainerRequests.delete(id);\n\n const containers = pendingContainerDestructions.get(id);\n\n if (containers) {\n for (const container of containers) {\n if (!containerOwners.has(container) && !container.destroyed) {\n container.destroy();\n }\n }\n\n pendingContainerDestructions.delete(id);\n }\n } else if (pending !== undefined) {\n pendingContainerRequests.set(id, pending - 1);\n }\n}\n\n/**\n * Defers destruction while requests for the identifier are still pending.\n * @param id - The container identifier associated with the request\n * @param container - The container to destroy or defer\n */\nfunction deferContainerDestruction(id: string, container: Container): void {\n if (containerOwners.has(container)) {\n return;\n }\n\n if (pendingContainerRequests.has(id)) {\n let containers = pendingContainerDestructions.get(id);\n\n if (!containers) {\n pendingContainerDestructions.set(id, (containers = new Set()));\n }\n\n containers.add(container);\n } else if (!container.destroyed) {\n container.destroy();\n }\n}\n\n/**\n * Releases an owner reference and destroys the container when it is no longer shared.\n * @param container - The container being released\n * @param id - The container identifier\n */\nfunction releaseContainer(container: Container, id: string): void {\n const owners = containerOwners.get(container);\n\n if (owners === undefined) {\n return;\n }\n\n if (owners === 1) {\n containerOwners.delete(container);\n deferContainerDestruction(id, container);\n } else {\n containerOwners.set(container, owners - 1);\n }\n}\n\n@Component({\n selector: \"ngx-confetti\",\n standalone: false,\n template: '<div [id]=\"id\"></div>',\n})\nexport class NgxConfettiComponent implements AfterViewInit, OnChanges, OnDestroy {\n @Input() options?: ConfettiOptions;\n @Input() id = \"tsparticles\";\n @Input() fire: boolean | number = true;\n\n #container?: Container;\n #containerId?: string;\n #renderId = 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.#tryFire();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (isPlatformServer(this.platformId)) {\n return;\n }\n\n const fireChanges = changes[\"fire\"];\n\n if (this.fire && fireChanges && fireChanges.previousValue !== fireChanges.currentValue) {\n void this.#tryFire();\n }\n }\n\n public ngOnDestroy(): void {\n this.#renderId++;\n\n const container = this.#container,\n id = this.#containerId;\n\n this.#container = undefined;\n this.#containerId = undefined;\n\n if (container && id !== undefined) {\n releaseContainer(container, id);\n }\n }\n\n async #tryFire(): Promise<void> {\n const currentRenderId = ++this.#renderId,\n id = this.id;\n\n retainPendingContainerRequest(id);\n\n try {\n const container = await confetti(id, this.options);\n\n if (currentRenderId !== this.#renderId) {\n if (container) {\n deferContainerDestruction(id, container);\n }\n\n return;\n }\n\n const previousContainer = this.#container,\n previousId = this.#containerId;\n\n if (container !== previousContainer) {\n if (container) {\n retainContainer(container);\n }\n\n this.#container = container;\n this.#containerId = container ? id : undefined;\n\n if (previousContainer && previousId !== undefined) {\n releaseContainer(previousContainer, previousId);\n }\n }\n } finally {\n releasePendingContainerRequest(id);\n }\n }\n}\n","import { NgModule } from \"@angular/core\";\nimport { confetti } from \"@tsparticles/confetti\";\nimport { NgxConfettiComponent } from \"./ng-confetti.component\";\n\n@NgModule({\n declarations: [NgxConfettiComponent],\n imports: [],\n exports: [NgxConfettiComponent],\n})\nexport class NgxConfettiModule {\n constructor() {\n void confetti.init();\n }\n}\n"],"mappings":";;;;AAcA,MAAM,kCAAkB,IAAI,QAAO;AACnC,MAAM,2CAA2B,IAAI,IAAG;AACxC,MAAM,+CAA+B,IAAI,IAAG;AAM5C,SAAS,gBAAgB,WAAoB;CAC3C,gBAAgB,IAAI,YAAY,gBAAgB,IAAI,SAAS,KAAK,KAAK,CAAC;AAC1E;AAMA,SAAS,8BAA8B,IAAU;CAC/C,yBAAyB,IAAI,KAAK,yBAAyB,IAAI,EAAE,KAAK,KAAK,CAAC;AAC9E;AAMA,SAAS,+BAA+B,IAAU;CAChD,MAAM,UAAU,yBAAyB,IAAI,EAAE;CAE/C,IAAI,YAAY,GAAG;EACjB,yBAAyB,OAAO,EAAE;EAElC,MAAM,aAAa,6BAA6B,IAAI,EAAE;EAEtD,IAAI,YAAY;GACd,KAAK,MAAM,aAAa,YACtB,IAAI,CAAC,gBAAgB,IAAI,SAAS,KAAK,CAAC,UAAU,WAChD,UAAU,QAAO;GAIrB,6BAA6B,OAAO,EAAE;EACxC;CACF,OAAO,IAAI,YAAY,QACrB,yBAAyB,IAAI,IAAI,UAAU,CAAC;AAEhD;AAOA,SAAS,0BAA0B,IAAY,WAAoB;CACjE,IAAI,gBAAgB,IAAI,SAAS,GAC/B;CAGF,IAAI,yBAAyB,IAAI,EAAE,GAAG;EAC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AAA,SAAA,CAEzB,oBAAoB;EAAA,CAAA;CAAA;CAEnB;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;EAAiB,CAAA;CAAA;;AAAjB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiB,YAAA,CAAA;EAL7B,MAAA;EAAS,MAAA,CAAA;GACR,cAAc,CAAC,oBAAoB;GACnC,SAAS,CAAA;GACT,SAAS,CAAC,oBAAoB;EAC/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-confetti",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
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,11 +85,11 @@
|
|
|
85
85
|
"@angular/common": ">=12.0.0",
|
|
86
86
|
"@angular/core": ">=12.0.0",
|
|
87
87
|
"rxjs": ">=7.0.0",
|
|
88
|
-
"@tsparticles/confetti": "^4.5.
|
|
89
|
-
"@tsparticles/engine": "^4.5.
|
|
88
|
+
"@tsparticles/confetti": "^4.5.2",
|
|
89
|
+
"@tsparticles/engine": "^4.5.2"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"tslib": "^2.
|
|
92
|
+
"tslib": "^2.9.1"
|
|
93
93
|
},
|
|
94
94
|
"publishConfig": {
|
|
95
95
|
"access": "public"
|