@tsparticles/shape-text 4.0.0-beta.1 → 4.0.0-beta.3
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/index.js +2 -1
- package/cjs/index.js +2 -1
- package/dist_browser_TextDrawer_js.js +1 -1
- package/esm/index.js +2 -1
- package/package.json +3 -4
- package/report.html +1 -1
- package/tsparticles.shape.text.js +2 -2
- package/tsparticles.shape.text.min.js +1 -1
- package/umd/ITextShape.js +0 -12
- package/umd/TextDrawer.js +0 -52
- package/umd/TextParticle.js +0 -12
- package/umd/Utils.js +0 -55
- package/umd/index.js +0 -57
package/browser/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import {} from "@tsparticles/engine";
|
|
1
2
|
import { validTypes } from "./Utils.js";
|
|
2
3
|
export async function loadTextShape(engine) {
|
|
3
|
-
engine.checkVersion("4.0.0-beta.
|
|
4
|
+
engine.checkVersion("4.0.0-beta.3");
|
|
4
5
|
await engine.pluginManager.register(e => {
|
|
5
6
|
e.pluginManager.addShape(validTypes, async () => {
|
|
6
7
|
const { TextDrawer } = await import("./TextDrawer.js");
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import {} from "@tsparticles/engine";
|
|
1
2
|
import { validTypes } from "./Utils.js";
|
|
2
3
|
export async function loadTextShape(engine) {
|
|
3
|
-
engine.checkVersion("4.0.0-beta.
|
|
4
|
+
engine.checkVersion("4.0.0-beta.3");
|
|
4
5
|
await engine.pluginManager.register(e => {
|
|
5
6
|
e.pluginManager.addShape(validTypes, async () => {
|
|
6
7
|
const { TextDrawer } = await import("./TextDrawer.js");
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import {} from "@tsparticles/engine";
|
|
1
2
|
import { validTypes } from "./Utils.js";
|
|
2
3
|
export async function loadTextShape(engine) {
|
|
3
|
-
engine.checkVersion("4.0.0-beta.
|
|
4
|
+
engine.checkVersion("4.0.0-beta.3");
|
|
4
5
|
await engine.pluginManager.register(e => {
|
|
5
6
|
e.pluginManager.addShape(validTypes, async () => {
|
|
6
7
|
const { TextDrawer } = await import("./TextDrawer.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-text",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "tsParticles text shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -53,12 +53,11 @@
|
|
|
53
53
|
"browser": "./browser/index.js",
|
|
54
54
|
"import": "./esm/index.js",
|
|
55
55
|
"require": "./cjs/index.js",
|
|
56
|
-
"
|
|
57
|
-
"default": "./cjs/index.js"
|
|
56
|
+
"default": "./esm/index.js"
|
|
58
57
|
},
|
|
59
58
|
"./package.json": "./package.json"
|
|
60
59
|
},
|
|
61
|
-
"
|
|
60
|
+
"peerDependencies": {
|
|
62
61
|
"@tsparticles/canvas-utils": "4.0.0-beta.1",
|
|
63
62
|
"@tsparticles/engine": "4.0.0-beta.1"
|
|
64
63
|
},
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>@tsparticles/shape-text [
|
|
6
|
+
<title>@tsparticles/shape-text [2 Apr 2026 at 08:13]</title>
|
|
7
7
|
<link
|
|
8
8
|
rel="shortcut icon"
|
|
9
9
|
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+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ORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII="
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
* v4.0.0-beta.
|
|
7
|
+
* v4.0.0-beta.3
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -64,7 +64,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
64
64
|
\*******************************/
|
|
65
65
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
66
66
|
|
|
67
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTextShape: () => (/* binding */ loadTextShape)\n/* harmony export */ });\n/* harmony import */ var
|
|
67
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTextShape: () => (/* binding */ loadTextShape)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nasync function loadTextShape(engine) {\n engine.checkVersion(\"4.0.0-beta.3\");\n await engine.pluginManager.register((e)=>{\n e.pluginManager.addShape(_Utils_js__WEBPACK_IMPORTED_MODULE_1__.validTypes, async ()=>{\n const { TextDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_TextDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TextDrawer.js */ \"./dist/browser/TextDrawer.js\"));\n return new TextDrawer();\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-text/./dist/browser/index.js?\n}");
|
|
68
68
|
|
|
69
69
|
/***/ }
|
|
70
70
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/canvas-utils"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/canvas-utils"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/canvas-utils")):t(e.window,e.window);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e,t)=>(()=>{"use strict";var r,n,a,i={425(e){e.exports=t},303(t){t.exports=e},131(e,t,r){r.d(t,{m:()=>i,u:()=>a});var n=r(303);let a=["text","character","char","multiline-text"];function i(e){let{context:t,particle:r,fill:a,stroke:i,radius:o,opacity:l}=e,s=r.shapeData;if(!s)return;let p=s.value;if(r.textLines??=(0,n.itemFromSingleOrMultiple)(p,r.randomIndexData)?.split(`
|
|
2
2
|
`)??[],r.maxTextLength??=r.textLines.length?Math.max(...r.textLines.map(e=>e.length)):r.textLines[0]?.length??0,!r.textLines.length||!r.maxTextLength)return;let c=r.textLines,u=s.style??"",h=s.weight??"400",d=s.font??"Verdana",f=Math.round(o)*n.double/(c.length*r.maxTextLength);t.font=`${u} ${h} ${f.toString()}px "${d}"`;let g=t.globalAlpha;t.globalAlpha=l;for(let e=0;e<c.length;e++){let r=c[e];r&&function(e,t,r,a,i,o){let l={x:-(t.length*r*n.half),y:r*n.half+a*r};i&&e.fillText(t,l.x,l.y),o&&e.strokeText(t,l.x,l.y)}(t,r,f,e,a,i)}t.globalAlpha=g}}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return i[e](r,r.exports,l),r.exports}l.m=i,l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>""+e+".min.js",l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},l.l=(e,t,r,n)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var a,i,o=document.getElementsByTagName("script"),p=0;p<o.length;p++){var c=o[p];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/shape-text:"+r){a=c;break}}a||(i=!0,(a=document.createElement("script")).charset="utf-8",l.nc&&a.setAttribute("nonce",l.nc),a.setAttribute("data-webpack","@tsparticles/shape-text:"+r),a.src=e),s[e]=[t];var u=(t,r)=>{a.onerror=a.onload=null,clearTimeout(h);var n=s[e];if(delete s[e],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach(e=>e(r)),t)return t(r)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=u.bind(null,a.onerror),a.onload=u.bind(null,a.onload),i&&document.head.appendChild(a)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(p=l.g.location+"");var s,p,c=l.g.document;if(!p&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(p=c.currentScript.src),!p)){var u=c.getElementsByTagName("script");if(u.length)for(var h=u.length-1;h>-1&&(!p||!/^http(s?):/.test(p));)p=u[h--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");l.p=p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={973:0},l.f.j=(e,t)=>{var n=l.o(r,e)?r[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var a=new Promise((t,a)=>n=r[e]=[t,a]);t.push(n[2]=a);var i=l.p+l.u(e),o=Error();l.l(i,t=>{if(l.o(r,e)&&(0!==(n=r[e])&&(r[e]=void 0),n)){var a=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;o.message="Loading chunk "+e+` failed.
|
|
3
|
-
(`+a+": "+i+")",o.name="ChunkLoadError",o.type=a,o.request=i,n[1](o)}},"chunk-"+e,e)}},n=(e,t)=>{var n,a,[i,o,s]=t,p=0;if(i.some(e=>0!==r[e])){for(n in o)l.o(o,n)&&(l.m[n]=o[n]);s&&s(l)}for(e&&e(t);p<i.length;p++)a=i[p],l.o(r,a)&&r[a]&&r[a][0](),r[a]=0},(a=this.webpackChunk_tsparticles_shape_text=this.webpackChunk_tsparticles_shape_text||[]).forEach(n.bind(null,0)),a.push=n.bind(null,a.push.bind(a));var d={};l.r(d),l.d(d,{loadTextShape:()=>g});var f=l(131);async function g(e){e.checkVersion("4.0.0-beta.
|
|
3
|
+
(`+a+": "+i+")",o.name="ChunkLoadError",o.type=a,o.request=i,n[1](o)}},"chunk-"+e,e)}},n=(e,t)=>{var n,a,[i,o,s]=t,p=0;if(i.some(e=>0!==r[e])){for(n in o)l.o(o,n)&&(l.m[n]=o[n]);s&&s(l)}for(e&&e(t);p<i.length;p++)a=i[p],l.o(r,a)&&r[a]&&r[a][0](),r[a]=0},(a=this.webpackChunk_tsparticles_shape_text=this.webpackChunk_tsparticles_shape_text||[]).forEach(n.bind(null,0)),a.push=n.bind(null,a.push.bind(a));var d={};l.r(d),l.d(d,{loadTextShape:()=>g}),l(303);var f=l(131);async function g(e){e.checkVersion("4.0.0-beta.3"),await e.pluginManager.register(e=>{e.pluginManager.addShape(f.u,async()=>{let{TextDrawer:e}=await l.e(834).then(l.bind(l,834));return new e})})}return d})());
|
package/umd/ITextShape.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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/TextDrawer.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
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", "./Utils.js", "@tsparticles/canvas-utils"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TextDrawer = void 0;
|
|
13
|
-
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const Utils_js_1 = require("./Utils.js");
|
|
15
|
-
const canvas_utils_1 = require("@tsparticles/canvas-utils");
|
|
16
|
-
const firstIndex = 0, minLength = 0;
|
|
17
|
-
class TextDrawer {
|
|
18
|
-
draw(data) {
|
|
19
|
-
(0, Utils_js_1.drawText)(data);
|
|
20
|
-
}
|
|
21
|
-
async init(container) {
|
|
22
|
-
const options = container.actualOptions;
|
|
23
|
-
if (Utils_js_1.validTypes.find(t => (0, engine_1.isInArray)(t, options.particles.shape.type))) {
|
|
24
|
-
const shapeOptions = Utils_js_1.validTypes
|
|
25
|
-
.map(t => options.particles.shape.options[t])
|
|
26
|
-
.find(t => !!t), promises = [];
|
|
27
|
-
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions, shape => {
|
|
28
|
-
promises.push((0, canvas_utils_1.loadFont)(shape.font, shape.weight));
|
|
29
|
-
});
|
|
30
|
-
await Promise.all(promises);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
particleInit(_container, particle) {
|
|
34
|
-
if (!particle.shape || !Utils_js_1.validTypes.includes(particle.shape)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const character = particle.shapeData;
|
|
38
|
-
if (character === undefined) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const textData = character.value;
|
|
42
|
-
if (!textData) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
particle.textLines = (0, engine_1.itemFromSingleOrMultiple)(textData, particle.randomIndexData)?.split("\n") ?? [];
|
|
46
|
-
particle.maxTextLength = particle.textLines.length
|
|
47
|
-
? Math.max(...particle.textLines.map(t => t.length))
|
|
48
|
-
: (particle.textLines[firstIndex]?.length ?? minLength);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.TextDrawer = TextDrawer;
|
|
52
|
-
});
|
package/umd/TextParticle.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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/Utils.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validTypes = void 0;
|
|
13
|
-
exports.drawText = drawText;
|
|
14
|
-
const engine_1 = require("@tsparticles/engine");
|
|
15
|
-
exports.validTypes = ["text", "character", "char", "multiline-text"];
|
|
16
|
-
const firstIndex = 0, minLength = 0;
|
|
17
|
-
function drawText(data) {
|
|
18
|
-
const { context, particle, fill, stroke, radius, opacity } = data, character = particle.shapeData;
|
|
19
|
-
if (!character) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const textData = character.value;
|
|
23
|
-
particle.textLines ??= (0, engine_1.itemFromSingleOrMultiple)(textData, particle.randomIndexData)?.split("\n") ?? [];
|
|
24
|
-
particle.maxTextLength ??= particle.textLines.length
|
|
25
|
-
? Math.max(...particle.textLines.map(t => t.length))
|
|
26
|
-
: (particle.textLines[firstIndex]?.length ?? minLength);
|
|
27
|
-
if (!particle.textLines.length || !particle.maxTextLength) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const lines = particle.textLines, style = character.style ?? "", weight = character.weight ?? "400", font = character.font ?? "Verdana", size = (Math.round(radius) * engine_1.double) / (lines.length * particle.maxTextLength);
|
|
31
|
-
context.font = `${style} ${weight} ${size.toString()}px "${font}"`;
|
|
32
|
-
const originalGlobalAlpha = context.globalAlpha;
|
|
33
|
-
context.globalAlpha = opacity;
|
|
34
|
-
for (let i = 0; i < lines.length; i++) {
|
|
35
|
-
const currentLine = lines[i];
|
|
36
|
-
if (!currentLine) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
drawTextLine(context, currentLine, size, i, fill, stroke);
|
|
40
|
-
}
|
|
41
|
-
context.globalAlpha = originalGlobalAlpha;
|
|
42
|
-
}
|
|
43
|
-
function drawTextLine(context, line, size, index, fill, stroke) {
|
|
44
|
-
const pos = {
|
|
45
|
-
x: -(line.length * size * engine_1.half),
|
|
46
|
-
y: size * engine_1.half + index * size,
|
|
47
|
-
};
|
|
48
|
-
if (fill) {
|
|
49
|
-
context.fillText(line, pos.x, pos.y);
|
|
50
|
-
}
|
|
51
|
-
if (stroke) {
|
|
52
|
-
context.strokeText(line, pos.x, pos.y);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
package/umd/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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 () {
|
|
18
|
-
var ownKeys = function(o) {
|
|
19
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
-
var ar = [];
|
|
21
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
-
return ar;
|
|
23
|
-
};
|
|
24
|
-
return ownKeys(o);
|
|
25
|
-
};
|
|
26
|
-
return function (mod) {
|
|
27
|
-
if (mod && mod.__esModule) return mod;
|
|
28
|
-
var result = {};
|
|
29
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
-
__setModuleDefault(result, mod);
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
|
-
(function (factory) {
|
|
35
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
36
|
-
var v = factory(require, exports);
|
|
37
|
-
if (v !== undefined) module.exports = v;
|
|
38
|
-
}
|
|
39
|
-
else if (typeof define === "function" && define.amd) {
|
|
40
|
-
define(["require", "exports", "./Utils.js"], factory);
|
|
41
|
-
}
|
|
42
|
-
})(function (require, exports) {
|
|
43
|
-
"use strict";
|
|
44
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.loadTextShape = loadTextShape;
|
|
47
|
-
const Utils_js_1 = require("./Utils.js");
|
|
48
|
-
async function loadTextShape(engine) {
|
|
49
|
-
engine.checkVersion("4.0.0-beta.1");
|
|
50
|
-
await engine.pluginManager.register(e => {
|
|
51
|
-
e.pluginManager.addShape(Utils_js_1.validTypes, async () => {
|
|
52
|
-
const { TextDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TextDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./TextDrawer.js"], resolve_1, reject_1); }).then(__importStar));
|
|
53
|
-
return new TextDrawer();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|