@netless/window-manager 1.0.0-canary.61 → 1.0.0-canary.63
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/index.js +81 -37
- package/dist/index.mjs +81 -37
- package/dist/index.umd.js +81 -37
- package/dist/src/AppManager.d.ts +2 -2
- package/dist/src/Page/PageController.d.ts +1 -0
- package/dist/src/PageState.d.ts +1 -0
- package/dist/src/View/CameraSynchronizer.d.ts +1 -1
- package/dist/src/View/MainView.d.ts +1 -0
- package/package.json +1 -1
- package/pnpm-lock.yaml +6 -6
- package/src/App/AppPageStateImpl.ts +3 -0
- package/src/App/WhiteboardView.ts +0 -1
- package/src/AppListener.ts +7 -1
- package/src/AppManager.ts +1 -1
- package/src/Cursor/Cursor.ts +2 -2
- package/src/Cursor/index.ts +3 -1
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +7 -0
- package/src/ReconnectRefresher.ts +1 -1
- package/src/View/CameraSynchronizer.ts +9 -6
- package/src/View/MainView.ts +5 -0
- package/src/View/ViewSync.ts +1 -2
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
@@ -238,25 +238,25 @@ function deleteRecord(db2, key) {
|
|
238
238
|
request.onerror = () => reject();
|
239
239
|
});
|
240
240
|
}
|
241
|
-
var __defProp$
|
242
|
-
var __defProps$
|
243
|
-
var __getOwnPropDescs$
|
244
|
-
var __getOwnPropSymbols$
|
245
|
-
var __hasOwnProp$
|
246
|
-
var __propIsEnum$
|
247
|
-
var __defNormalProp$
|
248
|
-
var __spreadValues$
|
241
|
+
var __defProp$9 = Object.defineProperty;
|
242
|
+
var __defProps$5 = Object.defineProperties;
|
243
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
244
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
245
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
246
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
247
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
248
|
+
var __spreadValues$9 = (a, b) => {
|
249
249
|
for (var prop in b || (b = {}))
|
250
|
-
if (__hasOwnProp$
|
251
|
-
__defNormalProp$
|
252
|
-
if (__getOwnPropSymbols$
|
253
|
-
for (var prop of __getOwnPropSymbols$
|
254
|
-
if (__propIsEnum$
|
255
|
-
__defNormalProp$
|
250
|
+
if (__hasOwnProp$9.call(b, prop))
|
251
|
+
__defNormalProp$9(a, prop, b[prop]);
|
252
|
+
if (__getOwnPropSymbols$9)
|
253
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
254
|
+
if (__propIsEnum$9.call(b, prop))
|
255
|
+
__defNormalProp$9(a, prop, b[prop]);
|
256
256
|
}
|
257
257
|
return a;
|
258
258
|
};
|
259
|
-
var __spreadProps$
|
259
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
260
260
|
var __async$b = (__this, __arguments, generator) => {
|
261
261
|
return new Promise((resolve, reject) => {
|
262
262
|
var fulfilled = (value) => {
|
@@ -339,7 +339,7 @@ function fetchWithTimeout(resource, options) {
|
|
339
339
|
const { timeout = 1e4 } = options;
|
340
340
|
const controller = new AbortController();
|
341
341
|
const id = setTimeout(() => controller.abort(), timeout);
|
342
|
-
const response = yield fetch(resource, __spreadProps$
|
342
|
+
const response = yield fetch(resource, __spreadProps$5(__spreadValues$9({}, options), {
|
343
343
|
signal: controller.signal,
|
344
344
|
headers: {
|
345
345
|
"content-type": "text/plain"
|
@@ -606,6 +606,25 @@ const isRootDirPage = (scenePath) => {
|
|
606
606
|
}, 0);
|
607
607
|
return delimiterCount === 1;
|
608
608
|
};
|
609
|
+
var __defProp$8 = Object.defineProperty;
|
610
|
+
var __defProps$4 = Object.defineProperties;
|
611
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
612
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
613
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
614
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
615
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
616
|
+
var __spreadValues$8 = (a, b) => {
|
617
|
+
for (var prop in b || (b = {}))
|
618
|
+
if (__hasOwnProp$8.call(b, prop))
|
619
|
+
__defNormalProp$8(a, prop, b[prop]);
|
620
|
+
if (__getOwnPropSymbols$8)
|
621
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
622
|
+
if (__propIsEnum$8.call(b, prop))
|
623
|
+
__defNormalProp$8(a, prop, b[prop]);
|
624
|
+
}
|
625
|
+
return a;
|
626
|
+
};
|
627
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
609
628
|
class AppListeners {
|
610
629
|
constructor(manager) {
|
611
630
|
this.manager = manager;
|
@@ -706,7 +725,13 @@ class AppListeners {
|
|
706
725
|
}
|
707
726
|
};
|
708
727
|
this.moveCameraHandler = (payload) => {
|
709
|
-
this.manager.
|
728
|
+
const size$ = this.manager.mainViewProxy.size$;
|
729
|
+
if (size$.value) {
|
730
|
+
const size = this.manager.mainView.size;
|
731
|
+
const diff = Math.max(size.height / size$.value.height, size.width / size$.value.width);
|
732
|
+
const nextCamera = __spreadProps$4(__spreadValues$8({}, payload), { scale: payload.scale * diff });
|
733
|
+
this.manager.mainView.moveCamera(nextCamera);
|
734
|
+
}
|
710
735
|
};
|
711
736
|
this.moveCameraToContainHandler = (payload) => {
|
712
737
|
this.manager.mainView.moveCameraToContain(payload);
|
@@ -1228,10 +1253,13 @@ class AppPageStateImpl {
|
|
1228
1253
|
}
|
1229
1254
|
}
|
1230
1255
|
toObject() {
|
1231
|
-
var _a2, _b;
|
1256
|
+
var _a2, _b, _c;
|
1232
1257
|
return {
|
1233
1258
|
index: ((_a2 = this.view) == null ? void 0 : _a2.focusSceneIndex) || 0,
|
1234
|
-
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0
|
1259
|
+
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0,
|
1260
|
+
pages: ((_c = this.sceneNode) == null ? void 0 : _c.scenes.map((name) => {
|
1261
|
+
return `${this.scenePath}/${name}`;
|
1262
|
+
})) || []
|
1235
1263
|
};
|
1236
1264
|
}
|
1237
1265
|
destroy() {
|
@@ -1249,15 +1277,17 @@ class CameraSynchronizer {
|
|
1249
1277
|
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1250
1278
|
}
|
1251
1279
|
};
|
1252
|
-
this.onRemoteUpdate = lodash.throttle((camera, size) => {
|
1280
|
+
this.onRemoteUpdate = lodash.throttle((camera, size, skipUpdate = false) => {
|
1253
1281
|
this.remoteCamera = camera;
|
1254
1282
|
this.remoteSize = size;
|
1255
|
-
if (
|
1256
|
-
|
1257
|
-
|
1283
|
+
if (skipUpdate)
|
1284
|
+
return;
|
1285
|
+
requestAnimationFrame(() => {
|
1286
|
+
if (this.remoteSize && this.rect) {
|
1287
|
+
this.moveCameraToContian(this.remoteSize);
|
1258
1288
|
this.moveCamera(camera);
|
1259
|
-
}
|
1260
|
-
}
|
1289
|
+
}
|
1290
|
+
});
|
1261
1291
|
}, 32);
|
1262
1292
|
}
|
1263
1293
|
setView(view) {
|
@@ -1275,8 +1305,10 @@ class CameraSynchronizer {
|
|
1275
1305
|
width: size.width,
|
1276
1306
|
height: size.height,
|
1277
1307
|
originX: currentCamera.centerX - size.width / 2,
|
1278
|
-
originY: currentCamera.centerY - size.height / 2
|
1308
|
+
originY: currentCamera.centerY - size.height / 2,
|
1309
|
+
animationMode: whiteWebSdk.AnimationMode.Immediately
|
1279
1310
|
});
|
1311
|
+
this.moveCamera(this.remoteCamera);
|
1280
1312
|
}
|
1281
1313
|
}
|
1282
1314
|
onLocalCameraUpdate(camera) {
|
@@ -1360,11 +1392,9 @@ class ViewSync {
|
|
1360
1392
|
};
|
1361
1393
|
this.subscribeCamera = () => {
|
1362
1394
|
return this.context.camera$.subscribe((camera, skipUpdate) => {
|
1363
|
-
if (skipUpdate)
|
1364
|
-
return;
|
1365
1395
|
const size = this.context.size$.value;
|
1366
1396
|
if (camera && size) {
|
1367
|
-
this.synchronizer.onRemoteUpdate(camera, size);
|
1397
|
+
this.synchronizer.onRemoteUpdate(camera, size, skipUpdate);
|
1368
1398
|
}
|
1369
1399
|
});
|
1370
1400
|
};
|
@@ -2445,6 +2475,10 @@ class MainViewProxy {
|
|
2445
2475
|
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2446
2476
|
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2447
2477
|
};
|
2478
|
+
this.saveToCamera$ = () => {
|
2479
|
+
const camera = __spreadProps$1(__spreadValues$2({}, this.view.camera), { id: this.manager.uid });
|
2480
|
+
this.camera$.setValue(camera, true);
|
2481
|
+
};
|
2448
2482
|
this.storeCurrentCamera = () => {
|
2449
2483
|
const iCamera = this.view.camera;
|
2450
2484
|
this.storeCamera(__spreadValues$2({
|
@@ -7328,14 +7362,14 @@ class Cursor {
|
|
7328
7362
|
var _a2;
|
7329
7363
|
if (this.member) {
|
7330
7364
|
const icons = this.cursorManager.applianceIcons;
|
7331
|
-
let applianceSrc
|
7365
|
+
let applianceSrc;
|
7332
7366
|
if (this.memberApplianceName === whiteWebSdk.ApplianceNames.pencilEraser) {
|
7333
7367
|
const size = ((_a2 = this.member) == null ? void 0 : _a2.memberState.pencilEraserSize) || 1;
|
7334
7368
|
applianceSrc = icons[`${this.memberApplianceName}${size}`];
|
7335
7369
|
} else {
|
7336
7370
|
applianceSrc = icons[this.memberApplianceName || whiteWebSdk.ApplianceNames.shape];
|
7337
7371
|
}
|
7338
|
-
return applianceSrc;
|
7372
|
+
return applianceSrc || icons[whiteWebSdk.ApplianceNames.shape];
|
7339
7373
|
}
|
7340
7374
|
}
|
7341
7375
|
updateMember() {
|
@@ -7510,7 +7544,8 @@ class CursorManager {
|
|
7510
7544
|
return (_a2 = this.manager.focusApp) == null ? void 0 : _a2.view;
|
7511
7545
|
}
|
7512
7546
|
updateCursor(event, clientX, clientY) {
|
7513
|
-
|
7547
|
+
const self = findMemberByUid(this.manager.room, this.manager.uid);
|
7548
|
+
if (this.wrapperRect && this.manager.canOperate && this.canMoveCursor(self)) {
|
7514
7549
|
const view = event.type === "main" ? this.manager.mainView : this.focusView;
|
7515
7550
|
const point = this.getPoint(view, clientX, clientY);
|
7516
7551
|
if (point) {
|
@@ -7568,11 +7603,19 @@ class PageStateImpl {
|
|
7568
7603
|
var _a2;
|
7569
7604
|
return ((_a2 = this.manager) == null ? void 0 : _a2.mainViewScenesLength) || 0;
|
7570
7605
|
}
|
7606
|
+
getPages() {
|
7607
|
+
var _a2;
|
7608
|
+
return ((_a2 = this.manager.callbacksNode) == null ? void 0 : _a2.scenes.map((sceneName) => {
|
7609
|
+
var _a22;
|
7610
|
+
return `${(_a22 = this.manager.callbacksNode) == null ? void 0 : _a22.path}${sceneName}`;
|
7611
|
+
})) || [];
|
7612
|
+
}
|
7571
7613
|
toObject() {
|
7572
7614
|
const index2 = this.index >= this.length ? this.length - 1 : this.index;
|
7573
7615
|
return {
|
7574
7616
|
index: index2,
|
7575
|
-
length: this.length
|
7617
|
+
length: this.length,
|
7618
|
+
pages: this.getPages()
|
7576
7619
|
};
|
7577
7620
|
}
|
7578
7621
|
}
|
@@ -12713,7 +12756,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
12713
12756
|
const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
|
12714
12757
|
constructor(context) {
|
12715
12758
|
super(context);
|
12716
|
-
this.version = "1.0.0-canary.
|
12759
|
+
this.version = "1.0.0-canary.63";
|
12717
12760
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
|
12718
12761
|
this.emitter = callbacks;
|
12719
12762
|
this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
|
@@ -12732,9 +12775,10 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
|
|
12732
12775
|
};
|
12733
12776
|
this.debouncedStoreCamera = () => {
|
12734
12777
|
const storeCamera = lodash.debounce(() => {
|
12735
|
-
var _a2, _b;
|
12736
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
12737
|
-
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.
|
12778
|
+
var _a2, _b, _c;
|
12779
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
|
12780
|
+
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
|
12781
|
+
(_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
|
12738
12782
|
this.mainView.callbacks.off("onCameraUpdated", storeCamera);
|
12739
12783
|
}, 200);
|
12740
12784
|
this.mainView.callbacks.on("onCameraUpdated", storeCamera);
|
package/dist/index.mjs
CHANGED
@@ -233,25 +233,25 @@ function deleteRecord(db2, key) {
|
|
233
233
|
request.onerror = () => reject();
|
234
234
|
});
|
235
235
|
}
|
236
|
-
var __defProp$
|
237
|
-
var __defProps$
|
238
|
-
var __getOwnPropDescs$
|
239
|
-
var __getOwnPropSymbols$
|
240
|
-
var __hasOwnProp$
|
241
|
-
var __propIsEnum$
|
242
|
-
var __defNormalProp$
|
243
|
-
var __spreadValues$
|
236
|
+
var __defProp$9 = Object.defineProperty;
|
237
|
+
var __defProps$5 = Object.defineProperties;
|
238
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
239
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
240
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
241
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
242
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
243
|
+
var __spreadValues$9 = (a, b) => {
|
244
244
|
for (var prop in b || (b = {}))
|
245
|
-
if (__hasOwnProp$
|
246
|
-
__defNormalProp$
|
247
|
-
if (__getOwnPropSymbols$
|
248
|
-
for (var prop of __getOwnPropSymbols$
|
249
|
-
if (__propIsEnum$
|
250
|
-
__defNormalProp$
|
245
|
+
if (__hasOwnProp$9.call(b, prop))
|
246
|
+
__defNormalProp$9(a, prop, b[prop]);
|
247
|
+
if (__getOwnPropSymbols$9)
|
248
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
249
|
+
if (__propIsEnum$9.call(b, prop))
|
250
|
+
__defNormalProp$9(a, prop, b[prop]);
|
251
251
|
}
|
252
252
|
return a;
|
253
253
|
};
|
254
|
-
var __spreadProps$
|
254
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
255
255
|
var __async$b = (__this, __arguments, generator) => {
|
256
256
|
return new Promise((resolve, reject) => {
|
257
257
|
var fulfilled = (value) => {
|
@@ -334,7 +334,7 @@ function fetchWithTimeout(resource, options) {
|
|
334
334
|
const { timeout = 1e4 } = options;
|
335
335
|
const controller = new AbortController();
|
336
336
|
const id = setTimeout(() => controller.abort(), timeout);
|
337
|
-
const response = yield fetch(resource, __spreadProps$
|
337
|
+
const response = yield fetch(resource, __spreadProps$5(__spreadValues$9({}, options), {
|
338
338
|
signal: controller.signal,
|
339
339
|
headers: {
|
340
340
|
"content-type": "text/plain"
|
@@ -601,6 +601,25 @@ const isRootDirPage = (scenePath) => {
|
|
601
601
|
}, 0);
|
602
602
|
return delimiterCount === 1;
|
603
603
|
};
|
604
|
+
var __defProp$8 = Object.defineProperty;
|
605
|
+
var __defProps$4 = Object.defineProperties;
|
606
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
607
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
608
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
609
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
610
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
611
|
+
var __spreadValues$8 = (a, b) => {
|
612
|
+
for (var prop in b || (b = {}))
|
613
|
+
if (__hasOwnProp$8.call(b, prop))
|
614
|
+
__defNormalProp$8(a, prop, b[prop]);
|
615
|
+
if (__getOwnPropSymbols$8)
|
616
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
617
|
+
if (__propIsEnum$8.call(b, prop))
|
618
|
+
__defNormalProp$8(a, prop, b[prop]);
|
619
|
+
}
|
620
|
+
return a;
|
621
|
+
};
|
622
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
604
623
|
class AppListeners {
|
605
624
|
constructor(manager) {
|
606
625
|
this.manager = manager;
|
@@ -701,7 +720,13 @@ class AppListeners {
|
|
701
720
|
}
|
702
721
|
};
|
703
722
|
this.moveCameraHandler = (payload) => {
|
704
|
-
this.manager.
|
723
|
+
const size$ = this.manager.mainViewProxy.size$;
|
724
|
+
if (size$.value) {
|
725
|
+
const size = this.manager.mainView.size;
|
726
|
+
const diff = Math.max(size.height / size$.value.height, size.width / size$.value.width);
|
727
|
+
const nextCamera = __spreadProps$4(__spreadValues$8({}, payload), { scale: payload.scale * diff });
|
728
|
+
this.manager.mainView.moveCamera(nextCamera);
|
729
|
+
}
|
705
730
|
};
|
706
731
|
this.moveCameraToContainHandler = (payload) => {
|
707
732
|
this.manager.mainView.moveCameraToContain(payload);
|
@@ -1223,10 +1248,13 @@ class AppPageStateImpl {
|
|
1223
1248
|
}
|
1224
1249
|
}
|
1225
1250
|
toObject() {
|
1226
|
-
var _a2, _b;
|
1251
|
+
var _a2, _b, _c;
|
1227
1252
|
return {
|
1228
1253
|
index: ((_a2 = this.view) == null ? void 0 : _a2.focusSceneIndex) || 0,
|
1229
|
-
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0
|
1254
|
+
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0,
|
1255
|
+
pages: ((_c = this.sceneNode) == null ? void 0 : _c.scenes.map((name) => {
|
1256
|
+
return `${this.scenePath}/${name}`;
|
1257
|
+
})) || []
|
1230
1258
|
};
|
1231
1259
|
}
|
1232
1260
|
destroy() {
|
@@ -1244,15 +1272,17 @@ class CameraSynchronizer {
|
|
1244
1272
|
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1245
1273
|
}
|
1246
1274
|
};
|
1247
|
-
this.onRemoteUpdate = throttle((camera, size) => {
|
1275
|
+
this.onRemoteUpdate = throttle((camera, size, skipUpdate = false) => {
|
1248
1276
|
this.remoteCamera = camera;
|
1249
1277
|
this.remoteSize = size;
|
1250
|
-
if (
|
1251
|
-
|
1252
|
-
|
1278
|
+
if (skipUpdate)
|
1279
|
+
return;
|
1280
|
+
requestAnimationFrame(() => {
|
1281
|
+
if (this.remoteSize && this.rect) {
|
1282
|
+
this.moveCameraToContian(this.remoteSize);
|
1253
1283
|
this.moveCamera(camera);
|
1254
|
-
}
|
1255
|
-
}
|
1284
|
+
}
|
1285
|
+
});
|
1256
1286
|
}, 32);
|
1257
1287
|
}
|
1258
1288
|
setView(view) {
|
@@ -1270,8 +1300,10 @@ class CameraSynchronizer {
|
|
1270
1300
|
width: size.width,
|
1271
1301
|
height: size.height,
|
1272
1302
|
originX: currentCamera.centerX - size.width / 2,
|
1273
|
-
originY: currentCamera.centerY - size.height / 2
|
1303
|
+
originY: currentCamera.centerY - size.height / 2,
|
1304
|
+
animationMode: AnimationMode.Immediately
|
1274
1305
|
});
|
1306
|
+
this.moveCamera(this.remoteCamera);
|
1275
1307
|
}
|
1276
1308
|
}
|
1277
1309
|
onLocalCameraUpdate(camera) {
|
@@ -1355,11 +1387,9 @@ class ViewSync {
|
|
1355
1387
|
};
|
1356
1388
|
this.subscribeCamera = () => {
|
1357
1389
|
return this.context.camera$.subscribe((camera, skipUpdate) => {
|
1358
|
-
if (skipUpdate)
|
1359
|
-
return;
|
1360
1390
|
const size = this.context.size$.value;
|
1361
1391
|
if (camera && size) {
|
1362
|
-
this.synchronizer.onRemoteUpdate(camera, size);
|
1392
|
+
this.synchronizer.onRemoteUpdate(camera, size, skipUpdate);
|
1363
1393
|
}
|
1364
1394
|
});
|
1365
1395
|
};
|
@@ -2440,6 +2470,10 @@ class MainViewProxy {
|
|
2440
2470
|
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2441
2471
|
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2442
2472
|
};
|
2473
|
+
this.saveToCamera$ = () => {
|
2474
|
+
const camera = __spreadProps$1(__spreadValues$2({}, this.view.camera), { id: this.manager.uid });
|
2475
|
+
this.camera$.setValue(camera, true);
|
2476
|
+
};
|
2443
2477
|
this.storeCurrentCamera = () => {
|
2444
2478
|
const iCamera = this.view.camera;
|
2445
2479
|
this.storeCamera(__spreadValues$2({
|
@@ -7323,14 +7357,14 @@ class Cursor {
|
|
7323
7357
|
var _a2;
|
7324
7358
|
if (this.member) {
|
7325
7359
|
const icons = this.cursorManager.applianceIcons;
|
7326
|
-
let applianceSrc
|
7360
|
+
let applianceSrc;
|
7327
7361
|
if (this.memberApplianceName === ApplianceNames.pencilEraser) {
|
7328
7362
|
const size = ((_a2 = this.member) == null ? void 0 : _a2.memberState.pencilEraserSize) || 1;
|
7329
7363
|
applianceSrc = icons[`${this.memberApplianceName}${size}`];
|
7330
7364
|
} else {
|
7331
7365
|
applianceSrc = icons[this.memberApplianceName || ApplianceNames.shape];
|
7332
7366
|
}
|
7333
|
-
return applianceSrc;
|
7367
|
+
return applianceSrc || icons[ApplianceNames.shape];
|
7334
7368
|
}
|
7335
7369
|
}
|
7336
7370
|
updateMember() {
|
@@ -7505,7 +7539,8 @@ class CursorManager {
|
|
7505
7539
|
return (_a2 = this.manager.focusApp) == null ? void 0 : _a2.view;
|
7506
7540
|
}
|
7507
7541
|
updateCursor(event, clientX, clientY) {
|
7508
|
-
|
7542
|
+
const self = findMemberByUid(this.manager.room, this.manager.uid);
|
7543
|
+
if (this.wrapperRect && this.manager.canOperate && this.canMoveCursor(self)) {
|
7509
7544
|
const view = event.type === "main" ? this.manager.mainView : this.focusView;
|
7510
7545
|
const point = this.getPoint(view, clientX, clientY);
|
7511
7546
|
if (point) {
|
@@ -7563,11 +7598,19 @@ class PageStateImpl {
|
|
7563
7598
|
var _a2;
|
7564
7599
|
return ((_a2 = this.manager) == null ? void 0 : _a2.mainViewScenesLength) || 0;
|
7565
7600
|
}
|
7601
|
+
getPages() {
|
7602
|
+
var _a2;
|
7603
|
+
return ((_a2 = this.manager.callbacksNode) == null ? void 0 : _a2.scenes.map((sceneName) => {
|
7604
|
+
var _a22;
|
7605
|
+
return `${(_a22 = this.manager.callbacksNode) == null ? void 0 : _a22.path}${sceneName}`;
|
7606
|
+
})) || [];
|
7607
|
+
}
|
7566
7608
|
toObject() {
|
7567
7609
|
const index2 = this.index >= this.length ? this.length - 1 : this.index;
|
7568
7610
|
return {
|
7569
7611
|
index: index2,
|
7570
|
-
length: this.length
|
7612
|
+
length: this.length,
|
7613
|
+
pages: this.getPages()
|
7571
7614
|
};
|
7572
7615
|
}
|
7573
7616
|
}
|
@@ -12708,7 +12751,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
12708
12751
|
const _WindowManager = class extends InvisiblePlugin {
|
12709
12752
|
constructor(context) {
|
12710
12753
|
super(context);
|
12711
|
-
this.version = "1.0.0-canary.
|
12754
|
+
this.version = "1.0.0-canary.63";
|
12712
12755
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
|
12713
12756
|
this.emitter = callbacks;
|
12714
12757
|
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
@@ -12727,9 +12770,10 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
12727
12770
|
};
|
12728
12771
|
this.debouncedStoreCamera = () => {
|
12729
12772
|
const storeCamera = debounce(() => {
|
12730
|
-
var _a2, _b;
|
12731
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
12732
|
-
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.
|
12773
|
+
var _a2, _b, _c;
|
12774
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
|
12775
|
+
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
|
12776
|
+
(_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
|
12733
12777
|
this.mainView.callbacks.off("onCameraUpdated", storeCamera);
|
12734
12778
|
}, 200);
|
12735
12779
|
this.mainView.callbacks.on("onCameraUpdated", storeCamera);
|
package/dist/index.umd.js
CHANGED
@@ -231,25 +231,25 @@
|
|
231
231
|
request.onerror = () => reject();
|
232
232
|
});
|
233
233
|
}
|
234
|
-
var __defProp$
|
235
|
-
var __defProps$
|
236
|
-
var __getOwnPropDescs$
|
237
|
-
var __getOwnPropSymbols$
|
238
|
-
var __hasOwnProp$
|
239
|
-
var __propIsEnum$
|
240
|
-
var __defNormalProp$
|
241
|
-
var __spreadValues$
|
234
|
+
var __defProp$9 = Object.defineProperty;
|
235
|
+
var __defProps$5 = Object.defineProperties;
|
236
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
237
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
238
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
239
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
240
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
241
|
+
var __spreadValues$9 = (a, b) => {
|
242
242
|
for (var prop in b || (b = {}))
|
243
|
-
if (__hasOwnProp$
|
244
|
-
__defNormalProp$
|
245
|
-
if (__getOwnPropSymbols$
|
246
|
-
for (var prop of __getOwnPropSymbols$
|
247
|
-
if (__propIsEnum$
|
248
|
-
__defNormalProp$
|
243
|
+
if (__hasOwnProp$9.call(b, prop))
|
244
|
+
__defNormalProp$9(a, prop, b[prop]);
|
245
|
+
if (__getOwnPropSymbols$9)
|
246
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
247
|
+
if (__propIsEnum$9.call(b, prop))
|
248
|
+
__defNormalProp$9(a, prop, b[prop]);
|
249
249
|
}
|
250
250
|
return a;
|
251
251
|
};
|
252
|
-
var __spreadProps$
|
252
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
253
253
|
var __async$b = (__this, __arguments, generator) => {
|
254
254
|
return new Promise((resolve, reject) => {
|
255
255
|
var fulfilled = (value) => {
|
@@ -332,7 +332,7 @@
|
|
332
332
|
const { timeout = 1e4 } = options;
|
333
333
|
const controller = new AbortController();
|
334
334
|
const id = setTimeout(() => controller.abort(), timeout);
|
335
|
-
const response = yield fetch(resource, __spreadProps$
|
335
|
+
const response = yield fetch(resource, __spreadProps$5(__spreadValues$9({}, options), {
|
336
336
|
signal: controller.signal,
|
337
337
|
headers: {
|
338
338
|
"content-type": "text/plain"
|
@@ -599,6 +599,25 @@
|
|
599
599
|
}, 0);
|
600
600
|
return delimiterCount === 1;
|
601
601
|
};
|
602
|
+
var __defProp$8 = Object.defineProperty;
|
603
|
+
var __defProps$4 = Object.defineProperties;
|
604
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
605
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
606
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
607
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
608
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
609
|
+
var __spreadValues$8 = (a, b) => {
|
610
|
+
for (var prop in b || (b = {}))
|
611
|
+
if (__hasOwnProp$8.call(b, prop))
|
612
|
+
__defNormalProp$8(a, prop, b[prop]);
|
613
|
+
if (__getOwnPropSymbols$8)
|
614
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
615
|
+
if (__propIsEnum$8.call(b, prop))
|
616
|
+
__defNormalProp$8(a, prop, b[prop]);
|
617
|
+
}
|
618
|
+
return a;
|
619
|
+
};
|
620
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
602
621
|
class AppListeners {
|
603
622
|
constructor(manager) {
|
604
623
|
this.manager = manager;
|
@@ -699,7 +718,13 @@
|
|
699
718
|
}
|
700
719
|
};
|
701
720
|
this.moveCameraHandler = (payload) => {
|
702
|
-
this.manager.
|
721
|
+
const size$ = this.manager.mainViewProxy.size$;
|
722
|
+
if (size$.value) {
|
723
|
+
const size = this.manager.mainView.size;
|
724
|
+
const diff = Math.max(size.height / size$.value.height, size.width / size$.value.width);
|
725
|
+
const nextCamera = __spreadProps$4(__spreadValues$8({}, payload), { scale: payload.scale * diff });
|
726
|
+
this.manager.mainView.moveCamera(nextCamera);
|
727
|
+
}
|
703
728
|
};
|
704
729
|
this.moveCameraToContainHandler = (payload) => {
|
705
730
|
this.manager.mainView.moveCameraToContain(payload);
|
@@ -1221,10 +1246,13 @@
|
|
1221
1246
|
}
|
1222
1247
|
}
|
1223
1248
|
toObject() {
|
1224
|
-
var _a2, _b;
|
1249
|
+
var _a2, _b, _c;
|
1225
1250
|
return {
|
1226
1251
|
index: ((_a2 = this.view) == null ? void 0 : _a2.focusSceneIndex) || 0,
|
1227
|
-
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0
|
1252
|
+
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0,
|
1253
|
+
pages: ((_c = this.sceneNode) == null ? void 0 : _c.scenes.map((name) => {
|
1254
|
+
return `${this.scenePath}/${name}`;
|
1255
|
+
})) || []
|
1228
1256
|
};
|
1229
1257
|
}
|
1230
1258
|
destroy() {
|
@@ -1242,15 +1270,17 @@
|
|
1242
1270
|
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1243
1271
|
}
|
1244
1272
|
};
|
1245
|
-
this.onRemoteUpdate = lodash.throttle((camera, size) => {
|
1273
|
+
this.onRemoteUpdate = lodash.throttle((camera, size, skipUpdate = false) => {
|
1246
1274
|
this.remoteCamera = camera;
|
1247
1275
|
this.remoteSize = size;
|
1248
|
-
if (
|
1249
|
-
|
1250
|
-
|
1276
|
+
if (skipUpdate)
|
1277
|
+
return;
|
1278
|
+
requestAnimationFrame(() => {
|
1279
|
+
if (this.remoteSize && this.rect) {
|
1280
|
+
this.moveCameraToContian(this.remoteSize);
|
1251
1281
|
this.moveCamera(camera);
|
1252
|
-
}
|
1253
|
-
}
|
1282
|
+
}
|
1283
|
+
});
|
1254
1284
|
}, 32);
|
1255
1285
|
}
|
1256
1286
|
setView(view) {
|
@@ -1268,8 +1298,10 @@
|
|
1268
1298
|
width: size.width,
|
1269
1299
|
height: size.height,
|
1270
1300
|
originX: currentCamera.centerX - size.width / 2,
|
1271
|
-
originY: currentCamera.centerY - size.height / 2
|
1301
|
+
originY: currentCamera.centerY - size.height / 2,
|
1302
|
+
animationMode: whiteWebSdk.AnimationMode.Immediately
|
1272
1303
|
});
|
1304
|
+
this.moveCamera(this.remoteCamera);
|
1273
1305
|
}
|
1274
1306
|
}
|
1275
1307
|
onLocalCameraUpdate(camera) {
|
@@ -1353,11 +1385,9 @@
|
|
1353
1385
|
};
|
1354
1386
|
this.subscribeCamera = () => {
|
1355
1387
|
return this.context.camera$.subscribe((camera, skipUpdate) => {
|
1356
|
-
if (skipUpdate)
|
1357
|
-
return;
|
1358
1388
|
const size = this.context.size$.value;
|
1359
1389
|
if (camera && size) {
|
1360
|
-
this.synchronizer.onRemoteUpdate(camera, size);
|
1390
|
+
this.synchronizer.onRemoteUpdate(camera, size, skipUpdate);
|
1361
1391
|
}
|
1362
1392
|
});
|
1363
1393
|
};
|
@@ -2438,6 +2468,10 @@
|
|
2438
2468
|
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2439
2469
|
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2440
2470
|
};
|
2471
|
+
this.saveToCamera$ = () => {
|
2472
|
+
const camera = __spreadProps$1(__spreadValues$2({}, this.view.camera), { id: this.manager.uid });
|
2473
|
+
this.camera$.setValue(camera, true);
|
2474
|
+
};
|
2441
2475
|
this.storeCurrentCamera = () => {
|
2442
2476
|
const iCamera = this.view.camera;
|
2443
2477
|
this.storeCamera(__spreadValues$2({
|
@@ -7321,14 +7355,14 @@
|
|
7321
7355
|
var _a2;
|
7322
7356
|
if (this.member) {
|
7323
7357
|
const icons = this.cursorManager.applianceIcons;
|
7324
|
-
let applianceSrc
|
7358
|
+
let applianceSrc;
|
7325
7359
|
if (this.memberApplianceName === whiteWebSdk.ApplianceNames.pencilEraser) {
|
7326
7360
|
const size = ((_a2 = this.member) == null ? void 0 : _a2.memberState.pencilEraserSize) || 1;
|
7327
7361
|
applianceSrc = icons[`${this.memberApplianceName}${size}`];
|
7328
7362
|
} else {
|
7329
7363
|
applianceSrc = icons[this.memberApplianceName || whiteWebSdk.ApplianceNames.shape];
|
7330
7364
|
}
|
7331
|
-
return applianceSrc;
|
7365
|
+
return applianceSrc || icons[whiteWebSdk.ApplianceNames.shape];
|
7332
7366
|
}
|
7333
7367
|
}
|
7334
7368
|
updateMember() {
|
@@ -7503,7 +7537,8 @@
|
|
7503
7537
|
return (_a2 = this.manager.focusApp) == null ? void 0 : _a2.view;
|
7504
7538
|
}
|
7505
7539
|
updateCursor(event, clientX, clientY) {
|
7506
|
-
|
7540
|
+
const self2 = findMemberByUid(this.manager.room, this.manager.uid);
|
7541
|
+
if (this.wrapperRect && this.manager.canOperate && this.canMoveCursor(self2)) {
|
7507
7542
|
const view = event.type === "main" ? this.manager.mainView : this.focusView;
|
7508
7543
|
const point = this.getPoint(view, clientX, clientY);
|
7509
7544
|
if (point) {
|
@@ -7561,11 +7596,19 @@
|
|
7561
7596
|
var _a2;
|
7562
7597
|
return ((_a2 = this.manager) == null ? void 0 : _a2.mainViewScenesLength) || 0;
|
7563
7598
|
}
|
7599
|
+
getPages() {
|
7600
|
+
var _a2;
|
7601
|
+
return ((_a2 = this.manager.callbacksNode) == null ? void 0 : _a2.scenes.map((sceneName) => {
|
7602
|
+
var _a22;
|
7603
|
+
return `${(_a22 = this.manager.callbacksNode) == null ? void 0 : _a22.path}${sceneName}`;
|
7604
|
+
})) || [];
|
7605
|
+
}
|
7564
7606
|
toObject() {
|
7565
7607
|
const index2 = this.index >= this.length ? this.length - 1 : this.index;
|
7566
7608
|
return {
|
7567
7609
|
index: index2,
|
7568
|
-
length: this.length
|
7610
|
+
length: this.length,
|
7611
|
+
pages: this.getPages()
|
7569
7612
|
};
|
7570
7613
|
}
|
7571
7614
|
}
|
@@ -12706,7 +12749,7 @@
|
|
12706
12749
|
const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
|
12707
12750
|
constructor(context) {
|
12708
12751
|
super(context);
|
12709
|
-
this.version = "1.0.0-canary.
|
12752
|
+
this.version = "1.0.0-canary.63";
|
12710
12753
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
|
12711
12754
|
this.emitter = callbacks;
|
12712
12755
|
this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
|
@@ -12725,9 +12768,10 @@
|
|
12725
12768
|
};
|
12726
12769
|
this.debouncedStoreCamera = () => {
|
12727
12770
|
const storeCamera = lodash.debounce(() => {
|
12728
|
-
var _a2, _b;
|
12729
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
12730
|
-
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.
|
12771
|
+
var _a2, _b, _c;
|
12772
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
|
12773
|
+
(_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
|
12774
|
+
(_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
|
12731
12775
|
this.mainView.callbacks.off("onCameraUpdated", storeCamera);
|
12732
12776
|
}, 200);
|
12733
12777
|
this.mainView.callbacks.on("onCameraUpdated", storeCamera);
|
package/dist/src/AppManager.d.ts
CHANGED
@@ -6,7 +6,7 @@ import { ViewManager } from "./View/ViewManager";
|
|
6
6
|
import { Val } from "value-enhancer";
|
7
7
|
import type { ReconnectRefresher } from "./ReconnectRefresher";
|
8
8
|
import type { BoxManager } from "./BoxManager";
|
9
|
-
import type { Displayer, Room, SceneState, Size } from "white-web-sdk";
|
9
|
+
import type { Displayer, Room, ScenesCallbacksNode, SceneState, Size } from "white-web-sdk";
|
10
10
|
import type { AddAppParams, TeleBoxRect } from "./index";
|
11
11
|
import type { Member } from "./Helper";
|
12
12
|
import { ScrollMode } from "./View/ScrollMode";
|
@@ -25,7 +25,7 @@ export declare class AppManager {
|
|
25
25
|
boxManager?: BoxManager;
|
26
26
|
scrollMode?: ScrollMode;
|
27
27
|
scrollBaseSize$: Val<Size | null, any>;
|
28
|
-
|
28
|
+
callbacksNode: ScenesCallbacksNode | null;
|
29
29
|
private appCreateQueue;
|
30
30
|
private sceneIndex$;
|
31
31
|
private focused$;
|
package/dist/src/PageState.d.ts
CHANGED
@@ -12,7 +12,7 @@ export declare class CameraSynchronizer {
|
|
12
12
|
constructor(saveCamera: SaveCamera);
|
13
13
|
setRect: (rect: TeleBoxRect, updateCamera?: boolean) => void;
|
14
14
|
setView(view: View): void;
|
15
|
-
onRemoteUpdate: import("lodash").DebouncedFunc<(camera: ICamera, size: ISize) => void>;
|
15
|
+
onRemoteUpdate: import("lodash").DebouncedFunc<(camera: ICamera, size: ISize, skipUpdate?: any) => void>;
|
16
16
|
onRemoteSizeUpdate(size: ISize): void;
|
17
17
|
onLocalCameraUpdate(camera: ICamera): void;
|
18
18
|
private moveCameraToContian;
|
package/package.json
CHANGED
package/pnpm-lock.yaml
CHANGED
@@ -46,7 +46,7 @@ specifiers:
|
|
46
46
|
|
47
47
|
dependencies:
|
48
48
|
'@juggle/resize-observer': 3.3.1
|
49
|
-
'@netless/synced-store': 2.0.7_white-web-sdk@2.16.
|
49
|
+
'@netless/synced-store': 2.0.7_white-web-sdk@2.16.36
|
50
50
|
'@netless/telebox-insider': 1.0.0-alpha.37
|
51
51
|
emittery: 0.11.0
|
52
52
|
lodash: 4.17.21
|
@@ -88,7 +88,7 @@ devDependencies:
|
|
88
88
|
vite: 3.1.3_less@4.1.3
|
89
89
|
vite-plugin-dts: 1.5.0_vite@3.1.3
|
90
90
|
vitest: 0.23.4_d3e3zazviv5held4lo66xldmcm
|
91
|
-
white-web-sdk: 2.16.
|
91
|
+
white-web-sdk: 2.16.36
|
92
92
|
|
93
93
|
packages:
|
94
94
|
|
@@ -266,7 +266,7 @@ packages:
|
|
266
266
|
/@netless/canvas-polyfill/0.0.4:
|
267
267
|
resolution: {integrity: sha512-7NzsJrba0R/mq/l10SkIZQwbrNVJyPxZYrjK6xL3Ts732iWAVuS2UB0u3s6iGeUVcqV39A679yva8APWRl4M0A==}
|
268
268
|
|
269
|
-
/@netless/synced-store/2.0.7_white-web-sdk@2.16.
|
269
|
+
/@netless/synced-store/2.0.7_white-web-sdk@2.16.36:
|
270
270
|
resolution: {integrity: sha512-E5ukXMTLa0Mlhlv9Rcy3MJSAM5kwiLoXQy42OCSIFdBR8jf0BKbSUXSjnA8J+FZq6UidNtGaadDWjhwlM1z5MA==}
|
271
271
|
peerDependencies:
|
272
272
|
white-web-sdk: '>= 2.16'
|
@@ -275,7 +275,7 @@ packages:
|
|
275
275
|
remitter: 0.2.6
|
276
276
|
side-effect-manager: 1.2.1
|
277
277
|
value-enhancer: 1.3.2
|
278
|
-
white-web-sdk: 2.16.
|
278
|
+
white-web-sdk: 2.16.36
|
279
279
|
dev: false
|
280
280
|
|
281
281
|
/@netless/telebox-insider/1.0.0-alpha.37:
|
@@ -4858,8 +4858,8 @@ packages:
|
|
4858
4858
|
isexe: 2.0.0
|
4859
4859
|
dev: true
|
4860
4860
|
|
4861
|
-
/white-web-sdk/2.16.
|
4862
|
-
resolution: {integrity: sha512-
|
4861
|
+
/white-web-sdk/2.16.36:
|
4862
|
+
resolution: {integrity: sha512-qmyi6Slkxkbo7+FM3MudieQGhhKRtEztQaTDya1whl7ntD1BRavZzpRBgnJ1NMX2A1wKjILGHXRg9zyZhnAZaA==}
|
4863
4863
|
dependencies:
|
4864
4864
|
'@juggle/resize-observer': 3.3.1
|
4865
4865
|
'@netless/canvas-polyfill': 0.0.4
|
@@ -83,7 +83,6 @@ export class WhiteBoardView implements PageController {
|
|
83
83
|
const scenes = Array.isArray(scene) ? scene : [scene || {}];
|
84
84
|
if (after) {
|
85
85
|
const nextIndex = this.pageState.index + 1;
|
86
|
-
|
87
86
|
putScenes(this.appContext.room, scenePath, scenes, nextIndex);
|
88
87
|
} else {
|
89
88
|
putScenes(this.appContext.room, scenePath, scenes);
|
package/src/AppListener.ts
CHANGED
@@ -135,7 +135,13 @@ export class AppListeners {
|
|
135
135
|
}
|
136
136
|
|
137
137
|
private moveCameraHandler = (payload: Camera) => {
|
138
|
-
this.manager.
|
138
|
+
const size$ = this.manager.mainViewProxy.size$;
|
139
|
+
if (size$.value) {
|
140
|
+
const size = this.manager.mainView.size;
|
141
|
+
const diff = Math.max(size.height / size$.value.height, size.width / size$.value.width);
|
142
|
+
const nextCamera = { ...payload, scale: payload.scale * diff };
|
143
|
+
this.manager.mainView.moveCamera(nextCamera);
|
144
|
+
}
|
139
145
|
}
|
140
146
|
|
141
147
|
private moveCameraToContainHandler = (payload: Rectangle & { animationMode?: AnimationMode }) => {
|
package/src/AppManager.ts
CHANGED
@@ -68,7 +68,7 @@ export class AppManager {
|
|
68
68
|
public scrollMode?: ScrollMode;
|
69
69
|
public scrollBaseSize$ = new Val<Size | null>(null);
|
70
70
|
|
71
|
-
|
71
|
+
public callbacksNode: ScenesCallbacksNode | null = null;
|
72
72
|
private appCreateQueue = new AppCreateQueue();
|
73
73
|
private sceneIndex$ = new Val<number | undefined>(undefined);
|
74
74
|
private focused$ = new Val<string | undefined>(undefined);
|
package/src/Cursor/Cursor.ts
CHANGED
@@ -164,14 +164,14 @@ export class Cursor {
|
|
164
164
|
private getIcon() {
|
165
165
|
if (this.member) {
|
166
166
|
const icons = this.cursorManager.applianceIcons;
|
167
|
-
let applianceSrc
|
167
|
+
let applianceSrc;
|
168
168
|
if (this.memberApplianceName === ApplianceNames.pencilEraser) {
|
169
169
|
const size = this.member?.memberState.pencilEraserSize || 1;
|
170
170
|
applianceSrc = icons[`${this.memberApplianceName}${size}`];
|
171
171
|
} else {
|
172
172
|
applianceSrc = icons[this.memberApplianceName || ApplianceNames.shape];
|
173
173
|
}
|
174
|
-
return applianceSrc;
|
174
|
+
return applianceSrc || icons[ApplianceNames.shape];
|
175
175
|
}
|
176
176
|
}
|
177
177
|
|
package/src/Cursor/index.ts
CHANGED
@@ -10,6 +10,7 @@ import type { PositionType } from "../AttributesDelegate";
|
|
10
10
|
import type { Point, RoomMember, View } from "white-web-sdk";
|
11
11
|
import type { AppManager } from "../AppManager";
|
12
12
|
import { ApplianceMap } from "./icons";
|
13
|
+
import { findMemberByUid } from "../Helper";
|
13
14
|
|
14
15
|
export type EventType = {
|
15
16
|
type: PositionType;
|
@@ -116,7 +117,8 @@ export class CursorManager {
|
|
116
117
|
}, 48);
|
117
118
|
|
118
119
|
private updateCursor(event: EventType, clientX: number, clientY: number) {
|
119
|
-
|
120
|
+
const self = findMemberByUid(this.manager.room, this.manager.uid);
|
121
|
+
if (this.wrapperRect && this.manager.canOperate && this.canMoveCursor(self)) {
|
120
122
|
const view = event.type === "main" ? this.manager.mainView : this.focusView;
|
121
123
|
const point = this.getPoint(view, clientX, clientY);
|
122
124
|
if (point) {
|
package/src/PageState.ts
CHANGED
@@ -18,11 +18,18 @@ export class PageStateImpl {
|
|
18
18
|
return this.manager?.mainViewScenesLength || 0;
|
19
19
|
}
|
20
20
|
|
21
|
+
public getPages() {
|
22
|
+
return this.manager.callbacksNode?.scenes.map(sceneName => {
|
23
|
+
return `${this.manager.callbacksNode?.path}${sceneName}`;
|
24
|
+
}) || [];
|
25
|
+
}
|
26
|
+
|
21
27
|
public toObject(): PageState {
|
22
28
|
const index = this.index >= this.length ? this.length - 1 : this.index;
|
23
29
|
return {
|
24
30
|
index,
|
25
31
|
length: this.length,
|
32
|
+
pages: this.getPages(),
|
26
33
|
};
|
27
34
|
}
|
28
35
|
}
|
@@ -27,15 +27,16 @@ export class CameraSynchronizer {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
// 远端 Camera 或者 size 更新
|
30
|
-
public onRemoteUpdate = throttle((camera: ICamera, size: ISize) => {
|
30
|
+
public onRemoteUpdate = throttle((camera: ICamera, size: ISize, skipUpdate = false) => {
|
31
31
|
this.remoteCamera = camera;
|
32
32
|
this.remoteSize = size;
|
33
|
-
if (
|
34
|
-
|
35
|
-
|
33
|
+
if (skipUpdate) return;;
|
34
|
+
requestAnimationFrame(() => {
|
35
|
+
if (this.remoteSize && this.rect) {
|
36
|
+
this.moveCameraToContian(this.remoteSize);
|
36
37
|
this.moveCamera(camera);
|
37
|
-
}
|
38
|
-
}
|
38
|
+
}
|
39
|
+
});
|
39
40
|
}, 32);
|
40
41
|
|
41
42
|
public onRemoteSizeUpdate(size: ISize) {
|
@@ -49,7 +50,9 @@ export class CameraSynchronizer {
|
|
49
50
|
height: size.height,
|
50
51
|
originX: currentCamera.centerX - (size.width / 2),
|
51
52
|
originY: currentCamera.centerY - (size.height / 2),
|
53
|
+
animationMode: AnimationMode.Immediately,
|
52
54
|
});
|
55
|
+
this.moveCamera(this.remoteCamera);
|
53
56
|
}
|
54
57
|
}
|
55
58
|
|
package/src/View/MainView.ts
CHANGED
@@ -130,6 +130,11 @@ export class MainViewProxy {
|
|
130
130
|
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
131
131
|
};
|
132
132
|
|
133
|
+
public saveToCamera$ = () => {
|
134
|
+
const camera = { ...this.view.camera, id: this.manager.uid };
|
135
|
+
this.camera$.setValue(camera, true);
|
136
|
+
}
|
137
|
+
|
133
138
|
public storeCurrentCamera = () => {
|
134
139
|
const iCamera = this.view.camera;
|
135
140
|
this.storeCamera({
|
package/src/View/ViewSync.ts
CHANGED
@@ -89,10 +89,9 @@ export class ViewSync {
|
|
89
89
|
|
90
90
|
private subscribeCamera = () => {
|
91
91
|
return this.context.camera$.subscribe((camera, skipUpdate) => {
|
92
|
-
if (skipUpdate) return;
|
93
92
|
const size = this.context.size$.value;
|
94
93
|
if (camera && size) {
|
95
|
-
this.synchronizer.onRemoteUpdate(camera, size);
|
94
|
+
this.synchronizer.onRemoteUpdate(camera, size, skipUpdate);
|
96
95
|
}
|
97
96
|
});
|
98
97
|
};
|
package/src/index.ts
CHANGED
@@ -852,6 +852,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
852
852
|
|
853
853
|
private debouncedStoreCamera = () => {
|
854
854
|
const storeCamera = debounce(() => {
|
855
|
+
this.appManager?.mainViewProxy.saveToCamera$();
|
855
856
|
this.appManager?.mainViewProxy.storeCurrentCamera();
|
856
857
|
this.appManager?.mainViewProxy.storeCurrentSize();
|
857
858
|
this.mainView.callbacks.off("onCameraUpdated", storeCamera);
|