@tsparticles/shape-emoji 3.0.3 → 3.2.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.
@@ -4,7 +4,15 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.3
7
+ * v3.2.0
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
16
  */
9
17
  (function webpackUniversalModuleDefinition(root, factory) {
10
18
  if(typeof exports === 'object' && typeof module === 'object')
@@ -15,15 +23,38 @@
15
23
  var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
25
  }
18
- })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 533:
31
+ /***/ "./dist/browser/Constants.js":
32
+ /*!***********************************!*\
33
+ !*** ./dist/browser/Constants.js ***!
34
+ \***********************************/
35
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
+
37
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ validTypes: () => (/* binding */ validTypes)\n/* harmony export */ });\nconst validTypes = [\"emoji\"];\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/Constants.js?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./dist/browser/index.js":
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
+
47
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmojiShape: () => (/* binding */ loadEmojiShape)\n/* harmony export */ });\n/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ \"./dist/browser/Constants.js\");\n\nasync function loadEmojiShape(engine, refresh = true) {\n const {\n EmojiDrawer\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmojiDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmojiDrawer.js */ \"./dist/browser/EmojiDrawer.js\"));\n await engine.addShape(_Constants_js__WEBPACK_IMPORTED_MODULE_0__.validTypes, new EmojiDrawer(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/index.js?");
48
+
49
+ /***/ }),
50
+
51
+ /***/ "@tsparticles/engine":
52
+ /*!*********************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
54
+ \*********************************************************************************************************************************/
24
55
  /***/ ((module) => {
25
56
 
26
- module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
27
58
 
28
59
  /***/ })
29
60
 
@@ -53,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
53
84
  /******/ return module.exports;
54
85
  /******/ }
55
86
  /******/
87
+ /******/ // expose the modules object (__webpack_modules__)
88
+ /******/ __webpack_require__.m = __webpack_modules__;
89
+ /******/
56
90
  /************************************************************************/
91
+ /******/ /* webpack/runtime/compat get default export */
92
+ /******/ (() => {
93
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
94
+ /******/ __webpack_require__.n = (module) => {
95
+ /******/ var getter = module && module.__esModule ?
96
+ /******/ () => (module['default']) :
97
+ /******/ () => (module);
98
+ /******/ __webpack_require__.d(getter, { a: getter });
99
+ /******/ return getter;
100
+ /******/ };
101
+ /******/ })();
102
+ /******/
57
103
  /******/ /* webpack/runtime/define property getters */
58
104
  /******/ (() => {
59
105
  /******/ // define getter functions for harmony exports
@@ -66,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
66
112
  /******/ };
67
113
  /******/ })();
68
114
  /******/
115
+ /******/ /* webpack/runtime/ensure chunk */
116
+ /******/ (() => {
117
+ /******/ __webpack_require__.f = {};
118
+ /******/ // This file contains only the entry chunk.
119
+ /******/ // The chunk loading function for additional chunks
120
+ /******/ __webpack_require__.e = (chunkId) => {
121
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
122
+ /******/ __webpack_require__.f[key](chunkId, promises);
123
+ /******/ return promises;
124
+ /******/ }, []));
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /******/ /* webpack/runtime/get javascript chunk filename */
129
+ /******/ (() => {
130
+ /******/ // This function allow to reference async chunks
131
+ /******/ __webpack_require__.u = (chunkId) => {
132
+ /******/ // return url for filenames based on template
133
+ /******/ return "" + chunkId + ".js";
134
+ /******/ };
135
+ /******/ })();
136
+ /******/
137
+ /******/ /* webpack/runtime/global */
138
+ /******/ (() => {
139
+ /******/ __webpack_require__.g = (function() {
140
+ /******/ if (typeof globalThis === 'object') return globalThis;
141
+ /******/ try {
142
+ /******/ return this || new Function('return this')();
143
+ /******/ } catch (e) {
144
+ /******/ if (typeof window === 'object') return window;
145
+ /******/ }
146
+ /******/ })();
147
+ /******/ })();
148
+ /******/
69
149
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
150
  /******/ (() => {
71
151
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
152
  /******/ })();
73
153
  /******/
