@tsparticles/interaction-external-push 3.0.0-alpha.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.
@@ -0,0 +1,187 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory(require("@tsparticles/engine"));
12
+ else if(typeof define === 'function' && define.amd)
13
+ define(["@tsparticles/engine"], factory);
14
+ else {
15
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ var __webpack_modules__ = ({
22
+
23
+ /***/ 533:
24
+ /***/ ((module) => {
25
+
26
+ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
27
+
28
+ /***/ })
29
+
30
+ /******/ });
31
+ /************************************************************************/
32
+ /******/ // The module cache
33
+ /******/ var __webpack_module_cache__ = {};
34
+ /******/
35
+ /******/ // The require function
36
+ /******/ function __webpack_require__(moduleId) {
37
+ /******/ // Check if module is in cache
38
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
39
+ /******/ if (cachedModule !== undefined) {
40
+ /******/ return cachedModule.exports;
41
+ /******/ }
42
+ /******/ // Create a new module (and put it into the cache)
43
+ /******/ var module = __webpack_module_cache__[moduleId] = {
44
+ /******/ // no module.id needed
45
+ /******/ // no module.loaded needed
46
+ /******/ exports: {}
47
+ /******/ };
48
+ /******/
49
+ /******/ // Execute the module function
50
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
51
+ /******/
52
+ /******/ // Return the exports of the module
53
+ /******/ return module.exports;
54
+ /******/ }
55
+ /******/
56
+ /************************************************************************/
57
+ /******/ /* webpack/runtime/define property getters */
58
+ /******/ (() => {
59
+ /******/ // define getter functions for harmony exports
60
+ /******/ __webpack_require__.d = (exports, definition) => {
61
+ /******/ for(var key in definition) {
62
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
63
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
64
+ /******/ }
65
+ /******/ }
66
+ /******/ };
67
+ /******/ })();
68
+ /******/
69
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
+ /******/ (() => {
71
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
+ /******/ })();
73
+ /******/
74
+ /******/ /* webpack/runtime/make namespace object */
75
+ /******/ (() => {
76
+ /******/ // define __esModule on exports
77
+ /******/ __webpack_require__.r = (exports) => {
78
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
79
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
80
+ /******/ }
81
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
82
+ /******/ };
83
+ /******/ })();
84
+ /******/
85
+ /************************************************************************/
86
+ var __webpack_exports__ = {};
87
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
+ (() => {
89
+ // ESM COMPAT FLAG
90
+ __webpack_require__.r(__webpack_exports__);
91
+
92
+ // EXPORTS
93
+ __webpack_require__.d(__webpack_exports__, {
94
+ "Push": () => (/* reexport */ Push),
95
+ "loadExternalPushInteraction": () => (/* binding */ loadExternalPushInteraction)
96
+ });
97
+
98
+ // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
99
+ var engine_root_window_ = __webpack_require__(533);
100
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Push.js
101
+ class Push {
102
+ constructor() {
103
+ this.default = true;
104
+ this.groups = [];
105
+ this.quantity = 4;
106
+ }
107
+ get particles_nb() {
108
+ return this.quantity;
109
+ }
110
+ set particles_nb(value) {
111
+ this.quantity = value;
112
+ }
113
+ load(data) {
114
+ var _a;
115
+ if (!data) {
116
+ return;
117
+ }
118
+ if (data.default !== undefined) {
119
+ this.default = data.default;
120
+ }
121
+ if (data.groups !== undefined) {
122
+ this.groups = data.groups.map(t => t);
123
+ }
124
+ if (!this.groups.length) {
125
+ this.default = true;
126
+ }
127
+ const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
128
+ if (quantity !== undefined) {
129
+ this.quantity = quantity;
130
+ }
131
+ }
132
+ }
133
+ ;// CONCATENATED MODULE: ./dist/browser/Pusher.js
134
+
135
+
136
+
137
+ class Pusher extends engine_root_window_.ExternalInteractorBase {
138
+ constructor(container) {
139
+ super(container);
140
+ this.handleClickMode = mode => {
141
+ if (mode !== "push") {
142
+ return;
143
+ }
144
+ const container = this.container,
145
+ options = container.actualOptions,
146
+ pushOptions = options.interactivity.modes.push;
147
+ if (!pushOptions) {
148
+ return;
149
+ }
150
+ const pushNb = pushOptions.quantity;
151
+ if (pushNb <= 0) {
152
+ return;
153
+ }
154
+ const group = (0,engine_root_window_.itemFromArray)([undefined, ...pushOptions.groups]),
155
+ groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
156
+ container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group);
157
+ };
158
+ }
159
+ clear() {}
160
+ init() {}
161
+ async interact() {}
162
+ isEnabled() {
163
+ return true;
164
+ }
165
+ loadModeOptions(options, ...sources) {
166
+ if (!options.push) {
167
+ options.push = new Push();
168
+ }
169
+ for (const source of sources) {
170
+ options.push.load(source === null || source === void 0 ? void 0 : source.push);
171
+ }
172
+ }
173
+ reset() {}
174
+ }
175
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
176
+
177
+ async function loadExternalPushInteraction(engine) {
178
+ await engine.addInteractor("externalPush", container => new Pusher(container));
179
+ }
180
+
181
+
182
+ })();
183
+
184
+ /******/ return __webpack_exports__;
185
+ /******/ })()
186
+ ;
187
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.interaction.external.push.min.js.LICENSE.txt */
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var r="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},r={};function o(t){var i=r[t];if(void 0!==i)return i.exports;var s=r[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Push:()=>e,loadExternalPushInteraction:()=>s});var t=o(533);class e{constructor(){this.default=!0,this.groups=[],this.quantity=4}get particles_nb(){return this.quantity}set particles_nb(t){this.quantity=t}load(t){var e;if(!t)return;void 0!==t.default&&(this.default=t.default),void 0!==t.groups&&(this.groups=t.groups.map((t=>t))),this.groups.length||(this.default=!0);const r=null!==(e=t.quantity)&&void 0!==e?e:t.particles_nb;void 0!==r&&(this.quantity=r)}}class r extends t.ExternalInteractorBase{constructor(e){super(e),this.handleClickMode=e=>{if("push"!==e)return;const r=this.container,o=r.actualOptions.interactivity.modes.push;if(!o)return;const i=o.quantity;if(i<=0)return;const s=(0,t.itemFromArray)([void 0,...o.groups]),n=void 0!==s?r.actualOptions.particles.groups[s]:void 0;r.particles.push(i,r.interactivity.mouse,n,s)}}clear(){}init(){}async interact(){}isEnabled(){return!0}loadModeOptions(t,...r){t.push||(t.push=new e);for(const e of r)t.push.load(null==e?void 0:e.push)}reset(){}}async function s(t){await t.addInteractor("externalPush",(t=>new r(t)))}})(),i})()));
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
@@ -0,0 +1,11 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { IPush } from "../Interfaces/IPush";
3
+ export declare class Push implements IPush, IOptionLoader<IPush> {
4
+ default: boolean;
5
+ groups: string[];
6
+ quantity: number;
7
+ constructor();
8
+ get particles_nb(): number;
9
+ set particles_nb(value: number);
10
+ load(data?: RecursivePartial<IPush>): void;
11
+ }
@@ -0,0 +1,7 @@
1
+ import type { Options } from "@tsparticles/engine";
2
+ import type { PushMode } from "../../Types";
3
+ export type PushOptions = Options & {
4
+ interactivity: {
5
+ modes: PushMode;
6
+ };
7
+ };
@@ -0,0 +1,6 @@
1
+ export interface IPush {
2
+ default: boolean;
3
+ groups: string[];
4
+ particles_nb: number;
5
+ quantity: number;
6
+ }
@@ -0,0 +1,13 @@
1
+ import { ExternalInteractorBase } from "@tsparticles/engine";
2
+ import type { IModes, Modes, RecursivePartial } from "@tsparticles/engine";
3
+ import type { IPushMode, PushContainer, PushMode } from "./Types";
4
+ export declare class Pusher extends ExternalInteractorBase<PushContainer> {
5
+ handleClickMode: (mode: string) => void;
6
+ constructor(container: PushContainer);
7
+ clear(): void;
8
+ init(): void;
9
+ interact(): Promise<void>;
10
+ isEnabled(): boolean;
11
+ loadModeOptions(options: Modes & PushMode, ...sources: RecursivePartial<(IModes & IPushMode) | undefined>[]): void;
12
+ reset(): void;
13
+ }
@@ -0,0 +1,13 @@
1
+ import type { Container } from "@tsparticles/engine";
2
+ import type { IPush } from "./Options/Interfaces/IPush";
3
+ import type { Push } from "./Options/Classes/Push";
4
+ import type { PushOptions } from "./Options/Classes/PushOptions";
5
+ export type IPushMode = {
6
+ push: IPush;
7
+ };
8
+ export type PushMode = {
9
+ push?: Push;
10
+ };
11
+ export type PushContainer = Container & {
12
+ actualOptions: PushOptions;
13
+ };
@@ -0,0 +1,4 @@
1
+ import type { Engine } from "@tsparticles/engine";
2
+ export declare function loadExternalPushInteraction(engine: Engine): Promise<void>;
3
+ export * from "./Options/Classes/Push";
4
+ export * from "./Options/Interfaces/IPush";
@@ -0,0 +1,46 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Push = void 0;
13
+ class Push {
14
+ constructor() {
15
+ this.default = true;
16
+ this.groups = [];
17
+ this.quantity = 4;
18
+ }
19
+ get particles_nb() {
20
+ return this.quantity;
21
+ }
22
+ set particles_nb(value) {
23
+ this.quantity = value;
24
+ }
25
+ load(data) {
26
+ var _a;
27
+ if (!data) {
28
+ return;
29
+ }
30
+ if (data.default !== undefined) {
31
+ this.default = data.default;
32
+ }
33
+ if (data.groups !== undefined) {
34
+ this.groups = data.groups.map((t) => t);
35
+ }
36
+ if (!this.groups.length) {
37
+ this.default = true;
38
+ }
39
+ const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
40
+ if (quantity !== undefined) {
41
+ this.quantity = quantity;
42
+ }
43
+ }
44
+ }
45
+ exports.Push = Push;
46
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/umd/Pusher.js ADDED
@@ -0,0 +1,56 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Push", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Pusher = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const Push_1 = require("./Options/Classes/Push");
15
+ const engine_2 = require("@tsparticles/engine");
16
+ class Pusher extends engine_1.ExternalInteractorBase {
17
+ constructor(container) {
18
+ super(container);
19
+ this.handleClickMode = (mode) => {
20
+ if (mode !== "push") {
21
+ return;
22
+ }
23
+ const container = this.container, options = container.actualOptions, pushOptions = options.interactivity.modes.push;
24
+ if (!pushOptions) {
25
+ return;
26
+ }
27
+ const pushNb = pushOptions.quantity;
28
+ if (pushNb <= 0) {
29
+ return;
30
+ }
31
+ const group = (0, engine_2.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
32
+ container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group);
33
+ };
34
+ }
35
+ clear() {
36
+ }
37
+ init() {
38
+ }
39
+ async interact() {
40
+ }
41
+ isEnabled() {
42
+ return true;
43
+ }
44
+ loadModeOptions(options, ...sources) {
45
+ if (!options.push) {
46
+ options.push = new Push_1.Push();
47
+ }
48
+ for (const source of sources) {
49
+ options.push.load(source === null || source === void 0 ? void 0 : source.push);
50
+ }
51
+ }
52
+ reset() {
53
+ }
54
+ }
55
+ exports.Pusher = Pusher;
56
+ });
package/umd/Types.js ADDED
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/umd/index.js ADDED
@@ -0,0 +1,34 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
+ };
15
+ (function (factory) {
16
+ if (typeof module === "object" && typeof module.exports === "object") {
17
+ var v = factory(require, exports);
18
+ if (v !== undefined) module.exports = v;
19
+ }
20
+ else if (typeof define === "function" && define.amd) {
21
+ define(["require", "exports", "./Pusher", "./Options/Classes/Push", "./Options/Interfaces/IPush"], factory);
22
+ }
23
+ })(function (require, exports) {
24
+ "use strict";
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadExternalPushInteraction = void 0;
27
+ const Pusher_1 = require("./Pusher");
28
+ async function loadExternalPushInteraction(engine) {
29
+ await engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container));
30
+ }
31
+ exports.loadExternalPushInteraction = loadExternalPushInteraction;
32
+ __exportStar(require("./Options/Classes/Push"), exports);
33
+ __exportStar(require("./Options/Interfaces/IPush"), exports);
34
+ });