@netless/fastboard 0.0.9 → 0.0.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.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +30 -10
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/react.tsx +32 -6
package/dist/index.es.js
CHANGED
|
@@ -2336,7 +2336,7 @@ class WhiteboardApp {
|
|
|
2336
2336
|
return this._instance.dispose();
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
|
-
const version = "0.0.
|
|
2339
|
+
const version = "0.0.10";
|
|
2340
2340
|
function useLastValue(value) {
|
|
2341
2341
|
const ref = useRef(value);
|
|
2342
2342
|
useEffect(() => {
|
|
@@ -2594,10 +2594,29 @@ function renderSpeeds({
|
|
|
2594
2594
|
}, speed))
|
|
2595
2595
|
});
|
|
2596
2596
|
}
|
|
2597
|
-
function
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2597
|
+
function useCombinedRefs(...refs) {
|
|
2598
|
+
const targetRef = useRef(null);
|
|
2599
|
+
useEffect(() => {
|
|
2600
|
+
for (const ref of refs) {
|
|
2601
|
+
if (!ref)
|
|
2602
|
+
continue;
|
|
2603
|
+
if (typeof ref === "function") {
|
|
2604
|
+
ref(targetRef.current);
|
|
2605
|
+
} else {
|
|
2606
|
+
ref.current = targetRef.current;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
}, [refs]);
|
|
2610
|
+
return targetRef;
|
|
2611
|
+
}
|
|
2612
|
+
const Fastboard = forwardRef((_c, outerRef) => {
|
|
2613
|
+
var _d = _c, {
|
|
2614
|
+
app
|
|
2615
|
+
} = _d, restProps = __objRest(_d, [
|
|
2616
|
+
"app"
|
|
2617
|
+
]);
|
|
2618
|
+
const innerRef = useRef(null);
|
|
2619
|
+
const ref = useCombinedRefs(outerRef, innerRef);
|
|
2601
2620
|
const previous = useLastValue(app);
|
|
2602
2621
|
useEffect(() => {
|
|
2603
2622
|
if (previous && previous !== app) {
|
|
@@ -2606,12 +2625,13 @@ function Fastboard({
|
|
|
2606
2625
|
if (app) {
|
|
2607
2626
|
app.bindElement(ref.current);
|
|
2608
2627
|
}
|
|
2609
|
-
}, [app, previous]);
|
|
2610
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2611
|
-
className: "fastboard"
|
|
2628
|
+
}, [app, previous, ref]);
|
|
2629
|
+
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({
|
|
2630
|
+
className: "fastboard"
|
|
2631
|
+
}, restProps), {
|
|
2612
2632
|
ref
|
|
2613
|
-
});
|
|
2614
|
-
}
|
|
2633
|
+
}));
|
|
2634
|
+
});
|
|
2615
2635
|
const register = WindowManager.register.bind(WindowManager);
|
|
2616
2636
|
async function createWhiteboardApp(config) {
|
|
2617
2637
|
const app = new WhiteboardApp(config);
|