@netless/window-manager 0.3.2 → 0.3.5-canary.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.
Files changed (45) hide show
  1. package/dist/AppListener.d.ts +0 -2
  2. package/dist/AppManager.d.ts +8 -8
  3. package/dist/Base/Context.d.ts +2 -2
  4. package/dist/BoxManager.d.ts +6 -2
  5. package/dist/Cursor/Cursor.d.ts +1 -0
  6. package/dist/Cursor/index.d.ts +2 -1
  7. package/dist/ViewManager.d.ts +0 -2
  8. package/dist/index.es.js +1 -1
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.umd.js +1 -1
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/typings.d.ts +1 -0
  13. package/package.json +3 -3
  14. package/src/AppContext.ts +1 -2
  15. package/src/AppListener.ts +0 -10
  16. package/src/AppManager.ts +44 -95
  17. package/src/AppProxy.ts +1 -0
  18. package/src/Base/Context.ts +6 -4
  19. package/src/BoxManager.ts +19 -7
  20. package/src/Cursor/Cursor.ts +8 -4
  21. package/src/Cursor/index.ts +15 -14
  22. package/src/index.ts +5 -4
  23. package/src/typings.ts +1 -0
  24. package/src/viewManager.ts +4 -23
  25. package/e2e/cypress/integration/index.spec.ts +0 -105
  26. package/e2e/cypress/integration/readonly.spec.ts +0 -26
  27. package/e2e/cypress/plugins/index.js +0 -22
  28. package/e2e/cypress/support/commands.js +0 -25
  29. package/e2e/cypress/support/index.js +0 -20
  30. package/e2e/cypress.json +0 -6
  31. package/e2e/package.json +0 -15
  32. package/example/.env +0 -4
  33. package/example/babel.config.js +0 -15
  34. package/example/dist/assets/css/chunk-vendors.d2fb6693.chunk.css +0 -1
  35. package/example/dist/assets/css/index.12f29b9a.chunk.css +0 -1
  36. package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js +0 -2
  37. package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js.LICENSE.txt +0 -136
  38. package/example/dist/assets/js/index.12f29b9a.chunk.js +0 -1
  39. package/example/dist/assets/js/runtime~index.d502de40.js +0 -1
  40. package/example/dist/index.html +0 -1
  41. package/example/index.html +0 -13
  42. package/example/index.tsx +0 -367
  43. package/example/package.json +0 -23
  44. package/example/poi.config.js +0 -12
  45. package/example/test.js +0 -114
