@tsparticles/stencil 4.1.3 → 4.2.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 (29) hide show
  1. package/README.md +13 -0
  2. package/dist/cjs/{Container-0BqPfTsu.js → Container-BIhHE6mu.js} +659 -1010
  3. package/dist/cjs/{index-Bw7g3biq.js → index-BIoj1BEO.js} +57 -160
  4. package/dist/cjs/{index-B2lLThjb.js → index-BjS63OiI.js} +95 -5
  5. package/dist/cjs/index.cjs.js +1 -1
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/stencil-particles.cjs.entry.js +23 -6
  8. package/dist/cjs/tsparticlesstencil.cjs.js +2 -2
  9. package/dist/collection/components/stencil-particles/stencil-particles.js +83 -4
  10. package/dist/esm/{Container-BxLt611H.js → Container-DZZsfp6i.js} +659 -1010
  11. package/dist/esm/{index-BXzC9NH1.js → index-BH3sNkGS.js} +57 -160
  12. package/dist/esm/{index-DKFk70aj.js → index-PhwiK2_P.js} +95 -6
  13. package/dist/esm/index.js +1 -1
  14. package/dist/esm/loader.js +3 -3
  15. package/dist/esm/stencil-particles.entry.js +23 -6
  16. package/dist/esm/tsparticlesstencil.js +3 -3
  17. package/dist/tsparticlesstencil/index.esm.js +1 -1
  18. package/dist/tsparticlesstencil/p-CIUgBOXY.js +1 -0
  19. package/dist/tsparticlesstencil/p-PhwiK2_P.js +2 -0
  20. package/dist/tsparticlesstencil/p-QSzGOBhI.js +1 -0
  21. package/dist/tsparticlesstencil/p-bd76f15b.entry.js +1 -0
  22. package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -1
  23. package/dist/types/components/stencil-particles/stencil-particles.d.ts +6 -2
  24. package/dist/types/components.d.ts +24 -2
  25. package/package.json +8 -7
  26. package/dist/tsparticlesstencil/p-BhGs05ap.js +0 -1
  27. package/dist/tsparticlesstencil/p-DKFk70aj.js +0 -2
  28. package/dist/tsparticlesstencil/p-LyLjQmWv.js +0 -1
  29. package/dist/tsparticlesstencil/p-cf6e2424.entry.js +0 -1
@@ -17,8 +17,14 @@ export class StencilParticles {
17
17
  async onPropsChange() {
18
18
  await this.loadParticles(++this.renderId);
19
19
  }
20
+ async onThemeChange() {
21
+ var _a, _b;
22
+ if (!this.container)
23
+ return;
24
+ (_b = (_a = this.container).loadTheme) === null || _b === void 0 ? void 0 : _b.call(_a, this.theme);
25
+ }
20
26
  async loadParticles(currentRenderId) {
21
- var _a;
27
+ var _a, _b, _c;
22
28
  (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
23
29
  if (!this.containerElement) {
24
30
  console.warn("[stencil-particles] container element not available yet");
@@ -37,8 +43,8 @@ export class StencilParticles {
37
43
  return;
38
44
  }
39
45
  // Load particles directly onto the DOM element.
40
- // tsParticles will auto-generate a unique internal ID, preventing collisions.
41
- const loadParams = Object.assign({ element: this.containerElement }, (this.options ? { options: this.options } : { url: this.url }));
46
+ // If a container-id is provided, use it so consumers can retrieve the container later.
47
+ const loadParams = Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : { url: this.url }));
42
48
  container = await tsParticles.load(loadParams);
43
49
  }
44
50
  catch (error) {
@@ -51,9 +57,13 @@ export class StencilParticles {
51
57
  return;
52
58
  }
53
59
  this.container = container;
60
+ this.particlesLoaded.emit(container);
61
+ if (container && this.theme) {
62
+ (_c = (_b = container).loadTheme) === null || _c === void 0 ? void 0 : _c.call(_b, this.theme);
63
+ }
54
64
  }
55
65
  render() {
56
- return (h("div", { key: '870e2cc222aed94f8bbfa274dc3c047392ed8b1a', ref: el => {
66
+ return (h("div", { key: 'f5fe33d147a1a606a75fe0d1ee385bacaf0e0b7d', id: this.containerId, ref: el => {
57
67
  this.containerElement = el;
58
68
  }, style: { width: "100%", height: "100%" } }));
59
69
  }
@@ -126,9 +136,72 @@ export class StencilParticles {
126
136
  },
127
137
  "getter": false,
128
138
  "setter": false
139
+ },
140
+ "containerId": {
141
+ "type": "string",
142
+ "mutable": false,
143
+ "complexType": {
144
+ "original": "string",
145
+ "resolved": "string",
146
+ "references": {}
147
+ },
148
+ "required": false,
149
+ "optional": true,
150
+ "docs": {
151
+ "tags": [],
152
+ "text": ""
153
+ },
154
+ "getter": false,
155
+ "setter": false,
156
+ "reflect": false,
157
+ "attribute": "container-id"
158
+ },
159
+ "theme": {
160
+ "type": "string",
161
+ "mutable": false,
162
+ "complexType": {
163
+ "original": "string",
164
+ "resolved": "string",
165
+ "references": {}
166
+ },
167
+ "required": false,
168
+ "optional": true,
169
+ "docs": {
170
+ "tags": [],
171
+ "text": ""
172
+ },
173
+ "getter": false,
174
+ "setter": false,
175
+ "reflect": false,
176
+ "attribute": "theme"
129
177
  }
130
178
  };
131
179
  }
180
+ static get events() {
181
+ return [{
182
+ "method": "particlesLoaded",
183
+ "name": "particlesLoaded",
184
+ "bubbles": true,
185
+ "cancelable": true,
186
+ "composed": true,
187
+ "docs": {
188
+ "tags": [],
189
+ "text": ""
190
+ },
191
+ "complexType": {
192
+ "original": "Container | undefined",
193
+ "resolved": "Container",
194
+ "references": {
195
+ "Container": {
196
+ "location": "import",
197
+ "path": "@tsparticles/engine",
198
+ "id": "../../engine/dist/types/index.d.ts::Container",
199
+ "referenceLocation": "Container"
200
+ }
201
+ }
202
+ }
203
+ }];
204
+ }
132
205
  static get watchers() {
133
206
  return [{
134
207
  "propName": "options",
@@ -139,6 +212,12 @@ export class StencilParticles {
139
212
  }, {
140
213
  "propName": "init",
141
214
  "methodName": "onPropsChange"
215
+ }, {
216
+ "propName": "containerId",
217
+ "methodName": "onPropsChange"
218
+ }, {
219
+ "propName": "theme",
220
+ "methodName": "onThemeChange"
142
221
  }];
143
222
  }
144
223
  }