154
+ /******/ /* webpack/runtime/load script */
155
+ /******/ (() => {
156
+ /******/ var inProgress = {};
157
+ /******/ var dataWebpackPrefix = "@tsparticles/shape-emoji:";
158
+ /******/ // loadScript function to load a script via script tag
159
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
160
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
161
+ /******/ var script, needAttach;
162
+ /******/ if(key !== undefined) {
163
+ /******/ var scripts = document.getElementsByTagName("script");
164
+ /******/ for(var i = 0; i < scripts.length; i++) {
165
+ /******/ var s = scripts[i];
166
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
167
+ /******/ }
168
+ /******/ }
169
+ /******/ if(!script) {
170
+ /******/ needAttach = true;
171
+ /******/ script = document.createElement('script');
172
+ /******/
173
+ /******/ script.charset = 'utf-8';
174
+ /******/ script.timeout = 120;
175
+ /******/ if (__webpack_require__.nc) {
176
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
177
+ /******/ }
178
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
179
+ /******/
180
+ /******/ script.src = url;
181
+ /******/ }
182
+ /******/ inProgress[url] = [done];
183
+ /******/ var onScriptComplete = (prev, event) => {
184
+ /******/ // avoid mem leaks in IE.
185
+ /******/ script.onerror = script.onload = null;
186
+ /******/ clearTimeout(timeout);
187
+ /******/ var doneFns = inProgress[url];
188
+ /******/ delete inProgress[url];
189
+ /******/ script.parentNode && script.parentNode.removeChild(script);
190
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
191
+ /******/ if(prev) return prev(event);
192
+ /******/ }
193
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
194
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
195
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
196
+ /******/ needAttach && document.head.appendChild(script);
197
+ /******/ };
198
+ /******/ })();
199
+ /******/
74
200
  /******/ /* webpack/runtime/make namespace object */
75
201
  /******/ (() => {
76
202
  /******/ // define __esModule on exports
@@ -82,119 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
82
208
  /******/ };
83
209
  /******/ })();
84
210
  /******/
