@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/build.ts +3 -0
- package/dist/index.d.ts +53 -40
- package/dist/index.global.js +236 -138
- package/dist/index.js +236 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +237 -138
- 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 +57 -31
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
// file that has been converted to a CommonJS file using a Babel-
|
|
38
38
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
39
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
-
|
|
40
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
41
41
|
mod
|
|
42
42
|
));
|
|
43
43
|
|
|
@@ -1023,9 +1023,9 @@ var require_lodash = __commonJS({
|
|
|
1023
1023
|
return getMapData(this, key).has(key);
|
|
1024
1024
|
}
|
|
1025
1025
|
function mapCacheSet(key, value) {
|
|
1026
|
-
var data = getMapData(this, key),
|
|
1026
|
+
var data = getMapData(this, key), size3 = data.size;
|
|
1027
1027
|
data.set(key, value);
|
|
1028
|
-
this.size += data.size ==
|
|
1028
|
+
this.size += data.size == size3 ? 0 : 1;
|
|
1029
1029
|
return this;
|
|
1030
1030
|
}
|
|
1031
1031
|
MapCache.prototype.clear = mapCacheClear;
|
|
@@ -2482,7 +2482,7 @@ var require_lodash = __commonJS({
|
|
|
2482
2482
|
bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
|
|
2483
2483
|
bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
|
|
2484
2484
|
if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
|
|
2485
|
-
bitmask &=
|
|
2485
|
+
bitmask &= -4;
|
|
2486
2486
|
}
|
|
2487
2487
|
var newData = [
|
|
2488
2488
|
func,
|
|
@@ -2538,7 +2538,7 @@ var require_lodash = __commonJS({
|
|
|
2538
2538
|
}
|
|
2539
2539
|
var length = partials ? partials.length : 0;
|
|
2540
2540
|
if (!length) {
|
|
2541
|
-
bitmask &=
|
|
2541
|
+
bitmask &= -97;
|
|
2542
2542
|
partials = holders = undefined2;
|
|
2543
2543
|
}
|
|
2544
2544
|
ary2 = ary2 === undefined2 ? ary2 : nativeMax(toInteger(ary2), 0);
|
|
@@ -2571,7 +2571,7 @@ var require_lodash = __commonJS({
|
|
|
2571
2571
|
holders = newData[4];
|
|
2572
2572
|
arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0);
|
|
2573
2573
|
if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
|
|
2574
|
-
bitmask &=
|
|
2574
|
+
bitmask &= -25;
|
|
2575
2575
|
}
|
|
2576
2576
|
if (!bitmask || bitmask == WRAP_BIND_FLAG) {
|
|
2577
2577
|
var result2 = createBind(func, bitmask, thisArg);
|
|
@@ -2839,19 +2839,19 @@ var require_lodash = __commonJS({
|
|
|
2839
2839
|
function getView(start, end, transforms) {
|
|
2840
2840
|
var index = -1, length = transforms.length;
|
|
2841
2841
|
while (++index < length) {
|
|
2842
|
-
var data = transforms[index],
|
|
2842
|
+
var data = transforms[index], size3 = data.size;
|
|
2843
2843
|
switch (data.type) {
|
|
2844
2844
|
case "drop":
|
|
2845
|
-
start +=
|
|
2845
|
+
start += size3;
|
|
2846
2846
|
break;
|
|
2847
2847
|
case "dropRight":
|
|
2848
|
-
end -=
|
|
2848
|
+
end -= size3;
|
|
2849
2849
|
break;
|
|
2850
2850
|
case "take":
|
|
2851
|
-
end = nativeMin(end, start +
|
|
2851
|
+
end = nativeMin(end, start + size3);
|
|
2852
2852
|
break;
|
|
2853
2853
|
case "takeRight":
|
|
2854
|
-
start = nativeMax(start, end -
|
|
2854
|
+
start = nativeMax(start, end - size3);
|
|
2855
2855
|
break;
|
|
2856
2856
|
}
|
|
2857
2857
|
}
|
|
@@ -3111,15 +3111,15 @@ var require_lodash = __commonJS({
|
|
|
3111
3111
|
return func.apply(undefined2, arguments);
|
|
3112
3112
|
};
|
|
3113
3113
|
}
|
|
3114
|
-
function shuffleSelf(array,
|
|
3114
|
+
function shuffleSelf(array, size3) {
|
|
3115
3115
|
var index = -1, length = array.length, lastIndex = length - 1;
|
|
3116
|
-
|
|
3117
|
-
while (++index <
|
|
3116
|
+
size3 = size3 === undefined2 ? length : size3;
|
|
3117
|
+
while (++index < size3) {
|
|
3118
3118
|
var rand = baseRandom(index, lastIndex), value = array[rand];
|
|
3119
3119
|
array[rand] = array[index];
|
|
3120
3120
|
array[index] = value;
|
|
3121
3121
|
}
|
|
3122
|
-
array.length =
|
|
3122
|
+
array.length = size3;
|
|
3123
3123
|
return array;
|
|
3124
3124
|
}
|
|
3125
3125
|
var stringToPath = memoizeCapped(function(string) {
|
|
@@ -3171,19 +3171,19 @@ var require_lodash = __commonJS({
|
|
|
3171
3171
|
result2.__values__ = wrapper.__values__;
|
|
3172
3172
|
return result2;
|
|
3173
3173
|
}
|
|
3174
|
-
function chunk(array,
|
|
3175
|
-
if (guard ? isIterateeCall(array,
|
|
3176
|
-
|
|
3174
|
+
function chunk(array, size3, guard) {
|
|
3175
|
+
if (guard ? isIterateeCall(array, size3, guard) : size3 === undefined2) {
|
|
3176
|
+
size3 = 1;
|
|
3177
3177
|
} else {
|
|
3178
|
-
|
|
3178
|
+
size3 = nativeMax(toInteger(size3), 0);
|
|
3179
3179
|
}
|
|
3180
3180
|
var length = array == null ? 0 : array.length;
|
|
3181
|
-
if (!length ||
|
|
3181
|
+
if (!length || size3 < 1) {
|
|
3182
3182
|
return [];
|
|
3183
3183
|
}
|
|
3184
|
-
var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length /
|
|
3184
|
+
var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length / size3));
|
|
3185
3185
|
while (index < length) {
|
|
3186
|
-
result2[resIndex++] = baseSlice(array, index, index +=
|
|
3186
|
+
result2[resIndex++] = baseSlice(array, index, index += size3);
|
|
3187
3187
|
}
|
|
3188
3188
|
return result2;
|
|
3189
3189
|
}
|
|
@@ -3859,7 +3859,7 @@ var require_lodash = __commonJS({
|
|
|
3859
3859
|
result2.placeholder = curryRight.placeholder;
|
|
3860
3860
|
return result2;
|
|
3861
3861
|
}
|
|
3862
|
-
function
|
|
3862
|
+
function debounce3(func, wait, options) {
|
|
3863
3863
|
var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
3864
3864
|
if (typeof func != "function") {
|
|
3865
3865
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
@@ -4039,7 +4039,7 @@ var require_lodash = __commonJS({
|
|
|
4039
4039
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4040
4040
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4041
4041
|
}
|
|
4042
|
-
return
|
|
4042
|
+
return debounce3(func, wait, {
|
|
4043
4043
|
"leading": leading,
|
|
4044
4044
|
"maxWait": wait,
|
|
4045
4045
|
"trailing": trailing
|
|
@@ -4991,7 +4991,7 @@ var require_lodash = __commonJS({
|
|
|
4991
4991
|
var id = ++idCounter;
|
|
4992
4992
|
return toString(prefix) + id;
|
|
4993
4993
|
}
|
|
4994
|
-
var
|
|
4994
|
+
var add2 = createMathOperation(function(augend, addend) {
|
|
4995
4995
|
return augend + addend;
|
|
4996
4996
|
}, 0);
|
|
4997
4997
|
var ceil = createRound("ceil");
|
|
@@ -5053,7 +5053,7 @@ var require_lodash = __commonJS({
|
|
|
5053
5053
|
lodash.create = create;
|
|
5054
5054
|
lodash.curry = curry;
|
|
5055
5055
|
lodash.curryRight = curryRight;
|
|
5056
|
-
lodash.debounce =
|
|
5056
|
+
lodash.debounce = debounce3;
|
|
5057
5057
|
lodash.defaults = defaults;
|
|
5058
5058
|
lodash.defaultsDeep = defaultsDeep;
|
|
5059
5059
|
lodash.defer = defer;
|
|
@@ -5184,7 +5184,7 @@ var require_lodash = __commonJS({
|
|
|
5184
5184
|
lodash.extend = assignIn;
|
|
5185
5185
|
lodash.extendWith = assignInWith;
|
|
5186
5186
|
mixin(lodash, lodash);
|
|
5187
|
-
lodash.add =
|
|
5187
|
+
lodash.add = add2;
|
|
5188
5188
|
lodash.attempt = attempt;
|
|
5189
5189
|
lodash.camelCase = camelCase;
|
|
5190
5190
|
lodash.capitalize = capitalize;
|
|
@@ -5521,72 +5521,81 @@ var require_lodash = __commonJS({
|
|
|
5521
5521
|
}
|
|
5522
5522
|
});
|
|
5523
5523
|
|
|
5524
|
-
// node_modules/.pnpm/@wopjs+disposable@0.1.
|
|
5525
|
-
var
|
|
5526
|
-
var
|
|
5524
|
+
// node_modules/.pnpm/@wopjs+disposable@0.1.19/node_modules/@wopjs/disposable/dist/index.mjs
|
|
5525
|
+
var isFn = (value) => !!(value && value.constructor && value.call && value.apply);
|
|
5526
|
+
var isDisposable = (value) => isFn(value) || isFn(value == null ? void 0 : value.dispose);
|
|
5527
|
+
function dispose(disposable) {
|
|
5527
5528
|
try {
|
|
5528
5529
|
if (disposable) {
|
|
5529
|
-
if (disposable.dispose) {
|
|
5530
|
+
if (isFn(disposable.dispose)) {
|
|
5530
5531
|
disposable.dispose();
|
|
5531
|
-
} else if (disposable
|
|
5532
|
+
} else if (isFn(disposable)) {
|
|
5532
5533
|
disposable();
|
|
5533
5534
|
}
|
|
5534
5535
|
}
|
|
5535
5536
|
} catch (e) {
|
|
5536
5537
|
console.error(e);
|
|
5537
5538
|
}
|
|
5538
|
-
}
|
|
5539
|
-
var
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
if (!this._d.has(disposable2)) {
|
|
5550
|
-
this._d.add(disposable2);
|
|
5551
|
-
if (isAbortable(disposable2)) {
|
|
5552
|
-
disposable2.abortable(() => this.remove(disposable2));
|
|
5553
|
-
}
|
|
5554
|
-
}
|
|
5555
|
-
}
|
|
5556
|
-
return disposable;
|
|
5557
|
-
},
|
|
5558
|
-
make(executor) {
|
|
5559
|
-
const disposable = executor();
|
|
5560
|
-
if (disposable) {
|
|
5561
|
-
return this.add(disposable);
|
|
5562
|
-
}
|
|
5563
|
-
},
|
|
5564
|
-
remove(disposable) {
|
|
5565
|
-
return this._d.delete(disposable);
|
|
5566
|
-
},
|
|
5567
|
-
flush(disposable) {
|
|
5568
|
-
if (disposable) {
|
|
5569
|
-
if (this.remove(disposable)) {
|
|
5570
|
-
dispose(disposable);
|
|
5571
|
-
}
|
|
5572
|
-
} else {
|
|
5573
|
-
this.dispose();
|
|
5574
|
-
}
|
|
5539
|
+
}
|
|
5540
|
+
var isAbortable = (disposable) => isDisposable(disposable) && isFn(disposable.abortable);
|
|
5541
|
+
function disposableStore(disposables) {
|
|
5542
|
+
function disposableStore2() {
|
|
5543
|
+
var _a, _b;
|
|
5544
|
+
if (disposableStore2._i)
|
|
5545
|
+
return;
|
|
5546
|
+
disposableStore2._i = 1;
|
|
5547
|
+
(_a = disposableStore2._d) == null ? void 0 : _a.forEach(dispose);
|
|
5548
|
+
(_b = disposableStore2._d) == null ? void 0 : _b.clear();
|
|
5549
|
+
disposableStore2._i = 0;
|
|
5575
5550
|
}
|
|
5576
|
-
|
|
5577
|
-
var disposableStore = (disposables) => {
|
|
5578
|
-
const disposableStore2 = () => {
|
|
5579
|
-
disposableStore2._d.forEach(dispose);
|
|
5580
|
-
disposableStore2._d.clear();
|
|
5581
|
-
};
|
|
5582
|
-
disposableStore2._d = /* @__PURE__ */ new Set();
|
|
5551
|
+
disposableStore2._i = 0;
|
|
5583
5552
|
disposableStore2.dispose = disposableStore2;
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5553
|
+
disposableStore2.size = size2;
|
|
5554
|
+
disposableStore2.has = has2;
|
|
5555
|
+
disposableStore2.add = add;
|
|
5556
|
+
disposableStore2.make = make3;
|
|
5557
|
+
disposableStore2.remove = remove3;
|
|
5558
|
+
disposableStore2.flush = flush2;
|
|
5559
|
+
return disposableStore2;
|
|
5560
|
+
}
|
|
5561
|
+
function _addOne(disposable) {
|
|
5562
|
+
var _a, _b;
|
|
5563
|
+
if (!((_a = this._d) == null ? void 0 : _a.has(disposable))) {
|
|
5564
|
+
((_b = this._d) != null ? _b : this._d = /* @__PURE__ */ new Set()).add(disposable);
|
|
5565
|
+
if (isAbortable(disposable)) {
|
|
5566
|
+
disposable.abortable(() => this.remove(disposable));
|
|
5567
|
+
}
|
|
5587
5568
|
}
|
|
5588
|
-
|
|
5589
|
-
|
|
5569
|
+
}
|
|
5570
|
+
function add(disposables) {
|
|
5571
|
+
Array.isArray(disposables) ? disposables.forEach(_addOne, this) : _addOne.call(this, disposables);
|
|
5572
|
+
return disposables;
|
|
5573
|
+
}
|
|
5574
|
+
function flush2(disposable) {
|
|
5575
|
+
if (disposable) {
|
|
5576
|
+
if (this.remove(disposable)) {
|
|
5577
|
+
dispose(disposable);
|
|
5578
|
+
}
|
|
5579
|
+
} else {
|
|
5580
|
+
this.dispose();
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5583
|
+
function has2(disposable) {
|
|
5584
|
+
var _a;
|
|
5585
|
+
return ((_a = this._d) == null ? void 0 : _a.has(disposable)) || false;
|
|
5586
|
+
}
|
|
5587
|
+
function make3(executor) {
|
|
5588
|
+
const disposable = executor();
|
|
5589
|
+
return disposable && this.add(disposable);
|
|
5590
|
+
}
|
|
5591
|
+
function remove3(disposable) {
|
|
5592
|
+
var _a;
|
|
5593
|
+
return ((_a = this._d) == null ? void 0 : _a.delete(disposable)) || false;
|
|
5594
|
+
}
|
|
5595
|
+
function size2() {
|
|
5596
|
+
var _a;
|
|
5597
|
+
return ((_a = this._d) == null ? void 0 : _a.size) || 0;
|
|
5598
|
+
}
|
|
5590
5599
|
|
|
5591
5600
|
// node_modules/.pnpm/@wopjs+dom@0.1.3/node_modules/@wopjs/dom/dist/index.js
|
|
5592
5601
|
function addEventListener(target, type, listener, options) {
|
|
@@ -6453,9 +6462,6 @@ var Presentation = class {
|
|
|
6453
6462
|
this.contentDOM.className = this.c("content");
|
|
6454
6463
|
this.previewDOM = document.createElement("div");
|
|
6455
6464
|
this.previewDOM.className = this.c("preview");
|
|
6456
|
-
this.imageDOM = document.createElement("div");
|
|
6457
|
-
this.imageDOM.className = this.c("image");
|
|
6458
|
-
this.image = document.createElement("img");
|
|
6459
6465
|
this.whiteboardDOM = document.createElement("div");
|
|
6460
6466
|
this.whiteboardDOM.className = this.c("wb-view");
|
|
6461
6467
|
this.footerDOM = document.createElement("div");
|
|
@@ -6525,8 +6531,6 @@ var Presentation = class {
|
|
|
6525
6531
|
this.togglePreview(false);
|
|
6526
6532
|
}
|
|
6527
6533
|
}));
|
|
6528
|
-
this.imageDOM.appendChild(this.image);
|
|
6529
|
-
this.contentDOM.appendChild(this.imageDOM);
|
|
6530
6534
|
this.updateImage();
|
|
6531
6535
|
this.contentDOM.appendChild(this.whiteboardDOM);
|
|
6532
6536
|
this.footerDOM.classList.toggle(this.c("readonly"), this.readonly);
|
|
@@ -6835,17 +6839,22 @@ var Scrollbar = class {
|
|
|
6835
6839
|
return;
|
|
6836
6840
|
const { scale, centerX, centerY } = this.view.camera;
|
|
6837
6841
|
const originScale = this.option.getOriginScale();
|
|
6838
|
-
const
|
|
6839
|
-
const
|
|
6840
|
-
const
|
|
6842
|
+
const { width: pageWidth, height: pageHeight } = this.option.getPageSize();
|
|
6843
|
+
const { width: viewWidth, height: viewHeight } = this.view.size;
|
|
6844
|
+
const originScaleX = viewWidth / pageWidth;
|
|
6845
|
+
const originScaleY = viewHeight / pageHeight;
|
|
6846
|
+
const ratioX = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
|
|
6847
|
+
const ratioY = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
|
|
6848
|
+
const scrollX = Math.round(centerX * originScaleX);
|
|
6849
|
+
const scrollY = Math.round(centerY * originScaleY);
|
|
6841
6850
|
if (this.scrollbarX) {
|
|
6842
|
-
this.scrollbarX.style.width = `${
|
|
6843
|
-
this.scrollbarX.style.display =
|
|
6851
|
+
this.scrollbarX.style.width = `${ratioX * 100}%`;
|
|
6852
|
+
this.scrollbarX.style.display = ratioX === 1 ? "none" : "block";
|
|
6844
6853
|
this.scrollbarX.style.transform = `translateX(${scrollX}px)`;
|
|
6845
6854
|
}
|
|
6846
6855
|
if (this.scrollbarY) {
|
|
6847
|
-
this.scrollbarY.style.height = `${
|
|
6848
|
-
this.scrollbarY.style.display =
|
|
6856
|
+
this.scrollbarY.style.height = `${ratioY * 100}%`;
|
|
6857
|
+
this.scrollbarY.style.display = ratioY === 1 ? "none" : "block";
|
|
6849
6858
|
this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
|
|
6850
6859
|
}
|
|
6851
6860
|
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, this.appId, originScale, scale);
|
|
@@ -6864,9 +6873,11 @@ var Scrollbar = class {
|
|
|
6864
6873
|
var _a, _b;
|
|
6865
6874
|
if (this.cameraCache) {
|
|
6866
6875
|
const { x } = transformedDrag;
|
|
6867
|
-
const
|
|
6876
|
+
const { width: pageWidth } = this.option.getPageSize();
|
|
6877
|
+
const { width: viewWidth } = this.view.size;
|
|
6878
|
+
const originScaleX = viewWidth / pageWidth;
|
|
6868
6879
|
const { minX, maxX } = this.getScrollXRange(this.cameraCache);
|
|
6869
|
-
const scrollX = Math.round(x /
|
|
6880
|
+
const scrollX = Math.round(x / originScaleX);
|
|
6870
6881
|
let centerX = scrollX + this.cameraCache.centerX;
|
|
6871
6882
|
if (centerX < minX) {
|
|
6872
6883
|
centerX = minX;
|
|
@@ -6884,9 +6895,11 @@ var Scrollbar = class {
|
|
|
6884
6895
|
var _a, _b;
|
|
6885
6896
|
if (this.cameraCache) {
|
|
6886
6897
|
const { y } = transformedDrag;
|
|
6887
|
-
const
|
|
6898
|
+
const { height: pageHeight } = this.option.getPageSize();
|
|
6899
|
+
const { height: viewHeight } = this.view.size;
|
|
6900
|
+
const originScaleY = viewHeight / pageHeight;
|
|
6888
6901
|
const { minY, maxY } = this.getScrollYRange(this.cameraCache);
|
|
6889
|
-
const scrollY = Math.round(y /
|
|
6902
|
+
const scrollY = Math.round(y / originScaleY);
|
|
6890
6903
|
let centerY = scrollY + this.cameraCache.centerY;
|
|
6891
6904
|
if (centerY < minY) {
|
|
6892
6905
|
centerY = minY;
|
|
@@ -6919,28 +6932,29 @@ var Scrollbar = class {
|
|
|
6919
6932
|
}
|
|
6920
6933
|
setReadonly(bol) {
|
|
6921
6934
|
this.readonly = bol;
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
} else {
|
|
6935
|
+
this.destroy();
|
|
6936
|
+
if (!this.readonly) {
|
|
6925
6937
|
this.init();
|
|
6926
6938
|
}
|
|
6927
6939
|
}
|
|
6928
6940
|
getScrollXRange(camera) {
|
|
6929
|
-
const { width } = this.option.getPageSize();
|
|
6930
|
-
const
|
|
6941
|
+
const { width: pageWidth } = this.option.getPageSize();
|
|
6942
|
+
const { width: viewWidth } = this.view.size;
|
|
6943
|
+
const originScaleX = viewWidth / pageWidth;
|
|
6931
6944
|
const scale = camera.scale;
|
|
6932
|
-
const ratio = Math.round(
|
|
6933
|
-
const scrollWidth =
|
|
6945
|
+
const ratio = Math.min(Math.round(originScaleX / scale * 100) / 100, 1);
|
|
6946
|
+
const scrollWidth = pageWidth * (1 - ratio);
|
|
6934
6947
|
const minX = -scrollWidth / 2;
|
|
6935
6948
|
const maxX = scrollWidth / 2;
|
|
6936
6949
|
return { minX, maxX };
|
|
6937
6950
|
}
|
|
6938
6951
|
getScrollYRange(camera) {
|
|
6939
|
-
const { height } = this.option.getPageSize();
|
|
6940
|
-
const
|
|
6952
|
+
const { height: pageHeight } = this.option.getPageSize();
|
|
6953
|
+
const { height: viewHeight } = this.view.size;
|
|
6954
|
+
const originScaleY = viewHeight / pageHeight;
|
|
6941
6955
|
const scale = camera.scale;
|
|
6942
|
-
const ratio = Math.round(
|
|
6943
|
-
const scrollHeight =
|
|
6956
|
+
const ratio = Math.min(Math.round(originScaleY / scale * 100) / 100, 1);
|
|
6957
|
+
const scrollHeight = pageHeight * (1 - ratio);
|
|
6944
6958
|
const minY = -scrollHeight / 2;
|
|
6945
6959
|
const maxY = scrollHeight / 2;
|
|
6946
6960
|
return { minY, maxY };
|
|
@@ -6986,20 +7000,32 @@ var Scrollbar = class {
|
|
|
6986
7000
|
this.onCameraUpdated();
|
|
6987
7001
|
}
|
|
6988
7002
|
destroy() {
|
|
6989
|
-
var _a, _b, _c, _d;
|
|
6990
7003
|
this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
|
6991
|
-
(
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
this.
|
|
6998
|
-
|
|
7004
|
+
if (this.scrollbarX && this.scrollbarContainerX) {
|
|
7005
|
+
this.scrollbarContainerX.removeChild(this.scrollbarX);
|
|
7006
|
+
this.scrollbarX.remove();
|
|
7007
|
+
this.scrollbarContainerX.remove();
|
|
7008
|
+
this.scrollbarX = void 0;
|
|
7009
|
+
}
|
|
7010
|
+
if (this.scrollbarY && this.scrollbarContainerY) {
|
|
7011
|
+
this.scrollbarContainerY.removeChild(this.scrollbarY);
|
|
7012
|
+
this.scrollbarY.remove();
|
|
7013
|
+
this.scrollbarContainerY.remove();
|
|
7014
|
+
this.scrollbarY = void 0;
|
|
7015
|
+
}
|
|
7016
|
+
if (this.draggableX) {
|
|
7017
|
+
this.draggableX.destroy();
|
|
7018
|
+
this.draggableX = void 0;
|
|
7019
|
+
}
|
|
7020
|
+
if (this.draggableY) {
|
|
7021
|
+
this.draggableY.destroy();
|
|
7022
|
+
this.draggableY = void 0;
|
|
7023
|
+
}
|
|
6999
7024
|
}
|
|
7000
7025
|
};
|
|
7001
7026
|
|
|
7002
7027
|
// src/app-presentation.ts
|
|
7028
|
+
var import_lodash2 = __toESM(require_lodash());
|
|
7003
7029
|
var emptySceneName = "$$empty$$";
|
|
7004
7030
|
var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
|
|
7005
7031
|
var createLogger = (room) => {
|
|
@@ -7081,9 +7107,9 @@ var NetlessAppPresentation = {
|
|
|
7081
7107
|
if (pages.length > 100)
|
|
7082
7108
|
console.warn(`[Presentation]: too many pages (${pages.length}), may cause performance issues`);
|
|
7083
7109
|
let redirectResolve = void 0;
|
|
7084
|
-
const
|
|
7085
|
-
if (
|
|
7086
|
-
const scenes =
|
|
7110
|
+
const room2 = context.getRoom();
|
|
7111
|
+
if (room2 && room2.isWritable) {
|
|
7112
|
+
const scenes = room2.entireScenes()[scenePath];
|
|
7087
7113
|
if (pageIndex$.value < 0 || pageIndex$.value >= pages.length) {
|
|
7088
7114
|
throw new Error(`[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`);
|
|
7089
7115
|
}
|
|
@@ -7098,8 +7124,8 @@ var NetlessAppPresentation = {
|
|
|
7098
7124
|
};
|
|
7099
7125
|
});
|
|
7100
7126
|
if (!scenesEqual(scenes, _scenes)) {
|
|
7101
|
-
|
|
7102
|
-
|
|
7127
|
+
room2.removeScenes(scenePath);
|
|
7128
|
+
room2.putScenes(scenePath, _scenes);
|
|
7103
7129
|
}
|
|
7104
7130
|
if (name === _scenes[pageIndex$.value].name && !ppt) {
|
|
7105
7131
|
context.addPage({ scene: { name: emptySceneName } }).then(() => {
|
|
@@ -7112,10 +7138,10 @@ var NetlessAppPresentation = {
|
|
|
7112
7138
|
redirectResolve && redirectResolve(false);
|
|
7113
7139
|
}
|
|
7114
7140
|
}).then(async (bol) => {
|
|
7115
|
-
await syncPage(pageIndex$.value,
|
|
7141
|
+
await syncPage(pageIndex$.value, room2.logger);
|
|
7116
7142
|
if (bol) {
|
|
7117
7143
|
log(`[Presentation] setup removeScenes ${scenePath}/${emptySceneName}`);
|
|
7118
|
-
|
|
7144
|
+
room2.removeScenes(`${scenePath}/${emptySceneName}`);
|
|
7119
7145
|
}
|
|
7120
7146
|
});
|
|
7121
7147
|
}
|
|
@@ -7230,14 +7256,32 @@ var NetlessAppPresentation = {
|
|
|
7230
7256
|
}
|
|
7231
7257
|
};
|
|
7232
7258
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
7259
|
+
const getPageSize = () => {
|
|
7260
|
+
const { width, height } = app.page() || {};
|
|
7261
|
+
return { width: width || 0, height: height || 0 };
|
|
7262
|
+
};
|
|
7233
7263
|
const box = context.getBox();
|
|
7234
|
-
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
7235
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7264
|
+
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
|
|
7265
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.6";
|
|
7236
7266
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7237
7267
|
app.log = log;
|
|
7238
7268
|
if (options.justDocsViewReadonly) {
|
|
7239
7269
|
app.setDocsViewReadonly(true);
|
|
7240
7270
|
}
|
|
7271
|
+
const room = context.getRoom();
|
|
7272
|
+
const goToPageByClick = () => {
|
|
7273
|
+
var _a2, _b2, _c2, _d;
|
|
7274
|
+
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 : "";
|
|
7275
|
+
if (!app.readonly && currentApplianceName === "clicker") {
|
|
7276
|
+
nextPage();
|
|
7277
|
+
}
|
|
7278
|
+
};
|
|
7279
|
+
if (room && options.goToPageByClick && app.whiteboardDOM) {
|
|
7280
|
+
dispose2.make(() => {
|
|
7281
|
+
app.whiteboardDOM.addEventListener("click", goToPageByClick);
|
|
7282
|
+
return () => app.whiteboardDOM.removeEventListener("click", goToPageByClick);
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7241
7285
|
context.mountView(app.whiteboardDOM);
|
|
7242
7286
|
if (options.disableCameraTransform) {
|
|
7243
7287
|
view.disableCameraTransform = true;
|
|
@@ -7267,10 +7311,6 @@ var NetlessAppPresentation = {
|
|
|
7267
7311
|
dispose2.add(context.emitter.on("writableChange", (isWritable) => {
|
|
7268
7312
|
app.setReadonly(!isWritable);
|
|
7269
7313
|
}));
|
|
7270
|
-
const getPageSize = () => {
|
|
7271
|
-
const { width, height } = app.page() || {};
|
|
7272
|
-
return { width: width || 0, height: height || 0 };
|
|
7273
|
-
};
|
|
7274
7314
|
const getOriginScale = () => {
|
|
7275
7315
|
const { size } = view;
|
|
7276
7316
|
const { width, height } = getPageSize();
|
|
@@ -7279,6 +7319,42 @@ var NetlessAppPresentation = {
|
|
|
7279
7319
|
const getScale = () => {
|
|
7280
7320
|
return view.camera.scale;
|
|
7281
7321
|
};
|
|
7322
|
+
const screenshotCurrentPageAsync = async (_context, _width, _height) => {
|
|
7323
|
+
var _a2, _b2;
|
|
7324
|
+
(_b2 = (_a2 = room == null ? void 0 : room.calibrationTimestamp) == null ? void 0 : _a2.toString()) != null ? _b2 : Date.now().toString();
|
|
7325
|
+
const currentPage = pages[pageIndex$.value];
|
|
7326
|
+
if (!currentPage) {
|
|
7327
|
+
throw new Error("[Presentation]: current page not found");
|
|
7328
|
+
}
|
|
7329
|
+
const { width, height, src } = currentPage;
|
|
7330
|
+
const img = document.createElement("img");
|
|
7331
|
+
img.width = width;
|
|
7332
|
+
img.height = height;
|
|
7333
|
+
img.crossOrigin = "Anonymous";
|
|
7334
|
+
await new Promise((resolve) => {
|
|
7335
|
+
img.onload = resolve;
|
|
7336
|
+
img.src = src;
|
|
7337
|
+
});
|
|
7338
|
+
_context.drawImage(img, 0, 0, width, height, 0, 0, _width || width, _height || height);
|
|
7339
|
+
const currentScenePath = view.focusScenePath;
|
|
7340
|
+
if (!currentScenePath) {
|
|
7341
|
+
throw new Error("[Presentation]: current scene path not found");
|
|
7342
|
+
}
|
|
7343
|
+
const windowManger = context.getWindowManager();
|
|
7344
|
+
if (windowManger._appliancePlugin) {
|
|
7345
|
+
await windowManger._appliancePlugin.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
|
|
7346
|
+
centerX: 0,
|
|
7347
|
+
centerY: 0,
|
|
7348
|
+
scale: _width && _height ? Math.min(_width / width, _height / height) : 1
|
|
7349
|
+
});
|
|
7350
|
+
} else {
|
|
7351
|
+
await view.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
|
|
7352
|
+
centerX: 0,
|
|
7353
|
+
centerY: 0,
|
|
7354
|
+
scale: _width && _height ? Math.min(_width / width, _height / height) : 1
|
|
7355
|
+
});
|
|
7356
|
+
}
|
|
7357
|
+
};
|
|
7282
7358
|
const moveCamera = (camera) => {
|
|
7283
7359
|
if (context.getIsWritable()) {
|
|
7284
7360
|
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
@@ -7369,12 +7445,12 @@ var NetlessAppPresentation = {
|
|
|
7369
7445
|
const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
|
|
7370
7446
|
if (scenes.some((scene) => scene.name == name)) {
|
|
7371
7447
|
const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
|
|
7372
|
-
const sPath = `${scenePath}/${
|
|
7373
|
-
const windowManger = context.
|
|
7448
|
+
const sPath = `${scenePath}/${name}`;
|
|
7449
|
+
const windowManger = context.getWindowManager();
|
|
7374
7450
|
if (windowManger._appliancePlugin) {
|
|
7375
7451
|
await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
|
|
7376
7452
|
} else {
|
|
7377
|
-
view.
|
|
7453
|
+
await view.screenshotToCanvasAsync(
|
|
7378
7454
|
wb,
|
|
7379
7455
|
sPath,
|
|
7380
7456
|
wb_canvas.width,
|
|
@@ -7420,11 +7496,12 @@ var NetlessAppPresentation = {
|
|
|
7420
7496
|
};
|
|
7421
7497
|
const setReadonly = (bol) => {
|
|
7422
7498
|
app.setReadonly(bol);
|
|
7499
|
+
if (options.goToPageByClick) ;
|
|
7423
7500
|
if (scrollbar) {
|
|
7424
7501
|
scrollbar.setReadonly(bol);
|
|
7425
7502
|
}
|
|
7426
7503
|
};
|
|
7427
|
-
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale };
|
|
7504
|
+
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale, getPageSize, screenshotCurrentPageAsync };
|
|
7428
7505
|
dispose2.add(listen(window, "message", (ev) => {
|
|
7429
7506
|
if (ev.data === "@netless/_presentation_") {
|
|
7430
7507
|
if (typeof window !== "undefined")
|
|
@@ -7443,7 +7520,6 @@ var AppPresentation = class extends Presentation {
|
|
|
7443
7520
|
constructor(config) {
|
|
7444
7521
|
super(config);
|
|
7445
7522
|
this.jumpPage = config.jumpPage;
|
|
7446
|
-
this.image.style.display = "none";
|
|
7447
7523
|
}
|
|
7448
7524
|
updateImage() {
|
|
7449
7525
|
super.updateImage();
|
|
@@ -7460,7 +7536,7 @@ var AppPresentation = class extends Presentation {
|
|
|
7460
7536
|
}
|
|
7461
7537
|
}
|
|
7462
7538
|
};
|
|
7463
|
-
function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
|
|
7539
|
+
function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, useClipView) {
|
|
7464
7540
|
box.mountStyles(style_default);
|
|
7465
7541
|
const app = new AppPresentation({ pages, readonly: box.readonly, jumpPage, thumbnail });
|
|
7466
7542
|
app.box = box;
|
|
@@ -7469,6 +7545,29 @@ function createPresentation(box, pages, jumpPage, pageIndex$, thumbnail) {
|
|
|
7469
7545
|
app.dispose.add(pageIndex$.subscribe((pageIndex) => {
|
|
7470
7546
|
app.setPageIndex(pageIndex);
|
|
7471
7547
|
}));
|
|
7548
|
+
if (useClipView && view) {
|
|
7549
|
+
const onCameraUpdatedEffectForMaskView = (0, import_lodash2.debounce)(() => {
|
|
7550
|
+
const { width: pageWidth, height: pageHeight } = app.page() || {};
|
|
7551
|
+
if (!pageWidth || !pageHeight) {
|
|
7552
|
+
return;
|
|
7553
|
+
}
|
|
7554
|
+
const { scale } = view.camera;
|
|
7555
|
+
const { width, height } = view.size;
|
|
7556
|
+
const pageRatioX = Math.round((1 - pageWidth * scale / width) / 2 * 100);
|
|
7557
|
+
const pageRatioY = Math.round((1 - pageHeight * scale / height) / 2 * 100);
|
|
7558
|
+
app.whiteboardDOM.style.clipPath = `inset(${pageRatioY}% ${pageRatioX}%)`;
|
|
7559
|
+
}, 50);
|
|
7560
|
+
onCameraUpdatedEffectForMaskView();
|
|
7561
|
+
const onCameraUpdatedEffect = () => {
|
|
7562
|
+
view.callbacks.on("onSizeUpdated", onCameraUpdatedEffectForMaskView);
|
|
7563
|
+
view.callbacks.on("onCameraUpdated", onCameraUpdatedEffectForMaskView);
|
|
7564
|
+
return () => {
|
|
7565
|
+
view.callbacks.off("onCameraUpdated", onCameraUpdatedEffectForMaskView);
|
|
7566
|
+
view.callbacks.off("onSizeUpdated", onCameraUpdatedEffectForMaskView);
|
|
7567
|
+
};
|
|
7568
|
+
};
|
|
7569
|
+
app.dispose.make(onCameraUpdatedEffect);
|
|
7570
|
+
}
|
|
7472
7571
|
return app;
|
|
7473
7572
|
}
|
|
7474
7573
|
var install = (register, options = {}) => {
|
|
@@ -7480,7 +7579,7 @@ var install = (register, options = {}) => {
|
|
|
7480
7579
|
};
|
|
7481
7580
|
|
|
7482
7581
|
// src/index.ts
|
|
7483
|
-
var version = "0.1.9-beta.
|
|
7582
|
+
var version = "0.1.9-beta.6";
|
|
7484
7583
|
/*! Bundled license information:
|
|
7485
7584
|
|
|
7486
7585
|
lodash/lodash.js:
|
|
@@ -7494,5 +7593,5 @@ lodash/lodash.js:
|
|
|
7494
7593
|
*)
|
|
7495
7594
|
*/
|
|
7496
7595
|
|
|
7497
|
-
export { NetlessAppPresentation, Presentation, NetlessAppPresentation as default, install,
|
|
7596
|
+
export { NetlessAppPresentation, Presentation, NetlessAppPresentation as default, install, version };
|
|
7498
7597
|
//# sourceMappingURL=index.mjs.map
|