@netless/appliance-plugin 1.1.34-beta.3 → 1.1.35-beta.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.
Files changed (51) hide show
  1. package/READMA.zh-CN.md +33 -1
  2. package/README.md +32 -0
  3. package/cdn/cdn.js +1 -1
  4. package/cdn/fullWorker-BShzOf.js +486 -0
  5. package/cdn/subWorker-DofGU2.js +486 -0
  6. package/dist/appliance-plugin.js +1 -1
  7. package/dist/appliance-plugin.mjs +1 -1
  8. package/dist/assets/fullWorker-BLBp1QlT.js +593 -0
  9. package/dist/assets/subWorker-CA5sK8hX.js +593 -0
  10. package/dist/{bridge-Bb-MjyNY.mjs → bridge-D6IerdOk.mjs} +6 -6
  11. package/dist/{bridge-m2Uim0rf.js → bridge-s6K3XU2g.js} +1 -1
  12. package/dist/bridge.js +1 -1
  13. package/dist/bridge.mjs +1 -1
  14. package/dist/core/autoShape/index.d.ts +12 -0
  15. package/dist/core/autoShape/mapper.d.ts +3 -0
  16. package/dist/core/autoShape/recognizer.d.ts +8 -0
  17. package/dist/core/autoShape/registry.d.ts +2 -0
  18. package/dist/core/autoShape/templates.d.ts +2 -0
  19. package/dist/core/autoShape/types.d.ts +78 -0
  20. package/dist/core/mainEngine.d.ts +9 -0
  21. package/dist/core/tools/pencil.d.ts +3 -0
  22. package/dist/core/types.d.ts +7 -0
  23. package/dist/fullWorker.js +147 -147
  24. package/dist/index-328yD4vj.js +1 -0
  25. package/dist/{index-B5p02yLM.mjs → index-4k563Sm-.mjs} +3076 -2293
  26. package/dist/index-C89lvDjQ.js +1 -0
  27. package/dist/{index-C-ITXa9_.js → index-CBE_U7Gn.js} +3 -3
  28. package/dist/{index-BAEfMWKR.mjs → index-CPmHcL9u.mjs} +1041 -1013
  29. package/dist/{index-BbVM6AMN.mjs → index-D-IWIyEl.mjs} +260 -253
  30. package/dist/{index-D9CYiyfx.mjs → index-D1p6YXf0.mjs} +3014 -2238
  31. package/dist/{index-HS0sRcOj.js → index-DDL0Hq_X.js} +3 -3
  32. package/dist/{index-on8Dtynb.mjs → index-DR2km5D4.mjs} +215 -208
  33. package/dist/index-DXx1-O0K.js +1 -0
  34. package/dist/index-DbLWM-6h.js +1 -0
  35. package/dist/{index-O6ldDna3.mjs → index-IQRiGPX7.mjs} +1041 -1013
  36. package/dist/plugin/multi/containerManager.d.ts +7 -0
  37. package/dist/plugin/types.d.ts +24 -0
  38. package/dist/subWorker.js +147 -147
  39. package/dist/svgToImageLoader-B3gIDAQo.js +1 -0
  40. package/dist/svgToImageLoader-DZz5bAo4.mjs +22 -0
  41. package/package.json +11 -5
  42. package/cdn/fullWorker-cY8Uuj.js +0 -486
  43. package/cdn/subWorker-BleGf3.js +0 -486
  44. package/dist/assets/fullWorker-BuSPsz-_.js +0 -593
  45. package/dist/assets/subWorker-B0NfJ2Bk.js +0 -593
  46. package/dist/index-BVYBjZU_.js +0 -1
  47. package/dist/index-D696FwsD.js +0 -1
  48. package/dist/index-DTeRhVER.js +0 -1
  49. package/dist/index-DnT8RFOT.js +0 -1
  50. package/dist/svgToImageLoader-DPRAAhwW.js +0 -1
  51. package/dist/svgToImageLoader-mXH53h-l.mjs +0 -18
@@ -12,7 +12,7 @@ function u() {
12
12
  );
13
13
  return r;
14
14
  }