211
+ /******/ /* webpack/runtime/publicPath */
212
+ /******/ (() => {
213
+ /******/ var scriptUrl;
214
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
215
+ /******/ var document = __webpack_require__.g.document;
216
+ /******/ if (!scriptUrl && document) {
217
+ /******/ if (document.currentScript)
218
+ /******/ scriptUrl = document.currentScript.src;
219
+ /******/ if (!scriptUrl) {
220
+ /******/ var scripts = document.getElementsByTagName("script");
221
+ /******/ if(scripts.length) {
222
+ /******/ var i = scripts.length - 1;
223
+ /******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
224
+ /******/ }
225
+ /******/ }
226
+ /******/ }
227
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
228
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
229
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
230
+ /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
231
+ /******/ __webpack_require__.p = scriptUrl;
232
+ /******/ })();
233
+ /******/
234
+ /******/ /* webpack/runtime/jsonp chunk loading */
235
+ /******/ (() => {
236
+ /******/ // no baseURI
237
+ /******/
238
+ /******/ // object to store loaded and loading chunks
239
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
240
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
241
+ /******/ var installedChunks = {
242
+ /******/ "tsparticles.shape.emoji": 0
243
+ /******/ };
244
+ /******/
245
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
246
+ /******/ // JSONP chunk loading for javascript
247
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
248
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
249
+ /******/
250
+ /******/ // a Promise means "currently loading".
251
+ /******/ if(installedChunkData) {
252
+ /******/ promises.push(installedChunkData[2]);
253
+ /******/ } else {
254
+ /******/ if(true) { // all chunks have JS
255
+ /******/ // setup Promise in chunk cache
256
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
257
+ /******/ promises.push(installedChunkData[2] = promise);
258
+ /******/
259
+ /******/ // start chunk loading
260
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
261
+ /******/ // create error before stack unwound to get useful stacktrace later
262
+ /******/ var error = new Error();
263
+ /******/ var loadingEnded = (event) => {
264
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
265
+ /******/ installedChunkData = installedChunks[chunkId];
266
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
267
+ /******/ if(installedChunkData) {
268
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
269
+ /******/ var realSrc = event && event.target && event.target.src;
270
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
271
+ /******/ error.name = 'ChunkLoadError';
272
+ /******/ error.type = errorType;
273
+ /******/ error.request = realSrc;
274
+ /******/ installedChunkData[1](error);
275
+ /******/ }
276
+ /******/ }
277
+ /******/ };
278
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
279
+ /******/ }
280
+ /******/ }
281
+ /******/ }
282
+ /******/ };
283
+ /******/
284
+ /******/ // no prefetching
285
+ /******/
286
+ /******/ // no preloaded
287
+ /******/
288
+ /******/ // no HMR
289
+ /******/
290
+ /******/ // no HMR manifest
291
+ /******/
292
+ /******/ // no on chunks loaded
293
+ /******/
294
+ /******/ // install a JSONP callback for chunk loading
295
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
296
+ /******/ var chunkIds = data[0];
297
+ /******/ var moreModules = data[1];
298
+ /******/ var runtime = data[2];
299
+ /******/ // add "moreModules" to the modules object,
300
+ /******/ // then flag all "chunkIds" as loaded and fire callback
301
+ /******/ var moduleId, chunkId, i = 0;
302
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
303
+ /******/ for(moduleId in moreModules) {
304
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
305
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
306
+ /******/ }
307
+ /******/ }
308
+ /******/ if(runtime) var result = runtime(__webpack_require__);
309
+ /******/ }
310
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
311
+ /******/ for(;i < chunkIds.length; i++) {
312
+ /******/ chunkId = chunkIds[i];
313
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
314
+ /******/ installedChunks[chunkId][0]();
315
+ /******/ }
316
+ /******/ installedChunks[chunkId] = 0;
317
+ /******/ }
318
+ /******/
319
+ /******/ }
320
+ /******/
321
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_shape_emoji"] = this["webpackChunk_tsparticles_shape_emoji"] || [];
322
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
323
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
324
+ /******/ })();
325
+ /******/
85
326
  /************************************************************************/
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
- loadEmojiShape: () => (/* binding */ loadEmojiShape)
95
- });
96
-
97
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
- var engine_root_window_ = __webpack_require__(533);
99
- ;// CONCATENATED MODULE: ./dist/browser/EmojiDrawer.js
100
-
101
- const validTypes = ["emoji"];
102
- const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
103
- class EmojiDrawer {
104
- constructor() {
105
- this._emojiShapeDict = new Map();
106
- }
107
- destroy() {
108
- for (const [key, emojiData] of this._emojiShapeDict) {
109
- emojiData instanceof ImageBitmap && emojiData?.close();
110
- this._emojiShapeDict.delete(key);
111
- }
112
- }
113
- draw(data) {
114
- const {
115
- context,
116
- particle,
117
- radius,
118
- opacity
119
- } = data,
120
- emojiData = particle.emojiData;
121
- if (!emojiData) {
122
- return;
123
- }
124
- context.globalAlpha = opacity;
125
- context.drawImage(emojiData, -radius, -radius, radius * 2, radius * 2);
126
- context.globalAlpha = 1;
127
- }
128
- async init(container) {
129
- const options = container.actualOptions;
130
- if (validTypes.find(t => (0,engine_root_window_.isInArray)(t, options.particles.shape.type))) {
131
- const promises = [(0,engine_root_window_.loadFont)(defaultFont)],
132
- shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t);
133
- if (shapeOptions) {
134
- (0,engine_root_window_.executeOnSingleOrMultiple)(shapeOptions, shape => {
135
- shape.font && promises.push((0,engine_root_window_.loadFont)(shape.font));
136
- });
137
- }
138
- await Promise.all(promises);
139
- }
140
- }
141
- particleDestroy(particle) {
142
- delete particle.emojiData;
143
- }
144
- particleInit(container, particle) {
145
- const shapeData = particle.shapeData;
146
- if (!shapeData?.value) {
147
- return;
148
- }
149
- const emoji = (0,engine_root_window_.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData),
150
- font = shapeData.font ?? defaultFont;
151
- if (!emoji) {
152
- return;
153
- }
154
- const key = `${emoji}_${font}`,
155
- existingData = this._emojiShapeDict.get(key);
156
- if (existingData) {
157
- particle.emojiData = existingData;
158
- return;
159
- }
160
- const canvasSize = (0,engine_root_window_.getRangeMax)(particle.size.value) * 2;
161
- let emojiData;
162
- if (typeof OffscreenCanvas !== "undefined") {
163
- const canvas = new OffscreenCanvas(canvasSize, canvasSize),
164
- context = canvas.getContext("2d");
165
- if (!context) {
166
- return;
167
- }
168
- context.font = `400 ${(0,engine_root_window_.getRangeMax)(particle.size.value) * 2}px ${font}`;
169
- context.textBaseline = "middle";
170
- context.textAlign = "center";
171
- context.fillText(emoji, (0,engine_root_window_.getRangeMax)(particle.size.value), (0,engine_root_window_.getRangeMax)(particle.size.value));
172
- emojiData = canvas.transferToImageBitmap();
173
- } else {
174
- const canvas = document.createElement("canvas");
175
- canvas.width = canvasSize;
176
- canvas.height = canvasSize;
177
- const context = canvas.getContext("2d");
178
- if (!context) {
179
- return;
180
- }
181
- context.font = `400 ${(0,engine_root_window_.getRangeMax)(particle.size.value) * 2}px ${font}`;
182
- context.textBaseline = "middle";
183
- context.textAlign = "center";
184
- context.fillText(emoji, (0,engine_root_window_.getRangeMax)(particle.size.value), (0,engine_root_window_.getRangeMax)(particle.size.value));
185
- emojiData = canvas;
186
- }
187
- this._emojiShapeDict.set(key, emojiData);
188
- particle.emojiData = emojiData;
189
- }
190
- }
191
- ;// CONCATENATED MODULE: ./dist/browser/index.js
192
-
193
- async function loadEmojiShape(engine, refresh = true) {
194
- await engine.addShape(validTypes, new EmojiDrawer(), refresh);
195
- }
196
- })();
197
-
327
+ /******/
328
+ /******/ // startup
329
+ /******/ // Load entry module and return exports
330
+ /******/ // This entry module can't be inlined because the eval devtool is used.
331
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
332
+ /******/
198
333
  /******/ return __webpack_exports__;
