@netless/fastboard-react 1.0.0-canary.2 → 1.0.0-canary.3
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 +3 -4
- package/dist/index.js +47 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -6
- package/src/create.ts +6 -2
- package/src/hooks.tsx +4 -3
- package/src/replay.ts +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FastboardOptions, FastboardReplayOptions, FastboardApp, FastboardPlayer } from '@netless/fastboard-core';
|
|
1
|
+
import { FastboardOptions, FastboardApp, FastboardReplayOptions, FastboardPlayer } from '@netless/fastboard-core';
|
|
3
2
|
export * from '@netless/fastboard-core';
|
|
4
3
|
import { RedoUndoProps, ZoomControlProps, PageControlProps, ToolbarProps, FastboardProps, ReplayFastboardProps } from '@netless/fastboard-ui';
|
|
5
4
|
export { AppInToolbar, AppsInToolbar, FastboardProps, FastboardUIConfig, GenericIcon, Language, PageControlProps, RedoUndoProps, ReplayFastboardProps, Theme, ToolbarProps, ZoomControlProps, apps } from '@netless/fastboard-ui';
|
|
@@ -32,7 +31,7 @@ declare const ReplayFastboard: react.FunctionComponent<ReplayFastboardProps>;
|
|
|
32
31
|
* },
|
|
33
32
|
* })
|
|
34
33
|
*/
|
|
35
|
-
declare function createFastboard<TEventData = any>(options: FastboardOptions): Promise<
|
|
34
|
+
declare function createFastboard<TEventData = any>(options: FastboardOptions): Promise<FastboardApp<TEventData>>;
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* Create a FastboardPlayer instance.
|
|
@@ -50,7 +49,7 @@ declare function createFastboard<TEventData = any>(options: FastboardOptions): P
|
|
|
50
49
|
* },
|
|
51
50
|
* })
|
|
52
51
|
*/
|
|
53
|
-
declare function replayFastboard<TEventData = any>(options: FastboardReplayOptions): Promise<
|
|
52
|
+
declare function replayFastboard<TEventData = any>(options: FastboardReplayOptions): Promise<FastboardPlayer<TEventData>>;
|
|
54
53
|
|
|
55
54
|
declare function useFastboard(config: () => FastboardOptions): FastboardApp | null;
|
|
56
55
|
declare function useReplayFastboard(config: () => FastboardReplayOptions): FastboardPlayer | null;
|
package/dist/index.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var fastboardCore = require('@netless/fastboard-core');
|
|
6
6
|
var fastboardUi = require('@netless/fastboard-ui');
|
|
7
|
-
var React = require('react');
|
|
8
7
|
var windowManager = require('@netless/window-manager');
|
|
9
8
|
var NetlessAppSlide = require('@netless/app-slide');
|
|
9
|
+
var React = require('react');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
13
|
var NetlessAppSlide__default = /*#__PURE__*/_interopDefaultLegacy(NetlessAppSlide);
|
|
14
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
15
|
|
|
16
16
|
// inline-sass-helper:inline-sass-style-helper.js
|
|
17
17
|
function injectStyle(text) {
|
|
@@ -28,6 +28,47 @@ var style_default = '.netless-window-manager-playground{width:100%;height:100%;p
|
|
|
28
28
|
|
|
29
29
|
// inline-sass-stub:./src/style.scss
|
|
30
30
|
injectStyle(style_default);
|
|
31
|
+
function registerSlide() {
|
|
32
|
+
if (windowManager.WindowManager.registered.has(NetlessAppSlide__default["default"].kind))
|
|
33
|
+
return;
|
|
34
|
+
windowManager.WindowManager.register({
|
|
35
|
+
kind: NetlessAppSlide__default["default"].kind,
|
|
36
|
+
appOptions: { debug: false },
|
|
37
|
+
src: NetlessAppSlide__default["default"],
|
|
38
|
+
addHooks: NetlessAppSlide.addHooks
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
var DefaultApps = {};
|
|
42
|
+
function registerDefaultApps() {
|
|
43
|
+
Object.keys(DefaultApps).forEach((kind) => {
|
|
44
|
+
if (windowManager.WindowManager.registered.has(kind))
|
|
45
|
+
return;
|
|
46
|
+
windowManager.WindowManager.register({ kind, ...DefaultApps[kind] });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
var injected = false;
|
|
50
|
+
function ensureNetlessUA() {
|
|
51
|
+
if (typeof window !== "undefined" && !injected) {
|
|
52
|
+
injected = true;
|
|
53
|
+
let str = window.__netlessUA || "";
|
|
54
|
+
str += ` ${fastboardCore.name}/${fastboardCore.version} `;
|
|
55
|
+
window.__netlessUA = str;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/create.ts
|
|
60
|
+
async function createFastboard(options) {
|
|
61
|
+
ensureNetlessUA();
|
|
62
|
+
registerSlide();
|
|
63
|
+
registerDefaultApps();
|
|
64
|
+
return fastboardCore.createFastboardCore(options);
|
|
65
|
+
}
|
|
66
|
+
async function replayFastboard(options) {
|
|
67
|
+
ensureNetlessUA();
|
|
68
|
+
registerSlide();
|
|
69
|
+
registerDefaultApps();
|
|
70
|
+
return fastboardCore.replayFastboardCore(options);
|
|
71
|
+
}
|
|
31
72
|
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
32
73
|
function useUpdateEffect(effect, deps) {
|
|
33
74
|
const isFirst = React.useRef(true);
|
|
@@ -39,7 +80,7 @@ function useUpdateEffect(effect, deps) {
|
|
|
39
80
|
return effect();
|
|
40
81
|
}, deps);
|
|
41
82
|
}
|
|
42
|
-
function wrapReactComponent(SvelteComponent,
|
|
83
|
+
function wrapReactComponent(SvelteComponent, name2) {
|
|
43
84
|
function ReactComponent(props) {
|
|
44
85
|
const [container, setContainer] = React.useState(null);
|
|
45
86
|
const component = React.useRef(null);
|
|
@@ -63,7 +104,7 @@ function wrapReactComponent(SvelteComponent, name) {
|
|
|
63
104
|
ref: setContainer
|
|
64
105
|
});
|
|
65
106
|
}
|
|
66
|
-
ReactComponent.displayName =
|
|
107
|
+
ReactComponent.displayName = name2;
|
|
67
108
|
return ReactComponent;
|
|
68
109
|
}
|
|
69
110
|
function useFastboard(config) {
|
|
@@ -71,7 +112,7 @@ function useFastboard(config) {
|
|
|
71
112
|
const [fastboard, setFastboard] = React.useState(null);
|
|
72
113
|
React.useEffect(() => {
|
|
73
114
|
let fastboard2 = null;
|
|
74
|
-
|
|
115
|
+
createFastboard(config()).then((app) => {
|
|
75
116
|
if (!unmountRef.current) {
|
|
76
117
|
setFastboard(fastboard2 = app);
|
|
77
118
|
} else {
|
|
@@ -90,7 +131,7 @@ function useReplayFastboard(config) {
|
|
|
90
131
|
const [fastboard, setFastboard] = React.useState(null);
|
|
91
132
|
React.useEffect(() => {
|
|
92
133
|
let fastboard2 = null;
|
|
93
|
-
|
|
134
|
+
replayFastboard(config()).then((app) => {
|
|
94
135
|
if (!unmountRef.current) {
|
|
95
136
|
setFastboard(fastboard2 = app);
|
|
96
137
|
} else {
|
|
@@ -121,34 +162,6 @@ var ReplayFastboard = /* @__PURE__ */ wrapReactComponent(
|
|
|
121
162
|
fastboardUi.ReplayFastboard,
|
|
122
163
|
"ReplayFastboard"
|
|
123
164
|
);
|
|
124
|
-
function registerSlide() {
|
|
125
|
-
if (windowManager.WindowManager.registered.has(NetlessAppSlide__default["default"].kind))
|
|
126
|
-
return;
|
|
127
|
-
windowManager.WindowManager.register({
|
|
128
|
-
kind: NetlessAppSlide__default["default"].kind,
|
|
129
|
-
appOptions: { debug: false },
|
|
130
|
-
src: NetlessAppSlide__default["default"],
|
|
131
|
-
addHooks: NetlessAppSlide.addHooks
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
var DefaultApps = {};
|
|
135
|
-
function registerDefaultApps() {
|
|
136
|
-
Object.keys(DefaultApps).forEach((kind) => {
|
|
137
|
-
if (windowManager.WindowManager.registered.has(kind))
|
|
138
|
-
return;
|
|
139
|
-
windowManager.WindowManager.register({ kind, ...DefaultApps[kind] });
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async function createFastboard(options) {
|
|
143
|
-
registerSlide();
|
|
144
|
-
registerDefaultApps();
|
|
145
|
-
return fastboardCore.createFastboardCore(options);
|
|
146
|
-
}
|
|
147
|
-
async function replayFastboard(options) {
|
|
148
|
-
registerSlide();
|
|
149
|
-
registerDefaultApps();
|
|
150
|
-
return fastboardCore.replayFastboardCore(options);
|
|
151
|
-
}
|
|
152
165
|
|
|
153
166
|
Object.defineProperty(exports, 'apps', {
|
|
154
167
|
enumerable: true,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/RedoUndo.tsx","../src/hooks.tsx","../src/ZoomControl.tsx","../src/PageControl.tsx","../src/Toolbar.tsx","../src/Fastboard.tsx","../src/behaviors/netless-app.ts","../src/create.ts","../src/replay.ts"],"names":["fastboard","createFastboardCore","replayFastboardCore"],"mappings":";;;;;;;;;;;;;;;;;AAEA,cAAc;AACd,SAAS,YAAY;;;ACDrB,SAAS,YAAY,oBAAoB;;;ACQzC,SAAS,qBAAqB,2BAA2B;AACzD,OAAO,SAAS,WAAW,iBAAiB,QAAQ,gBAAgB;AAE7D,IAAM,4BAA4B,OAAO,aAAa,cAAc,kBAAkB;AAEtF,SAAS,gBAAgB,QAAwB,MAAuB;AAC7E,QAAM,UAAU,OAAO,IAAI;AAE3B,4BAA0B,MAAM;AAC9B,QAAI,QAAQ,SAAS;AACnB,cAAQ,UAAU;AAClB;AAAA,IACF;AAEA,WAAO,OAAO;AAAA,EAChB,GAAG,IAAI;AACT;AAEO,SAAS,mBACd,iBACA,MAC0B;AAC1B,WAAS,eAAe,OAAc;AACpC,UAAM,CAAC,WAAW,YAAY,IAAI,SAAgC,IAAI;AACtE,UAAM,YAAY,OAAmC,IAAI;AAEzD,8BAA0B,MAAM;AAC9B,UAAI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sourcesContent":["import \"./style.scss\";\n\nexport * from \"@netless/fastboard-core\";\nexport { apps } from \"@netless/fastboard-ui\";\nexport type {\n Theme,\n Language,\n GenericIcon,\n AppInToolbar,\n AppsInToolbar,\n FastboardUIConfig,\n} from \"@netless/fastboard-ui\";\nexport * from \"./RedoUndo\";\nexport * from \"./ZoomControl\";\nexport * from \"./PageControl\";\nexport * from \"./Toolbar\";\nexport * from \"./Fastboard\";\nexport * from \"./behaviors\";\nexport * from \"./create\";\nexport * from \"./replay\";\nexport { useFastboard, useReplayFastboard } from \"./hooks\";\n\n// Caution about Export Namespace (Star)\n// esbuild can not handle nested `export *`, i.e. given two files:\n//\n// foo: export * from './bar'\n// bar: export * from 'baz' (external: baz)\n//\n// the result of bundling foo will be broken.\n// `export * from external-module` works and only works at the entry points.\n// ref: https://github.com/evanw/esbuild/issues/1737\n","import type { RedoUndoProps } from \"@netless/fastboard-ui\";\n\nimport { RedoUndo as RedoUndoImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { RedoUndoProps };\n\nexport const RedoUndo = /* @__PURE__ */ wrapReactComponent<RedoUndoProps>(RedoUndoImpl, \"RedoUndo\");\n","/* eslint-disable react-hooks/exhaustive-deps */\nimport type {\n FastboardApp,\n FastboardOptions,\n FastboardPlayer,\n FastboardReplayOptions,\n} from \"@netless/fastboard-core\";\nimport type { DependencyList, EffectCallback, FunctionComponent } from \"react\";\nimport type { SvelteComponent as SvelteComponentType } from \"svelte\";\n\nimport { createFastboardCore, replayFastboardCore } from \"@netless/fastboard-core\";\nimport React, { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\nexport const useIsomorphicLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function useUpdateEffect(effect: EffectCallback, deps?: DependencyList) {\n const isFirst = useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (isFirst.current) {\n isFirst.current = false;\n return;\n }\n\n return effect();\n }, deps);\n}\n\nexport function wrapReactComponent<Props>(\n SvelteComponent: typeof SvelteComponentType,\n name: string\n): FunctionComponent<Props> {\n function ReactComponent(props: Props) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const component = useRef<SvelteComponentType | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (container) {\n component.current = new SvelteComponent({ target: container, props });\n\n return () => {\n if (component.current) {\n component.current.$destroy();\n }\n };\n }\n }, [container]);\n\n useUpdateEffect(() => {\n if (component.current) {\n component.current.$set(props);\n }\n }, [props]);\n\n return <div className=\"fastboard-react-div\" ref={setContainer} />;\n }\n\n ReactComponent.displayName = name;\n\n return ReactComponent;\n}\n\nexport function useFastboard(config: () => FastboardOptions): FastboardApp | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardApp | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardApp | null = null;\n\n createFastboardCore(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n\nexport function useReplayFastboard(config: () => FastboardReplayOptions): FastboardPlayer | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardPlayer | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardPlayer | null = null;\n\n replayFastboardCore(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n","import type { ZoomControlProps } from \"@netless/fastboard-ui\";\n\nimport { ZoomControl as ZoomControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ZoomControlProps };\n\nexport const ZoomControl = /* @__PURE__ */ wrapReactComponent<ZoomControlProps>(\n ZoomControlImpl,\n \"ZoomControl\"\n);\n","import type { PageControlProps } from \"@netless/fastboard-ui\";\n\nimport { PageControl as PageControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { PageControlProps };\n\nexport const PageControl = /* @__PURE__ */ wrapReactComponent<PageControlProps>(\n PageControlImpl,\n \"PageControl\"\n);\n","import type { ToolbarProps } from \"@netless/fastboard-ui\";\n\nimport { Toolbar as ToolbarImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ToolbarProps };\n\nexport const Toolbar = /* @__PURE__ */ wrapReactComponent<ToolbarProps>(ToolbarImpl, \"Toolbar\");\n","import type { FastboardProps, ReplayFastboardProps } from \"@netless/fastboard-ui\";\n\nimport { Fastboard as FastboardImpl, ReplayFastboard as ReplayFastboardImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { FastboardProps, ReplayFastboardProps };\n\nexport const Fastboard = /* @__PURE__ */ wrapReactComponent<FastboardProps>(FastboardImpl, \"Fastboard\");\nexport const ReplayFastboard = /* @__PURE__ */ wrapReactComponent<ReplayFastboardProps>(\n ReplayFastboardImpl,\n \"ReplayFastboard\"\n);\n","import type {\n AppOptions as NetlessAppSlideAppOptions,\n Attributes as NetlessAppSlideAttributes,\n SlideState,\n SlideViewerOptions,\n} from \"@netless/app-slide\";\nimport type { RegisterParams } from \"@netless/window-manager\";\n\nimport { WindowManager } from \"@netless/window-manager\";\n\nimport NetlessAppSlide, { addHooks, previewSlide, Slide, SlideViewer } from \"@netless/app-slide\";\n\nexport { Slide, SlideViewer, previewSlide };\nexport type { NetlessAppSlideAttributes, SlideState, SlideViewerOptions };\n\nexport function registerSlide() {\n if (WindowManager.registered.has(NetlessAppSlide.kind)) return;\n WindowManager.register({\n kind: NetlessAppSlide.kind,\n appOptions: { debug: false } as NetlessAppSlideAppOptions,\n src: NetlessAppSlide,\n addHooks,\n });\n}\n\nconst DefaultApps: {\n [kind: string]: Omit<RegisterParams, \"kind\">;\n} = {};\n\nexport function registerDefaultApps() {\n Object.keys(DefaultApps).forEach(kind => {\n if (WindowManager.registered.has(kind)) return;\n WindowManager.register({ kind, ...DefaultApps[kind] });\n });\n}\n","import type { FastboardOptions } from \"@netless/fastboard-core\";\n\nimport { createFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\n\n/**\n * Create a FastboardApp instance.\n * @example\n * let app = await createFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * joinRoom: {\n * uid: unique_id,\n * uuid: import.meta.env.VITE_ROOM_UUID,\n * roomToken: import.meta.env.VITE_ROOM_TOKEN,\n * },\n * })\n */\nexport async function createFastboard<TEventData = any>(options: FastboardOptions) {\n registerSlide();\n registerDefaultApps();\n return createFastboardCore<TEventData>(options);\n}\n","import type { FastboardReplayOptions } from \"@netless/fastboard-core\";\n\nimport { replayFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\n\n/**\n * Create a FastboardPlayer instance.\n * @example\n * let player = await replayFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * replayRoom: {\n * room: \"room uuid\",\n * roomToken: \"NETLESSROOM_...\",\n * beginTimestamp: 1646619090394,\n * duration: 70448,\n * },\n * })\n */\nexport async function replayFastboard<TEventData = any>(options: FastboardReplayOptions) {\n registerSlide();\n registerDefaultApps();\n return replayFastboardCore<TEventData>(options);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/RedoUndo.tsx","../src/create.ts","../src/behaviors/netless-app.ts","../src/behaviors/netless-ua.ts","../src/replay.ts","../src/hooks.tsx","../src/ZoomControl.tsx","../src/PageControl.tsx","../src/Toolbar.tsx","../src/Fastboard.tsx"],"names":["name","fastboard"],"mappings":";;;;;;;;;;;;;;;;;AAEA,cAAc;AACd,SAAS,YAAY;;;ACDrB,SAAS,YAA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AAIA,aAAoC;AAExC,oBAAgB,OAAO,CAAC,EAAE,KAAK,SAAO;AACpC,UAAI,CAAC,WAAW,SAAS;AACvB,qBAAcA,aAAY,GAAI;AAAA,MAChC,OAAO;AACL,YAAI,QAAQ;AAAA,MACd;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,iBAAW,UAAU;AACrB,MAAAA,cAAaA,WAAU,QAAQ;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;;;ALtGO,IAAM,WAA2B,mCAAkC,cAAc,UAAU;;;AMLlG,SAAS,eAAe,uBAAuB;AAKxC,IAAM,cAA8B;AAAA,EACzC;AAAA,EACA;AACF;;;ACRA,SAAS,eAAe,uBAAuB;AAKxC,IAAM,cAA8B;AAAA,EACzC;AAAA,EACA;AACF;;;ACRA,SAAS,WAAW,mBAAmB;AAKhC,IAAM,UAA0B,mCAAiC,aAAa,SAAS;;;ACL9F,SAAS,aAAa,eAAe,mBAAmB,2BAA2B;AAK5E,IAAM,YAA4B,mCAAmC,eAAe,WAAW;AAC/F,IAAM,kBAAkC;AAAA,EAC7C;AAAA,EACA;AACF","sourcesContent":["import \"./style.scss\";\n\nexport * from \"@netless/fastboard-core\";\nexport { apps } from \"@netless/fastboard-ui\";\nexport type {\n Theme,\n Language,\n GenericIcon,\n AppInToolbar,\n AppsInToolbar,\n FastboardUIConfig,\n} from \"@netless/fastboard-ui\";\nexport * from \"./RedoUndo\";\nexport * from \"./ZoomControl\";\nexport * from \"./PageControl\";\nexport * from \"./Toolbar\";\nexport * from \"./Fastboard\";\nexport * from \"./behaviors\";\nexport * from \"./create\";\nexport * from \"./replay\";\nexport { useFastboard, useReplayFastboard } from \"./hooks\";\n\n// Caution about Export Namespace (Star)\n// esbuild can not handle nested `export *`, i.e. given two files:\n//\n// foo: export * from './bar'\n// bar: export * from 'baz' (external: baz)\n//\n// the result of bundling foo will be broken.\n// `export * from external-module` works and only works at the entry points.\n// ref: https://github.com/evanw/esbuild/issues/1737\n","import type { RedoUndoProps } from \"@netless/fastboard-ui\";\n\nimport { RedoUndo as RedoUndoImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { RedoUndoProps };\n\nexport const RedoUndo = /* @__PURE__ */ wrapReactComponent<RedoUndoProps>(RedoUndoImpl, \"RedoUndo\");\n","import type { FastboardApp, FastboardOptions } from \"@netless/fastboard-core\";\n\nimport { createFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\nimport { ensureNetlessUA } from \"./behaviors/netless-ua\";\n\n/**\n * Create a FastboardApp instance.\n * @example\n * let app = await createFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * joinRoom: {\n * uid: unique_id,\n * uuid: import.meta.env.VITE_ROOM_UUID,\n * roomToken: import.meta.env.VITE_ROOM_TOKEN,\n * },\n * })\n */\nexport async function createFastboard<TEventData = any>(\n options: FastboardOptions\n): Promise<FastboardApp<TEventData>> {\n ensureNetlessUA();\n registerSlide();\n registerDefaultApps();\n return createFastboardCore<TEventData>(options);\n}\n","import type {\n AppOptions as NetlessAppSlideAppOptions,\n Attributes as NetlessAppSlideAttributes,\n SlideState,\n SlideViewerOptions,\n} from \"@netless/app-slide\";\nimport type { RegisterParams } from \"@netless/window-manager\";\n\nimport { WindowManager } from \"@netless/window-manager\";\n\nimport NetlessAppSlide, { addHooks, previewSlide, Slide, SlideViewer } from \"@netless/app-slide\";\n\nexport { Slide, SlideViewer, previewSlide };\nexport type { NetlessAppSlideAttributes, SlideState, SlideViewerOptions };\n\nexport function registerSlide() {\n if (WindowManager.registered.has(NetlessAppSlide.kind)) return;\n WindowManager.register({\n kind: NetlessAppSlide.kind,\n appOptions: { debug: false } as NetlessAppSlideAppOptions,\n src: NetlessAppSlide,\n addHooks,\n });\n}\n\nconst DefaultApps: {\n [kind: string]: Omit<RegisterParams, \"kind\">;\n} = {};\n\nexport function registerDefaultApps() {\n Object.keys(DefaultApps).forEach(kind => {\n if (WindowManager.registered.has(kind)) return;\n WindowManager.register({ kind, ...DefaultApps[kind] });\n });\n}\n","import { name, version } from \"@netless/fastboard-core\";\n\ninterface InjectTarget {\n __netlessUA?: string;\n}\n\nlet injected = false;\nexport function ensureNetlessUA() {\n if (typeof window !== \"undefined\" && !injected) {\n injected = true;\n let str = (window as InjectTarget).__netlessUA || \"\";\n str += ` ${name}/${version} `;\n (window as InjectTarget).__netlessUA = str;\n }\n}\n","import type { FastboardPlayer, FastboardReplayOptions } from \"@netless/fastboard-core\";\n\nimport { replayFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\nimport { ensureNetlessUA } from \"./behaviors/netless-ua\";\n\n/**\n * Create a FastboardPlayer instance.\n * @example\n * let player = await replayFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * replayRoom: {\n * room: \"room uuid\",\n * roomToken: \"NETLESSROOM_...\",\n * beginTimestamp: 1646619090394,\n * duration: 70448,\n * },\n * })\n */\nexport async function replayFastboard<TEventData = any>(\n options: FastboardReplayOptions\n): Promise<FastboardPlayer<TEventData>> {\n ensureNetlessUA();\n registerSlide();\n registerDefaultApps();\n return replayFastboardCore<TEventData>(options);\n}\n","/* eslint-disable react-hooks/exhaustive-deps */\nimport type {\n FastboardApp,\n FastboardOptions,\n FastboardPlayer,\n FastboardReplayOptions,\n} from \"@netless/fastboard-core\";\nimport type { DependencyList, EffectCallback, FunctionComponent } from \"react\";\nimport type { SvelteComponent as SvelteComponentType } from \"svelte\";\n\nimport { createFastboard } from \"./create\";\nimport { replayFastboard } from \"./replay\";\nimport React, { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\nexport const useIsomorphicLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function useUpdateEffect(effect: EffectCallback, deps?: DependencyList) {\n const isFirst = useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (isFirst.current) {\n isFirst.current = false;\n return;\n }\n\n return effect();\n }, deps);\n}\n\nexport function wrapReactComponent<Props>(\n SvelteComponent: typeof SvelteComponentType,\n name: string\n): FunctionComponent<Props> {\n function ReactComponent(props: Props) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const component = useRef<SvelteComponentType | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (container) {\n component.current = new SvelteComponent({ target: container, props });\n\n return () => {\n if (component.current) {\n component.current.$destroy();\n }\n };\n }\n }, [container]);\n\n useUpdateEffect(() => {\n if (component.current) {\n component.current.$set(props);\n }\n }, [props]);\n\n return <div className=\"fastboard-react-div\" ref={setContainer} />;\n }\n\n ReactComponent.displayName = name;\n\n return ReactComponent;\n}\n\nexport function useFastboard(config: () => FastboardOptions): FastboardApp | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardApp | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardApp | null = null;\n\n createFastboard(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n\nexport function useReplayFastboard(config: () => FastboardReplayOptions): FastboardPlayer | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardPlayer | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardPlayer | null = null;\n\n replayFastboard(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n","import type { ZoomControlProps } from \"@netless/fastboard-ui\";\n\nimport { ZoomControl as ZoomControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ZoomControlProps };\n\nexport const ZoomControl = /* @__PURE__ */ wrapReactComponent<ZoomControlProps>(\n ZoomControlImpl,\n \"ZoomControl\"\n);\n","import type { PageControlProps } from \"@netless/fastboard-ui\";\n\nimport { PageControl as PageControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { PageControlProps };\n\nexport const PageControl = /* @__PURE__ */ wrapReactComponent<PageControlProps>(\n PageControlImpl,\n \"PageControl\"\n);\n","import type { ToolbarProps } from \"@netless/fastboard-ui\";\n\nimport { Toolbar as ToolbarImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ToolbarProps };\n\nexport const Toolbar = /* @__PURE__ */ wrapReactComponent<ToolbarProps>(ToolbarImpl, \"Toolbar\");\n","import type { FastboardProps, ReplayFastboardProps } from \"@netless/fastboard-ui\";\n\nimport { Fastboard as FastboardImpl, ReplayFastboard as ReplayFastboardImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { FastboardProps, ReplayFastboardProps };\n\nexport const Fastboard = /* @__PURE__ */ wrapReactComponent<FastboardProps>(FastboardImpl, \"Fastboard\");\nexport const ReplayFastboard = /* @__PURE__ */ wrapReactComponent<ReplayFastboardProps>(\n ReplayFastboardImpl,\n \"ReplayFastboard\"\n);\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createFastboardCore, replayFastboardCore } from '@netless/fastboard-core';
|
|
1
|
+
import { createFastboardCore, replayFastboardCore, name, version } from '@netless/fastboard-core';
|
|
2
2
|
export * from '@netless/fastboard-core';
|
|
3
3
|
import { RedoUndo as RedoUndo$1, ZoomControl as ZoomControl$1, PageControl as PageControl$1, Toolbar as Toolbar$1, Fastboard as Fastboard$1, ReplayFastboard as ReplayFastboard$1 } from '@netless/fastboard-ui';
|
|
4
4
|
export { apps } from '@netless/fastboard-ui';
|
|
5
|
-
import React, { useRef, useState, useEffect, useLayoutEffect } from 'react';
|
|
6
5
|
import { WindowManager } from '@netless/window-manager';
|
|
7
6
|
import NetlessAppSlide, { addHooks } from '@netless/app-slide';
|
|
8
7
|
export { Slide, SlideViewer, previewSlide } from '@netless/app-slide';
|
|
8
|
+
import React, { useRef, useState, useEffect, useLayoutEffect } from 'react';
|
|
9
9
|
|
|
10
10
|
// inline-sass-helper:inline-sass-style-helper.js
|
|
11
11
|
function injectStyle(text) {
|
|
@@ -22,6 +22,47 @@ var style_default = '.netless-window-manager-playground{width:100%;height:100%;p
|
|
|
22
22
|
|
|
23
23
|
// inline-sass-stub:./src/style.scss
|
|
24
24
|
injectStyle(style_default);
|
|
25
|
+
function registerSlide() {
|
|
26
|
+
if (WindowManager.registered.has(NetlessAppSlide.kind))
|
|
27
|
+
return;
|
|
28
|
+
WindowManager.register({
|
|
29
|
+
kind: NetlessAppSlide.kind,
|
|
30
|
+
appOptions: { debug: false },
|
|
31
|
+
src: NetlessAppSlide,
|
|
32
|
+
addHooks
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var DefaultApps = {};
|
|
36
|
+
function registerDefaultApps() {
|
|
37
|
+
Object.keys(DefaultApps).forEach((kind) => {
|
|
38
|
+
if (WindowManager.registered.has(kind))
|
|
39
|
+
return;
|
|
40
|
+
WindowManager.register({ kind, ...DefaultApps[kind] });
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
var injected = false;
|
|
44
|
+
function ensureNetlessUA() {
|
|
45
|
+
if (typeof window !== "undefined" && !injected) {
|
|
46
|
+
injected = true;
|
|
47
|
+
let str = window.__netlessUA || "";
|
|
48
|
+
str += ` ${name}/${version} `;
|
|
49
|
+
window.__netlessUA = str;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/create.ts
|
|
54
|
+
async function createFastboard(options) {
|
|
55
|
+
ensureNetlessUA();
|
|
56
|
+
registerSlide();
|
|
57
|
+
registerDefaultApps();
|
|
58
|
+
return createFastboardCore(options);
|
|
59
|
+
}
|
|
60
|
+
async function replayFastboard(options) {
|
|
61
|
+
ensureNetlessUA();
|
|
62
|
+
registerSlide();
|
|
63
|
+
registerDefaultApps();
|
|
64
|
+
return replayFastboardCore(options);
|
|
65
|
+
}
|
|
25
66
|
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
26
67
|
function useUpdateEffect(effect, deps) {
|
|
27
68
|
const isFirst = useRef(true);
|
|
@@ -33,7 +74,7 @@ function useUpdateEffect(effect, deps) {
|
|
|
33
74
|
return effect();
|
|
34
75
|
}, deps);
|
|
35
76
|
}
|
|
36
|
-
function wrapReactComponent(SvelteComponent,
|
|
77
|
+
function wrapReactComponent(SvelteComponent, name2) {
|
|
37
78
|
function ReactComponent(props) {
|
|
38
79
|
const [container, setContainer] = useState(null);
|
|
39
80
|
const component = useRef(null);
|
|
@@ -57,7 +98,7 @@ function wrapReactComponent(SvelteComponent, name) {
|
|
|
57
98
|
ref: setContainer
|
|
58
99
|
});
|
|
59
100
|
}
|
|
60
|
-
ReactComponent.displayName =
|
|
101
|
+
ReactComponent.displayName = name2;
|
|
61
102
|
return ReactComponent;
|
|
62
103
|
}
|
|
63
104
|
function useFastboard(config) {
|
|
@@ -65,7 +106,7 @@ function useFastboard(config) {
|
|
|
65
106
|
const [fastboard, setFastboard] = useState(null);
|
|
66
107
|
useEffect(() => {
|
|
67
108
|
let fastboard2 = null;
|
|
68
|
-
|
|
109
|
+
createFastboard(config()).then((app) => {
|
|
69
110
|
if (!unmountRef.current) {
|
|
70
111
|
setFastboard(fastboard2 = app);
|
|
71
112
|
} else {
|
|
@@ -84,7 +125,7 @@ function useReplayFastboard(config) {
|
|
|
84
125
|
const [fastboard, setFastboard] = useState(null);
|
|
85
126
|
useEffect(() => {
|
|
86
127
|
let fastboard2 = null;
|
|
87
|
-
|
|
128
|
+
replayFastboard(config()).then((app) => {
|
|
88
129
|
if (!unmountRef.current) {
|
|
89
130
|
setFastboard(fastboard2 = app);
|
|
90
131
|
} else {
|
|
@@ -115,34 +156,6 @@ var ReplayFastboard = /* @__PURE__ */ wrapReactComponent(
|
|
|
115
156
|
ReplayFastboard$1,
|
|
116
157
|
"ReplayFastboard"
|
|
117
158
|
);
|
|
118
|
-
function registerSlide() {
|
|
119
|
-
if (WindowManager.registered.has(NetlessAppSlide.kind))
|
|
120
|
-
return;
|
|
121
|
-
WindowManager.register({
|
|
122
|
-
kind: NetlessAppSlide.kind,
|
|
123
|
-
appOptions: { debug: false },
|
|
124
|
-
src: NetlessAppSlide,
|
|
125
|
-
addHooks
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
var DefaultApps = {};
|
|
129
|
-
function registerDefaultApps() {
|
|
130
|
-
Object.keys(DefaultApps).forEach((kind) => {
|
|
131
|
-
if (WindowManager.registered.has(kind))
|
|
132
|
-
return;
|
|
133
|
-
WindowManager.register({ kind, ...DefaultApps[kind] });
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
async function createFastboard(options) {
|
|
137
|
-
registerSlide();
|
|
138
|
-
registerDefaultApps();
|
|
139
|
-
return createFastboardCore(options);
|
|
140
|
-
}
|
|
141
|
-
async function replayFastboard(options) {
|
|
142
|
-
registerSlide();
|
|
143
|
-
registerDefaultApps();
|
|
144
|
-
return replayFastboardCore(options);
|
|
145
|
-
}
|
|
146
159
|
|
|
147
160
|
export { Fastboard, PageControl, RedoUndo, ReplayFastboard, Toolbar, ZoomControl, createFastboard, replayFastboard, useFastboard, useReplayFastboard };
|
|
148
161
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/RedoUndo.tsx","../src/hooks.tsx","../src/ZoomControl.tsx","../src/PageControl.tsx","../src/Toolbar.tsx","../src/Fastboard.tsx","../src/behaviors/netless-app.ts","../src/create.ts","../src/replay.ts"],"names":["fastboard","createFastboardCore","replayFastboardCore"],"mappings":";;;;;;;;;;;;;;;;;A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AM,gBAAgB;AAAA,IACtB,YAAY,EAAE,OAAO,MAAM;AAAA,IAC3B,KAAK;AAAA,IACL;AAAA,EACF,CAAC;AACH;AAEA,IAAM,cAEF,CAAC;AAEE,SAAS,sBAAsB;AACpC,SAAO,KAAK,WAAW,EAAE,QAAQ,UAAQ;AACvC,QAAI,cAAc,WAAW,IAAI,IAAI;AAAG;AACxC,kBAAc,SAAS,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,EACvD,CAAC;AACH;;;AChCA,SAAS,uBAAAC,4BAA2B;AAkBpC,eAAsB,gBAAkC,SAA2B;AACjF,gBAAc;AACd,sBAAoB;AACpB,SAAOA,qBAAgC,OAAO;AAChD;;;ACtBA,SAAS,uBAAAC,4BAA2B;AAmBpC,eAAsB,gBAAkC,SAAiC;AACvF,gBAAc;AACd,sBAAoB;AACpB,SAAOA,qBAAgC,OAAO;AAChD","sourcesContent":["import \"./style.scss\";\n\nexport * from \"@netless/fastboard-core\";\nexport { apps } from \"@netless/fastboard-ui\";\nexport type {\n Theme,\n Language,\n GenericIcon,\n AppInToolbar,\n AppsInToolbar,\n FastboardUIConfig,\n} from \"@netless/fastboard-ui\";\nexport * from \"./RedoUndo\";\nexport * from \"./ZoomControl\";\nexport * from \"./PageControl\";\nexport * from \"./Toolbar\";\nexport * from \"./Fastboard\";\nexport * from \"./behaviors\";\nexport * from \"./create\";\nexport * from \"./replay\";\nexport { useFastboard, useReplayFastboard } from \"./hooks\";\n\n// Caution about Export Namespace (Star)\n// esbuild can not handle nested `export *`, i.e. given two files:\n//\n// foo: export * from './bar'\n// bar: export * from 'baz' (external: baz)\n//\n// the result of bundling foo will be broken.\n// `export * from external-module` works and only works at the entry points.\n// ref: https://github.com/evanw/esbuild/issues/1737\n","import type { RedoUndoProps } from \"@netless/fastboard-ui\";\n\nimport { RedoUndo as RedoUndoImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { RedoUndoProps };\n\nexport const RedoUndo = /* @__PURE__ */ wrapReactComponent<RedoUndoProps>(RedoUndoImpl, \"RedoUndo\");\n","/* eslint-disable react-hooks/exhaustive-deps */\nimport type {\n FastboardApp,\n FastboardOptions,\n FastboardPlayer,\n FastboardReplayOptions,\n} from \"@netless/fastboard-core\";\nimport type { DependencyList, EffectCallback, FunctionComponent } from \"react\";\nimport type { SvelteComponent as SvelteComponentType } from \"svelte\";\n\nimport { createFastboardCore, replayFastboardCore } from \"@netless/fastboard-core\";\nimport React, { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\nexport const useIsomorphicLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function useUpdateEffect(effect: EffectCallback, deps?: DependencyList) {\n const isFirst = useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (isFirst.current) {\n isFirst.current = false;\n return;\n }\n\n return effect();\n }, deps);\n}\n\nexport function wrapReactComponent<Props>(\n SvelteComponent: typeof SvelteComponentType,\n name: string\n): FunctionComponent<Props> {\n function ReactComponent(props: Props) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const component = useRef<SvelteComponentType | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (container) {\n component.current = new SvelteComponent({ target: container, props });\n\n return () => {\n if (component.current) {\n component.current.$destroy();\n }\n };\n }\n }, [container]);\n\n useUpdateEffect(() => {\n if (component.current) {\n component.current.$set(props);\n }\n }, [props]);\n\n return <div className=\"fastboard-react-div\" ref={setContainer} />;\n }\n\n ReactComponent.displayName = name;\n\n return ReactComponent;\n}\n\nexport function useFastboard(config: () => FastboardOptions): FastboardApp | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardApp | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardApp | null = null;\n\n createFastboardCore(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n\nexport function useReplayFastboard(config: () => FastboardReplayOptions): FastboardPlayer | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardPlayer | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardPlayer | null = null;\n\n replayFastboardCore(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n","import type { ZoomControlProps } from \"@netless/fastboard-ui\";\n\nimport { ZoomControl as ZoomControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ZoomControlProps };\n\nexport const ZoomControl = /* @__PURE__ */ wrapReactComponent<ZoomControlProps>(\n ZoomControlImpl,\n \"ZoomControl\"\n);\n","import type { PageControlProps } from \"@netless/fastboard-ui\";\n\nimport { PageControl as PageControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { PageControlProps };\n\nexport const PageControl = /* @__PURE__ */ wrapReactComponent<PageControlProps>(\n PageControlImpl,\n \"PageControl\"\n);\n","import type { ToolbarProps } from \"@netless/fastboard-ui\";\n\nimport { Toolbar as ToolbarImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ToolbarProps };\n\nexport const Toolbar = /* @__PURE__ */ wrapReactComponent<ToolbarProps>(ToolbarImpl, \"Toolbar\");\n","import type { FastboardProps, ReplayFastboardProps } from \"@netless/fastboard-ui\";\n\nimport { Fastboard as FastboardImpl, ReplayFastboard as ReplayFastboardImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { FastboardProps, ReplayFastboardProps };\n\nexport const Fastboard = /* @__PURE__ */ wrapReactComponent<FastboardProps>(FastboardImpl, \"Fastboard\");\nexport const ReplayFastboard = /* @__PURE__ */ wrapReactComponent<ReplayFastboardProps>(\n ReplayFastboardImpl,\n \"ReplayFastboard\"\n);\n","import type {\n AppOptions as NetlessAppSlideAppOptions,\n Attributes as NetlessAppSlideAttributes,\n SlideState,\n SlideViewerOptions,\n} from \"@netless/app-slide\";\nimport type { RegisterParams } from \"@netless/window-manager\";\n\nimport { WindowManager } from \"@netless/window-manager\";\n\nimport NetlessAppSlide, { addHooks, previewSlide, Slide, SlideViewer } from \"@netless/app-slide\";\n\nexport { Slide, SlideViewer, previewSlide };\nexport type { NetlessAppSlideAttributes, SlideState, SlideViewerOptions };\n\nexport function registerSlide() {\n if (WindowManager.registered.has(NetlessAppSlide.kind)) return;\n WindowManager.register({\n kind: NetlessAppSlide.kind,\n appOptions: { debug: false } as NetlessAppSlideAppOptions,\n src: NetlessAppSlide,\n addHooks,\n });\n}\n\nconst DefaultApps: {\n [kind: string]: Omit<RegisterParams, \"kind\">;\n} = {};\n\nexport function registerDefaultApps() {\n Object.keys(DefaultApps).forEach(kind => {\n if (WindowManager.registered.has(kind)) return;\n WindowManager.register({ kind, ...DefaultApps[kind] });\n });\n}\n","import type { FastboardOptions } from \"@netless/fastboard-core\";\n\nimport { createFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\n\n/**\n * Create a FastboardApp instance.\n * @example\n * let app = await createFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * joinRoom: {\n * uid: unique_id,\n * uuid: import.meta.env.VITE_ROOM_UUID,\n * roomToken: import.meta.env.VITE_ROOM_TOKEN,\n * },\n * })\n */\nexport async function createFastboard<TEventData = any>(options: FastboardOptions) {\n registerSlide();\n registerDefaultApps();\n return createFastboardCore<TEventData>(options);\n}\n","import type { FastboardReplayOptions } from \"@netless/fastboard-core\";\n\nimport { replayFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\n\n/**\n * Create a FastboardPlayer instance.\n * @example\n * let player = await replayFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * replayRoom: {\n * room: \"room uuid\",\n * roomToken: \"NETLESSROOM_...\",\n * beginTimestamp: 1646619090394,\n * duration: 70448,\n * },\n * })\n */\nexport async function replayFastboard<TEventData = any>(options: FastboardReplayOptions) {\n registerSlide();\n registerDefaultApps();\n return replayFastboardCore<TEventData>(options);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/RedoUndo.tsx","../src/create.ts","../src/behaviors/netless-app.ts","../src/behaviors/netless-ua.ts","../src/replay.ts","../src/hooks.tsx","../src/ZoomControl.tsx","../src/PageControl.tsx","../src/Toolbar.tsx","../src/Fastboard.tsx"],"names":["name","fastboard"],"mappings":";;;;;;;;;;;;;;;;;AAEA,cAAc;AACd,SAAS,YAAY;;;ACDrB,SAAS,YAAY,oBAAoB;;;ACAzC,SAAS,2BAA2B;;;ACMpC,SAAS,qBAAqB;AAE9B,OAAO,mBAAmB,UAAU,cAAc,OAAO,mBAAmB;AAKrE,SAAS,gBAAgB;AAC9B,MAAI,cAAc,WAAW,IAAI,gBAAgB,IAAI;AAAG;AACxD,gBAAc,SAAS;AAAA,IACrB,MAAM,gBAAgB;AAAA,IACtB,YAAY,EAAE,OAAO,MAAM;AAAA,IAC3B,KAAK;AAAA,IACL;AAAA,EACF,CAAC;AACH;AAEA,IAAM,cAEF,CAAC;AAEE,SAAS,sBAAsB;AACpC,SAAO,KAAK,WAAW,EAAE,QAAQ,UAAQ;AACvC,QAAI,cAAc,WAAW,IAAI,IAAI;AAAG;AACxC,kBAAc,SAAS,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,EACvD,CAAC;AACH;;;AClCA,SAAS,MAAM,eAAe;AAM9B,IAAI,WAAW;AACR,SAAS,kBAAkB;AAChC,MAAI,OAAO,WAAW,eAAe,CAAC,UAAU;AAC9C,eAAW;AACX,QAAI,MAAO,OAAwB,eAAe;AA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kC;AAAA,EAC7C;AAAA,EACA;AACF","sourcesContent":["import \"./style.scss\";\n\nexport * from \"@netless/fastboard-core\";\nexport { apps } from \"@netless/fastboard-ui\";\nexport type {\n Theme,\n Language,\n GenericIcon,\n AppInToolbar,\n AppsInToolbar,\n FastboardUIConfig,\n} from \"@netless/fastboard-ui\";\nexport * from \"./RedoUndo\";\nexport * from \"./ZoomControl\";\nexport * from \"./PageControl\";\nexport * from \"./Toolbar\";\nexport * from \"./Fastboard\";\nexport * from \"./behaviors\";\nexport * from \"./create\";\nexport * from \"./replay\";\nexport { useFastboard, useReplayFastboard } from \"./hooks\";\n\n// Caution about Export Namespace (Star)\n// esbuild can not handle nested `export *`, i.e. given two files:\n//\n// foo: export * from './bar'\n// bar: export * from 'baz' (external: baz)\n//\n// the result of bundling foo will be broken.\n// `export * from external-module` works and only works at the entry points.\n// ref: https://github.com/evanw/esbuild/issues/1737\n","import type { RedoUndoProps } from \"@netless/fastboard-ui\";\n\nimport { RedoUndo as RedoUndoImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { RedoUndoProps };\n\nexport const RedoUndo = /* @__PURE__ */ wrapReactComponent<RedoUndoProps>(RedoUndoImpl, \"RedoUndo\");\n","import type { FastboardApp, FastboardOptions } from \"@netless/fastboard-core\";\n\nimport { createFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\nimport { ensureNetlessUA } from \"./behaviors/netless-ua\";\n\n/**\n * Create a FastboardApp instance.\n * @example\n * let app = await createFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * joinRoom: {\n * uid: unique_id,\n * uuid: import.meta.env.VITE_ROOM_UUID,\n * roomToken: import.meta.env.VITE_ROOM_TOKEN,\n * },\n * })\n */\nexport async function createFastboard<TEventData = any>(\n options: FastboardOptions\n): Promise<FastboardApp<TEventData>> {\n ensureNetlessUA();\n registerSlide();\n registerDefaultApps();\n return createFastboardCore<TEventData>(options);\n}\n","import type {\n AppOptions as NetlessAppSlideAppOptions,\n Attributes as NetlessAppSlideAttributes,\n SlideState,\n SlideViewerOptions,\n} from \"@netless/app-slide\";\nimport type { RegisterParams } from \"@netless/window-manager\";\n\nimport { WindowManager } from \"@netless/window-manager\";\n\nimport NetlessAppSlide, { addHooks, previewSlide, Slide, SlideViewer } from \"@netless/app-slide\";\n\nexport { Slide, SlideViewer, previewSlide };\nexport type { NetlessAppSlideAttributes, SlideState, SlideViewerOptions };\n\nexport function registerSlide() {\n if (WindowManager.registered.has(NetlessAppSlide.kind)) return;\n WindowManager.register({\n kind: NetlessAppSlide.kind,\n appOptions: { debug: false } as NetlessAppSlideAppOptions,\n src: NetlessAppSlide,\n addHooks,\n });\n}\n\nconst DefaultApps: {\n [kind: string]: Omit<RegisterParams, \"kind\">;\n} = {};\n\nexport function registerDefaultApps() {\n Object.keys(DefaultApps).forEach(kind => {\n if (WindowManager.registered.has(kind)) return;\n WindowManager.register({ kind, ...DefaultApps[kind] });\n });\n}\n","import { name, version } from \"@netless/fastboard-core\";\n\ninterface InjectTarget {\n __netlessUA?: string;\n}\n\nlet injected = false;\nexport function ensureNetlessUA() {\n if (typeof window !== \"undefined\" && !injected) {\n injected = true;\n let str = (window as InjectTarget).__netlessUA || \"\";\n str += ` ${name}/${version} `;\n (window as InjectTarget).__netlessUA = str;\n }\n}\n","import type { FastboardPlayer, FastboardReplayOptions } from \"@netless/fastboard-core\";\n\nimport { replayFastboardCore } from \"@netless/fastboard-core\";\nimport { registerDefaultApps, registerSlide } from \"./behaviors/netless-app\";\nimport { ensureNetlessUA } from \"./behaviors/netless-ua\";\n\n/**\n * Create a FastboardPlayer instance.\n * @example\n * let player = await replayFastboard({\n * sdkConfig: {\n * appIdentifier: import.meta.env.VITE_APPID,\n * region: 'cn-hz',\n * },\n * replayRoom: {\n * room: \"room uuid\",\n * roomToken: \"NETLESSROOM_...\",\n * beginTimestamp: 1646619090394,\n * duration: 70448,\n * },\n * })\n */\nexport async function replayFastboard<TEventData = any>(\n options: FastboardReplayOptions\n): Promise<FastboardPlayer<TEventData>> {\n ensureNetlessUA();\n registerSlide();\n registerDefaultApps();\n return replayFastboardCore<TEventData>(options);\n}\n","/* eslint-disable react-hooks/exhaustive-deps */\nimport type {\n FastboardApp,\n FastboardOptions,\n FastboardPlayer,\n FastboardReplayOptions,\n} from \"@netless/fastboard-core\";\nimport type { DependencyList, EffectCallback, FunctionComponent } from \"react\";\nimport type { SvelteComponent as SvelteComponentType } from \"svelte\";\n\nimport { createFastboard } from \"./create\";\nimport { replayFastboard } from \"./replay\";\nimport React, { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\nexport const useIsomorphicLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function useUpdateEffect(effect: EffectCallback, deps?: DependencyList) {\n const isFirst = useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (isFirst.current) {\n isFirst.current = false;\n return;\n }\n\n return effect();\n }, deps);\n}\n\nexport function wrapReactComponent<Props>(\n SvelteComponent: typeof SvelteComponentType,\n name: string\n): FunctionComponent<Props> {\n function ReactComponent(props: Props) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const component = useRef<SvelteComponentType | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (container) {\n component.current = new SvelteComponent({ target: container, props });\n\n return () => {\n if (component.current) {\n component.current.$destroy();\n }\n };\n }\n }, [container]);\n\n useUpdateEffect(() => {\n if (component.current) {\n component.current.$set(props);\n }\n }, [props]);\n\n return <div className=\"fastboard-react-div\" ref={setContainer} />;\n }\n\n ReactComponent.displayName = name;\n\n return ReactComponent;\n}\n\nexport function useFastboard(config: () => FastboardOptions): FastboardApp | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardApp | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardApp | null = null;\n\n createFastboard(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n\nexport function useReplayFastboard(config: () => FastboardReplayOptions): FastboardPlayer | null {\n const unmountRef = useRef(false);\n const [fastboard, setFastboard] = useState<FastboardPlayer | null>(null);\n\n useEffect(() => {\n let fastboard: FastboardPlayer | null = null;\n\n replayFastboard(config()).then(app => {\n if (!unmountRef.current) {\n setFastboard((fastboard = app));\n } else {\n app.destroy();\n }\n });\n\n return () => {\n unmountRef.current = true;\n fastboard && fastboard.destroy();\n };\n }, []);\n\n return fastboard;\n}\n","import type { ZoomControlProps } from \"@netless/fastboard-ui\";\n\nimport { ZoomControl as ZoomControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ZoomControlProps };\n\nexport const ZoomControl = /* @__PURE__ */ wrapReactComponent<ZoomControlProps>(\n ZoomControlImpl,\n \"ZoomControl\"\n);\n","import type { PageControlProps } from \"@netless/fastboard-ui\";\n\nimport { PageControl as PageControlImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { PageControlProps };\n\nexport const PageControl = /* @__PURE__ */ wrapReactComponent<PageControlProps>(\n PageControlImpl,\n \"PageControl\"\n);\n","import type { ToolbarProps } from \"@netless/fastboard-ui\";\n\nimport { Toolbar as ToolbarImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { ToolbarProps };\n\nexport const Toolbar = /* @__PURE__ */ wrapReactComponent<ToolbarProps>(ToolbarImpl, \"Toolbar\");\n","import type { FastboardProps, ReplayFastboardProps } from \"@netless/fastboard-ui\";\n\nimport { Fastboard as FastboardImpl, ReplayFastboard as ReplayFastboardImpl } from \"@netless/fastboard-ui\";\nimport { wrapReactComponent } from \"./hooks\";\n\nexport type { FastboardProps, ReplayFastboardProps };\n\nexport const Fastboard = /* @__PURE__ */ wrapReactComponent<FastboardProps>(FastboardImpl, \"Fastboard\");\nexport const ReplayFastboard = /* @__PURE__ */ wrapReactComponent<ReplayFastboardProps>(\n ReplayFastboardImpl,\n \"ReplayFastboard\"\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/fastboard-react",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.3",
|
|
4
4
|
"description": "React components of @netless/fastboard.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,17 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@netless/app-slide": "0.3.0-canary.7",
|
|
18
|
-
"@netless/fastboard-core": "1.0.0-canary.
|
|
19
|
-
"@netless/fastboard-ui": "1.0.0-canary.
|
|
20
|
-
"@netless/synced-store": "^2.0.6"
|
|
18
|
+
"@netless/fastboard-core": "1.0.0-canary.3",
|
|
19
|
+
"@netless/fastboard-ui": "1.0.0-canary.3"
|
|
21
20
|
},
|
|
22
21
|
"devDependencies": {
|
|
23
22
|
"@netless/esbuild-plugin-inline-sass": "0.1.0",
|
|
24
23
|
"@types/react": "^18.0.17",
|
|
25
24
|
"@types/react-dom": "^18.0.6",
|
|
26
25
|
"react": "^18.2.0",
|
|
27
|
-
"react-dom": "^18.2.0"
|
|
28
|
-
"white-web-sdk": "^2.16.33"
|
|
26
|
+
"react-dom": "^18.2.0"
|
|
29
27
|
},
|
|
30
28
|
"scripts": {
|
|
31
29
|
"cleanup": "rimraf dist",
|
package/src/create.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { FastboardOptions } from "@netless/fastboard-core";
|
|
1
|
+
import type { FastboardApp, FastboardOptions } from "@netless/fastboard-core";
|
|
2
2
|
|
|
3
3
|
import { createFastboardCore } from "@netless/fastboard-core";
|
|
4
4
|
import { registerDefaultApps, registerSlide } from "./behaviors/netless-app";
|
|
5
|
+
import { ensureNetlessUA } from "./behaviors/netless-ua";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a FastboardApp instance.
|
|
@@ -18,7 +19,10 @@ import { registerDefaultApps, registerSlide } from "./behaviors/netless-app";
|
|
|
18
19
|
* },
|
|
19
20
|
* })
|
|
20
21
|
*/
|
|
21
|
-
export async function createFastboard<TEventData = any>(
|
|
22
|
+
export async function createFastboard<TEventData = any>(
|
|
23
|
+
options: FastboardOptions
|
|
24
|
+
): Promise<FastboardApp<TEventData>> {
|
|
25
|
+
ensureNetlessUA();
|
|
22
26
|
registerSlide();
|
|
23
27
|
registerDefaultApps();
|
|
24
28
|
return createFastboardCore<TEventData>(options);
|
package/src/hooks.tsx
CHANGED
|
@@ -8,7 +8,8 @@ import type {
|
|
|
8
8
|
import type { DependencyList, EffectCallback, FunctionComponent } from "react";
|
|
9
9
|
import type { SvelteComponent as SvelteComponentType } from "svelte";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { createFastboard } from "./create";
|
|
12
|
+
import { replayFastboard } from "./replay";
|
|
12
13
|
import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
13
14
|
|
|
14
15
|
export const useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
@@ -67,7 +68,7 @@ export function useFastboard(config: () => FastboardOptions): FastboardApp | nul
|
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
let fastboard: FastboardApp | null = null;
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
createFastboard(config()).then(app => {
|
|
71
72
|
if (!unmountRef.current) {
|
|
72
73
|
setFastboard((fastboard = app));
|
|
73
74
|
} else {
|
|
@@ -91,7 +92,7 @@ export function useReplayFastboard(config: () => FastboardReplayOptions): Fastbo
|
|
|
91
92
|
useEffect(() => {
|
|
92
93
|
let fastboard: FastboardPlayer | null = null;
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
replayFastboard(config()).then(app => {
|
|
95
96
|
if (!unmountRef.current) {
|
|
96
97
|
setFastboard((fastboard = app));
|
|
97
98
|
} else {
|
package/src/replay.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { FastboardReplayOptions } from "@netless/fastboard-core";
|
|
1
|
+
import type { FastboardPlayer, FastboardReplayOptions } from "@netless/fastboard-core";
|
|
2
2
|
|
|
3
3
|
import { replayFastboardCore } from "@netless/fastboard-core";
|
|
4
4
|
import { registerDefaultApps, registerSlide } from "./behaviors/netless-app";
|
|
5
|
+
import { ensureNetlessUA } from "./behaviors/netless-ua";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a FastboardPlayer instance.
|
|
@@ -19,7 +20,10 @@ import { registerDefaultApps, registerSlide } from "./behaviors/netless-app";
|
|
|
19
20
|
* },
|
|
20
21
|
* })
|
|
21
22
|
*/
|
|
22
|
-
export async function replayFastboard<TEventData = any>(
|
|
23
|
+
export async function replayFastboard<TEventData = any>(
|
|
24
|
+
options: FastboardReplayOptions
|
|
25
|
+
): Promise<FastboardPlayer<TEventData>> {
|
|
26
|
+
ensureNetlessUA();
|
|
23
27
|
registerSlide();
|
|
24
28
|
registerDefaultApps();
|
|
25
29
|
return replayFastboardCore<TEventData>(options);
|