@netless/fastboard-core 0.3.8 → 0.3.10
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 +36 -14
- package/dist/index.js +245 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/helpers/listen.ts +16 -0
- package/src/impl/FastboardApp.ts +47 -6
- package/src/impl/FastboardPlayer.ts +5 -1
- package/src/utils/misc.ts +31 -1
- package/src/utils/store.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Size, SceneDefinition, ConvertedFile, RoomPhase as RoomPhase$1, ApplianceNames, ShapeType, MemberState, RoomState, Camera, AnimationMode, Rectangle, Color, ConversionResponse, WhiteWebSdkConfiguration, JoinRoomParams, RoomCallbacks, WhiteWebSdk, Room, HotKeys,
|
|
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,
|
|
1
|
+
import { Size, SceneDefinition, ConvertedFile, RoomPhase as RoomPhase$1, ApplianceNames, ShapeType, MemberState, RoomState, CameraState, Camera, AnimationMode, Rectangle, Color, ConversionResponse, WhiteWebSdkConfiguration, JoinRoomParams, RoomCallbacks, WhiteWebSdk, Room, HotKeys, PlayerPhase as PlayerPhase$1, PlayerState, PlayerSeekingResult, ReplayRoomParams, PlayerCallbacks, Player, ViewCallbacks, View } from 'white-web-sdk';
|
|
2
|
+
export { AnimationMode, ApplianceNames, Camera, CameraState, 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, RegisterParams, PublicEvent } 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';
|
|
@@ -22,7 +22,7 @@ interface Writable<T> extends Readable<T> {
|
|
|
22
22
|
declare function readable<T>(value: T, start?: StartStopNotifier<T>): Readable<T>;
|
|
23
23
|
declare function writable<T>(value: T, start: StartStopNotifier<T> | undefined, set: Subscriber<T>): Writable<T>;
|
|
24
24
|
|
|
25
|
-
declare function getImageSize(url: string, fallback: Size): Promise<Size>;
|
|
25
|
+
declare function getImageSize(url: string, fallback: Size, crossOrigin?: boolean | string): Promise<Size>;
|
|
26
26
|
declare function makeSlideParams(scenes: SceneDefinition[]): {
|
|
27
27
|
scenes: SceneDefinition[];
|
|
28
28
|
taskId: string;
|
|
@@ -45,10 +45,6 @@ declare class FastboardAppBase<TEventData extends Record<string, any> = any> {
|
|
|
45
45
|
readonly syncedStore: SyncedStore<TEventData>;
|
|
46
46
|
constructor(sdk: WhiteWebSdk, room: Room, manager: WindowManager, hotKeys: Partial<HotKeys>, syncedStore: SyncedStore<TEventData>);
|
|
47
47
|
protected _destroyed: boolean;
|
|
48
|
-
protected _assertNotDestroyed(): void;
|
|
49
|
-
protected _addRoomListener<K extends keyof RoomCallbacks>(name: K, listener: RoomCallbacks[K]): () => void;
|
|
50
|
-
protected _addManagerListener<K extends keyof PublicEvent>(name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
51
|
-
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
52
48
|
/**
|
|
53
49
|
* Destroy fastboard (disconnect from the whiteboard room).
|
|
54
50
|
*/
|
|
@@ -157,7 +153,7 @@ declare class FastboardApp<TEventData extends Record<string, any> = any> extends
|
|
|
157
153
|
*
|
|
158
154
|
* Change the camera position by `app.moveCamera()`.
|
|
159
155
|
*/
|
|
160
|
-
readonly camera: Readable<
|
|
156
|
+
readonly camera: Readable<CameraState>;
|
|
161
157
|
/**
|
|
162
158
|
* Current tool's info, like "is using pencil?", "what color?".
|
|
163
159
|
*
|
|
@@ -223,6 +219,14 @@ declare class FastboardApp<TEventData extends Record<string, any> = any> extends
|
|
|
223
219
|
* setTextColor([0x66, 0xcc, 0xff])
|
|
224
220
|
*/
|
|
225
221
|
setTextColor(textColor: Color): void;
|
|
222
|
+
/**
|
|
223
|
+
* Toggle dotted line effect on pencil.
|
|
224
|
+
*/
|
|
225
|
+
toggleDottedLine(force?: boolean): void;
|
|
226
|
+
/**
|
|
227
|
+
* Set pencil eraser size.
|
|
228
|
+
*/
|
|
229
|
+
setPencilEraserSize(size: number): void;
|
|
226
230
|
/**
|
|
227
231
|
* Goto previous page (the main whiteboard view).
|
|
228
232
|
*/
|
|
@@ -231,6 +235,10 @@ declare class FastboardApp<TEventData extends Record<string, any> = any> extends
|
|
|
231
235
|
* Goto next page (the main whiteboard view).
|
|
232
236
|
*/
|
|
233
237
|
nextPage(): Promise<boolean>;
|
|
238
|
+
/**
|
|
239
|
+
* Goto any page (index range: 0..n-1)
|
|
240
|
+
*/
|
|
241
|
+
jumpPage(index: number): Promise<boolean>;
|
|
234
242
|
/**
|
|
235
243
|
* Add one page to the main whiteboard view.
|
|
236
244
|
*
|
|
@@ -251,10 +259,12 @@ declare class FastboardApp<TEventData extends Record<string, any> = any> extends
|
|
|
251
259
|
/**
|
|
252
260
|
* Insert an image to the main view.
|
|
253
261
|
*
|
|
262
|
+
* @param crossOrigin Whether to load the image with CORS enabled, default is `true`.
|
|
263
|
+
*
|
|
254
264
|
* @example
|
|
255
265
|
* insertImage("https://i.imgur.com/CzXTtJV.jpg")
|
|
256
266
|
*/
|
|
257
|
-
insertImage(url: string): Promise<void>;
|
|
267
|
+
insertImage(url: string, crossOrigin?: boolean | string): Promise<void>;
|
|
258
268
|
/**
|
|
259
269
|
* Insert PDF/PPTX from conversion result.
|
|
260
270
|
* @param status https://developer.netless.link/server-en/home/server-conversion#get-query-task-conversion-progress
|
|
@@ -330,10 +340,6 @@ declare class FastboardPlayerBase<TEventData extends Record<string, any> = any>
|
|
|
330
340
|
readonly syncedStore: SyncedStore<TEventData>;
|
|
331
341
|
constructor(sdk: WhiteWebSdk, player: Player, manager: WindowManager, syncedStore: SyncedStore<TEventData>);
|
|
332
342
|
protected _destroyed: boolean;
|
|
333
|
-
protected _assertNotDestroyed(): void;
|
|
334
|
-
protected _addPlayerListener<K extends keyof PlayerCallbacks>(name: K, listener: PlayerCallbacks[K]): () => void;
|
|
335
|
-
protected _addManagerListener<K extends keyof PublicEvent>(name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
336
|
-
protected _addMainViewListener<K extends keyof ViewCallbacks>(name: K, listener: ViewCallbacks[K]): () => void;
|
|
337
343
|
destroy(): void;
|
|
338
344
|
}
|
|
339
345
|
type PlayerPhase = `${PlayerPhase$1}`;
|
|
@@ -428,6 +434,22 @@ declare const version: string;
|
|
|
428
434
|
|
|
429
435
|
declare function addRoomListener<K extends keyof RoomCallbacks>(room: Room, name: K, listener: RoomCallbacks[K]): () => void;
|
|
430
436
|
declare function addPlayerListener<K extends keyof PlayerCallbacks>(player: Player, name: K, listener: PlayerCallbacks[K]): () => void;
|
|
437
|
+
/**
|
|
438
|
+
* Note: view listeners will be invalid on reconnection.
|
|
439
|
+
* You have to rebind them after the phase changed.
|
|
440
|
+
* @example
|
|
441
|
+
* const bindCamera = () => addViewListener(mainView, "onCameraUpdated", setCamera)
|
|
442
|
+
* let dispose = bindCamera(), phase_ = "disconnected"
|
|
443
|
+
* setCamera(mainView.camera)
|
|
444
|
+
* addRoomListener(room, "onPhaseChanged", (phase) => {
|
|
445
|
+
* if (phase === "connected" && phase_ === "reconnecting") {
|
|
446
|
+
* dispose()
|
|
447
|
+
* dispose = bindCamera()
|
|
448
|
+
* setCamera(mainView.camera)
|
|
449
|
+
* }
|
|
450
|
+
* phase_ = phase
|
|
451
|
+
* })
|
|
452
|
+
*/
|
|
431
453
|
declare function addViewListener<K extends keyof ViewCallbacks>(view: View, name: K, listener: (value: ViewCallbacks[K]) => void): () => void;
|
|
432
454
|
declare function addManagerListener<K extends keyof PublicEvent>(manager: WindowManager, name: K, listener: (value: PublicEvent[K]) => void): () => void;
|
|
433
455
|
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ var windowManager = require('@netless/window-manager');
|
|
|
5
5
|
var syncedStore = require('@netless/synced-store');
|
|
6
6
|
var SlideApp = require('@netless/app-slide');
|
|
7
7
|
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var SlideApp__default = /*#__PURE__*/_interopDefault(SlideApp);
|
|
11
|
+
|
|
8
12
|
var __defProp = Object.defineProperty;
|
|
9
13
|
var __defProps = Object.defineProperties;
|
|
10
14
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -105,20 +109,43 @@ function writable(value, start = noop, set) {
|
|
|
105
109
|
reaction: internal.reaction,
|
|
106
110
|
set,
|
|
107
111
|
update(fn) {
|
|
108
|
-
set(fn(value));
|
|
112
|
+
set(fn(internal.value));
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
// src/utils/misc.ts
|
|
114
|
-
function getImageSize(url, fallback) {
|
|
118
|
+
function getImageSize(url, fallback, crossOrigin) {
|
|
115
119
|
return new Promise((resolve) => {
|
|
116
120
|
const img = new Image();
|
|
121
|
+
applyCrossOrigin(img, url, crossOrigin);
|
|
117
122
|
img.onload = () => resolve(img);
|
|
118
123
|
img.onerror = () => resolve(fallback);
|
|
119
124
|
img.src = url;
|
|
120
125
|
});
|
|
121
126
|
}
|
|
127
|
+
function applyCrossOrigin(image, src, crossOrigin) {
|
|
128
|
+
if (crossOrigin === void 0 && !src.startsWith("data:")) {
|
|
129
|
+
image.crossOrigin = determineCrossOrigin(src);
|
|
130
|
+
} else if (crossOrigin !== false) {
|
|
131
|
+
image.crossOrigin = typeof crossOrigin === "string" ? crossOrigin : "anonymous";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function determineCrossOrigin(src) {
|
|
135
|
+
if (src.startsWith("data:") || typeof window === "undefined" || !window.location) {
|
|
136
|
+
return "";
|
|
137
|
+
}
|
|
138
|
+
const loc = window.location;
|
|
139
|
+
try {
|
|
140
|
+
const parsedUrl = new URL(src, document.baseURI);
|
|
141
|
+
if (parsedUrl.hostname !== loc.hostname || parsedUrl.port !== loc.port || parsedUrl.protocol !== loc.protocol) {
|
|
142
|
+
return "anonymous";
|
|
143
|
+
}
|
|
144
|
+
return "";
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
122
149
|
function makeSlideParams(scenes) {
|
|
123
150
|
const emptyScenes = [];
|
|
124
151
|
let taskId = "";
|
|
@@ -205,7 +232,7 @@ var DefaultApps = {
|
|
|
205
232
|
windowManager.WindowManager.register({
|
|
206
233
|
kind: "Slide",
|
|
207
234
|
appOptions: { debug: false },
|
|
208
|
-
src:
|
|
235
|
+
src: SlideApp__default.default,
|
|
209
236
|
addHooks: SlideApp.addHooks
|
|
210
237
|
});
|
|
211
238
|
for (const kind in DefaultApps) {
|
|
@@ -215,7 +242,7 @@ for (const kind in DefaultApps) {
|
|
|
215
242
|
}
|
|
216
243
|
}
|
|
217
244
|
var register = windowManager.WindowManager.register.bind(windowManager.WindowManager);
|
|
218
|
-
var version = "0.3.
|
|
245
|
+
var version = "0.3.10";
|
|
219
246
|
if (typeof window !== "undefined") {
|
|
220
247
|
let str = window.__netlessUA || "";
|
|
221
248
|
str += ` ${"@netless/fastboard"}@${version} `;
|
|
@@ -232,26 +259,33 @@ var FastboardAppBase = class {
|
|
|
232
259
|
this.syncedStore = syncedStore;
|
|
233
260
|
__publicField(this, "_destroyed", false);
|
|
234
261
|
}
|
|
262
|
+
/** @internal */
|
|
235
263
|
_assertNotDestroyed() {
|
|
236
264
|
if (this._destroyed) {
|
|
237
265
|
throw new Error("FastboardApp has been destroyed");
|
|
238
266
|
}
|
|
239
267
|
}
|
|
268
|
+
/** @internal */
|
|
240
269
|
_addRoomListener(name, listener) {
|
|
241
270
|
this._assertNotDestroyed();
|
|
242
271
|
this.room.callbacks.on(name, listener);
|
|
243
272
|
return () => this.room.callbacks.off(name, listener);
|
|
244
273
|
}
|
|
274
|
+
/** @internal */
|
|
245
275
|
_addManagerListener(name, listener) {
|
|
246
276
|
this._assertNotDestroyed();
|
|
247
277
|
this.manager.emitter.on(name, listener);
|
|
248
278
|
return () => this.manager.emitter.off(name, listener);
|
|
249
279
|
}
|
|
280
|
+
/** @internal */
|
|
250
281
|
_addMainViewListener(name, listener) {
|
|
251
282
|
this._assertNotDestroyed();
|
|
252
283
|
this.manager.mainView.callbacks.on(name, listener);
|
|
253
284
|
return () => this.manager.mainView.callbacks.off(name, listener);
|
|
254
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Destroy fastboard (disconnect from the whiteboard room).
|
|
288
|
+
*/
|
|
255
289
|
destroy() {
|
|
256
290
|
this._destroyed = true;
|
|
257
291
|
this.manager.destroy();
|
|
@@ -261,6 +295,9 @@ var FastboardAppBase = class {
|
|
|
261
295
|
var FastboardApp = class extends FastboardAppBase {
|
|
262
296
|
constructor() {
|
|
263
297
|
super(...arguments);
|
|
298
|
+
/**
|
|
299
|
+
* Is current room writable?
|
|
300
|
+
*/
|
|
264
301
|
__publicField(this, "writable", writable(
|
|
265
302
|
this.room.isWritable,
|
|
266
303
|
(set) => {
|
|
@@ -269,34 +306,63 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
269
306
|
},
|
|
270
307
|
this.room.setWritable.bind(this.room)
|
|
271
308
|
));
|
|
309
|
+
/**
|
|
310
|
+
* Is current room online?
|
|
311
|
+
*/
|
|
272
312
|
__publicField(this, "phase", readable(this.room.phase, (set) => {
|
|
273
313
|
set(this.room.phase);
|
|
274
314
|
return this._addRoomListener("onPhaseChanged", set);
|
|
275
315
|
}));
|
|
316
|
+
/**
|
|
317
|
+
* Current window-manager's windows' state (is it maximized?).
|
|
318
|
+
*/
|
|
276
319
|
__publicField(this, "boxState", readable(this.manager.boxState, (set) => {
|
|
277
320
|
set(this.manager.boxState);
|
|
278
321
|
return this._addManagerListener("boxStateChange", set);
|
|
279
322
|
}));
|
|
323
|
+
/**
|
|
324
|
+
* Current window-manager's focused app's id.
|
|
325
|
+
* @example "HelloWorld-1A2b3C4d"
|
|
326
|
+
*/
|
|
280
327
|
__publicField(this, "focusedApp", readable(this.manager.focused, (set) => {
|
|
281
328
|
set(this.manager.focused);
|
|
282
329
|
return this._addManagerListener("focusedChange", set);
|
|
283
330
|
}));
|
|
331
|
+
/**
|
|
332
|
+
* How many times can I call `app.redo()`?
|
|
333
|
+
*/
|
|
284
334
|
__publicField(this, "canRedoSteps", readable(this.manager.canRedoSteps, (set) => {
|
|
285
335
|
set(this.manager.canRedoSteps);
|
|
286
336
|
return this._addManagerListener("canRedoStepsChange", set);
|
|
287
337
|
}));
|
|
338
|
+
/**
|
|
339
|
+
* How many times can I call `app.undo()`?
|
|
340
|
+
*/
|
|
288
341
|
__publicField(this, "canUndoSteps", readable(this.manager.canUndoSteps, (set) => {
|
|
289
342
|
set(this.manager.canUndoSteps);
|
|
290
343
|
return this._addManagerListener("canUndoStepsChange", set);
|
|
291
344
|
}));
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Current camera information of main view.
|
|
347
|
+
*
|
|
348
|
+
* Change the camera position by `app.moveCamera()`.
|
|
349
|
+
*/
|
|
350
|
+
__publicField(this, "camera", readable(this.manager.cameraState, (set) => {
|
|
351
|
+
set(this.manager.cameraState);
|
|
352
|
+
return this._addManagerListener("cameraStateChange", set);
|
|
295
353
|
}));
|
|
354
|
+
/**
|
|
355
|
+
* Current tool's info, like "is using pencil?", "what color?".
|
|
356
|
+
*
|
|
357
|
+
* Change the tool by `app.setAppliance()`.
|
|
358
|
+
*/
|
|
296
359
|
__publicField(this, "memberState", readable(this.room.state.memberState, (set) => {
|
|
297
360
|
set(this.room.state.memberState);
|
|
298
361
|
return this._addRoomListener("onRoomStateChanged", ({ memberState: m }) => m && set(m));
|
|
299
362
|
}));
|
|
363
|
+
/**
|
|
364
|
+
* 0..n-1, current index of main view scenes.
|
|
365
|
+
*/
|
|
300
366
|
__publicField(this, "sceneIndex", writable(
|
|
301
367
|
this.manager.mainViewSceneIndex,
|
|
302
368
|
(set) => {
|
|
@@ -305,11 +371,18 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
305
371
|
},
|
|
306
372
|
this.manager.setMainViewSceneIndex.bind(this.manager)
|
|
307
373
|
));
|
|
374
|
+
/**
|
|
375
|
+
* How many pages are in the main view?
|
|
376
|
+
*/
|
|
308
377
|
__publicField(this, "sceneLength", readable(this.manager.mainViewScenesLength, (set) => {
|
|
309
378
|
set(this.manager.mainViewScenesLength);
|
|
310
379
|
return this._addManagerListener("mainViewScenesLengthChange", set);
|
|
311
380
|
}));
|
|
381
|
+
/** @internal */
|
|
312
382
|
__publicField(this, "_appsStatus", {});
|
|
383
|
+
/**
|
|
384
|
+
* Apps status.
|
|
385
|
+
*/
|
|
313
386
|
__publicField(this, "appsStatus", readable(
|
|
314
387
|
{},
|
|
315
388
|
(set) => this._addManagerListener("loadApp", ({ kind, status, reason }) => {
|
|
@@ -318,34 +391,58 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
318
391
|
})
|
|
319
392
|
));
|
|
320
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Render this app to some DOM.
|
|
396
|
+
*/
|
|
321
397
|
bindContainer(container) {
|
|
322
398
|
this._assertNotDestroyed();
|
|
323
399
|
this.manager.bindContainer(container);
|
|
324
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Move window-manager's collector to some place.
|
|
403
|
+
*/
|
|
325
404
|
bindCollector(container) {
|
|
326
405
|
this._assertNotDestroyed();
|
|
327
406
|
this.manager.bindCollectorContainer(container);
|
|
328
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* Undo a step on main view.
|
|
410
|
+
*/
|
|
329
411
|
undo() {
|
|
330
412
|
this._assertNotDestroyed();
|
|
331
413
|
this.manager.undo();
|
|
332
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Redo a step on main view.
|
|
417
|
+
*/
|
|
333
418
|
redo() {
|
|
334
419
|
this._assertNotDestroyed();
|
|
335
420
|
this.manager.redo();
|
|
336
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Move current main view's camera position.
|
|
424
|
+
*/
|
|
337
425
|
moveCamera(camera) {
|
|
338
426
|
this._assertNotDestroyed();
|
|
339
427
|
this.manager.moveCamera(camera);
|
|
340
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Move current main view's camera to include a rectangle.
|
|
431
|
+
*/
|
|
341
432
|
moveCameraToContain(rectangle) {
|
|
342
433
|
this._assertNotDestroyed();
|
|
343
434
|
this.manager.moveCameraToContain(rectangle);
|
|
344
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Delete all things on the main view.
|
|
438
|
+
*/
|
|
345
439
|
cleanCurrentScene() {
|
|
346
440
|
this._assertNotDestroyed();
|
|
347
441
|
this.manager.cleanCurrentScene();
|
|
348
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Set current tool, like "pencil".
|
|
445
|
+
*/
|
|
349
446
|
setAppliance(appliance, shape) {
|
|
350
447
|
this._assertNotDestroyed();
|
|
351
448
|
this.manager.mainView.setMemberState({
|
|
@@ -353,39 +450,104 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
353
450
|
shapeType: shape
|
|
354
451
|
});
|
|
355
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Set pencil and shape's thickness.
|
|
455
|
+
*/
|
|
356
456
|
setStrokeWidth(strokeWidth) {
|
|
357
457
|
this._assertNotDestroyed();
|
|
358
458
|
this.manager.mainView.setMemberState({ strokeWidth });
|
|
359
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Set pencil and shape's color.
|
|
462
|
+
*/
|
|
360
463
|
setStrokeColor(strokeColor) {
|
|
361
464
|
this._assertNotDestroyed();
|
|
362
465
|
this.manager.mainView.setMemberState({ strokeColor });
|
|
363
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Set text size. Default is 16.
|
|
469
|
+
*/
|
|
364
470
|
setTextSize(textSize) {
|
|
365
471
|
this._assertNotDestroyed();
|
|
366
472
|
this.manager.mainView.setMemberState({ textSize });
|
|
367
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Set text color.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* setTextColor([0x66, 0xcc, 0xff])
|
|
479
|
+
*/
|
|
368
480
|
setTextColor(textColor) {
|
|
369
481
|
this._assertNotDestroyed();
|
|
370
482
|
this.manager.mainView.setMemberState({ textColor });
|
|
371
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* Toggle dotted line effect on pencil.
|
|
486
|
+
*/
|
|
487
|
+
toggleDottedLine(force) {
|
|
488
|
+
this._assertNotDestroyed();
|
|
489
|
+
this.manager.mainView.setMemberState({ dottedLine: force != null ? force : !this.memberState.value.dottedLine });
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Set pencil eraser size.
|
|
493
|
+
*/
|
|
494
|
+
setPencilEraserSize(size) {
|
|
495
|
+
this._assertNotDestroyed();
|
|
496
|
+
this.manager.mainView.setMemberState({ pencilEraserSize: size });
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Goto previous page (the main whiteboard view).
|
|
500
|
+
*/
|
|
372
501
|
prevPage() {
|
|
373
502
|
this._assertNotDestroyed();
|
|
374
503
|
return this.manager.prevPage();
|
|
375
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Goto next page (the main whiteboard view).
|
|
507
|
+
*/
|
|
376
508
|
nextPage() {
|
|
377
509
|
this._assertNotDestroyed();
|
|
378
510
|
return this.manager.nextPage();
|
|
379
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* Goto any page (index range: 0..n-1)
|
|
514
|
+
*/
|
|
515
|
+
jumpPage(index) {
|
|
516
|
+
this._assertNotDestroyed();
|
|
517
|
+
return this.manager.jumpPage(index);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Add one page to the main whiteboard view.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* addPage({ after: true }) // add one page right after current one.
|
|
524
|
+
* nextPage() // then, goto that page.
|
|
525
|
+
*/
|
|
380
526
|
addPage(params) {
|
|
381
527
|
this._assertNotDestroyed();
|
|
382
528
|
return this.manager.addPage(params);
|
|
383
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Remove one page at given index or current page (by default).
|
|
532
|
+
*
|
|
533
|
+
* Requires `@netless/window-manager` >= 0.4.30.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* removePage() // remove current page
|
|
537
|
+
*/
|
|
384
538
|
removePage(index) {
|
|
385
539
|
this._assertNotDestroyed();
|
|
386
540
|
return this.manager.removePage(index);
|
|
387
541
|
}
|
|
388
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Insert an image to the main view.
|
|
544
|
+
*
|
|
545
|
+
* @param crossOrigin Whether to load the image with CORS enabled, default is `true`.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* insertImage("https://i.imgur.com/CzXTtJV.jpg")
|
|
549
|
+
*/
|
|
550
|
+
async insertImage(url, crossOrigin) {
|
|
389
551
|
this._assertNotDestroyed();
|
|
390
552
|
await this.manager.switchMainViewToWriter();
|
|
391
553
|
const { divElement } = this.manager.mainView;
|
|
@@ -394,13 +556,21 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
394
556
|
height: (divElement == null ? void 0 : divElement.scrollHeight) || window.innerHeight
|
|
395
557
|
};
|
|
396
558
|
const maxWidth = containerSize.width * 0.8;
|
|
397
|
-
let { width, height } = await getImageSize(url, containerSize);
|
|
559
|
+
let { width, height } = await getImageSize(url, containerSize, crossOrigin);
|
|
398
560
|
const scale = Math.min(maxWidth / width, 1);
|
|
399
561
|
const uuid = genUID();
|
|
400
562
|
const { centerX, centerY } = this.manager.camera;
|
|
401
563
|
width *= scale;
|
|
402
564
|
height *= scale;
|
|
403
|
-
this.manager.mainView.insertImage({
|
|
565
|
+
this.manager.mainView.insertImage({
|
|
566
|
+
uuid,
|
|
567
|
+
centerX,
|
|
568
|
+
centerY,
|
|
569
|
+
width,
|
|
570
|
+
height,
|
|
571
|
+
locked: false,
|
|
572
|
+
crossOrigin
|
|
573
|
+
});
|
|
404
574
|
this.manager.mainView.completeImageUpload(uuid, url);
|
|
405
575
|
width /= 0.8;
|
|
406
576
|
height /= 0.8;
|
|
@@ -443,6 +613,7 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
443
613
|
throw new Error("Invalid input: not found 'progress', 'prefix' nor 'images'");
|
|
444
614
|
}
|
|
445
615
|
}
|
|
616
|
+
/** @internal */
|
|
446
617
|
_insertDocsImpl(_a) {
|
|
447
618
|
var _b = _a, { fileType, scenePath, title, scenes } = _b, attributes = __objRest(_b, ["fileType", "scenePath", "title", "scenes"]);
|
|
448
619
|
this._assertNotDestroyed();
|
|
@@ -463,6 +634,9 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
463
634
|
});
|
|
464
635
|
}
|
|
465
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* Insert the Media Player app.
|
|
639
|
+
*/
|
|
466
640
|
insertMedia(title, src) {
|
|
467
641
|
this._assertNotDestroyed();
|
|
468
642
|
return this.manager.addApp({
|
|
@@ -471,6 +645,10 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
471
645
|
attributes: { src }
|
|
472
646
|
});
|
|
473
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Insert the Monaco Code Editor app.
|
|
650
|
+
* @deprecated Use `app.manager.addApp({ kind: 'Monaco' })` instead.
|
|
651
|
+
*/
|
|
474
652
|
insertCodeEditor() {
|
|
475
653
|
this._assertNotDestroyed();
|
|
476
654
|
return this.manager.addApp({
|
|
@@ -478,6 +656,10 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
478
656
|
options: { title: "Code Editor" }
|
|
479
657
|
});
|
|
480
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Insert the Countdown app.
|
|
661
|
+
* @deprecated Use `app.manager.addApp({ kind: 'Countdown' })` instead.
|
|
662
|
+
*/
|
|
481
663
|
insertCountdown() {
|
|
482
664
|
this._assertNotDestroyed();
|
|
483
665
|
return this.manager.addApp({
|
|
@@ -485,6 +667,10 @@ var FastboardApp = class extends FastboardAppBase {
|
|
|
485
667
|
options: { title: "Countdown" }
|
|
486
668
|
});
|
|
487
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* Insert the GeoGebra app.
|
|
672
|
+
* @deprecated Use `app.manager.addApp({ kind: 'GeoGebra' })` instead.
|
|
673
|
+
*/
|
|
488
674
|
insertGeoGebra() {
|
|
489
675
|
this._assertNotDestroyed();
|
|
490
676
|
return this.manager.addApp({
|
|
@@ -552,21 +738,25 @@ var FastboardPlayerBase = class {
|
|
|
552
738
|
this.syncedStore = syncedStore;
|
|
553
739
|
__publicField(this, "_destroyed", false);
|
|
554
740
|
}
|
|
741
|
+
/** @internal */
|
|
555
742
|
_assertNotDestroyed() {
|
|
556
743
|
if (this._destroyed) {
|
|
557
744
|
throw new Error("FastboardApp has been destroyed");
|
|
558
745
|
}
|
|
559
746
|
}
|
|
747
|
+
/** @internal */
|
|
560
748
|
_addPlayerListener(name, listener) {
|
|
561
749
|
this._assertNotDestroyed();
|
|
562
750
|
this.player.callbacks.on(name, listener);
|
|
563
751
|
return () => this.player.callbacks.off(name, listener);
|
|
564
752
|
}
|
|
753
|
+
/** @internal */
|
|
565
754
|
_addManagerListener(name, listener) {
|
|
566
755
|
this._assertNotDestroyed();
|
|
567
756
|
this.manager.emitter.on(name, listener);
|
|
568
757
|
return () => this.manager.emitter.off(name, listener);
|
|
569
758
|
}
|
|
759
|
+
/** @internal */
|
|
570
760
|
_addMainViewListener(name, listener) {
|
|
571
761
|
this._assertNotDestroyed();
|
|
572
762
|
this.manager.mainView.callbacks.on(name, listener);
|
|
@@ -581,6 +771,9 @@ var FastboardPlayerBase = class {
|
|
|
581
771
|
var FastboardPlayer = class extends FastboardPlayerBase {
|
|
582
772
|
constructor() {
|
|
583
773
|
super(...arguments);
|
|
774
|
+
/**
|
|
775
|
+
* Player current time in milliseconds.
|
|
776
|
+
*/
|
|
584
777
|
__publicField(this, "currentTime", writable(
|
|
585
778
|
this.player.progressTime,
|
|
586
779
|
(set) => {
|
|
@@ -589,15 +782,25 @@ var FastboardPlayer = class extends FastboardPlayerBase {
|
|
|
589
782
|
},
|
|
590
783
|
this.player.seekToProgressTime.bind(this.player)
|
|
591
784
|
));
|
|
785
|
+
/**
|
|
786
|
+
* Player state, like "is it playing?".
|
|
787
|
+
*/
|
|
592
788
|
__publicField(this, "phase", readable(this.player.phase, (set) => {
|
|
593
789
|
set(this.player.phase);
|
|
594
790
|
return this._addPlayerListener("onPhaseChanged", set);
|
|
595
791
|
}));
|
|
792
|
+
/**
|
|
793
|
+
* Will become true after buffering.
|
|
794
|
+
*/
|
|
596
795
|
__publicField(this, "canplay", readable(this.player.isPlayable, (set) => {
|
|
597
796
|
set(this.player.isPlayable);
|
|
598
797
|
return this._addPlayerListener("onIsPlayableChanged", set);
|
|
599
798
|
}));
|
|
799
|
+
/** @internal */
|
|
600
800
|
__publicField(this, "_setPlaybackRate");
|
|
801
|
+
/**
|
|
802
|
+
* Playback speed, default `1`.
|
|
803
|
+
*/
|
|
601
804
|
__publicField(this, "playbackRate", writable(
|
|
602
805
|
this.player.playbackSpeed,
|
|
603
806
|
(set) => {
|
|
@@ -609,38 +812,65 @@ var FastboardPlayer = class extends FastboardPlayerBase {
|
|
|
609
812
|
this._setPlaybackRate(value);
|
|
610
813
|
}
|
|
611
814
|
));
|
|
815
|
+
/**
|
|
816
|
+
* Playback duration in milliseconds.
|
|
817
|
+
*/
|
|
612
818
|
__publicField(this, "duration", readable(this.player.timeDuration, (set) => {
|
|
613
819
|
set(this.player.timeDuration);
|
|
614
820
|
}));
|
|
821
|
+
/**
|
|
822
|
+
* Get state of room at that time, like "who was in the room?".
|
|
823
|
+
*/
|
|
615
824
|
__publicField(this, "state", readable(this.player.state, (set) => {
|
|
616
825
|
set(this.player.state);
|
|
617
826
|
return this._addPlayerListener("onPlayerStateChanged", () => set(this.player.state));
|
|
618
827
|
}));
|
|
619
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Render this player to some DOM.
|
|
831
|
+
*/
|
|
620
832
|
bindContainer(container) {
|
|
621
833
|
this._assertNotDestroyed();
|
|
622
834
|
this.manager.bindContainer(container);
|
|
623
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Move window-manager's collector to some place.
|
|
838
|
+
*/
|
|
624
839
|
bindCollector(container) {
|
|
625
840
|
this._assertNotDestroyed();
|
|
626
841
|
this.manager.bindCollectorContainer(container);
|
|
627
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* Seek to some time in milliseconds.
|
|
845
|
+
*/
|
|
628
846
|
seek(timestamp) {
|
|
629
847
|
this._assertNotDestroyed();
|
|
630
848
|
return this.player.seekToProgressTime(timestamp);
|
|
631
849
|
}
|
|
850
|
+
/**
|
|
851
|
+
* Change player state to playing.
|
|
852
|
+
*/
|
|
632
853
|
play() {
|
|
633
854
|
this._assertNotDestroyed();
|
|
634
855
|
this.player.play();
|
|
635
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Change player state to paused.
|
|
859
|
+
*/
|
|
636
860
|
pause() {
|
|
637
861
|
this._assertNotDestroyed();
|
|
638
862
|
this.player.pause();
|
|
639
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* Change player state to stopped.
|
|
866
|
+
*/
|
|
640
867
|
stop() {
|
|
641
868
|
this._assertNotDestroyed();
|
|
642
869
|
this.player.stop();
|
|
643
870
|
}
|
|
871
|
+
/**
|
|
872
|
+
* Set playback speed, a shortcut for `speed.set(x)`.
|
|
873
|
+
*/
|
|
644
874
|
setPlaybackRate(value) {
|
|
645
875
|
this._assertNotDestroyed();
|
|
646
876
|
this.playbackRate.set(value);
|
|
@@ -773,7 +1003,10 @@ function dispatchDocsEvent(fastboard, event, options = {}) {
|
|
|
773
1003
|
}
|
|
774
1004
|
}
|
|
775
1005
|
|
|
776
|
-
exports
|
|
1006
|
+
Object.defineProperty(exports, 'SlideApp', {
|
|
1007
|
+
enumerable: true,
|
|
1008
|
+
get: function () { return SlideApp__default.default; }
|
|
1009
|
+
});
|
|
777
1010
|
Object.defineProperty(exports, 'addSlideHooks', {
|
|
778
1011
|
enumerable: true,
|
|
779
1012
|
get: function () { return SlideApp.addHooks; }
|
|
@@ -804,5 +1037,4 @@ exports.replayFastboard = replayFastboard;
|
|
|
804
1037
|
exports.version = version;
|
|
805
1038
|
exports.warn = warn;
|
|
806
1039
|
exports.writable = writable;
|
|
807
|
-
//# sourceMappingURL=
|
|
808
|
-
//# sourceMappingURL=index.js.map
|
|
1040
|
+
//# sourceMappingURL=index.js.map
|