@tsparticles/plugin-themes 4.0.5 → 4.1.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.
- package/browser/ThemesPluginInstance.js +9 -9
- package/browser/index.js +1 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/ThemesPluginInstance.js +9 -9
- package/cjs/index.js +1 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/ThemesPluginInstance.js +9 -9
- package/esm/index.js +1 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +2 -2
- package/tsparticles.plugin.themes.js +11 -11
- package/tsparticles.plugin.themes.min.js +1 -1
- package/types/ThemesPluginInstance.d.ts +1 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { manageListener, safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
export class ThemesPluginInstance {
|
|
3
|
-
|
|
3
|
+
#container;
|
|
4
4
|
constructor(container) {
|
|
5
|
-
this
|
|
5
|
+
this.#container = container;
|
|
6
6
|
}
|
|
7
7
|
init() {
|
|
8
|
-
const container = this
|
|
8
|
+
const container = this.#container;
|
|
9
9
|
container.themeMatchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
10
10
|
const loadTheme = async (name) => {
|
|
11
11
|
if (container.destroyed) {
|
|
@@ -16,10 +16,10 @@ export class ThemesPluginInstance {
|
|
|
16
16
|
};
|
|
17
17
|
container.themeHandlers = {
|
|
18
18
|
themeChange: (e) => {
|
|
19
|
-
this
|
|
19
|
+
this.#handleThemeChange(e);
|
|
20
20
|
},
|
|
21
21
|
oldThemeChange: (e) => {
|
|
22
|
-
this
|
|
22
|
+
this.#handleThemeChange(e);
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
container.manageMediaMatch = (add) => {
|
|
@@ -36,7 +36,7 @@ export class ThemesPluginInstance {
|
|
|
36
36
|
return Promise.resolve();
|
|
37
37
|
}
|
|
38
38
|
manageListeners(add) {
|
|
39
|
-
const container = this
|
|
39
|
+
const container = this.#container;
|
|
40
40
|
container.manageMediaMatch?.(add);
|
|
41
41
|
}
|
|
42
42
|
async start() {
|
|
@@ -47,12 +47,12 @@ export class ThemesPluginInstance {
|
|
|
47
47
|
this.manageListeners(false);
|
|
48
48
|
}
|
|
49
49
|
updateActualOptions() {
|
|
50
|
-
const container = this
|
|
50
|
+
const container = this.#container;
|
|
51
51
|
container.actualOptions.setTheme?.(container.currentTheme);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
const mediaEvent = e, container = this
|
|
54
|
+
#handleThemeChange = (e) => {
|
|
55
|
+
const mediaEvent = e, container = this.#container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes?.find(theme => theme.name === themeName);
|
|
56
56
|
if (theme?.default.auto) {
|
|
57
57
|
void container.loadTheme?.(themeName);
|
|
58
58
|
}
|
package/browser/index.js
CHANGED
package/browser/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadThemesPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ThemesPlugin } = await import("./ThemesPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new ThemesPlugin());
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { manageListener, safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
export class ThemesPluginInstance {
|
|
3
|
-
|
|
3
|
+
#container;
|
|
4
4
|
constructor(container) {
|
|
5
|
-
this
|
|
5
|
+
this.#container = container;
|
|
6
6
|
}
|
|
7
7
|
init() {
|
|
8
|
-
const container = this
|
|
8
|
+
const container = this.#container;
|
|
9
9
|
container.themeMatchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
10
10
|
const loadTheme = async (name) => {
|
|
11
11
|
if (container.destroyed) {
|
|
@@ -16,10 +16,10 @@ export class ThemesPluginInstance {
|
|
|
16
16
|
};
|
|
17
17
|
container.themeHandlers = {
|
|
18
18
|
themeChange: (e) => {
|
|
19
|
-
this
|
|
19
|
+
this.#handleThemeChange(e);
|
|
20
20
|
},
|
|
21
21
|
oldThemeChange: (e) => {
|
|
22
|
-
this
|
|
22
|
+
this.#handleThemeChange(e);
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
container.manageMediaMatch = (add) => {
|
|
@@ -36,7 +36,7 @@ export class ThemesPluginInstance {
|
|
|
36
36
|
return Promise.resolve();
|
|
37
37
|
}
|
|
38
38
|
manageListeners(add) {
|
|
39
|
-
const container = this
|
|
39
|
+
const container = this.#container;
|
|
40
40
|
container.manageMediaMatch?.(add);
|
|
41
41
|
}
|
|
42
42
|
async start() {
|
|
@@ -47,12 +47,12 @@ export class ThemesPluginInstance {
|
|
|
47
47
|
this.manageListeners(false);
|
|
48
48
|
}
|
|
49
49
|
updateActualOptions() {
|
|
50
|
-
const container = this
|
|
50
|
+
const container = this.#container;
|
|
51
51
|
container.actualOptions.setTheme?.(container.currentTheme);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
const mediaEvent = e, container = this
|
|
54
|
+
#handleThemeChange = (e) => {
|
|
55
|
+
const mediaEvent = e, container = this.#container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes?.find(theme => theme.name === themeName);
|
|
56
56
|
if (theme?.default.auto) {
|
|
57
57
|
void container.loadTheme?.(themeName);
|
|
58
58
|
}
|
package/cjs/index.js
CHANGED
package/cjs/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadThemesPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ThemesPlugin } = await import("./ThemesPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new ThemesPlugin());
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { manageListener, safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
export class ThemesPluginInstance {
|
|
3
|
-
|
|
3
|
+
#container;
|
|
4
4
|
constructor(container) {
|
|
5
|
-
this
|
|
5
|
+
this.#container = container;
|
|
6
6
|
}
|
|
7
7
|
init() {
|
|
8
|
-
const container = this
|
|
8
|
+
const container = this.#container;
|
|
9
9
|
container.themeMatchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
10
10
|
const loadTheme = async (name) => {
|
|
11
11
|
if (container.destroyed) {
|
|
@@ -16,10 +16,10 @@ export class ThemesPluginInstance {
|
|
|
16
16
|
};
|
|
17
17
|
container.themeHandlers = {
|
|
18
18
|
themeChange: (e) => {
|
|
19
|
-
this
|
|
19
|
+
this.#handleThemeChange(e);
|
|
20
20
|
},
|
|
21
21
|
oldThemeChange: (e) => {
|
|
22
|
-
this
|
|
22
|
+
this.#handleThemeChange(e);
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
container.manageMediaMatch = (add) => {
|
|
@@ -36,7 +36,7 @@ export class ThemesPluginInstance {
|
|
|
36
36
|
return Promise.resolve();
|
|
37
37
|
}
|
|
38
38
|
manageListeners(add) {
|
|
39
|
-
const container = this
|
|
39
|
+
const container = this.#container;
|
|
40
40
|
container.manageMediaMatch?.(add);
|
|
41
41
|
}
|
|
42
42
|
async start() {
|
|
@@ -47,12 +47,12 @@ export class ThemesPluginInstance {
|
|
|
47
47
|
this.manageListeners(false);
|
|
48
48
|
}
|
|
49
49
|
updateActualOptions() {
|
|
50
|
-
const container = this
|
|
50
|
+
const container = this.#container;
|
|
51
51
|
container.actualOptions.setTheme?.(container.currentTheme);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
const mediaEvent = e, container = this
|
|
54
|
+
#handleThemeChange = (e) => {
|
|
55
|
+
const mediaEvent = e, container = this.#container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes?.find(theme => theme.name === themeName);
|
|
56
56
|
if (theme?.default.auto) {
|
|
57
57
|
void container.loadTheme?.(themeName);
|
|
58
58
|
}
|
package/esm/index.js
CHANGED
package/esm/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadThemesPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ThemesPlugin } = await import("./ThemesPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new ThemesPlugin());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-themes",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "tsParticles themes plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"./package.json": "./package.json"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@tsparticles/engine": "4.0
|
|
95
|
+
"@tsparticles/engine": "4.1.0"
|
|
96
96
|
},
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Plugin v4.0
|
|
2
|
+
/* Plugin v4.1.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
async function loadThemesPlugin(engine) {
|
|
124
|
-
engine.checkVersion("4.0
|
|
124
|
+
engine.checkVersion("4.1.0");
|
|
125
125
|
await engine.pluginManager.register(e => {
|
|
126
126
|
e.pluginManager.addPlugin(new ThemesPlugin());
|
|
127
127
|
});
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
globalObject.loadThemesPlugin = loadThemesPlugin;
|
|
133
133
|
|
|
134
134
|
class ThemesPluginInstance {
|
|
135
|
-
|
|
135
|
+
#container;
|
|
136
136
|
constructor(container) {
|
|
137
|
-
this
|
|
137
|
+
this.#container = container;
|
|
138
138
|
}
|
|
139
139
|
init() {
|
|
140
|
-
const container = this
|
|
140
|
+
const container = this.#container;
|
|
141
141
|
container.themeMatchMedia = engine.safeMatchMedia("(prefers-color-scheme: dark)");
|
|
142
142
|
const loadTheme = async (name) => {
|
|
143
143
|
if (container.destroyed) {
|
|
@@ -148,10 +148,10 @@
|
|
|
148
148
|
};
|
|
149
149
|
container.themeHandlers = {
|
|
150
150
|
themeChange: (e) => {
|
|
151
|
-
this
|
|
151
|
+
this.#handleThemeChange(e);
|
|
152
152
|
},
|
|
153
153
|
oldThemeChange: (e) => {
|
|
154
|
-
this
|
|
154
|
+
this.#handleThemeChange(e);
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
container.manageMediaMatch = (add) => {
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
return Promise.resolve();
|
|
169
169
|
}
|
|
170
170
|
manageListeners(add) {
|
|
171
|
-
const container = this
|
|
171
|
+
const container = this.#container;
|
|
172
172
|
container.manageMediaMatch?.(add);
|
|
173
173
|
}
|
|
174
174
|
async start() {
|
|
@@ -179,12 +179,12 @@
|
|
|
179
179
|
this.manageListeners(false);
|
|
180
180
|
}
|
|
181
181
|
updateActualOptions() {
|
|
182
|
-
const container = this
|
|
182
|
+
const container = this.#container;
|
|
183
183
|
container.actualOptions.setTheme?.(container.currentTheme);
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
const mediaEvent = e, container = this
|
|
186
|
+
#handleThemeChange = (e) => {
|
|
187
|
+
const mediaEvent = e, container = this.#container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes?.find(theme => theme.name === themeName);
|
|
188
188
|
if (theme?.default.auto) {
|
|
189
189
|
void container.loadTheme?.(themeName);
|
|
190
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.themes=e.__tsParticlesInternals.plugins.themes||{}),e.__tsParticlesInternals.engine)}(this,function(e,t){"use strict";var s;!function(e){e.any="any",e.dark="dark",e.light="light"}(s||(s={}));class n{auto;mode;value;constructor(){this.auto=!1,this.mode=s.any,this.value=!1}load(e){t.isNull(e)||(void 0!==e.auto&&(this.auto=e.auto),void 0!==e.mode&&(this.mode=e.mode),void 0!==e.value&&(this.value=e.value))}}class a{default;name;options;constructor(){this.name="",this.default=new n}load(e){t.isNull(e)||(void 0!==e.name&&(this.name=e.name),this.default.load(e.default),void 0!==e.options&&(this.options=t.deepExtend({},e.options)))}}class l{id="theme";async getPlugin(e){const{ThemesPluginInstance:t}=await Promise.resolve().then(function(){return c});return new t(e)}loadOptions(e,n,l){if(!this.needsPlugin(n)&&!this.needsPlugin(l))return;const r=e=>{if(n.themes)return n.themes.find(t=>t.default.value&&t.default.mode===e)??n.themes.find(e=>e.default.value&&e.default.mode===s.any)};if(n.findDefaultTheme=r,n.setTheme=e=>{if(n.themes)if(e){const t=n.themes.find(t=>t.name===e);t&&n.load(t.options)}else{const e=t.safeMatchMedia("(prefers-color-scheme: dark)"),a=e?.matches,l=r(a?s.dark:s.light);l&&n.load(l.options)}},n.themes??=[],void 0!==l?.themes)for(const e of l.themes){if(!e)continue;const t=n.themes.find(t=>t.name===e.name);if(t)t.load(e);else{const t=new a;t.load(e),n.themes.push(t)}}n.defaultThemes.dark=r(s.dark)?.name,n.defaultThemes.light=r(s.light)?.name}needsPlugin(e){return!!e?.themes?.length}}async function r(e){e.checkVersion("4.0
|
|
1
|
+
!function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.themes=e.__tsParticlesInternals.plugins.themes||{}),e.__tsParticlesInternals.engine)}(this,function(e,t){"use strict";var s;!function(e){e.any="any",e.dark="dark",e.light="light"}(s||(s={}));class n{auto;mode;value;constructor(){this.auto=!1,this.mode=s.any,this.value=!1}load(e){t.isNull(e)||(void 0!==e.auto&&(this.auto=e.auto),void 0!==e.mode&&(this.mode=e.mode),void 0!==e.value&&(this.value=e.value))}}class a{default;name;options;constructor(){this.name="",this.default=new n}load(e){t.isNull(e)||(void 0!==e.name&&(this.name=e.name),this.default.load(e.default),void 0!==e.options&&(this.options=t.deepExtend({},e.options)))}}class l{id="theme";async getPlugin(e){const{ThemesPluginInstance:t}=await Promise.resolve().then(function(){return c});return new t(e)}loadOptions(e,n,l){if(!this.needsPlugin(n)&&!this.needsPlugin(l))return;const r=e=>{if(n.themes)return n.themes.find(t=>t.default.value&&t.default.mode===e)??n.themes.find(e=>e.default.value&&e.default.mode===s.any)};if(n.findDefaultTheme=r,n.setTheme=e=>{if(n.themes)if(e){const t=n.themes.find(t=>t.name===e);t&&n.load(t.options)}else{const e=t.safeMatchMedia("(prefers-color-scheme: dark)"),a=e?.matches,l=r(a?s.dark:s.light);l&&n.load(l.options)}},n.themes??=[],void 0!==l?.themes)for(const e of l.themes){if(!e)continue;const t=n.themes.find(t=>t.name===e.name);if(t)t.load(e);else{const t=new a;t.load(e),n.themes.push(t)}}n.defaultThemes.dark=r(s.dark)?.name,n.defaultThemes.light=r(s.light)?.name}needsPlugin(e){return!!e?.themes?.length}}async function r(e){e.checkVersion("4.1.0"),await e.pluginManager.register(e=>{e.pluginManager.addPlugin(new l)})}const i=globalThis;i.__tsParticlesInternals=i.__tsParticlesInternals??{},i.loadThemesPlugin=r;var c=Object.freeze({__proto__:null,ThemesPluginInstance:class{#e;constructor(e){this.#e=e}init(){const e=this.#e;e.themeMatchMedia=t.safeMatchMedia("(prefers-color-scheme: dark)");return e.themeHandlers={themeChange:e=>{this.#t(e)},oldThemeChange:e=>{this.#t(e)}},e.manageMediaMatch=s=>{const n=e.themeHandlers;n&&e.themeMatchMedia&&t.manageListener(e.themeMatchMedia,"change",n.themeChange,s)},e.loadTheme=async t=>{e.destroyed||(e.currentTheme=t,await e.refresh())},Promise.resolve()}manageListeners(e){const t=this.#e;t.manageMediaMatch?.(e)}async start(){return this.manageListeners(!0),Promise.resolve()}stop(){this.manageListeners(!1)}updateActualOptions(){const e=this.#e;return e.actualOptions.setTheme?.(e.currentTheme),!1}#t=e=>{const t=e,s=this.#e,n=s.options,a=n.defaultThemes,l=t.matches?a.dark:a.light,r=n.themes?.find(e=>e.name===l);r?.default.auto&&s.loadTheme?.(l)}}});e.loadThemesPlugin=r}),Object.assign(globalThis.window||globalThis,{loadThemesPlugin:(globalThis.__tsParticlesInternals.plugins.themes||{}).loadThemesPlugin}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type IContainerPlugin } from "@tsparticles/engine";
|
|
2
2
|
import type { ThemesContainer } from "./types.js";
|
|
3
3
|
export declare class ThemesPluginInstance implements IContainerPlugin {
|
|
4
|
-
private
|
|
4
|
+
#private;
|
|
5
5
|
constructor(container: ThemesContainer);
|
|
6
6
|
init(): Promise<void>;
|
|
7
7
|
manageListeners(add: boolean): void;
|
|
8
8
|
start(): Promise<void>;
|
|
9
9
|
stop(): void;
|
|
10
10
|
updateActualOptions(): boolean;
|
|
11
|
-
private readonly _handleThemeChange;
|
|
12
11
|
}
|