@netless/fastboard-ui 1.0.5 → 1.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.mjs CHANGED
@@ -18028,11 +18028,13 @@ function create_fragment78(ctx) {
18028
18028
  );
18029
18029
  let if_block1 = (
18030
18030
  /*config*/
18031
- ((_b = ctx[3].redo_undo) == null ? void 0 : _b.enable) !== false && create_if_block_26(ctx)
18031
+ ((_b = ctx[3].redo_undo) == null ? void 0 : _b.enable) !== false && !/*hidden_redo_undo*/
18032
+ ctx[6] && create_if_block_26(ctx)
18032
18033
  );
18033
18034
  let if_block2 = (
18034
18035
  /*config*/
18035
- ((_c = ctx[3].zoom_control) == null ? void 0 : _c.enable) !== false && create_if_block_112(ctx)
18036
+ ((_c = ctx[3].zoom_control) == null ? void 0 : _c.enable) !== false && !/*hidden_zoom_control*/
18037
+ ctx[7] && create_if_block_112(ctx)
18036
18038
  );
18037
18039
  let if_block3 = (
18038
18040
  /*config*/
@@ -18061,23 +18063,26 @@ function create_fragment78(ctx) {
18061
18063
  attr(div0, "class", name9 + "-view");
18062
18064
  attr(div1, "class", div1_class_value = name9 + "-" + /*config*/
18063
18065
  (((_a2 = ctx[3].toolbar) == null ? void 0 : _a2.placement) || "left"));
18064
- toggle_class(div1, "hidden", !/*toolbar_has_items*/
18065
- ctx[6] || !/*layout*/
18066
- (ctx[5] === "visible" || /*layout*/
18067
- ctx[5] === "toolbar-only"));
18066
+ toggle_class(
18067
+ div1,
18068
+ "hidden",
18069
+ /*hidden_toolbar*/
18070
+ ctx[5]
18071
+ );
18068
18072
  attr(div2, "class", name9 + "-bottom-left");
18069
18073
  toggle_class(
18070
18074
  div2,
18071
18075
  "hidden",
18072
- /*layout*/
18073
- ctx[5] !== "visible"
18076
+ /*hidden_toolbar*/
18077
+ ctx[5] && /*hidden_redo_undo*/
18078
+ ctx[6]
18074
18079
  );
18075
18080
  attr(div3, "class", name9 + "-bottom-right");
18076
18081
  toggle_class(
18077
18082
  div3,
18078
18083
  "hidden",
18079
- /*layout*/
18080
- ctx[5] !== "visible"
18084
+ /*hidden_page_control*/
18085
+ ctx[8]
18081
18086
  );
18082
18087
  attr(div4, "class", name9 + "-root");
18083
18088
  toggle_class(div4, "loading", !/*app*/
@@ -18086,7 +18091,7 @@ function create_fragment78(ctx) {
18086
18091
  m(target, anchor) {
18087
18092
  insert(target, div4, anchor);
18088
18093
  append(div4, div0);
18089
- ctx[16](div0);
18094
+ ctx[26](div0);
18090
18095
  append(div4, t0);
18091
18096
  append(div4, div1);
18092
18097
  if (if_block0)
@@ -18108,7 +18113,7 @@ function create_fragment78(ctx) {
18108
18113
  div0,
18109
18114
  "touchstart",
18110
18115
  /*focus_me*/
18111
- ctx[10],
18116
+ ctx[13],
18112
18117
  { passive: true, capture: true }
18113
18118
  );
18114
18119
  mounted = true;
@@ -18144,21 +18149,24 @@ function create_fragment78(ctx) {
18144
18149
  (((_b2 = ctx2[3].toolbar) == null ? void 0 : _b2.placement) || "left"))) {
18145
18150
  attr(div1, "class", div1_class_value);
18146
18151
  }
18147
- if (!current || dirty & /*config, toolbar_has_items, layout*/
18148
- 104) {
18149
- toggle_class(div1, "hidden", !/*toolbar_has_items*/
18150
- ctx2[6] || !/*layout*/
18151
- (ctx2[5] === "visible" || /*layout*/
18152
- ctx2[5] === "toolbar-only"));
18152
+ if (!current || dirty & /*config, hidden_toolbar*/
18153
+ 40) {
18154
+ toggle_class(
18155
+ div1,
18156
+ "hidden",
18157
+ /*hidden_toolbar*/
18158
+ ctx2[5]
18159
+ );
18153
18160
  }
18154
18161
  if (
18155
18162
  /*config*/
18156
- ((_c2 = ctx2[3].redo_undo) == null ? void 0 : _c2.enable) !== false
18163
+ ((_c2 = ctx2[3].redo_undo) == null ? void 0 : _c2.enable) !== false && !/*hidden_redo_undo*/
18164
+ ctx2[6]
18157
18165
  ) {
18158
18166
  if (if_block1) {
18159
18167
  if_block1.p(ctx2, dirty);
18160
- if (dirty & /*config*/
18161
- 8) {
18168
+ if (dirty & /*config, hidden_redo_undo*/
18169
+ 72) {
18162
18170
  transition_in(if_block1, 1);
18163
18171
  }
18164
18172
  } else {
@@ -18176,12 +18184,13 @@ function create_fragment78(ctx) {
18176
18184
  }
18177
18185
  if (
18178
18186
  /*config*/
18179
- ((_d2 = ctx2[3].zoom_control) == null ? void 0 : _d2.enable) !== false
18187
+ ((_d2 = ctx2[3].zoom_control) == null ? void 0 : _d2.enable) !== false && !/*hidden_zoom_control*/
18188
+ ctx2[7]
18180
18189
  ) {
18181
18190
  if (if_block2) {
18182
18191
  if_block2.p(ctx2, dirty);
18183
- if (dirty & /*config*/
18184
- 8) {
18192
+ if (dirty & /*config, hidden_zoom_control*/
18193
+ 136) {
18185
18194
  transition_in(if_block2, 1);
18186
18195
  }
18187
18196
  } else {
@@ -18197,13 +18206,14 @@ function create_fragment78(ctx) {
18197
18206
  });
18198
18207
  check_outros();
18199
18208
  }
18200
- if (!current || dirty & /*layout*/
18201
- 32) {
18209
+ if (!current || dirty & /*hidden_toolbar, hidden_redo_undo*/
18210
+ 96) {
18202
18211
  toggle_class(
18203
18212
  div2,
18204
18213
  "hidden",
18205
- /*layout*/
18206
- ctx2[5] !== "visible"
18214
+ /*hidden_toolbar*/
18215
+ ctx2[5] && /*hidden_redo_undo*/
18216
+ ctx2[6]
18207
18217
  );
18208
18218
  }
18209
18219
  if (
@@ -18229,13 +18239,13 @@ function create_fragment78(ctx) {
18229
18239
  });
18230
18240
  check_outros();
18231
18241
  }
18232
- if (!current || dirty & /*layout*/
18233
- 32) {
18242
+ if (!current || dirty & /*hidden_page_control*/
18243
+ 256) {
18234
18244
  toggle_class(
18235
18245
  div3,
18236
18246
  "hidden",
18237
- /*layout*/
18238
- ctx2[5] !== "visible"
18247
+ /*hidden_page_control*/
18248
+ ctx2[8]
18239
18249
  );
18240
18250
  }
18241
18251
  if (!current || dirty & /*app*/
@@ -18263,7 +18273,7 @@ function create_fragment78(ctx) {
18263
18273
  d(detaching) {
18264
18274
  if (detaching)
18265
18275
  detach(div4);
18266
- ctx[16](null);
18276
+ ctx[26](null);
18267
18277
  if (if_block0)
18268
18278
  if_block0.d();
18269
18279
  if (if_block1)
@@ -18282,22 +18292,33 @@ function instance78($$self, $$props, $$invalidate) {
18282
18292
  let writable2;
18283
18293
  let boxState;
18284
18294
  let focusedApp;
18295
+ let visibleApps;
18285
18296
  let toolbar_has_items;
18286
- let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(13, $focusedApp = $$value)), focusedApp);
18287
- let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(14, $boxState = $$value)), boxState);
18288
- let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(15, $writable = $$value)), writable2);
18297
+ let $focusedApp, $$unsubscribe_focusedApp = noop, $$subscribe_focusedApp = () => ($$unsubscribe_focusedApp(), $$unsubscribe_focusedApp = subscribe(focusedApp, ($$value) => $$invalidate(22, $focusedApp = $$value)), focusedApp);
18298
+ let $boxState, $$unsubscribe_boxState = noop, $$subscribe_boxState = () => ($$unsubscribe_boxState(), $$unsubscribe_boxState = subscribe(boxState, ($$value) => $$invalidate(23, $boxState = $$value)), boxState);
18299
+ let $visibleApps, $$unsubscribe_visibleApps = noop, $$subscribe_visibleApps = () => ($$unsubscribe_visibleApps(), $$unsubscribe_visibleApps = subscribe(visibleApps, ($$value) => $$invalidate(24, $visibleApps = $$value)), visibleApps);
18300
+ let $writable, $$unsubscribe_writable = noop, $$subscribe_writable = () => ($$unsubscribe_writable(), $$unsubscribe_writable = subscribe(writable2, ($$value) => $$invalidate(25, $writable = $$value)), writable2);
18289
18301
  $$self.$$.on_destroy.push(() => $$unsubscribe_focusedApp());
18290
18302
  $$self.$$.on_destroy.push(() => $$unsubscribe_boxState());
18303
+ $$self.$$.on_destroy.push(() => $$unsubscribe_visibleApps());
18291
18304
  $$self.$$.on_destroy.push(() => $$unsubscribe_writable());
18292
18305
  let { app = null } = $$props;
18293
18306
  let { theme = "light" } = $$props;
18294
18307
  let { language = "en" } = $$props;
18295
18308
  let { containerRef = void 0 } = $$props;
18296
18309
  let { config = {} } = $$props;
18297
- const AppsShowToolbar = ["DocsViewer", "Slide"];
18310
+ let { force_show_toolbar = void 0 } = $$props;
18311
+ let { force_show_redo_undo = void 0 } = $$props;
18312
+ let { force_show_zoom_control = void 0 } = $$props;
18313
+ let { force_show_page_control = void 0 } = $$props;
18314
+ const AppsShowToolbar = ["DocsViewer", "Slide", "PDFjs"];
18298
18315
  let container;
18299
18316
  let layout = "hidden";
18300
18317
  let mounted = false;
18318
+ let hidden_toolbar = false;
18319
+ let hidden_redo_undo = false;
18320
+ let hidden_zoom_control = false;
18321
+ let hidden_page_control = false;
18301
18322
  onMount(() => {
18302
18323
  if (containerRef) {
18303
18324
  containerRef(container);
@@ -18326,47 +18347,73 @@ function instance78($$self, $$props, $$invalidate) {
18326
18347
  if ("language" in $$props2)
18327
18348
  $$invalidate(2, language = $$props2.language);
18328
18349
  if ("containerRef" in $$props2)
18329
- $$invalidate(11, containerRef = $$props2.containerRef);
18350
+ $$invalidate(14, containerRef = $$props2.containerRef);
18330
18351
  if ("config" in $$props2)
18331
18352
  $$invalidate(3, config = $$props2.config);
18353
+ if ("force_show_toolbar" in $$props2)
18354
+ $$invalidate(15, force_show_toolbar = $$props2.force_show_toolbar);
18355
+ if ("force_show_redo_undo" in $$props2)
18356
+ $$invalidate(16, force_show_redo_undo = $$props2.force_show_redo_undo);
18357
+ if ("force_show_zoom_control" in $$props2)
18358
+ $$invalidate(17, force_show_zoom_control = $$props2.force_show_zoom_control);
18359
+ if ("force_show_page_control" in $$props2)
18360
+ $$invalidate(18, force_show_page_control = $$props2.force_show_page_control);
18332
18361
  };
18333
18362
  $$self.$$.update = () => {
18334
18363
  if ($$self.$$.dirty & /*app*/
18335
18364
  1) {
18336
- $$subscribe_writable($$invalidate(9, writable2 = app == null ? void 0 : app.writable));
18365
+ $$subscribe_writable($$invalidate(12, writable2 = app == null ? void 0 : app.writable));
18366
+ }
18367
+ if ($$self.$$.dirty & /*app*/
18368
+ 1) {
18369
+ $$subscribe_boxState($$invalidate(11, boxState = app == null ? void 0 : app.boxState));
18337
18370
  }
18338
18371
  if ($$self.$$.dirty & /*app*/
18339
18372
  1) {
18340
- $$subscribe_boxState($$invalidate(8, boxState = app == null ? void 0 : app.boxState));
18373
+ $$subscribe_focusedApp($$invalidate(10, focusedApp = app == null ? void 0 : app.focusedApp));
18341
18374
  }
18342
18375
  if ($$self.$$.dirty & /*app*/
18343
18376
  1) {
18344
- $$subscribe_focusedApp($$invalidate(7, focusedApp = app == null ? void 0 : app.focusedApp));
18377
+ $$subscribe_visibleApps($$invalidate(9, visibleApps = app == null ? void 0 : app.visibleApps));
18345
18378
  }
18346
- if ($$self.$$.dirty & /*$writable, $boxState, $focusedApp*/
18347
- 57344) {
18379
+ if ($$self.$$.dirty & /*$writable, app, $visibleApps, $boxState, $focusedApp*/
18380
+ 62914561) {
18348
18381
  if (!$writable) {
18349
- $$invalidate(5, layout = "hidden");
18382
+ $$invalidate(19, layout = "hidden");
18383
+ } else if (app == null ? void 0 : app.appInMainViewPlugin) {
18384
+ if ($visibleApps && $visibleApps.size > 0) {
18385
+ if ($boxState === "maximized") {
18386
+ if (AppsShowToolbar.some((kind) => ($focusedApp || "").includes(kind))) {
18387
+ $$invalidate(19, layout = "toolbar-only");
18388
+ } else {
18389
+ $$invalidate(19, layout = "hidden");
18390
+ }
18391
+ } else {
18392
+ $$invalidate(19, layout = "visible");
18393
+ }
18394
+ } else {
18395
+ $$invalidate(19, layout = "visible");
18396
+ }
18350
18397
  } else if ($boxState === "maximized") {
18351
18398
  if ($focusedApp && AppsShowToolbar.some((kind) => ($focusedApp || "").includes(kind))) {
18352
- $$invalidate(5, layout = "toolbar-only");
18399
+ $$invalidate(19, layout = "toolbar-only");
18353
18400
  } else {
18354
- $$invalidate(5, layout = "hidden");
18401
+ $$invalidate(19, layout = "hidden");
18355
18402
  }
18356
18403
  } else {
18357
- $$invalidate(5, layout = "visible");
18404
+ $$invalidate(19, layout = "visible");
18358
18405
  }
18359
18406
  }
18360
18407
  if ($$self.$$.dirty & /*config*/
18361
18408
  8) {
18362
- $$invalidate(6, toolbar_has_items = !config.toolbar || !config.toolbar.items || !config.toolbar.apps || config.toolbar.items.length > 0 || config.toolbar.apps.enable !== false);
18409
+ $$invalidate(21, toolbar_has_items = !config.toolbar || !config.toolbar.items || !config.toolbar.apps || config.toolbar.items.length > 0 || config.toolbar.apps.enable !== false);
18363
18410
  }
18364
18411
  if ($$self.$$.dirty & /*app, container*/
18365
18412
  17) {
18366
18413
  try {
18367
18414
  if (app && container) {
18368
18415
  app.bindContainer(container);
18369
- $$invalidate(12, mounted = true);
18416
+ $$invalidate(20, mounted = true);
18370
18417
  }
18371
18418
  } catch (err) {
18372
18419
  console.error("[fastboard] An error occurred while binding container");
@@ -18374,11 +18421,51 @@ function instance78($$self, $$props, $$invalidate) {
18374
18421
  }
18375
18422
  }
18376
18423
  if ($$self.$$.dirty & /*app, theme, mounted*/
18377
- 4099) {
18424
+ 1048579) {
18378
18425
  if (app && theme && mounted) {
18379
18426
  app.manager.setPrefersColorScheme(theme);
18380
18427
  }
18381
18428
  }
18429
+ if ($$self.$$.dirty & /*force_show_toolbar, toolbar_has_items, layout*/
18430
+ 2654208) {
18431
+ if (force_show_toolbar === false) {
18432
+ $$invalidate(5, hidden_toolbar = true);
18433
+ } else if (force_show_toolbar === true) {
18434
+ $$invalidate(5, hidden_toolbar = false);
18435
+ } else {
18436
+ $$invalidate(5, hidden_toolbar = !toolbar_has_items || !(layout === "visible" || layout === "toolbar-only"));
18437
+ }
18438
+ }
18439
+ if ($$self.$$.dirty & /*force_show_redo_undo, layout*/
18440
+ 589824) {
18441
+ if (force_show_redo_undo === false) {
18442
+ $$invalidate(6, hidden_redo_undo = true);
18443
+ } else if (force_show_redo_undo === true) {
18444
+ $$invalidate(6, hidden_redo_undo = false);
18445
+ } else {
18446
+ $$invalidate(6, hidden_redo_undo = layout !== "visible");
18447
+ }
18448
+ }
18449
+ if ($$self.$$.dirty & /*force_show_zoom_control, layout*/
18450
+ 655360) {
18451
+ if (force_show_zoom_control === false) {
18452
+ $$invalidate(7, hidden_zoom_control = true);
18453
+ } else if (force_show_zoom_control === true) {
18454
+ $$invalidate(7, hidden_zoom_control = false);
18455
+ } else {
18456
+ $$invalidate(7, hidden_zoom_control = layout !== "visible");
18457
+ }
18458
+ }
18459
+ if ($$self.$$.dirty & /*force_show_page_control, layout*/
18460
+ 786432) {
18461
+ if (force_show_page_control === false) {
18462
+ $$invalidate(8, hidden_page_control = true);
18463
+ } else if (force_show_page_control === true) {
18464
+ $$invalidate(8, hidden_page_control = false);
18465
+ } else {
18466
+ $$invalidate(8, hidden_page_control = layout !== "visible");
18467
+ }
18468
+ }
18382
18469
  };
18383
18470
  return [
18384
18471
  app,
@@ -18386,16 +18473,26 @@ function instance78($$self, $$props, $$invalidate) {
18386
18473
  language,
18387
18474
  config,
18388
18475
  container,
18389
- layout,
18390
- toolbar_has_items,
18476
+ hidden_toolbar,
18477
+ hidden_redo_undo,
18478
+ hidden_zoom_control,
18479
+ hidden_page_control,
18480
+ visibleApps,
18391
18481
  focusedApp,
18392
18482
  boxState,
18393
18483
  writable2,
18394
18484
  focus_me,
18395
18485
  containerRef,
18486
+ force_show_toolbar,
18487
+ force_show_redo_undo,
18488
+ force_show_zoom_control,
18489
+ force_show_page_control,
18490
+ layout,
18396
18491
  mounted,
18492
+ toolbar_has_items,
18397
18493
  $focusedApp,
18398
18494
  $boxState,
18495
+ $visibleApps,
18399
18496
  $writable,
18400
18497
  div0_binding
18401
18498
  ];
@@ -18407,8 +18504,12 @@ var Fastboard = class extends SvelteComponent {
18407
18504
  app: 0,
18408
18505
  theme: 1,
18409
18506
  language: 2,
18410
- containerRef: 11,
18411
- config: 3
18507
+ containerRef: 14,
18508
+ config: 3,
18509
+ force_show_toolbar: 15,
18510
+ force_show_redo_undo: 16,
18511
+ force_show_zoom_control: 17,
18512
+ force_show_page_control: 18
18412
18513
  });
18413
18514
  }
18414
18515
  };
@@ -18456,6 +18557,66 @@ function createUI(app, div) {
18456
18557
  fastboard.$destroy();
18457
18558
  }
18458
18559
  fastboard = void 0;
18560
+ },
18561
+ forceShowToolbar() {
18562
+ if (fastboard) {
18563
+ fastboard.$set({ force_show_toolbar: true });
18564
+ }
18565
+ },
18566
+ forceHideToolbar() {
18567
+ if (fastboard) {
18568
+ fastboard.$set({ force_show_toolbar: false });
18569
+ }
18570
+ },
18571
+ recoverToolbar() {
18572
+ if (fastboard) {
18573
+ fastboard.$set({ force_show_toolbar: void 0 });
18574
+ }
18575
+ },
18576
+ forceShowPageControl() {
18577
+ if (fastboard) {
18578
+ fastboard.$set({ force_show_page_control: true });
18579
+ }
18580
+ },
18581
+ forceHidePageControl() {
18582
+ if (fastboard) {
18583
+ fastboard.$set({ force_show_page_control: false });
18584
+ }
18585
+ },
18586
+ recoverPageControl() {
18587
+ if (fastboard) {
18588
+ fastboard.$set({ force_show_page_control: void 0 });
18589
+ }
18590
+ },
18591
+ forceShowRedoUndo() {
18592
+ if (fastboard) {
18593
+ fastboard.$set({ force_show_redo_undo: true });
18594
+ }
18595
+ },
18596
+ forceHideRedoUndo() {
18597
+ if (fastboard) {
18598
+ fastboard.$set({ force_show_redo_undo: false });
18599
+ }
18600
+ },
18601
+ recoverRedoUndo() {
18602
+ if (fastboard) {
18603
+ fastboard.$set({ force_show_redo_undo: void 0 });
18604
+ }
18605
+ },
18606
+ forceShowZoomControl() {
18607
+ if (fastboard) {
18608
+ fastboard.$set({ force_show_zoom_control: true });
18609
+ }
18610
+ },
18611
+ forceHideZoomControl() {
18612
+ if (fastboard) {
18613
+ fastboard.$set({ force_show_zoom_control: false });
18614
+ }
18615
+ },
18616
+ recoverZoomControl() {
18617
+ if (fastboard) {
18618
+ fastboard.$set({ force_show_zoom_control: void 0 });
18619
+ }
18459
18620
  }
18460
18621
  };
18461
18622
  if (div) {