@netless/fastboard-react 0.1.1 → 0.2.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/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@netless/fastboard-react",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A UI kit built on top of @netless/fastboard.",
5
5
  "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "src/index.ts",
8
- "sideEffects": false,
9
6
  "files": [
10
7
  "src",
11
8
  "dist"
@@ -13,30 +10,38 @@
13
10
  "dependencies": {
14
11
  "@tippyjs/react": "^4.2.6",
15
12
  "clsx": "^1.1.1",
16
- "framer-motion": "^5.6.0",
17
- "i18next": "^21.6.6",
13
+ "framer-motion": "^6.2.1",
14
+ "i18next": "^21.6.7",
18
15
  "rc-slider": "^9.7.5"
19
16
  },
20
17
  "peerDependencies": {
21
- "@netless/fastboard": "*",
18
+ "@netless/fastboard-core": "*",
22
19
  "@netless/window-manager": ">=0.4.0",
23
20
  "react": "*",
24
21
  "react-dom": "*",
25
22
  "white-web-sdk": ">=2.16.0"
26
23
  },
27
24
  "devDependencies": {
28
- "@netless/app-slide": "^0.0.55",
29
- "@netless/fastboard": "0.1.1",
30
- "@netless/window-manager": "^0.4.0-canary.17",
25
+ "@netless/app-slide": "^0.0.56",
26
+ "@netless/fastboard-core": "0.2.0",
27
+ "@netless/window-manager": "^0.4.0-canary.24",
31
28
  "@types/react": "^17.0.38",
32
29
  "@types/react-dom": "^17.0.11",
33
30
  "sass": "^1.49.0",
34
31
  "tippy.js": "^6.3.7",
35
32
  "tsup": "^5.11.11",
36
- "white-web-sdk": "^2.16.0"
33
+ "white-web-sdk": "^2.16.1"
34
+ },
35
+ "publishConfig": {
36
+ "main": "dist/index.js",
37
+ "module": "dist/index.mjs",
38
+ "types": "src/index.ts"
37
39
  },
38
40
  "scripts": {
39
41
  "build": "tsup",
40
- "cleanup": "rimraf dist"
41
- }
42
+ "cleanup": "rimraf dist",
43
+ "check": "tsc --noEmit"
44
+ },
45
+ "module": "dist/index.mjs",
46
+ "types": "src/index.ts"
42
47
  }
@@ -1,4 +1,4 @@
1
- import type { FastboardApp } from "@netless/fastboard";
1
+ import type { FastboardApp } from "@netless/fastboard-core";
2
2
  import type { ForwardedRef } from "react";
3
3
  import type { Language, Theme } from "../typings";
4
4
 
@@ -21,20 +21,19 @@ export interface FastboardProps {
21
21
  export type DivProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
22
22
  export type WithForwardedRef<T = HTMLDivElement> = { forwardedRef: ForwardedRef<T> };
23
23
 
24
- export const Fastboard = forwardRef<HTMLDivElement, FastboardProps & DivProps>(function Fastboard(
25
- { app, theme, layout, language, ...restProps },
26
- ref
27
- ) {
28
- if (!app) {
29
- return <div className="fastboard-root" ref={ref} {...restProps} />;
30
- }
24
+ export const Fastboard = /* @__PURE__ */ forwardRef<HTMLDivElement, FastboardProps & DivProps>(
25
+ function Fastboard({ app, theme, layout, language, ...restProps }, ref) {
26
+ if (!app) {
27
+ return <div className="fastboard-root" ref={ref} {...restProps} />;
28
+ }
31
29
 
32
- return (
33
- <FastboardAppContext.Provider value={app}>
34
- <FastboardInternal forwardedRef={ref} {...{ theme, layout, language }} {...restProps} />
35
- </FastboardAppContext.Provider>
36
- );
37
- });
30
+ return (
31
+ <FastboardAppContext.Provider value={app}>
32
+ <FastboardInternal forwardedRef={ref} {...{ theme, layout, language }} {...restProps} />
33
+ </FastboardAppContext.Provider>
34
+ );
35
+ }
36
+ );
38
37
 
39
38
  function FastboardInternal({
40
39
  forwardedRef,
@@ -1,4 +1,4 @@
1
- import type { FastboardApp, FastboardReadable } from "@netless/fastboard";
1
+ import type { FastboardApp, FastboardReadable } from "@netless/fastboard-core";
2
2
  import type { Theme } from "../typings";
3
3
 
4
4
  import { BuiltinApps } from "@netless/window-manager";
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from "./components/PageControl";
8
8
  export * from "./components/Toolbar";
9
9
  export * from "./components/PlayerControl";
10
10
  export * from "./components/Fastboard";
11
+ export * from "./vanilla";
@@ -0,0 +1,18 @@
1
+ import type { FastboardApp } from "@netless/fastboard-core";
2
+ import type { DivProps, FastboardProps } from "../components/Fastboard";
3
+
4
+ import React from "react";
5
+ import ReactDOM from "react-dom";
6
+ import { Fastboard } from "../components/Fastboard";
7
+
8
+ /**
9
+ * Mount fastboard app to some dom, returns the disposer, which will unmount the app.
10
+ * @example
11
+ * let app = await createFastboard({ ...config })
12
+ * let disposer = mount(app, document.getElementById("whiteboard"))
13
+ * disposer()
14
+ */
15
+ export function mount(app: FastboardApp, dom: HTMLElement, props: Omit<FastboardProps & DivProps, "ref">) {
16
+ ReactDOM.render(<Fastboard app={app} {...props} />, dom);
17
+ return () => ReactDOM.unmountComponentAtNode(dom);
18
+ }