@netless/window-manager 0.4.59 → 0.4.61-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.
- package/dist/AttributesDelegate.d.ts +4 -1
- package/dist/View/IframeBridge.d.ts +146 -0
- package/dist/View/MainView.d.ts +2 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +555 -9
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +2 -2
- package/package.json +3 -3
- package/src/AttributesDelegate.ts +18 -1
- package/src/View/IframeBridge.ts +636 -0
- package/src/View/MainView.ts +14 -1
- package/src/index.ts +19 -5
- package/src/style.css +4 -0
- package/src/typings.ts +2 -2
package/src/index.ts
CHANGED
@@ -55,6 +55,8 @@ import type { PublicEvent } from "./callback";
|
|
55
55
|
import type Emittery from "emittery";
|
56
56
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
57
57
|
import { boxEmitter } from "./BoxEmitter";
|
58
|
+
import { IframeBridge } from "./View/IframeBridge";
|
59
|
+
export * from "./View/IframeBridge";
|
58
60
|
|
59
61
|
export type WindowMangerAttributes = {
|
60
62
|
modelValue?: string;
|
@@ -364,9 +366,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
364
366
|
/**
|
365
367
|
* 注册插件
|
366
368
|
*/
|
367
|
-
public static register<
|
368
|
-
params: RegisterParams<AppOptions, SetupResult, Attributes>
|
369
|
-
): Promise<void> {
|
369
|
+
public static register(params: RegisterParams<any, any, any>): Promise<void> {
|
370
370
|
return appRegister.register(params);
|
371
371
|
}
|
372
372
|
|
@@ -820,6 +820,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
820
820
|
WindowManager.playground.parentNode?.removeChild(WindowManager.playground);
|
821
821
|
}
|
822
822
|
WindowManager.params = undefined;
|
823
|
+
this._iframeBridge?.destroy();
|
824
|
+
this._iframeBridge = undefined;
|
823
825
|
log("Destroyed");
|
824
826
|
}
|
825
827
|
|
@@ -925,8 +927,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
925
927
|
}
|
926
928
|
|
927
929
|
public setContainerSizeRatio(ratio: number) {
|
928
|
-
if (!isNumber(ratio)) {
|
929
|
-
throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${ratio}`);
|
930
|
+
if (!isNumber(ratio) || !(ratio > 0)) {
|
931
|
+
throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a positive number. but got ${ratio}`);
|
930
932
|
}
|
931
933
|
WindowManager.containerSizeRatio = ratio;
|
932
934
|
this.containerSizeRatio = ratio;
|
@@ -958,7 +960,19 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
958
960
|
if (!this.attributes[Fields.Registered]) {
|
959
961
|
this.safeSetAttributes({ [Fields.Registered]: {} });
|
960
962
|
}
|
963
|
+
if (!this.attributes[Fields.IframeBridge]) {
|
964
|
+
this.safeSetAttributes({ [Fields.IframeBridge]: {} });
|
965
|
+
}
|
966
|
+
}
|
967
|
+
}
|
968
|
+
|
969
|
+
private _iframeBridge?: IframeBridge;
|
970
|
+
public getIframeBridge() {
|
971
|
+
if (!this.appManager) {
|
972
|
+
throw new Error("[WindowManager]: should call getIframeBridge() after await mount()");
|
961
973
|
}
|
974
|
+
this._iframeBridge || (this._iframeBridge = new IframeBridge(this, this.appManager));
|
975
|
+
return this._iframeBridge;
|
962
976
|
}
|
963
977
|
}
|
964
978
|
|
package/src/style.css
CHANGED
package/src/typings.ts
CHANGED
@@ -14,7 +14,7 @@ import type { AppContext } from "./App";
|
|
14
14
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
15
15
|
import type { PageState } from "./Page";
|
16
16
|
|
17
|
-
export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
|
17
|
+
export interface NetlessApp<Attributes extends {} = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
|
18
18
|
kind: string;
|
19
19
|
config?: {
|
20
20
|
/** Box width relative to whiteboard. 0~1. Default 0.5. */
|
@@ -65,7 +65,7 @@ export type RegisterEvents<SetupResult = any> = {
|
|
65
65
|
focus: RegisterEventData;
|
66
66
|
};
|
67
67
|
|
68
|
-
export type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
|
68
|
+
export type RegisterParams<AppOptions = any, SetupResult = any, Attributes extends {} = any> = {
|
69
69
|
kind: string;
|
70
70
|
src:
|
71
71
|
| NetlessApp<Attributes, SetupResult>
|