@netless/app-presentation 0.1.9-beta.1 → 0.1.9-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.global.js +50 -19
- package/dist/index.js +50 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +28 -6
- package/src/scrollbar/index.ts +7 -12
package/dist/index.d.ts
CHANGED
|
@@ -363,6 +363,14 @@ interface PresentationController {
|
|
|
363
363
|
setDocsViewReadonly: (bol: boolean) => void;
|
|
364
364
|
/** set the presentation readonly */
|
|
365
365
|
setReadonly: (bol: boolean) => void;
|
|
366
|
+
/** move the camera */
|
|
367
|
+
moveCamera: (camera: {
|
|
368
|
+
centerX: number;
|
|
369
|
+
centerY: number;
|
|
370
|
+
scale: number;
|
|
371
|
+
}) => void;
|
|
372
|
+
/** get the origin scale */
|
|
373
|
+
getOriginScale: () => number;
|
|
366
374
|
}
|
|
367
375
|
|
|
368
376
|
declare const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions, PresentationController>;
|
package/dist/index.global.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
var NetlessAppPresentation = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
|
|
4
24
|
// node_modules/.pnpm/@wopjs+disposable@0.1.5/node_modules/@wopjs/disposable/dist/index.mjs
|
|
5
25
|
var isAbortable = (disposable) => disposable && disposable.abortable;
|
|
6
26
|
var dispose = (disposable) => {
|
|
@@ -1304,13 +1324,14 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1304
1324
|
};
|
|
1305
1325
|
},
|
|
1306
1326
|
getWritable: () => false,
|
|
1327
|
+
getOriginScale: () => 1,
|
|
1307
1328
|
syncView: () => void 0
|
|
1308
1329
|
};
|
|
1309
1330
|
this.onCameraUpdated = () => {
|
|
1310
1331
|
if (this.readonly)
|
|
1311
1332
|
return;
|
|
1312
1333
|
const { scale, centerX, centerY } = this.view.camera;
|
|
1313
|
-
const originScale = this.getOriginScale();
|
|
1334
|
+
const originScale = this.option.getOriginScale();
|
|
1314
1335
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1315
1336
|
const scrollX = Math.round(centerX * originScale);
|
|
1316
1337
|
const scrollY = Math.round(centerY * originScale);
|
|
@@ -1336,7 +1357,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1336
1357
|
this.onDragX = (transformedDrag) => {
|
|
1337
1358
|
if (this.cameraCache) {
|
|
1338
1359
|
const { x } = transformedDrag;
|
|
1339
|
-
const originScale = this.getOriginScale();
|
|
1360
|
+
const originScale = this.option.getOriginScale();
|
|
1340
1361
|
const { minX, maxX } = this.getScrollXRange(this.cameraCache);
|
|
1341
1362
|
const scrollX = Math.round(x / originScale);
|
|
1342
1363
|
let centerX = scrollX + this.cameraCache.centerX;
|
|
@@ -1354,7 +1375,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1354
1375
|
this.onDragY = (transformedDrag) => {
|
|
1355
1376
|
if (this.cameraCache) {
|
|
1356
1377
|
const { y } = transformedDrag;
|
|
1357
|
-
const originScale = this.getOriginScale();
|
|
1378
|
+
const originScale = this.option.getOriginScale();
|
|
1358
1379
|
const { minY, maxY } = this.getScrollYRange(this.cameraCache);
|
|
1359
1380
|
const scrollY = Math.round(y / originScale);
|
|
1360
1381
|
let centerY = scrollY + this.cameraCache.centerY;
|
|
@@ -1383,11 +1404,6 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1383
1404
|
c(className) {
|
|
1384
1405
|
return `${this.namespace}-${className}`;
|
|
1385
1406
|
}
|
|
1386
|
-
getOriginScale() {
|
|
1387
|
-
const { size } = this.view;
|
|
1388
|
-
const { width, height } = this.option.getPageSize();
|
|
1389
|
-
return Math.min(size.height / height, size.width / width);
|
|
1390
|
-
}
|
|
1391
1407
|
setReadonly(bol) {
|
|
1392
1408
|
this.readonly = bol;
|
|
1393
1409
|
if (this.readonly) {
|
|
@@ -1398,7 +1414,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1398
1414
|
}
|
|
1399
1415
|
getScrollXRange(camera) {
|
|
1400
1416
|
const { width } = this.option.getPageSize();
|
|
1401
|
-
const originScale = this.getOriginScale();
|
|
1417
|
+
const originScale = this.option.getOriginScale();
|
|
1402
1418
|
const scale = camera.scale;
|
|
1403
1419
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1404
1420
|
const scrollWidth = width * (1 - ratio);
|
|
@@ -1408,7 +1424,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1408
1424
|
}
|
|
1409
1425
|
getScrollYRange(camera) {
|
|
1410
1426
|
const { height } = this.option.getPageSize();
|
|
1411
|
-
const originScale = this.getOriginScale();
|
|
1427
|
+
const originScale = this.option.getOriginScale();
|
|
1412
1428
|
const scale = camera.scale;
|
|
1413
1429
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1414
1430
|
const scrollHeight = height * (1 - ratio);
|
|
@@ -1703,7 +1719,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1703
1719
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
1704
1720
|
const box = context.getBox();
|
|
1705
1721
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
1706
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
1722
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.2";
|
|
1707
1723
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
1708
1724
|
app.log = log;
|
|
1709
1725
|
if (options.justDocsViewReadonly) {
|
|
@@ -1738,16 +1754,31 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1738
1754
|
dispose2.add(context.emitter.on("writableChange", (isWritable) => {
|
|
1739
1755
|
app.setReadonly(!isWritable);
|
|
1740
1756
|
}));
|
|
1757
|
+
const getPageSize = () => {
|
|
1758
|
+
const { width, height } = app.page() || {};
|
|
1759
|
+
return { width: width || 0, height: height || 0 };
|
|
1760
|
+
};
|
|
1761
|
+
const getOriginScale = () => {
|
|
1762
|
+
const { size } = view;
|
|
1763
|
+
const { width, height } = getPageSize();
|
|
1764
|
+
return Math.min(size.height / height, size.width / width);
|
|
1765
|
+
};
|
|
1766
|
+
const moveCamera = (camera) => {
|
|
1767
|
+
if (context.getIsWritable()) {
|
|
1768
|
+
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
1769
|
+
syncView();
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
1773
|
+
};
|
|
1741
1774
|
let scrollbar;
|
|
1742
1775
|
if (options.useScrollbar) {
|
|
1743
1776
|
dispose2.make(() => {
|
|
1744
1777
|
scrollbar = new Scrollbar(app.contentDOM, {
|
|
1745
|
-
getPageSize
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
getWritable: () => context.getIsWritable(),
|
|
1750
|
-
syncView: () => syncView()
|
|
1778
|
+
getPageSize,
|
|
1779
|
+
getOriginScale,
|
|
1780
|
+
syncView,
|
|
1781
|
+
getWritable: () => context.getIsWritable()
|
|
1751
1782
|
}, view);
|
|
1752
1783
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
1753
1784
|
});
|
|
@@ -1875,7 +1906,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1875
1906
|
scrollbar.setReadonly(bol);
|
|
1876
1907
|
}
|
|
1877
1908
|
};
|
|
1878
|
-
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly };
|
|
1909
|
+
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale };
|
|
1879
1910
|
dispose2.add(listen(window, "message", (ev) => {
|
|
1880
1911
|
if (ev.data === "@netless/_presentation_") {
|
|
1881
1912
|
if (typeof window !== "undefined")
|
|
@@ -1931,7 +1962,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1931
1962
|
};
|
|
1932
1963
|
|
|
1933
1964
|
// src/index.ts
|
|
1934
|
-
var version = "0.1.9-beta.
|
|
1965
|
+
var version = "0.1.9-beta.2";
|
|
1935
1966
|
|
|
1936
1967
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
1937
1968
|
exports.Presentation = Presentation;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
|
|
5
25
|
// node_modules/.pnpm/@wopjs+disposable@0.1.5/node_modules/@wopjs/disposable/dist/index.mjs
|
|
6
26
|
var isAbortable = (disposable) => disposable && disposable.abortable;
|
|
7
27
|
var dispose = (disposable) => {
|
|
@@ -1305,13 +1325,14 @@ var Scrollbar = class {
|
|
|
1305
1325
|
};
|
|
1306
1326
|
},
|
|
1307
1327
|
getWritable: () => false,
|
|
1328
|
+
getOriginScale: () => 1,
|
|
1308
1329
|
syncView: () => void 0
|
|
1309
1330
|
};
|
|
1310
1331
|
this.onCameraUpdated = () => {
|
|
1311
1332
|
if (this.readonly)
|
|
1312
1333
|
return;
|
|
1313
1334
|
const { scale, centerX, centerY } = this.view.camera;
|
|
1314
|
-
const originScale = this.getOriginScale();
|
|
1335
|
+
const originScale = this.option.getOriginScale();
|
|
1315
1336
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1316
1337
|
const scrollX = Math.round(centerX * originScale);
|
|
1317
1338
|
const scrollY = Math.round(centerY * originScale);
|
|
@@ -1337,7 +1358,7 @@ var Scrollbar = class {
|
|
|
1337
1358
|
this.onDragX = (transformedDrag) => {
|
|
1338
1359
|
if (this.cameraCache) {
|
|
1339
1360
|
const { x } = transformedDrag;
|
|
1340
|
-
const originScale = this.getOriginScale();
|
|
1361
|
+
const originScale = this.option.getOriginScale();
|
|
1341
1362
|
const { minX, maxX } = this.getScrollXRange(this.cameraCache);
|
|
1342
1363
|
const scrollX = Math.round(x / originScale);
|
|
1343
1364
|
let centerX = scrollX + this.cameraCache.centerX;
|
|
@@ -1355,7 +1376,7 @@ var Scrollbar = class {
|
|
|
1355
1376
|
this.onDragY = (transformedDrag) => {
|
|
1356
1377
|
if (this.cameraCache) {
|
|
1357
1378
|
const { y } = transformedDrag;
|
|
1358
|
-
const originScale = this.getOriginScale();
|
|
1379
|
+
const originScale = this.option.getOriginScale();
|
|
1359
1380
|
const { minY, maxY } = this.getScrollYRange(this.cameraCache);
|
|
1360
1381
|
const scrollY = Math.round(y / originScale);
|
|
1361
1382
|
let centerY = scrollY + this.cameraCache.centerY;
|
|
@@ -1384,11 +1405,6 @@ var Scrollbar = class {
|
|
|
1384
1405
|
c(className) {
|
|
1385
1406
|
return `${this.namespace}-${className}`;
|
|
1386
1407
|
}
|
|
1387
|
-
getOriginScale() {
|
|
1388
|
-
const { size } = this.view;
|
|
1389
|
-
const { width, height } = this.option.getPageSize();
|
|
1390
|
-
return Math.min(size.height / height, size.width / width);
|
|
1391
|
-
}
|
|
1392
1408
|
setReadonly(bol) {
|
|
1393
1409
|
this.readonly = bol;
|
|
1394
1410
|
if (this.readonly) {
|
|
@@ -1399,7 +1415,7 @@ var Scrollbar = class {
|
|
|
1399
1415
|
}
|
|
1400
1416
|
getScrollXRange(camera) {
|
|
1401
1417
|
const { width } = this.option.getPageSize();
|
|
1402
|
-
const originScale = this.getOriginScale();
|
|
1418
|
+
const originScale = this.option.getOriginScale();
|
|
1403
1419
|
const scale = camera.scale;
|
|
1404
1420
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1405
1421
|
const scrollWidth = width * (1 - ratio);
|
|
@@ -1409,7 +1425,7 @@ var Scrollbar = class {
|
|
|
1409
1425
|
}
|
|
1410
1426
|
getScrollYRange(camera) {
|
|
1411
1427
|
const { height } = this.option.getPageSize();
|
|
1412
|
-
const originScale = this.getOriginScale();
|
|
1428
|
+
const originScale = this.option.getOriginScale();
|
|
1413
1429
|
const scale = camera.scale;
|
|
1414
1430
|
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1415
1431
|
const scrollHeight = height * (1 - ratio);
|
|
@@ -1704,7 +1720,7 @@ var NetlessAppPresentation = {
|
|
|
1704
1720
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
1705
1721
|
const box = context.getBox();
|
|
1706
1722
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
1707
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
1723
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.2";
|
|
1708
1724
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
1709
1725
|
app.log = log;
|
|
1710
1726
|
if (options.justDocsViewReadonly) {
|
|
@@ -1739,16 +1755,31 @@ var NetlessAppPresentation = {
|
|
|
1739
1755
|
dispose2.add(context.emitter.on("writableChange", (isWritable) => {
|
|
1740
1756
|
app.setReadonly(!isWritable);
|
|
1741
1757
|
}));
|
|
1758
|
+
const getPageSize = () => {
|
|
1759
|
+
const { width, height } = app.page() || {};
|
|
1760
|
+
return { width: width || 0, height: height || 0 };
|
|
1761
|
+
};
|
|
1762
|
+
const getOriginScale = () => {
|
|
1763
|
+
const { size } = view;
|
|
1764
|
+
const { width, height } = getPageSize();
|
|
1765
|
+
return Math.min(size.height / height, size.width / width);
|
|
1766
|
+
};
|
|
1767
|
+
const moveCamera = (camera) => {
|
|
1768
|
+
if (context.getIsWritable()) {
|
|
1769
|
+
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
1770
|
+
syncView();
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
1774
|
+
};
|
|
1742
1775
|
let scrollbar;
|
|
1743
1776
|
if (options.useScrollbar) {
|
|
1744
1777
|
dispose2.make(() => {
|
|
1745
1778
|
scrollbar = new Scrollbar(app.contentDOM, {
|
|
1746
|
-
getPageSize
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
getWritable: () => context.getIsWritable(),
|
|
1751
|
-
syncView: () => syncView()
|
|
1779
|
+
getPageSize,
|
|
1780
|
+
getOriginScale,
|
|
1781
|
+
syncView,
|
|
1782
|
+
getWritable: () => context.getIsWritable()
|
|
1752
1783
|
}, view);
|
|
1753
1784
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
1754
1785
|
});
|
|
@@ -1876,7 +1907,7 @@ var NetlessAppPresentation = {
|
|
|
1876
1907
|
scrollbar.setReadonly(bol);
|
|
1877
1908
|
}
|
|
1878
1909
|
};
|
|
1879
|
-
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly };
|
|
1910
|
+
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale };
|
|
1880
1911
|
dispose2.add(listen(window, "message", (ev) => {
|
|
1881
1912
|
if (ev.data === "@netless/_presentation_") {
|
|
1882
1913
|
if (typeof window !== "undefined")
|
|
@@ -1932,7 +1963,7 @@ var install = (register, options = {}) => {
|
|
|
1932
1963
|
};
|
|
1933
1964
|
|
|
1934
1965
|
// src/index.ts
|
|
1935
|
-
var version = "0.1.9-beta.
|
|
1966
|
+
var version = "0.1.9-beta.2";
|
|
1936
1967
|
|
|
1937
1968
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
1938
1969
|
exports.Presentation = Presentation;
|