@netless/window-manager 0.4.1-canary.0 → 0.4.4

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/docs/api.md CHANGED
@@ -14,6 +14,15 @@
14
14
  - [`cleanCurrentScene`](#cleanCurrentScene)
15
15
  - [`redo`](#redo)
16
16
  - [`undo`](#undo)
17
+ - [`copy`](#copy)
18
+ - [`paste`](#paste)
19
+ - [`delete`](#delete)
20
+ - [`duplicate`](#duplicate)
21
+ - [`insertText`](#insertText)
22
+ - [`insertImage`](#insertImage)
23
+ - [`completeImageUpload`](#completeImageUpload)
24
+ - [`lockImage`](#lockImage)
25
+ - [`lockImages`](#lockImages)
17
26
  - [实例属性](#prototypes)
18
27
  - [事件回调](#events)
19
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.1-canary.0",
3
+ "version": "0.4.4",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -27,12 +27,12 @@
27
27
  "p-retry": "^4.6.1",
28
28
  "side-effect-manager": "^0.1.5",
29
29
  "uuid": "^7.0.3",
30
- "video.js": ">=7"
30
+ "video.js": ">=7",
31
+ "@netless/telebox-insider": "0.2.22"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@netless/app-docs-viewer": "^0.2.6",
34
35
  "@netless/app-media-player": "0.1.0-beta.5",
35
- "@netless/telebox-insider": "0.2.22",
36
36
  "@rollup/plugin-commonjs": "^20.0.0",
37
37
  "@rollup/plugin-node-resolve": "^13.0.4",
38
38
  "@rollup/plugin-url": "^6.1.0",
@@ -201,7 +201,7 @@ export class Storage<TState extends Record<string, any> = any> implements Storag
201
201
  private _getRawState(defaultValue: TState): TState
202
202
  private _getRawState(defaultValue?: TState): TState | undefined {
203
203
  if (this.id === null) {
204
- return get(this._context.getAttributes(), [], defaultValue);
204
+ return this._context.getAttributes() ?? defaultValue;
205
205
  } else {
206
206
  return get(this._context.getAttributes(), [STORAGE_NS, this.id], defaultValue);
207
207
  }
@@ -44,6 +44,10 @@ export const replaceRoomFunction = (room: Room | Player, manager: WindowManager)
44
44
  room.redo = () => manager.redo();
45
45
  room.undo = () => manager.undo();
46
46
  room.cleanCurrentScene = () => manager.cleanCurrentScene();
47
+ room.delete = () => manager.delete();
48
+ room.copy = () => manager.copy();
49
+ room.paste = () => manager.paste();
50
+ room.duplicate = () => manager.duplicate();
47
51
  delegateRemoveScenes(room);
48
52
  }
49
53
  };
@@ -18,7 +18,11 @@ export class ViewManager {
18
18
  public destroyView(id: string): void {
19
19
  const view = this.views.get(id);
20
20
  if (view) {
21
- view.release();
21
+ try {
22
+ view.release();
23
+ } catch {
24
+ // ignore
25
+ }
22
26
  this.views.delete(id);
23
27
  }
24
28
  }
@@ -32,7 +36,11 @@ export class ViewManager {
32
36
 
33
37
  public destroy() {
34
38
  this.views.forEach(view => {
35
- view.release();
39
+ try {
40
+ view.release();
41
+ } catch {
42
+ // ignore
43
+ }
36
44
  });
37
45
  this.views.clear();
38
46
  }
package/src/index.ts CHANGED
@@ -47,6 +47,7 @@ import type {
47
47
  ViewVisionMode,
48
48
  CameraState,
49
49
  Player,
50
+ ImageInformation,
50
51
  } from "white-web-sdk";
51
52
  import type { AppListeners } from "./AppListener";
52
53
  import type { NetlessApp, RegisterParams } from "./typings";
@@ -614,6 +615,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
614
615
  return this.attributes.focus;
615
616
  }
616
617
 
618
+ public get focusedView(): View | undefined {
619
+ return this.appManager?.focusApp?.view || this.mainView;
620
+ }
621
+
617
622
  public get mainViewSceneIndex(): number {
618
623
  return this.appManager?.store.getMainViewSceneIndex();
619
624
  }
@@ -683,7 +688,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
683
688
  this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
684
689
  setTimeout(() => {
685
690
  this.appManager?.mainViewProxy.setCameraAndSize();
686
- }, 100);
691
+ }, 500);
687
692
  }
688
693
 
689
694
  public moveCameraToContain(
@@ -696,7 +701,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
696
701
  this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
697
702
  setTimeout(() => {
698
703
  this.appManager?.mainViewProxy.setCameraAndSize();
699
- }, 100);
704
+ }, 500);
700
705
  }
701
706
 
702
707
  public convertToPointInWorld(point: Point): Point {
@@ -768,30 +773,51 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
768
773
  }
769
774
 
770
775
  public cleanCurrentScene(): void {
771
- const focused = this.focused;
772
- if (focused) {
773
- this.appManager?.focusApp?.view?.cleanCurrentScene();
774
- } else {
775
- this.mainView.cleanCurrentScene();
776
- }
776
+ this.focusedView?.cleanCurrentScene();
777
777
  }
778
778
 
779
779
  public redo(): number {
780
- const focused = this.focused;
781
- if (focused) {
782
- return this.appManager?.focusApp?.view?.redo() || 0;
783
- } else {
784
- return this.mainView.redo();
785
- }
780
+ return this.focusedView?.redo() || 0;
786
781
  }
787
782
 
788
783
  public undo(): number {
789
- const focused = this.focused;
790
- if (focused) {
791
- return this.appManager?.focusApp?.view?.undo() || 0;
792
- } else {
793
- return this.mainView.undo();
794
- }
784
+ return this.focusedView?.undo() || 0;
785
+ }
786
+
787
+ public delete(): void {
788
+ this.focusedView?.delete();
789
+ }
790
+
791
+ public copy(): void {
792
+ this.focusedView?.copy();
793
+ }
794
+
795
+ public paste(): void {
796
+ this.focusedView?.paste();
797
+ }
798
+
799
+ public duplicate(): void {
800
+ this.focusedView?.duplicate();
801
+ }
802
+
803
+ public insertText(x: number, y: number, text: string): string {
804
+ return this.focusedView?.insertText(x, y, text) || "";
805
+ }
806
+
807
+ public insertImage(info: ImageInformation): void {
808
+ return this.focusedView?.insertImage(info);
809
+ }
810
+
811
+ public completeImageUpload(uuid: string, url: string): void {
812
+ return this.focusedView?.completeImageUpload(uuid, url);
813
+ }
814
+
815
+ public lockImage(uuid: string, locked: boolean): void {
816
+ return this.focusedView?.lockImage(uuid, locked);
817
+ }
818
+
819
+ public lockImages(locked: boolean): void {
820
+ return this.focusedView?.lockImages(locked);
795
821
  }
796
822
 
797
823
  private isDynamicPPT(scenes: SceneDefinition[]) {
package/vite.config.js CHANGED
@@ -2,7 +2,7 @@ import path from "path";
2
2
  import { defineConfig } from "vite";
3
3
  import { svelte } from "@sveltejs/vite-plugin-svelte";
4
4
  import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
5
-
5
+ import { omit } from "lodash";
6
6
 
7
7
  export default defineConfig(({ mode }) => {
8
8
  const isProd = mode === "production";
@@ -34,7 +34,7 @@ export default defineConfig(({ mode }) => {
34
34
  sourcemap: true,
35
35
  rollupOptions: {
36
36
  external: Object.keys({
37
- ...dependencies,
37
+ ...omit(dependencies, ["@netless/telebox-insider"]),
38
38
  ...peerDependencies,
39
39
  }),
40
40
  },