@netless/app-presentation 0.1.9-beta.5 → 0.1.9-beta.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.
@@ -40,7 +40,7 @@ var NetlessAppPresentation = (function (exports) {
40
40
  // file that has been converted to a CommonJS file using a Babel-
41
41
  // compatible transform (i.e. "__esModule" has not been set), then set
42
42
  // "default" to the CommonJS "module.exports" for node compatibility.
43
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
44
44
  mod
45
45
  ));
46
46
 
@@ -1026,9 +1026,9 @@ var NetlessAppPresentation = (function (exports) {
1026
1026
  return getMapData(this, key).has(key);
1027
1027
  }
1028
1028
  function mapCacheSet(key, value) {
1029
- var data = getMapData(this, key), size2 = data.size;
1029
+ var data = getMapData(this, key), size3 = data.size;
1030
1030
  data.set(key, value);
1031
- this.size += data.size == size2 ? 0 : 1;
1031
+ this.size += data.size == size3 ? 0 : 1;
1032
1032
  return this;
1033
1033
  }
1034
1034
  MapCache.prototype.clear = mapCacheClear;
@@ -2485,7 +2485,7 @@ var NetlessAppPresentation = (function (exports) {
2485
2485
  bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
2486
2486
  bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
2487
2487
  if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
2488
- bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
2488
+ bitmask &= -4;
2489
2489
  }
2490
2490
  var newData = [
2491
2491
  func,
@@ -2541,7 +2541,7 @@ var NetlessAppPresentation = (function (exports) {
2541
2541
  }
2542
2542
  var length = partials ? partials.length : 0;
2543
2543
  if (!length) {
2544
- bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
2544
+ bitmask &= -97;
2545
2545
  partials = holders = undefined2;
2546
2546
  }
2547
2547
  ary2 = ary2 === undefined2 ? ary2 : nativeMax(toInteger(ary2), 0);
@@ -2574,7 +2574,7 @@ var NetlessAppPresentation = (function (exports) {
2574
2574
  holders = newData[4];
2575
2575
  arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0);
2576
2576
  if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
2577
- bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
2577
+ bitmask &= -25;
2578
2578
  }
2579
2579
  if (!bitmask || bitmask == WRAP_BIND_FLAG) {
2580
2580
  var result2 = createBind(func, bitmask, thisArg);
@@ -2842,19 +2842,19 @@ var NetlessAppPresentation = (function (exports) {
2842
2842
  function getView(start, end, transforms) {
2843
2843
  var index = -1, length = transforms.length;
2844
2844
  while (++index < length) {
2845
- var data = transforms[index], size2 = data.size;
2845
+ var data = transforms[index], size3 = data.size;
2846
2846
  switch (data.type) {
2847
2847
  case "drop":
2848
- start += size2;
2848
+ start += size3;
2849
2849
  break;
2850
2850
  case "dropRight":
2851
- end -= size2;
2851
+ end -= size3;
2852
2852
  break;
2853
2853
  case "take":
2854
- end = nativeMin(end, start + size2);
2854
+ end = nativeMin(end, start + size3);
2855
2855
  break;
2856
2856
  case "takeRight":
2857
- start = nativeMax(start, end - size2);
2857
+ start = nativeMax(start, end - size3);
2858
2858
  break;
2859
2859
  }
2860
2860
  }
@@ -3114,15 +3114,15 @@ var NetlessAppPresentation = (function (exports) {
3114
3114
  return func.apply(undefined2, arguments);
3115
3115
  };
3116
3116
  }
3117
- function shuffleSelf(array, size2) {
3117
+ function shuffleSelf(array, size3) {
3118
3118
  var index = -1, length = array.length, lastIndex = length - 1;
3119
- size2 = size2 === undefined2 ? length : size2;
3120
- while (++index < size2) {
3119
+ size3 = size3 === undefined2 ? length : size3;
3120
+ while (++index < size3) {
3121
3121
  var rand = baseRandom(index, lastIndex), value = array[rand];
3122
3122
  array[rand] = array[index];
3123
3123
  array[index] = value;
3124
3124
  }
3125
- array.length = size2;
3125
+ array.length = size3;
3126
3126
  return array;
3127
3127
  }
3128
3128
  var stringToPath = memoizeCapped(function(string) {
@@ -3174,19 +3174,19 @@ var NetlessAppPresentation = (function (exports) {
3174
3174
  result2.__values__ = wrapper.__values__;
3175
3175
  return result2;
3176
3176
  }
3177
- function chunk(array, size2, guard) {
3178
- if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
3179
- size2 = 1;
3177
+ function chunk(array, size3, guard) {
3178
+ if (guard ? isIterateeCall(array, size3, guard) : size3 === undefined2) {
3179
+ size3 = 1;
3180
3180
  } else {
3181
- size2 = nativeMax(toInteger(size2), 0);
3181
+ size3 = nativeMax(toInteger(size3), 0);
3182
3182
  }
3183
3183
  var length = array == null ? 0 : array.length;
3184
- if (!length || size2 < 1) {
3184
+ if (!length || size3 < 1) {
3185
3185
  return [];
3186
3186
  }
3187
- var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length / size2));
3187
+ var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length / size3));
3188
3188
  while (index < length) {
3189
- result2[resIndex++] = baseSlice(array, index, index += size2);
3189
+ result2[resIndex++] = baseSlice(array, index, index += size3);
3190
3190
  }
3191
3191
  return result2;
3192
3192
  }
@@ -3862,7 +3862,7 @@ var NetlessAppPresentation = (function (exports) {
3862
3862
  result2.placeholder = curryRight.placeholder;
3863
3863
  return result2;
3864
3864
  }
3865
- function debounce2(func, wait, options) {
3865
+ function debounce3(func, wait, options) {
3866
3866
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
3867
3867
  if (typeof func != "function") {
3868
3868
  throw new TypeError2(FUNC_ERROR_TEXT);
@@ -4042,7 +4042,7 @@ var NetlessAppPresentation = (function (exports) {
4042
4042
  leading = "leading" in options ? !!options.leading : leading;
4043
4043
  trailing = "trailing" in options ? !!options.trailing : trailing;
4044
4044
  }
4045
- return debounce2(func, wait, {
4045
+ return debounce3(func, wait, {
4046
4046
  "leading": leading,
4047
4047
  "maxWait": wait,
4048
4048
  "trailing": trailing
@@ -4994,7 +4994,7 @@ var NetlessAppPresentation = (function (exports) {
4994
4994
  var id = ++idCounter;
4995
4995
  return toString(prefix) + id;
4996
4996
  }
4997
- var add = createMathOperation(function(augend, addend) {
4997
+ var add2 = createMathOperation(function(augend, addend) {
4998
4998
  return augend + addend;
4999
4999
  }, 0);
5000
5000
  var ceil = createRound("ceil");
@@ -5056,7 +5056,7 @@ var NetlessAppPresentation = (function (exports) {
5056
5056
  lodash.create = create;
5057
5057
  lodash.curry = curry;
5058
5058
  lodash.curryRight = curryRight;
5059
- lodash.debounce = debounce2;
5059
+ lodash.debounce = debounce3;
5060
5060
  lodash.defaults = defaults;
5061
5061
  lodash.defaultsDeep = defaultsDeep;
5062
5062
  lodash.defer = defer;
@@ -5187,7 +5187,7 @@ var NetlessAppPresentation = (function (exports) {
5187
5187
  lodash.extend = assignIn;
5188
5188
  lodash.extendWith = assignInWith;
5189
5189
  mixin(lodash, lodash);
5190
- lodash.add = add;
5190
+ lodash.add = add2;
5191
5191
  lodash.attempt = attempt;
5192
5192
  lodash.camelCase = camelCase;
5193
5193
  lodash.capitalize = capitalize;
@@ -5524,72 +5524,81 @@ var NetlessAppPresentation = (function (exports) {
5524
5524
  }
5525
5525
  });
5526
5526
 
5527
- // node_modules/.pnpm/@wopjs+disposable@0.1.5/node_modules/@wopjs/disposable/dist/index.mjs
5528
- var isAbortable = (disposable) => disposable && disposable.abortable;
5529
- var dispose = (disposable) => {
5527
+ // node_modules/.pnpm/@wopjs+disposable@0.1.19/node_modules/@wopjs/disposable/dist/index.mjs
5528
+ var isFn = (value) => !!(value && value.constructor && value.call && value.apply);
5529
+ var isDisposable = (value) => isFn(value) || isFn(value == null ? void 0 : value.dispose);
5530
+ function dispose(disposable) {
5530
5531
  try {
5531
5532
  if (disposable) {
5532
- if (disposable.dispose) {
5533
+ if (isFn(disposable.dispose)) {
5533
5534
  disposable.dispose();
5534
- } else if (disposable.constructor && disposable.call && disposable.apply) {
5535
+ } else if (isFn(disposable)) {
5535
5536
  disposable();
5536
5537
  }
5537
5538
  }
5538
5539
  } catch (e) {
5539
5540
  console.error(e);
5540
5541
  }
5541
- };
5542
- var methods = {
5543
- size() {
5544
- return this._d.size;
5545
- },
5546
- has(disposable) {
5547
- return this._d.has(disposable);
5548
- },
5549
- add(disposable) {
5550
- const disposables = Array.isArray(disposable) ? disposable : [disposable];
5551
- for (const disposable2 of disposables) {
5552
- if (!this._d.has(disposable2)) {
5553
- this._d.add(disposable2);
5554
- if (isAbortable(disposable2)) {
5555
- disposable2.abortable(() => this.remove(disposable2));
5556
- }
5557
- }
5558
- }
5559
- return disposable;
5560
- },
5561
- make(executor) {
5562
- const disposable = executor();
5563
- if (disposable) {
5564
- return this.add(disposable);
5565
- }
5566
- },
5567
- remove(disposable) {
5568
- return this._d.delete(disposable);
5569
- },
5570
- flush(disposable) {
5571
- if (disposable) {
5572
- if (this.remove(disposable)) {
5573
- dispose(disposable);
5574
- }
5575
- } else {
5576
- this.dispose();
5577
- }
5542
+ }
5543
+ var isAbortable = (disposable) => isDisposable(disposable) && isFn(disposable.abortable);
5544
+ function disposableStore(disposables) {
5545
+ function disposableStore2() {
5546
+ var _a, _b;
5547
+ if (disposableStore2._i)
5548
+ return;
5549
+ disposableStore2._i = 1;
5550
+ (_a = disposableStore2._d) == null ? void 0 : _a.forEach(dispose);
5551
+ (_b = disposableStore2._d) == null ? void 0 : _b.clear();
5552
+ disposableStore2._i = 0;
5578
5553
  }
5579
- };
5580
- var disposableStore = (disposables) => {
5581
- const disposableStore2 = () => {
5582
- disposableStore2._d.forEach(dispose);
5583
- disposableStore2._d.clear();
5584
- };
5585
- disposableStore2._d = /* @__PURE__ */ new Set();
5554
+ disposableStore2._i = 0;
5586
5555
  disposableStore2.dispose = disposableStore2;
5587
- const store = Object.assign(disposableStore2, methods);
5588
- if (disposables) {
5589
- store.add(disposables);
5556
+ disposableStore2.size = size2;
5557
+ disposableStore2.has = has2;
5558
+ disposableStore2.add = add;
5559
+ disposableStore2.make = make3;
5560
+ disposableStore2.remove = remove3;
5561
+ disposableStore2.flush = flush2;
5562
+ return disposableStore2;
5563
+ }
5564
+ function _addOne(disposable) {
5565
+ var _a, _b;
5566
+ if (!((_a = this._d) == null ? void 0 : _a.has(disposable))) {
5567
+ ((_b = this._d) != null ? _b : this._d = /* @__PURE__ */ new Set()).add(disposable);
5568
+ if (isAbortable(disposable)) {
5569
+ disposable.abortable(() => this.remove(disposable));
5570
+ }
5590
5571
  }
5591
- return store;
5592
- };
5572
+ }
5573
+ function add(disposables) {
5574
+ Array.isArray(disposables) ? disposables.forEach(_addOne, this) : _addOne.call(this, disposables);
5575
+ return disposables;
5576
+ }
5577
+ function flush2(disposable) {
5578
+ if (disposable) {
5579
+ if (this.remove(disposable)) {
5580
+ dispose(disposable);
5581
+ }
5582
+ } else {
5583
+ this.dispose();
5584
+ }
5585
+ }
5586
+ function has2(disposable) {
5587
+ var _a;
5588
+ return ((_a = this._d) == null ? void 0 : _a.has(disposable)) || false;
5589
+ }
5590
+ function make3(executor) {
5591
+ const disposable = executor();
5592
+ return disposable && this.add(disposable);
5593
+ }
5594
+ function remove3(disposable) {
5595
+ var _a;
5596
+ return ((_a = this._d) == null ? void 0 : _a.delete(disposable)) || false;
5597
+ }
5598
+ function size2() {
5599
+ var _a;
5600
+ return ((_a = this._d) == null ? void 0 : _a.size) || 0;
5601
+ }
5593
5602
 
5594
5603
  // node_modules/.pnpm/@wopjs+dom@0.1.3/node_modules/@wopjs/dom/dist/index.js
5595
5604
  function addEventListener(target, type, listener, options) {
@@ -6456,9 +6465,6 @@ var NetlessAppPresentation = (function (exports) {
6456
6465
  this.contentDOM.className = this.c("content");
6457
6466
  this.previewDOM = document.createElement("div");
6458
6467
  this.previewDOM.className = this.c("preview");
6459
- this.imageDOM = document.createElement("div");
6460
- this.imageDOM.className = this.c("image");
6461
- this.image = document.createElement("img");
6462
6468
  this.whiteboardDOM = document.createElement("div");
6463
6469
  this.whiteboardDOM.className = this.c("wb-view");
6464
6470
  this.footerDOM = document.createElement("div");
@@ -6528,8 +6534,6 @@ var NetlessAppPresentation = (function (exports) {
6528
6534
  this.togglePreview(false);
6529
6535
  }
6530
6536
  }));
6531
- this.imageDOM.appendChild(this.image);
6532
- this.contentDOM.appendChild(this.imageDOM);
6533
6537
  this.updateImage();
6534
6538
  this.contentDOM.appendChild(this.whiteboardDOM);
6535
6539
  this.footerDOM.classList.toggle(this.c("readonly"), this.readonly);
@@ -6838,17 +6842,22 @@ var NetlessAppPresentation = (function (exports) {
6838
6842
  return;
6839
6843
  const { scale, centerX, centerY } = this.view.camera;
6840
6844
  const originScale = this.option.getOriginScale();
6841
- const ratio = Math.round(originScale / scale * 1e3) / 1e3;
6842
- const scrollX = Math.round(centerX * originScale);
6843
- const scrollY = Math.round(centerY * originScale);
6845
+ const { width: pageWidth, height: pageHeight } = this.option.getPageSize();
6846
+ const { width: viewWidth, height: viewHeight } = this.view.size;
6847
+ const originScaleX = viewWidth / pageWidth;
6848
+ const originScaleY = viewHeight / pageHeight;
6849
+ const ratioX = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
6850
+ const ratioY = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
6851
+ const scrollX = Math.round(centerX * originScaleX);
6852
+ const scrollY = Math.round(centerY * originScaleY);
6844
6853
  if (this.scrollbarX) {
6845
- this.scrollbarX.style.width = `${ratio * 100}%`;
6846
- this.scrollbarX.style.display = ratio === 1 ? "none" : "block";
6854
+ this.scrollbarX.style.width = `${ratioX * 100}%`;
6855
+ this.scrollbarX.style.display = ratioX === 1 ? "none" : "block";
6847
6856
  this.scrollbarX.style.transform = `translateX(${scrollX}px)`;
6848
6857
  }
6849
6858
  if (this.scrollbarY) {
6850
- this.scrollbarY.style.height = `${ratio * 100}%`;
6851
- this.scrollbarY.style.display = ratio === 1 ? "none" : "block";
6859
+ this.scrollbarY.style.height = `${ratioY * 100}%`;
6860
+ this.scrollbarY.style.display = ratioY === 1 ? "none" : "block";
6852
6861
  this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
6853
6862
  }
6854
6863
  (_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, this.appId, originScale, scale);
@@ -6867,9 +6876,11 @@ var NetlessAppPresentation = (function (exports) {
6867
6876
  var _a, _b;
6868
6877
  if (this.cameraCache) {
6869
6878
  const { x } = transformedDrag;
6870
- const originScale = this.option.getOriginScale();
6879
+ const { width: pageWidth } = this.option.getPageSize();
6880
+ const { width: viewWidth } = this.view.size;
6881
+ const originScaleX = viewWidth / pageWidth;
6871
6882
  const { minX, maxX } = this.getScrollXRange(this.cameraCache);
6872
- const scrollX = Math.round(x / originScale);
6883
+ const scrollX = Math.round(x / originScaleX);
6873
6884
  let centerX = scrollX + this.cameraCache.centerX;
6874
6885
  if (centerX < minX) {
6875
6886
  centerX = minX;
@@ -6887,9 +6898,11 @@ var NetlessAppPresentation = (function (exports) {
6887
6898
  var _a, _b;
6888
6899
  if (this.cameraCache) {
6889
6900
  const { y } = transformedDrag;
6890
- const originScale = this.option.getOriginScale();
6901
+ const { height: pageHeight } = this.option.getPageSize();
6902
+ const { height: viewHeight } = this.view.size;
6903
+ const originScaleY = viewHeight / pageHeight;
6891
6904
  const { minY, maxY } = this.getScrollYRange(this.cameraCache);
6892
- const scrollY = Math.round(y / originScale);
6905
+ const scrollY = Math.round(y / originScaleY);
6893
6906
  let centerY = scrollY + this.cameraCache.centerY;
6894
6907
  if (centerY < minY) {
6895
6908
  centerY = minY;
@@ -6928,21 +6941,23 @@ var NetlessAppPresentation = (function (exports) {
6928
6941
  }
6929
6942
  }
6930
6943
  getScrollXRange(camera) {
6931
- const { width } = this.option.getPageSize();
6932
- const originScale = this.option.getOriginScale();
6944
+ const { width: pageWidth } = this.option.getPageSize();
6945
+ const { width: viewWidth } = this.view.size;
6946
+ const originScaleX = viewWidth / pageWidth;
6933
6947
  const scale = camera.scale;
6934
- const ratio = Math.round(originScale / scale * 1e3) / 1e3;
6935
- const scrollWidth = width * (1 - ratio);
6948
+ const ratio = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
6949
+ const scrollWidth = pageWidth * (1 - ratio);
6936
6950
  const minX = -scrollWidth / 2;
6937
6951
  const maxX = scrollWidth / 2;
6938
6952
  return { minX, maxX };
6939
6953
  }
6940
6954
  getScrollYRange(camera) {
6941
- const { height } = this.option.getPageSize();
6942
- const originScale = this.option.getOriginScale();
6955
+ const { height: pageHeight } = this.option.getPageSize();
6956
+ const { height: viewHeight } = this.view.size;
6957
+ const originScaleY = viewHeight / pageHeight;
6943
6958
  const scale = camera.scale;
6944
- const ratio = Math.round(originScale / scale * 1e3) / 1e3;
6945
- const scrollHeight = height * (1 - ratio);
6959
+ const ratio = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
6960
+ const scrollHeight = pageHeight * (1 - ratio);
6946
6961
  const minY = -scrollHeight / 2;
6947
6962
  const maxY = scrollHeight / 2;
6948
6963
  return { minY, maxY };
@@ -7013,6 +7028,7 @@ var NetlessAppPresentation = (function (exports) {
7013
7028
  };
7014
7029
 
7015
7030
  // src/app-presentation.ts
7031
+ var import_lodash2 = __toESM(require_lodash());
7016
7032
  var emptySceneName = "$$empty$$";
7017
7033
  var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
7018
7034
  var createLogger = (room) => {
@@ -7094,9 +7110,9 @@ var NetlessAppPresentation = (function (exports) {
7094
7110
  if (pages.length > 100)
7095
7111
  console.warn(`[Presentation]: too many pages (${pages.length}), may cause performance issues`);
7096
7112
  let redirectResolve = void 0;
7097
- const room = context.getRoom();
7098
- if (room && room.isWritable) {
7099
- const scenes = room.entireScenes()[scenePath];
7113
+ const room2 = context.getRoom();
7114
+ if (room2 && room2.isWritable) {
7115
+ const scenes = room2.entireScenes()[scenePath];
7100
7116
  if (pageIndex$.value < 0 || pageIndex$.value >= pages.length) {
7101
7117
  throw new Error(`[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`);
7102
7118
  }
@@ -7111,8 +7127,8 @@ var NetlessAppPresentation = (function (exports) {
7111
7127
  };
7112
7128
  });
7113
7129
  if (!scenesEqual(scenes, _scenes)) {
7114
- room.removeScenes(scenePath);
7115
- room.putScenes(scenePath, _scenes);
7130
+ room2.removeScenes(scenePath);
7131
+ room2.putScenes(scenePath, _scenes);
7116
7132
  }
7117
7133
  if (name === _scenes[pageIndex$.value].name && !ppt) {
7118
7134
  context.addPage({ scene: { name: emptySceneName } }).then(() => {
@@ -7125,10 +7141,10 @@ var NetlessAppPresentation = (function (exports) {
7125
7141
  redirectResolve && redirectResolve(false);
7126
7142
  }
7127
7143
  }).then(async (bol) => {
7128
- await syncPage(pageIndex$.value, room.logger);
7144
+ await syncPage(pageIndex$.value, room2.logger);
7129
7145
  if (bol) {
7130
7146
  log(`[Presentation] setup removeScenes ${scenePath}/${emptySceneName}`);
7131
- room.removeScenes(`${scenePath}/${emptySceneName}`);
7147
+ room2.removeScenes(`${scenePath}/${emptySceneName}`);
7132
7148
  }
7133
7149
  });
7134
7150
  }
@@ -7243,14 +7259,32 @@ var NetlessAppPresentation = (function (exports) {
7243
7259
  }
7244
7260
  };
7245
7261
  dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
7262
+ const getPageSize = () => {
7263
+ const { width, height } = app.page() || {};
7264
+ return { width: width || 0, height: height || 0 };
7265
+ };
7246
7266
  const box = context.getBox();
7247
- const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
7248
- app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.5";
7267
+ const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
7268
+ app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.6";
7249
7269
  app.scaleDocsToFit = scaleDocsToFit;
7250
7270
  app.log = log;
7251
7271
  if (options.justDocsViewReadonly) {
7252
7272
  app.setDocsViewReadonly(true);
7253
7273
  }
7274
+ const room = context.getRoom();
7275
+ const goToPageByClick = () => {
7276
+ var _a2, _b2, _c2, _d;
7277
+ const currentApplianceName = (_d = (_c2 = (_b2 = (_a2 = context.getRoom()) == null ? void 0 : _a2.state) == null ? void 0 : _b2.memberState) == null ? void 0 : _c2.currentApplianceName) != null ? _d : "";
7278
+ if (!app.readonly && currentApplianceName === "clicker") {
7279
+ nextPage();
7280
+ }
7281
+ };
7282
+ if (room && options.goToPageByClick && app.whiteboardDOM) {
7283
+ dispose2.make(() => {
7284
+ app.whiteboardDOM.addEventListener("click", goToPageByClick);
7285
+ return () => app.whiteboardDOM.removeEventListener("click", goToPageByClick);
7286
+ });
7287
+ }
7254
7288
  context.mountView(app.whiteboardDOM);
7255
7289
  if (options.disableCameraTransform) {
7256
7290
  view.disableCameraTransform = true;
@@ -7280,10 +7314,6 @@ var NetlessAppPresentation = (function (exports) {
7280
7314
  dispose2.add(context.emitter.on("writableChange", (isWritable) => {
7281
7315
  app.setReadonly(!isWritable);
7282
7316
  }));
7283
- const getPageSize = () => {
7284
- const { width, height } = app.page() || {};
7285
- return { width: width || 0, height: height || 0 };
7286
- };
7287
7317
  const getOriginScale = () => {
7288
7318
  const { size } = view;
7289
7319
  const { width, height } = getPageSize();
@@ -7292,6 +7322,42 @@ var NetlessAppPresentation = (function (exports) {
7292
7322
  const getScale = () => {
7293
7323
  return view.camera.scale;
7294
7324
  };
7325
+ const screenshotCurrentPageAsync = async (_context, _width, _height) => {
7326
+ var _a2, _b2;
7327
+ (_b2 = (_a2 = room == null ? void 0 : room.calibrationTimestamp) == null ? void 0 : _a2.toString()) != null ? _b2 : Date.now().toString();
7328
+ const currentPage = pages[pageIndex$.value];
7329
+ if (!currentPage) {
7330
+ throw new Error("[Presentation]: current page not found");
7331
+ }
7332
+ const { width, height, src } = currentPage;
7333
+ const img = document.createElement("img");
7334
+ img.width = width;
7335
+ img.height = height;
7336
+ img.crossOrigin = "Anonymous";
7337
+ await new Promise((resolve) => {
7338
+ img.onload = resolve;
7339
+ img.src = src;
7340
+ });
7341
+ _context.drawImage(img, 0, 0, width, height, 0, 0, _width || width, _height || height);
7342
+ const currentScenePath = view.focusScenePath;
7343
+ if (!currentScenePath) {
7344
+ throw new Error("[Presentation]: current scene path not found");
7345
+ }
7346
+ const windowManger = context.getWindowManager();
7347
+ if (windowManger._appliancePlugin) {
7348
+ await windowManger._appliancePlugin.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
7349
+ centerX: 0,
7350
+ centerY: 0,
7351
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
7352
+ });
7353
+ } else {
7354
+ await view.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
7355
+ centerX: 0,
7356
+ centerY: 0,
7357
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
7358
+ });
7359
+ }
7360
+ };
7295
7361
  const moveCamera = (camera) => {
7296
7362
  if (context.getIsWritable()) {
7297
7363
  view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
@@ -7382,12 +7448,12 @@ var NetlessAppPresentation = (function (exports) {
7382
7448
  const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
7383
7449
  if (scenes.some((scene) => scene.name == name)) {
7384
7450
  const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
7385
- const sPath = `${scenePath}/${index + 1}`;
7386
- const windowManger = context.manager.windowManger;
7451
+ const sPath = `${scenePath}/${name}`;
7452
+ const windowManger = context.getWindowManager();
7387
7453
  if (windowManger._appliancePlugin) {
7388
7454
  await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
7389
7455
  } else {
7390
- view.screenshotToCanvas(
7456
+ await view.screenshotToCanvasAsync(
7391
7457
  wb,
7392
7458
  sPath,
7393
7459
  wb_canvas.width,
@@ -7433,11 +7499,12 @@ var NetlessAppPresentation = (function (exports) {
7433
7499
  };
7434
7500
  const setReadonly = (bol) => {
7435
7501
  app.setReadonly(bol);
7502
+ if (options.goToPageByClick) ;
7436
7503
  if (scrollbar) {
7437
7504
  scrollbar.setReadonly(bol);
7438
7505
  }
7439
7506
  };
7440
- const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale };
7507
+ const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale, getPageSize, screenshotCurrentPageAsync };
7441
7508
  dispose2.add(listen(window, "message", (ev) => {
7442
7509
  if (ev.data === "@netless/_presentation_") {
7443
7510
  if (typeof window !== "undefined")
@@ -7456,7 +7523,6 @@ var NetlessAppPresentation = (function (exports) {
7456
7523
  constructor(config) {
7457
7524
  super(config);
7458
7525
  this.jumpPage = config.jumpPage;
7459
- this.image.style.display = "none";
7460
7526
  }
7461
7527
  updateImage() {
7462
7528
  super.updateImage();
@@ -7473,7 +7539,7 @@ var NetlessAppPresentation = (function (exports) {
7473
7539
  }
7474
7540
  }
7475
7541
  };
7476
- function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
7542
+ function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, useClipView) {
7477
7543
  box.mountStyles(style_default);
7478
7544
  const app = new AppPresentation({ pages, readonly: box.readonly, jumpPage, thumbnail });
7479
7545
  app.box = box;
@@ -7482,6 +7548,29 @@ var NetlessAppPresentation = (function (exports) {
7482
7548
  app.dispose.add(pageIndex$.subscribe((pageIndex) => {
7483
7549
  app.setPageIndex(pageIndex);
7484
7550
  }));
7551
+ if (useClipView && view) {
7552
+ const onCameraUpdatedEffectForMaskView = (0, import_lodash2.debounce)(() => {
7553
+ const { width: pageWidth, height: pageHeight } = app.page() || {};
7554
+ if (!pageWidth || !pageHeight) {
7555
+ return;
7556
+ }
7557
+ const { scale } = view.camera;
7558
+ const { width, height } = view.size;
7559
+ const pageRatioX = Math.round((1 - pageWidth * scale / width) / 2 * 100);
7560
+ const pageRatioY = Math.round((1 - pageHeight * scale / height) / 2 * 100);
7561
+ app.whiteboardDOM.style.clipPath = `inset(${pageRatioY}% ${pageRatioX}%)`;
7562
+ }, 50);
7563
+ onCameraUpdatedEffectForMaskView();
7564
+ const onCameraUpdatedEffect = () => {
7565
+ view.callbacks.on("onSizeUpdated", onCameraUpdatedEffectForMaskView);
7566
+ view.callbacks.on("onCameraUpdated", onCameraUpdatedEffectForMaskView);
7567
+ return () => {
7568
+ view.callbacks.off("onCameraUpdated", onCameraUpdatedEffectForMaskView);
7569
+ view.callbacks.off("onSizeUpdated", onCameraUpdatedEffectForMaskView);
7570
+ };
7571
+ };
7572
+ app.dispose.make(onCameraUpdatedEffect);
7573
+ }
7485
7574
  return app;
7486
7575
  }
7487
7576
  var install = (register, options = {}) => {
@@ -7493,7 +7582,7 @@ var NetlessAppPresentation = (function (exports) {
7493
7582
  };
7494
7583
 
7495
7584
  // src/index.ts
7496
- var version = "0.1.9-beta.5";
7585
+ var version = "0.1.9-beta.6";
7497
7586
  /*! Bundled license information:
7498
7587
 
7499
7588
  lodash/lodash.js:
@@ -7511,7 +7600,6 @@ var NetlessAppPresentation = (function (exports) {
7511
7600
  exports.Presentation = Presentation;
7512
7601
  exports.default = NetlessAppPresentation;
7513
7602
  exports.install = install;
7514
- exports.styles = style_default;
7515
7603
  exports.version = version;
7516
7604
 
7517
7605
  Object.defineProperty(exports, '__esModule', { value: true });