@netless/fastboard-core 0.3.4-canary.0 → 0.3.4
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/index.d.ts +399 -0
- package/dist/index.js +678 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +627 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +2 -2
- package/src/impl/FastboardApp.ts +24 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { Size, SceneDefinition, ConvertedFile, RoomPhase as RoomPhase$1, ApplianceNames, ShapeType, MemberState, RoomState, Camera, AnimationMode, Rectangle, Color, ConversionResponse, WhiteWebSdkConfiguration, JoinRoomParams, RoomCallbacks, WhiteWebSdk, Room, HotKeys, ViewCallbacks, PlayerPhase as PlayerPhase$1, PlayerState, PlayerSeekingResult, ReplayRoomParams, PlayerCallbacks, Player } from 'white-web-sdk';
|
|
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 { AddPageParams, MountParams, NetlessApp, WindowManager, PublicEvent, RegisterParams } from '@netless/window-manager';
|
|
4
|
+
export { AddPageParams, MountParams, NetlessApp, PublicEvent, WindowManager } from '@netless/window-manager';
|
|
5
|
+
export { PreviewParams, default as SlideApp, Controller as SlideController, AppOptions as SlideOptions, SlidePreviewer, addHooks as addSlideHooks, previewSlide, apps as slideApps } from '@netless/app-slide';
|
|
6
|
+
|
|
7
|
+
declare type Subscriber<T> = (value: T) => void;
|
|
8
|
+
declare type Unsubscriber = () => void;
|
|
9
|
+
declare type Updater<T> = (value: T) => T;
|
|
10
|
+
declare type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
|
|
11
|
+
interface Readable<T> {
|
|
12
|
+
readonly value: T;
|
|
13
|
+
subscribe(this: void, run: Subscriber<T>): Unsubscriber;
|
|
14
|
+
reaction(this: void, run: Subscriber<T>): Unsubscriber;
|
|
15
|
+
}
|
|
16
|
+
interface Writable<T> extends Readable<T> {
|
|
17
|
+
set(this: void, value: T): void;
|
|
18
|
+
update(this: void, updater: Updater<T>): void;
|
|
19
|
+
}
|
|
20
|
+
declare function readable<T>(value: T, start?: StartStopNotifier<T>): Readable<T>;
|
|
21
|
+
declare function writable<T>(value: T, start: StartStopNotifier<T> | undefined, set: Subscriber<T>): Writable<T>;
|
|
22
|
+
|
|
23
|
+
declare function getImageSize(url: string, fallback: Size): Promise<Size>;
|
|
24
|
+
declare function makeSlideParams(scenes: SceneDefinition[]): {
|
|
25
|
+
scenes: SceneDefinition[];
|
|
26
|
+
taskId: string;
|
|
27
|
+
url: string;
|
|
28
|
+
};
|
|
29
|
+
declare function convertedFileToScene(f: ConvertedFile, i: number): SceneDefinition;
|
|
30
|
+
|
|
31
|
+
declare function genUID(): string;
|
|
32
|
+
|
|
33
|
+
declare const warnings: {
|
|
34
|
+
readonly "no-ppt-in-scenes": "You're probably inserting the slide app in a wrong way, there shouldn't exist `scenes[0].ppt`.";
|
|
35
|
+
};
|
|
36
|
+
declare function warn(id: keyof typeof warnings): void;
|
|
37
|
+
|
|
38
|
+
declare class FastboardAppBase {
|
|
39
|
+
readonly sdk: WhiteWebSdk;
|
|
40
|
+
readonly room: Room;
|
|
41
|
+
readonly manager: WindowManager;
|
|
42
|
+
readonly hotKeys: Partial<HotKeys>;
|
|
43
|
+
constructor(sdk: WhiteWebSdk, room: Room, manager: WindowManager, hotKeys: Partial<HotKeys>);
|
|
44
|
+
protected _destroyed: boolean;
|
|
45
|
+
protected _assertNotDestroyed(): void;
|
|
46
|
+
protected _addRoomListener<K extends keyof RoomCallbacks>(name: K, listener: RoomCallbacks[K]): () => void;
|
|
47
|
+
protected _addManagerListener<K extends keyof PublicEvent>(name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
48
|
+
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Destroy fastboard (disconnect from the whiteboard room).
|
|
51
|
+
*/
|
|
52
|
+
destroy(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
declare type RoomPhase = `${RoomPhase$1}`;
|
|
55
|
+
|
|
56
|
+
/** pencil, eraser, rectangle... */
|
|
57
|
+
declare type Appliance = `${ApplianceNames}`;
|
|
58
|
+
/** triangle, star... */
|
|
59
|
+
declare type Shape = `${ShapeType}`;
|
|
60
|
+
/** Params for static docs, they are rendered as many images. */
|
|
61
|
+
interface InsertDocsStatic {
|
|
62
|
+
readonly fileType: "pdf";
|
|
63
|
+
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
64
|
+
readonly scenePath: string;
|
|
65
|
+
/** @example [{ name: '1', ppt: { src: 'url/to/ppt/1.png' } }] */
|
|
66
|
+
readonly scenes: SceneDefinition[];
|
|
67
|
+
/** Window title. */
|
|
68
|
+
readonly title?: string;
|
|
69
|
+
}
|
|
70
|
+
/** Params for slides, they are rendered in @netless/app-slide with animations. */
|
|
71
|
+
interface InsertDocsDynamic {
|
|
72
|
+
readonly fileType: "pptx";
|
|
73
|
+
/** Unique string for binding whiteboard view to the doc. Must start with `/`. */
|
|
74
|
+
readonly scenePath: string;
|
|
75
|
+
/** Conversion task id, see https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress. */
|
|
76
|
+
readonly taskId: string;
|
|
77
|
+
/** Window title. */
|
|
78
|
+
readonly title?: string;
|
|
79
|
+
/** Where the slide resource placed. @default `https://convertcdn.netless.link/dynamicConvert` */
|
|
80
|
+
readonly url?: string;
|
|
81
|
+
/** @example [{ name: '1' }, { name: '2' }, { name: '3' }] */
|
|
82
|
+
readonly scenes?: SceneDefinition[];
|
|
83
|
+
}
|
|
84
|
+
declare type InsertDocsParams = InsertDocsStatic | InsertDocsDynamic;
|
|
85
|
+
declare type SetMemberStateFn = (partialMemberState: Partial<MemberState>) => void;
|
|
86
|
+
declare type RoomStateChanged = (diff: Partial<RoomState>) => void;
|
|
87
|
+
/** App download progress. */
|
|
88
|
+
interface AppsStatus {
|
|
89
|
+
[kind: string]: {
|
|
90
|
+
status: "idle" | "loading" | "failed";
|
|
91
|
+
/** Exist if status is `failed`. */
|
|
92
|
+
reason?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
declare class FastboardApp extends FastboardAppBase {
|
|
96
|
+
/**
|
|
97
|
+
* Render this app to some DOM.
|
|
98
|
+
*/
|
|
99
|
+
bindContainer(container: HTMLElement): void;
|
|
100
|
+
/**
|
|
101
|
+
* Move window-manager's collector to some place.
|
|
102
|
+
*/
|
|
103
|
+
bindCollector(container: HTMLElement): void;
|
|
104
|
+
/**
|
|
105
|
+
* Is current room writable?
|
|
106
|
+
*/
|
|
107
|
+
readonly writable: Writable<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Is current room online?
|
|
110
|
+
*/
|
|
111
|
+
readonly phase: Readable<"connecting" | "connected" | "reconnecting" | "disconnecting" | "disconnected">;
|
|
112
|
+
/**
|
|
113
|
+
* Current window-manager's windows' state (is it maximized?).
|
|
114
|
+
*/
|
|
115
|
+
readonly boxState: Readable<"minimized" | "maximized" | "normal" | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Current window-manager's focused app's id.
|
|
118
|
+
* @example "HelloWorld-1A2b3C4d"
|
|
119
|
+
*/
|
|
120
|
+
readonly focusedApp: Readable<string | undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* How many times can I call `app.redo()`?
|
|
123
|
+
*/
|
|
124
|
+
readonly canRedoSteps: Readable<number>;
|
|
125
|
+
/**
|
|
126
|
+
* How many times can I call `app.undo()`?
|
|
127
|
+
*/
|
|
128
|
+
readonly canUndoSteps: Readable<number>;
|
|
129
|
+
/**
|
|
130
|
+
* Current camera information of main view.
|
|
131
|
+
*
|
|
132
|
+
* Change the camera position by `app.moveCamera()`.
|
|
133
|
+
*/
|
|
134
|
+
readonly camera: Readable<Camera>;
|
|
135
|
+
/**
|
|
136
|
+
* Current tool's info, like "is using pencil?", "what color?".
|
|
137
|
+
*
|
|
138
|
+
* Change the tool by `app.setAppliance()`.
|
|
139
|
+
*/
|
|
140
|
+
readonly memberState: Readable<MemberState>;
|
|
141
|
+
/**
|
|
142
|
+
* 0..n-1, current index of main view scenes.
|
|
143
|
+
*/
|
|
144
|
+
readonly sceneIndex: Writable<number>;
|
|
145
|
+
/**
|
|
146
|
+
* How many pages are in the main view?
|
|
147
|
+
*/
|
|
148
|
+
readonly sceneLength: Readable<number>;
|
|
149
|
+
private _appsStatus;
|
|
150
|
+
/**
|
|
151
|
+
* Apps status.
|
|
152
|
+
*/
|
|
153
|
+
readonly appsStatus: Readable<AppsStatus>;
|
|
154
|
+
/**
|
|
155
|
+
* Undo a step on main view.
|
|
156
|
+
*/
|
|
157
|
+
undo(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Redo a step on main view.
|
|
160
|
+
*/
|
|
161
|
+
redo(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Move current main view's camera position.
|
|
164
|
+
*/
|
|
165
|
+
moveCamera(camera: Partial<Camera> & {
|
|
166
|
+
animationMode?: AnimationMode | undefined;
|
|
167
|
+
}): void;
|
|
168
|
+
/**
|
|
169
|
+
* Move current main view's camera to include a rectangle.
|
|
170
|
+
*/
|
|
171
|
+
moveCameraToContain(rectangle: Rectangle & {
|
|
172
|
+
animationMode?: AnimationMode;
|
|
173
|
+
}): void;
|
|
174
|
+
/**
|
|
175
|
+
* Delete all things on the main view.
|
|
176
|
+
*/
|
|
177
|
+
cleanCurrentScene(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Set current tool, like "pencil".
|
|
180
|
+
*/
|
|
181
|
+
setAppliance(appliance: ApplianceNames | Appliance, shape?: ShapeType | Shape): void;
|
|
182
|
+
/**
|
|
183
|
+
* Set pencil and shape's thickness.
|
|
184
|
+
*/
|
|
185
|
+
setStrokeWidth(strokeWidth: number): void;
|
|
186
|
+
/**
|
|
187
|
+
* Set pencil and shape's color.
|
|
188
|
+
*/
|
|
189
|
+
setStrokeColor(strokeColor: Color): void;
|
|
190
|
+
/**
|
|
191
|
+
* Set text size. Default is 16.
|
|
192
|
+
*/
|
|
193
|
+
setTextSize(textSize: number): void;
|
|
194
|
+
/**
|
|
195
|
+
* Set text color.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* setTextColor([0x66, 0xcc, 0xff])
|
|
199
|
+
*/
|
|
200
|
+
setTextColor(textColor: Color): void;
|
|
201
|
+
/**
|
|
202
|
+
* Goto previous page (the main whiteboard view).
|
|
203
|
+
*/
|
|
204
|
+
prevPage(): Promise<boolean>;
|
|
205
|
+
/**
|
|
206
|
+
* Goto next page (the main whiteboard view).
|
|
207
|
+
*/
|
|
208
|
+
nextPage(): Promise<boolean>;
|
|
209
|
+
/**
|
|
210
|
+
* Add one page to the main whiteboard view.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* addPage({ after: true }) // add one page right after current one.
|
|
214
|
+
* nextPage() // then, goto that page.
|
|
215
|
+
*/
|
|
216
|
+
addPage(params?: AddPageParams): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Remove one page at given index or current page (by default).
|
|
219
|
+
*
|
|
220
|
+
* Requires `@netless/window-manager` >= 0.4.30.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* removePage() // remove current page
|
|
224
|
+
*/
|
|
225
|
+
removePage(index?: number): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* Insert an image to the main view.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* insertImage("https://i.imgur.com/CzXTtJV.jpg")
|
|
231
|
+
*/
|
|
232
|
+
insertImage(url: string): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Insert PDF/PPTX from conversion result.
|
|
235
|
+
* @param status https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress
|
|
236
|
+
*/
|
|
237
|
+
insertDocs(filename: string, status: ConversionResponse): Promise<string | undefined>;
|
|
238
|
+
/**
|
|
239
|
+
* Manual way.
|
|
240
|
+
* @example
|
|
241
|
+
* app.insertDocs({
|
|
242
|
+
* fileType: 'pptx',
|
|
243
|
+
* scenePath: `/pptx/${conversion.taskId}`,
|
|
244
|
+
* taskId: conversion.taskId,
|
|
245
|
+
* title: 'Title',
|
|
246
|
+
* })
|
|
247
|
+
*/
|
|
248
|
+
insertDocs(params: InsertDocsParams): Promise<string | undefined>;
|
|
249
|
+
private _insertDocsImpl;
|
|
250
|
+
/**
|
|
251
|
+
* Insert the Media Player app.
|
|
252
|
+
*/
|
|
253
|
+
insertMedia(title: string, src: string): Promise<string | undefined>;
|
|
254
|
+
/**
|
|
255
|
+
* Insert the Monaco Code Editor app.
|
|
256
|
+
* @deprecated Use `app.manager.addApp({ kind: 'Monaco' })` instead.
|
|
257
|
+
*/
|
|
258
|
+
insertCodeEditor(): Promise<string | undefined>;
|
|
259
|
+
/**
|
|
260
|
+
* Insert the Countdown app.
|
|
261
|
+
* @deprecated Use `app.manager.addApp({ kind: 'Countdown' })` instead.
|
|
262
|
+
*/
|
|
263
|
+
insertCountdown(): Promise<string | undefined>;
|
|
264
|
+
/**
|
|
265
|
+
* Insert the GeoGebra app.
|
|
266
|
+
* @deprecated Use `app.manager.addApp({ kind: 'GeoGebra' })` instead.
|
|
267
|
+
*/
|
|
268
|
+
insertGeoGebra(): Promise<string | undefined>;
|
|
269
|
+
}
|
|
270
|
+
interface FastboardOptions {
|
|
271
|
+
sdkConfig: Omit<WhiteWebSdkConfiguration, "useMobXState"> & {
|
|
272
|
+
region: NonNullable<WhiteWebSdkConfiguration["region"]>;
|
|
273
|
+
};
|
|
274
|
+
joinRoom: Omit<JoinRoomParams, "useMultiViews" | "disableNewPencil" | "disableMagixEventDispatchLimit"> & {
|
|
275
|
+
callbacks?: Partial<RoomCallbacks>;
|
|
276
|
+
};
|
|
277
|
+
managerConfig?: Omit<MountParams, "room">;
|
|
278
|
+
netlessApps?: NetlessApp[];
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Create a FastboardApp instance.
|
|
282
|
+
* @example
|
|
283
|
+
* let app = await createFastboard({
|
|
284
|
+
* sdkConfig: {
|
|
285
|
+
* appIdentifier: import.meta.env.VITE_APPID,
|
|
286
|
+
* region: 'cn-hz',
|
|
287
|
+
* },
|
|
288
|
+
* joinRoom: {
|
|
289
|
+
* uid: unique_id,
|
|
290
|
+
* uuid: import.meta.env.VITE_ROOM_UUID,
|
|
291
|
+
* roomToken: import.meta.env.VITE_ROOM_TOKEN,
|
|
292
|
+
* },
|
|
293
|
+
* })
|
|
294
|
+
*/
|
|
295
|
+
declare function createFastboard({ sdkConfig, joinRoom: { callbacks, ...joinRoomParams }, managerConfig, netlessApps, }: FastboardOptions): Promise<FastboardApp>;
|
|
296
|
+
|
|
297
|
+
declare class FastboardPlayerBase {
|
|
298
|
+
readonly sdk: WhiteWebSdk;
|
|
299
|
+
readonly player: Player;
|
|
300
|
+
readonly manager: WindowManager;
|
|
301
|
+
constructor(sdk: WhiteWebSdk, player: Player, manager: WindowManager);
|
|
302
|
+
protected _destroyed: boolean;
|
|
303
|
+
protected _assertNotDestroyed(): void;
|
|
304
|
+
protected _addPlayerListener<K extends keyof PlayerCallbacks>(name: K, listener: PlayerCallbacks[K]): () => void;
|
|
305
|
+
protected _addManagerListener<K extends keyof PublicEvent>(name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
306
|
+
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
307
|
+
destroy(): void;
|
|
308
|
+
}
|
|
309
|
+
declare type PlayerPhase = `${PlayerPhase$1}`;
|
|
310
|
+
|
|
311
|
+
declare class FastboardPlayer extends FastboardPlayerBase {
|
|
312
|
+
/**
|
|
313
|
+
* Render this player to some DOM.
|
|
314
|
+
*/
|
|
315
|
+
bindContainer(container: HTMLElement): void;
|
|
316
|
+
/**
|
|
317
|
+
* Move window-manager's collector to some place.
|
|
318
|
+
*/
|
|
319
|
+
bindCollector(container: HTMLElement): void;
|
|
320
|
+
/**
|
|
321
|
+
* Player current time in milliseconds.
|
|
322
|
+
*/
|
|
323
|
+
readonly currentTime: Writable<number>;
|
|
324
|
+
/**
|
|
325
|
+
* Player state, like "is it playing?".
|
|
326
|
+
*/
|
|
327
|
+
readonly phase: Readable<"waitingFirstFrame" | "playing" | "pause" | "stop" | "ended" | "buffering">;
|
|
328
|
+
/**
|
|
329
|
+
* Will become true after buffering.
|
|
330
|
+
*/
|
|
331
|
+
readonly canplay: Readable<boolean>;
|
|
332
|
+
private _setPlaybackRate;
|
|
333
|
+
/**
|
|
334
|
+
* Playback speed, default `1`.
|
|
335
|
+
*/
|
|
336
|
+
readonly playbackRate: Writable<number>;
|
|
337
|
+
/**
|
|
338
|
+
* Playback duration in milliseconds.
|
|
339
|
+
*/
|
|
340
|
+
readonly duration: Readable<number>;
|
|
341
|
+
/**
|
|
342
|
+
* Get state of room at that time, like "who was in the room?".
|
|
343
|
+
*/
|
|
344
|
+
readonly state: Readable<PlayerState>;
|
|
345
|
+
/**
|
|
346
|
+
* Seek to some time in milliseconds.
|
|
347
|
+
*/
|
|
348
|
+
seek(timestamp: number): Promise<PlayerSeekingResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Change player state to playing.
|
|
351
|
+
*/
|
|
352
|
+
play(): void;
|
|
353
|
+
/**
|
|
354
|
+
* Change player state to paused.
|
|
355
|
+
*/
|
|
356
|
+
pause(): void;
|
|
357
|
+
/**
|
|
358
|
+
* Change player state to stopped.
|
|
359
|
+
*/
|
|
360
|
+
stop(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Set playback speed, a shortcut for `speed.set(x)`.
|
|
363
|
+
*/
|
|
364
|
+
setPlaybackRate(value: number): void;
|
|
365
|
+
}
|
|
366
|
+
interface FastboardReplayOptions {
|
|
367
|
+
sdkConfig: Omit<WhiteWebSdkConfiguration, "useMobXState"> & {
|
|
368
|
+
region: NonNullable<WhiteWebSdkConfiguration["region"]>;
|
|
369
|
+
};
|
|
370
|
+
replayRoom: Omit<ReplayRoomParams, "useMultiViews"> & {
|
|
371
|
+
callbacks?: Partial<PlayerCallbacks>;
|
|
372
|
+
};
|
|
373
|
+
managerConfig?: Omit<MountParams, "room">;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Create a FastboardPlayer instance.
|
|
377
|
+
* @example
|
|
378
|
+
* let player = await replayFastboard({
|
|
379
|
+
* sdkConfig: {
|
|
380
|
+
* appIdentifier: import.meta.env.VITE_APPID,
|
|
381
|
+
* region: 'cn-hz',
|
|
382
|
+
* },
|
|
383
|
+
* replayRoom: {
|
|
384
|
+
* room: "room uuid",
|
|
385
|
+
* roomToken: "NETLESSROOM_...",
|
|
386
|
+
* beginTimestamp: 1646619090394,
|
|
387
|
+
* duration: 70448,
|
|
388
|
+
* },
|
|
389
|
+
* })
|
|
390
|
+
*/
|
|
391
|
+
declare function replayFastboard({ sdkConfig, replayRoom: { callbacks, ...replayRoomParams }, managerConfig, }: FastboardReplayOptions): Promise<FastboardPlayer>;
|
|
392
|
+
|
|
393
|
+
interface AppsConfig {
|
|
394
|
+
[kind: string]: Omit<RegisterParams, "kind">;
|
|
395
|
+
}
|
|
396
|
+
declare const register: typeof WindowManager.register;
|
|
397
|
+
declare const version: string;
|
|
398
|
+
|
|
399
|
+
export { Appliance, AppsConfig, AppsStatus, FastboardApp, FastboardOptions, FastboardPlayer, FastboardReplayOptions, InsertDocsDynamic, InsertDocsParams, InsertDocsStatic, PlayerPhase, Readable, RoomPhase, RoomStateChanged, SetMemberStateFn, Shape, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable, convertedFileToScene, createFastboard, genUID, getImageSize, makeSlideParams, readable, register, replayFastboard, version, warn, writable };
|