@netless/app-presentation 0.1.2 → 0.1.4-beta.0
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 +24 -8
- package/dist/index.global.js +169 -59
- package/dist/index.js +169 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +169 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/app-presentation.ts +14 -5
- package/src/preload.ts +154 -53
- package/src/presentation.ts +16 -8
package/dist/index.d.ts
CHANGED
|
@@ -195,17 +195,32 @@ interface ILazyLoadInstance {
|
|
|
195
195
|
toLoadCount: number;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
declare enum ELoadState {
|
|
199
|
+
unloaded = 0,
|
|
200
|
+
loading = 1,
|
|
201
|
+
loaded = 2,
|
|
202
|
+
error = 3
|
|
203
|
+
}
|
|
204
|
+
interface IPreloadMapValue {
|
|
205
|
+
src: string;
|
|
206
|
+
state: ELoadState;
|
|
207
|
+
}
|
|
198
208
|
declare class Preload implements IDisposable {
|
|
199
209
|
readonly pages: PresentationPage[];
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
static maxLinks: number;
|
|
211
|
+
readonly loadingLinks: Map<number, HTMLLinkElement>;
|
|
212
|
+
readonly preloadMap: Map<number, IPreloadMapValue>;
|
|
213
|
+
readonly waitingLoadSet: Set<number>;
|
|
214
|
+
readonly waitinglinks: number[];
|
|
215
|
+
touchIndex: number;
|
|
216
|
+
preloadSize: number;
|
|
206
217
|
constructor(pages: PresentationPage[]);
|
|
207
|
-
touch(index: number):
|
|
208
|
-
|
|
218
|
+
touch(index: number): Promise<ELoadState>;
|
|
219
|
+
private autoTouch;
|
|
220
|
+
private createLink;
|
|
221
|
+
private handler;
|
|
222
|
+
private requestAsyncCallBack;
|
|
223
|
+
private destroyLink;
|
|
209
224
|
dispose(): void;
|
|
210
225
|
}
|
|
211
226
|
|
|
@@ -272,6 +287,7 @@ declare class Presentation implements IDisposable<void> {
|
|
|
272
287
|
showPreview: boolean;
|
|
273
288
|
pageIndex: number;
|
|
274
289
|
previewLazyload: ILazyLoadInstance | null;
|
|
290
|
+
timer: number | null;
|
|
275
291
|
constructor(config: PresentationConfig);
|
|
276
292
|
initialize(): void;
|
|
277
293
|
setDOM(dom: Element | DocumentFragment): void;
|
package/dist/index.global.js
CHANGED
|
@@ -790,66 +790,161 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
// src/preload.ts
|
|
793
|
-
var
|
|
793
|
+
var _Preload = class _Preload {
|
|
794
794
|
constructor(pages) {
|
|
795
795
|
this.pages = pages;
|
|
796
|
-
this.
|
|
797
|
-
this.
|
|
798
|
-
this.
|
|
799
|
-
this.
|
|
800
|
-
this.
|
|
796
|
+
this.loadingLinks = /* @__PURE__ */ new Map();
|
|
797
|
+
this.preloadMap = /* @__PURE__ */ new Map();
|
|
798
|
+
this.waitingLoadSet = /* @__PURE__ */ new Set();
|
|
799
|
+
this.waitinglinks = [];
|
|
800
|
+
this.touchIndex = 0;
|
|
801
|
+
this.preloadSize = 0;
|
|
802
|
+
this.preloadMap = new Map(pages.map((e, index) => [index, {
|
|
803
|
+
src: e.src,
|
|
804
|
+
state: 0 /* unloaded */
|
|
805
|
+
}]));
|
|
806
|
+
this.waitingLoadSet = new Set(pages.map((e, index) => index));
|
|
807
|
+
this.preloadSize = this.preloadMap.size;
|
|
801
808
|
this.touch(0);
|
|
802
809
|
}
|
|
803
|
-
|
|
804
|
-
|
|
810
|
+
async touch(index) {
|
|
811
|
+
this.touchIndex = index;
|
|
812
|
+
const value = this.preloadMap.get(index);
|
|
813
|
+
let state = 0 /* unloaded */;
|
|
814
|
+
if (value) {
|
|
815
|
+
state = value.state;
|
|
816
|
+
if (value.state === 0 /* unloaded */) {
|
|
817
|
+
if (this.loadingLinks.size) {
|
|
818
|
+
for (const [i, link] of this.loadingLinks) {
|
|
819
|
+
this.destroyLink(i, link);
|
|
820
|
+
this.waitingLoadSet.add(i);
|
|
821
|
+
const v = this.preloadMap.get(i);
|
|
822
|
+
if (v) {
|
|
823
|
+
v.state = 0 /* unloaded */;
|
|
824
|
+
this.preloadMap.set(i, v);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
for (const i of this.waitinglinks) {
|
|
828
|
+
this.waitingLoadSet.add(i);
|
|
829
|
+
}
|
|
830
|
+
this.waitinglinks.length = 0;
|
|
831
|
+
}
|
|
832
|
+
if (this.waitinglinks.includes(index)) {
|
|
833
|
+
this.waitinglinks.splice(this.waitinglinks.indexOf(index), 1);
|
|
834
|
+
}
|
|
835
|
+
state = await new Promise((resolve) => {
|
|
836
|
+
this.waitingLoadSet.delete(index);
|
|
837
|
+
this.createLink(index, resolve);
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (this.waitingLoadSet.size) {
|
|
842
|
+
this.requestAsyncCallBack(() => {
|
|
843
|
+
this.autoTouch();
|
|
844
|
+
}, 1e3);
|
|
845
|
+
}
|
|
846
|
+
return state;
|
|
805
847
|
}
|
|
806
|
-
|
|
807
|
-
|
|
848
|
+
autoTouch() {
|
|
849
|
+
this.handler();
|
|
850
|
+
if (this.waitingLoadSet.size === 0) {
|
|
808
851
|
return;
|
|
809
|
-
|
|
810
|
-
|
|
852
|
+
}
|
|
853
|
+
let nextTouchDelay = 1e3;
|
|
854
|
+
this.touchIndex = (this.touchIndex + 1) % this.preloadSize;
|
|
855
|
+
const value = this.preloadMap.get(this.touchIndex);
|
|
856
|
+
if (value) {
|
|
857
|
+
switch (value.state) {
|
|
858
|
+
case 0 /* unloaded */:
|
|
859
|
+
case 3 /* error */:
|
|
860
|
+
if (!this.waitinglinks.includes(this.touchIndex)) {
|
|
861
|
+
this.waitinglinks.push(this.touchIndex);
|
|
862
|
+
this.waitingLoadSet.delete(this.touchIndex);
|
|
863
|
+
}
|
|
864
|
+
nextTouchDelay = 0;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
this.requestAsyncCallBack(() => {
|
|
869
|
+
this.autoTouch();
|
|
870
|
+
}, nextTouchDelay);
|
|
811
871
|
}
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
this.head--;
|
|
816
|
-
if (!links[this.head]) {
|
|
872
|
+
createLink(index, resolve) {
|
|
873
|
+
const value = this.preloadMap.get(index);
|
|
874
|
+
if (value) {
|
|
817
875
|
const link = document.createElement("link");
|
|
818
|
-
links[this.head] = link;
|
|
819
876
|
link.rel = "preload";
|
|
820
877
|
link.as = "image";
|
|
821
|
-
link.href =
|
|
822
|
-
link.dataset.order =
|
|
878
|
+
link.href = value.src;
|
|
879
|
+
link.dataset.order = index + "";
|
|
823
880
|
document.head.appendChild(link);
|
|
824
|
-
|
|
881
|
+
link.onload = () => {
|
|
882
|
+
value.state = 2 /* loaded */;
|
|
883
|
+
this.preloadMap.set(index, value);
|
|
884
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
885
|
+
this.loadingLinks.delete(index);
|
|
886
|
+
resolve && resolve(2 /* loaded */);
|
|
887
|
+
this.autoTouch();
|
|
888
|
+
};
|
|
889
|
+
link.onerror = () => {
|
|
890
|
+
value.state = 3 /* error */;
|
|
891
|
+
this.preloadMap.set(index, value);
|
|
892
|
+
if (!this.waitinglinks.includes(index)) {
|
|
893
|
+
this.waitinglinks.push(index);
|
|
894
|
+
this.waitingLoadSet.delete(this.touchIndex);
|
|
895
|
+
}
|
|
896
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
897
|
+
this.loadingLinks.delete(index);
|
|
898
|
+
resolve && resolve(3 /* error */);
|
|
899
|
+
this.autoTouch();
|
|
900
|
+
};
|
|
901
|
+
this.loadingLinks.set(index, link);
|
|
902
|
+
value.state = 1 /* loading */;
|
|
903
|
+
this.preloadMap.set(index, value);
|
|
825
904
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
if (this.
|
|
829
|
-
|
|
830
|
-
links[this.tail] = link;
|
|
831
|
-
link.rel = "preload";
|
|
832
|
-
link.as = "image";
|
|
833
|
-
link.href = this.pages[this.tail].src;
|
|
834
|
-
link.dataset.order = this.count + "";
|
|
835
|
-
document.head.appendChild(link);
|
|
836
|
-
this.count++;
|
|
905
|
+
}
|
|
906
|
+
handler() {
|
|
907
|
+
if (!this.waitinglinks.length) {
|
|
908
|
+
return;
|
|
837
909
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
910
|
+
let i = this.loadingLinks.size;
|
|
911
|
+
while (i < _Preload.maxLinks) {
|
|
912
|
+
const index = this.waitinglinks.shift();
|
|
913
|
+
if (index !== void 0) {
|
|
914
|
+
this.createLink(index);
|
|
915
|
+
}
|
|
916
|
+
i++;
|
|
844
917
|
}
|
|
845
918
|
}
|
|
919
|
+
async requestAsyncCallBack(callBack, timeout) {
|
|
920
|
+
await new Promise(function(resolve) {
|
|
921
|
+
if (window.requestIdleCallback) {
|
|
922
|
+
requestIdleCallback(() => {
|
|
923
|
+
resolve(1);
|
|
924
|
+
}, { timeout });
|
|
925
|
+
} else {
|
|
926
|
+
setTimeout(() => {
|
|
927
|
+
resolve(2);
|
|
928
|
+
}, timeout);
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
callBack();
|
|
932
|
+
}
|
|
933
|
+
destroyLink(index, link) {
|
|
934
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
935
|
+
this.loadingLinks.delete(index);
|
|
936
|
+
}
|
|
846
937
|
dispose() {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
this.
|
|
938
|
+
for (const [index, link] of this.loadingLinks) {
|
|
939
|
+
this.destroyLink(index, link);
|
|
940
|
+
}
|
|
941
|
+
this.preloadMap.clear();
|
|
942
|
+
this.waitingLoadSet.clear();
|
|
943
|
+
this.waitinglinks.length = 0;
|
|
851
944
|
}
|
|
852
945
|
};
|
|
946
|
+
_Preload.maxLinks = 5;
|
|
947
|
+
var Preload = _Preload;
|
|
853
948
|
|
|
854
949
|
// src/presentation.ts
|
|
855
950
|
var Presentation = class {
|
|
@@ -860,6 +955,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
860
955
|
this.showPreview = false;
|
|
861
956
|
this.pageIndex = 0;
|
|
862
957
|
this.previewLazyload = null;
|
|
958
|
+
this.timer = null;
|
|
863
959
|
var _a;
|
|
864
960
|
this.pages = config.pages;
|
|
865
961
|
this.preload = new Preload(this.pages);
|
|
@@ -1062,15 +1158,22 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1062
1158
|
return this.pages[this.pageIndex];
|
|
1063
1159
|
}
|
|
1064
1160
|
updateImage() {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
this.image.src = "";
|
|
1068
|
-
return;
|
|
1161
|
+
if (this.timer) {
|
|
1162
|
+
clearTimeout(this.timer);
|
|
1069
1163
|
}
|
|
1070
|
-
this.
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1164
|
+
this.timer = setTimeout(() => {
|
|
1165
|
+
this.timer = null;
|
|
1166
|
+
this.preload.touch(this.pageIndex).then(() => {
|
|
1167
|
+
const page = this.page();
|
|
1168
|
+
if (!page) {
|
|
1169
|
+
this.image.src = "";
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
this.image.width = page.width;
|
|
1173
|
+
this.image.height = page.height;
|
|
1174
|
+
this.image.src = page.src;
|
|
1175
|
+
});
|
|
1176
|
+
}, 200);
|
|
1074
1177
|
}
|
|
1075
1178
|
/** Returns a modified URL that points to the thumbnail image. */
|
|
1076
1179
|
thumbnail(src) {
|
|
@@ -1252,7 +1355,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1252
1355
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
1253
1356
|
const box = context.getBox();
|
|
1254
1357
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, page$$, options.thumbnail));
|
|
1255
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.
|
|
1358
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.4-beta.0";
|
|
1256
1359
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
1257
1360
|
app.log = log;
|
|
1258
1361
|
context.mountView(app.whiteboardDOM);
|
|
@@ -1348,13 +1451,20 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1348
1451
|
stage.drawImage(img, 0, 0);
|
|
1349
1452
|
wb.clearRect(0, 0, pdfWidth, pdfHeight);
|
|
1350
1453
|
if (scenes.some((scene) => scene.name == String(index + 1))) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
wb_canvas.height,
|
|
1356
|
-
|
|
1357
|
-
|
|
1454
|
+
const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
|
|
1455
|
+
const sPath = `${scenePath}/${index + 1}`;
|
|
1456
|
+
const windowManger = context.manager.windowManger;
|
|
1457
|
+
if (windowManger._appliancePlugin) {
|
|
1458
|
+
await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
|
|
1459
|
+
} else {
|
|
1460
|
+
view.screenshotToCanvas(
|
|
1461
|
+
wb,
|
|
1462
|
+
sPath,
|
|
1463
|
+
wb_canvas.width,
|
|
1464
|
+
wb_canvas.height,
|
|
1465
|
+
camera
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1358
1468
|
try {
|
|
1359
1469
|
const wb_url = wb_canvas.toDataURL("image/png");
|
|
1360
1470
|
const wb_img = document.createElement("img");
|
|
@@ -1444,7 +1554,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1444
1554
|
};
|
|
1445
1555
|
|
|
1446
1556
|
// src/index.ts
|
|
1447
|
-
var version = "0.1.
|
|
1557
|
+
var version = "0.1.4-beta.0";
|
|
1448
1558
|
|
|
1449
1559
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
1450
1560
|
exports.Presentation = Presentation;
|
package/dist/index.js
CHANGED
|
@@ -791,66 +791,161 @@ function arrowRightSVG(namespace) {
|
|
|
791
791
|
}
|
|
792
792
|
|
|
793
793
|
// src/preload.ts
|
|
794
|
-
var
|
|
794
|
+
var _Preload = class _Preload {
|
|
795
795
|
constructor(pages) {
|
|
796
796
|
this.pages = pages;
|
|
797
|
-
this.
|
|
798
|
-
this.
|
|
799
|
-
this.
|
|
800
|
-
this.
|
|
801
|
-
this.
|
|
797
|
+
this.loadingLinks = /* @__PURE__ */ new Map();
|
|
798
|
+
this.preloadMap = /* @__PURE__ */ new Map();
|
|
799
|
+
this.waitingLoadSet = /* @__PURE__ */ new Set();
|
|
800
|
+
this.waitinglinks = [];
|
|
801
|
+
this.touchIndex = 0;
|
|
802
|
+
this.preloadSize = 0;
|
|
803
|
+
this.preloadMap = new Map(pages.map((e, index) => [index, {
|
|
804
|
+
src: e.src,
|
|
805
|
+
state: 0 /* unloaded */
|
|
806
|
+
}]));
|
|
807
|
+
this.waitingLoadSet = new Set(pages.map((e, index) => index));
|
|
808
|
+
this.preloadSize = this.preloadMap.size;
|
|
802
809
|
this.touch(0);
|
|
803
810
|
}
|
|
804
|
-
|
|
805
|
-
|
|
811
|
+
async touch(index) {
|
|
812
|
+
this.touchIndex = index;
|
|
813
|
+
const value = this.preloadMap.get(index);
|
|
814
|
+
let state = 0 /* unloaded */;
|
|
815
|
+
if (value) {
|
|
816
|
+
state = value.state;
|
|
817
|
+
if (value.state === 0 /* unloaded */) {
|
|
818
|
+
if (this.loadingLinks.size) {
|
|
819
|
+
for (const [i, link] of this.loadingLinks) {
|
|
820
|
+
this.destroyLink(i, link);
|
|
821
|
+
this.waitingLoadSet.add(i);
|
|
822
|
+
const v = this.preloadMap.get(i);
|
|
823
|
+
if (v) {
|
|
824
|
+
v.state = 0 /* unloaded */;
|
|
825
|
+
this.preloadMap.set(i, v);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
for (const i of this.waitinglinks) {
|
|
829
|
+
this.waitingLoadSet.add(i);
|
|
830
|
+
}
|
|
831
|
+
this.waitinglinks.length = 0;
|
|
832
|
+
}
|
|
833
|
+
if (this.waitinglinks.includes(index)) {
|
|
834
|
+
this.waitinglinks.splice(this.waitinglinks.indexOf(index), 1);
|
|
835
|
+
}
|
|
836
|
+
state = await new Promise((resolve) => {
|
|
837
|
+
this.waitingLoadSet.delete(index);
|
|
838
|
+
this.createLink(index, resolve);
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (this.waitingLoadSet.size) {
|
|
843
|
+
this.requestAsyncCallBack(() => {
|
|
844
|
+
this.autoTouch();
|
|
845
|
+
}, 1e3);
|
|
846
|
+
}
|
|
847
|
+
return state;
|
|
806
848
|
}
|
|
807
|
-
|
|
808
|
-
|
|
849
|
+
autoTouch() {
|
|
850
|
+
this.handler();
|
|
851
|
+
if (this.waitingLoadSet.size === 0) {
|
|
809
852
|
return;
|
|
810
|
-
|
|
811
|
-
|
|
853
|
+
}
|
|
854
|
+
let nextTouchDelay = 1e3;
|
|
855
|
+
this.touchIndex = (this.touchIndex + 1) % this.preloadSize;
|
|
856
|
+
const value = this.preloadMap.get(this.touchIndex);
|
|
857
|
+
if (value) {
|
|
858
|
+
switch (value.state) {
|
|
859
|
+
case 0 /* unloaded */:
|
|
860
|
+
case 3 /* error */:
|
|
861
|
+
if (!this.waitinglinks.includes(this.touchIndex)) {
|
|
862
|
+
this.waitinglinks.push(this.touchIndex);
|
|
863
|
+
this.waitingLoadSet.delete(this.touchIndex);
|
|
864
|
+
}
|
|
865
|
+
nextTouchDelay = 0;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
this.requestAsyncCallBack(() => {
|
|
870
|
+
this.autoTouch();
|
|
871
|
+
}, nextTouchDelay);
|
|
812
872
|
}
|
|
813
|
-
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
this.head--;
|
|
817
|
-
if (!links[this.head]) {
|
|
873
|
+
createLink(index, resolve) {
|
|
874
|
+
const value = this.preloadMap.get(index);
|
|
875
|
+
if (value) {
|
|
818
876
|
const link = document.createElement("link");
|
|
819
|
-
links[this.head] = link;
|
|
820
877
|
link.rel = "preload";
|
|
821
878
|
link.as = "image";
|
|
822
|
-
link.href =
|
|
823
|
-
link.dataset.order =
|
|
879
|
+
link.href = value.src;
|
|
880
|
+
link.dataset.order = index + "";
|
|
824
881
|
document.head.appendChild(link);
|
|
825
|
-
|
|
882
|
+
link.onload = () => {
|
|
883
|
+
value.state = 2 /* loaded */;
|
|
884
|
+
this.preloadMap.set(index, value);
|
|
885
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
886
|
+
this.loadingLinks.delete(index);
|
|
887
|
+
resolve && resolve(2 /* loaded */);
|
|
888
|
+
this.autoTouch();
|
|
889
|
+
};
|
|
890
|
+
link.onerror = () => {
|
|
891
|
+
value.state = 3 /* error */;
|
|
892
|
+
this.preloadMap.set(index, value);
|
|
893
|
+
if (!this.waitinglinks.includes(index)) {
|
|
894
|
+
this.waitinglinks.push(index);
|
|
895
|
+
this.waitingLoadSet.delete(this.touchIndex);
|
|
896
|
+
}
|
|
897
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
898
|
+
this.loadingLinks.delete(index);
|
|
899
|
+
resolve && resolve(3 /* error */);
|
|
900
|
+
this.autoTouch();
|
|
901
|
+
};
|
|
902
|
+
this.loadingLinks.set(index, link);
|
|
903
|
+
value.state = 1 /* loading */;
|
|
904
|
+
this.preloadMap.set(index, value);
|
|
826
905
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
if (this.
|
|
830
|
-
|
|
831
|
-
links[this.tail] = link;
|
|
832
|
-
link.rel = "preload";
|
|
833
|
-
link.as = "image";
|
|
834
|
-
link.href = this.pages[this.tail].src;
|
|
835
|
-
link.dataset.order = this.count + "";
|
|
836
|
-
document.head.appendChild(link);
|
|
837
|
-
this.count++;
|
|
906
|
+
}
|
|
907
|
+
handler() {
|
|
908
|
+
if (!this.waitinglinks.length) {
|
|
909
|
+
return;
|
|
838
910
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
911
|
+
let i = this.loadingLinks.size;
|
|
912
|
+
while (i < _Preload.maxLinks) {
|
|
913
|
+
const index = this.waitinglinks.shift();
|
|
914
|
+
if (index !== void 0) {
|
|
915
|
+
this.createLink(index);
|
|
916
|
+
}
|
|
917
|
+
i++;
|
|
845
918
|
}
|
|
846
919
|
}
|
|
920
|
+
async requestAsyncCallBack(callBack, timeout) {
|
|
921
|
+
await new Promise(function(resolve) {
|
|
922
|
+
if (window.requestIdleCallback) {
|
|
923
|
+
requestIdleCallback(() => {
|
|
924
|
+
resolve(1);
|
|
925
|
+
}, { timeout });
|
|
926
|
+
} else {
|
|
927
|
+
setTimeout(() => {
|
|
928
|
+
resolve(2);
|
|
929
|
+
}, timeout);
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
callBack();
|
|
933
|
+
}
|
|
934
|
+
destroyLink(index, link) {
|
|
935
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
936
|
+
this.loadingLinks.delete(index);
|
|
937
|
+
}
|
|
847
938
|
dispose() {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
this.
|
|
939
|
+
for (const [index, link] of this.loadingLinks) {
|
|
940
|
+
this.destroyLink(index, link);
|
|
941
|
+
}
|
|
942
|
+
this.preloadMap.clear();
|
|
943
|
+
this.waitingLoadSet.clear();
|
|
944
|
+
this.waitinglinks.length = 0;
|
|
852
945
|
}
|
|
853
946
|
};
|
|
947
|
+
_Preload.maxLinks = 5;
|
|
948
|
+
var Preload = _Preload;
|
|
854
949
|
|
|
855
950
|
// src/presentation.ts
|
|
856
951
|
var Presentation = class {
|
|
@@ -861,6 +956,7 @@ var Presentation = class {
|
|
|
861
956
|
this.showPreview = false;
|
|
862
957
|
this.pageIndex = 0;
|
|
863
958
|
this.previewLazyload = null;
|
|
959
|
+
this.timer = null;
|
|
864
960
|
var _a;
|
|
865
961
|
this.pages = config.pages;
|
|
866
962
|
this.preload = new Preload(this.pages);
|
|
@@ -1063,15 +1159,22 @@ var Presentation = class {
|
|
|
1063
1159
|
return this.pages[this.pageIndex];
|
|
1064
1160
|
}
|
|
1065
1161
|
updateImage() {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
this.image.src = "";
|
|
1069
|
-
return;
|
|
1162
|
+
if (this.timer) {
|
|
1163
|
+
clearTimeout(this.timer);
|
|
1070
1164
|
}
|
|
1071
|
-
this.
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1165
|
+
this.timer = setTimeout(() => {
|
|
1166
|
+
this.timer = null;
|
|
1167
|
+
this.preload.touch(this.pageIndex).then(() => {
|
|
1168
|
+
const page = this.page();
|
|
1169
|
+
if (!page) {
|
|
1170
|
+
this.image.src = "";
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
this.image.width = page.width;
|
|
1174
|
+
this.image.height = page.height;
|
|
1175
|
+
this.image.src = page.src;
|
|
1176
|
+
});
|
|
1177
|
+
}, 200);
|
|
1075
1178
|
}
|
|
1076
1179
|
/** Returns a modified URL that points to the thumbnail image. */
|
|
1077
1180
|
thumbnail(src) {
|
|
@@ -1253,7 +1356,7 @@ var NetlessAppPresentation = {
|
|
|
1253
1356
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
1254
1357
|
const box = context.getBox();
|
|
1255
1358
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, page$$, options.thumbnail));
|
|
1256
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.
|
|
1359
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.4-beta.0";
|
|
1257
1360
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
1258
1361
|
app.log = log;
|
|
1259
1362
|
context.mountView(app.whiteboardDOM);
|
|
@@ -1349,13 +1452,20 @@ var NetlessAppPresentation = {
|
|
|
1349
1452
|
stage.drawImage(img, 0, 0);
|
|
1350
1453
|
wb.clearRect(0, 0, pdfWidth, pdfHeight);
|
|
1351
1454
|
if (scenes.some((scene) => scene.name == String(index + 1))) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
wb_canvas.height,
|
|
1357
|
-
|
|
1358
|
-
|
|
1455
|
+
const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
|
|
1456
|
+
const sPath = `${scenePath}/${index + 1}`;
|
|
1457
|
+
const windowManger = context.manager.windowManger;
|
|
1458
|
+
if (windowManger._appliancePlugin) {
|
|
1459
|
+
await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
|
|
1460
|
+
} else {
|
|
1461
|
+
view.screenshotToCanvas(
|
|
1462
|
+
wb,
|
|
1463
|
+
sPath,
|
|
1464
|
+
wb_canvas.width,
|
|
1465
|
+
wb_canvas.height,
|
|
1466
|
+
camera
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1359
1469
|
try {
|
|
1360
1470
|
const wb_url = wb_canvas.toDataURL("image/png");
|
|
1361
1471
|
const wb_img = document.createElement("img");
|
|
@@ -1445,7 +1555,7 @@ var install = (register, options = {}) => {
|
|
|
1445
1555
|
};
|
|
1446
1556
|
|
|
1447
1557
|
// src/index.ts
|
|
1448
|
-
var version = "0.1.
|
|
1558
|
+
var version = "0.1.4-beta.0";
|
|
1449
1559
|
|
|
1450
1560
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
1451
1561
|
exports.Presentation = Presentation;
|