199
334
  /******/ })()
200
335
  ;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.emoji.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var a in o)("object"==typeof exports?exports:e)[a]=o[a]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function a(e){var i=o[e];if(void 0!==i)return i.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,a),n.exports}a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{a.r(i),a.d(i,{loadEmojiShape:()=>r});var e=a(533);const t=["emoji"],o='"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';class n{constructor(){this._emojiShapeDict=new Map}destroy(){for(const[e,t]of this._emojiShapeDict)t instanceof ImageBitmap&&t?.close(),this._emojiShapeDict.delete(e)}draw(e){const{context:t,particle:o,radius:a,opacity:i}=e,n=o.emojiData;n&&(t.globalAlpha=i,t.drawImage(n,-a,-a,2*a,2*a),t.globalAlpha=1)}async init(a){const i=a.actualOptions;if(t.find((t=>(0,e.isInArray)(t,i.particles.shape.type)))){const a=[(0,e.loadFont)(o)],n=t.map((e=>i.particles.shape.options[e])).find((e=>!!e));n&&(0,e.executeOnSingleOrMultiple)(n,(t=>{t.font&&a.push((0,e.loadFont)(t.font))})),await Promise.all(a)}}particleDestroy(e){delete e.emojiData}particleInit(t,a){const i=a.shapeData;if(!i?.value)return;const n=(0,e.itemFromSingleOrMultiple)(i.value,a.randomIndexData),r=i.font??o;if(!n)return;const s=`${n}_${r}`,l=this._emojiShapeDict.get(s);if(l)return void(a.emojiData=l);const p=2*(0,e.getRangeMax)(a.size.value);let c;if("undefined"!=typeof OffscreenCanvas){const t=new OffscreenCanvas(p,p),o=t.getContext("2d");if(!o)return;o.font=`400 ${2*(0,e.getRangeMax)(a.size.value)}px ${r}`,o.textBaseline="middle",o.textAlign="center",o.fillText(n,(0,e.getRangeMax)(a.size.value),(0,e.getRangeMax)(a.size.value)),c=t.transferToImageBitmap()}else{const t=document.createElement("canvas");t.width=p,t.height=p;const o=t.getContext("2d");if(!o)return;o.font=`400 ${2*(0,e.getRangeMax)(a.size.value)}px ${r}`,o.textBaseline="middle",o.textAlign="center",o.fillText(n,(0,e.getRangeMax)(a.size.value),(0,e.getRangeMax)(a.size.value)),c=t}this._emojiShapeDict.set(s,c),a.emojiData=c}}async function r(e,o=!0){await e.addShape(t,new n,o)}})(),i})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={305:(e,t,r)=>{r.d(t,{h:()=>o});const o=["emoji"]},533:t=>{t.exports=e}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/shape-emoji:",i.l=(e,o,n,a)=>{if(t[e])t[e].push(o);else{var s,c;if(void 0!==n)for(var p=document.getElementsByTagName("script"),l=0;l<p.length;l++){var u=p[l];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+n){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,i.nc&&s.setAttribute("nonce",i.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var d=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),c&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={938:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,a=r[0],s=r[1],c=r[2],p=0;if(a.some((t=>0!==e[t]))){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);if(c)c(i)}for(t&&t(r);p<a.length;p++)n=a[p],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_shape_emoji=this.webpackChunk_tsparticles_shape_emoji||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};return(()=>{i.r(a),i.d(a,{loadEmojiShape:()=>t});var e=i(305);async function t(t,r=!0){const{EmojiDrawer:o}=await i.e(216).then(i.bind(i,216));await t.addShape(e.h,new o,r)}})(),a})()));
@@ -1 +1 @@
1
- /*! tsParticles Emoji Shape v3.0.3 by Matteo Bruni */
1
+ /*! tsParticles Emoji Shape v3.2.0 by Matteo Bruni */
@@ -0,0 +1 @@
1
+ export declare const validTypes: string[];
@@ -1,11 +1,10 @@
1
1
  import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
2
2
  import type { EmojiParticle } from "./EmojiParticle.js";
3
- export declare const validTypes: string[];
4
3
  export declare class EmojiDrawer implements IShapeDrawer<EmojiParticle> {
5
4
  private readonly _emojiShapeDict;
6
5
  destroy(): void;
7
- draw(data: IShapeDrawData<EmojiParticle>): void;
6
+ draw(data: IShapeDrawData<EmojiParticle>): Promise<void>;
8
7
  init(container: Container): Promise<void>;
9
8
  particleDestroy(particle: EmojiParticle): void;
10
- particleInit(container: Container, particle: EmojiParticle): void;
9
+ particleInit(container: Container, particle: EmojiParticle): Promise<void>;
11
10
  }
@@ -0,0 +1,3 @@
1
+ import type { EmojiParticle } from "./EmojiParticle.js";
2
+ import type { IShapeDrawData } from "@tsparticles/engine";
3
+ export declare function drawEmoji(data: IShapeDrawData<EmojiParticle>): void;
@@ -0,0 +1,14 @@
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.validTypes = void 0;
13
+ exports.validTypes = ["emoji"];
14
+ });
@@ -1,17 +1,41 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
4
27
  if (v !== undefined) module.exports = v;
