@meta2d/core 1.0.15 → 1.0.16

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/src/core.d.ts CHANGED
@@ -3,10 +3,10 @@ import { Canvas } from './canvas';
3
3
  import { Options } from './options';
4
4
  import { calcTextDrawRect, calcTextLines, calcTextRect, facePen, getWords, LockState, Pen, renderPenRaw, IValue, setElemPosition } from './pen';
5
5
  import { Point } from './point';
6
- import { EditAction, register, registerAnchors, registerCanvasDraw, Meta2dData, Meta2dStore } from './store';
6
+ import { EditAction, register, registerAnchors, registerCanvasDraw, Meta2dData, Meta2dStore, Network } from './store';
7
7
  import { Padding } from './utils';
8
8
  import { Rect } from './rect';
9
- import { Event } from './event';
9
+ import { Event, TriggerCondition } from './event';
10
10
  import { ViewMap } from './map';
11
11
  import { MqttClient } from 'mqtt';
12
12
  export declare class Meta2d {
@@ -16,7 +16,9 @@ export declare class Meta2d {
16
16
  mqttClient: MqttClient;
17
17
  websockets: WebSocket[];
18
18
  mqttClients: MqttClient[];
19
- socketFn: (e: string, topic: string) => boolean;
19
+ socketFn: (e: string, topic: string, context?: {
20
+ meta2d: Meta2d;
21
+ }) => boolean;
20
22
  events: Record<number, (pen: Pen, e: Event) => void>;
21
23
  map: ViewMap;
22
24
  mapTimer: any;
@@ -47,7 +49,9 @@ export declare class Meta2d {
47
49
  setDatabyOptions(options?: Options): void;
48
50
  private init;
49
51
  initEventFns(): void;
52
+ navigatorTo(id: string): void;
50
53
  doSendDataEvent(value: any, topics?: string): void;
54
+ sendDataToNetWork(value: any, network: Network): Promise<void>;
51
55
  resize(width?: number, height?: number): void;
52
56
  /**
53
57
  *
@@ -126,7 +130,7 @@ export declare class Meta2d {
126
130
  height: number;
127
131
  };
128
132
  setPenRect(pen: Pen, rect: Rect, render?: boolean): void;
129
- startAnimate(idOrTagOrPens?: string | Pen[], index?: number): void;
133
+ startAnimate(idOrTagOrPens?: string | Pen[], params?: number | string): void;
130
134
  pauseAnimate(idOrTagOrPens?: string | Pen[]): void;
131
135
  stopAnimate(idOrTagOrPens?: string | Pen[]): void;
132
136
  startVideo(idOrTagOrPens?: string | Pen[]): void;
@@ -143,6 +147,7 @@ export declare class Meta2d {
143
147
  isCombine(pen: Pen): boolean;
144
148
  active(pens: Pen[], emit?: boolean): void;
145
149
  inactive(): void;
150
+ activeAll(): void;
146
151
  /**
147
152
  * 删除画笔
148
153
  * @param pens 需要删除的画笔们
@@ -181,6 +186,10 @@ export declare class Meta2d {
181
186
  connectHttp(): void;
182
187
  sendDatabyHttp(data: string): Promise<void>;
183
188
  closeHttp(): void;
189
+ networkTimer: any;
190
+ connectNetwork(): void;
191
+ onNetworkConnect(https: Network[]): void;
192
+ closeNetwork(): void;
184
193
  socketCallback(message: string, topic?: string): void;
185
194
  setDatas(datas: {
186
195
  dataId: string;
@@ -205,6 +214,7 @@ export declare class Meta2d {
205
214
  clearDropdownList(): void;
206
215
  private onEvent;
207
216
  private doEvent;
217
+ judgeCondition(pen: Pen, key: string, condition: TriggerCondition): boolean;
208
218
  pushChildren(parent: Pen, children: Pen[]): void;
209
219
  renderPenRaw: typeof renderPenRaw;
210
220
  toPng(padding?: Padding, callback?: BlobCallback, containBkImg?: boolean): string;
@@ -241,6 +251,11 @@ export declare class Meta2d {
241
251
  * @param pens 画笔们
242
252
  */
243
253
  beSameByFirst(pens?: Pen[], attribute?: string): void;
254
+ /**
255
+ * 大小相同
256
+ * @param pens 画笔们
257
+ */
258
+ beSameByLast(pens?: Pen[], attribute?: string): void;
244
259
  /**
245
260
  * 格式刷(样式相同,大小无需一致。)
246
261
  * @param pens 画笔们
@@ -256,6 +271,12 @@ export declare class Meta2d {
256
271
  * @param pens
257
272
  */
258
273
  alignNodesByFirst(align: string, pens?: Pen[]): void;
274
+ /**
275
+ * 对齐画笔,基于最后选中的画笔
276
+ * @param align 左对齐,右对齐,上对齐,下对齐,居中对齐
277
+ * @param pens
278
+ */
279
+ alignNodesByLast(align: string, pens?: Pen[]): void;
259
280
  /**
260
281
  * 将画笔参照 rect 进行 align 对齐
261
282
  * @param align 左对齐,右对齐,上对齐,下对齐,居中对齐
@@ -285,9 +306,8 @@ export declare class Meta2d {
285
306
  /**
286
307
  * 将该画笔置顶,即放到数组最后,最后绘制即在顶部
287
308
  * @param pen pen 置顶的画笔
288
- * @param pens 画笔们,注意 pen 必须在该数组内才有效
289
309
  */
290
- top(pen: Pen, pens?: Pen[]): void;
310
+ top(pen: Pen): void;
291
311
  /**
292
312
  * 若本次改变的画笔存在图片,并且在上层 or 下层,需要擦除上层 or 下层
293
313
  * 子节点中包含图片,也需要重绘
@@ -298,7 +318,7 @@ export declare class Meta2d {
298
318
  * 该画笔置底,即放到数组最前,最后绘制即在底部
299
319
  * @param pens 画笔们,注意 pen 必须在该数组内才有效
300
320
  */
301
- bottom(pen: Pen, pens?: Pen[]): void;
321
+ bottom(pen: Pen): void;
302
322
  /**
303
323
  * data.pens 决定了绘制顺序,即越后面的越在上层
304
324
  * 该方法通过区域重叠计算,找出该画笔之后第一个与其重叠的画笔,然后把该画笔放到找出的画笔之后
@@ -307,14 +327,14 @@ export declare class Meta2d {
307
327
  upByArea(pen: Pen): void;
308
328
  /**
309
329
  * 该画笔上移,即把该画笔在数组中的位置向后移动一个
310
- * @param pens 画笔们,注意 pen 必须在该数组内才有效
330
+ * @param pen 画笔
311
331
  */
312
- up(pen: Pen, pens?: Pen[]): void;
332
+ up(pen: Pen): void;
313
333
  /**
314
334
  * 该画笔下移,即把该画笔在该数组中的位置前移一个
315
- * @param pens 画笔们,注意 pen 必须在该数组内才有效
335
+ * @param pen 画笔
316
336
  */
317
- down(pen: Pen, pens?: Pen[]): void;
337
+ down(pen: Pen): void;
318
338
  setLayer(pen: Pen, toIndex: number, pens?: Pen[]): void;
319
339
  changePenId(oldId: string, newId: string): void;
320
340
  /**