@netless/fastboard-core 0.3.6 → 0.3.8-alpha.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/dist/index.d.ts +79 -24
- package/dist/index.js +261 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/behaviors/index.ts +2 -2
- package/src/helpers/docs.ts +117 -0
- package/src/helpers/index.ts +2 -0
- package/src/helpers/listen.ts +37 -0
- package/src/impl/FastboardApp.ts +51 -6
- package/src/impl/FastboardPlayer.ts +6 -3
- package/src/index.ts +1 -0
- package/src/utils/misc.ts +5 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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';
|
|
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, View } from 'white-web-sdk';
|
|
2
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
3
|
import { AddPageParams, MountParams, NetlessApp, WindowManager, PublicEvent, RegisterParams } 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
|
-
export { PreviewParams, default as SlideApp,
|
|
7
|
+
export { PreviewParams, default as SlideApp, AppResult as SlideController, AppOptions as SlideOptions, SlidePreviewer, addHooks as addSlideHooks, previewSlide, apps as slideApps } from '@netless/app-slide';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
type Subscriber<T> = (value: T) => void;
|
|
10
|
+
type Unsubscriber = () => void;
|
|
11
|
+
type Updater<T> = (value: T) => T;
|
|
12
|
+
type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
|
|
13
13
|
interface Readable<T> {
|
|
14
14
|
readonly value: T;
|
|
15
15
|
subscribe(this: void, run: Subscriber<T>): Unsubscriber;
|
|
@@ -37,7 +37,7 @@ declare const warnings: {
|
|
|
37
37
|
};
|
|
38
38
|
declare function warn(id: keyof typeof warnings): void;
|
|
39
39
|
|
|
40
|
-
declare class FastboardAppBase<TEventData = any> {
|
|
40
|
+
declare class FastboardAppBase<TEventData extends Record<string, any> = any> {
|
|
41
41
|
readonly sdk: WhiteWebSdk;
|
|
42
42
|
readonly room: Room;
|
|
43
43
|
readonly manager: WindowManager;
|
|
@@ -54,12 +54,12 @@ declare class FastboardAppBase<TEventData = any> {
|
|
|
54
54
|
*/
|
|
55
55
|
destroy(): Promise<void>;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
type RoomPhase = `${RoomPhase$1}`;
|
|
58
58
|
|
|
59
59
|
/** pencil, eraser, rectangle... */
|
|
60
|
-
|
|
60
|
+
type Appliance = `${ApplianceNames}`;
|
|
61
61
|
/** triangle, star... */
|
|
62
|
-
|
|
62
|
+
type Shape = `${ShapeType}`;
|
|
63
63
|
/** Params for static docs, they are rendered as many images. */
|
|
64
64
|
interface InsertDocsStatic {
|
|
65
65
|
readonly fileType: "pdf";
|
|
@@ -84,9 +84,32 @@ interface InsertDocsDynamic {
|
|
|
84
84
|
/** @example [{ name: '1' }, { name: '2' }, { name: '3' }] */
|
|
85
85
|
readonly scenes?: SceneDefinition[];
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
type InsertDocsParams = InsertDocsStatic | InsertDocsDynamic;
|
|
88
|
+
interface ProjectorResponse {
|
|
89
|
+
uuid: string;
|
|
90
|
+
status: "Waiting" | "Converting" | "Finished" | "Fail";
|
|
91
|
+
type: "dynamic" | "static";
|
|
92
|
+
/** 0..100 */
|
|
93
|
+
convertedPercentage: number;
|
|
94
|
+
/** https://example.org/path/to/dynamicConvert, only when type=dynamic */
|
|
95
|
+
prefix?: string;
|
|
96
|
+
pageCount?: number;
|
|
97
|
+
/** {1:"{prefix}/{taskId}/preview/1.png"}, only when type=dynamic and preview=true */
|
|
98
|
+
previews?: Record<number, string>;
|
|
99
|
+
/** {prefix}/{taskId}/jsonOutput/note.json */
|
|
100
|
+
note?: string;
|
|
101
|
+
/** {1:{width,height,url}}, only when type=static */
|
|
102
|
+
images?: Record<number, {
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
url: string;
|
|
106
|
+
}>;
|
|
107
|
+
/** 20xxxxx */
|
|
108
|
+
errorCode?: string;
|
|
109
|
+
errorMessage?: string;
|
|
110
|
+
}
|
|
111
|
+
type SetMemberStateFn = (partialMemberState: Partial<MemberState>) => void;
|
|
112
|
+
type RoomStateChanged = (diff: Partial<RoomState>) => void;
|
|
90
113
|
/** App download progress. */
|
|
91
114
|
interface AppsStatus {
|
|
92
115
|
[kind: string]: {
|
|
@@ -95,7 +118,7 @@ interface AppsStatus {
|
|
|
95
118
|
reason?: string;
|
|
96
119
|
};
|
|
97
120
|
}
|
|
98
|
-
declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData> {
|
|
121
|
+
declare class FastboardApp<TEventData extends Record<string, any> = any> extends FastboardAppBase<TEventData> {
|
|
99
122
|
/**
|
|
100
123
|
* Render this app to some DOM.
|
|
101
124
|
*/
|
|
@@ -149,7 +172,6 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
149
172
|
* How many pages are in the main view?
|
|
150
173
|
*/
|
|
151
174
|
readonly sceneLength: Readable<number>;
|
|
152
|
-
private _appsStatus;
|
|
153
175
|
/**
|
|
154
176
|
* Apps status.
|
|
155
177
|
*/
|
|
@@ -238,6 +260,11 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
238
260
|
* @param status https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress
|
|
239
261
|
*/
|
|
240
262
|
insertDocs(filename: string, status: ConversionResponse): Promise<string | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* Insert PDF/PPTX from projector conversion result.
|
|
265
|
+
* @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
|
|
266
|
+
*/
|
|
267
|
+
insertDocs(filename: string, response: ProjectorResponse): Promise<string | undefined>;
|
|
241
268
|
/**
|
|
242
269
|
* Manual way.
|
|
243
270
|
* @example
|
|
@@ -249,7 +276,6 @@ declare class FastboardApp<TEventData = any> extends FastboardAppBase<TEventData
|
|
|
249
276
|
* })
|
|
250
277
|
*/
|
|
251
278
|
insertDocs(params: InsertDocsParams): Promise<string | undefined>;
|
|
252
|
-
private _insertDocsImpl;
|
|
253
279
|
/**
|
|
254
280
|
* Insert the Media Player app.
|
|
255
281
|
*/
|
|
@@ -275,7 +301,7 @@ interface FastboardOptions {
|
|
|
275
301
|
region: NonNullable<WhiteWebSdkConfiguration["region"]>;
|
|
276
302
|
};
|
|
277
303
|
joinRoom: Omit<JoinRoomParams, "useMultiViews" | "disableNewPencil" | "disableMagixEventDispatchLimit"> & {
|
|
278
|
-
callbacks?: Partial<RoomCallbacks
|
|
304
|
+
callbacks?: Partial<Omit<RoomCallbacks, "onCanRedoStepsUpdate" | "onCanUndoStepsUpdate">>;
|
|
279
305
|
};
|
|
280
306
|
managerConfig?: Omit<MountParams, "room">;
|
|
281
307
|
netlessApps?: NetlessApp[];
|
|
@@ -295,9 +321,9 @@ interface FastboardOptions {
|
|
|
295
321
|
* },
|
|
296
322
|
* })
|
|
297
323
|
*/
|
|
298
|
-
declare function createFastboard<TEventData = any>({ sdkConfig, joinRoom: { callbacks, ...joinRoomParams }, managerConfig, netlessApps, }: FastboardOptions): Promise<FastboardApp<TEventData>>;
|
|
324
|
+
declare function createFastboard<TEventData extends Record<string, any> = any>({ sdkConfig, joinRoom: { callbacks, ...joinRoomParams }, managerConfig, netlessApps, }: FastboardOptions): Promise<FastboardApp<TEventData>>;
|
|
299
325
|
|
|
300
|
-
declare class FastboardPlayerBase<TEventData = any> {
|
|
326
|
+
declare class FastboardPlayerBase<TEventData extends Record<string, any> = any> {
|
|
301
327
|
readonly sdk: WhiteWebSdk;
|
|
302
328
|
readonly player: Player;
|
|
303
329
|
readonly manager: WindowManager;
|
|
@@ -310,9 +336,9 @@ declare class FastboardPlayerBase<TEventData = any> {
|
|
|
310
336
|
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
311
337
|
destroy(): void;
|
|
312
338
|
}
|
|
313
|
-
|
|
339
|
+
type PlayerPhase = `${PlayerPhase$1}`;
|
|
314
340
|
|
|
315
|
-
declare class FastboardPlayer<TEventData = any> extends FastboardPlayerBase<TEventData> {
|
|
341
|
+
declare class FastboardPlayer<TEventData extends Record<string, any> = any> extends FastboardPlayerBase<TEventData> {
|
|
316
342
|
/**
|
|
317
343
|
* Render this player to some DOM.
|
|
318
344
|
*/
|
|
@@ -333,7 +359,6 @@ declare class FastboardPlayer<TEventData = any> extends FastboardPlayerBase<TEve
|
|
|
333
359
|
* Will become true after buffering.
|
|
334
360
|
*/
|
|
335
361
|
readonly canplay: Readable<boolean>;
|
|
336
|
-
private _setPlaybackRate;
|
|
337
362
|
/**
|
|
338
363
|
* Playback speed, default `1`.
|
|
339
364
|
*/
|
|
@@ -393,7 +418,7 @@ interface FastboardReplayOptions {
|
|
|
393
418
|
* },
|
|
394
419
|
* })
|
|
395
420
|
*/
|
|
396
|
-
declare function replayFastboard<TEventData = any>({ sdkConfig, replayRoom: { callbacks, ...replayRoomParams }, managerConfig, netlessApps, }: FastboardReplayOptions): Promise<FastboardPlayer<TEventData>>;
|
|
421
|
+
declare function replayFastboard<TEventData extends Record<string, any> = any>({ sdkConfig, replayRoom: { callbacks, ...replayRoomParams }, managerConfig, netlessApps, }: FastboardReplayOptions): Promise<FastboardPlayer<TEventData>>;
|
|
397
422
|
|
|
398
423
|
interface AppsConfig {
|
|
399
424
|
[kind: string]: Omit<RegisterParams, "kind">;
|
|
@@ -401,4 +426,34 @@ interface AppsConfig {
|
|
|
401
426
|
declare const register: typeof WindowManager.register;
|
|
402
427
|
declare const version: string;
|
|
403
428
|
|
|
404
|
-
|
|
429
|
+
declare function addRoomListener<K extends keyof RoomCallbacks>(room: Room, name: K, listener: RoomCallbacks[K]): () => void;
|
|
430
|
+
declare function addPlayerListener<K extends keyof PlayerCallbacks>(player: Player, name: K, listener: PlayerCallbacks[K]): () => void;
|
|
431
|
+
declare function addViewListener<K extends keyof ViewCallbacks>(view: View, name: K, listener: (value: ViewCallbacks[K]) => void): () => void;
|
|
432
|
+
declare function addManagerListener<K extends keyof PublicEvent>(manager: WindowManager, name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
433
|
+
|
|
434
|
+
interface DocsEventOptions {
|
|
435
|
+
/** If provided, will dispatch to the specific app. Default to the focused app. */
|
|
436
|
+
appId?: string;
|
|
437
|
+
/** Used by `jumpToPage` event, range from 1 to total pages count. */
|
|
438
|
+
page?: number;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Send specific command to the static docs / slide app.
|
|
442
|
+
* Only works for apps that were created by `insertDocs()`.
|
|
443
|
+
*
|
|
444
|
+
* Returns false if failed to find the app or not writable.
|
|
445
|
+
*
|
|
446
|
+
* For static docs, `nextPage` equals to `nextStep`, as with `prevPage` and `prevStep`.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```js
|
|
450
|
+
* // send "next page" to the focused app
|
|
451
|
+
* dispatchDocsEvent(fastboard, "nextPage")
|
|
452
|
+
*
|
|
453
|
+
* // send "prev page" to some app
|
|
454
|
+
* dispatchDocsEvent(fastboard, "prevPage", {appId:"Slide-1a2b3c4d"})
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function dispatchDocsEvent(fastboard: FastboardApp | WindowManager, event: "prevPage" | "nextPage" | "prevStep" | "nextStep" | "jumpToPage", options?: DocsEventOptions): boolean;
|
|
458
|
+
|
|
459
|
+
export { Appliance, AppsConfig, AppsStatus, DocsEventOptions, FastboardApp, FastboardOptions, FastboardPlayer, FastboardReplayOptions, InsertDocsDynamic, InsertDocsParams, InsertDocsStatic, PlayerPhase, ProjectorResponse, Readable, RoomPhase, RoomStateChanged, SetMemberStateFn, Shape, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable, addManagerListener, addPlayerListener, addRoomListener, addViewListener, convertedFileToScene, createFastboard, dispatchDocsEvent, genUID, getImageSize, makeSlideParams, readable, register, replayFastboard, version, warn, writable };
|