5
28
  }
6
29
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
30
+ define(["require", "exports", "@tsparticles/engine", "./Constants.js"], factory);
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.EmojiDrawer = exports.validTypes = void 0;
36
+ exports.EmojiDrawer = void 0;
13
37
  const engine_1 = require("@tsparticles/engine");
14
- exports.validTypes = ["emoji"];
38
+ const Constants_js_1 = require("./Constants.js");
15
39
  const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
16
40
  class EmojiDrawer {
17
41
  constructor() {
@@ -19,38 +43,38 @@
19
43
  }
20
44
  destroy() {
21
45
  for (const [key, emojiData] of this._emojiShapeDict) {
22
- emojiData instanceof ImageBitmap && emojiData?.close();
23
- this._emojiShapeDict.delete(key);
46
+ if (emojiData instanceof ImageBitmap) {
47
+ emojiData?.close();
48
+ this._emojiShapeDict.delete(key);
49
+ }
24
50
  }
25
51
  }
26
- draw(data) {
27
- const { context, particle, radius, opacity } = data, emojiData = particle.emojiData;
28
- if (!emojiData) {
29
- return;
30
- }
31
- context.globalAlpha = opacity;
32
- context.drawImage(emojiData, -radius, -radius, radius * 2, radius * 2);
33
- context.globalAlpha = 1;
52
+ async draw(data) {
53
+ const { drawEmoji } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar));
54
+ drawEmoji(data);
34
55
  }