15
- const h = "/assets/fullWorker-BuSPsz-_.js", g = "/assets/subWorker-B0NfJ2Bk.js";
15
+ const h = "/assets/fullWorker-BLBp1QlT.js", g = "/assets/subWorker-CA5sK8hX.js";
16
16
  class d {
17
17
  constructor() {
18
18
  i(this, "control");
@@ -31,7 +31,7 @@ class d {
31
31
  delete this._listeners[e];
32
32
  }
33
33
  }
34
- class k {
34
+ class b {
35
35
  constructor(e) {
36
36
  i(this, "control");
37
37
  i(this, "worker");
@@ -54,14 +54,14 @@ class k {
54
54
  });
55
55
  }
56
56
  }
57
- async function b(s) {
58
- return c(s), import("./index-D9CYiyfx.mjs").then((e) => e.a7);
57
+ async function k(s) {
58
+ return c(s), import("./index-D1p6YXf0.mjs").then((e) => e.a7);
59
59
  }
60
60
  export {
61
- k as P,
61
+ b as P,
62
62
  d as a,
63
63
  h as f,
64
64
  u as g,
65
- b as l,
65
+ k as l,
66
66
  g as s
67
67
  };
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var l=(s,e,t)=>e in s?o(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>l(s,typeof e!="symbol"?e+"":e,t);let n;function u(s){n=s}function c(){if(!n)throw new Error("[@netless/appliance-plugin/bridge] white-web-sdk runtime has not been bound yet.");return n}const a="/assets/fullWorker-BuSPsz-_.js",h="/assets/subWorker-B0NfJ2Bk.js";class g{constructor(){i(this,"control");i(this,"_listeners",{})}_inject(e){this.control=e}_onEvent(e,t){this._listeners[e]&&this._listeners[e](...t)}callbacks(e,t){this._listeners[e]=t}removeCallback(e){delete this._listeners[e]}}class d{constructor(e){i(this,"control");i(this,"worker");i(this,"publicMsgEmitter");i(this,"plugins",new Map);const{control:t,publicMsgEmitter:r}=e;this.control=t,this.publicMsgEmitter=r,this.worker=t.worker}use(e){this.plugins.set(e.kind,e),e._inject(this.control),e.onCreate()}destroy(){this.plugins.forEach(e=>{this.plugins.delete(e.kind),e.onDestroy()})}dispatchPluginEvent(e,...t){this.plugins.forEach(r=>{r._onEvent(e,t)})}}async function k(s){return u(s),Promise.resolve().then(()=>require("./index-DTeRhVER.js")).then(e=>e.index)}exports.Plugin=g;exports.PluginManager=d;exports.fullWorker=a;exports.getWhiteWebSdkBridgeRuntime=c;exports.loadAppliancePluginBridge=k;exports.subWorker=h;
1
+ "use strict";var l=Object.defineProperty;var o=(s,e,t)=>e in s?l(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>o(s,typeof e!="symbol"?e+"":e,t);let n;function u(s){n=s}function c(){if(!n)throw new Error("[@netless/appliance-plugin/bridge] white-web-sdk runtime has not been bound yet.");return n}const h="/assets/fullWorker-BLBp1QlT.js",a="/assets/subWorker-CA5sK8hX.js";class g{constructor(){i(this,"control");i(this,"_listeners",{})}_inject(e){this.control=e}_onEvent(e,t){this._listeners[e]&&this._listeners[e](...t)}callbacks(e,t){this._listeners[e]=t}removeCallback(e){delete this._listeners[e]}}class d{constructor(e){i(this,"control");i(this,"worker");i(this,"publicMsgEmitter");i(this,"plugins",new Map);const{control:t,publicMsgEmitter:r}=e;this.control=t,this.publicMsgEmitter=r,this.worker=t.worker}use(e){this.plugins.set(e.kind,e),e._inject(this.control),e.onCreate()}destroy(){this.plugins.forEach(e=>{this.plugins.delete(e.kind),e.onDestroy()})}dispatchPluginEvent(e,...t){this.plugins.forEach(r=>{r._onEvent(e,t)})}}async function k(s){return u(s),Promise.resolve().then(()=>require("./index-DbLWM-6h.js")).then(e=>e.index)}exports.Plugin=g;exports.PluginManager=d;exports.fullWorker=h;exports.getWhiteWebSdkBridgeRuntime=c;exports.loadAppliancePluginBridge=k;exports.subWorker=a;
package/dist/bridge.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./bridge-m2Uim0rf.js");exports.Plugin=r.Plugin;exports.fullWorkerUrl=r.fullWorker;exports.loadAppliancePluginBridge=r.loadAppliancePluginBridge;exports.subWorkerUrl=r.subWorker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./bridge-s6K3XU2g.js");exports.Plugin=r.Plugin;exports.fullWorkerUrl=r.fullWorker;exports.loadAppliancePluginBridge=r.loadAppliancePluginBridge;exports.subWorkerUrl=r.subWorker;
package/dist/bridge.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a, f as s, l as e, s as o } from "./bridge-Bb-MjyNY.mjs";
1
+ import { a, f as s, l as e, s as o } from "./bridge-D6IerdOk.mjs";
2
2
  export {
3
3
  a as Plugin,
4
4
  s as fullWorkerUrl,
@@ -0,0 +1,12 @@
1
+ import { serializeAutoShapeWork } from "./mapper";
2
+ import type { AutoShapeContext, AutoShapeMappedWork, AutoShapePoint, AutoShapeResult } from "./types";
3
+ export * from "./types";
4
+ export declare function buildAutoShapeContext(params: {
5
+ rawPoints: AutoShapePoint[];
6
+ pencilOptions: AutoShapeContext["pencilOptions"];
7
+ viewId: string;
8
+ scenePath?: string;
9
+ }): AutoShapeContext | null;
10
+ export declare function detectAutoShape(context: AutoShapeContext): AutoShapeResult;
11
+ export declare function mapAutoShapeResult(result: AutoShapeResult, context: AutoShapeContext): AutoShapeMappedWork | null;
12
+ export { serializeAutoShapeWork };
@@ -0,0 +1,3 @@
1
+ import type { AutoShapeDefinition, AutoShapeMappedWork } from "./types";
2
+ export declare const defaultAutoShapeMappers: Record<Exclude<AutoShapeDefinition["kind"], "none">, AutoShapeDefinition["mapper"]>;
3
+ export declare function serializeAutoShapeWork(work: AutoShapeMappedWork): string;
@@ -0,0 +1,8 @@
1
+ import type { AutoShapeContext, AutoShapePoint, AutoShapeResult } from "./types";
2
+ export declare function createAutoShapeContext(params: {
3
+ rawPoints: AutoShapePoint[];
4
+ pencilOptions: AutoShapeContext["pencilOptions"];
5
+ viewId: string;
6
+ scenePath?: string;
7
+ }): AutoShapeContext | null;
8
+ export declare function recognizeAutoShape(context: AutoShapeContext): AutoShapeResult;
@@ -0,0 +1,2 @@
1
+ import type { AutoShapeDefinition } from "./types";
2
+ export declare function getAutoShapeDefinitions(): AutoShapeDefinition[];
@@ -0,0 +1,2 @@
1
+ import type { AutoShapeTemplateDefinition } from "./types";
2
+ export declare const defaultAutoShapeTemplates: AutoShapeTemplateDefinition[];
@@ -0,0 +1,78 @@
1
+ import type { EToolsKey } from "../enum";
2
+ import type { ShapeOptions } from "../tools";
3
+ import type { PencilOptions } from "../tools/pencil";
4
+ export type AutoShapePoint = [number, number];
5
+ export type AutoShapeKind = "straight" | "arrow" | "rectangle" | "ellipse" | "triangle" | "rhombus" | "star" | "none";
6
+ export interface AutoShapeBounds {
7
+ minX: number;
8
+ minY: number;
9
+ maxX: number;
10
+ maxY: number;
11
+ }
12
+ export interface AutoShapeMetrics {
13
+ pathLength: number;
14
+ chordLength: number;
15
+ straightness: number;
16
+ closureDistance: number;
17
+ closureRatio: number;
18
+ bboxWidth: number;
19
+ bboxHeight: number;
20
+ bboxDiagonal: number;
21
+ aspectRatio: number;
22
+ cornerCount: number;
23
+ angleVariance: number;
24
+ radialVariance: number;
25
+ bboxCornerCloseness: number;
26
+ diamondCloseness: number;
27
+ }
28
+ export interface AutoShapeContext {
29
+ viewId: string;
30
+ scenePath?: string;
31
+ pencilOptions: PencilOptions;
32
+ rawPoints: AutoShapePoint[];
33
+ points: AutoShapePoint[];
34
+ start: AutoShapePoint;
35
+ end: AutoShapePoint;
36
+ bbox: AutoShapeBounds;
37
+ metrics: AutoShapeMetrics;
38
+ }
39
+ export interface AutoShapeTemplateDefinition {
40
+ id: string;
41
+ semanticKind: Exclude<AutoShapeKind, "none">;
42
+ points: AutoShapePoint[];
43
+ threshold?: number;
44
+ }
45
+ export interface AutoShapeCandidate {
46
+ kind: Exclude<AutoShapeKind, "none">;
47
+ templateId: string;
48
+ score: number;
49
+ threshold: number;
50
+ distance: number;
51
+ }
52
+ export interface AutoShapeResult {
53
+ kind: AutoShapeKind;
54
+ score: number;
55
+ threshold: number;
56
+ recognized: boolean;
57
+ bbox: AutoShapeBounds;
58
+ start: AutoShapePoint;
59
+ end: AutoShapePoint;
60
+ points: AutoShapePoint[];
61
+ templateId?: string;
62
+ metrics: AutoShapeMetrics;
63
+ candidates: AutoShapeCandidate[];
64
+ }
65
+ export interface AutoShapeMappedWork {
66
+ toolsType: EToolsKey;
67
+ opt: ShapeOptions;
68
+ op: number[];
69
+ }
70
+ export type AutoShapePostProcessor = (candidate: AutoShapeCandidate, context: AutoShapeContext) => AutoShapeCandidate | null;
71
+ export type AutoShapeMapper = (result: AutoShapeResult, context: AutoShapeContext) => AutoShapeMappedWork | null;
72
+ export interface AutoShapeDefinition {
73
+ kind: Exclude<AutoShapeKind, "none">;
74
+ templates: AutoShapeTemplateDefinition[];
75
+ postProcessor?: AutoShapePostProcessor;
76
+ mapper: AutoShapeMapper;
77
+ enabledInV1?: boolean;
78
+ }
@@ -26,6 +26,7 @@ export declare abstract class MasterController {
26
26
  protected abstract localPointsBatchData: Map<IworkId, {
27
27
  state: EventWorkState;
28
28
  points: number[];
29
+ rawPoints: number[];
29
30
  isFullWork: boolean;
30
31
  viewId: string;
31
32
  }>;
@@ -133,6 +134,7 @@ export declare class MasterControlForWorker extends MasterController {
133
134
  protected localPointsBatchData: Map<IworkId, {
134
135
  state: EventWorkState;
135
136
  points: number[];
137
+ rawPoints: number[];
136
138
  /** 完整的绘制 */
137
139
  isFullWork: boolean;
138
140
  viewId: string;
@@ -222,11 +224,18 @@ export declare class MasterControlForWorker extends MasterController {
222
224
  getLocalPointsInfo(): Map<IworkId, {
223
225
  state: EventWorkState;
224
226
  points: number[];
227
+ rawPoints: number[];
225
228
  /** 完整的绘制 */
226
229
  isFullWork: boolean;
227
230
  viewId: string;
228
231
  opt?: BaseShapeOptions;
229
232
  }>;
233
+ private shouldUseAutoShape;
234
+ private toAutoShapePoints;
235
+ private logAutoShapeResult;
236
+ private emitAutoShapeResult;
237
+ private createAutoShapeTask;
238
+ private mapAutoShapeFallback;
230
239
  private correctStorage;
231
240
  originalEventLintener(workState: EventWorkState, point: [number, number], viewId: string): Promise<void>;
232
241
  getLocalWorkViewId(): string | undefined;
@@ -9,6 +9,9 @@ export interface PencilOptions extends BaseShapeOptions {
9
9
  thickness: number;
10
10
  strokeColor: string;
11
11
  strokeType: EStrokeType;
12
+ autoShape?: boolean;
13
+ /** 仅用于本地预览,不向 collector 同步中间态 */
14
+ previewLocalOnly?: boolean;
12
15
  }
13
16
  export declare class PencilShape extends BaseShapeTool {
14
17
  readonly canRotate: boolean;
@@ -6,6 +6,7 @@ import type { BaseShapeOptions, BaseShapeTool, ShapeOptions } from "./tools";
6
6
  import type { SelectorShape } from "./tools";
7
7
  import type { Direction } from "re-resizable/lib/resizer";
8
8
  import type { ShapeOptType } from "../displayer/types";
9
+ import type { AutoShapeResult } from "./autoShape/types";
9
10
  export type PickOne<T> = {
10
11
  [P in keyof T]: Record<P, T[P]> & Partial<Record<Exclude<keyof T, P>, undefined>>;
11
12
  }[keyof T];
@@ -155,6 +156,10 @@ export type IWorkerMessage = Omit<Partial<BaseCollectorReducerAction>, "op"> & {
155
156
  buffer: ArrayBuffer;
156
157
  }[];
157
158
  isRunBackgroundThread?: boolean;
159
+ /** 直接提交 FullWork 时,清理本地铅笔预览层 */
160
+ clearPreviewLocalWork?: boolean;
161
+ /** auto-shape 的识别结果,仅用于内部调试/日志 */
162
+ autoShapeResult?: AutoShapeResult;
158
163
  [key: string]: any;
159
164
  };
160
165
  export interface IRectType {
@@ -209,6 +214,8 @@ export interface IMainMessage extends INormalPushMsg {
209
214
  nextTasks?: IMainMessage[];
210
215
  setFontFaceResult?: boolean;
211
216
  needUndoTicker?: number;
217
+ clearPreviewLocalWork?: boolean;
218
+ autoShapeResult?: AutoShapeResult;
212
219
  [key: string]: any;
213
220
  }
214
221
  export interface IMainMessageRenderData {