@netless/fastboard-core 0.3.6 → 1.0.0-canary.2
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/README.md +61 -0
- package/dist/index.d.ts +174 -200
- package/dist/index.js +364 -498
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +344 -440
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -8
- package/src/FastboardApp.ts +631 -0
- package/src/FastboardPlayer.ts +240 -0
- package/src/helpers.ts +57 -0
- package/src/index.ts +11 -3
- package/src/store.ts +83 -0
- package/src/typings.ts +42 -0
- package/src/behaviors/index.ts +0 -62
- package/src/impl/FastboardApp.ts +0 -637
- package/src/impl/FastboardPlayer.ts +0 -251
- package/src/impl/index.ts +0 -2
- package/src/internal.ts +0 -16
- package/src/utils/index.ts +0 -4
- package/src/utils/misc.ts +0 -49
- package/src/utils/store.ts +0 -87
- package/src/utils/uid.ts +0 -12
- package/src/utils/warn.ts +0 -11
package/README.md
CHANGED
|
@@ -4,6 +4,67 @@ A tiny wrapper of white-web-sdk and @netless/window-manager.
|
|
|
4
4
|
|
|
5
5
|
Used by [@netless/fastboard-ui](https://github.com/netless-io/fastboard/tree/main/packages/fastboard-ui).
|
|
6
6
|
|
|
7
|
+
### Usage
|
|
8
|
+
|
|
9
|
+
> **Warning**: This package is not intended to be used directly. You should use @netless/fastboard or @netless/fastboard-react instead.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { FastboardApp } from "@netless/fastboard-core";
|
|
13
|
+
|
|
14
|
+
let sdk = new WhiteWebSdk();
|
|
15
|
+
let room = await sdk.joinRoom({ hotKeys });
|
|
16
|
+
let manager = await WindowManager.mount(room);
|
|
17
|
+
let syncedStore = await SyncedStorePlugin.init(room);
|
|
18
|
+
|
|
19
|
+
let app = new FastboardApp(sdk, room, manager, syncedStore, hotKeys);
|
|
20
|
+
|
|
21
|
+
// reactive values
|
|
22
|
+
app.writable.subscribe(w => console.log(w ? "room is writable" : "room is readonly"));
|
|
23
|
+
|
|
24
|
+
// methods
|
|
25
|
+
await app.insertImage("https://url/to/image.png");
|
|
26
|
+
|
|
27
|
+
// requires @netless/app-slide to be registered
|
|
28
|
+
await app.insertDocs("filename.pptx", conversionResponse);
|
|
29
|
+
|
|
30
|
+
// quit
|
|
31
|
+
await app.destroy();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Advanced Usage
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { addRoomListener } from "@netless/fastboard-core";
|
|
38
|
+
|
|
39
|
+
const stopListen = addRoomListener(room, "onKeyDown", event => {
|
|
40
|
+
console.log("keydown", event.key);
|
|
41
|
+
stopListen();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
import { createVal } from "@netless/fastboard-core";
|
|
45
|
+
|
|
46
|
+
const writable = createVal(
|
|
47
|
+
// initial value
|
|
48
|
+
room.isWritable,
|
|
49
|
+
// setup listener, returns a cleanup function to stop listening
|
|
50
|
+
set => addRoomListener(room, "onEnableWriteNowChanged", () => set(room.isWritable)),
|
|
51
|
+
// optional setter
|
|
52
|
+
newValue => room.setWritable(newValue)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
writable.value; // true
|
|
56
|
+
writable.subscribe(w => console.log(w ? "room is writable" : "room is readonly"));
|
|
57
|
+
// change the value and invoke subs,
|
|
58
|
+
// if provided setter, this function will not change inner value directly, instead it calls the setter
|
|
59
|
+
writable.set(true);
|
|
60
|
+
writable.dispose(); // stop listening
|
|
61
|
+
|
|
62
|
+
// hacking, should not be used
|
|
63
|
+
writable.subs.forEach(f => f(writable.value)); // subs: Set<Subscriber>
|
|
64
|
+
writable.subs.clear(); // remove all subs
|
|
65
|
+
writable.value = false; // no trigger subs, but did change value
|
|
66
|
+
```
|
|
67
|
+
|
|
7
68
|
### License
|
|
8
69
|
|
|
9
70
|
MIT @ [netless](https://github.com/netless-io)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,107 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { AnimationMode, ApplianceNames, Camera, Color, ConversionResponse, HotKey, HotKeys, JoinRoomParams, MemberState, PlayerSeekingResult, Rectangle, Room, RoomCallbacks, RoomState, SceneDefinition, ShapeType, ViewCallbacks, WhiteWebSdk, WhiteWebSdkConfiguration } from 'white-web-sdk';
|
|
3
|
-
import {
|
|
1
|
+
import { ApplianceNames, RoomCallbacks, Room, PlayerCallbacks, Player, ViewCallbacks, View, JoinRoomParams, ReplayRoomParams, WhiteWebSdk, HotKeys, RoomPhase, MemberState, CameraState, Camera, AnimationMode, ShapeType, Color, ConversionResponse, SceneDefinition, WhiteWebSdkConfiguration, PlayerPhase, PlayerState, PlayerSeekingResult } from 'white-web-sdk';
|
|
2
|
+
export { AnimationMode, ApplianceNames, Camera, CameraState, Color, ConversionResponse, ConvertedFile, HotKey, HotKeys, JoinRoomParams, MemberState, Player, PlayerCallbacks, PlayerPhase, PlayerSeekingResult, PlayerState, Rectangle, ReplayRoomParams, Room, RoomCallbacks, RoomPhase, RoomState, SceneDefinition, ShapeType, View, ViewCallbacks, WhiteWebSdk, WhiteWebSdkConfiguration } from 'white-web-sdk';
|
|
3
|
+
import { PublicEvent, WindowManager, AddPageParams, MountParams, NetlessApp } from '@netless/window-manager';
|
|
4
4
|
export { AddPageParams, MountParams, NetlessApp, PublicEvent, WindowManager } from '@netless/window-manager';
|
|
5
5
|
import { SyncedStore } from '@netless/synced-store';
|
|
6
6
|
export { Diff, DiffOne, Storage, SyncedStore } from '@netless/synced-store';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
declare type Appliance = `${ApplianceNames}`;
|
|
9
|
+
|
|
10
|
+
declare function addRoomListener<K extends keyof RoomCallbacks>(room: Room, name: K, listener: RoomCallbacks[K]): () => void;
|
|
11
|
+
declare function addPlayerListener<K extends keyof PlayerCallbacks>(player: Player, name: K, listener: PlayerCallbacks[K]): () => void;
|
|
12
|
+
declare function addViewListener<K extends keyof ViewCallbacks>(view: View, name: K, listener: (value: ViewCallbacks[K]) => void): () => void;
|
|
13
|
+
declare function addManagerListener<K extends keyof PublicEvent>(manager: WindowManager, name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
14
|
+
declare function ensureOfficialPlugins<T extends JoinRoomParams | ReplayRoomParams>(joinRoom: T): T;
|
|
8
15
|
|
|
9
16
|
declare type Subscriber<T> = (value: T) => void;
|
|
10
|
-
declare type Unsubscriber = () => void;
|
|
11
17
|
declare type Updater<T> = (value: T) => T;
|
|
12
|
-
declare type
|
|
18
|
+
declare type Disposer = () => void;
|
|
19
|
+
declare type StartStopNotifier<T> = (set: Subscriber<T>) => Disposer | void;
|
|
13
20
|
interface Readable<T> {
|
|
14
21
|
readonly value: T;
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
readonly subs: Set<Subscriber<T>>;
|
|
23
|
+
subscribe(this: Readable<T>, run: Subscriber<T>): Disposer;
|
|
24
|
+
reaction(this: Readable<T>, run: Subscriber<T>): Disposer;
|
|
25
|
+
dispose(this: Readable<T>): void;
|
|
17
26
|
}
|
|
18
27
|
interface Writable<T> extends Readable<T> {
|
|
19
|
-
set(this:
|
|
20
|
-
update(this:
|
|
28
|
+
set(this: Writable<T>, value: T): void;
|
|
29
|
+
update(this: Writable<T>, updater: Updater<T>): void;
|
|
21
30
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
declare const warnings: {
|
|
36
|
-
readonly "no-ppt-in-scenes": "You're probably inserting the slide app in a wrong way, there shouldn't exist `scenes[0].ppt`.";
|
|
37
|
-
};
|
|
38
|
-
declare function warn(id: keyof typeof warnings): void;
|
|
31
|
+
/**
|
|
32
|
+
* ```js
|
|
33
|
+
* const mediaQuery = matchMedia("(prefers-color-scheme: dark)")
|
|
34
|
+
* const isDark = createVal(mediaQuery.matches, set => {
|
|
35
|
+
* const update = () => set(mediaQuery.matches)
|
|
36
|
+
* mediaQuery.addEventListener("change", update)
|
|
37
|
+
* return () => mediaQuery.removeEventListener("change", update)
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function createVal<T>(init: T, start: StartStopNotifier<T>): Readable<T>;
|
|
42
|
+
declare function createVal<T>(init: T, start: StartStopNotifier<T>, setter: (value: T) => void): Writable<T>;
|
|
39
43
|
|
|
40
|
-
declare class
|
|
44
|
+
declare class FastboardAppStruct<TEventData> {
|
|
41
45
|
readonly sdk: WhiteWebSdk;
|
|
42
46
|
readonly room: Room;
|
|
43
47
|
readonly manager: WindowManager;
|
|
44
|
-
readonly hotKeys: Partial<HotKeys>;
|
|
45
48
|
readonly syncedStore: SyncedStore<TEventData>;
|
|
46
|
-
|
|
49
|
+
readonly hotKeys: Partial<HotKeys>;
|
|
50
|
+
protected _disposers: Disposer[];
|
|
47
51
|
protected _destroyed: boolean;
|
|
48
52
|
protected _assertNotDestroyed(): void;
|
|
49
|
-
protected
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
protected _flushAllDisposers(): void;
|
|
54
|
+
constructor(sdk: WhiteWebSdk, room: Room, manager: WindowManager, syncedStore: SyncedStore<TEventData>, hotKeys: Partial<HotKeys>);
|
|
55
|
+
}
|
|
56
|
+
declare class FastboardApp<TEventData = any> extends FastboardAppStruct<TEventData> {
|
|
57
|
+
constructor(sdk: WhiteWebSdk, room: Room, manager: WindowManager, syncedStore: SyncedStore<TEventData>, hotKeys: Partial<HotKeys>);
|
|
52
58
|
/**
|
|
53
|
-
*
|
|
59
|
+
* Disconnect from whiteboard room.
|
|
54
60
|
*/
|
|
55
61
|
destroy(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
declare type RoomPhase = `${RoomPhase$1}`;
|
|
58
|
-
|
|
59
|
-
/** pencil, eraser, rectangle... */
|
|
60
|
-
declare type Appliance = `${ApplianceNames}`;
|
|
61
|
-
/** triangle, star... */
|
|
62
|
-
declare type Shape = `${ShapeType}`;
|
|
63
|
-
/** Params for static docs, they are rendered as many images. */
|
|
64
|
-
interface InsertDocsStatic {
|
|
65
|
-
readonly fileType: "pdf";
|
|
66
|
-
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
67
|
-
readonly scenePath: string;
|
|
68
|
-
/** @example [{ name: '1', ppt: { src: 'url/to/ppt/1.png' } }] */
|
|
69
|
-
readonly scenes: SceneDefinition[];
|
|
70
|
-
/** Window title. */
|
|
71
|
-
readonly title?: string;
|
|
72
|
-
}
|
|
73
|
-
/** Params for slides, they are rendered in @netless/app-slide with animations. */
|
|
74
|
-
interface InsertDocsDynamic {
|
|
75
|
-
readonly fileType: "pptx";
|
|
76
|
-
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
77
|
-
readonly scenePath: string;
|
|
78
|
-
/** Conversion task id, see https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress. */
|
|
79
|
-
readonly taskId: string;
|
|
80
|
-
/** Window title. */
|
|
81
|
-
readonly title?: string;
|
|
82
|
-
/** Where the slide resource placed. @default `https://convertcdn.netless.link/dynamicConvert` */
|
|
83
|
-
readonly url?: string;
|
|
84
|
-
/** @example [{ name: '1' }, { name: '2' }, { name: '3' }] */
|
|
85
|
-
readonly scenes?: SceneDefinition[];
|
|
86
|
-
}
|
|
87
|
-
declare type InsertDocsParams = InsertDocsStatic | InsertDocsDynamic;
|
|
88
|
-
declare type SetMemberStateFn = (partialMemberState: Partial<MemberState>) => void;
|
|
89
|
-
declare type RoomStateChanged = (diff: Partial<RoomState>) => void;
|
|
90
|
-
/** App download progress. */
|
|
91
|
-
interface AppsStatus {
|
|
92
|
-
[kind: string]: {
|
|
93
|
-
status: "idle" | "loading" | "failed";
|
|
94
|
-
/** Exist if status is `failed`. */
|
|
95
|
-
reason?: string;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData> {
|
|
99
62
|
/**
|
|
100
63
|
* Render this app to some DOM.
|
|
101
64
|
*/
|
|
102
65
|
bindContainer(container: HTMLElement): void;
|
|
103
66
|
/**
|
|
104
|
-
* Move window
|
|
67
|
+
* Move window manager's collector to some place.
|
|
105
68
|
*/
|
|
106
69
|
bindCollector(container: HTMLElement): void;
|
|
107
70
|
/**
|
|
@@ -111,14 +74,19 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
111
74
|
/**
|
|
112
75
|
* Is current room online?
|
|
113
76
|
*/
|
|
114
|
-
readonly phase: Readable<
|
|
77
|
+
readonly phase: Readable<RoomPhase>;
|
|
78
|
+
/**
|
|
79
|
+
* Current user's state, including 'strokeColor', etc.
|
|
80
|
+
*
|
|
81
|
+
* To change the tool, use `app.setAppliance('pencil')`.
|
|
82
|
+
*/
|
|
83
|
+
readonly memberState: Readable<MemberState>;
|
|
115
84
|
/**
|
|
116
|
-
*
|
|
85
|
+
* Window manager's windows' state (is it maximized).
|
|
117
86
|
*/
|
|
118
|
-
readonly boxState: Readable<"
|
|
87
|
+
readonly boxState: Readable<"normal" | "minimized" | "maximized" | undefined>;
|
|
119
88
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @example "HelloWorld-1A2b3C4d"
|
|
89
|
+
* Window manager's focused (at the top) app's id, like `HelloWorld-1A2b3C4d`.
|
|
122
90
|
*/
|
|
123
91
|
readonly focusedApp: Readable<string | undefined>;
|
|
124
92
|
/**
|
|
@@ -130,28 +98,30 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
130
98
|
*/
|
|
131
99
|
readonly canUndoSteps: Readable<number>;
|
|
132
100
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* Change the camera position by `app.moveCamera()`.
|
|
101
|
+
* The synced camera state across all users.
|
|
136
102
|
*/
|
|
137
|
-
readonly
|
|
103
|
+
readonly baseCamera: Readable<{
|
|
104
|
+
id: string;
|
|
105
|
+
centerX: number | null;
|
|
106
|
+
centerY: number | null;
|
|
107
|
+
scale: number;
|
|
108
|
+
} | undefined>;
|
|
138
109
|
/**
|
|
139
|
-
*
|
|
110
|
+
* The local camera state of main view in window manager.
|
|
140
111
|
*
|
|
141
|
-
* Change the
|
|
112
|
+
* Change the camera position by `app.moveCamera()`.
|
|
142
113
|
*/
|
|
143
|
-
readonly
|
|
114
|
+
readonly camera: Readable<CameraState>;
|
|
144
115
|
/**
|
|
145
|
-
* 0..n-1, current index of
|
|
116
|
+
* 0..n-1, current index of pages.
|
|
146
117
|
*/
|
|
147
|
-
readonly
|
|
118
|
+
readonly pageIndex: Writable<number>;
|
|
148
119
|
/**
|
|
149
|
-
* How many pages are in the main view?
|
|
120
|
+
* How many pages are there in the main view?
|
|
150
121
|
*/
|
|
151
|
-
readonly
|
|
152
|
-
private _appsStatus;
|
|
122
|
+
readonly pageLength: Readable<number>;
|
|
153
123
|
/**
|
|
154
|
-
* Apps status.
|
|
124
|
+
* Apps loading status.
|
|
155
125
|
*/
|
|
156
126
|
readonly appsStatus: Readable<AppsStatus>;
|
|
157
127
|
/**
|
|
@@ -163,15 +133,9 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
163
133
|
*/
|
|
164
134
|
redo(): void;
|
|
165
135
|
/**
|
|
166
|
-
* Move
|
|
136
|
+
* Move main view's camera.
|
|
167
137
|
*/
|
|
168
138
|
moveCamera(camera: Partial<Camera> & {
|
|
169
|
-
animationMode?: AnimationMode | undefined;
|
|
170
|
-
}): void;
|
|
171
|
-
/**
|
|
172
|
-
* Move current main view's camera to include a rectangle.
|
|
173
|
-
*/
|
|
174
|
-
moveCameraToContain(rectangle: Rectangle & {
|
|
175
139
|
animationMode?: AnimationMode;
|
|
176
140
|
}): void;
|
|
177
141
|
/**
|
|
@@ -179,65 +143,67 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
179
143
|
*/
|
|
180
144
|
cleanCurrentScene(): void;
|
|
181
145
|
/**
|
|
182
|
-
* Set current tool, like
|
|
146
|
+
* Set current tool, like `pencil`.
|
|
183
147
|
*/
|
|
184
|
-
setAppliance(appliance: ApplianceNames |
|
|
148
|
+
setAppliance(appliance: ApplianceNames | `${ApplianceNames}`, shape?: ShapeType | `${ShapeType}`): void;
|
|
185
149
|
/**
|
|
186
150
|
* Set pencil and shape's thickness.
|
|
187
151
|
*/
|
|
188
|
-
setStrokeWidth(
|
|
152
|
+
setStrokeWidth(width: number): void;
|
|
189
153
|
/**
|
|
190
154
|
* Set pencil and shape's color.
|
|
191
155
|
*/
|
|
192
|
-
setStrokeColor(
|
|
156
|
+
setStrokeColor(color: Color): void;
|
|
193
157
|
/**
|
|
194
158
|
* Set text size. Default is 16.
|
|
195
159
|
*/
|
|
196
|
-
setTextSize(
|
|
160
|
+
setTextSize(size: number): void;
|
|
197
161
|
/**
|
|
198
162
|
* Set text color.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* setTextColor([0x66, 0xcc, 0xff])
|
|
202
163
|
*/
|
|
203
|
-
setTextColor(
|
|
164
|
+
setTextColor(color: Color): void;
|
|
165
|
+
/**
|
|
166
|
+
* Toggle dotted line effect on pencil.
|
|
167
|
+
*/
|
|
168
|
+
toggleDottedLine(force?: boolean): void;
|
|
204
169
|
/**
|
|
205
|
-
* Goto previous page
|
|
170
|
+
* Goto previous page, returns true if success.
|
|
206
171
|
*/
|
|
207
172
|
prevPage(): Promise<boolean>;
|
|
208
173
|
/**
|
|
209
|
-
* Goto next page
|
|
174
|
+
* Goto next page, returns true if success.
|
|
210
175
|
*/
|
|
211
176
|
nextPage(): Promise<boolean>;
|
|
212
177
|
/**
|
|
213
178
|
* Add one page to the main whiteboard view.
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
179
|
+
* ```js
|
|
180
|
+
* app.addPage({ after: true }) // add one page right after current page
|
|
181
|
+
* app.nextPage() // then, goto that page
|
|
182
|
+
* ```
|
|
218
183
|
*/
|
|
219
184
|
addPage(params?: AddPageParams): Promise<void>;
|
|
220
185
|
/**
|
|
221
186
|
* Remove one page at given index or current page (by default).
|
|
222
|
-
*
|
|
223
|
-
* Requires `@netless/window-manager` >= 0.4.30.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* removePage() // remove current page
|
|
227
187
|
*/
|
|
228
188
|
removePage(index?: number): Promise<boolean>;
|
|
229
189
|
/**
|
|
230
190
|
* Insert an image to the main view.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* insertImage("https://i.imgur.com/CzXTtJV.jpg")
|
|
234
191
|
*/
|
|
235
|
-
insertImage(url: string): Promise<void>;
|
|
192
|
+
insertImage(url: string, options?: InsertImageOptions): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Insert the Media Player app.
|
|
195
|
+
*/
|
|
196
|
+
insertMedia(title: string, src: string): Promise<string | undefined>;
|
|
236
197
|
/**
|
|
237
198
|
* Insert PDF/PPTX from conversion result.
|
|
238
199
|
* @param status https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress
|
|
239
200
|
*/
|
|
240
201
|
insertDocs(filename: string, status: ConversionResponse): Promise<string | undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* Insert PDF/PPTX from projector conversion result.
|
|
204
|
+
* @param response https://developer.netless.link/server-zh/home/server-projector#get-%E6%9F%A5%E8%AF%A2%E4%BB%BB%E5%8A%A1%E8%BD%AC%E6%8D%A2%E8%BF%9B%E5%BA%A6
|
|
205
|
+
*/
|
|
206
|
+
insertDocs(filename: string, response: ProjectorResponse): Promise<string | undefined>;
|
|
241
207
|
/**
|
|
242
208
|
* Manual way.
|
|
243
209
|
* @example
|
|
@@ -249,26 +215,68 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
249
215
|
* })
|
|
250
216
|
*/
|
|
251
217
|
insertDocs(params: InsertDocsParams): Promise<string | undefined>;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
218
|
+
}
|
|
219
|
+
interface AppsStatus {
|
|
220
|
+
[kind: string]: {
|
|
221
|
+
status: "idle" | "loading" | "failed";
|
|
222
|
+
/** Exist if status is `failed` */
|
|
223
|
+
reason?: string;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
interface InsertImageOptions {
|
|
227
|
+
/** Image width, in pixel */
|
|
228
|
+
width?: number;
|
|
229
|
+
/** Image height, in pixel */
|
|
230
|
+
height?: number;
|
|
231
|
+
/** Image position, in pixel, default as 0 */
|
|
232
|
+
centerX?: number;
|
|
233
|
+
/** Image position, in pixel, default as 0 */
|
|
234
|
+
centerY?: number;
|
|
235
|
+
/** Whether to disable moving, default is false */
|
|
236
|
+
locked?: boolean;
|
|
237
|
+
/** Whether to keep ratio */
|
|
238
|
+
uniformScale?: boolean;
|
|
239
|
+
}
|
|
240
|
+
/** Params for static docs, they are rendered as many images. */
|
|
241
|
+
interface InsertDocsStatic {
|
|
242
|
+
readonly fileType: "pdf";
|
|
243
|
+
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
244
|
+
readonly scenePath: string;
|
|
245
|
+
/** @example [{ name: '1', ppt: { src: 'url/to/ppt/1.png' } }] */
|
|
246
|
+
readonly scenes: SceneDefinition[];
|
|
247
|
+
/** Window title. */
|
|
248
|
+
readonly title?: string;
|
|
249
|
+
}
|
|
250
|
+
/** Params for slides, they are rendered in @netless/app-slide with animations. */
|
|
251
|
+
interface InsertDocsDynamic {
|
|
252
|
+
readonly fileType: "pptx";
|
|
253
|
+
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
254
|
+
readonly scenePath: string;
|
|
255
|
+
/** Conversion task id, see https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress. */
|
|
256
|
+
readonly taskId: string;
|
|
257
|
+
/** Window title. */
|
|
258
|
+
readonly title?: string;
|
|
259
|
+
/** Where the slide resource placed. @default `https://convertcdn.netless.link/dynamicConvert` */
|
|
260
|
+
readonly url?: string;
|
|
261
|
+
/** @example [{ name: '1' }, { name: '2' }, { name: '3' }] */
|
|
262
|
+
readonly scenes?: SceneDefinition[];
|
|
263
|
+
}
|
|
264
|
+
declare type InsertDocsParams = InsertDocsStatic | InsertDocsDynamic;
|
|
265
|
+
interface ProjectorResponse {
|
|
266
|
+
uuid: string;
|
|
267
|
+
status: "Waiting" | "Converting" | "Finished" | "Fail";
|
|
268
|
+
/** 0..100 */
|
|
269
|
+
convertedPercentage: number;
|
|
270
|
+
/** https://example.org/path/to/dynamicConvert */
|
|
271
|
+
prefix: string;
|
|
272
|
+
pageCount: number;
|
|
273
|
+
/** {1:"{prefix}/{taskId}/preview/1.png"} */
|
|
274
|
+
previews: Record<number, string>;
|
|
275
|
+
/** {prefix}/{taskId}/jsonOutput/note.json */
|
|
276
|
+
note: string;
|
|
277
|
+
/** 20xxxxx */
|
|
278
|
+
errorCode: `${number}`;
|
|
279
|
+
errorMessage: string;
|
|
272
280
|
}
|
|
273
281
|
interface FastboardOptions {
|
|
274
282
|
sdkConfig: Omit<WhiteWebSdkConfiguration, "useMobXState"> & {
|
|
@@ -280,45 +288,31 @@ interface FastboardOptions {
|
|
|
280
288
|
managerConfig?: Omit<MountParams, "room">;
|
|
281
289
|
netlessApps?: NetlessApp[];
|
|
282
290
|
}
|
|
283
|
-
|
|
284
|
-
* Create a FastboardApp instance.
|
|
285
|
-
* @example
|
|
286
|
-
* let app = await createFastboard({
|
|
287
|
-
* sdkConfig: {
|
|
288
|
-
* appIdentifier: import.meta.env.VITE_APPID,
|
|
289
|
-
* region: 'cn-hz',
|
|
290
|
-
* },
|
|
291
|
-
* joinRoom: {
|
|
292
|
-
* uid: unique_id,
|
|
293
|
-
* uuid: import.meta.env.VITE_ROOM_UUID,
|
|
294
|
-
* roomToken: import.meta.env.VITE_ROOM_TOKEN,
|
|
295
|
-
* },
|
|
296
|
-
* })
|
|
297
|
-
*/
|
|
298
|
-
declare function createFastboard<TEventData = any>({ sdkConfig, joinRoom: { callbacks, ...joinRoomParams }, managerConfig, netlessApps, }: FastboardOptions): Promise<FastboardApp<TEventData>>;
|
|
291
|
+
declare function createFastboardCore<TEventData = any>({ sdkConfig, joinRoom: { callbacks, ...joinRoomParams }, managerConfig, netlessApps, }: FastboardOptions): Promise<FastboardApp<TEventData>>;
|
|
299
292
|
|
|
300
|
-
declare class
|
|
293
|
+
declare class FastboardPlayerStruct<TEventData> {
|
|
301
294
|
readonly sdk: WhiteWebSdk;
|
|
302
295
|
readonly player: Player;
|
|
303
296
|
readonly manager: WindowManager;
|
|
304
297
|
readonly syncedStore: SyncedStore<TEventData>;
|
|
305
|
-
|
|
298
|
+
protected _disposers: Disposer[];
|
|
306
299
|
protected _destroyed: boolean;
|
|
307
300
|
protected _assertNotDestroyed(): void;
|
|
308
|
-
protected
|
|
309
|
-
|
|
310
|
-
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
311
|
-
destroy(): void;
|
|
301
|
+
protected _flushAllDisposers(): void;
|
|
302
|
+
constructor(sdk: WhiteWebSdk, player: Player, manager: WindowManager, syncedStore: SyncedStore<TEventData>);
|
|
312
303
|
}
|
|
313
|
-
declare
|
|
314
|
-
|
|
315
|
-
|
|
304
|
+
declare class FastboardPlayer<TEventData = any> extends FastboardPlayerStruct<TEventData> {
|
|
305
|
+
constructor(sdk: WhiteWebSdk, player: Player, manager: WindowManager, syncedStore: SyncedStore<TEventData>);
|
|
306
|
+
/**
|
|
307
|
+
* Disconnect from whiteboard room.
|
|
308
|
+
*/
|
|
309
|
+
destroy(): void;
|
|
316
310
|
/**
|
|
317
|
-
* Render this
|
|
311
|
+
* Render this app to some DOM.
|
|
318
312
|
*/
|
|
319
313
|
bindContainer(container: HTMLElement): void;
|
|
320
314
|
/**
|
|
321
|
-
* Move window
|
|
315
|
+
* Move window manager's collector to some place.
|
|
322
316
|
*/
|
|
323
317
|
bindCollector(container: HTMLElement): void;
|
|
324
318
|
/**
|
|
@@ -328,12 +322,11 @@ declare class FastboardPlayer<TEventData = any> extends FastboardPlayerBase<TEve
|
|
|
328
322
|
/**
|
|
329
323
|
* Player state, like "is it playing?".
|
|
330
324
|
*/
|
|
331
|
-
readonly phase: Readable<
|
|
325
|
+
readonly phase: Readable<PlayerPhase>;
|
|
332
326
|
/**
|
|
333
327
|
* Will become true after buffering.
|
|
334
328
|
*/
|
|
335
329
|
readonly canplay: Readable<boolean>;
|
|
336
|
-
private _setPlaybackRate;
|
|
337
330
|
/**
|
|
338
331
|
* Playback speed, default `1`.
|
|
339
332
|
*/
|
|
@@ -343,7 +336,7 @@ declare class FastboardPlayer<TEventData = any> extends FastboardPlayerBase<TEve
|
|
|
343
336
|
*/
|
|
344
337
|
readonly duration: Readable<number>;
|
|
345
338
|
/**
|
|
346
|
-
* Get state of room at
|
|
339
|
+
* Get state of room at current time.
|
|
347
340
|
*/
|
|
348
341
|
readonly state: Readable<PlayerState>;
|
|
349
342
|
/**
|
|
@@ -363,7 +356,7 @@ declare class FastboardPlayer<TEventData = any> extends FastboardPlayerBase<TEve
|
|
|
363
356
|
*/
|
|
364
357
|
stop(): void;
|
|
365
358
|
/**
|
|
366
|
-
* Set playback speed,
|
|
359
|
+
* Set playback speed, the same as `player.playbackRate.set(x)`.
|
|
367
360
|
*/
|
|
368
361
|
setPlaybackRate(value: number): void;
|
|
369
362
|
}
|
|
@@ -377,28 +370,9 @@ interface FastboardReplayOptions {
|
|
|
377
370
|
managerConfig?: Omit<MountParams, "room">;
|
|
378
371
|
netlessApps?: NetlessApp[];
|
|
379
372
|
}
|
|
380
|
-
|
|
381
|
-
* Create a FastboardPlayer instance.
|
|
382
|
-
* @example
|
|
383
|
-
* let player = await replayFastboard({
|
|
384
|
-
* sdkConfig: {
|
|
385
|
-
* appIdentifier: import.meta.env.VITE_APPID,
|
|
386
|
-
* region: 'cn-hz',
|
|
387
|
-
* },
|
|
388
|
-
* replayRoom: {
|
|
389
|
-
* room: "room uuid",
|
|
390
|
-
* roomToken: "NETLESSROOM_...",
|
|
391
|
-
* beginTimestamp: 1646619090394,
|
|
392
|
-
* duration: 70448,
|
|
393
|
-
* },
|
|
394
|
-
* })
|
|
395
|
-
*/
|
|
396
|
-
declare function replayFastboard<TEventData = any>({ sdkConfig, replayRoom: { callbacks, ...replayRoomParams }, managerConfig, netlessApps, }: FastboardReplayOptions): Promise<FastboardPlayer<TEventData>>;
|
|
373
|
+
declare function replayFastboardCore<TEventData = any>({ sdkConfig, replayRoom: { callbacks, ...replayRoomParams }, managerConfig, netlessApps, }: FastboardReplayOptions): Promise<FastboardPlayer<TEventData>>;
|
|
397
374
|
|
|
398
|
-
|
|
399
|
-
[kind: string]: Omit<RegisterParams, "kind">;
|
|
400
|
-
}
|
|
401
|
-
declare const register: typeof WindowManager.register;
|
|
375
|
+
declare const name: string;
|
|
402
376
|
declare const version: string;
|
|
403
377
|
|
|
404
|
-
export { Appliance,
|
|
378
|
+
export { Appliance, AppsStatus, Disposer, FastboardApp, FastboardOptions, FastboardPlayer, FastboardReplayOptions, InsertDocsDynamic, InsertDocsParams, InsertDocsStatic, InsertImageOptions, ProjectorResponse, Readable, StartStopNotifier, Subscriber, Updater, Writable, addManagerListener, addPlayerListener, addRoomListener, addViewListener, createFastboardCore, createVal, ensureOfficialPlugins, name, replayFastboardCore, version };
|