@netless/app-presentation 0.1.9-beta.5 → 0.1.9-beta.7

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
@@ -4174,7 +4174,7 @@ var NetlessAppPresentation = (function (exports) {
4174
4174
  return baseIsMatch(object, source, getMatchData(source), customizer);
4175
4175
  }
4176
4176
  function isNaN(value) {
4177
- return isNumber(value) && value != +value;
4177
+ return isNumber2(value) && value != +value;
4178
4178
  }
4179
4179
  function isNative(value) {
4180
4180
  if (isMaskable(value)) {
@@ -4188,7 +4188,7 @@ var NetlessAppPresentation = (function (exports) {
4188
4188
  function isNil(value) {
4189
4189
  return value == null;
4190
4190
  }
4191
- function isNumber(value) {
4191
+ function isNumber2(value) {
4192
4192
  return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
4193
4193
  }
4194
4194
  function isPlainObject(value) {
@@ -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;
@@ -5254,7 +5254,7 @@ var NetlessAppPresentation = (function (exports) {
5254
5254
  lodash.isNative = isNative;
5255
5255
  lodash.isNil = isNil;
5256
5256
  lodash.isNull = isNull;
5257
- lodash.isNumber = isNumber;
5257
+ lodash.isNumber = isNumber2;
5258
5258
  lodash.isObject = isObject;
5259
5259
  lodash.isObjectLike = isObjectLike;
5260
5260
  lodash.isPlainObject = isPlainObject;
@@ -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;
@@ -6909,6 +6922,35 @@ var NetlessAppPresentation = (function (exports) {
6909
6922
  this.option.syncView();
6910
6923
  (_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollbarDragEnd) == null ? void 0 : _b.call(_a);
6911
6924
  };
6925
+ this.moveCamera = (camera) => {
6926
+ const { centerX, centerY } = camera;
6927
+ const cacheCamera = this.view.camera;
6928
+ const _camera = {};
6929
+ if ((0, import_lodash.isNumber)(centerX)) {
6930
+ const { minX, maxX } = this.getScrollXRange(cacheCamera);
6931
+ let newCenterX = centerX;
6932
+ if (centerX < minX) {
6933
+ newCenterX = minX;
6934
+ } else if (centerX > maxX) {
6935
+ newCenterX = maxX;
6936
+ }
6937
+ _camera.centerX = newCenterX;
6938
+ }
6939
+ if ((0, import_lodash.isNumber)(centerY)) {
6940
+ const { minY, maxY } = this.getScrollYRange(cacheCamera);
6941
+ let newCenterY = centerY;
6942
+ if (centerY < minY) {
6943
+ newCenterY = minY;
6944
+ } else if (centerY > maxY) {
6945
+ newCenterY = maxY;
6946
+ }
6947
+ _camera.centerY = newCenterY;
6948
+ }
6949
+ this.view.moveCamera(__spreadProps(__spreadValues({}, _camera), {
6950
+ animationMode: "immediately"
6951
+ }));
6952
+ this.option.syncView();
6953
+ };
6912
6954
  this.scrollContainer.className = this.c("scrollbar-container");
6913
6955
  this.container = container;
6914
6956
  this.option = option;
@@ -6928,21 +6970,23 @@ var NetlessAppPresentation = (function (exports) {
6928
6970
  }
6929
6971
  }
6930
6972
  getScrollXRange(camera) {
6931
- const { width } = this.option.getPageSize();
6932
- const originScale = this.option.getOriginScale();
6973
+ const { width: pageWidth } = this.option.getPageSize();
6974
+ const { width: viewWidth } = this.view.size;
6975
+ const originScaleX = viewWidth / pageWidth;
6933
6976
  const scale = camera.scale;
6934
- const ratio = Math.round(originScale / scale * 1e3) / 1e3;
6935
- const scrollWidth = width * (1 - ratio);
6977
+ const ratio = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
6978
+ const scrollWidth = pageWidth * (1 - ratio);
6936
6979
  const minX = -scrollWidth / 2;
6937
6980
  const maxX = scrollWidth / 2;
6938
6981
  return { minX, maxX };
6939
6982
  }
6940
6983
  getScrollYRange(camera) {
6941
- const { height } = this.option.getPageSize();
6942
- const originScale = this.option.getOriginScale();
6984
+ const { height: pageHeight } = this.option.getPageSize();
6985
+ const { height: viewHeight } = this.view.size;
6986
+ const originScaleY = viewHeight / pageHeight;
6943
6987
  const scale = camera.scale;
6944
- const ratio = Math.round(originScale / scale * 1e3) / 1e3;
6945
- const scrollHeight = height * (1 - ratio);
6988
+ const ratio = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
6989
+ const scrollHeight = pageHeight * (1 - ratio);
6946
6990
  const minY = -scrollHeight / 2;
6947
6991
  const maxY = scrollHeight / 2;
6948
6992
  return { minY, maxY };
@@ -7013,6 +7057,7 @@ var NetlessAppPresentation = (function (exports) {
7013
7057
  };
7014
7058
 
7015
7059
  // src/app-presentation.ts
7060
+ var import_lodash2 = __toESM(require_lodash());
7016
7061
  var emptySceneName = "$$empty$$";
7017
7062
  var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
7018
7063
  var createLogger = (room) => {
@@ -7094,9 +7139,9 @@ var NetlessAppPresentation = (function (exports) {
7094
7139
  if (pages.length > 100)
7095
7140
  console.warn(`[Presentation]: too many pages (${pages.length}), may cause performance issues`);
7096
7141
  let redirectResolve = void 0;
7097
- const room = context.getRoom();
7098
- if (room && room.isWritable) {
7099
- const scenes = room.entireScenes()[scenePath];
7142
+ const room2 = context.getRoom();
7143
+ if (room2 && room2.isWritable) {
7144
+ const scenes = room2.entireScenes()[scenePath];
7100
7145
  if (pageIndex$.value < 0 || pageIndex$.value >= pages.length) {
7101
7146
  throw new Error(`[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`);
7102
7147
  }
@@ -7111,8 +7156,8 @@ var NetlessAppPresentation = (function (exports) {
7111
7156
  };
7112
7157
  });
7113
7158
  if (!scenesEqual(scenes, _scenes)) {
7114
- room.removeScenes(scenePath);
7115
- room.putScenes(scenePath, _scenes);
7159
+ room2.removeScenes(scenePath);
7160
+ room2.putScenes(scenePath, _scenes);
7116
7161
  }
7117
7162
  if (name === _scenes[pageIndex$.value].name && !ppt) {
7118
7163
  context.addPage({ scene: { name: emptySceneName } }).then(() => {
@@ -7125,10 +7170,10 @@ var NetlessAppPresentation = (function (exports) {
7125
7170
  redirectResolve && redirectResolve(false);
7126
7171
  }
7127
7172
  }).then(async (bol) => {
7128
- await syncPage(pageIndex$.value, room.logger);
7173
+ await syncPage(pageIndex$.value, room2.logger);
7129
7174
  if (bol) {
7130
7175
  log(`[Presentation] setup removeScenes ${scenePath}/${emptySceneName}`);
7131
- room.removeScenes(`${scenePath}/${emptySceneName}`);
7176
+ room2.removeScenes(`${scenePath}/${emptySceneName}`);
7132
7177
  }
7133
7178
  });
7134
7179
  }
@@ -7243,14 +7288,32 @@ var NetlessAppPresentation = (function (exports) {
7243
7288
  }
7244
7289
  };
7245
7290
  dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
7291
+ const getPageSize = () => {
7292
+ const { width, height } = app.page() || {};
7293
+ return { width: width || 0, height: height || 0 };
7294
+ };
7246
7295
  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";
7296
+ const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
7297
+ app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.7";
7249
7298
  app.scaleDocsToFit = scaleDocsToFit;
7250
7299
  app.log = log;
7251
7300
  if (options.justDocsViewReadonly) {
7252
7301
  app.setDocsViewReadonly(true);
7253
7302
  }
7303
+ const room = context.getRoom();
7304
+ const goToPageByClick = () => {
7305
+ var _a2, _b2, _c2, _d;
7306
+ 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 : "";
7307
+ if (!app.readonly && currentApplianceName === "clicker") {
7308
+ nextPage();
7309
+ }
7310
+ };
7311
+ if (room && options.goToPageByClick && app.whiteboardDOM) {
7312
+ dispose2.make(() => {
7313
+ app.whiteboardDOM.addEventListener("click", goToPageByClick);
7314
+ return () => app.whiteboardDOM.removeEventListener("click", goToPageByClick);
7315
+ });
7316
+ }
7254
7317
  context.mountView(app.whiteboardDOM);
7255
7318
  if (options.disableCameraTransform) {
7256
7319
  view.disableCameraTransform = true;
@@ -7280,10 +7343,6 @@ var NetlessAppPresentation = (function (exports) {
7280
7343
  dispose2.add(context.emitter.on("writableChange", (isWritable) => {
7281
7344
  app.setReadonly(!isWritable);
7282
7345
  }));
7283
- const getPageSize = () => {
7284
- const { width, height } = app.page() || {};
7285
- return { width: width || 0, height: height || 0 };
7286
- };
7287
7346
  const getOriginScale = () => {
7288
7347
  const { size } = view;
7289
7348
  const { width, height } = getPageSize();
@@ -7292,13 +7351,41 @@ var NetlessAppPresentation = (function (exports) {
7292
7351
  const getScale = () => {
7293
7352
  return view.camera.scale;
7294
7353
  };
7295
- const moveCamera = (camera) => {
7296
- if (context.getIsWritable()) {
7297
- view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
7298
- syncView();
7299
- return;
7354
+ const screenshotCurrentPageAsync = async (_context, _width, _height) => {
7355
+ var _a2, _b2;
7356
+ (_b2 = (_a2 = room == null ? void 0 : room.calibrationTimestamp) == null ? void 0 : _a2.toString()) != null ? _b2 : Date.now().toString();
7357
+ const currentPage = pages[pageIndex$.value];
7358
+ if (!currentPage) {
7359
+ throw new Error("[Presentation]: current page not found");
7360
+ }
7361
+ const { width, height, src } = currentPage;
7362
+ const img = document.createElement("img");
7363
+ img.width = width;
7364
+ img.height = height;
7365
+ img.crossOrigin = "Anonymous";
7366
+ await new Promise((resolve) => {
7367
+ img.onload = resolve;
7368
+ img.src = src;
7369
+ });
7370
+ _context.drawImage(img, 0, 0, width, height, 0, 0, _width || width, _height || height);
7371
+ const currentScenePath = view.focusScenePath;
7372
+ if (!currentScenePath) {
7373
+ throw new Error("[Presentation]: current scene path not found");
7374
+ }
7375
+ const windowManger = context.getWindowManager();
7376
+ if (windowManger._appliancePlugin) {
7377
+ await windowManger._appliancePlugin.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
7378
+ centerX: 0,
7379
+ centerY: 0,
7380
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
7381
+ });
7382
+ } else {
7383
+ await view.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
7384
+ centerX: 0,
7385
+ centerY: 0,
7386
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
7387
+ });
7300
7388
  }
7301
- throw new Error("[Presentation]: moveCamera must be called in writable room");
7302
7389
  };
7303
7390
  let scrollbar;
7304
7391
  if (options.useScrollbar) {
@@ -7314,6 +7401,16 @@ var NetlessAppPresentation = (function (exports) {
7314
7401
  return () => scrollbar == null ? void 0 : scrollbar.destroy();
7315
7402
  });
7316
7403
  }
7404
+ const moveCamera = (camera) => {
7405
+ if (context.getIsWritable() && scrollbar) {
7406
+ if (!scrollbar) {
7407
+ throw new Error("[Presentation]: moveCamera must be called when appOptions: useScrollbar is true");
7408
+ }
7409
+ scrollbar.moveCamera(camera);
7410
+ return;
7411
+ }
7412
+ throw new Error("[Presentation]: moveCamera must be called in writable room");
7413
+ };
7317
7414
  context.emitter.on("destroy", () => dispose2());
7318
7415
  const reportProgress = (progress, result) => {
7319
7416
  window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
@@ -7382,12 +7479,12 @@ var NetlessAppPresentation = (function (exports) {
7382
7479
  const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
7383
7480
  if (scenes.some((scene) => scene.name == name)) {
7384
7481
  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;
7482
+ const sPath = `${scenePath}/${name}`;
7483
+ const windowManger = context.getWindowManager();
7387
7484
  if (windowManger._appliancePlugin) {
7388
7485
  await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
7389
7486
  } else {
7390
- view.screenshotToCanvas(
7487
+ await view.screenshotToCanvasAsync(
7391
7488
  wb,
7392
7489
  sPath,
7393
7490
  wb_canvas.width,
@@ -7433,11 +7530,12 @@ var NetlessAppPresentation = (function (exports) {
7433
7530
  };
7434
7531
  const setReadonly = (bol) => {
7435
7532
  app.setReadonly(bol);
7533
+ if (options.goToPageByClick) ;
7436
7534
  if (scrollbar) {
7437
7535
  scrollbar.setReadonly(bol);
7438
7536
  }
7439
7537
  };
7440
- const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale };
7538
+ const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale, getPageSize, screenshotCurrentPageAsync };
7441
7539
  dispose2.add(listen(window, "message", (ev) => {
7442
7540
  if (ev.data === "@netless/_presentation_") {
7443
7541
  if (typeof window !== "undefined")
@@ -7456,7 +7554,6 @@ var NetlessAppPresentation = (function (exports) {
7456
7554
  constructor(config) {
7457
7555
  super(config);
7458
7556
  this.jumpPage = config.jumpPage;
7459
- this.image.style.display = "none";
7460
7557
  }
7461
7558
  updateImage() {
7462
7559
  super.updateImage();
@@ -7473,7 +7570,7 @@ var NetlessAppPresentation = (function (exports) {
7473
7570
  }
7474
7571
  }
7475
7572
  };
7476
- function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
7573
+ function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, useClipView) {
7477
7574
  box.mountStyles(style_default);
7478
7575
  const app = new AppPresentation({ pages, readonly: box.readonly, jumpPage, thumbnail });
7479
7576
  app.box = box;
@@ -7482,6 +7579,29 @@ var NetlessAppPresentation = (function (exports) {
7482
7579
  app.dispose.add(pageIndex$.subscribe((pageIndex) => {
7483
7580
  app.setPageIndex(pageIndex);
7484
7581
  }));
7582
+ if (useClipView && view) {
7583
+ const onCameraUpdatedEffectForMaskView = (0, import_lodash2.debounce)(() => {
7584
+ const { width: pageWidth, height: pageHeight } = app.page() || {};
7585
+ if (!pageWidth || !pageHeight) {
7586
+ return;
7587
+ }
7588
+ const { scale } = view.camera;
7589
+ const { width, height } = view.size;
7590
+ const pageRatioX = Math.round((1 - pageWidth * scale / width) / 2 * 100);
7591
+ const pageRatioY = Math.round((1 - pageHeight * scale / height) / 2 * 100);
7592
+ app.whiteboardDOM.style.clipPath = `inset(${pageRatioY}% ${pageRatioX}%)`;
7593
+ }, 50);
7594
+ onCameraUpdatedEffectForMaskView();
7595
+ const onCameraUpdatedEffect = () => {
7596
+ view.callbacks.on("onSizeUpdated", onCameraUpdatedEffectForMaskView);
7597
+ view.callbacks.on("onCameraUpdated", onCameraUpdatedEffectForMaskView);
7598
+ return () => {
7599
+ view.callbacks.off("onCameraUpdated", onCameraUpdatedEffectForMaskView);
7600
+ view.callbacks.off("onSizeUpdated", onCameraUpdatedEffectForMaskView);
7601
+ };
7602
+ };
7603
+ app.dispose.make(onCameraUpdatedEffect);
7604
+ }
7485
7605
  return app;
7486
7606
  }
7487
7607
  var install = (register, options = {}) => {
@@ -7493,7 +7613,7 @@ var NetlessAppPresentation = (function (exports) {
7493
7613
  };
7494
7614
 
7495
7615
  // src/index.ts
7496
- var version = "0.1.9-beta.5";
7616
+ var version = "0.1.9-beta.7";
7497
7617
  /*! Bundled license information:
7498
7618
 
7499
7619
  lodash/lodash.js:
@@ -7509,9 +7629,9 @@ var NetlessAppPresentation = (function (exports) {
7509
7629
 
7510
7630
  exports.NetlessAppPresentation = NetlessAppPresentation;
7511
7631
  exports.Presentation = Presentation;
7632
+ exports.Scrollbar = Scrollbar;
7512
7633
  exports.default = NetlessAppPresentation;
7513
7634
  exports.install = install;
7514
- exports.styles = style_default;
7515
7635
  exports.version = version;
7516
7636
 
7517
7637
  Object.defineProperty(exports, '__esModule', { value: true });