package/example/index.tsx DELETED
@@ -1,367 +0,0 @@
1
- import React from "react";
2
- import ReactDom from "react-dom";
3
- import { PlayerPhase, WhiteWebSdk } from "white-web-sdk";
4
- import type { AppContext} from "../dist";
5
- import { BuiltinApps, WindowManager } from "../dist/index.es";
6
- import "../dist/style.css";
7
- import "video.js/dist/video-js.css";
8
-
9
- const anyWindow = window as any;
10
-
11
- const createHelloWorld = () => {
12
- anyWindow.manager.addApp({
13
- kind: "HelloWorld",
14
- options: {
15
- scenePath: "/helloworld1"
16
- }
17
- });
18
- }
19
-
20
- const createDocs1 = () => {
21
- anyWindow.manager.addApp({
22
- kind: BuiltinApps.DocsViewer,
23
- options: {
24
- scenePath: "/test5/",
25
- title: "ppt1",
26
- scenes: [
27
- {
28
- name: "1",
29
- ppt: {
30
- "height": 1010,
31
- "src": "https://convertcdn.netless.link/staticConvert/18140800fe8a11eb8cb787b1c376634e/1.png",
32
- "width": 714
33
- }
34
- },
35
- {
36
- name: "2",
37
- ppt: {
38
- "height": 1010,
39
- "src": "https://convertcdn.netless.link/staticConvert/18140800fe8a11eb8cb787b1c376634e/2.png",
40
- "width": 714
41
- }
42
- },
43
- ]
44
- },
45
- }).then(appId => console.log("appID", appId));
46
- }
47
- const createDocs2 = () => {
48
- anyWindow.manager.addApp({
49
- kind: BuiltinApps.DocsViewer,
50
- options: {
51
- scenePath: "/ppt3",
52
- title: "ppt3",
53
- scenes: [
54
- {
55
- "name": "1",
56
- "ppt": {
57
- "height": 720,
58
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/1.png",
59
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/1.slide",
60
- "width": 1280
61
- }
62
- },
63
- {
64
- "name": "2",
65
- "ppt": {
66
- "height": 720,
67
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/2.png",
68
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/2.slide",
69
- "width": 1280
70
- }
71
- },
72
- {
73
- "name": "3",
74
- "ppt": {
75
- "height": 720,
76
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/3.png",
77
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/3.slide",
78
- "width": 1280
79
- }
80
- },
81
- {
82
- "name": "4",
83
- "ppt": {
84
- "height": 720,
85
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/4.png",
86
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/4.slide",
87
- "width": 1280
88
- }
89
- },
90
- {
91
- "name": "5",
92
- "ppt": {
93
- "height": 720,
94
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/5.png",
95
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/5.slide",
96
- "width": 1280
97
- }
98
- },
99
- {
100
- "name": "6",
101
- "ppt": {
102
- "height": 720,
103
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/6.png",
104
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/6.slide",
105
- "width": 1280
106
- }
107
- },
108
- {
109
- "name": "7",
110
- "ppt": {
111
- "height": 720,
112
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/7.png",
113
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/7.slide",
114
- "width": 1280
115
- }
116
- },
117
- {
118
- "name": "8",
119
- "ppt": {
120
- "height": 720,
121
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/8.png",
122
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/8.slide",
123
- "width": 1280
124
- }
125
- },
126
- {
127
- "name": "9",
128
- "ppt": {
129
- "height": 720,
130
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/9.png",
131
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/9.slide",
132
- "width": 1280
133
- }
134
- },
135
- {
136
- "name": "10",
137
- "ppt": {
138
- "height": 720,
139
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/10.png",
140
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/10.slide",
141
- "width": 1280
142
- }
143
- },
144
- {
145
- "name": "11",
146
- "ppt": {
147
- "height": 720,
148
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/11.png",
149
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/11.slide",
150
- "width": 1280
151
- }
152
- },
153
- {
154
- "name": "12",
155
- "ppt": {
156
- "height": 720,
157
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/12.png",
158
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/12.slide",
159
- "width": 1280
160
- }
161
- },
162
- {
163
- "name": "13",
164
- "ppt": {
165
- "height": 720,
166
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/13.png",
167
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/13.slide",
168
- "width": 1280
169
- }
170
- },
171
- {
172
- "name": "14",
173
- "ppt": {
174
- "height": 720,
175
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/14.png",
176
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/14.slide",
177
- "width": 1280
178
- }
179
- },
180
- {
181
- "name": "15",
182
- "ppt": {
183
- "height": 720,
184
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/15.png",
185
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/15.slide",
186
- "width": 1280
187
- }
188
- },
189
- {
190
- "name": "16",
191
- "ppt": {
192
- "height": 720,
193
- "previewURL": "https://convertcdn.netless.link/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/preview/16.png",
194
- "src": "pptx://cover.herewhite.com/dynamicConvert/6a212c90fa5311ea8b9c074232aaccd4/16.slide",
195
- "width": 1280
196
- }
197
- }
198
- ]
199
- }
200
- })
201
- }
202
- const createVideo = () => {
203
- anyWindow.manager.addApp({
204
- kind: BuiltinApps.MediaPlayer,
205
- attributes: {
206
- src: "https://developer-assets.netless.link/Zelda.mp4"
207
- }
208
- })
209
- }
210
-
211
- let firstPlay = false;
212
-
213
- const replay = () => {
214
- sdk.replayRoom({
215
- room: process.env.ROOM_UUID,
216
- roomToken: process.env.ROOM_TOKEN,
217
- invisiblePlugins: [WindowManager as any],
218
- useMultiViews: true,
219
- }).then(async player => {
220
- await anyWindow.manager.destroy();
221
- anyWindow.room.disconnect();
222
- setTimeout(async () => {
223
- anyWindow.player = player;
224
- // player.bindHtmlElement(document.getElementById("container") as any)
225
- player.play()
226
- }, 500)
227
- player.callbacks.on("onPhaseChanged", phase => {
228
- if (phase === PlayerPhase.Playing) {
229
- if (firstPlay) return;
230
- setTimeout(() => {
231
- mountManager(player, document.getElementById("container"))
232
- }, 1000)
233
- firstPlay = true
234
- }
235
- })
236
- })
237
- }
238
-
239
- const onRef = (ref) => {
240
- sdk.joinRoom({
241
- uuid: process.env.ROOM_UUID,
242
- roomToken: process.env.ROOM_TOKEN,
243
- invisiblePlugins: [WindowManager as any],
244
- useMultiViews: true,
245
- userPayload: {
246
- userId: "111",
247
- cursorName: "测试测试",
248
- avatar: "https://avatars.githubusercontent.com/u/8299540?s=60&v=4",
249
- },
250
- isWritable: !(isWritable === "false"),
251
- cursorAdapter: undefined,
252
- uid: Math.random().toString().substr(3, 8),
253
- disableMagixEventDispatchLimit: true,
254
- }).then(async room => {
255
- if (room.isWritable) {
256
- room.setMemberState({ strokeColor: [0, 0, 1] });
257
- }
258
-
259
- (window as any).room = room;
260
- await mountManager(room, ref);
261
- })
262
- }
263
-
264
- const HelloWorldApp = async () => {
265
- console.log('start loading HelloWorld...')
266
- // await new Promise(resolve => setTimeout(resolve, 2000))
267
- console.log('HelloWorld Loaded')
268
- return {
269
- kind: "HelloWorld",
270
- setup: (context: AppContext<any, any>) => {
271
- console.log('helloworld options', context.getAppOptions());
272
- context.mountView(context.getBox().$content as any);
273
- context.emitter.on("destroy",() => console.log("[HelloWorld]: destroy"))
274
- return "Hello World Result";
275
- }
276
- }
277
- };
278
-
279
- WindowManager.register({
280
- kind: "HelloWorld",
281
- src: HelloWorldApp,
282
- appOptions: () => 'AppOptions',
283
- addHooks: (emitter) => {
284
- emitter.on('created', result => {
285
- console.log('HelloWordResult', result);
286
- })
287
- }
288
- });
289
-
290
- const sdk = new WhiteWebSdk({
291
- appIdentifier: process.env.APPID,
292
- useMobXState: true
293
- });
294
-
295
- (window as any).WindowManager = WindowManager;
296
- const search = window.location.search;
297
- const url = new URLSearchParams(search);
298
- const isWritable = url.get("isWritable");
299
-
300
- const mountManager = async (room, root) => {
301
- const manager = await WindowManager.mount({
302
- room,
303
- container: root,
304
- // collectorStyles: { bottom: "100px", right: "30px" },
305
- containerSizeRatio: 9 / 16,
306
- chessboard: true,
307
- debug: true,
308
- cursor: true,
309
- // disableCameraTransform: true,
310
- });
311
-
312
- (window as any).manager = manager;
313
- (window as any).manager.onAppDestroy(BuiltinApps.DocsViewer, (error) => {
314
- console.log("onAppDestroy", error)
315
- });
316
-
317
- (window as any).manager.emitter.on("mainViewModeChange", mode => {
318
- console.log("mode", mode);
319
- })
320
-
321
- manager.emitter.on("boxStateChange", state => {
322
- console.log("boxState", state);
323
- });
324
- console.log("boxState", manager.boxState);
325
- }
326
- const destroy = () => {
327
- anyWindow.manager.destroy();
328
- anyWindow.manager = undefined;
329
- }
330
-
331
- anyWindow.mountManager = mountManager;
332
- anyWindow.destroy = destroy;
333
-
334
- const App = () => {
335
- return (
336
- <div style={{
337
- display: "flex",
338
- width: "100vw",
339
- height: "100vh",
340
- padding: "16px 16px",
341
- overflow: "hidden",
342
- boxSizing: "border-box"
343
- }}>
344
- <div ref={onRef} id="container" style={{
345
- flex: 1,
346
- height: "calc(100vh - 32px)",
347
- border: "1px solid"
348
- }}>
349
- </div>
350
- <div style={{
351
- flexShrink: 0,
352
- padding: "16px",
353
- marginRight: "16px",
354
- textAlign: "center",
355
- userSelect: "none"
356
- }}>
357
- <button style={{ display: "block", margin: "1em 0" }} onClick={createHelloWorld}>Hello World</button>
358
- <button style={{ display: "block", margin: "1em 0" }} onClick={createDocs1}>课件1</button>
359
- <button style={{ display: "block", margin: "1em 0" }} onClick={createDocs2}>课件2</button>
360
- <button style={{ display: "block", margin: "1em 0" }} onClick={createVideo}>视频</button>
361
- <button style={{ display: "block", margin: "1em 0" }} onClick={replay}>回放</button>
362
- </div>
363
- </div>
364
- )
365
- }
366
-
367
- ReactDom.render(<App />, document.getElementById("root"))
@@ -1,23 +0,0 @@
1
- {
2
- "name": "test",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "dev": "poi index.html --serve --watch"
8
- },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "dependencies": {
13
- "@netless/video-js-plugin": "^0.3.7",
14
- "normalize.css": "^8.0.1",
15
- "p-queue": "^7.1.0",
16
- "react": "^17.0.2",
17
- "react-dom": "^17.0.2",
18
- "video.js": "^7.14.3"
19
- },
20
- "devDependencies": {
21
- "poi": "^12.10.3"
22
- }
23
- }
@@ -1,12 +0,0 @@
1
- // eslint-disable-next-line
2
- const dotenv = require('dotenv').config();
3
-
4
- // eslint-disable-next-line no-undef
5
- module.exports = {
6
- envs: dotenv.parsed,
7
- configureWebpack: {
8
- module: {
9
- unknownContextCritical: false
10
- }
11
- },
12
- }
package/example/test.js DELETED
@@ -1,114 +0,0 @@
1
- export const scenes = [
2
- {
3
- "name": "2d9a8a51-08c1-4949-94f9-7d186d04b3b0",
4
- "ppt": {
5
- "width": 612,
6
- "height": 870,
7
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/1.png"
8
- }
9
- },
10
- {
11
- "name": "50bfa0be-c17b-4b36-87d8-39d406f2ff98",
12
- "ppt": {
13
- "width": 612,
14
- "height": 870,
15
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/2.png"
16
- }
17
- },
18
- {
19
- "name": "4fcc3ac8-d730-43c0-ab8e-7cb633a9a333",
20
- "ppt": {
21
- "width": 612,
22
- "height": 870,
23
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/3.png"
24
- }
25
- },
26
- {
27
- "name": "078be34b-9f0e-42b5-b972-8b0dd1f3bc8d",
28
- "ppt": {
29
- "width": 612,
30
- "height": 870,
31
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/4.png"
32
- }
33
- },
34
- {
35
- "name": "753d4588-0a6b-413b-b6c1-2f6ead5040db",
36
- "ppt": {
37
- "width": 612,
38
- "height": 870,
39
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/5.png"
40
- }
41
- },
42
- {
43
- "name": "855aeadf-2087-4c02-94a9-301e9c032a8f",
44
- "ppt": {
45
- "width": 612,
46
- "height": 870,
47
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/6.png"
48
- }
49
- },
50
- {
51
- "name": "31c45862-a931-4733-86c1-3087a9f0f8d5",
52
- "ppt": {
53
- "width": 612,
54
- "height": 870,
55
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/7.png"
56
- }
57
- },
58
- {
59
- "name": "bf4a0ca3-e4b4-402e-a150-6f6b2ae5b213",
60
- "ppt": {
61
- "width": 612,
62
- "height": 870,
63
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/8.png"
64
- }
65
- },
66
- {
67
- "name": "fdad1852-b143-4f7c-926a-64902cdfc049",
68
- "ppt": {
69
- "width": 612,
70
- "height": 870,
71
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/9.png"
72
- }
73
- },
74
- {
75
- "name": "1290c291-3b10-442f-b03d-8bbd5754b9b5",
76
- "ppt": {
77
- "width": 612,
78
- "height": 870,
79
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/10.png"
80
- }
81
- },
82
- {
83
- "name": "a68cf556-4789-423e-bb93-d86429229043",
84
- "ppt": {
85
- "width": 612,
86
- "height": 870,
87
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/11.png"
88
- }
89
- },
90
- {
91
- "name": "2bda29d6-484a-4ac5-ab53-52006b23ee6c",
92
- "ppt": {
93
- "width": 612,
94
- "height": 870,
95
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/12.png"
96
- }
97
- },
98
- {
99
- "name": "90dd0526-dff9-494d-a2d6-417b64eb605b",
100
- "ppt": {
101
- "width": 612,
102
- "height": 870,
103
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/13.png"
104
- }
105
- },
106
- {
107
- "name": "9fcb4e45-f160-42e6-88c8-1da7ff291b7d",
108
- "ppt": {
109
- "width": 612,
110
- "height": 870,
111
- "src": "https://convertcdn.netless.link/staticConvert/245bab80eeb911ebb78953592d694b06/14.png"
112
- }
113
- }
114
- ]