@netless/window-manager 0.1.69-canary.0 → 0.2.1

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/style.css CHANGED
@@ -1 +1 @@
1
- .netless-window-manager-playground{width:100%;height:100%;position:relative;z-index:1;overflow:hidden}.netless-window-manager-sizer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;overflow:hidden;display:flex}.netless-window-manager-sizer-horizontal{flex-direction:column}.netless-window-manager-sizer:before,.netless-window-manager-sizer:after{flex:1;content:"";display:block}.netless-window-manager-chess-sizer:before,.netless-window-manager-chess-sizer:after{background-image:linear-gradient(45deg,#b0b0b0 25%,transparent 25%),linear-gradient(-45deg,#b0b0b0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#b0b0b0 75%),linear-gradient(-45deg,transparent 75%,#b0b0b0 75%);background-color:#fff;background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}.netless-window-manager-wrapper{position:relative;z-index:1;width:100%;height:100%;overflow:hidden}.netless-window-manager-main-view{width:100%;height:100%}.cursor-box{color:#fff;padding:4px;border-radius:2px;width:100%;height:100%;position:absolute}.cursor-pencil-image{width:26px;height:26px}.cursor-selector-image{width:24px;height:24px}.cursor-selector-avatar{border-radius:50%;border-style:solid;border-width:2px;border-color:#fff;margin-bottom:2px}.cursor-selector-avatar img{width:12px}.cursor-inner{border-radius:4px;display:flex;align-items:center;justify-content:center;flex-direction:row;padding-left:4px;padding-right:4px;font-size:12px}.cursor-inner-mellow{height:32px;border-radius:16px;display:flex;align-items:center;justify-content:center;flex-direction:row;padding-left:16px;padding-right:16px}.cursor-tag-name{font-size:12px;margin-left:4px;padding:2px 8px;border-radius:4px}.netless-window-manager-cursor-mid{display:flex;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:26px;height:26px;z-index:2000;left:0;top:0;will-change:transform;transition:transform .05s;transform-origin:0 0;user-select:none}.cursor-pencil-offset{margin-left:-20px}.cursor-selector-offset{margin-left:-22px;margin-top:56px}.cursor-text-offset{margin-left:-30px;margin-top:18px}.cursor-shape-offset{display:flex;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:180px;height:64px;margin-left:-30px;margin-top:12px}.netless-window-manager-cursor-name{width:100%;height:48px;display:flex;align-items:center;justify-content:center;position:absolute;top:-40px}.cursor-image-wrapper{display:flex;justify-content:center}.tele-fancy-scrollbar{overscroll-behavior:contain;overflow:auto;overflow-y:scroll;overflow-y:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.tele-fancy-scrollbar::-webkit-scrollbar{height:8px;width:8px}.tele-fancy-scrollbar::-webkit-scrollbar-track{background-color:transparent}.tele-fancy-scrollbar::-webkit-scrollbar-thumb{background-color:#444e601a;background-color:transparent;border-radius:4px;transition:background-color .4s}.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb{background-color:#444e601a}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover{background-color:#444e6033}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active{background-color:#444e6033}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical{min-height:50px}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-box{position:absolute;top:0;left:0;z-index:100;will-change:transform;transition:width .4s cubic-bezier(.4,.9,.71,1.02),height .4s cubic-bezier(.55,.82,.63,.95),opacity .6s cubic-bezier(.7,0,.84,0),transform .4s ease}.telebox-box-main{position:relative;width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#f9f9fc;box-shadow:0 4px 10px #2f419226;border-radius:6px;border:1px solid #e3e3ec}.telebox-titlebar-wrap{flex-shrink:0;position:relative;z-index:1}.telebox-content-wrap{flex:1;width:100%;overflow:hidden;display:flex;justify-content:center;align-items:center}.telebox-content{width:100%;height:100%;position:relative}.telebox-footer-wrap{flex-shrink:0;display:flex;flex-direction:column}.telebox-footer-wrap:before{content:"";display:block;flex:1}.telebox-resize-handle{position:absolute;z-index:2147483647}.telebox-n{width:100%;height:5px;left:0;top:-5px;cursor:n-resize}.telebox-s{width:100%;height:5px;left:0;bottom:-5px;cursor:s-resize}.telebox-w{width:5px;height:100%;left:-5px;top:0;cursor:w-resize}.telebox-e{width:5px;height:100%;right:-5px;top:0;cursor:e-resize}.telebox-nw{width:15px;height:15px;top:-5px;left:-5px;cursor:nw-resize}.telebox-ne{width:15px;height:15px;top:-5px;right:-5px;cursor:ne-resize}.telebox-se{width:15px;height:15px;bottom:-5px;right:-5px;cursor:se-resize}.telebox-sw{width:15px;height:15px;bottom:-5px;left:-5px;cursor:sw-resize}.telebox-track-mask{position:fixed;top:0;left:0;z-index:2147483647;width:100%;height:100%;background:rgba(0,0,0,.0001);cursor:move}.telebox-cursor-n{cursor:n-resize}.telebox-cursor-s{cursor:s-resize}.telebox-cursor-w{cursor:w-resize}.telebox-cursor-e{cursor:e-resize}.telebox-cursor-nw{cursor:nw-resize}.telebox-cursor-ne{cursor:ne-resize}.telebox-cursor-se{cursor:se-resize}.telebox-cursor-sw{cursor:sw-resize}.telebox-maximized .telebox-resize-handles,.telebox-no-resize .telebox-resize-handles{display:none}.telebox-maximized{box-shadow:none;transition:none}.telebox-minimized{will-change:transform;transition:width 50ms cubic-bezier(.4,.9,.71,1.02),height 50ms cubic-bezier(.55,.82,.63,.95),opacity .6s cubic-bezier(.7,0,.84,0),transform .6s ease;opacity:0;pointer-events:none;user-select:none}.telebox-transforming{will-change:transform;transition:opacity .6s cubic-bezier(.7,0,.84,0)}.telebox-readonly .telebox-resize-handle{cursor:initial!important;pointer-events:none!important}.telebox-titlebar{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;background:#fff;user-select:none;border-bottom:1px solid #eeeef7}.telebox-title{overflow:hidden;margin:0 24px 0 0;padding:0;font-size:14px;font-weight:400;font-family:PingFangSC-Regular,PingFang SC;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;color:#191919}.telebox-titlebar-btns{white-space:nowrap;word-break:keep-all;margin-left:auto;font-size:0}.telebox-titlebar-btn{width:22px;height:22px;padding:0;outline:0;border:none;background:0 0;cursor:pointer}.telebox-titlebar-btn~.telebox-titlebar-btn{margin-left:10px}.telebox-titlebar-btn-icon{width:22px;height:22px}.telebox-readonly .telebox-titlebar-btn{cursor:not-allowed}.telebox-collector{visibility:hidden;display:block;position:absolute;z-index:200;width:40px;height:40px;margin:0;padding:0;border:none;outline:0;font-size:0;border-radius:50%;background:#fff;box-shadow:0 2px 6px #2f419226;cursor:pointer;user-select:none;pointer-events:none}.telebox-collector-icon{width:18px;height:16px}.telebox-collector-visible{visibility:visible;pointer-events:initial}.telebox-max-titlebar{display:none;position:absolute;top:0;left:0;z-index:50000;user-select:none}.telebox-max-titlebar-maximized{display:flex}.telebox-titles{flex:1;height:100%;margin:0 16px 0 -16px;overflow-y:hidden;overflow-x:scroll;overflow-x:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.telebox-titles::-webkit-scrollbar{height:8px;width:8px}.telebox-titles::-webkit-scrollbar-track{background-color:transparent}.telebox-titles::-webkit-scrollbar-thumb{background-color:#eeeef7cc;background-color:transparent;border-radius:4px;transition:background-color .4s}.telebox-titles:hover::-webkit-scrollbar-thumb{background-color:#eeeef7cc}.telebox-titles::-webkit-scrollbar-thumb:hover{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:active{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:vertical{min-height:50px}.telebox-titles::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-titles-content{height:100%;display:flex;flex-wrap:nowrap;align-items:center;padding:0}.telebox-titles-tab{overflow:hidden;max-width:182px;min-width:50px;padding:0 26px 0 16px;outline:0;font-size:13px;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;text-overflow:ellipsis;white-space:nowrap;word-break:keep-all;border:none;border-right:1px solid #e5e5f0;color:#7b88a0;background:0 0;cursor:pointer}.telebox-titles-tab~.telebox-titles-tab{margin-left:2px}.telebox-titles-tab-focus{color:#357bf6}.telebox-readonly .telebox-titles-tab{cursor:not-allowed}
1
+ .netless-window-manager-playground{width:100%;height:100%;position:relative;z-index:1;overflow:hidden}.netless-window-manager-sizer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;overflow:hidden;display:flex}.netless-window-manager-sizer-horizontal{flex-direction:column}.netless-window-manager-sizer:before,.netless-window-manager-sizer:after{flex:1;content:"";display:block}.netless-window-manager-chess-sizer:before,.netless-window-manager-chess-sizer:after{background-image:linear-gradient(45deg,#b0b0b0 25%,transparent 25%),linear-gradient(-45deg,#b0b0b0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#b0b0b0 75%),linear-gradient(-45deg,transparent 75%,#b0b0b0 75%);background-color:#fff;background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}.netless-window-manager-wrapper{position:relative;z-index:1;width:100%;height:100%;overflow:hidden}.netless-window-manager-main-view{width:100%;height:100%}.netless-window-manager-cursor-pencil-image{width:26px;height:26px}.netless-window-manager-cursor-selector-image{width:24px;height:24px}.netless-window-manager-cursor-selector-avatar{border-radius:50%;border-style:solid;border-width:2px;border-color:#fff;margin-bottom:2px}.netless-window-manager-cursor-selector-avatar img{width:12px}.netless-window-manager-cursor-inner{border-radius:4px;display:flex;align-items:center;justify-content:center;flex-direction:row;padding-left:4px;padding-right:4px;font-size:12px}.netless-window-manager-cursor-inner-mellow{height:32px;border-radius:16px;display:flex;align-items:center;justify-content:center;flex-direction:row;padding-left:16px;padding-right:16px}.netless-window-manager-cursor-tag-name{font-size:12px;margin-left:4px;padding:2px 8px;border-radius:4px}.netless-window-manager-cursor-mid{display:flex;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:26px;height:26px;z-index:2000;left:0;top:0;will-change:transform;transition:transform .05s;transform-origin:0 0;user-select:none}.netless-window-manager-cursor-pencil-offset{margin-left:-20px}.netless-window-manager-cursor-selector-offset{margin-left:-22px;margin-top:56px}.netless-window-manager-cursor-text-offset{margin-left:-30px;margin-top:18px}.netless-window-manager-cursor-shape-offset{display:flex;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:180px;height:64px;margin-left:-30px;margin-top:12px}.netless-window-manager-cursor-name{width:100%;height:48px;display:flex;align-items:center;justify-content:center;position:absolute;top:-40px}.cursor-image-wrapper{display:flex;justify-content:center}.tele-fancy-scrollbar{overscroll-behavior:contain;overflow:auto;overflow-y:scroll;overflow-y:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.tele-fancy-scrollbar::-webkit-scrollbar{height:8px;width:8px}.tele-fancy-scrollbar::-webkit-scrollbar-track{background-color:transparent}.tele-fancy-scrollbar::-webkit-scrollbar-thumb{background-color:#444e601a;background-color:transparent;border-radius:4px;transition:background-color .4s}.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb{background-color:#444e601a}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover{background-color:#444e6033}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active{background-color:#444e6033}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical{min-height:50px}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-box{position:absolute;top:0;left:0;z-index:100;will-change:transform;transition:width .4s cubic-bezier(.4,.9,.71,1.02),height .4s cubic-bezier(.55,.82,.63,.95),opacity .6s cubic-bezier(.7,0,.84,0),transform .4s ease}.telebox-box-main{position:relative;width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#f9f9fc;box-shadow:0 4px 10px #2f419226;border-radius:6px;border:1px solid #e3e3ec}.telebox-titlebar-wrap{flex-shrink:0;position:relative;z-index:1}.telebox-content-wrap{flex:1;width:100%;overflow:hidden;display:flex;justify-content:center;align-items:center}.telebox-content{width:100%;height:100%;position:relative}.telebox-footer-wrap{flex-shrink:0;display:flex;flex-direction:column}.telebox-footer-wrap:before{content:"";display:block;flex:1}.telebox-resize-handle{position:absolute;z-index:2147483647}.telebox-n{width:100%;height:5px;left:0;top:-5px;cursor:n-resize}.telebox-s{width:100%;height:5px;left:0;bottom:-5px;cursor:s-resize}.telebox-w{width:5px;height:100%;left:-5px;top:0;cursor:w-resize}.telebox-e{width:5px;height:100%;right:-5px;top:0;cursor:e-resize}.telebox-nw{width:15px;height:15px;top:-5px;left:-5px;cursor:nw-resize}.telebox-ne{width:15px;height:15px;top:-5px;right:-5px;cursor:ne-resize}.telebox-se{width:15px;height:15px;bottom:-5px;right:-5px;cursor:se-resize}.telebox-sw{width:15px;height:15px;bottom:-5px;left:-5px;cursor:sw-resize}.telebox-track-mask{position:fixed;top:0;left:0;z-index:2147483647;width:100%;height:100%;background:rgba(0,0,0,.0001);cursor:move}.telebox-cursor-n{cursor:n-resize}.telebox-cursor-s{cursor:s-resize}.telebox-cursor-w{cursor:w-resize}.telebox-cursor-e{cursor:e-resize}.telebox-cursor-nw{cursor:nw-resize}.telebox-cursor-ne{cursor:ne-resize}.telebox-cursor-se{cursor:se-resize}.telebox-cursor-sw{cursor:sw-resize}.telebox-maximized .telebox-resize-handles,.telebox-no-resize .telebox-resize-handles{display:none}.telebox-maximized{box-shadow:none;transition:none}.telebox-minimized{will-change:transform;transition:width 50ms cubic-bezier(.4,.9,.71,1.02),height 50ms cubic-bezier(.55,.82,.63,.95),opacity .6s cubic-bezier(.7,0,.84,0),transform .6s ease;opacity:0;pointer-events:none;user-select:none}.telebox-transforming{will-change:transform;transition:opacity .6s cubic-bezier(.7,0,.84,0)}.telebox-readonly .telebox-resize-handle{cursor:initial!important;pointer-events:none!important}.telebox-titlebar{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;background:#fff;user-select:none;border-bottom:1px solid #eeeef7}.telebox-title{overflow:hidden;margin:0 24px 0 0;padding:0;font-size:14px;font-weight:400;font-family:PingFangSC-Regular,PingFang SC;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;color:#191919}.telebox-titlebar-btns{white-space:nowrap;word-break:keep-all;margin-left:auto;font-size:0}.telebox-titlebar-btn{width:22px;height:22px;padding:0;outline:0;border:none;background:0 0;cursor:pointer}.telebox-titlebar-btn~.telebox-titlebar-btn{margin-left:10px}.telebox-titlebar-btn-icon{width:22px;height:22px}.telebox-readonly .telebox-titlebar-btn{cursor:not-allowed}.telebox-collector{visibility:hidden;display:block;position:absolute;z-index:200;width:40px;height:40px;margin:0;padding:0;border:none;outline:0;font-size:0;border-radius:50%;background:#fff;box-shadow:0 2px 6px #2f419226;cursor:pointer;user-select:none;pointer-events:none}.telebox-collector-icon{width:18px;height:16px}.telebox-collector-visible{visibility:visible;pointer-events:initial}.telebox-max-titlebar{display:none;position:absolute;top:0;left:0;z-index:50000;user-select:none}.telebox-max-titlebar-maximized{display:flex}.telebox-titles{flex:1;height:100%;margin:0 16px 0 -16px;overflow-y:hidden;overflow-x:scroll;overflow-x:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.telebox-titles::-webkit-scrollbar{height:8px;width:8px}.telebox-titles::-webkit-scrollbar-track{background-color:transparent}.telebox-titles::-webkit-scrollbar-thumb{background-color:#eeeef7cc;background-color:transparent;border-radius:4px;transition:background-color .4s}.telebox-titles:hover::-webkit-scrollbar-thumb{background-color:#eeeef7cc}.telebox-titles::-webkit-scrollbar-thumb:hover{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:active{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:vertical{min-height:50px}.telebox-titles::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-titles-content{height:100%;display:flex;flex-wrap:nowrap;align-items:center;padding:0}.telebox-titles-tab{overflow:hidden;max-width:182px;min-width:50px;padding:0 26px 0 16px;outline:0;font-size:13px;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;text-overflow:ellipsis;white-space:nowrap;word-break:keep-all;border:none;border-right:1px solid #e5e5f0;color:#7b88a0;background:0 0;cursor:pointer}.telebox-titles-tab~.telebox-titles-tab{margin-left:2px}.telebox-titles-tab-focus{color:#357bf6}.telebox-readonly .telebox-titles-tab{cursor:not-allowed}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.1.69-canary.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -25,11 +25,10 @@
25
25
  "@netless/app-docs-viewer": "^0.1.21",
26
26
  "@netless/app-media-player": "0.1.0-beta.5",
27
27
  "@netless/telebox-insider": "^0.1.17",
28
- "dexie": "^3.0.3",
29
28
  "emittery": "^0.9.2",
30
29
  "lodash": "^4.17.21",
31
30
  "p-retry": "^4.6.1",
32
- "uuid": "^8.3.2",
31
+ "uuid": "^7.0.3",
33
32
  "video.js": ">=7"
34
33
  },
35
34
  "devDependencies": {
package/src/AppContext.ts CHANGED
@@ -1,11 +1,19 @@
1
- import { autorun, reaction, listenUpdated, unlistenUpdated, listenDisposed, unlistenDisposed } from "white-web-sdk";
1
+ import {
2
+ autorun,
3
+ listenDisposed,
4
+ listenUpdated,
5
+ reaction,
6
+ unlistenDisposed,
7
+ unlistenUpdated
8
+ } from 'white-web-sdk';
9
+ import { BoxNotCreatedError } from './Utils/error';
10
+ import { wait } from './Utils/Common';
2
11
  import type { Room, SceneDefinition, View } from "white-web-sdk";
3
12
  import type { ReadonlyTeleBox } from "@netless/telebox-insider";
4
13
  import type Emittery from "emittery";
5
14
  import type { BoxManager } from "./BoxManager";
6
15
  import type { AppEmitterEvent } from "./index";
7
16
  import type { AppManager } from "./AppManager";
8
- import { BoxNotCreatedError } from "./Utils/error";
9
17
  import type { AppProxy } from "./AppProxy";
10
18
 
11
19
  export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
@@ -91,6 +99,17 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
91
99
  }
92
100
  }
93
101
 
102
+ public async setScenePath(scenePath: string): Promise<void> {
103
+ if (!this.appProxy.box) return;
104
+ if (this.appProxy.box.focus) {
105
+ this.getRoom()?.setScenePath(scenePath);
106
+ } else {
107
+ this.emitter.emit("focus", true);
108
+ await wait(50);
109
+ this.getRoom()?.setScenePath(scenePath);
110
+ }
111
+ }
112
+
94
113
  public mountView(dom: HTMLDivElement): void {
95
114
  const view = this.getView();
96
115
  if (view) {
@@ -44,7 +44,7 @@
44
44
  >
45
45
  {#if hasAvatar}
46
46
  <img
47
- class="cursor-selector-avatar"
47
+ class="netless-window-manager-cursor-selector-avatar"
48
48
  style={computedAvatarStyle()}
49
49
  src={avatar}
50
50
  alt="avatar"
@@ -52,13 +52,13 @@
52
52
  {/if}
53
53
  {cursorName}
54
54
  {#if hasTagName}
55
- <span class="cursor-tag-name" style="background-color: {cursorTagBackgroundColor}">
55
+ <span class="netless-window-manager-cursor-tag-name" style="background-color: {cursorTagBackgroundColor}">
56
56
  {tagName}
57
57
  </span>
58
58
  {/if}
59
59
  </div>
60
60
  </div>
61
61
  <div class="cursor-image-wrapper">
62
- <img class="cursor-{appliance}-image" {src} alt={appliance} />
62
+ <img class="netless-window-manager-cursor-{appliance}-image" {src} alt={appliance} />
63
63
  </div>
64
64
  </div>
@@ -80,9 +80,9 @@ export class Cursor {
80
80
 
81
81
  private get memberTheme() {
82
82
  if (this.payload?.theme) {
83
- return "cursor-inner-mellow";
83
+ return "netless-window-manager-cursor-inner-mellow";
84
84
  } else {
85
- return "cursor-inner";
85
+ return "netless-window-manager-cursor-inner";
86
86
  }
87
87
  }
88
88
 
@@ -155,7 +155,8 @@ export class Cursor {
155
155
 
156
156
  private getIcon() {
157
157
  if (this.member) {
158
- return ApplianceMap[this.memberApplianceName || ApplianceNames.shape];
158
+ const applianceSrc = ApplianceMap[this.memberApplianceName || ApplianceNames.shape];
159
+ return applianceSrc || ApplianceMap[ApplianceNames.shape];
159
160
  }
160
161
  }
161
162
 
@@ -1,21 +1,76 @@
1
- import Dexie from "dexie";
2
-
3
1
  const DatabaseName = "__WindowManagerAppCache";
4
2
 
5
- const db = new Dexie(DatabaseName);
3
+ let db: IDBDatabase;
4
+ let store: IDBObjectStore;
6
5
 
7
- db.version(1).stores({
8
- apps: "kind, sourceCode",
9
- });
6
+ export const initDb = async () => {
7
+ db = await createDb();
8
+ }
10
9
 
11
- export const getItem = async (key: string): Promise<string> => {
12
- return (await db.table("apps").get(key))?.sourceCode;
10
+ export const setItem = (key: string, val: any) => {
11
+ if (!db) return;
12
+ return addRecord(db, { kind: key, sourceCode: val })
13
13
  };
14
14
 
15
- export const setItem = (key: string, val: any) => {
16
- return db.table("apps").add({ kind: key, sourceCode: val });
15
+ export const getItem = async (key: string): Promise<string | null> => {
16
+ if (!db) return null;
17
+ return await query(db, key);
17
18
  };
18
19
 
19
20
  export const removeItem = (key: string) => {
20
- return db.table("apps").delete(key);
21
+ if (!db) return;
22
+ return deleteRecord(db, key);
21
23
  };
24
+
25
+ function createDb(): Promise<IDBDatabase> {
26
+ return new Promise((resolve, reject) => {
27
+ const request = indexedDB.open(DatabaseName, 2);
28
+ request.onerror = (e) => {
29
+ reject(e);
30
+ }
31
+
32
+ request.onupgradeneeded = (event: any) => {
33
+ const db = event.target.result as IDBDatabase;
34
+ if (!db.objectStoreNames.contains("apps")) {
35
+ store = db.createObjectStore("apps", { keyPath: "kind" });
36
+ store.createIndex("kind", "kind", { unique: true });
37
+ }
38
+ }
39
+
40
+ request.onsuccess = () => {
41
+ const db = request.result;
42
+ resolve(db);
43
+ }
44
+ })
45
+ }
46
+
47
+ function query<T>(db: IDBDatabase, val: string): Promise<T | null> {
48
+ return new Promise((resolve, reject) => {
49
+ const index = db.transaction(["apps"]).objectStore("apps").index("kind");
50
+ const request = index.get(val);
51
+ request.onerror = (e) => reject(e);
52
+ request.onsuccess = () => {
53
+ if (request.result) {
54
+ resolve(request.result);
55
+ } else {
56
+ resolve(null);
57
+ }
58
+ }
59
+ })
60
+ }
61
+
62
+ function addRecord(db: IDBDatabase, payload: any): Promise<void> {
63
+ return new Promise((resolve, reject) => {
64
+ const request = db.transaction(["apps"], "readwrite").objectStore("apps").add(payload);
65
+ request.onsuccess = () => resolve();
66
+ request.onerror = () => reject();
67
+ })
68
+ }
69
+
70
+ function deleteRecord(db: IDBDatabase, key: string): Promise<void> {
71
+ return new Promise((resolve, reject) => {
72
+ const request = db.transaction(["apps"], "readwrite").objectStore("apps").delete(key);
73
+ request.onsuccess = () => resolve();
74
+ request.onerror = () => reject();
75
+ })
76
+ }
package/src/index.ts CHANGED
@@ -40,6 +40,7 @@ import type { AppListeners } from "./AppListener";
40
40
  import type { NetlessApp, RegisterParams } from "./typings";
41
41
  import type { TELE_BOX_STATE } from "./BoxManager";
42
42
  import { REQUIRE_VERSION, DEFAULT_CONTAINER_RATIO } from "./constants";
43
+ import { initDb } from "./Register/storage";
43
44
 
44
45
  const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
45
46
 
@@ -254,6 +255,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
254
255
  replaceRoomFunction(room, manager.appManager);
255
256
  emitter.emit("onCreated");
256
257
  WindowManager.isCreated = true;
258
+ try {
259
+ await initDb();
260
+ } catch (error) {
261
+ console.warn("[WindowManager]: indexedDB open failed");
262
+ console.log(error);
263
+ }
257
264
  return manager;
258
265
  }
259
266
 
package/src/style.css CHANGED
@@ -52,26 +52,18 @@
52
52
  height: 100%;
53
53
  }
54
54
 
55
- .cursor-box {
56
- color: white;
57
- padding: 4px;
58
- border-radius: 2px;
59
- width: 100%;
60
- height: 100%;
61
- position: absolute;
62
- }
63
55
 
64
- .cursor-pencil-image {
56
+ .netless-window-manager-cursor-pencil-image {
65
57
  width: 26px;
66
58
  height: 26px;
67
59
  }
68
60
 
69
- .cursor-selector-image {
61
+ .netless-window-manager-cursor-selector-image {
70
62
  width: 24px;
71
63
  height: 24px;
72
64
  }
73
65
 
74
- .cursor-selector-avatar {
66
+ .netless-window-manager-cursor-selector-avatar {
75
67
  border-radius: 50%;
76
68
  border-style: solid;
77
69
  border-width: 2px;
@@ -79,11 +71,11 @@
79
71
  margin-bottom: 2px;
80
72
  }
81
73
 
82
- .cursor-selector-avatar img {
74
+ .netless-window-manager-cursor-selector-avatar img {
83
75
  width: 12px;
84
76
  }
85
77
 
86
- .cursor-inner {
78
+ .netless-window-manager-cursor-inner {
87
79
  border-radius: 4px;
88
80
  display: flex;
89
81
  align-items: center;
@@ -94,7 +86,7 @@
94
86
  font-size: 12px;
95
87
  }
96
88
 
97
- .cursor-inner-mellow {
89
+ .netless-window-manager-cursor-inner-mellow {
98
90
  height: 32px;
99
91
  border-radius: 16px;
100
92
  display: flex;
@@ -105,7 +97,7 @@
105
97
  padding-right: 16px;
106
98
  }
107
99
 
108
- .cursor-tag-name {
100
+ .netless-window-manager-cursor-tag-name {
109
101
  font-size: 12px;
110
102
  margin-left: 4px;
111
103
  padding: 2px 8px;
@@ -129,21 +121,21 @@
129
121
  user-select: none;
130
122
  }
131
123
 
132
- .cursor-pencil-offset {
124
+ .netless-window-manager-cursor-pencil-offset {
133
125
  margin-left: -20px;
134
126
  }
135
127
 
136
- .cursor-selector-offset {
128
+ .netless-window-manager-cursor-selector-offset {
137
129
  margin-left: -22px;
138
130
  margin-top: 56px;
139
131
  }
140
132
 
141
- .cursor-text-offset {
133
+ .netless-window-manager-cursor-text-offset {
142
134
  margin-left: -30px;
143
135
  margin-top: 18px;
144
136
  }
145
137
 
146
- .cursor-shape-offset {
138
+ .netless-window-manager-cursor-shape-offset {
147
139
  display: flex;
148
140
  flex-direction: column;
149
141
  align-items: center;