@netless/window-manager 0.4.30 → 1.0.0-canary.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.
- package/CHANGELOG.md +8 -0
- package/dist/App/AppProxy.d.ts +0 -1
- package/dist/AppManager.d.ts +5 -1
- package/dist/BoxEmitter.d.ts +34 -0
- package/dist/BoxManager.d.ts +8 -6
- package/dist/Cursor/index.d.ts +3 -1
- package/dist/Helper.d.ts +0 -2
- package/dist/InternalEmitter.d.ts +2 -19
- package/dist/Utils/AppCreateQueue.d.ts +2 -3
- package/dist/View/CameraSynchronizer.d.ts +17 -0
- package/dist/View/MainView.d.ts +4 -5
- package/dist/index.cjs.js +21 -22
- package/dist/index.d.ts +2 -3
- package/dist/index.es.js +2283 -1898
- package/dist/index.umd.js +21 -22
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +2 -1
- package/docs/api.md +1 -1
- package/docs/app-context.md +127 -36
- package/docs/develop-app.md +1 -1
- package/package.json +5 -4
- package/pnpm-lock.yaml +150 -133
- package/src/App/AppContext.ts +1 -1
- package/src/App/AppProxy.ts +2 -10
- package/src/AppManager.ts +67 -59
- package/src/BoxEmitter.ts +19 -0
- package/src/BoxManager.ts +99 -108
- package/src/Cursor/Cursor.ts +3 -3
- package/src/Cursor/index.ts +13 -7
- package/src/Helper.ts +2 -15
- package/src/InternalEmitter.ts +6 -8
- package/src/Utils/AppCreateQueue.ts +2 -3
- package/src/View/CameraSynchronizer.ts +67 -0
- package/src/View/MainView.ts +45 -53
- package/src/index.ts +33 -57
- package/src/typings.ts +3 -0
- package/vite.config.js +0 -1
- package/dist/ContainerResizeObserver.d.ts +0 -11
- package/dist/ScenePath/index.d.ts +0 -12
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js.map +0 -1
- package/src/ContainerResizeObserver.ts +0 -73
- package/src/ScenePath/index.ts +0 -47
@@ -1,73 +0,0 @@
|
|
1
|
-
import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
|
2
|
-
import { isFunction } from "lodash";
|
3
|
-
import { WindowManager } from "./index";
|
4
|
-
import type { EmitterType } from "./InternalEmitter";
|
5
|
-
import type { UnsubscribeFn } from "emittery";
|
6
|
-
|
7
|
-
const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
|
8
|
-
|
9
|
-
export class ContainerResizeObserver {
|
10
|
-
private containerResizeObserver?: ResizeObserver;
|
11
|
-
private disposer?: UnsubscribeFn;
|
12
|
-
|
13
|
-
constructor(private emitter: EmitterType) {}
|
14
|
-
|
15
|
-
public static create(
|
16
|
-
container: HTMLElement,
|
17
|
-
sizer: HTMLElement,
|
18
|
-
wrapper: HTMLDivElement,
|
19
|
-
emitter: EmitterType
|
20
|
-
) {
|
21
|
-
const containerResizeObserver = new ContainerResizeObserver(emitter);
|
22
|
-
containerResizeObserver.observePlaygroundSize(container, sizer, wrapper);
|
23
|
-
return containerResizeObserver;
|
24
|
-
}
|
25
|
-
|
26
|
-
public observePlaygroundSize(
|
27
|
-
container: HTMLElement,
|
28
|
-
sizer: HTMLElement,
|
29
|
-
wrapper: HTMLDivElement
|
30
|
-
) {
|
31
|
-
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
32
|
-
|
33
|
-
this.containerResizeObserver = new ResizeObserver(entries => {
|
34
|
-
const containerRect = entries[0]?.contentRect;
|
35
|
-
if (containerRect) {
|
36
|
-
this.updateSizer(containerRect, sizer, wrapper);
|
37
|
-
this.emitter.emit("playgroundSizeChange", containerRect);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
|
41
|
-
this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
|
42
|
-
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
43
|
-
});
|
44
|
-
|
45
|
-
this.containerResizeObserver.observe(container);
|
46
|
-
}
|
47
|
-
|
48
|
-
public updateSizer(
|
49
|
-
{ width, height }: DOMRectReadOnly,
|
50
|
-
sizer: HTMLElement,
|
51
|
-
wrapper: HTMLDivElement
|
52
|
-
) {
|
53
|
-
if (width && height) {
|
54
|
-
if (height / width > WindowManager.containerSizeRatio) {
|
55
|
-
height = width * WindowManager.containerSizeRatio;
|
56
|
-
sizer.classList.toggle("netless-window-manager-sizer-horizontal", true);
|
57
|
-
} else {
|
58
|
-
width = height / WindowManager.containerSizeRatio;
|
59
|
-
sizer.classList.toggle("netless-window-manager-sizer-horizontal", false);
|
60
|
-
}
|
61
|
-
wrapper.style.width = `${width}px`;
|
62
|
-
wrapper.style.height = `${height}px`;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
public disconnect() {
|
67
|
-
this.containerResizeObserver?.disconnect();
|
68
|
-
if (isFunction(this.disposer)) {
|
69
|
-
this.disposer();
|
70
|
-
this.disposer = undefined;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
package/src/ScenePath/index.ts
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
import type { ScenesCallbacks, ScenesCallbacksNode } from "white-web-sdk";
|
2
|
-
import type { AppManager } from "../AppManager";
|
3
|
-
|
4
|
-
export class ScenesCallbackManager {
|
5
|
-
|
6
|
-
private nodes: Map<string, ScenesCallbacksNode> = new Map();
|
7
|
-
|
8
|
-
constructor(private manager: AppManager) {}
|
9
|
-
|
10
|
-
public createNode(path: string, callbacks?: Partial<ScenesCallbacks>): ScenesCallbacksNode | null {
|
11
|
-
const node = this.manager.displayer.createScenesCallback(path, callbacks);
|
12
|
-
if (node) {
|
13
|
-
this.nodes.set(path, node);
|
14
|
-
}
|
15
|
-
return node;
|
16
|
-
}
|
17
|
-
|
18
|
-
public getScenes(path: string) {
|
19
|
-
const node = this.nodes.get(path);
|
20
|
-
return node?.scenes;
|
21
|
-
}
|
22
|
-
|
23
|
-
public getScenesOnce(path: string) {
|
24
|
-
let node = this.nodes.get(path);
|
25
|
-
if (!node) {
|
26
|
-
const created = this.createNode(path);
|
27
|
-
if (created) {
|
28
|
-
node = created;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
const scenes = node?.scenes;
|
32
|
-
this.removeNode(path);
|
33
|
-
return scenes;
|
34
|
-
}
|
35
|
-
|
36
|
-
public removeNode(path: string) {
|
37
|
-
const node = this.nodes.get(path);
|
38
|
-
if (node) {
|
39
|
-
node.dispose();
|
40
|
-
this.nodes.delete(path);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
public destroy(): void {
|
45
|
-
this.nodes.forEach(node => node.dispose());
|
46
|
-
}
|
47
|
-
}
|