@netless/window-manager 0.4.65-beta.0 → 0.4.66-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.65-beta.0",
3
+ "version": "0.4.66-beta.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,6 +28,7 @@ import type {
28
28
  MagixEventRemoveListener,
29
29
  } from "./MagixEvent";
30
30
  import type { AddPageParams, PageController, PageState } from "../Page";
31
+ import { internalEmitter } from "../InternalEmitter";
31
32
 
32
33
  export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
33
34
  implements PageController
@@ -256,4 +257,13 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
256
257
  public get pageState(): PageState {
257
258
  return this.appProxy.pageState;
258
259
  }
260
+
261
+ public get kind(): string {
262
+ return this.appProxy.kind;
263
+ }
264
+
265
+ /** Dispatch a local event to `manager.onAppEvent()`. */
266
+ public dispatchAppEvent(type: string, value?: any): void {
267
+ internalEmitter.emit(`custom-${this.kind}` as any, { type, appId: this.appId, value });
268
+ }
259
269
  }
@@ -372,6 +372,7 @@ export class AppProxy implements PageRemoveService {
372
372
  const appState = this.appAttributes?.state;
373
373
  if (appState?.zIndex > 0 && appState.zIndex !== this.box?.zIndex) {
374
374
  this.boxManager?.setZIndex(appId, appState.zIndex);
375
+ this.boxManager?.focusBox({ appId });
375
376
  }
376
377
  });
377
378
  });
package/src/index.ts CHANGED
@@ -450,11 +450,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
450
450
  for (const appId of apps) {
451
451
  const appScenePath = appManager.store.getAppScenePath(appId);
452
452
  if (appScenePath && appScenePath === scenePath) {
453
- console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
453
+ console.warn(`[WindowManager]: ScenePath "${scenePath}" already opened`);
454
454
  if (this.boxManager) {
455
455
  const topBox = this.boxManager.getTopBox();
456
456
  if (topBox) {
457
457
  this.boxManager.setZIndex(appId, topBox.zIndex + 1, false);
458
+ this.boxManager.focusBox({ appId }, false);
458
459
  }
459
460
  }
460
461
  return;
@@ -611,6 +612,15 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
611
612
  addEmitterOnceListener(`destroy-${kind}`, listener);
612
613
  }
613
614
 
615
+ /**
616
+ * app 本地自定义事件回调
617
+ *
618
+ * 返回一个用于撤销此监听的函数
619
+ */
620
+ public onAppEvent(kind: string, listener: (args: { type: string, appId: string, value: any }) => void): () => void {
621
+ return internalEmitter.on(`custom-${kind}` as any, listener);
622
+ }
623
+
614
624
  /**
615
625
  * 设置 ViewMode
616
626
  */