35
56
  async init(container) {
36
57
  const options = container.actualOptions;
37
- if (exports.validTypes.find((t) => (0, engine_1.isInArray)(t, options.particles.shape.type))) {
38
- const promises = [(0, engine_1.loadFont)(defaultFont)], shapeOptions = exports.validTypes
39
- .map((t) => options.particles.shape.options[t])
40
- .find((t) => !!t);
41
- if (shapeOptions) {
42
- (0, engine_1.executeOnSingleOrMultiple)(shapeOptions, (shape) => {
43
- shape.font && promises.push((0, engine_1.loadFont)(shape.font));
44
- });
45
- }
46
- await Promise.all(promises);
58
+ if (!Constants_js_1.validTypes.find((t) => (0, engine_1.isInArray)(t, options.particles.shape.type))) {
59
+ return;
60
+ }
61
+ const promises = [(0, engine_1.loadFont)(defaultFont)], shapeOptions = Constants_js_1.validTypes
62
+ .map((t) => options.particles.shape.options[t])
63
+ .find((t) => !!t);
64
+ if (shapeOptions) {
65
+ (0, engine_1.executeOnSingleOrMultiple)(shapeOptions, (shape) => {
66
+ if (shape.font) {
67
+ promises.push((0, engine_1.loadFont)(shape.font));
68
+ }
69
+ });
47
70
  }
71
+ await Promise.all(promises);
48
72
  }
49
73
  particleDestroy(particle) {
50
74
  delete particle.emojiData;
51
75
  }
52
- particleInit(container, particle) {
53
- const shapeData = particle.shapeData;
76
+ async particleInit(container, particle) {
77
+ const double = 2, shapeData = particle.shapeData;
54
78
  if (!shapeData?.value) {
55
79
  return;
56
80
  }
@@ -63,17 +87,18 @@
63
87
  particle.emojiData = existingData;
64
88
  return;
65
89
  }
66
- const canvasSize = (0, engine_1.getRangeMax)(particle.size.value) * 2;
90
+ const canvasSize = (0, engine_1.getRangeMax)(particle.size.value) * double;
67
91
  let emojiData;
92
+ const maxSize = (0, engine_1.getRangeMax)(particle.size.value);
68
93
  if (typeof OffscreenCanvas !== "undefined") {
69
94
  const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
70
95
  if (!context) {
71
96
  return;
72
97
  }
73
- context.font = `400 ${(0, engine_1.getRangeMax)(particle.size.value) * 2}px ${font}`;
98
+ context.font = `400 ${maxSize * double}px ${font}`;
74
99
  context.textBaseline = "middle";
75
100
  context.textAlign = "center";
76
- context.fillText(emoji, (0, engine_1.getRangeMax)(particle.size.value), (0, engine_1.getRangeMax)(particle.size.value));
101
+ context.fillText(emoji, maxSize, maxSize);
77
102
  emojiData = canvas.transferToImageBitmap();
78
103
  }
79
104
  else {
@@ -84,14 +109,15 @@
84
109
  if (!context) {
85
110
  return;
86
111
  }
87
- context.font = `400 ${(0, engine_1.getRangeMax)(particle.size.value) * 2}px ${font}`;
112
+ context.font = `400 ${maxSize * double}px ${font}`;
88
113
  context.textBaseline = "middle";
89
114
  context.textAlign = "center";
90
- context.fillText(emoji, (0, engine_1.getRangeMax)(particle.size.value), (0, engine_1.getRangeMax)(particle.size.value));
115
+ context.fillText(emoji, maxSize, maxSize);
91
116
  emojiData = canvas;
92
117
  }
93
118
  this._emojiShapeDict.set(key, emojiData);
94
119
  particle.emojiData = emojiData;
120
+ await Promise.resolve();
95
121
  }
96
122
  }
97
123
  exports.EmojiDrawer = EmojiDrawer;
package/umd/Utils.js ADDED
@@ -0,0 +1,23 @@
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.drawEmoji = void 0;
13
+ function drawEmoji(data) {
14
+ const { context, particle, radius, opacity } = data, emojiData = particle.emojiData, double = 2, diameter = radius * double, previousAlpha = context.globalAlpha;
15
+ if (!emojiData) {
16
+ return;
17
+ }
18
+ context.globalAlpha = opacity;
19
+ context.drawImage(emojiData, -radius, -radius, diameter, diameter);
20
+ context.globalAlpha = previousAlpha;
21
+ }
22
+ exports.drawEmoji = drawEmoji;
23
+ });