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