From acbb24a1db9762946deb8e2b8e8f50b5c2ec3264 Mon Sep 17 00:00:00 2001 From: Yuan Date: Tue, 12 Dec 2023 17:39:01 +0800 Subject: [PATCH] =?UTF-8?q?target=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 2002 ++++++++++++++++++++++++++++++++++++++++--------- tsconfig.json | 4 +- 2 files changed, 1633 insertions(+), 373 deletions(-) diff --git a/lib/index.js b/lib/index.js index af43ef5..1602b9e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,13 +4,55 @@ import { Viewport } from 'pixi-viewport'; import { Client } from '@stomp/stompjs'; import mqtt from 'mqtt'; +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + /** * ID生成器 */ class IdGenerator { - serial = 0; - type; constructor(type) { + Object.defineProperty(this, "serial", { + enumerable: true, + configurable: true, + writable: true, + value: 0 + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.type = type; } next() { @@ -33,11 +75,31 @@ var InteractionPluginType; InteractionPluginType["Other"] = "other"; })(InteractionPluginType || (InteractionPluginType = {})); class InteractionPluginBase { - _type; - name; // 唯一标识 - app; - _pause; constructor(app, name, type) { + Object.defineProperty(this, "_type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "name", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 唯一标识 + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_pause", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this._type = type; this.app = app; this.name = name; @@ -82,12 +144,37 @@ class OtherInteractionPlugin extends InteractionPluginBase { } } class AppDragEvent { - app; - type; - target; - original; - start; // 画布坐标 constructor(app, type, target, original, start) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "target", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "original", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "start", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 画布坐标 this.app = app; this.type = type; this.target = target; @@ -148,14 +235,38 @@ class AppDragEvent { * 拖拽操作插件 */ class DragPlugin extends OtherInteractionPlugin { - static Name = '__drag_operation_plugin'; - threshold = 3; - target = null; - start = null; - startClientPoint = null; - drag = false; constructor(app) { super(app, DragPlugin.Name); + Object.defineProperty(this, "threshold", { + enumerable: true, + configurable: true, + writable: true, + value: 3 + }); + Object.defineProperty(this, "target", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); + Object.defineProperty(this, "start", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); + Object.defineProperty(this, "startClientPoint", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); + Object.defineProperty(this, "drag", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); app.on('options-update', (options) => { if (options.threshold !== undefined) { this.threshold = options.threshold; @@ -237,19 +348,36 @@ class DragPlugin extends OtherInteractionPlugin { this.target = null; } } +Object.defineProperty(DragPlugin, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: '__drag_operation_plugin' +}); /** * 视口移动插件 */ class ViewportMovePlugin extends OtherInteractionPlugin { - static Name = '__viewport_move_plugin'; - static MoveInterval = 20; // 移动间隔,单位ms - static TriggerRange = 100; // 边界触发范围,单位px - static DefaultMoveSpeed = 200 / ViewportMovePlugin.MoveInterval; // 默认移动速度 - moveHandler = null; - moveSpeedx = 0; - moveSpeedy = 0; constructor(app) { super(app, ViewportMovePlugin.Name); + Object.defineProperty(this, "moveHandler", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); + Object.defineProperty(this, "moveSpeedx", { + enumerable: true, + configurable: true, + writable: true, + value: 0 + }); + Object.defineProperty(this, "moveSpeedy", { + enumerable: true, + configurable: true, + writable: true, + value: 0 + }); } static new(app) { return new ViewportMovePlugin(app); @@ -323,6 +451,30 @@ class ViewportMovePlugin extends OtherInteractionPlugin { } } } +Object.defineProperty(ViewportMovePlugin, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: '__viewport_move_plugin' +}); +Object.defineProperty(ViewportMovePlugin, "MoveInterval", { + enumerable: true, + configurable: true, + writable: true, + value: 20 +}); // 移动间隔,单位ms +Object.defineProperty(ViewportMovePlugin, "TriggerRange", { + enumerable: true, + configurable: true, + writable: true, + value: 100 +}); // 边界触发范围,单位px +Object.defineProperty(ViewportMovePlugin, "DefaultMoveSpeed", { + enumerable: true, + configurable: true, + writable: true, + value: 200 / ViewportMovePlugin.MoveInterval +}); // 默认移动速度 /** * 应用交互插件,同时只能生效一个 */ @@ -342,11 +494,31 @@ class AppInteractionPlugin extends InteractionPluginBase { * 图形交互插件,可同时生效 */ class GraphicInteractionPlugin { - _type = InteractionPluginType.Graphic; - app; - name; // 唯一标识 - _pause; constructor(name, app) { + Object.defineProperty(this, "_type", { + enumerable: true, + configurable: true, + writable: true, + value: InteractionPluginType.Graphic + }); + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "name", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 唯一标识 + Object.defineProperty(this, "_pause", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.app = app; this.name = name; this._pause = true; @@ -401,12 +573,37 @@ class GraphicInteractionPlugin { } class CompleteMouseToolOptions { - boxSelect; - viewportDrag; - viewportDragLeft; - wheelZoom; - selectFilter; constructor() { + Object.defineProperty(this, "boxSelect", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "viewportDrag", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "viewportDragLeft", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "wheelZoom", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "selectFilter", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.boxSelect = true; this.viewportDrag = true; this.wheelZoom = true; @@ -432,16 +629,44 @@ class CompleteMouseToolOptions { * 通用交互工具 */ class CommonMouseTool extends AppInteractionPlugin { - static Name = 'mouse-tool'; - static SelectBox = '__select_box'; - options; - box; - leftDownTarget = null; - drag = false; - graphicSelect = false; - rightTarget = null; constructor(scene) { super(CommonMouseTool.Name, scene); + Object.defineProperty(this, "options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "box", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "leftDownTarget", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); + Object.defineProperty(this, "drag", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "graphicSelect", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "rightTarget", { + enumerable: true, + configurable: true, + writable: true, + value: null + }); this.options = new CompleteMouseToolOptions(); this.box = new Graphics(); this.box.name = CommonMouseTool.SelectBox; @@ -697,15 +922,32 @@ class CommonMouseTool extends AppInteractionPlugin { app.updateSelected(...selects); } } +Object.defineProperty(CommonMouseTool, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: 'mouse-tool' +}); +Object.defineProperty(CommonMouseTool, "SelectBox", { + enumerable: true, + configurable: true, + writable: true, + value: '__select_box' +}); let target; class GlobalKeyboardHelper { - appKeyboardPluginMap = []; constructor() { + Object.defineProperty(this, "appKeyboardPluginMap", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); window.onkeydown = (e) => { this.appKeyboardPluginMap.forEach((plugin) => { const listenerMap = plugin.getKeyListener(e); - listenerMap?.forEach((listener) => { + listenerMap === null || listenerMap === void 0 ? void 0 : listenerMap.forEach((listener) => { if (listener.global) { listener.press(e, plugin.app); } @@ -731,7 +973,7 @@ class GlobalKeyboardHelper { window.onkeyup = (e) => { this.appKeyboardPluginMap.forEach((plugin) => { const listenerMap = plugin.getKeyListener(e); - listenerMap?.forEach((listener) => { + listenerMap === null || listenerMap === void 0 ? void 0 : listenerMap.forEach((listener) => { if (listener.global) { listener.release(e, plugin.app); } @@ -753,13 +995,28 @@ class GlobalKeyboardHelper { } const GlobalKeyboardPlugin = new GlobalKeyboardHelper(); class JlGraphicAppKeyboardPlugin { - app; - /** - * 结构为Map> - */ - keyListenerMap = new Map(); // 键值监听map - keyListenerStackMap = new Map(); // 键值监听栈(多次注册相同的监听会把之前注册的监听器入栈,移除最新的监听会从栈中弹出一个作为指定事件监听处理器) constructor(app) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 结构为Map> + */ + Object.defineProperty(this, "keyListenerMap", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); // 键值监听map + Object.defineProperty(this, "keyListenerStackMap", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); // 键值监听栈(多次注册相同的监听会把之前注册的监听器入栈,移除最新的监听会从栈中弹出一个作为指定事件监听处理器) this.app = app; GlobalKeyboardPlugin.registerGAKPlugin(this); const onMouseUpdateTarget = (e) => { @@ -767,10 +1024,11 @@ class JlGraphicAppKeyboardPlugin { target = node; }; const keydownHandle = (e) => { + var _a; // console.debug(e.key, e.code, e.keyCode); - if (target && target == this.app.dom?.getElementsByTagName('canvas')[0]) { + if (target && target == ((_a = this.app.dom) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('canvas')[0])) { const listenerMap = this.getKeyListener(e); - listenerMap?.forEach((listener) => { + listenerMap === null || listenerMap === void 0 ? void 0 : listenerMap.forEach((listener) => { if (!listener.global) { listener.press(e, this.app); } @@ -778,9 +1036,10 @@ class JlGraphicAppKeyboardPlugin { } }; const keyupHandle = (e) => { - if (target && target == this.app.dom?.getElementsByTagName('canvas')[0]) { + var _a; + if (target && target == ((_a = this.app.dom) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('canvas')[0])) { const listenerMap = this.getKeyListener(e); - listenerMap?.forEach((listener) => { + listenerMap === null || listenerMap === void 0 ? void 0 : listenerMap.forEach((listener) => { if (!listener.global) { listener.release(e, this.app); } @@ -887,10 +1146,20 @@ const DefaultKeyListenerOptions = { onRelease: undefined, }; class KeyListener { - // value 支持keyCode,key,code三种值 - options; - isPress = false; constructor(options) { + // value 支持keyCode,key,code三种值 + Object.defineProperty(this, "options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "isPress", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); this.options = Object.assign({}, DefaultKeyListenerOptions, options); } static create(options) { @@ -976,14 +1245,49 @@ class KeyListener { * 图形复制插件 */ class GraphicCopyPlugin { - container; - scene; - keyListeners; - copys; - start; - running = false; - moveLimit; constructor(scene) { + Object.defineProperty(this, "container", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "scene", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "keyListeners", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "copys", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "start", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "running", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "moveLimit", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.scene = scene; this.container = new Container(); this.copys = []; @@ -1143,11 +1447,26 @@ class VectorGraphicUtil { * 矢量文字.实现原理:在缩放发生变化时,更新fontSize */ class VectorText extends Text { - vectorFontSize = 8; - scaled = 1; - scaledListenerOn = false; constructor(text, style, canvas) { super(text, style, canvas); + Object.defineProperty(this, "vectorFontSize", { + enumerable: true, + configurable: true, + writable: true, + value: 8 + }); + Object.defineProperty(this, "scaled", { + enumerable: true, + configurable: true, + writable: true, + value: 1 + }); + Object.defineProperty(this, "scaledListenerOn", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); VectorGraphicUtil.handle(this); } updateOnScaled() { @@ -1185,13 +1504,18 @@ DraggablePointGraphic.endFill(); * 拖拽点,用于更新图形属性 */ class DraggablePoint extends Graphics { - scaledListenerOn = false; /** * * @param point 画布坐标点 */ constructor(point) { super(DraggablePointGraphic.geometry); + Object.defineProperty(this, "scaledListenerOn", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); this.position.copyFrom(point); this.eventMode = 'static'; this.draggable = true; @@ -1233,6 +1557,12 @@ function floatEquals(f1, f2) { /* eslint-disable @typescript-eslint/no-this-alias */ class Vector2 { constructor(values) { + Object.defineProperty(this, "values", { + enumerable: true, + configurable: true, + writable: true, + value: new Float32Array(2) + }); if (values !== undefined) { this.xy = values; } @@ -1240,9 +1570,6 @@ class Vector2 { static from(p) { return new Vector2([p.x, p.y]); } - values = new Float32Array(2); - static zero = new Vector2([0, 0]); - static one = new Vector2([1, 1]); get x() { return this.values[0]; } @@ -1500,6 +1827,18 @@ class Vector2 { return dest; } } +Object.defineProperty(Vector2, "zero", { + enumerable: true, + configurable: true, + writable: true, + value: new Vector2([0, 0]) +}); +Object.defineProperty(Vector2, "one", { + enumerable: true, + configurable: true, + writable: true, + value: new Vector2([1, 1]) +}); /** * 递归父节点执行逻辑 @@ -1952,7 +2291,7 @@ function angleOfIncludedAngle(pa, pb, pc) { function getNormalVector(point1, point2) { const x1 = point1.x, y1 = point1.y; const x2 = point2.x, y2 = point2.y; - const length = Math.sqrt((y2 - y1) ** 2 + (x2 - x1) ** 2); + const length = Math.sqrt(Math.pow((y2 - y1), 2) + Math.pow((x2 - x1), 2)); return [(y2 - y1) / length, (x1 - x2) / length]; } /** @@ -2432,11 +2771,31 @@ const RIGHT = new Point(1, 0); * 越界结果 */ class OutOfBound { - left; - top; - right; - bottom; constructor(left, top, right, bottom) { + Object.defineProperty(this, "left", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "top", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "right", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "bottom", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.left = left; this.top = top; this.right = right; @@ -2494,10 +2853,6 @@ AbsorbablePointGraphic.endFill(); * 可吸附线 */ class AbsorbableLine extends Graphics { - p1; - p2; - absorbRange; - _color = '#E77E0E'; /** * * @param p1 画布坐标 @@ -2506,6 +2861,30 @@ class AbsorbableLine extends Graphics { */ constructor(p1, p2, absorbRange = 20) { super(); + Object.defineProperty(this, "p1", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "p2", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "absorbRange", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_color", { + enumerable: true, + configurable: true, + writable: true, + value: '#E77E0E' + }); this.p1 = new Point(p1.x, p1.y); this.p2 = new Point(p2.x, p2.y); this.absorbRange = absorbRange; @@ -2545,10 +2924,6 @@ class AbsorbableLine extends Graphics { * 可吸附圆 */ class AbsorbableCircle extends Graphics { - absorbRange; - p0; - radius; - _color = '#E77E0E'; /** * * @param p 画布坐标 @@ -2557,6 +2932,30 @@ class AbsorbableCircle extends Graphics { */ constructor(p, radius, absorbRange = 10) { super(); + Object.defineProperty(this, "absorbRange", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "p0", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "radius", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_color", { + enumerable: true, + configurable: true, + writable: true, + value: '#E77E0E' + }); this.p0 = new Point(p.x, p.y); this.radius = radius; this.absorbRange = absorbRange; @@ -2602,11 +3001,26 @@ const DefaultDashedLineOptions = { color: '#0000ff', }; class DashedLine extends Container { - p1; - p2; - _options; constructor(p1, p2, options) { super(); + Object.defineProperty(this, "p1", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "p2", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); const config = Object.assign({}, DefaultDashedLineOptions, options); this._options = config; this.p1 = new Point(p1.x, p1.y); @@ -2658,19 +3072,34 @@ class DashedLine extends Container { /* eslint-disable @typescript-eslint/no-explicit-any */ class ShiftData { - /** - * 起始位置 - */ - startPosition; - /** - * 上一次终点位置 - */ - lastPosition; - /** - * 当前位置 - */ - currentPosition; constructor(startPosition, currentPosition, lastPosition) { + /** + * 起始位置 + */ + Object.defineProperty(this, "startPosition", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 上一次终点位置 + */ + Object.defineProperty(this, "lastPosition", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 当前位置 + */ + Object.defineProperty(this, "currentPosition", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.startPosition = startPosition; this.lastPosition = lastPosition; this.currentPosition = currentPosition; @@ -2704,10 +3133,25 @@ class ShiftData { } } class ScaleData { - start; - current; - last; constructor(start, current, last) { + Object.defineProperty(this, "start", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "current", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "last", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.start = start; this.current = current; this.last = last; @@ -2720,13 +3164,28 @@ class ScaleData { * 图形平移事件 */ class GraphicTransformEvent { - /** - * 图形对象 - */ - target; - type; - data; constructor(target, type, data) { + /** + * 图形对象 + */ + Object.defineProperty(this, "target", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "data", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.target = target; this.type = type; this.data = data; @@ -2760,15 +3219,23 @@ class GraphicTransformEvent { } } class GraphicTransformPlugin extends InteractionPluginBase { - static Name = '__graphic_transform_plugin'; - /** - * 可吸附位置列表 - */ - absorbablePositions; - apContainer; - static AbsorbablePosisiontsName = '__AbsorbablePosisionts'; constructor(app) { super(app, GraphicTransformPlugin.Name, InteractionPluginType.Other); + /** + * 可吸附位置列表 + */ + Object.defineProperty(this, "absorbablePositions", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "apContainer", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.apContainer = new Container(); this.apContainer.name = GraphicTransformPlugin.AbsorbablePosisiontsName; this.app.canvas.addAssistantAppend(this.apContainer); @@ -2819,6 +3286,7 @@ class GraphicTransformPlugin extends InteractionPluginBase { this.app.off('graphicchildselectedchange', this.onGraphicSelectedChange, this); } getDraggedTargets(e) { + var _a; const targets = []; if (e.target.isGraphicChild() && e.target.selected && e.target.draggable) { const graphic = e.target.getGraphic(); @@ -2830,7 +3298,7 @@ class GraphicTransformPlugin extends InteractionPluginBase { }); } else if ((e.target.isGraphic() || e.target.isGraphicChild()) && - e.target.getGraphic()?.draggable) { + ((_a = e.target.getGraphic()) === null || _a === void 0 ? void 0 : _a.draggable)) { // 图形对象 targets.push(...this.app.selectedGraphics); } @@ -2937,71 +3405,207 @@ class GraphicTransformPlugin extends InteractionPluginBase { } } } +Object.defineProperty(GraphicTransformPlugin, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: '__graphic_transform_plugin' +}); +Object.defineProperty(GraphicTransformPlugin, "AbsorbablePosisiontsName", { + enumerable: true, + configurable: true, + writable: true, + value: '__AbsorbablePosisionts' +}); /** * 缩放、旋转辅助 */ class TransformPoints extends Container { - static Name = 'transformPoints'; - static MinLength = 40; - static LeftTopName = 'lt-scale-point'; - static TopName = 't-scale-point'; - static RightTopName = 'rt-scale-point'; - static RightName = 'r-scale-point'; - static RightBottomName = 'rb-scale-point'; - static BottomName = 'b-scale-point'; - static LeftBottomName = 'lb-scale-point'; - static LeftName = 'l-scale-point'; - static RotateName = 'rotate-point'; - obj; - ltScalePoint; - ltLocal = new Point(); - tScalePoint; - tLocal = new Point(); - tCanvas = new Point(); - rtScalePoint; - rtLocal = new Point(); - rScalePoint; - rLocal = new Point(); - rbScalePoint; - rbLocal = new Point(); - bScalePoint; - bLocal = new Point(); - lbScalePoint; - lbLocal = new Point(); - lScalePoint; - lLocal = new Point(); - originScale = new Point(); - scalePivot = new Point(); - /** - * 旋转拖拽点 - */ - rotatePoint; - /** - * 旋转中心坐标 - */ - rotatePivot; - /** - * 起始旋转坐标 - */ - rotateLastPoint; - /** - * 起始图形角度 - */ - startAngle = 0; - /** - * 当前角度信息文本辅助 - */ - angleAssistantText; - /** - * 旋转角度步长 - */ - angleStep = 1; - /** - * 修改旋转步长键盘监听 - */ - rotateAngleStepKeyListeners = []; constructor(obj) { super(); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "ltScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "ltLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "tScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "tLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "tCanvas", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "rtScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "rtLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "rScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "rLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "rbScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "rbLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "bScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "bLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "lbScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "lbLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "lScalePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "lLocal", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "originScale", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + Object.defineProperty(this, "scalePivot", { + enumerable: true, + configurable: true, + writable: true, + value: new Point() + }); + /** + * 旋转拖拽点 + */ + Object.defineProperty(this, "rotatePoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 旋转中心坐标 + */ + Object.defineProperty(this, "rotatePivot", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 起始旋转坐标 + */ + Object.defineProperty(this, "rotateLastPoint", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 起始图形角度 + */ + Object.defineProperty(this, "startAngle", { + enumerable: true, + configurable: true, + writable: true, + value: 0 + }); + /** + * 当前角度信息文本辅助 + */ + Object.defineProperty(this, "angleAssistantText", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 旋转角度步长 + */ + Object.defineProperty(this, "angleStep", { + enumerable: true, + configurable: true, + writable: true, + value: 1 + }); + /** + * 修改旋转步长键盘监听 + */ + Object.defineProperty(this, "rotateAngleStepKeyListeners", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); this.obj = obj; this.name = TransformPoints.Name; this.angleAssistantText = new VectorText('', { @@ -3102,10 +3706,11 @@ class TransformPoints extends Container { this.updateAngleAssistantText(de); } updateAngleAssistantText(de) { + var _a, _b, _c; this.angleAssistantText.text = this.obj.angle + '°'; - let cursorPoint = de.data?.startPosition; - if (de.data?.currentPosition) { - cursorPoint = de.data?.currentPosition; + let cursorPoint = (_a = de.data) === null || _a === void 0 ? void 0 : _a.startPosition; + if ((_b = de.data) === null || _b === void 0 ? void 0 : _b.currentPosition) { + cursorPoint = (_c = de.data) === null || _c === void 0 ? void 0 : _c.currentPosition; } if (cursorPoint) { this.angleAssistantText.position.x = cursorPoint.x; @@ -3345,20 +3950,90 @@ class TransformPoints extends Container { } } } +Object.defineProperty(TransformPoints, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: 'transformPoints' +}); +Object.defineProperty(TransformPoints, "MinLength", { + enumerable: true, + configurable: true, + writable: true, + value: 40 +}); +Object.defineProperty(TransformPoints, "LeftTopName", { + enumerable: true, + configurable: true, + writable: true, + value: 'lt-scale-point' +}); +Object.defineProperty(TransformPoints, "TopName", { + enumerable: true, + configurable: true, + writable: true, + value: 't-scale-point' +}); +Object.defineProperty(TransformPoints, "RightTopName", { + enumerable: true, + configurable: true, + writable: true, + value: 'rt-scale-point' +}); +Object.defineProperty(TransformPoints, "RightName", { + enumerable: true, + configurable: true, + writable: true, + value: 'r-scale-point' +}); +Object.defineProperty(TransformPoints, "RightBottomName", { + enumerable: true, + configurable: true, + writable: true, + value: 'rb-scale-point' +}); +Object.defineProperty(TransformPoints, "BottomName", { + enumerable: true, + configurable: true, + writable: true, + value: 'b-scale-point' +}); +Object.defineProperty(TransformPoints, "LeftBottomName", { + enumerable: true, + configurable: true, + writable: true, + value: 'lb-scale-point' +}); +Object.defineProperty(TransformPoints, "LeftName", { + enumerable: true, + configurable: true, + writable: true, + value: 'l-scale-point' +}); +Object.defineProperty(TransformPoints, "RotateName", { + enumerable: true, + configurable: true, + writable: true, + value: 'rotate-point' +}); /** * 包围盒矩形图形,现使用外边框转画布多边形实现 */ class BoundsGraphic extends Graphics { - static Name = '_BoundsRect'; - static BoundsLineStyle = { - width: 1, - color: '#1976d2', - alpha: 1, - }; - obj; - debouncedRedraw; constructor(graphic) { super(); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "debouncedRedraw", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.obj = graphic; this.name = BoundsGraphic.Name; this.visible = false; @@ -3408,18 +4083,49 @@ class BoundsGraphic extends Graphics { this.visible = visible; } } +Object.defineProperty(BoundsGraphic, "Name", { + enumerable: true, + configurable: true, + writable: true, + value: '_BoundsRect' +}); +Object.defineProperty(BoundsGraphic, "BoundsLineStyle", { + enumerable: true, + configurable: true, + writable: true, + value: { + width: 1, + color: '#1976d2', + alpha: 1, + } +}); /** * 图形动画管理 */ class AnimationManager { - app; - _pause; - /** - * key - graphic.id - */ - graphicAnimationMap; constructor(app) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_pause", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * key - graphic.id + */ + Object.defineProperty(this, "graphicAnimationMap", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.app = app; this._pause = false; this.graphicAnimationMap = new Map(); @@ -3499,12 +4205,37 @@ class AnimationManager { * 操作 */ class JlOperation { - type; // 操作类型/名称 - app; - obj; // 操作对象 - data; // 操作数据 - description = ''; // 操作描述 constructor(app, type) { + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 操作类型/名称 + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 操作对象 + Object.defineProperty(this, "data", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 操作数据 + Object.defineProperty(this, "description", { + enumerable: true, + configurable: true, + writable: true, + value: '' + }); // 操作描述 this.app = app; this.type = type; } @@ -3525,10 +4256,25 @@ class JlOperation { * 操作记录 */ class OperationRecord { - undoStack = []; - redoStack = []; - maxLen; constructor(maxLen = 100) { + Object.defineProperty(this, "undoStack", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + Object.defineProperty(this, "redoStack", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + Object.defineProperty(this, "maxLen", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.maxLen = maxLen; } get hasUndo() { @@ -3582,12 +4328,32 @@ class OperationRecord { * 更新画布操作 */ class UpdateCanvasOperation extends JlOperation { - obj; - old; - data; - description = ''; constructor(app, obj, old, data) { super(app, 'update-canvas'); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "old", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "data", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "description", { + enumerable: true, + configurable: true, + writable: true, + value: '' + }); this.app = app; this.obj = obj; this.old = old; @@ -3606,10 +4372,20 @@ class UpdateCanvasOperation extends JlOperation { * 创建图形操作 */ class GraphicCreateOperation extends JlOperation { - obj; - description = ''; constructor(app, obj) { super(app, 'graphic-create'); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "description", { + enumerable: true, + configurable: true, + writable: true, + value: '' + }); this.app = app; this.obj = obj; } @@ -3625,9 +4401,14 @@ class GraphicCreateOperation extends JlOperation { * 删除图形操作 */ class GraphicDeleteOperation extends JlOperation { - obj; constructor(app, obj) { super(app, 'graphic-delete'); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.app = app; this.obj = obj; } @@ -3640,11 +4421,26 @@ class GraphicDeleteOperation extends JlOperation { } } class GraphicDataUpdateOperation extends JlOperation { - obj; - oldData; - newData; constructor(app, obj, oldData, newData) { super(app, 'graphic-drag'); + Object.defineProperty(this, "obj", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "oldData", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "newData", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.obj = [...obj]; this.oldData = oldData; this.newData = newData; @@ -3671,9 +4467,19 @@ class GraphicDataUpdateOperation extends JlOperation { * 图形关系数据 */ class GraphicRelationParam { - g; - param; constructor(g, param = null) { + Object.defineProperty(this, "g", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "param", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.g = g; this.param = param; } @@ -3694,9 +4500,19 @@ class GraphicRelationParam { * 图形关系 */ class GraphicRelation { - rp1; - rp2; constructor(rp1, rp2) { + Object.defineProperty(this, "rp1", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "rp2", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.rp1 = rp1; this.rp2 = rp2; } @@ -3760,7 +4576,14 @@ class GraphicRelation { * 图形关系管理 */ class RelationManage { - relations = []; + constructor() { + Object.defineProperty(this, "relations", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + } isContainsRelation(rp1, rp2) { const relation = this.relations.find((relation) => relation.equals(rp1, rp2)); return !!relation; @@ -3832,9 +4655,19 @@ class RelationManage { * 图形存储 */ class GraphicStore { - store; - relationManage; constructor() { + Object.defineProperty(this, "store", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "relationManage", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.store = new Map(); this.relationManage = new RelationManage(); } @@ -3966,10 +4799,20 @@ class GraphicStore { /* eslint-disable @typescript-eslint/no-explicit-any */ class MessageClient extends EventEmitter { - options; - subClients = []; // 订阅客户端 constructor(options) { super(); + Object.defineProperty(this, "options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "subClients", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); // 订阅客户端 this.options = options; } unsubscribe(destination) { @@ -3997,12 +4840,37 @@ class MessageClient extends EventEmitter { } } class SubscriptionClient { - mc; - destination; - protocol; - handlers = []; - subscripted = false; constructor(mc, destination, protocal) { + Object.defineProperty(this, "mc", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "destination", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "protocol", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "handlers", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + Object.defineProperty(this, "subscripted", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); this.mc = mc; this.destination = destination; this.protocol = protocal; @@ -4059,9 +4927,14 @@ const ReconnectDelay = 3000; const HeartbeatIncoming = 30000; const HeartbeatOutgoing = 30000; class StompMessagingClient extends MessageClient { - cli; constructor(options) { super(options); + Object.defineProperty(this, "cli", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.options = options; this.cli = new Client({ brokerURL: options.wsUrl, @@ -4124,11 +4997,26 @@ class StompMessagingClient extends MessageClient { } class MqttMsgClient extends MessageClient { - cli; - retryTimes = 0; - subMsgHandler = new Map(); constructor(options) { super(options); + Object.defineProperty(this, "cli", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "retryTimes", { + enumerable: true, + configurable: true, + writable: true, + value: 0 + }); + Object.defineProperty(this, "subMsgHandler", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); this.options = options; try { this.cli = mqtt.connect(options.wsUrl, { @@ -4251,9 +5139,6 @@ const DefaultStompOption = { retryTimes: 100, }; class WsMsgCli { - static client; - static options; - static appMsgBroker = []; static new(options) { if (WsMsgCli.client) { // 已经创建 @@ -4329,10 +5214,26 @@ class WsMsgCli { } } } +Object.defineProperty(WsMsgCli, "appMsgBroker", { + enumerable: true, + configurable: true, + writable: true, + value: [] +}); class AppMessageHandler { - app; - sub; constructor(app, subOptions) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "sub", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.app = app; if (!subOptions.messageConverter && !subOptions.messageHandle) { throw new Error(`没有消息处理器或图形状态消息转换器: ${subOptions}`); @@ -4357,9 +5258,19 @@ class AppMessageHandler { * 图形APP的websocket消息代理 */ class AppWsMsgBroker { - app; - subscriptions = new Map(); constructor(app) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "subscriptions", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); this.app = app; WsMsgCli.registerAppMsgBroker(this); } @@ -4394,9 +5305,19 @@ class AppWsMsgBroker { } class ContextMenuPlugin { - app; - contextMenuMap = new Map(); constructor(app) { + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "contextMenuMap", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); this.app = app; const canvas = this.app.canvas; canvas.on('pointerdown', () => { @@ -4499,16 +5420,36 @@ const AppConsts = { assistantElementColor: '#1976d2', }; class CanvasData { - width; - height; - backgroundColor; - viewportTransform; constructor(properties = { width: 1920, height: 1080, backgroundColor: '#ffffff', viewportTransform: GraphicTransform.default(), }) { + Object.defineProperty(this, "width", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "height", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "backgroundColor", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "viewportTransform", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.width = properties.width; this.height = properties.height; this.backgroundColor = properties.backgroundColor; @@ -4541,15 +5482,50 @@ class CanvasData { } } class JlCanvas extends Container { - __JlCanvas = true; - type = 'Canvas'; - scene; - _properties; - bg = new Graphics(); // 背景 - nonInteractiveContainer; // 无交互对象容器 - assistantAppendContainer; // 辅助附加容器 constructor(scene, properties = new CanvasData()) { super(); + Object.defineProperty(this, "__JlCanvas", { + enumerable: true, + configurable: true, + writable: true, + value: true + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: 'Canvas' + }); + Object.defineProperty(this, "scene", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_properties", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "bg", { + enumerable: true, + configurable: true, + writable: true, + value: new Graphics() + }); // 背景 + Object.defineProperty(this, "nonInteractiveContainer", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 无交互对象容器 + Object.defineProperty(this, "assistantAppendContainer", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 辅助附加容器 this.scene = scene; this._properties = properties; this.eventMode = 'static'; @@ -4677,23 +5653,98 @@ class JlCanvas extends Container { } } class GraphicSceneBase extends EventEmitter { - graphicStore; - _options; - pixi; // Pixi 渲染器 - viewport; // 视口 - canvas; // 画布 - _loaded = false; // 是否已经加载 - _dom; // 场景绑定到的dom节点 - _viewportResizer; // 自动根据dom大小变化调整视口尺寸 - graphicTemplateMap = new Map(); // 图形对象模板 - interactionPluginMap = new Map(); // 交互插件 - graphicCopyPlugin; // 图形复制操作插件 - animationManager; // 动画管理组件 - menuPlugin; // 菜单插件 - debounceEmitFunc; - wsMsgBroker; // websocket消息代理 constructor(options) { super(); + Object.defineProperty(this, "graphicStore", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "pixi", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // Pixi 渲染器 + Object.defineProperty(this, "viewport", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 视口 + Object.defineProperty(this, "canvas", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 画布 + Object.defineProperty(this, "_loaded", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); // 是否已经加载 + Object.defineProperty(this, "_dom", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 场景绑定到的dom节点 + Object.defineProperty(this, "_viewportResizer", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 自动根据dom大小变化调整视口尺寸 + Object.defineProperty(this, "graphicTemplateMap", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); // 图形对象模板 + Object.defineProperty(this, "interactionPluginMap", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); // 交互插件 + Object.defineProperty(this, "graphicCopyPlugin", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形复制操作插件 + Object.defineProperty(this, "animationManager", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 动画管理组件 + Object.defineProperty(this, "menuPlugin", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 菜单插件 + Object.defineProperty(this, "debounceEmitFunc", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "wsMsgBroker", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // websocket消息代理 this.graphicStore = new GraphicStore(); this._options = options; // 创建pixi渲染app @@ -4768,34 +5819,40 @@ class GraphicSceneBase extends EventEmitter { get selectedGraphics() { return this.queryStore.getAllGraphics().filter((g) => g.selected); } - async load() { - if (this._options.dataLoader) { - const storage = await this._options.dataLoader(); - if (storage.canvasProperty) { - this.canvas.update(storage.canvasProperty); + load() { + return __awaiter(this, void 0, void 0, function* () { + if (this._options.dataLoader) { + const storage = yield this._options.dataLoader(); + if (storage.canvasProperty) { + this.canvas.update(storage.canvasProperty); + } + if (storage.datas) { + yield this.loadGraphic(storage.datas); + } } - if (storage.datas) { - await this.loadGraphic(storage.datas); - } - } - this._loaded = true; + this._loaded = true; + }); } /** * 重新加载数据 */ - async reload() { - if (!this._loaded) { - this.graphicStore.clear(); - await this.load(); - } - else { - console.debug('场景已经加载过数据,不重新加载', this); - } + reload() { + return __awaiter(this, void 0, void 0, function* () { + if (!this._loaded) { + this.graphicStore.clear(); + yield this.load(); + } + else { + console.debug('场景已经加载过数据,不重新加载', this); + } + }); } - async forceReload() { - console.debug('场景强制重新加载数据', this); - this.graphicStore.clear(); - await this.load(); + forceReload() { + return __awaiter(this, void 0, void 0, function* () { + console.debug('场景强制重新加载数据', this); + this.graphicStore.clear(); + yield this.load(); + }); } /** * 更新选项 @@ -4906,31 +5963,34 @@ class GraphicSceneBase extends EventEmitter { * @param protos * @param options 添加到可交互/不可交互容器选项配置 */ - async loadGraphic(protos) { - for (const item of this.graphicTemplateMap) { - await item[1].loadAssets(); - } - // 加载数据到图形存储 - protos.forEach((proto) => { - const template = this.getGraphicTemplatesByType(proto.graphicType); - const g = template.new(); - g.loadData(proto); - this.addGraphics(g); + loadGraphic(protos) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + for (const item of this.graphicTemplateMap) { + yield item[1].loadAssets(); + } + // 加载数据到图形存储 + protos.forEach((proto) => { + const template = this.getGraphicTemplatesByType(proto.graphicType); + const g = template.new(); + g.loadData(proto); + this.addGraphics(g); + }); + // 加载数据关系 + this.queryStore.getAllGraphics().forEach((g) => g.loadRelations()); + // 更新id生成器 + const max = (_a = this.queryStore + .getAllGraphics() + .filter((g) => !isNaN(parseInt(g.id))) + .map((g) => parseInt(g.id)) + .sort((a, b) => a - b) + .pop()) !== null && _a !== void 0 ? _a : 0; + GraphicIdGenerator.initSerial(max); + // 数据加载完成后 + this.emit('postdataloaded'); + // 加载完成通知 + this.emit('loadfinish'); }); - // 加载数据关系 - this.queryStore.getAllGraphics().forEach((g) => g.loadRelations()); - // 更新id生成器 - const max = this.queryStore - .getAllGraphics() - .filter((g) => !isNaN(parseInt(g.id))) - .map((g) => parseInt(g.id)) - .sort((a, b) => a - b) - .pop() ?? 0; - GraphicIdGenerator.initSerial(max); - // 数据加载完成后 - this.emit('postdataloaded'); - // 加载完成通知 - this.emit('loadfinish'); } /** * 添加图形前处理 @@ -5003,7 +6063,8 @@ class GraphicSceneBase extends EventEmitter { */ deleteGraphics(...graphics) { const dels = graphics.filter((g) => { - if (this._options?.isSupportDeletion == undefined || + var _a; + if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.isSupportDeletion) == undefined || this._options.isSupportDeletion(g)) { this.doDeleteGraphics(g); return true; @@ -5222,14 +6283,29 @@ class GraphicSceneBase extends EventEmitter { * 图形app基类 */ class GraphicApp extends GraphicSceneBase { - /** - * 场景列表 - */ - scenes = new Map(); - opRecord; // 操作记录 - keyboardPlugin; // 键盘操作处理插件 constructor(options) { super(options); + /** + * 场景列表 + */ + Object.defineProperty(this, "scenes", { + enumerable: true, + configurable: true, + writable: true, + value: new Map() + }); + Object.defineProperty(this, "opRecord", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 操作记录 + Object.defineProperty(this, "keyboardPlugin", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 键盘操作处理插件 this.opRecord = new OperationRecord(); // 绑定键盘监听 this.keyboardPlugin = new JlGraphicAppKeyboardPlugin(this); @@ -5329,10 +6405,20 @@ class GraphicApp extends GraphicSceneBase { * 场景 */ class JlScene extends GraphicSceneBase { - code; - app; constructor(app, code, options) { super(options); + Object.defineProperty(this, "code", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.code = code; this.app = app; } @@ -5344,24 +6430,64 @@ class JlScene extends GraphicSceneBase { * 图形绘制助手 */ class GraphicDrawAssistant extends AppInteractionPlugin { - __GraphicDrawAssistant = true; - app; - type; // 图形对象类型 - description; // 描述 - icon; // 界面显示的图标 - container = new Container(); - graphicTemplate; - escListener = new KeyListener({ - value: 'Escape', - onRelease: () => { - this.onEsc(); - }, - }); onEsc() { this.createAndStore(true); } constructor(graphicApp, graphicTemplate, icon, description) { super(graphicTemplate.type, graphicApp); + Object.defineProperty(this, "__GraphicDrawAssistant", { + enumerable: true, + configurable: true, + writable: true, + value: true + }); + Object.defineProperty(this, "app", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形对象类型 + Object.defineProperty(this, "description", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 描述 + Object.defineProperty(this, "icon", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 界面显示的图标 + Object.defineProperty(this, "container", { + enumerable: true, + configurable: true, + writable: true, + value: new Container() + }); + Object.defineProperty(this, "graphicTemplate", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "escListener", { + enumerable: true, + configurable: true, + writable: true, + value: new KeyListener({ + value: 'Escape', + onRelease: () => { + this.onEsc(); + }, + }) + }); this.app = graphicApp; this.type = graphicTemplate.type; this.graphicTemplate = graphicTemplate; @@ -5391,9 +6517,10 @@ class GraphicDrawAssistant extends AppInteractionPlugin { }); } unbind() { + var _a; this.clearCache(); const canvas = this.canvas; - if (this.container?.parent) { + if ((_a = this.container) === null || _a === void 0 ? void 0 : _a.parent) { canvas.removeChild(this.container); } canvas.off('mousedown', this.onLeftDown, this); @@ -5467,20 +6594,6 @@ class GraphicDrawAssistant extends AppInteractionPlugin { * 绘制应用 */ class JlDrawApp extends GraphicApp { - font = BitmapFont.from('coordinates', { - fontFamily: 'Roboto', - fontSize: 16, - fill: '#ff2700', - }, { chars: ['画布坐标:() 屏幕坐标:() 缩放:.,', ['0', '9']] }); - coordinates = new BitmapText('画布坐标: (0, 0) 屏幕坐标:(0, 0)', { - fontName: 'coordinates', - }); - scaleText = new BitmapText('缩放: 1', { - fontName: 'coordinates', - }); - drawAssistants = []; - _drawing = false; - debouncedFormDataUpdator; get drawing() { return this._drawing; } @@ -5489,6 +6602,56 @@ class JlDrawApp extends GraphicApp { } constructor(options) { super(options); + Object.defineProperty(this, "font", { + enumerable: true, + configurable: true, + writable: true, + value: BitmapFont.from('coordinates', { + fontFamily: 'Roboto', + fontSize: 16, + fill: '#ff2700', + }, { chars: ['画布坐标:() 屏幕坐标:() 缩放:.,', ['0', '9']] }) + }); + Object.defineProperty(this, "coordinates", { + enumerable: true, + configurable: true, + writable: true, + value: new BitmapText('画布坐标: (0, 0) 屏幕坐标:(0, 0)', { + fontName: 'coordinates', + }) + }); + Object.defineProperty(this, "scaleText", { + enumerable: true, + configurable: true, + writable: true, + value: new BitmapText('缩放: 1', { + fontName: 'coordinates', + }) + }); + Object.defineProperty(this, "drawAssistants", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + Object.defineProperty(this, "_drawing", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "debouncedFormDataUpdator", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "formData", { + enumerable: true, + configurable: true, + writable: true, + value: undefined + }); this.appendDrawStatesDisplay(); // 拖拽操作记录 this.appOperationRecord(); @@ -5673,7 +6836,6 @@ class JlDrawApp extends GraphicApp { this.handleFormDataUpdate(graphic); }); } - formData = undefined; /** * 绑定form表单对象 * @param form @@ -6120,11 +7282,31 @@ Graphics.prototype.drawBezierCurve = function drawBezierCurve(p1, p2, cp1, cp2, * 图形变换数据 */ class GraphicTransform { - position; - scale; - rotation; - skew; constructor(position, scale, rotation, skew) { + Object.defineProperty(this, "position", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "scale", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "rotation", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "skew", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.position = position; this.scale = scale; this.rotation = rotation; @@ -6147,17 +7329,28 @@ class GraphicTransform { * 图形子元素变换 */ class ChildTransform { - name; - transform; constructor(name, transform) { + Object.defineProperty(this, "name", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "transform", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.name = name; this.transform = transform; } static fromChild(child) { + var _a; if (child.name == null || child.name == undefined || child.name.trim() == '') { - throw new Error(`图形type=${child.getGraphic()?.type}的子元素${child}name为空,但设置为需要保存变换数据`); + throw new Error(`图形type=${(_a = child.getGraphic()) === null || _a === void 0 ? void 0 : _a.type}的子元素${child}name为空,但设置为需要保存变换数据`); } return new ChildTransform(child.name, GraphicTransform.fromObject(child)); } @@ -6166,13 +7359,28 @@ class ChildTransform { } } class GraphicAnimation { - options; - _running; - /** - * 倍速 - */ - _xSpeed; constructor(options) { + Object.defineProperty(this, "options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "_running", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + /** + * 倍速 + */ + Object.defineProperty(this, "_xSpeed", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.options = options; this._running = false; this._xSpeed = 1; @@ -6211,16 +7419,56 @@ class GraphicAnimation { * 图形对象基类 */ class JlGraphic extends Container { - __JlGraphic = true; - type; // 图形类型 - _id = ''; // 图形的唯一标识,不具有业务意义,唯一,不可重复,可用做图形数据关联。 - _code = ''; // 业务编号/名称,用于标识图形对象,具有业务意义 - _datas; // 图形数据 - _states; // 图形状态数据 - _relationManage; // 图形关系管理 - _queryStore; // 图形对象查询仓库 constructor(type) { super(); + Object.defineProperty(this, "__JlGraphic", { + enumerable: true, + configurable: true, + writable: true, + value: true + }); + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形类型 + Object.defineProperty(this, "_id", { + enumerable: true, + configurable: true, + writable: true, + value: '' + }); // 图形的唯一标识,不具有业务意义,唯一,不可重复,可用做图形数据关联。 + Object.defineProperty(this, "_code", { + enumerable: true, + configurable: true, + writable: true, + value: '' + }); // 业务编号/名称,用于标识图形对象,具有业务意义 + Object.defineProperty(this, "_datas", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形数据 + Object.defineProperty(this, "_states", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形状态数据 + Object.defineProperty(this, "_relationManage", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形关系管理 + Object.defineProperty(this, "_queryStore", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); // 图形对象查询仓库 this.type = type; this.draggable = false; this.filters; @@ -6557,9 +7805,19 @@ class JlGraphic extends Container { * 图形对象模板 */ class JlGraphicTemplate { - type; - options; constructor(type, options) { + Object.defineProperty(this, "type", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "options", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); this.type = type; this.options = options; } @@ -6578,7 +7836,9 @@ class JlGraphicTemplate { /** * 加载图形对象需要用到的资源 */ - async loadAssets() { } + loadAssets() { + return __awaiter(this, void 0, void 0, function* () { }); + } /** * 克隆图形对象 * @param graphic diff --git a/tsconfig.json b/tsconfig.json index 64a3a2c..e93e717 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,8 @@ "baseUrl": ".", "esModuleInterop": true, "allowJs": false, - "module": "ESNext", - "target": "ESNext", + "module": "ES2015", + "target": "ES2015", "moduleResolution": "Node", "typeRoots": ["node_modules/@types"], "strict": true,