@netless/fastboard-ui 0.3.4-canary.1 → 0.3.5-canary.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.
@@ -9269,13 +9269,13 @@ function create_fragment57(ctx) {
9269
9269
  m(target, anchor) {
9270
9270
  insert(target, div2, anchor);
9271
9271
  append(div2, div0);
9272
- ctx[5](div0);
9272
+ ctx[7](div0);
9273
9273
  append(div2, t);
9274
9274
  append(div2, div1);
9275
9275
  mount_component(playercontrol, div1, null);
9276
9276
  current = true;
9277
9277
  if (!mounted) {
9278
- dispose = listen(div0, "touchstart", tippy_hide_all, { passive: true, capture: true });
9278
+ dispose = listen(div0, "touchstart", ctx[4], { passive: true, capture: true });
9279
9279
  mounted = true;
9280
9280
  }
9281
9281
  },
@@ -9305,7 +9305,7 @@ function create_fragment57(ctx) {
9305
9305
  d(detaching) {
9306
9306
  if (detaching)
9307
9307
  detach(div2);
9308
- ctx[5](null);
9308
+ ctx[7](null);
9309
9309
  destroy_component(playercontrol);
9310
9310
  mounted = false;
9311
9311
  dispose();
@@ -9319,6 +9319,7 @@ function instance57($$self, $$props, $$invalidate) {
9319
9319
  let { language = "en" } = $$props;
9320
9320
  let { containerRef = void 0 } = $$props;
9321
9321
  let container;
9322
+ let mounted = false;
9322
9323
  onMount(() => {
9323
9324
  if (containerRef) {
9324
9325
  containerRef(container);
@@ -9328,6 +9329,11 @@ function instance57($$self, $$props, $$invalidate) {
9328
9329
  };
9329
9330
  }
9330
9331
  });
9332
+ function focus_me() {
9333
+ tippy_hide_all();
9334
+ let a = document.activeElement;
9335
+ a && a.blur && a.blur();
9336
+ }
9331
9337
  function div0_binding($$value) {
9332
9338
  binding_callbacks[$$value ? "unshift" : "push"](() => {
9333
9339
  container = $$value;
@@ -9342,25 +9348,36 @@ function instance57($$self, $$props, $$invalidate) {
9342
9348
  if ("language" in $$props2)
9343
9349
  $$invalidate(2, language = $$props2.language);
9344
9350
  if ("containerRef" in $$props2)
9345
- $$invalidate(4, containerRef = $$props2.containerRef);
9351
+ $$invalidate(5, containerRef = $$props2.containerRef);
9346
9352
  };
9347
9353
  $$self.$$.update = () => {
9348
9354
  if ($$self.$$.dirty & 9) {
9349
9355
  try {
9350
- if (player && container)
9356
+ if (player && container) {
9351
9357
  player.bindContainer(container);
9358
+ $$invalidate(6, mounted = true);
9359
+ }
9352
9360
  } catch (err) {
9353
9361
  console.error("[fastboard] An error occurred while binding container");
9354
9362
  console.error(err);
9355
9363
  }
9356
9364
  }
9357
- if ($$self.$$.dirty & 3) {
9358
- if (player && theme) {
9365
+ if ($$self.$$.dirty & 67) {
9366
+ if (player && theme && mounted) {
9359
9367
  player.manager.setPrefersColorScheme(theme);
9360
9368
  }
9361
9369
  }
9362
9370
  };
9363
- return [player, theme, language, container, containerRef, div0_binding];
9371
+ return [
9372
+ player,
9373
+ theme,
9374
+ language,
9375
+ container,
9376
+ focus_me,
9377
+ containerRef,
9378
+ mounted,
9379
+ div0_binding
9380
+ ];
9364
9381
  }
9365
9382
  var ReplayFastboard = class extends SvelteComponent {
9366
9383
  constructor(options) {
@@ -9369,7 +9386,7 @@ var ReplayFastboard = class extends SvelteComponent {
9369
9386
  player: 0,
9370
9387
  theme: 1,
9371
9388
  language: 2,
9372
- containerRef: 4
9389
+ containerRef: 5
9373
9390
  });
9374
9391
  }
9375
9392
  };
@@ -9599,7 +9616,7 @@ function create_fragment58(ctx) {
9599
9616
  m(target, anchor) {
9600
9617
  insert(target, div4, anchor);
9601
9618
  append(div4, div0);
9602
- ctx[13](div0);
9619
+ ctx[15](div0);
9603
9620
  append(div4, t0);
9604
9621
  append(div4, div1);
9605
9622
  if (if_block0)
@@ -9617,7 +9634,7 @@ function create_fragment58(ctx) {
9617
9634
  if_block3.m(div3, null);
9618
9635
  current = true;
9619
9636
  if (!mounted) {
9620
- dispose = listen(div0, "touchstart", tippy_hide_all, { passive: true, capture: true });
9637
+ dispose = listen(div0, "touchstart", ctx[9], { passive: true, capture: true });
9621
9638
  mounted = true;
9622
9639
  }
9623
9640
  },
@@ -9731,7 +9748,7 @@ function create_fragment58(ctx) {
9731
9748
  d(detaching) {
9732
9749
  if (detaching)
9733
9750
  detach(div4);
9734
- ctx[13](null);
9751
+ ctx[15](null);
9735
9752
  if (if_block0)
9736
9753
  if_block0.d();
9737
9754
  if (if_block1)
@@ -9750,9 +9767,9 @@ function instance58($$self, $$props, $$invalidate) {
9750
9767
  let writable2;
9751
9768
  let boxState;
9752
9769
  let focusedApp;
9753
- let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(10, $focusedApp = $$value)), focusedApp);
9754
- let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(11, $boxState = $$value)), boxState);
9755
- let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(12, $writable = $$value)), writable2);
9770
+ let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(12, $focusedApp = $$value)), focusedApp);
9771
+ let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(13, $boxState = $$value)), boxState);
9772
+ let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(14, $writable = $$value)), writable2);
9756
9773
  $$self.$$.on_destroy.push(() => $$unsubscribe_focusedApp());
