@netless/fastboard-ui 0.3.4-canary.0 → 0.3.4

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.mjs CHANGED
@@ -9930,7 +9930,7 @@ function create_fragment57(ctx) {
9930
9930
  m(target, anchor) {
9931
9931
  insert(target, div2, anchor);
9932
9932
  append(div2, div0);
9933
- ctx[5](div0);
9933
+ ctx[6](div0);
9934
9934
  append(div2, t);
9935
9935
  append(div2, div1);
9936
9936
  mount_component(playercontrol, div1, null);
@@ -9966,7 +9966,7 @@ function create_fragment57(ctx) {
9966
9966
  d(detaching) {
9967
9967
  if (detaching)
9968
9968
  detach(div2);
9969
- ctx[5](null);
9969
+ ctx[6](null);
9970
9970
  destroy_component(playercontrol);
9971
9971
  mounted = false;
9972
9972
  dispose();
@@ -9980,6 +9980,7 @@ function instance57($$self, $$props, $$invalidate) {
9980
9980
  let { language = "en" } = $$props;
9981
9981
  let { containerRef = void 0 } = $$props;
9982
9982
  let container;
9983
+ let mounted = false;
9983
9984
  onMount(() => {
9984
9985
  if (containerRef) {
9985
9986
  containerRef(container);
@@ -10008,20 +10009,22 @@ function instance57($$self, $$props, $$invalidate) {
10008
10009
  $$self.$$.update = () => {
10009
10010
  if ($$self.$$.dirty & 9) {
10010
10011
  try {
10011
- if (player && container)
10012
+ if (player && container) {
10012
10013
  player.bindContainer(container);
10014
+ $$invalidate(5, mounted = true);
10015
+ }
10013
10016
  } catch (err) {
10014
10017
  console.error("[fastboard] An error occurred while binding container");
10015
10018
  console.error(err);
10016
10019
  }
10017
10020
  }
10018
- if ($$self.$$.dirty & 3) {
10019
- if (player && theme) {
10021
+ if ($$self.$$.dirty & 35) {
10022
+ if (player && theme && mounted) {
10020
10023
  player.manager.setPrefersColorScheme(theme);
10021
10024
  }
10022
10025
  }
10023
10026
  };
10024
- return [player, theme, language, container, containerRef, div0_binding];
10027
+ return [player, theme, language, container, containerRef, mounted, div0_binding];
10025
10028
  }
10026
10029
  var ReplayFastboard = class extends SvelteComponent {
10027
10030
  constructor(options) {
@@ -10262,7 +10265,7 @@ function create_fragment58(ctx) {
10262
10265
  m(target, anchor) {
10263
10266
  insert(target, div4, anchor);
10264
10267
  append(div4, div0);
10265
- ctx[13](div0);
10268
+ ctx[14](div0);
10266
10269
  append(div4, t0);
10267
10270
  append(div4, div1);
10268
10271
  if (if_block0)
@@ -10394,7 +10397,7 @@ function create_fragment58(ctx) {
10394
10397
  d(detaching) {
10395
10398
  if (detaching)
10396
10399
  detach(div4);
10397
- ctx[13](null);
10400
+ ctx[14](null);
10398
10401
  if (if_block0)
10399
10402
  if_block0.d();
10400
10403
  if (if_block1)
@@ -10413,9 +10416,9 @@ function instance58($$self, $$props, $$invalidate) {
10413
10416
  let writable2;
10414
10417
  let boxState;
10415
10418
  let focusedApp;
10416
- let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(10, $focusedApp = $$value)), focusedApp);
10417
- let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(11, $boxState = $$value)), boxState);
10418
- let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(12, $writable = $$value)), writable2);
10419
+ let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(11, $focusedApp = $$value)), focusedApp);
10420
+ let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(12, $boxState = $$value)), boxState);
10421
+ let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(13, $writable = $$value)), writable2);
10419
10422
  $$self.$$.on_destroy.push(() => $$unsubscribe_focusedApp());
10420
10423
  $$self.$$.on_destroy.push(() => $$unsubscribe_boxState());
10421
10424
  $$self.$$.on_destroy.push(() => $$unsubscribe_writable());
@@ -10427,6 +10430,7 @@ function instance58($$self, $$props, $$invalidate) {
10427
10430
  const AppsShowToolbar = ["DocsViewer", "Slide"];
10428
10431
  let container;
10429
10432
  let layout = "hidden";
10433
+ let mounted = false;
10430
10434
  onMount(() => {
10431
10435
  if (containerRef) {
10432
10436
  containerRef(container);
@@ -10464,7 +10468,7 @@ function instance58($$self, $$props, $$invalidate) {
10464
10468
  if ($$self.$$.dirty & 1) {
10465
10469
  $$subscribe_focusedApp($$invalidate(6, focusedApp = app == null ? void 0 : app.focusedApp));
10466
10470
  }
10467
- if ($$self.$$.dirty & 7168) {
10471
+ if ($$self.$$.dirty & 14336) {
10468
10472
  if (!$writable) {
10469
10473
  $$invalidate(5, layout = "hidden");
10470
10474
  } else if ($boxState === "maximized") {
@@ -10479,15 +10483,17 @@ function instance58($$self, $$props, $$invalidate) {
10479
10483
  }
10480
10484
  if ($$self.$$.dirty & 17) {
10481
10485
  try {
10482
- if (app && container)
10486
+ if (app && container) {
10483
10487
  app.bindContainer(container);
10488
+ $$invalidate(10, mounted = true);
10489
+ }
10484
10490
  } catch (err) {
10485
10491
  console.error("[fastboard] An error occurred while binding container");
10486
10492
  console.error(err);
10487
10493
  }
10488
10494
  }
10489
- if ($$self.$$.dirty & 3) {
10490
- if (app && theme) {
10495
+ if ($$self.$$.dirty & 1027) {
10496
+ if (app && theme && mounted) {
10491
10497
  app.manager.setPrefersColorScheme(theme);
10492
10498
  }
10493
10499
  }
@@ -10503,6 +10509,7 @@ function instance58($$self, $$props, $$invalidate) {
10503
10509
  boxState,
10504
10510
  writable2,
10505
10511
  containerRef,
10512
+ mounted,
10506
10513
  $focusedApp,
10507
10514
  $boxState,
10508
10515
  $writable,
@@ -10523,6 +10530,62 @@ var Fastboard = class extends SvelteComponent {
10523
10530
  };
10524
10531
  var Fastboard_default = Fastboard;
10525
10532
 
10533
+ // src/helpers/index.ts
10534
+ function createUI(app, div) {
10535
+ let fastboard;
10536
+ const ui = {
10537
+ mount(div2, props) {
10538
+ if (fastboard) {
10539
+ fastboard.$destroy();
10540
+ }
10541
+ fastboard = new Fastboard_default({ target: div2, props: __spreadValues({ app }, props) });
10542
+ return ui;
10543
+ },
10544
+ update(props) {
10545
+ if (fastboard) {
10546
+ fastboard.$set(props);
10547
+ }
10548
+ },
10549
+ destroy() {
10550
+ if (fastboard) {
10551
+ fastboard.$destroy();
10552
+ }
10553
+ fastboard = void 0;
10554
+ }
10555
+ };
10556
+ if (div) {
10557
+ ui.mount(div);
10558
+ }
10559
+ return ui;
10560
+ }
10561
+ function createReplayUI(player, div) {
10562
+ let fastboard;
10563
+ const ui = {
10564
+ mount(div2, props) {
10565
+ if (fastboard) {
10566
+ fastboard.$destroy();
10567
+ }
10568
+ fastboard = new ReplayFastboard_default({ target: div2, props: __spreadValues({ player }, props) });
10569
+ return ui;
10570
+ },
10571
+ update(props) {
10572
+ if (fastboard) {
10573
+ fastboard.$set(props);
10574
+ }
10575
+ },
10576
+ destroy() {
10577
+ if (fastboard) {
10578
+ fastboard.$destroy();
10579
+ }
10580
+ fastboard = void 0;
10581
+ }
10582
+ };
10583
+ if (div) {
10584
+ ui.mount(div);
10585
+ }
10586
+ return ui;
10587
+ }
10588
+
10526
10589
  // inline-sass-helper:inline-sass-style-helper.js
10527
10590
  function injectStyle(text2) {
10528
10591
  if (typeof document !== "undefined") {
@@ -10539,5 +10602,5 @@ var style_default = '.tippy-box[data-animation=fade][data-state=hidden]{opacity:
10539
10602
  // inline-sass-stub:./src/style.scss
10540
10603
  injectStyle(style_default);
10541
10604
 
10542
- 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 };
10605
+ 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 };
10543
10606
  //# sourceMappingURL=index.mjs.map