@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.
- package/build.ts +3 -0
- package/dist/index.d.ts +53 -40
- package/dist/index.global.js +214 -126
- package/dist/index.js +214 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -126
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/src/app-presentation.ts +104 -17
- package/src/presentation.ts +5 -5
- package/src/scrollbar/index.ts +34 -19
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
|
-
|
|
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),
|
|
1030
|
+
var data = getMapData(this, key), size3 = data.size;
|
|
1031
1031
|
data.set(key, value);
|
|
1032
|
-
this.size += data.size ==
|
|
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 &=
|
|
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 &=
|
|
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 &=
|
|
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],
|
|
2846
|
+
var data = transforms[index], size3 = data.size;
|
|
2847
2847
|
switch (data.type) {
|
|
2848
2848
|
case "drop":
|
|
2849
|
-
start +=
|
|
2849
|
+
start += size3;
|
|
2850
2850
|
break;
|
|
2851
2851
|
case "dropRight":
|
|
2852
|
-
end -=
|
|
2852
|
+
end -= size3;
|
|
2853
2853
|
break;
|
|
2854
2854
|
case "take":
|
|
2855
|
-
end = nativeMin(end, start +
|
|
2855
|
+
end = nativeMin(end, start + size3);
|
|
2856
2856
|
break;
|
|
2857
2857
|
case "takeRight":
|
|
2858
|
-
start = nativeMax(start, end -
|
|
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,
|
|
3118
|
+
function shuffleSelf(array, size3) {
|
|
3119
3119
|
var index = -1, length = array.length, lastIndex = length - 1;
|
|
3120
|
-
|
|
3121
|
-
while (++index <
|
|
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 =
|
|
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,
|
|
3179
|
-
if (guard ? isIterateeCall(array,
|
|
3180
|
-
|
|
3178
|
+
function chunk(array, size3, guard) {
|
|
3179
|
+
if (guard ? isIterateeCall(array, size3, guard) : size3 === undefined2) {
|
|
3180
|
+
size3 = 1;
|
|
3181
3181
|
} else {
|
|
3182
|
-
|
|
3182
|
+
size3 = nativeMax(toInteger(size3), 0);
|
|
3183
3183
|
}
|
|
3184
3184
|
var length = array == null ? 0 : array.length;
|
|
3185
|
-
if (!length ||
|
|
3185
|
+
if (!length || size3 < 1) {
|
|
3186
3186
|
return [];
|
|
3187
3187
|
}
|
|
3188
|
-
var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length /
|
|
3188
|
+
var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length / size3));
|
|
3189
3189
|
while (index < length) {
|
|
3190
|
-
result2[resIndex++] = baseSlice(array, index, index +=
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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.
|
|
5529
|
-
var
|
|
5530
|
-
var
|
|
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
|
|
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
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
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
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
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
|
-
|
|
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
|
|
6843
|
-
const
|
|
6844
|
-
const
|
|
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 = `${
|
|
6847
|
-
this.scrollbarX.style.display =
|
|
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 = `${
|
|
6852
|
-
this.scrollbarY.style.display =
|
|
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
|
|
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 /
|
|
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
|
|
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 /
|
|
6906
|
+
const scrollY = Math.round(y / originScaleY);
|
|
6894
6907
|
let centerY = scrollY + this.cameraCache.centerY;
|
|
6895
6908
|
if (centerY < minY) {
|
|
6896
6909
|
centerY = minY;
|
|
@@ -6929,21 +6942,23 @@ var Scrollbar = class {
|
|
|
6929
6942
|
}
|
|
6930
6943
|
}
|
|
6931
6944
|
getScrollXRange(camera) {
|
|
6932
|
-
const { width } = this.option.getPageSize();
|
|
6933
|
-
const
|
|
6945
|
+
const { width: pageWidth } = this.option.getPageSize();
|
|
6946
|
+
const { width: viewWidth } = this.view.size;
|
|
6947
|
+
const originScaleX = viewWidth / pageWidth;
|
|
6934
6948
|
const scale = camera.scale;
|
|
6935
|
-
const ratio = Math.round(
|
|
6936
|
-
const scrollWidth =
|
|
6949
|
+
const ratio = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
|
|
6950
|
+
const scrollWidth = pageWidth * (1 - ratio);
|
|
6937
6951
|
const minX = -scrollWidth / 2;
|
|
6938
6952
|
const maxX = scrollWidth / 2;
|
|
6939
6953
|
return { minX, maxX };
|
|
6940
6954
|
}
|
|
6941
6955
|
getScrollYRange(camera) {
|
|
6942
|
-
const { height } = this.option.getPageSize();
|
|
6943
|
-
const
|
|
6956
|
+
const { height: pageHeight } = this.option.getPageSize();
|
|
6957
|
+
const { height: viewHeight } = this.view.size;
|
|
6958
|
+
const originScaleY = viewHeight / pageHeight;
|
|
6944
6959
|
const scale = camera.scale;
|
|
6945
|
-
const ratio = Math.round(
|
|
6946
|
-
const scrollHeight =
|
|
6960
|
+
const ratio = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
|
|
6961
|
+
const scrollHeight = pageHeight * (1 - ratio);
|
|
6947
6962
|
const minY = -scrollHeight / 2;
|
|
6948
6963
|
const maxY = scrollHeight / 2;
|
|
6949
6964
|
return { minY, maxY };
|
|
@@ -7014,6 +7029,7 @@ var Scrollbar = class {
|
|
|
7014
7029
|
};
|
|
7015
7030
|
|
|
7016
7031
|
// src/app-presentation.ts
|
|
7032
|
+
var import_lodash2 = __toESM(require_lodash());
|
|
7017
7033
|
var emptySceneName = "$$empty$$";
|
|
7018
7034
|
var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
|
|
7019
7035
|
var createLogger = (room) => {
|
|
@@ -7095,9 +7111,9 @@ var NetlessAppPresentation = {
|
|
|
7095
7111
|
if (pages.length > 100)
|
|
7096
7112
|
console.warn(`[Presentation]: too many pages (${pages.length}), may cause performance issues`);
|
|
7097
7113
|
let redirectResolve = void 0;
|
|
7098
|
-
const
|
|
7099
|
-
if (
|
|
7100
|
-
const scenes =
|
|
7114
|
+
const room2 = context.getRoom();
|
|
7115
|
+
if (room2 && room2.isWritable) {
|
|
7116
|
+
const scenes = room2.entireScenes()[scenePath];
|
|
7101
7117
|
if (pageIndex$.value < 0 || pageIndex$.value >= pages.length) {
|
|
7102
7118
|
throw new Error(`[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`);
|
|
7103
7119
|
}
|
|
@@ -7112,8 +7128,8 @@ var NetlessAppPresentation = {
|
|
|
7112
7128
|
};
|
|
7113
7129
|
});
|
|
7114
7130
|
if (!scenesEqual(scenes, _scenes)) {
|
|
7115
|
-
|
|
7116
|
-
|
|
7131
|
+
room2.removeScenes(scenePath);
|
|
7132
|
+
room2.putScenes(scenePath, _scenes);
|
|
7117
7133
|
}
|
|
7118
7134
|
if (name === _scenes[pageIndex$.value].name && !ppt) {
|
|
7119
7135
|
context.addPage({ scene: { name: emptySceneName } }).then(() => {
|
|
@@ -7126,10 +7142,10 @@ var NetlessAppPresentation = {
|
|
|
7126
7142
|
redirectResolve && redirectResolve(false);
|
|
7127
7143
|
}
|
|
7128
7144
|
}).then(async (bol) => {
|
|
7129
|
-
await syncPage(pageIndex$.value,
|
|
7145
|
+
await syncPage(pageIndex$.value, room2.logger);
|
|
7130
7146
|
if (bol) {
|
|
7131
7147
|
log(`[Presentation] setup removeScenes ${scenePath}/${emptySceneName}`);
|
|
7132
|
-
|
|
7148
|
+
room2.removeScenes(`${scenePath}/${emptySceneName}`);
|
|
7133
7149
|
}
|
|
7134
7150
|
});
|
|
7135
7151
|
}
|
|
@@ -7244,14 +7260,32 @@ var NetlessAppPresentation = {
|
|
|
7244
7260
|
}
|
|
7245
7261
|
};
|
|
7246
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
|
+
};
|
|
7247
7267
|
const box = context.getBox();
|
|
7248
|
-
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
7249
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
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";
|
|
7250
7270
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7251
7271
|
app.log = log;
|
|
7252
7272
|
if (options.justDocsViewReadonly) {
|
|
7253
7273
|
app.setDocsViewReadonly(true);
|
|
7254
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
|
+
}
|
|
7255
7289
|
context.mountView(app.whiteboardDOM);
|
|
7256
7290
|
if (options.disableCameraTransform) {
|
|
7257
7291
|
view.disableCameraTransform = true;
|
|
@@ -7281,10 +7315,6 @@ var NetlessAppPresentation = {
|
|
|
7281
7315
|
dispose2.add(context.emitter.on("writableChange", (isWritable) => {
|
|
7282
7316
|
app.setReadonly(!isWritable);
|
|
7283
7317
|
}));
|
|
7284
|
-
const getPageSize = () => {
|
|
7285
|
-
const { width, height } = app.page() || {};
|
|
7286
|
-
return { width: width || 0, height: height || 0 };
|
|
7287
|
-
};
|
|
7288
7318
|
const getOriginScale = () => {
|
|
7289
7319
|
const { size } = view;
|
|
7290
7320
|
const { width, height } = getPageSize();
|
|
@@ -7293,6 +7323,42 @@ var NetlessAppPresentation = {
|
|
|
7293
7323
|
const getScale = () => {
|
|
7294
7324
|
return view.camera.scale;
|
|
7295
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
|
+
};
|
|
7296
7362
|
const moveCamera = (camera) => {
|
|
7297
7363
|
if (context.getIsWritable()) {
|
|
7298
7364
|
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
@@ -7383,12 +7449,12 @@ var NetlessAppPresentation = {
|
|
|
7383
7449
|
const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
|
|
7384
7450
|
if (scenes.some((scene) => scene.name == name)) {
|
|
7385
7451
|
const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
|
|
7386
|
-
const sPath = `${scenePath}/${
|
|
7387
|
-
const windowManger = context.
|
|
7452
|
+
const sPath = `${scenePath}/${name}`;
|
|
7453
|
+
const windowManger = context.getWindowManager();
|
|
7388
7454
|
if (windowManger._appliancePlugin) {
|
|
7389
7455
|
await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
|
|
7390
7456
|
} else {
|
|
7391
|
-
view.
|
|
7457
|
+
await view.screenshotToCanvasAsync(
|
|
7392
7458
|
wb,
|
|
7393
7459
|
sPath,
|
|
7394
7460
|
wb_canvas.width,
|
|
@@ -7434,11 +7500,12 @@ var NetlessAppPresentation = {
|
|
|
7434
7500
|
};
|
|
7435
7501
|
const setReadonly = (bol) => {
|
|
7436
7502
|
app.setReadonly(bol);
|
|
7503
|
+
if (options.goToPageByClick) ;
|
|
7437
7504
|
if (scrollbar) {
|
|
7438
7505
|
scrollbar.setReadonly(bol);
|
|
7439
7506
|
}
|
|
7440
7507
|
};
|
|
7441
|
-
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 };
|
|
7442
7509
|
dispose2.add(listen(window, "message", (ev) => {
|
|
7443
7510
|
if (ev.data === "@netless/_presentation_") {
|
|
7444
7511
|
if (typeof window !== "undefined")
|
|
@@ -7457,7 +7524,6 @@ var AppPresentation = class extends Presentation {
|
|
|
7457
7524
|
constructor(config) {
|
|
7458
7525
|
super(config);
|
|
7459
7526
|
this.jumpPage = config.jumpPage;
|
|
7460
|
-
this.image.style.display = "none";
|
|
7461
7527
|
}
|
|
7462
7528
|
updateImage() {
|
|
7463
7529
|
super.updateImage();
|
|
@@ -7474,7 +7540,7 @@ var AppPresentation = class extends Presentation {
|
|
|
7474
7540
|
}
|
|
7475
7541
|
}
|
|
7476
7542
|
};
|
|
7477
|
-
function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
|
|
7543
|
+
function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, useClipView) {
|
|
7478
7544
|
box.mountStyles(style_default);
|
|
7479
7545
|
const app = new AppPresentation({ pages, readonly: box.readonly, jumpPage, thumbnail });
|
|
7480
7546
|
app.box = box;
|
|
@@ -7483,6 +7549,29 @@ function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
|
|
|
7483
7549
|
app.dispose.add(pageIndex$.subscribe((pageIndex) => {
|
|
7484
7550
|
app.setPageIndex(pageIndex);
|
|
7485
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
|
+
}
|
|
7486
7575
|
return app;
|
|
7487
7576
|
}
|
|
7488
7577
|
var install = (register, options = {}) => {
|
|
@@ -7494,7 +7583,7 @@ var install = (register, options = {}) => {
|
|
|
7494
7583
|
};
|
|
7495
7584
|
|
|
7496
7585
|
// src/index.ts
|
|
7497
|
-
var version = "0.1.9-beta.
|
|
7586
|
+
var version = "0.1.9-beta.6";
|
|
7498
7587
|
/*! Bundled license information:
|
|
7499
7588
|
|
|
7500
7589
|
lodash/lodash.js:
|
|
@@ -7512,6 +7601,5 @@ exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
|
7512
7601
|
exports.Presentation = Presentation;
|
|
7513
7602
|
exports.default = NetlessAppPresentation;
|
|
7514
7603
|
exports.install = install;
|
|
7515
|
-
exports.styles = style_default;
|
|
7516
7604
|
exports.version = version;
|
|
7517
7605
|
//# sourceMappingURL=index.js.map
|