9757
9774
  $$self.$$.on_destroy.push(() => $$unsubscribe_boxState());
9758
9775
  $$self.$$.on_destroy.push(() => $$unsubscribe_writable());
@@ -9764,6 +9781,7 @@ function instance58($$self, $$props, $$invalidate) {
9764
9781
  const AppsShowToolbar = ["DocsViewer", "Slide"];
9765
9782
  let container;
9766
9783
  let layout = "hidden";
9784
+ let mounted = false;
9767
9785
  onMount(() => {
9768
9786
  if (containerRef) {
9769
9787
  containerRef(container);
@@ -9773,6 +9791,11 @@ function instance58($$self, $$props, $$invalidate) {
9773
9791
  };
9774
9792
  }
9775
9793
  });
9794
+ function focus_me() {
9795
+ tippy_hide_all();
9796
+ let a = document.activeElement;
9797
+ a && a.blur && a.blur();
9798
+ }
9776
9799
  function div0_binding($$value) {
9777
9800
  binding_callbacks[$$value ? "unshift" : "push"](() => {
9778
9801
  container = $$value;
@@ -9787,7 +9810,7 @@ function instance58($$self, $$props, $$invalidate) {
9787
9810
  if ("language" in $$props2)
9788
9811
  $$invalidate(2, language = $$props2.language);
9789
9812
  if ("containerRef" in $$props2)
9790
- $$invalidate(9, containerRef = $$props2.containerRef);
9813
+ $$invalidate(10, containerRef = $$props2.containerRef);
9791
9814
  if ("config" in $$props2)
9792
9815
  $$invalidate(3, config = $$props2.config);
9793
9816
  };
@@ -9801,7 +9824,7 @@ function instance58($$self, $$props, $$invalidate) {
9801
9824
  if ($$self.$$.dirty & 1) {
9802
9825
  $$subscribe_focusedApp($$invalidate(6, focusedApp = app == null ? void 0 : app.focusedApp));
9803
9826
  }
9804
- if ($$self.$$.dirty & 7168) {
9827
+ if ($$self.$$.dirty & 28672) {
9805
9828
  if (!$writable) {
9806
9829
  $$invalidate(5, layout = "hidden");
9807
9830
  } else if ($boxState === "maximized") {
@@ -9816,15 +9839,17 @@ function instance58($$self, $$props, $$invalidate) {
9816
9839
  }
9817
9840
  if ($$self.$$.dirty & 17) {
9818
9841
  try {
9819
- if (app && container)
9842
+ if (app && container) {
9820
9843
  app.bindContainer(container);
9844
+ $$invalidate(11, mounted = true);
9845
+ }
9821
9846
  } catch (err) {
9822
9847
  console.error("[fastboard] An error occurred while binding container");
9823
9848
  console.error(err);
9824
9849
  }
9825
9850
  }
9826
- if ($$self.$$.dirty & 3) {
9827
- if (app && theme) {
9851
+ if ($$self.$$.dirty & 2051) {
9852
+ if (app && theme && mounted) {
9828
9853
  app.manager.setPrefersColorScheme(theme);
9829
9854
  }
9830
9855
  }
@@ -9839,7 +9864,9 @@ function instance58($$self, $$props, $$invalidate) {
9839
9864
  focusedApp,
9840
9865
  boxState,
9841
9866
  writable2,
9867
+ focus_me,
9842
9868
  containerRef,
9869
+ mounted,
9843
9870
  $focusedApp,
9844
9871
  $boxState,
9845
9872
  $writable,
@@ -9853,13 +9880,69 @@ var Fastboard = class extends SvelteComponent {
9853
9880
  app: 0,
9854
9881
  theme: 1,
9855
9882
  language: 2,
9856
- containerRef: 9,
9883
+ containerRef: 10,
9857
9884
  config: 3
9858
9885
  });
9859
9886
  }
9860
9887
  };
9861
9888
  var Fastboard_default = Fastboard;
9862
9889
 
9890
+ // src/helpers/index.ts
9891
+ function createUI(app, div) {
9892
+ let fastboard;
9893
+ const ui = {
9894
+ mount(div2, props) {
9895
+ if (fastboard) {
9896
+ fastboard.$destroy();
9897
+ }
9898
+ fastboard = new Fastboard_default({ target: div2, props: __spreadValues({ app }, props) });
9899
+ return ui;
9900
+ },
9901
+ update(props) {
9902
+ if (fastboard) {
9903
+ fastboard.$set(props);
9904
+ }
9905
+ },
9906
+ destroy() {
9907
+ if (fastboard) {
9908
+ fastboard.$destroy();
9909
+ }
9910
+ fastboard = void 0;
9911
+ }
9912
+ };
9913
+ if (div) {
9914
+ ui.mount(div);
9915
+ }
9916
+ return ui;
9917
+ }
9918
+ function createReplayUI(player, div) {
9919
+ let fastboard;
9920
+ const ui = {
9921
+ mount(div2, props) {
9922
+ if (fastboard) {
9923
+ fastboard.$destroy();
9924
+ }
9925
+ fastboard = new ReplayFastboard_default({ target: div2, props: __spreadValues({ player }, props) });
9926
+ return ui;
9927
+ },
9928
+ update(props) {
9929
+ if (fastboard) {
9930
+ fastboard.$set(props);
9931
+ }
9932
+ },
9933
+ destroy() {
9934
+ if (fastboard) {
9935
+ fastboard.$destroy();
9936
+ }
9937
+ fastboard = void 0;
9938
+ }
9939
+ };
9940
+ if (div) {
9941
+ ui.mount(div);
9942
+ }
9943
+ return ui;
9944
+ }
9945
+
9863
9946
  // inline-sass-helper:inline-sass-style-helper.js
9864
9947
  function injectStyle(text4) {
9865
9948
  if (typeof document !== "undefined") {
@@ -9876,5 +9959,5 @@ var style_default = '.tippy-box[data-animation=fade][data-state=hidden]{opacity:
9876
9959
  // inline-sass-stub:./src/style.scss
9877
9960
  injectStyle(style_default);
9878
9961
 
9879
- export { Fastboard_default as Fastboard, PageControl_default as PageControl, PlayerControl_default as PlayerControl, RedoUndo_default as RedoUndo, ReplayFastboard_default as ReplayFastboard, Toolbar_default as Toolbar, ZoomControl_default as ZoomControl, apps };
9962
+ export { Fastboard_default as Fastboard, PageControl_default as PageControl, PlayerControl_default as PlayerControl, RedoUndo_default as RedoUndo, ReplayFastboard_default as ReplayFastboard, Toolbar_default as Toolbar, ZoomControl_default as ZoomControl, apps, createReplayUI, createUI };
9880
9963
  //# sourceMappingURL=index.svelte.mjs.map