@tsparticles/stencil 4.0.5

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/cjs/Container-DFed5jPA.js +3556 -0
  4. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  5. package/dist/cjs/index-BY5-j3YK.js +1143 -0
  6. package/dist/cjs/index-Dwz1YgEM.js +1229 -0
  7. package/dist/cjs/index.cjs.js +9 -0
  8. package/dist/cjs/loader.cjs.js +13 -0
  9. package/dist/cjs/stencil-particles.cjs.entry.js +76 -0
  10. package/dist/cjs/tsparticlesstencil.cjs.js +25 -0
  11. package/dist/collection/collection-manifest.json +13 -0
  12. package/dist/collection/components/stencil-particles/stencil-particles.js +144 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/initParticlesEngine.js +38 -0
  15. package/dist/esm/Container-Di-pVL5B.js +3554 -0
  16. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  17. package/dist/esm/index-BzK79uqU.js +1223 -0
  18. package/dist/esm/index-CPcFDf6d.js +1052 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/loader.js +11 -0
  21. package/dist/esm/stencil-particles.entry.js +74 -0
  22. package/dist/esm/tsparticlesstencil.js +21 -0
  23. package/dist/index.cjs.js +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/tsparticlesstencil/index.esm.js +1 -0
  26. package/dist/tsparticlesstencil/p-2a10755a.entry.js +1 -0
  27. package/dist/tsparticlesstencil/p-BzK79uqU.js +2 -0
  28. package/dist/tsparticlesstencil/p-C6McIuSD.js +1 -0
  29. package/dist/tsparticlesstencil/p-DQuL1Twl.js +1 -0
  30. package/dist/tsparticlesstencil/p-x9G6hxBi.js +1 -0
  31. package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -0
  32. package/dist/types/components/stencil-particles/stencil-particles.d.ts +16 -0
  33. package/dist/types/components.d.ts +52 -0
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/initParticlesEngine.d.ts +5 -0
  36. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  37. package/loader/cdn.js +1 -0
  38. package/loader/index.cjs.js +1 -0
  39. package/loader/index.d.ts +24 -0
  40. package/loader/index.es2017.js +1 -0
  41. package/loader/index.js +2 -0
  42. package/package.json +64 -0
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BY5-j3YK.js');
4
+
5
+
6
+
7
+ exports.initParticlesEngine = index.initParticlesEngine;
8
+ exports.isParticlesEngineInitialized = index.isParticlesEngineInitialized;
9
+ exports.waitForParticlesEngineInitialization = index.waitForParticlesEngineInitialization;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Dwz1YgEM.js');
4
+ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
+
6
+ const defineCustomElements = async (win, options) => {
7
+ if (typeof window === 'undefined') return undefined;
8
+ await appGlobals.globalScripts();
9
+ return index.bootstrapLazy([["stencil-particles.cjs",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}]}]]]], options);
10
+ };
11
+
12
+ exports.setNonce = index.setNonce;
13
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Dwz1YgEM.js');
4
+ var index$1 = require('./index-BY5-j3YK.js');
5
+
6
+ const StencilParticles = class {
7
+ constructor(hostRef) {
8
+ index.registerInstance(this, hostRef);
9
+ this.renderId = 0;
10
+ }
11
+ async componentDidLoad() {
12
+ await this.loadParticles(++this.renderId);
13
+ }
14
+ disconnectedCallback() {
15
+ var _a;
16
+ this.renderId++; // Invalidate any pending load promises
17
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
18
+ this.container = undefined;
19
+ }
20
+ async onPropsChange() {
21
+ await this.loadParticles(++this.renderId);
22
+ }
23
+ async loadParticles(currentRenderId) {
24
+ var _a;
25
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
26
+ if (!this.containerElement) {
27
+ console.warn("[stencil-particles] container element not available yet");
28
+ return;
29
+ }
30
+ let container;
31
+ try {
32
+ // Use the shared initialization logic to ensure consistent plugin registration
33
+ // and avoid duplicate initialization when multiple instances mount concurrently.
34
+ // initParticlesEngine handles promise de-duplication and enforces a stable init callback.
35
+ if (this.init) {
36
+ await index$1.initParticlesEngine(this.init);
37
+ }
38
+ if (!this.options && !this.url) {
39
+ console.warn("[stencil-particles] neither options nor url provided");
40
+ return;
41
+ }
42
+ // Load particles directly onto the DOM element.
43
+ // tsParticles will auto-generate a unique internal ID, preventing collisions.
44
+ const loadParams = Object.assign({ element: this.containerElement }, (this.options ? { options: this.options } : { url: this.url }));
45
+ container = await index$1.tsParticles.load(loadParams);
46
+ }
47
+ catch (error) {
48
+ console.error("[stencil-particles] load failed", error);
49
+ return;
50
+ }
51
+ // Race condition guard: discard result if props changed during async load
52
+ if (currentRenderId !== this.renderId) {
53
+ container === null || container === void 0 ? void 0 : container.destroy();
54
+ return;
55
+ }
56
+ this.container = container;
57
+ }
58
+ render() {
59
+ return (index.h("div", { key: '870e2cc222aed94f8bbfa274dc3c047392ed8b1a', ref: el => {
60
+ this.containerElement = el;
61
+ }, style: { width: "100%", height: "100%" } }));
62
+ }
63
+ static get watchers() { return {
64
+ "options": [{
65
+ "onPropsChange": 0
66
+ }],
67
+ "url": [{
68
+ "onPropsChange": 0
69
+ }],
70
+ "init": [{
71
+ "onPropsChange": 0
72
+ }]
73
+ }; }
74
+ };
75
+
76
+ exports.stencil_particles = StencilParticles;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Dwz1YgEM.js');
4
+ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
+
6
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
+ /*
8
+ Stencil Client Patch Browser v4.43.4 | MIT Licensed | https://stenciljs.com
9
+ */
10
+
11
+ var patchBrowser = () => {
12
+ const importMeta = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('tsparticlesstencil.cjs.js', document.baseURI).href));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
18
+ };
19
+
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ return index.bootstrapLazy([["stencil-particles.cjs",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}]}]]]], options);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;
@@ -0,0 +1,13 @@
1
+ {
2
+ "entries": [
3
+ "components/stencil-particles/stencil-particles.js"
4
+ ],
5
+ "mixins": [],
6
+ "compiler": {
7
+ "name": "@stencil/core",
8
+ "version": "4.43.4",
9
+ "typescriptVersion": "5.8.3"
10
+ },
11
+ "collections": [],
12
+ "bundles": []
13
+ }
@@ -0,0 +1,144 @@
1
+ import { h } from "@stencil/core";
2
+ import { tsParticles } from "@tsparticles/engine";
3
+ import { initParticlesEngine } from "../../initParticlesEngine";
4
+ export class StencilParticles {
5
+ constructor() {
6
+ this.renderId = 0;
7
+ }
8
+ async componentDidLoad() {
9
+ await this.loadParticles(++this.renderId);
10
+ }
11
+ disconnectedCallback() {
12
+ var _a;
13
+ this.renderId++; // Invalidate any pending load promises
14
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
15
+ this.container = undefined;
16
+ }
17
+ async onPropsChange() {
18
+ await this.loadParticles(++this.renderId);
19
+ }
20
+ async loadParticles(currentRenderId) {
21
+ var _a;
22
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
23
+ if (!this.containerElement) {
24
+ console.warn("[stencil-particles] container element not available yet");
25
+ return;
26
+ }
27
+ let container;
28
+ try {
29
+ // Use the shared initialization logic to ensure consistent plugin registration
30
+ // and avoid duplicate initialization when multiple instances mount concurrently.
31
+ // initParticlesEngine handles promise de-duplication and enforces a stable init callback.
32
+ if (this.init) {
33
+ await initParticlesEngine(this.init);
34
+ }
35
+ if (!this.options && !this.url) {
36
+ console.warn("[stencil-particles] neither options nor url provided");
37
+ return;
38
+ }
39
+ // 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 }));
42
+ container = await tsParticles.load(loadParams);
43
+ }
44
+ catch (error) {
45
+ console.error("[stencil-particles] load failed", error);
46
+ return;
47
+ }
48
+ // Race condition guard: discard result if props changed during async load
49
+ if (currentRenderId !== this.renderId) {
50
+ container === null || container === void 0 ? void 0 : container.destroy();
51
+ return;
52
+ }
53
+ this.container = container;
54
+ }
55
+ render() {
56
+ return (h("div", { key: '870e2cc222aed94f8bbfa274dc3c047392ed8b1a', ref: el => {
57
+ this.containerElement = el;
58
+ }, style: { width: "100%", height: "100%" } }));
59
+ }
60
+ static get is() { return "stencil-particles"; }
61
+ static get properties() {
62
+ return {
63
+ "options": {
64
+ "type": "unknown",
65
+ "mutable": false,
66
+ "complexType": {
67
+ "original": "ISourceOptions",
68
+ "resolved": "IOptions",
69
+ "references": {
70
+ "ISourceOptions": {
71
+ "location": "import",
72
+ "path": "@tsparticles/engine",
73
+ "id": "../../engine/dist/types/index.d.ts::ISourceOptions",
74
+ "referenceLocation": "ISourceOptions"
75
+ }
76
+ }
77
+ },
78
+ "required": false,
79
+ "optional": true,
80
+ "docs": {
81
+ "tags": [],
82
+ "text": ""
83
+ },
84
+ "getter": false,
85
+ "setter": false
86
+ },
87
+ "url": {
88
+ "type": "string",
89
+ "mutable": false,
90
+ "complexType": {
91
+ "original": "string",
92
+ "resolved": "string",
93
+ "references": {}
94
+ },
95
+ "required": false,
96
+ "optional": true,
97
+ "docs": {
98
+ "tags": [],
99
+ "text": ""
100
+ },
101
+ "getter": false,
102
+ "setter": false,
103
+ "reflect": false,
104
+ "attribute": "url"
105
+ },
106
+ "init": {
107
+ "type": "unknown",
108
+ "mutable": false,
109
+ "complexType": {
110
+ "original": "ParticlesPluginRegistrar",
111
+ "resolved": "(engine: Engine) => void | Promise<void>",
112
+ "references": {
113
+ "ParticlesPluginRegistrar": {
114
+ "location": "import",
115
+ "path": "../../initParticlesEngine",
116
+ "id": "src/initParticlesEngine.ts::ParticlesPluginRegistrar",
117
+ "referenceLocation": "ParticlesPluginRegistrar"
118
+ }
119
+ }
120
+ },
121
+ "required": false,
122
+ "optional": true,
123
+ "docs": {
124
+ "tags": [],
125
+ "text": ""
126
+ },
127
+ "getter": false,
128
+ "setter": false
129
+ }
130
+ };
131
+ }
132
+ static get watchers() {
133
+ return [{
134
+ "propName": "options",
135
+ "methodName": "onPropsChange"
136
+ }, {
137
+ "propName": "url",
138
+ "methodName": "onPropsChange"
139
+ }, {
140
+ "propName": "init",
141
+ "methodName": "onPropsChange"
142
+ }];
143
+ }
144
+ }
@@ -0,0 +1 @@
1
+ export { initParticlesEngine, isParticlesEngineInitialized, waitForParticlesEngineInitialization } from "./initParticlesEngine";
@@ -0,0 +1,38 @@
1
+ import { tsParticles } from "@tsparticles/engine";
2
+ let initialized = false;
3
+ let initPromise;
4
+ let initCallback;
5
+ export async function initParticlesEngine(init) {
6
+ if (initialized) {
7
+ return;
8
+ }
9
+ if (initPromise) {
10
+ if (initCallback !== init) {
11
+ throw new Error("initParticlesEngine callback must be stable across the app lifecycle.");
12
+ }
13
+ await initPromise;
14
+ return;
15
+ }
16
+ initCallback = init;
17
+ initPromise = (async () => {
18
+ if (init) {
19
+ await init(tsParticles);
20
+ }
21
+ if (typeof tsParticles.init === "function") {
22
+ await tsParticles.init();
23
+ }
24
+ initialized = true;
25
+ })().catch((error) => {
26
+ initPromise = undefined;
27
+ initCallback = undefined;
28
+ initialized = false;
29
+ throw error;
30
+ });
31
+ await initPromise;
32
+ }
33
+ export function isParticlesEngineInitialized() {
34
+ return initialized;
35
+ }
36
+ export async function waitForParticlesEngineInitialization() {
37
+ await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
38
+ }