@netless/fastboard-ui 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 +30 -1
- package/dist/index.js +81 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -16
- package/dist/index.mjs.map +1 -1
- package/dist/index.svelte.mjs +79 -16
- package/dist/index.svelte.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/Fastboard/Fastboard.svelte +6 -2
- package/src/components/Fastboard/ReplayFastboard.svelte +6 -2
- package/src/helpers/index.ts +94 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/fastboard-ui",
|
|
3
|
-
"version": "0.3.4
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "The front-end of @netless/fastboard-core.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"svelte": "dist/index.svelte.mjs",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": "netless-io/fastboard",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@netless/fastboard-core": "0.3.4
|
|
13
|
+
"@netless/fastboard-core": "0.3.4"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"tippy.js": "^6.3.7"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@netless/esbuild-plugin-inline-sass": "0.1.0",
|
|
20
|
-
"@netless/fastboard-core": "0.3.4
|
|
20
|
+
"@netless/fastboard-core": "0.3.4"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"cleanup": "rimraf dist",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
let container: HTMLDivElement;
|
|
23
23
|
let layout: "hidden" | "toolbar-only" | "visible" = "hidden";
|
|
24
|
+
let mounted = false;
|
|
24
25
|
|
|
25
26
|
$: writable = app?.writable;
|
|
26
27
|
$: boxState = app?.boxState;
|
|
@@ -39,13 +40,16 @@
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
$: try {
|
|
42
|
-
if (app && container)
|
|
43
|
+
if (app && container) {
|
|
44
|
+
app.bindContainer(container);
|
|
45
|
+
mounted = true;
|
|
46
|
+
}
|
|
43
47
|
} catch (err) {
|
|
44
48
|
console.error("[fastboard] An error occurred while binding container");
|
|
45
49
|
console.error(err);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
$: if (app && theme) {
|
|
52
|
+
$: if (app && theme && mounted) {
|
|
49
53
|
app.manager.setPrefersColorScheme(theme);
|
|
50
54
|
}
|
|
51
55
|
|
|
@@ -15,15 +15,19 @@
|
|
|
15
15
|
const name = "fastboard";
|
|
16
16
|
|
|
17
17
|
let container: HTMLDivElement;
|
|
18
|
+
let mounted = false;
|
|
18
19
|
|
|
19
20
|
$: try {
|
|
20
|
-
if (player && container)
|
|
21
|
+
if (player && container) {
|
|
22
|
+
player.bindContainer(container);
|
|
23
|
+
mounted = true;
|
|
24
|
+
}
|
|
21
25
|
} catch (err) {
|
|
22
26
|
console.error("[fastboard] An error occurred while binding container");
|
|
23
27
|
console.error(err);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
$: if (player && theme) {
|
|
30
|
+
$: if (player && theme && mounted) {
|
|
27
31
|
player.manager.setPrefersColorScheme(theme);
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { FastboardApp, FastboardPlayer } from "@netless/fastboard-core";
|
|
2
|
+
import type { FastboardProps, ReplayFastboardProps } from "../components/Fastboard";
|
|
3
|
+
|
|
4
|
+
import { Fastboard, ReplayFastboard } from "../components/Fastboard";
|
|
5
|
+
|
|
6
|
+
export interface UI {
|
|
7
|
+
/** render UI to div */
|
|
8
|
+
mount(div: Element, props?: Omit<FastboardProps, "app">): UI;
|
|
9
|
+
/** update UI (theme, language, etc.) */
|
|
10
|
+
update(props?: Omit<FastboardProps, "app">): void;
|
|
11
|
+
/** remove UI */
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @example
|
|
17
|
+
* let ui = createUI(fastboardApp, document.getElementById("whiteboard"));
|
|
18
|
+
* ui.update({ theme: "dark" })
|
|
19
|
+
*/
|
|
20
|
+
export function createUI(app: FastboardApp, div?: Element): UI {
|
|
21
|
+
let fastboard: Fastboard | undefined;
|
|
22
|
+
|
|
23
|
+
const ui: UI = {
|
|
24
|
+
mount(div: Element, props?: Omit<FastboardProps, "app">) {
|
|
25
|
+
if (fastboard) {
|
|
26
|
+
fastboard.$destroy();
|
|
27
|
+
}
|
|
28
|
+
fastboard = new Fastboard({ target: div, props: { app, ...props } });
|
|
29
|
+
return ui;
|
|
30
|
+
},
|
|
31
|
+
update(props?: Omit<FastboardProps, "app">) {
|
|
32
|
+
if (fastboard) {
|
|
33
|
+
fastboard.$set(props);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
destroy() {
|
|
37
|
+
if (fastboard) {
|
|
38
|
+
fastboard.$destroy();
|
|
39
|
+
}
|
|
40
|
+
fastboard = undefined;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (div) {
|
|
45
|
+
ui.mount(div);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ui;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ReplayUI {
|
|
52
|
+
/** render UI to div */
|
|
53
|
+
mount(div: Element, props?: Omit<ReplayFastboardProps, "player">): ReplayUI;
|
|
54
|
+
/** update UI (theme, language, etc.) */
|
|
55
|
+
update(props?: Omit<ReplayFastboardProps, "player">): void;
|
|
56
|
+
/** remove UI */
|
|
57
|
+
destroy(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @example
|
|
62
|
+
* let ui = createReplayUI(fastboardPlayer, document.getElementById("whiteboard"));
|
|
63
|
+
* ui.update({ theme: "dark" })
|
|
64
|
+
*/
|
|
65
|
+
export function createReplayUI(player: FastboardPlayer, div?: Element): ReplayUI {
|
|
66
|
+
let fastboard: ReplayFastboard | undefined;
|
|
67
|
+
|
|
68
|
+
const ui: ReplayUI = {
|
|
69
|
+
mount(div: Element, props?: Omit<ReplayFastboardProps, "player">) {
|
|
70
|
+
if (fastboard) {
|
|
71
|
+
fastboard.$destroy();
|
|
72
|
+
}
|
|
73
|
+
fastboard = new ReplayFastboard({ target: div, props: { player, ...props } });
|
|
74
|
+
return ui;
|
|
75
|
+
},
|
|
76
|
+
update(props?: Omit<ReplayFastboardProps, "player">) {
|
|
77
|
+
if (fastboard) {
|
|
78
|
+
fastboard.$set(props);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
destroy() {
|
|
82
|
+
if (fastboard) {
|
|
83
|
+
fastboard.$destroy();
|
|
84
|
+
}
|
|
85
|
+
fastboard = undefined;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
if (div) {
|
|
90
|
+
ui.mount(div);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return ui;
|
|
94
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { default as PlayerControl, type PlayerControlProps } from "./components/
|
|
|
8
8
|
export { Fastboard, ReplayFastboard } from "./components/Fastboard";
|
|
9
9
|
export type { FastboardProps, ReplayFastboardProps } from "./components/Fastboard";
|
|
10
10
|
|
|
11
|
+
export * from "./helpers";
|
|
11
12
|
export * from "./behaviors";
|
|
12
13
|
|
|
13
14
|
import "./style.scss";
|