@netless/fastboard 0.0.5 → 0.0.6

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.es.js CHANGED
@@ -1847,14 +1847,14 @@ function PageControl({
1847
1847
  if (manager && room) {
1848
1848
  await manager.switchMainViewToWriter();
1849
1849
  const path = room.state.sceneState.contextPath;
1850
- room.putScenes(path, [{}], pageCount);
1851
- await manager.setMainViewSceneIndex(pageIndex);
1850
+ room.putScenes(path, [{}], pageIndex + 1);
1851
+ await manager.setMainViewSceneIndex(pageIndex + 1);
1852
1852
  } else if (!manager && room) {
1853
1853
  const path = room.state.sceneState.contextPath;
1854
- room.putScenes(path, [{}], pageCount);
1855
- room.setSceneIndex(pageIndex);
1854
+ room.putScenes(path, [{}], pageIndex + 1);
1855
+ room.setSceneIndex(pageIndex + 1);
1856
1856
  }
1857
- }, [room, manager, pageCount, pageIndex]);
1857
+ }, [room, manager, pageIndex]);
1858
1858
  const prevPage = useCallback(() => {
1859
1859
  if (room == null ? void 0 : room.isWritable) {
1860
1860
  if (manager) {
@@ -2035,6 +2035,7 @@ class Instance {
2035
2035
  __publicField(this, "resolveReady");
2036
2036
  __publicField(this, "readyPromise");
2037
2037
  __publicField(this, "_target", null);
2038
+ __publicField(this, "collector", null);
2038
2039
  this.config = config;
2039
2040
  this.refreshReadyPromise();
2040
2041
  this.initialize();
@@ -2063,6 +2064,11 @@ class Instance {
2063
2064
  this._target = value;
2064
2065
  this.forceUpdate();
2065
2066
  }
2067
+ bindElement(target, collector) {
2068
+ this.target = target;
2069
+ this.collector = collector;
2070
+ this.forceUpdate();
2071
+ }
2066
2072
  async forceUpdate() {
2067
2073
  await this.readyPromise;
2068
2074
  if (this.target) {
@@ -2094,7 +2100,12 @@ class Instance {
2094
2100
  }
2095
2101
  async mount(node) {
2096
2102
  await this.readyPromise;
2097
- if (this.manager) {
2103
+ if (!this.manager) {
2104
+ throw new Error(`[WhiteboardApp] mounted, but not found window manager`);
2105
+ }
2106
+ if (this.collector) {
2107
+ this.manager.bindContainer(node, this.collector);
2108
+ } else {
2098
2109
  this.manager.bindContainer(node);
2099
2110
  }
2100
2111
  }
@@ -2193,12 +2204,10 @@ class WhiteboardApp {
2193
2204
  constructor(config) {
2194
2205
  __publicField(this, "_instance");
2195
2206
  __publicField(this, "_target", null);
2207
+ __publicField(this, "_collector", null);
2196
2208
  this.config = config;
2197
2209
  this._instance = new Instance(config);
2198
2210
  }
2199
- get target() {
2200
- return this._target;
2201
- }
2202
2211
  get room() {
2203
2212
  return this._instance.room;
2204
2213
  }
@@ -2211,9 +2220,16 @@ class WhiteboardApp {
2211
2220
  get i18n() {
2212
2221
  return this._instance.i18n;
2213
2222
  }
2214
- bindElement(target) {
2223
+ get target() {
2224
+ return this._target;
2225
+ }
2226
+ get collector() {
2227
+ return this._collector;
2228
+ }
2229
+ bindElement(target, collector) {
2215
2230
  this._target = target || null;
2216
- this._instance.target = target || null;
2231
+ this._collector = collector || null;
2232
+ this._instance.bindElement(this._target, this._collector);
2217
2233
  }
2218
2234
  insertDocs(params) {
2219
2235
  return this._instance.insertDocs(params);
@@ -2234,7 +2250,7 @@ class WhiteboardApp {
2234
2250
  return this._instance.dispose();
2235
2251
  }
2236
2252
  }
2237
- const version = "0.0.5";
2253
+ const version = "0.0.6";
2238
2254
  const EMPTY_ARRAY = [];
2239
2255
  function useForceUpdate() {
2240
2256
  const [, forceUpdate_] = useState({});
@@ -2495,6 +2511,7 @@ function renderSpeeds({
2495
2511
  function useFastboard(config) {
2496
2512
  const [app, setApp] = useState(null);
2497
2513
  const [currentTarget, ref] = useState(null);
2514
+ const [collector, collectorRef] = useState(null);
2498
2515
  useEffect(() => {
2499
2516
  let isMounted = true;
2500
2517
  const promise = createWhiteboardApp(config).then((app2) => {
@@ -2508,10 +2525,14 @@ function useFastboard(config) {
2508
2525
  }, []);
2509
2526
  useEffect(() => {
2510
2527
  if (app) {
2511
- app.bindElement(currentTarget);
2528
+ app.bindElement(currentTarget, collector);
2512
2529
  }
2513
- }, [app, currentTarget]);
2514
- return Object.assign([app, ref], { app, ref });
2530
+ }, [app, collector, currentTarget]);
2531
+ return Object.assign([app, ref, collectorRef], {
2532
+ app,
2533
+ ref,
2534
+ collectorRef
2535
+ });
2515
2536
  }
2516
2537
  const register = WindowManager.register.bind(WindowManager);
2517
2538
  async function createWhiteboardApp(config) {