@netless/window-manager 1.0.14 → 1.0.15
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/dist/app-docs-viewer.js +4 -0
- package/dist/app-docs-viewer.js.map +1 -0
- package/dist/app-docs-viewer.mjs +2892 -0
- package/dist/app-docs-viewer.mjs.map +1 -0
- package/dist/app-media-player.js +31 -0
- package/dist/app-media-player.js.map +1 -0
- package/dist/app-media-player.mjs +7056 -0
- package/dist/app-media-player.mjs.map +1 -0
- package/dist/app-presentation.js +21 -0
- package/dist/app-presentation.js.map +1 -0
- package/dist/app-presentation.mjs +7538 -0
- package/dist/app-presentation.mjs.map +1 -0
- package/dist/index.d.ts +18 -1
- package/dist/index.js +5 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1204 -10940
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/App/AppProxy.ts +8 -3
- package/src/AppManager.ts +16 -11
- package/src/BuiltinApps.ts +25 -6
- package/src/ContainerResizeObserver.ts +14 -5
- package/src/Utils/RoomHacker.ts +3 -1
- package/src/Utils/attributesLogStringify.ts +13 -8
- package/src/Utils/log.ts +13 -9
- package/src/View/MainView.ts +50 -24
- package/src/css.d.ts +1 -0
- package/src/index.ts +255 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/window-manager",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Multi-window mode for Netless Whiteboard",
|
|
5
5
|
"author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@hyrious/dts": "^0.2.2",
|
|
44
44
|
"@netless/app-docs-viewer": "^0.2.19",
|
|
45
45
|
"@netless/app-media-player": "0.1.4",
|
|
46
|
+
"@netless/app-presentation": "^0.1.9",
|
|
46
47
|
"@rollup/plugin-commonjs": "^20.0.0",
|
|
47
48
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
48
49
|
"@rollup/plugin-url": "^6.1.0",
|
package/src/App/AppProxy.ts
CHANGED
|
@@ -167,7 +167,8 @@ export class AppProxy implements PageRemoveService {
|
|
|
167
167
|
params.isDragContent
|
|
168
168
|
);
|
|
169
169
|
} else {
|
|
170
|
-
this.Logger &&
|
|
170
|
+
this.Logger &&
|
|
171
|
+
this.Logger.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
|
171
172
|
throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
|
172
173
|
}
|
|
173
174
|
internalEmitter.emit("updateManagerRect");
|
|
@@ -216,7 +217,10 @@ export class AppProxy implements PageRemoveService {
|
|
|
216
217
|
}
|
|
217
218
|
setTimeout(async () => {
|
|
218
219
|
// 延迟执行 setup, 防止初始化的属性没有更新成功
|
|
219
|
-
this.Logger &&
|
|
220
|
+
this.Logger &&
|
|
221
|
+
this.Logger.info(
|
|
222
|
+
`[WindowManager]: setup app ${this.kind}, appId: ${appId}`
|
|
223
|
+
);
|
|
220
224
|
const result = await app.setup(context);
|
|
221
225
|
this.appResult = result;
|
|
222
226
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
|
@@ -561,7 +565,8 @@ export class AppProxy implements PageRemoveService {
|
|
|
561
565
|
this.manager.refresher.remove(this.stateKey);
|
|
562
566
|
this.manager.refresher.remove(`${this.id}-fullPath`);
|
|
563
567
|
this._prevFullPath = undefined;
|
|
564
|
-
this.Logger &&
|
|
568
|
+
this.Logger &&
|
|
569
|
+
this.Logger.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
|
|
565
570
|
}
|
|
566
571
|
|
|
567
572
|
public close(): Promise<void> {
|
package/src/AppManager.ts
CHANGED
|
@@ -158,7 +158,9 @@ export class AppManager {
|
|
|
158
158
|
sceneName = this.callbacksNode?.scenes[nextIndex];
|
|
159
159
|
}
|
|
160
160
|
if (sceneName) {
|
|
161
|
-
console.log(
|
|
161
|
+
console.log(
|
|
162
|
+
`[window-manager] onRemoveScenes setMainViewScenePath ${ROOT_DIR}${sceneName}`
|
|
163
|
+
);
|
|
162
164
|
this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
|
163
165
|
}
|
|
164
166
|
await this.setMainViewSceneIndex(nextIndex);
|
|
@@ -604,9 +606,10 @@ export class AppManager {
|
|
|
604
606
|
try {
|
|
605
607
|
const appAttributes = this.attributes[id];
|
|
606
608
|
if (!appAttributes) {
|
|
607
|
-
this.Logger &&
|
|
608
|
-
|
|
609
|
-
|
|
609
|
+
this.Logger &&
|
|
610
|
+
this.Logger.error(
|
|
611
|
+
`[WindowManager]: appAttributes is undefined, appId: ${id}`
|
|
612
|
+
);
|
|
610
613
|
throw new Error("appAttributes is undefined");
|
|
611
614
|
}
|
|
612
615
|
|
|
@@ -712,7 +715,9 @@ export class AppManager {
|
|
|
712
715
|
callbacks.emit("onMainViewMounted", mainView);
|
|
713
716
|
const hasRoot = this.hasRoot(mainView.divElement);
|
|
714
717
|
const rect = this.getRectByDivElement(mainView.divElement);
|
|
715
|
-
let log = `[window-manager] bindMainView hasRoot:${hasRoot}, rect:${JSON.stringify(
|
|
718
|
+
let log = `[window-manager] bindMainView hasRoot:${hasRoot}, rect:${JSON.stringify(
|
|
719
|
+
rect
|
|
720
|
+
)}, outerHeight:${window.outerHeight}, outerWidth:${window.outerWidth}`;
|
|
716
721
|
const visualViewport = window.visualViewport;
|
|
717
722
|
if (visualViewport) {
|
|
718
723
|
log += `, visualViewportWidth:${visualViewport.width}, visualViewportHeight:${visualViewport.height}, visualViewportOffsetLeft:${visualViewport.offsetLeft}, visualViewportOffsetTop:${visualViewport.offsetTop}`;
|
|
@@ -720,7 +725,7 @@ export class AppManager {
|
|
|
720
725
|
console.log(log);
|
|
721
726
|
}
|
|
722
727
|
|
|
723
|
-
private hasRoot(divElement: HTMLDivElement){
|
|
728
|
+
private hasRoot(divElement: HTMLDivElement) {
|
|
724
729
|
let current = divElement;
|
|
725
730
|
while (current) {
|
|
726
731
|
if (current.parentElement === document.body) {
|
|
@@ -731,7 +736,7 @@ export class AppManager {
|
|
|
731
736
|
return false;
|
|
732
737
|
}
|
|
733
738
|
|
|
734
|
-
private getRectByDivElement(divElement: HTMLDivElement){
|
|
739
|
+
private getRectByDivElement(divElement: HTMLDivElement) {
|
|
735
740
|
// 获取当前divElement的矩形区域
|
|
736
741
|
const rect = divElement.getBoundingClientRect();
|
|
737
742
|
return rect;
|
|
@@ -818,7 +823,8 @@ export class AppManager {
|
|
|
818
823
|
return appProxy;
|
|
819
824
|
} else {
|
|
820
825
|
this.appStatus.delete(appId);
|
|
821
|
-
this.Logger &&
|
|
826
|
+
this.Logger &&
|
|
827
|
+
this.Logger.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
|
|
822
828
|
throw new Error("[WindowManger]: initialize AppProxy failed");
|
|
823
829
|
}
|
|
824
830
|
}
|
|
@@ -858,7 +864,8 @@ export class AppManager {
|
|
|
858
864
|
const scenePathType = this.displayer.scenePathType(scenePath);
|
|
859
865
|
const sceneDir = parseSceneDir(scenePath);
|
|
860
866
|
if (sceneDir !== ROOT_DIR) {
|
|
861
|
-
this.Logger &&
|
|
867
|
+
this.Logger &&
|
|
868
|
+
this.Logger.error(`[WindowManager]: main view scenePath must in root dir "/"`);
|
|
862
869
|
throw new Error(`[WindowManager]: main view scenePath must in root dir "/"`);
|
|
863
870
|
}
|
|
864
871
|
if (scenePathType === ScenePathType.None) {
|
|
@@ -866,7 +873,6 @@ export class AppManager {
|
|
|
866
873
|
throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
|
|
867
874
|
} else if (scenePathType === ScenePathType.Page) {
|
|
868
875
|
await this._setMainViewScenePath(scenePath);
|
|
869
|
-
|
|
870
876
|
} else if (scenePathType === ScenePathType.Dir) {
|
|
871
877
|
const validScenePath = makeValidScenePath(this.displayer, scenePath);
|
|
872
878
|
if (validScenePath) {
|
|
@@ -1000,4 +1006,3 @@ export class AppManager {
|
|
|
1000
1006
|
this._resolveTimer = undefined;
|
|
1001
1007
|
}
|
|
1002
1008
|
}
|
|
1003
|
-
|
package/src/BuiltinApps.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import AppDocsViewer from "@netless/app-docs-viewer";
|
|
2
1
|
import { WindowManager } from "./index";
|
|
3
2
|
|
|
4
3
|
const loadAppMediaPlayer = async () => {
|
|
@@ -9,18 +8,38 @@ const loadAppMediaPlayer = async () => {
|
|
|
9
8
|
return (mod.default || mod) as any;
|
|
10
9
|
};
|
|
11
10
|
|
|
11
|
+
const loadAppDocsViewer = async () => {
|
|
12
|
+
const mod = await import("@netless/app-docs-viewer");
|
|
13
|
+
return (mod.default || mod) as any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const loadAppPresentation = async () => {
|
|
17
|
+
const mod = await import("@netless/app-presentation");
|
|
18
|
+
return (mod.default || mod) as any;
|
|
19
|
+
};
|
|
20
|
+
|
|
12
21
|
export const setupBuiltin = () => {
|
|
13
22
|
WindowManager.register({
|
|
14
|
-
kind:
|
|
15
|
-
src:
|
|
23
|
+
kind: BuiltinApps.DocsViewer,
|
|
24
|
+
src: loadAppDocsViewer,
|
|
16
25
|
});
|
|
17
26
|
WindowManager.register({
|
|
18
|
-
kind:
|
|
27
|
+
kind: BuiltinApps.MediaPlayer,
|
|
19
28
|
src: loadAppMediaPlayer,
|
|
20
29
|
});
|
|
30
|
+
WindowManager.register({
|
|
31
|
+
kind: BuiltinApps.Presentation,
|
|
32
|
+
src: loadAppPresentation,
|
|
33
|
+
appOptions: {
|
|
34
|
+
reScaleOnPageChange: true,
|
|
35
|
+
debounceSync: true,
|
|
36
|
+
useScrollbar: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
21
39
|
};
|
|
22
40
|
|
|
23
41
|
export const BuiltinApps = {
|
|
24
|
-
DocsViewer:
|
|
25
|
-
MediaPlayer: "MediaPlayer"
|
|
42
|
+
DocsViewer: "DocsViewer",
|
|
43
|
+
MediaPlayer: "MediaPlayer",
|
|
44
|
+
Presentation: "Presentation",
|
|
26
45
|
};
|
|
@@ -9,7 +9,7 @@ const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
|
|
|
9
9
|
export class ContainerResizeObserver {
|
|
10
10
|
private containerResizeObserver?: ResizeObserver;
|
|
11
11
|
private disposer?: UnsubscribeFn;
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
private updateSizerLocalConsole = new LocalConsole("updateSizer", 100);
|
|
14
14
|
|
|
15
15
|
constructor(private emitter: EmitterType) {}
|
|
@@ -30,19 +30,24 @@ export class ContainerResizeObserver {
|
|
|
30
30
|
sizer: HTMLElement,
|
|
31
31
|
wrapper: HTMLDivElement
|
|
32
32
|
) {
|
|
33
|
-
this.updateSizer(
|
|
33
|
+
this.updateSizer(
|
|
34
|
+
container.getBoundingClientRect(),
|
|
35
|
+
sizer,
|
|
36
|
+
wrapper,
|
|
37
|
+
"observePlaygroundSize"
|
|
38
|
+
);
|
|
34
39
|
|
|
35
40
|
this.containerResizeObserver = new ResizeObserver(entries => {
|
|
36
41
|
const containerRect = entries[0]?.contentRect;
|
|
37
42
|
if (containerRect) {
|
|
38
|
-
this.updateSizer(containerRect, sizer, wrapper,
|
|
43
|
+
this.updateSizer(containerRect, sizer, wrapper, "containerResizeObserver");
|
|
39
44
|
this.emitter.emit("playgroundSizeChange", containerRect);
|
|
40
45
|
}
|
|
41
46
|
});
|
|
42
47
|
|
|
43
48
|
this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
|
|
44
49
|
const containerRect = container.getBoundingClientRect();
|
|
45
|
-
this.updateSizer(containerRect, sizer, wrapper,
|
|
50
|
+
this.updateSizer(containerRect, sizer, wrapper, "containerSizeRatioUpdate");
|
|
46
51
|
this.emitter.emit("playgroundSizeChange", containerRect);
|
|
47
52
|
});
|
|
48
53
|
|
|
@@ -66,7 +71,11 @@ export class ContainerResizeObserver {
|
|
|
66
71
|
wrapper.style.width = `${width}px`;
|
|
67
72
|
wrapper.style.height = `${height}px`;
|
|
68
73
|
const wrapperRect = wrapper.getBoundingClientRect();
|
|
69
|
-
this.updateSizerLocalConsole.log(
|
|
74
|
+
this.updateSizerLocalConsole.log(
|
|
75
|
+
`from ${origin}, traget size: ${JSON.stringify({ width, height })}, wrapperRect: ${
|
|
76
|
+
wrapperRect.width
|
|
77
|
+
} ${wrapperRect.height}`
|
|
78
|
+
);
|
|
70
79
|
this.emitter.emit("wrapperRectChange", {
|
|
71
80
|
width: wrapperRect.width,
|
|
72
81
|
height: wrapperRect.height,
|
package/src/Utils/RoomHacker.ts
CHANGED
|
@@ -48,7 +48,9 @@ export const replaceRoomFunction = (room: Room | Player, manager: WindowManager)
|
|
|
48
48
|
console.log("[window-manager] putScenes " + JSON.stringify(args));
|
|
49
49
|
for (const scene of scenes) {
|
|
50
50
|
if (`${path}${scene.name}` === currentScenePath) {
|
|
51
|
-
console.error(
|
|
51
|
+
console.error(
|
|
52
|
+
`[window-manager] putScenes: scene name can not be the same as the current scene path: ${currentScenePath}`
|
|
53
|
+
);
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -3,11 +3,16 @@ function formatAttributesLogObjectKey(key: string): string {
|
|
|
3
3
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
type AttributesLogRecord = Record<string, unknown>;
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* attributes 调试日志:对象/数组会写成近似 JS 字面量(保留 `undefined`、数组空洞),避免 `[object Object]`;
|
|
8
10
|
* 并处理 BigInt、循环引用等。
|
|
9
11
|
*/
|
|
10
|
-
export function stringifyForAttributesLog(
|
|
12
|
+
export function stringifyForAttributesLog(
|
|
13
|
+
value: unknown,
|
|
14
|
+
seen?: WeakSet<AttributesLogRecord>
|
|
15
|
+
): string {
|
|
11
16
|
if (value === undefined) {
|
|
12
17
|
return "undefined";
|
|
13
18
|
}
|
|
@@ -29,17 +34,17 @@ export function stringifyForAttributesLog(value: unknown, seen?: WeakSet<object>
|
|
|
29
34
|
return t === "string" ? JSON.stringify(value as string) : String(value);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
const obj = value as
|
|
37
|
+
const obj = value as AttributesLogRecord;
|
|
33
38
|
if (seen?.has(obj)) {
|
|
34
39
|
return "[Circular]";
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
const nextSeen = seen ?? new WeakSet<
|
|
42
|
+
const nextSeen = seen ?? new WeakSet<AttributesLogRecord>();
|
|
38
43
|
nextSeen.add(obj);
|
|
39
44
|
try {
|
|
40
45
|
if (Array.isArray(value)) {
|
|
41
|
-
return `[${Array.from(value as unknown[],
|
|
42
|
-
stringifyForAttributesLog(item, nextSeen)
|
|
46
|
+
return `[${Array.from(value as unknown[], item =>
|
|
47
|
+
stringifyForAttributesLog(item, nextSeen)
|
|
43
48
|
).join(",")}]`;
|
|
44
49
|
}
|
|
45
50
|
if (value instanceof Date) {
|
|
@@ -48,11 +53,11 @@ export function stringifyForAttributesLog(value: unknown, seen?: WeakSet<object>
|
|
|
48
53
|
if (value instanceof RegExp) {
|
|
49
54
|
return String(value);
|
|
50
55
|
}
|
|
51
|
-
const keys = Object.keys(
|
|
52
|
-
const pairs = keys.map(
|
|
56
|
+
const keys = Object.keys(obj);
|
|
57
|
+
const pairs = keys.map(k => {
|
|
53
58
|
let v: unknown;
|
|
54
59
|
try {
|
|
55
|
-
v =
|
|
60
|
+
v = obj[k];
|
|
56
61
|
} catch {
|
|
57
62
|
return `${formatAttributesLogObjectKey(k)}:[Threw]`;
|
|
58
63
|
}
|
package/src/Utils/log.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Logger } from "white-web-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isShallowMergeAttributesRecord,
|
|
4
|
+
stringifyForAttributesLog,
|
|
5
|
+
} from "./attributesLogStringify";
|
|
3
6
|
import { WindowManager } from "../index";
|
|
4
7
|
|
|
5
8
|
/** ArgusLog 经 `logger.info` 上报的单条字符串上限(含前缀) */
|
|
@@ -39,10 +42,7 @@ export class LocalConsole {
|
|
|
39
42
|
private pendingArgs: unknown[] | null = null;
|
|
40
43
|
private flushTimer: ReturnType<typeof setTimeout> | null = null;
|
|
41
44
|
|
|
42
|
-
constructor(
|
|
43
|
-
private readonly name: string,
|
|
44
|
-
private readonly debounceTime?: number,
|
|
45
|
-
) {}
|
|
45
|
+
constructor(private readonly name: string, private readonly debounceTime?: number) {}
|
|
46
46
|
|
|
47
47
|
private flush(): void {
|
|
48
48
|
this.flushTimer = null;
|
|
@@ -102,7 +102,7 @@ export class ArgusLog {
|
|
|
102
102
|
constructor(
|
|
103
103
|
private readonly logger: Logger,
|
|
104
104
|
private readonly name: string,
|
|
105
|
-
private readonly debounceTime?: number
|
|
105
|
+
private readonly debounceTime?: number
|
|
106
106
|
) {}
|
|
107
107
|
|
|
108
108
|
private emitInfo(message: string): void {
|
|
@@ -127,7 +127,9 @@ export class ArgusLog {
|
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
const body =
|
|
130
|
-
p.kind === "record"
|
|
130
|
+
p.kind === "record"
|
|
131
|
+
? stringifyForAttributesLog(p.data)
|
|
132
|
+
: stringifyForAttributesLog(p.value);
|
|
131
133
|
this.emitInfo(`[WindowManager][${this.name}]: ${p.label} ${body}`);
|
|
132
134
|
// 输出后释放合并对象引用,避免长时间持有 attributes 快照
|
|
133
135
|
if (p.kind === "record") {
|
|
@@ -198,7 +200,7 @@ export class ArgusLog {
|
|
|
198
200
|
return;
|
|
199
201
|
}
|
|
200
202
|
const parts = segments.map(
|
|
201
|
-
|
|
203
|
+
s => `${s.keys.join(", ")} ${stringifyForAttributesLog(s.value)}`
|
|
202
204
|
);
|
|
203
205
|
this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${parts.join(" | ")}`);
|
|
204
206
|
for (const s of segments) {
|
|
@@ -219,7 +221,9 @@ export class ArgusLog {
|
|
|
219
221
|
|
|
220
222
|
if (!debounced) {
|
|
221
223
|
this.emitInfo(
|
|
222
|
-
`[WindowManager][${this.name}]: safeUpdateAttributes ${keysCopy.join(
|
|
224
|
+
`[WindowManager][${this.name}]: safeUpdateAttributes ${keysCopy.join(
|
|
225
|
+
", "
|
|
226
|
+
)} ${stringifyForAttributesLog(value)}`
|
|
223
227
|
);
|
|
224
228
|
return;
|
|
225
229
|
}
|
package/src/View/MainView.ts
CHANGED
|
@@ -3,11 +3,12 @@ import { callbacks } from "../callback";
|
|
|
3
3
|
import { createView } from "./ViewManager";
|
|
4
4
|
import { debounce, get, isEmpty, isEqual } from "lodash";
|
|
5
5
|
import { internalEmitter } from "../InternalEmitter";
|
|
6
|
-
import { Fields
|
|
6
|
+
import { Fields } from "../AttributesDelegate";
|
|
7
7
|
import { setViewFocusScenePath } from "../Utils/Common";
|
|
8
8
|
import { SideEffectManager } from "side-effect-manager";
|
|
9
9
|
import type { Camera, Room, Size, View } from "white-web-sdk";
|
|
10
10
|
import type { AppManager } from "../AppManager";
|
|
11
|
+
import type { MainViewCamera } from "../AttributesDelegate";
|
|
11
12
|
import { Events } from "../constants";
|
|
12
13
|
import { LocalConsole } from "../Utils/log";
|
|
13
14
|
|
|
@@ -35,7 +36,10 @@ export class MainViewProxy {
|
|
|
35
36
|
|
|
36
37
|
private sideEffectManager = new SideEffectManager();
|
|
37
38
|
|
|
38
|
-
private playgroundSizeChangeListenerLocalConsole = new LocalConsole(
|
|
39
|
+
private playgroundSizeChangeListenerLocalConsole = new LocalConsole(
|
|
40
|
+
"playgroundSizeChangeListener",
|
|
41
|
+
100
|
|
42
|
+
);
|
|
39
43
|
private sizeUpdatedLocalConsole = new LocalConsole("sizeUpdated", 100);
|
|
40
44
|
private cameraUpdatedLocalConsole = new LocalConsole("cameraUpdated", 100);
|
|
41
45
|
private cameraReactionLocalConsole = new LocalConsole("cameraReaction", 100);
|
|
@@ -52,12 +56,15 @@ export class MainViewProxy {
|
|
|
52
56
|
const playgroundSizeChangeListener = () => {
|
|
53
57
|
this.playgroundSizeChangeListenerLocalConsole.log(
|
|
54
58
|
JSON.stringify(this.mainView.camera),
|
|
55
|
-
JSON.stringify(this.mainView.size),
|
|
56
|
-
JSON.stringify(this.mainViewSize),
|
|
59
|
+
JSON.stringify(this.mainView.size),
|
|
60
|
+
JSON.stringify(this.mainViewSize),
|
|
57
61
|
JSON.stringify(this.mainViewCamera),
|
|
58
|
-
window.outerHeight,
|
|
59
|
-
window.
|
|
60
|
-
window.visualViewport?.
|
|
62
|
+
window.outerHeight,
|
|
63
|
+
window.outerWidth,
|
|
64
|
+
window.visualViewport?.width ?? "null",
|
|
65
|
+
window.visualViewport?.height ?? "null",
|
|
66
|
+
window.visualViewport?.offsetLeft ?? "null",
|
|
67
|
+
window.visualViewport?.offsetTop ?? "null"
|
|
61
68
|
);
|
|
62
69
|
this.sizeChangeHandler(this.mainViewSize);
|
|
63
70
|
};
|
|
@@ -164,7 +171,7 @@ export class MainViewProxy {
|
|
|
164
171
|
element: HTMLDivElement
|
|
165
172
|
) {
|
|
166
173
|
const { width: viewWidth, height: viewHeight } = this.mainView.size;
|
|
167
|
-
|
|
174
|
+
const targetElement = element;
|
|
168
175
|
if (
|
|
169
176
|
Math.abs(viewWidth - observedSize.width) <= 0.5 &&
|
|
170
177
|
Math.abs(viewHeight - observedSize.height) <= 0.5
|
|
@@ -172,11 +179,14 @@ export class MainViewProxy {
|
|
|
172
179
|
return;
|
|
173
180
|
}
|
|
174
181
|
if (this.isForcingMainViewDivElement) {
|
|
175
|
-
console.log(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
console.log(
|
|
183
|
+
"[window-manager] skipForceSyncMainViewDivElement " +
|
|
184
|
+
JSON.stringify({
|
|
185
|
+
reason,
|
|
186
|
+
observedSize,
|
|
187
|
+
viewSize: this.mainView.size,
|
|
188
|
+
})
|
|
189
|
+
);
|
|
180
190
|
return;
|
|
181
191
|
}
|
|
182
192
|
this.isForcingMainViewDivElement = true;
|
|
@@ -202,11 +212,14 @@ export class MainViewProxy {
|
|
|
202
212
|
} finally {
|
|
203
213
|
queueMicrotask(() => {
|
|
204
214
|
const rect = targetElement.getBoundingClientRect();
|
|
205
|
-
console.log(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
215
|
+
console.log(
|
|
216
|
+
"[window-manager] forceSyncMainViewDivElementResult " +
|
|
217
|
+
JSON.stringify({
|
|
218
|
+
reason,
|
|
219
|
+
viewSize: this.mainView.size,
|
|
220
|
+
rect: { width: rect.width, height: rect.height },
|
|
221
|
+
})
|
|
222
|
+
);
|
|
210
223
|
this.isForcingMainViewDivElement = false;
|
|
211
224
|
});
|
|
212
225
|
}
|
|
@@ -220,10 +233,14 @@ export class MainViewProxy {
|
|
|
220
233
|
this.addCameraReaction();
|
|
221
234
|
if (this.manager.room) this.syncMainView(this.manager.room);
|
|
222
235
|
this.started = true;
|
|
223
|
-
if(this.mainView.focusScenePath) {
|
|
224
|
-
this.manager.windowManger.onMainViewScenePathChangeHandler(
|
|
236
|
+
if (this.mainView.focusScenePath) {
|
|
237
|
+
this.manager.windowManger.onMainViewScenePathChangeHandler(
|
|
238
|
+
this.mainView.focusScenePath
|
|
239
|
+
);
|
|
225
240
|
}
|
|
226
|
-
console.log(
|
|
241
|
+
console.log(
|
|
242
|
+
"[window-manager] start end mainView size:" + JSON.stringify(this.mainView.size)
|
|
243
|
+
);
|
|
227
244
|
}
|
|
228
245
|
|
|
229
246
|
public addCameraReaction = () => {
|
|
@@ -243,7 +260,11 @@ export class MainViewProxy {
|
|
|
243
260
|
if (camera && camera.id !== this.manager.uid) {
|
|
244
261
|
this.moveCameraToContian(this.mainViewSize);
|
|
245
262
|
this.moveCamera(camera);
|
|
246
|
-
this.cameraReactionLocalConsole.log(
|
|
263
|
+
this.cameraReactionLocalConsole.log(
|
|
264
|
+
`camera: ${JSON.stringify(camera)}, current size: ${JSON.stringify(
|
|
265
|
+
this.mainViewSize
|
|
266
|
+
)}`
|
|
267
|
+
);
|
|
247
268
|
}
|
|
248
269
|
},
|
|
249
270
|
{ fireImmediately: true }
|
|
@@ -254,8 +275,13 @@ export class MainViewProxy {
|
|
|
254
275
|
if (size) {
|
|
255
276
|
this.moveCameraToContian(size);
|
|
256
277
|
this.moveCamera(this.mainViewCamera);
|
|
257
|
-
console.log(
|
|
258
|
-
|
|
278
|
+
console.log(
|
|
279
|
+
"[window-manager] sizeChangeHandler current size and camera" +
|
|
280
|
+
JSON.stringify(size) +
|
|
281
|
+
JSON.stringify(this.mainViewCamera) +
|
|
282
|
+
JSON.stringify(this.mainView.camera) +
|
|
283
|
+
JSON.stringify(this.mainView.size)
|
|
284
|
+
);
|
|
259
285
|
}
|
|
260
286
|
this.ensureMainViewSize();
|
|
261
287
|
}, 30);
|
package/src/css.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css";
|