@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.
package/dist/index.mjs CHANGED
@@ -9930,13 +9930,13 @@ 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[7](div0);
9934
9934
  append(div2, t);
9935
9935
  append(div2, div1);
9936
9936
  mount_component(playercontrol, div1, null);
9937
9937
  current = true;
9938
9938
  if (!mounted) {
9939
- dispose = listen(div0, "touchstart", tippy_hide_all, { passive: true, capture: true });
9939
+ dispose = listen(div0, "touchstart", ctx[4], { passive: true, capture: true });
9940
9940
  mounted = true;
9941
9941
  }
9942
9942
  },
@@ -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[7](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);
@@ -9989,6 +9990,11 @@ function instance57($$self, $$props, $$invalidate) {
9989
9990
  };
9990
9991
  }
9991
9992
  });
9993
+ function focus_me() {
9994
+ tippy_hide_all();
9995
+ let a = document.activeElement;
9996
+ a && a.blur && a.blur();
9997
+ }
9992
9998
  function div0_binding($$value) {
9993
9999
  binding_callbacks[$$value ? "unshift" : "push"](() => {
9994
10000
  container = $$value;
@@ -10003,25 +10009,36 @@ function instance57($$self, $$props, $$invalidate) {
10003
10009
  if ("language" in $$props2)
10004
10010
  $$invalidate(2, language = $$props2.language);
10005
10011
  if ("containerRef" in $$props2)
10006
- $$invalidate(4, containerRef = $$props2.containerRef);
10012
+ $$invalidate(5, containerRef = $$props2.containerRef);
10007
10013
  };
10008
10014
  $$self.$$.update = () => {
10009
10015
  if ($$self.$$.dirty & 9) {
10010
10016
  try {
10011
- if (player && container)
10017
+ if (player && container) {
10012
10018
  player.bindContainer(container);
10019
+ $$invalidate(6, mounted = true);
10020
+ }
10013
10021
  } catch (err) {
10014
10022
  console.error("[fastboard] An error occurred while binding container");
10015
10023
  console.error(err);
10016
10024
  }
10017
10025
  }
10018
- if ($$self.$$.dirty & 3) {
10019
- if (player && theme) {
10026
+ if ($$self.$$.dirty & 67) {
10027
+ if (player && theme && mounted) {
10020
10028
  player.manager.setPrefersColorScheme(theme);
10021
10029
  }
10022
10030
  }
10023
10031
  };
10024
- return [player, theme, language, container, containerRef, div0_binding];
10032
+ return [
10033
+ player,
10034
+ theme,
10035
+ language,
10036
+ container,
10037
+ focus_me,
10038
+ containerRef,
10039
+ mounted,
10040
+ div0_binding
10041
+ ];
10025
10042
  }
10026
10043
  var ReplayFastboard = class extends SvelteComponent {
10027
10044
  constructor(options) {
@@ -10030,7 +10047,7 @@ var ReplayFastboard = class extends SvelteComponent {
10030
10047
  player: 0,
10031
10048
  theme: 1,
10032
10049
  language: 2,
10033
- containerRef: 4
10050
+ containerRef: 5
10034
10051
  });
10035
10052
  }
10036
10053
  };
@@ -10262,7 +10279,7 @@ function create_fragment58(ctx) {
10262
10279
  m(target, anchor) {
10263
10280
  insert(target, div4, anchor);
10264
10281
  append(div4, div0);
10265
- ctx[13](div0);
10282
+ ctx[15](div0);
10266
10283
  append(div4, t0);
10267
10284
  append(div4, div1);
10268
10285
  if (if_block0)
@@ -10280,7 +10297,7 @@ function create_fragment58(ctx) {
10280
10297
  if_block3.m(div3, null);
10281
10298
  current = true;
10282
10299
  if (!mounted) {
10283
- dispose = listen(div0, "touchstart", tippy_hide_all, { passive: true, capture: true });
10300
+ dispose = listen(div0, "touchstart", ctx[9], { passive: true, capture: true });
10284
10301
  mounted = true;
10285
10302
  }
10286
10303
  },
@@ -10394,7 +10411,7 @@ function create_fragment58(ctx) {
10394
10411
  d(detaching) {
10395
10412
  if (detaching)
10396
10413
  detach(div4);
10397
- ctx[13](null);
10414
+ ctx[15](null);
10398
10415
  if (if_block0)
10399
10416
  if_block0.d();
10400
10417
  if (if_block1)
@@ -10413,9 +10430,9 @@ function instance58($$self, $$props, $$invalidate) {
10413
10430
  let writable2;
10414
10431
  let boxState;
10415
10432
  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);
10433
+ let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(12, $focusedApp = $$value)), focusedApp);
10434
+ let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(13, $boxState = $$value)), boxState);
10435
+ let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(14, $writable = $$value)), writable2);
10419
10436
  $$self.$$.on_destroy.push(() => $$unsubscribe_focusedApp());
10420
10437
  $$self.$$.on_destroy.push(() => $$unsubscribe_boxState());
10421
10438
  $$self.$$.on_destroy.push(() => $$unsubscribe_writable());
@@ -10427,6 +10444,7 @@ function instance58($$self, $$props, $$invalidate) {
10427
10444
  const AppsShowToolbar = ["DocsViewer", "Slide"];
10428
10445
  let container;
10429
10446
  let layout = "hidden";
10447
+ let mounted = false;
10430
10448
  onMount(() => {
10431
10449
  if (containerRef) {
10432
10450
  containerRef(container);
@@ -10436,6 +10454,11 @@ function instance58($$self, $$props, $$invalidate) {
10436
10454
  };
10437
10455
  }
10438
10456
  });
10457
+ function focus_me() {
10458
+ tippy_hide_all();
10459
+ let a = document.activeElement;
10460
+ a && a.blur && a.blur();
10461
+ }
10439
10462
  function div0_binding($$value) {
10440
10463
  binding_callbacks[$$value ? "unshift" : "push"](() => {
10441
10464
  container = $$value;
@@ -10450,7 +10473,7 @@ function instance58($$self, $$props, $$invalidate) {
10450
10473
  if ("language" in $$props2)
10451
10474
  $$invalidate(2, language = $$props2.language);
10452
10475
  if ("containerRef" in $$props2)
10453
- $$invalidate(9, containerRef = $$props2.containerRef);
10476
+ $$invalidate(10, containerRef = $$props2.containerRef);
10454
10477
  if ("config" in $$props2)
10455
10478
  $$invalidate(3, config = $$props2.config);
10456
10479
  };
@@ -10464,7 +10487,7 @@ function instance58($$self, $$props, $$invalidate) {
10464
10487
  if ($$self.$$.dirty & 1) {
10465
10488
  $$subscribe_focusedApp($$invalidate(6, focusedApp = app == null ? void 0 : app.focusedApp));
10466
10489
  }
10467
- if ($$self.$$.dirty & 7168) {
10490
+ if ($$self.$$.dirty & 28672) {
10468
10491
  if (!$writable) {
10469
10492
  $$invalidate(5, layout = "hidden");
10470
10493
  } else if ($boxState === "maximized") {
@@ -10479,15 +10502,17 @@ function instance58($$self, $$props, $$invalidate) {
10479
10502
  }
10480
10503
  if ($$self.$$.dirty & 17) {
10481
10504
  try {
10482
- if (app && container)
10505
+ if (app && container) {
10483
10506
  app.bindContainer(container);
10507
+ $$invalidate(11, mounted = true);
10508
+ }
10484
10509
  } catch (err) {
10485
10510
  console.error("[fastboard] An error occurred while binding container");
10486
10511
  console.error(err);
10487
10512
  }
10488
10513
  }
10489
- if ($$self.$$.dirty & 3) {
10490
- if (app && theme) {
10514
+ if ($$self.$$.dirty & 2051) {
10515
+ if (app && theme && mounted) {
10491
10516
  app.manager.setPrefersColorScheme(theme);
10492
10517
  }
10493
10518
  }
@@ -10502,7 +10527,9 @@ function instance58($$self, $$props, $$invalidate) {
10502
10527
  focusedApp,
10503
10528
  boxState,
10504
10529
  writable2,
10530
+ focus_me,
10505
10531
  containerRef,
10532
+ mounted,
10506
10533
  $focusedApp,
10507
10534
  $boxState,
10508
10535
  $writable,
@@ -10516,13 +10543,69 @@ var Fastboard = class extends SvelteComponent {
10516
10543
  app: 0,
10517
10544
  theme: 1,
10518
10545
  language: 2,
10519
- containerRef: 9,
10546
+ containerRef: 10,
10520
10547
  config: 3
10521
10548
  });
10522
10549
  }
10523
10550
  };
10524
10551
  var Fastboard_default = Fastboard;
10525
10552
 
10553
+ // src/helpers/index.ts
10554
+ function createUI(app, div) {
10555
+ let fastboard;
10556
+ const ui = {
10557
+ mount(div2, props) {
10558
+ if (fastboard) {
10559
+ fastboard.$destroy();
10560
+ }
10561
+ fastboard = new Fastboard_default({ target: div2, props: __spreadValues({ app }, props) });
10562
+ return ui;
10563
+ },
10564
+ update(props) {
10565
+ if (fastboard) {
10566
+ fastboard.$set(props);
10567
+ }
10568
+ },
10569
+ destroy() {
10570
+ if (fastboard) {
10571
+ fastboard.$destroy();
10572
+ }
10573
+ fastboard = void 0;
10574
+ }
10575
+ };
10576
+ if (div) {
10577
+ ui.mount(div);
10578
+ }
10579
+ return ui;
10580
+ }
10581
+ function createReplayUI(player, div) {
10582
+ let fastboard;
10583
+ const ui = {
10584
+ mount(div2, props) {
10585
+ if (fastboard) {
10586
+ fastboard.$destroy();
10587
+ }
10588
+ fastboard = new ReplayFastboard_default({ target: div2, props: __spreadValues({ player }, props) });
10589
+ return ui;
10590
+ },
10591
+ update(props) {
10592
+ if (fastboard) {
10593
+ fastboard.$set(props);
10594
+ }
10595
+ },
10596
+ destroy() {
10597
+ if (fastboard) {
10598
+ fastboard.$destroy();
10599
+ }
10600
+ fastboard = void 0;
10601
+ }
10602
+ };
10603
+ if (div) {
10604
+ ui.mount(div);
10605
+ }
10606
+ return ui;
10607
+ }
10608
+
10526
10609
  // inline-sass-helper:inline-sass-style-helper.js
10527
10610
  function injectStyle(text2) {
10528
10611
  if (typeof document !== "undefined") {
@@ -10539,5 +10622,5 @@ var style_default = '.tippy-box[data-animation=fade][data-state=hidden]{opacity:
10539
10622
  // inline-sass-stub:./src/style.scss
10540
10623
  injectStyle(style_default);
10541
10624
 
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 };
10625
+ 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
10626
  //# sourceMappingURL=index.mjs.map