@netless/app-presentation 0.1.13-beta.2 → 0.1.13-beta.3
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/README-zh.md +18 -0
- package/README.md +22 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.global.js +81 -48
- package/dist/index.js +81 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/app-presentation.ts +9 -41
- package/src/preload.ts +23 -11
- package/src/runtime-lifecycle.ts +13 -6
- package/src/setup-ready.ts +39 -0
package/README-zh.md
CHANGED
|
@@ -93,6 +93,24 @@ scenePpt.height = ppt.height * ratio
|
|
|
93
93
|
|
|
94
94
|
### 应用选项
|
|
95
95
|
|
|
96
|
+
#### Lazy 缓存生命周期与图片就绪
|
|
97
|
+
|
|
98
|
+
Lazy setup/cache 需要带有 `teardown` 和 focus 事件生命周期的 WindowManager
|
|
99
|
+
`1.0.23-beta.1` 或更高版本;当前集成验证版本为 `1.0.23-beta.3`。
|
|
100
|
+
未启用 lazy 的旧宿主仍可使用普通查看功能。
|
|
101
|
+
|
|
102
|
+
`setupReadyTimeout` 限制当前背景图的等待时间,默认 5000ms。图片加载成功或请求失败
|
|
103
|
+
均结束等待;尚未设置图片地址的元素仍等待 SDK 赋值。失败/超时会记录警告并允许 setup
|
|
104
|
+
完成,不会取消 SDK 自己的图片加载或重试。
|
|
105
|
+
|
|
106
|
+
在 lazy 最大化/最小化模式下,失焦 App 优先使用可用的 `ppt.previewURL` 缩略图;
|
|
107
|
+
没有可用缩略图时隐藏背景并替换为静态像素,重新聚焦恢复原图。`thumbnail(src)` 自定义
|
|
108
|
+
侧边预览图,不参与此背景降级策略。设置 `disableBlurThumbnailDegradation: true` 可关闭降级。
|
|
109
|
+
该优化减少常驻图片资源,不保证节省下载流量:宿主可能在首次 setup 等待完成后才补发焦点状态。
|
|
110
|
+
|
|
111
|
+
预加载为尽力而为:失败时移除对应 link,不自动循环重试;显式重新访问失败页时可再次尝试
|
|
112
|
+
预加载。SDK 的可见图片加载不受此策略影响。
|
|
113
|
+
|
|
96
114
|
#### `disableDeviceCameraTransform`
|
|
97
115
|
|
|
98
116
|
禁止鼠标滚轮、触摸手势等本地设备输入改变相机,但不改变程序化相机操作使用的
|
package/README.md
CHANGED
|
@@ -99,6 +99,28 @@ handles app whose kind is `DocsViewer` or `Slide`.
|
|
|
99
99
|
|
|
100
100
|
### App Options
|
|
101
101
|
|
|
102
|
+
#### Lazy cache lifecycle and image readiness
|
|
103
|
+
|
|
104
|
+
Lazy setup/cache requires WindowManager `1.0.23-beta.1` or later with the
|
|
105
|
+
`teardown` and focus-event lifecycle; integration is currently verified with
|
|
106
|
+
`1.0.23-beta.3`. Older hosts without lazy mode can still use the normal viewer.
|
|
107
|
+
|
|
108
|
+
`setupReadyTimeout` bounds the current background-image wait (default 5000 ms).
|
|
109
|
+
A loaded image or a failed image request releases the wait; an image element
|
|
110
|
+
without a source still waits for the SDK to assign it. Failure/timeout logs a
|
|
111
|
+
warning and lets setup finish; it does not cancel SDK image loading or retrying.
|
|
112
|
+
|
|
113
|
+
In lazy maximized/minimized mode, blurred apps use `ppt.previewURL` when it is a
|
|
114
|
+
usable thumbnail. Otherwise their background is hidden behind a static pixel;
|
|
115
|
+
focus restores the original image. `thumbnail(src)` customizes sidebar previews,
|
|
116
|
+
not this background policy. Set `disableBlurThumbnailDegradation: true` to opt out.
|
|
117
|
+
This reduces retained image resources; it does not guarantee reduced downloads,
|
|
118
|
+
since the host can synchronize focus only after the initial setup wait.
|
|
119
|
+
|
|
120
|
+
Image preloading is best effort: failed preload links are removed without an
|
|
121
|
+
automatic retry loop. Explicitly revisiting the failed page can retry preloading;
|
|
122
|
+
the SDK's visible image loading remains independent.
|
|
123
|
+
|
|
102
124
|
#### `disableDeviceCameraTransform`
|
|
103
125
|
|
|
104
126
|
Disable camera transforms initiated by local device input, such as mouse-wheel and touch gestures,
|
package/dist/index.d.ts
CHANGED
|
@@ -253,11 +253,13 @@ declare class Preload implements IDisposable {
|
|
|
253
253
|
touchIndex: number;
|
|
254
254
|
preloadSize: number;
|
|
255
255
|
paused: boolean;
|
|
256
|
+
private disposed;
|
|
256
257
|
constructor(pages: PresentationPage[]);
|
|
257
258
|
pause(): void;
|
|
258
259
|
resume(index?: number): void;
|
|
259
260
|
touch(index: number, force?: boolean): void;
|
|
260
261
|
private createLink;
|
|
262
|
+
private removeLink;
|
|
261
263
|
private destroySomeLink;
|
|
262
264
|
private requestAsyncCallBack;
|
|
263
265
|
dispose(): void;
|
|
@@ -539,7 +541,8 @@ interface PresentationController {
|
|
|
539
541
|
* hidden and replaced with a static pixel after TeleBox commits the blur.
|
|
540
542
|
*
|
|
541
543
|
* While degraded, every load of a background `<img>` is re-degraded
|
|
542
|
-
* immediately via a capture-phase `load` listener on the
|
|
544
|
+
* immediately via a capture-phase `load` listener on the document, filtered
|
|
545
|
+
* to the current view container
|
|
543
546
|
* (`load` does not bubble but capture works). This covers remote page turns,
|
|
544
547
|
* SDK React re-renders and the SDK's own background-image onError retries —
|
|
545
548
|
* any path that (re)renders the full-size image while the app stays blurred.
|
package/dist/index.global.js
CHANGED
|
@@ -1153,6 +1153,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1153
1153
|
// 暂停后不再创建预加载链接(app 失焦降级时调用);已插入的 link 会被移除,
|
|
1154
1154
|
// 挂起的 idle 回调重新进入 touch() 时也会被跳过
|
|
1155
1155
|
this.paused = false;
|
|
1156
|
+
this.disposed = false;
|
|
1156
1157
|
this.preloadMap = new Map(pages.map((e, index) => [index, {
|
|
1157
1158
|
src: e.src,
|
|
1158
1159
|
state: 0 /* unloaded */
|
|
@@ -1167,13 +1168,13 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1167
1168
|
this.destroySomeLink();
|
|
1168
1169
|
}
|
|
1169
1170
|
resume(index) {
|
|
1170
|
-
if (!this.paused)
|
|
1171
|
+
if (!this.paused || this.disposed)
|
|
1171
1172
|
return;
|
|
1172
1173
|
this.paused = false;
|
|
1173
1174
|
this.touch(index != null ? index : this.touchIndex, true);
|
|
1174
1175
|
}
|
|
1175
1176
|
touch(index, force = false) {
|
|
1176
|
-
if (this.paused)
|
|
1177
|
+
if (this.paused || this.disposed)
|
|
1177
1178
|
return;
|
|
1178
1179
|
if (index >= this.preloadSize) {
|
|
1179
1180
|
this.touchIndex = 0;
|
|
@@ -1181,11 +1182,11 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1181
1182
|
this.touchIndex = index;
|
|
1182
1183
|
}
|
|
1183
1184
|
const value = this.preloadMap.get(this.touchIndex);
|
|
1184
|
-
if (value && value.state === 0 /* unloaded */) {
|
|
1185
|
+
if (value && (value.state === 0 /* unloaded */ || force && value.state === 2 /* error */)) {
|
|
1185
1186
|
this.createLink(this.touchIndex, force);
|
|
1186
1187
|
}
|
|
1187
1188
|
if (this.loadingLinks.size < _Preload.maxLinks) {
|
|
1188
|
-
const willLoad = [...this.preloadMap.entries()].find(([i, e]) => i > this.touchIndex && e.state
|
|
1189
|
+
const willLoad = [...this.preloadMap.entries()].find(([i, e]) => i > this.touchIndex && e.state === 0 /* unloaded */);
|
|
1189
1190
|
if (willLoad) {
|
|
1190
1191
|
this.requestAsyncCallBack(() => {
|
|
1191
1192
|
this.touch(willLoad[0], false);
|
|
@@ -1218,21 +1219,27 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1218
1219
|
linkDom.as = "image";
|
|
1219
1220
|
linkDom.href = value.src;
|
|
1220
1221
|
linkDom.dataset.order = index + "";
|
|
1221
|
-
document.head.appendChild(linkDom);
|
|
1222
1222
|
linkDom.onload = () => {
|
|
1223
|
+
var _a;
|
|
1224
|
+
if (((_a = this.loadingLinks.get(index)) == null ? void 0 : _a.link) !== linkDom)
|
|
1225
|
+
return;
|
|
1223
1226
|
const value2 = this.preloadMap.get(index);
|
|
1224
1227
|
if (value2) {
|
|
1225
1228
|
value2.state = 1 /* loaded */;
|
|
1226
1229
|
this.preloadMap.set(index, value2);
|
|
1227
|
-
|
|
1228
|
-
this.loadingLinks.delete(index);
|
|
1230
|
+
this.removeLink(index, linkDom);
|
|
1229
1231
|
this.touch(this.touchIndex + 1, false);
|
|
1230
1232
|
}
|
|
1231
1233
|
};
|
|
1232
1234
|
linkDom.onerror = () => {
|
|
1235
|
+
var _a;
|
|
1236
|
+
if (((_a = this.loadingLinks.get(index)) == null ? void 0 : _a.link) !== linkDom)
|
|
1237
|
+
return;
|
|
1233
1238
|
const value2 = this.preloadMap.get(index);
|
|
1234
|
-
if (value2
|
|
1235
|
-
|
|
1239
|
+
if (value2) {
|
|
1240
|
+
value2.state = 2 /* error */;
|
|
1241
|
+
this.removeLink(index, linkDom);
|
|
1242
|
+
this.touch(this.touchIndex + 1, false);
|
|
1236
1243
|
}
|
|
1237
1244
|
};
|
|
1238
1245
|
this.loadingLinks.set(index, {
|
|
@@ -1241,17 +1248,23 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1241
1248
|
});
|
|
1242
1249
|
value.state = 0 /* unloaded */;
|
|
1243
1250
|
this.preloadMap.set(index, value);
|
|
1251
|
+
document.head.appendChild(linkDom);
|
|
1244
1252
|
return 0 /* unloaded */;
|
|
1245
1253
|
}
|
|
1246
1254
|
return 2 /* error */;
|
|
1247
1255
|
}
|
|
1256
|
+
removeLink(index, link) {
|
|
1257
|
+
link.onload = null;
|
|
1258
|
+
link.onerror = null;
|
|
1259
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
1260
|
+
this.loadingLinks.delete(index);
|
|
1261
|
+
}
|
|
1248
1262
|
destroySomeLink(excludeIndex) {
|
|
1249
1263
|
for (const [index, { link }] of this.loadingLinks) {
|
|
1250
1264
|
if (excludeIndex !== void 0 && index === excludeIndex) {
|
|
1251
1265
|
continue;
|
|
1252
1266
|
}
|
|
1253
|
-
|
|
1254
|
-
this.loadingLinks.delete(index);
|
|
1267
|
+
this.removeLink(index, link);
|
|
1255
1268
|
}
|
|
1256
1269
|
}
|
|
1257
1270
|
async requestAsyncCallBack(callBack, timeout) {
|
|
@@ -1269,6 +1282,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1269
1282
|
callBack();
|
|
1270
1283
|
}
|
|
1271
1284
|
dispose() {
|
|
1285
|
+
this.disposed = true;
|
|
1272
1286
|
this.destroySomeLink();
|
|
1273
1287
|
this.preloadMap.clear();
|
|
1274
1288
|
}
|
|
@@ -1981,19 +1995,62 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1981
1995
|
var createPresentationRuntimeTeardown = (box, dispose2) => {
|
|
1982
1996
|
let tornDown = false;
|
|
1983
1997
|
return () => {
|
|
1998
|
+
var _a, _b, _c;
|
|
1984
1999
|
if (tornDown)
|
|
1985
2000
|
return;
|
|
1986
2001
|
tornDown = true;
|
|
1987
2002
|
try {
|
|
1988
2003
|
dispose2();
|
|
1989
2004
|
} finally {
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2005
|
+
try {
|
|
2006
|
+
(_a = box.unmountContent) == null ? void 0 : _a.call(box);
|
|
2007
|
+
} finally {
|
|
2008
|
+
try {
|
|
2009
|
+
(_b = box.unmountFooter) == null ? void 0 : _b.call(box);
|
|
2010
|
+
} finally {
|
|
2011
|
+
(_c = box.unmountStyles) == null ? void 0 : _c.call(box);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
1993
2014
|
}
|
|
1994
2015
|
};
|
|
1995
2016
|
};
|
|
1996
2017
|
|
|
2018
|
+
// src/setup-ready.ts
|
|
2019
|
+
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed) => {
|
|
2020
|
+
return new Promise((resolve) => {
|
|
2021
|
+
let settled = false;
|
|
2022
|
+
let pollTimer;
|
|
2023
|
+
const settle = (result) => {
|
|
2024
|
+
if (settled)
|
|
2025
|
+
return;
|
|
2026
|
+
settled = true;
|
|
2027
|
+
window.clearTimeout(timeoutTimer);
|
|
2028
|
+
if (pollTimer !== void 0)
|
|
2029
|
+
window.clearInterval(pollTimer);
|
|
2030
|
+
resolve(result);
|
|
2031
|
+
};
|
|
2032
|
+
const timeoutTimer = window.setTimeout(() => settle("timeout"), timeoutMs);
|
|
2033
|
+
const check = () => {
|
|
2034
|
+
var _a, _b;
|
|
2035
|
+
if (isDisposed()) {
|
|
2036
|
+
settle("disposed");
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
const img = getImage();
|
|
2040
|
+
if (img == null ? void 0 : img.complete) {
|
|
2041
|
+
if (img.naturalWidth > 0) {
|
|
2042
|
+
settle("loaded");
|
|
2043
|
+
} else if (img.currentSrc || ((_a = img.getAttribute("src")) == null ? void 0 : _a.trim()) || ((_b = img.getAttribute("srcset")) == null ? void 0 : _b.trim())) {
|
|
2044
|
+
settle("error");
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
check();
|
|
2049
|
+
if (!settled)
|
|
2050
|
+
pollTimer = window.setInterval(check, 100);
|
|
2051
|
+
});
|
|
2052
|
+
};
|
|
2053
|
+
|
|
1997
2054
|
// src/app-presentation.ts
|
|
1998
2055
|
var import_debounce2 = __toESM(require_debounce());
|
|
1999
2056
|
var emptySceneName = "$$empty$$";
|
|
@@ -2022,36 +2079,6 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2022
2079
|
return boxState !== void 0 && boxState !== "normal";
|
|
2023
2080
|
};
|
|
2024
2081
|
var DEFAULT_SETUP_READY_TIMEOUT = 5e3;
|
|
2025
|
-
var waitForCurrentPageImage = (view, timeoutMs, isDisposed) => {
|
|
2026
|
-
return new Promise((resolve) => {
|
|
2027
|
-
let settled = false;
|
|
2028
|
-
let pollTimer;
|
|
2029
|
-
const settle = (loaded) => {
|
|
2030
|
-
if (settled)
|
|
2031
|
-
return;
|
|
2032
|
-
settled = true;
|
|
2033
|
-
window.clearTimeout(timeoutTimer);
|
|
2034
|
-
if (pollTimer !== void 0)
|
|
2035
|
-
window.clearInterval(pollTimer);
|
|
2036
|
-
resolve(loaded);
|
|
2037
|
-
};
|
|
2038
|
-
const timeoutTimer = window.setTimeout(() => settle(false), timeoutMs);
|
|
2039
|
-
const check = () => {
|
|
2040
|
-
if (isDisposed()) {
|
|
2041
|
-
settle(false);
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
const img = findBackgroundImage(view);
|
|
2045
|
-
if (img && img.complete && img.naturalWidth > 0) {
|
|
2046
|
-
settle(true);
|
|
2047
|
-
}
|
|
2048
|
-
};
|
|
2049
|
-
check();
|
|
2050
|
-
if (!settled) {
|
|
2051
|
-
pollTimer = window.setInterval(check, 100);
|
|
2052
|
-
}
|
|
2053
|
-
});
|
|
2054
|
-
};
|
|
2055
2082
|
var resolveImageUrl = (url) => {
|
|
2056
2083
|
try {
|
|
2057
2084
|
return new URL(url, window.location.href).href;
|
|
@@ -2629,7 +2656,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2629
2656
|
options.useClipView
|
|
2630
2657
|
)
|
|
2631
2658
|
);
|
|
2632
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.
|
|
2659
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.3";
|
|
2633
2660
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
2634
2661
|
app.log = log;
|
|
2635
2662
|
app.warn = warn;
|
|
@@ -3098,9 +3125,15 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
3098
3125
|
);
|
|
3099
3126
|
const setupReadyTimeout = (_d = options.setupReadyTimeout) != null ? _d : DEFAULT_SETUP_READY_TIMEOUT;
|
|
3100
3127
|
return prepareScenesPromise.then(async () => {
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3128
|
+
const result = await waitForCurrentPageImage(
|
|
3129
|
+
() => findBackgroundImage(view),
|
|
3130
|
+
setupReadyTimeout,
|
|
3131
|
+
() => disposed
|
|
3132
|
+
);
|
|
3133
|
+
if (result === "timeout" && !disposed) {
|
|
3103
3134
|
warn(`[Presentation] setup ready wait timed out after ${setupReadyTimeout}ms`);
|
|
3135
|
+
} else if (result === "error" && !disposed) {
|
|
3136
|
+
warn("[Presentation] setup page image failed to load; continuing setup");
|
|
3104
3137
|
}
|
|
3105
3138
|
return controller;
|
|
3106
3139
|
});
|
|
@@ -3189,7 +3222,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
3189
3222
|
};
|
|
3190
3223
|
|
|
3191
3224
|
// src/index.ts
|
|
3192
|
-
var version = "0.1.13-beta.
|
|
3225
|
+
var version = "0.1.13-beta.3";
|
|
3193
3226
|
|
|
3194
3227
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
3195
3228
|
exports.Presentation = Presentation;
|
package/dist/index.js
CHANGED
|
@@ -1154,6 +1154,7 @@ var _Preload = class _Preload {
|
|
|
1154
1154
|
// 暂停后不再创建预加载链接(app 失焦降级时调用);已插入的 link 会被移除,
|
|
1155
1155
|
// 挂起的 idle 回调重新进入 touch() 时也会被跳过
|
|
1156
1156
|
this.paused = false;
|
|
1157
|
+
this.disposed = false;
|
|
1157
1158
|
this.preloadMap = new Map(pages.map((e, index) => [index, {
|
|
1158
1159
|
src: e.src,
|
|
1159
1160
|
state: 0 /* unloaded */
|
|
@@ -1168,13 +1169,13 @@ var _Preload = class _Preload {
|
|
|
1168
1169
|
this.destroySomeLink();
|
|
1169
1170
|
}
|
|
1170
1171
|
resume(index) {
|
|
1171
|
-
if (!this.paused)
|
|
1172
|
+
if (!this.paused || this.disposed)
|
|
1172
1173
|
return;
|
|
1173
1174
|
this.paused = false;
|
|
1174
1175
|
this.touch(index != null ? index : this.touchIndex, true);
|
|
1175
1176
|
}
|
|
1176
1177
|
touch(index, force = false) {
|
|
1177
|
-
if (this.paused)
|
|
1178
|
+
if (this.paused || this.disposed)
|
|
1178
1179
|
return;
|
|
1179
1180
|
if (index >= this.preloadSize) {
|
|
1180
1181
|
this.touchIndex = 0;
|
|
@@ -1182,11 +1183,11 @@ var _Preload = class _Preload {
|
|
|
1182
1183
|
this.touchIndex = index;
|
|
1183
1184
|
}
|
|
1184
1185
|
const value = this.preloadMap.get(this.touchIndex);
|
|
1185
|
-
if (value && value.state === 0 /* unloaded */) {
|
|
1186
|
+
if (value && (value.state === 0 /* unloaded */ || force && value.state === 2 /* error */)) {
|
|
1186
1187
|
this.createLink(this.touchIndex, force);
|
|
1187
1188
|
}
|
|
1188
1189
|
if (this.loadingLinks.size < _Preload.maxLinks) {
|
|
1189
|
-
const willLoad = [...this.preloadMap.entries()].find(([i, e]) => i > this.touchIndex && e.state
|
|
1190
|
+
const willLoad = [...this.preloadMap.entries()].find(([i, e]) => i > this.touchIndex && e.state === 0 /* unloaded */);
|
|
1190
1191
|
if (willLoad) {
|
|
1191
1192
|
this.requestAsyncCallBack(() => {
|
|
1192
1193
|
this.touch(willLoad[0], false);
|
|
@@ -1219,21 +1220,27 @@ var _Preload = class _Preload {
|
|
|
1219
1220
|
linkDom.as = "image";
|
|
1220
1221
|
linkDom.href = value.src;
|
|
1221
1222
|
linkDom.dataset.order = index + "";
|
|
1222
|
-
document.head.appendChild(linkDom);
|
|
1223
1223
|
linkDom.onload = () => {
|
|
1224
|
+
var _a;
|
|
1225
|
+
if (((_a = this.loadingLinks.get(index)) == null ? void 0 : _a.link) !== linkDom)
|
|
1226
|
+
return;
|
|
1224
1227
|
const value2 = this.preloadMap.get(index);
|
|
1225
1228
|
if (value2) {
|
|
1226
1229
|
value2.state = 1 /* loaded */;
|
|
1227
1230
|
this.preloadMap.set(index, value2);
|
|
1228
|
-
|
|
1229
|
-
this.loadingLinks.delete(index);
|
|
1231
|
+
this.removeLink(index, linkDom);
|
|
1230
1232
|
this.touch(this.touchIndex + 1, false);
|
|
1231
1233
|
}
|
|
1232
1234
|
};
|
|
1233
1235
|
linkDom.onerror = () => {
|
|
1236
|
+
var _a;
|
|
1237
|
+
if (((_a = this.loadingLinks.get(index)) == null ? void 0 : _a.link) !== linkDom)
|
|
1238
|
+
return;
|
|
1234
1239
|
const value2 = this.preloadMap.get(index);
|
|
1235
|
-
if (value2
|
|
1236
|
-
|
|
1240
|
+
if (value2) {
|
|
1241
|
+
value2.state = 2 /* error */;
|
|
1242
|
+
this.removeLink(index, linkDom);
|
|
1243
|
+
this.touch(this.touchIndex + 1, false);
|
|
1237
1244
|
}
|
|
1238
1245
|
};
|
|
1239
1246
|
this.loadingLinks.set(index, {
|
|
@@ -1242,17 +1249,23 @@ var _Preload = class _Preload {
|
|
|
1242
1249
|
});
|
|
1243
1250
|
value.state = 0 /* unloaded */;
|
|
1244
1251
|
this.preloadMap.set(index, value);
|
|
1252
|
+
document.head.appendChild(linkDom);
|
|
1245
1253
|
return 0 /* unloaded */;
|
|
1246
1254
|
}
|
|
1247
1255
|
return 2 /* error */;
|
|
1248
1256
|
}
|
|
1257
|
+
removeLink(index, link) {
|
|
1258
|
+
link.onload = null;
|
|
1259
|
+
link.onerror = null;
|
|
1260
|
+
document.head.contains(link) && document.head.removeChild(link);
|
|
1261
|
+
this.loadingLinks.delete(index);
|
|
1262
|
+
}
|
|
1249
1263
|
destroySomeLink(excludeIndex) {
|
|
1250
1264
|
for (const [index, { link }] of this.loadingLinks) {
|
|
1251
1265
|
if (excludeIndex !== void 0 && index === excludeIndex) {
|
|
1252
1266
|
continue;
|
|
1253
1267
|
}
|
|
1254
|
-
|
|
1255
|
-
this.loadingLinks.delete(index);
|
|
1268
|
+
this.removeLink(index, link);
|
|
1256
1269
|
}
|
|
1257
1270
|
}
|
|
1258
1271
|
async requestAsyncCallBack(callBack, timeout) {
|
|
@@ -1270,6 +1283,7 @@ var _Preload = class _Preload {
|
|
|
1270
1283
|
callBack();
|
|
1271
1284
|
}
|
|
1272
1285
|
dispose() {
|
|
1286
|
+
this.disposed = true;
|
|
1273
1287
|
this.destroySomeLink();
|
|
1274
1288
|
this.preloadMap.clear();
|
|
1275
1289
|
}
|
|
@@ -1982,19 +1996,62 @@ function cameraToSharedViewport(camera, viewSize, referenceSize) {
|
|
|
1982
1996
|
var createPresentationRuntimeTeardown = (box, dispose2) => {
|
|
1983
1997
|
let tornDown = false;
|
|
1984
1998
|
return () => {
|
|
1999
|
+
var _a, _b, _c;
|
|
1985
2000
|
if (tornDown)
|
|
1986
2001
|
return;
|
|
1987
2002
|
tornDown = true;
|
|
1988
2003
|
try {
|
|
1989
2004
|
dispose2();
|
|
1990
2005
|
} finally {
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2006
|
+
try {
|
|
2007
|
+
(_a = box.unmountContent) == null ? void 0 : _a.call(box);
|
|
2008
|
+
} finally {
|
|
2009
|
+
try {
|
|
2010
|
+
(_b = box.unmountFooter) == null ? void 0 : _b.call(box);
|
|
2011
|
+
} finally {
|
|
2012
|
+
(_c = box.unmountStyles) == null ? void 0 : _c.call(box);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1994
2015
|
}
|
|
1995
2016
|
};
|
|
1996
2017
|
};
|
|
1997
2018
|
|
|
2019
|
+
// src/setup-ready.ts
|
|
2020
|
+
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed) => {
|
|
2021
|
+
return new Promise((resolve) => {
|
|
2022
|
+
let settled = false;
|
|
2023
|
+
let pollTimer;
|
|
2024
|
+
const settle = (result) => {
|
|
2025
|
+
if (settled)
|
|
2026
|
+
return;
|
|
2027
|
+
settled = true;
|
|
2028
|
+
window.clearTimeout(timeoutTimer);
|
|
2029
|
+
if (pollTimer !== void 0)
|
|
2030
|
+
window.clearInterval(pollTimer);
|
|
2031
|
+
resolve(result);
|
|
2032
|
+
};
|
|
2033
|
+
const timeoutTimer = window.setTimeout(() => settle("timeout"), timeoutMs);
|
|
2034
|
+
const check = () => {
|
|
2035
|
+
var _a, _b;
|
|
2036
|
+
if (isDisposed()) {
|
|
2037
|
+
settle("disposed");
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
const img = getImage();
|
|
2041
|
+
if (img == null ? void 0 : img.complete) {
|
|
2042
|
+
if (img.naturalWidth > 0) {
|
|
2043
|
+
settle("loaded");
|
|
2044
|
+
} else if (img.currentSrc || ((_a = img.getAttribute("src")) == null ? void 0 : _a.trim()) || ((_b = img.getAttribute("srcset")) == null ? void 0 : _b.trim())) {
|
|
2045
|
+
settle("error");
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
check();
|
|
2050
|
+
if (!settled)
|
|
2051
|
+
pollTimer = window.setInterval(check, 100);
|
|
2052
|
+
});
|
|
2053
|
+
};
|
|
2054
|
+
|
|
1998
2055
|
// src/app-presentation.ts
|
|
1999
2056
|
var import_debounce2 = __toESM(require_debounce());
|
|
2000
2057
|
var emptySceneName = "$$empty$$";
|
|
@@ -2023,36 +2080,6 @@ var isBlurDegradationAllowed = (context) => {
|
|
|
2023
2080
|
return boxState !== void 0 && boxState !== "normal";
|
|
2024
2081
|
};
|
|
2025
2082
|
var DEFAULT_SETUP_READY_TIMEOUT = 5e3;
|
|
2026
|
-
var waitForCurrentPageImage = (view, timeoutMs, isDisposed) => {
|
|
2027
|
-
return new Promise((resolve) => {
|
|
2028
|
-
let settled = false;
|
|
2029
|
-
let pollTimer;
|
|
2030
|
-
const settle = (loaded) => {
|
|
2031
|
-
if (settled)
|
|
2032
|
-
return;
|
|
2033
|
-
settled = true;
|
|
2034
|
-
window.clearTimeout(timeoutTimer);
|
|
2035
|
-
if (pollTimer !== void 0)
|
|
2036
|
-
window.clearInterval(pollTimer);
|
|
2037
|
-
resolve(loaded);
|
|
2038
|
-
};
|
|
2039
|
-
const timeoutTimer = window.setTimeout(() => settle(false), timeoutMs);
|
|
2040
|
-
const check = () => {
|
|
2041
|
-
if (isDisposed()) {
|
|
2042
|
-
settle(false);
|
|
2043
|
-
return;
|
|
2044
|
-
}
|
|
2045
|
-
const img = findBackgroundImage(view);
|
|
2046
|
-
if (img && img.complete && img.naturalWidth > 0) {
|
|
2047
|
-
settle(true);
|
|
2048
|
-
}
|
|
2049
|
-
};
|
|
2050
|
-
check();
|
|
2051
|
-
if (!settled) {
|
|
2052
|
-
pollTimer = window.setInterval(check, 100);
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
};
|
|
2056
2083
|
var resolveImageUrl = (url) => {
|
|
2057
2084
|
try {
|
|
2058
2085
|
return new URL(url, window.location.href).href;
|
|
@@ -2630,7 +2657,7 @@ var NetlessAppPresentation = {
|
|
|
2630
2657
|
options.useClipView
|
|
2631
2658
|
)
|
|
2632
2659
|
);
|
|
2633
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.
|
|
2660
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.3";
|
|
2634
2661
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
2635
2662
|
app.log = log;
|
|
2636
2663
|
app.warn = warn;
|
|
@@ -3099,9 +3126,15 @@ var NetlessAppPresentation = {
|
|
|
3099
3126
|
);
|
|
3100
3127
|
const setupReadyTimeout = (_d = options.setupReadyTimeout) != null ? _d : DEFAULT_SETUP_READY_TIMEOUT;
|
|
3101
3128
|
return prepareScenesPromise.then(async () => {
|
|
3102
|
-
const
|
|
3103
|
-
|
|
3129
|
+
const result = await waitForCurrentPageImage(
|
|
3130
|
+
() => findBackgroundImage(view),
|
|
3131
|
+
setupReadyTimeout,
|
|
3132
|
+
() => disposed
|
|
3133
|
+
);
|
|
3134
|
+
if (result === "timeout" && !disposed) {
|
|
3104
3135
|
warn(`[Presentation] setup ready wait timed out after ${setupReadyTimeout}ms`);
|
|
3136
|
+
} else if (result === "error" && !disposed) {
|
|
3137
|
+
warn("[Presentation] setup page image failed to load; continuing setup");
|
|
3105
3138
|
}
|
|
3106
3139
|
return controller;
|
|
3107
3140
|
});
|
|
@@ -3190,7 +3223,7 @@ var install = (register, options = {}) => {
|
|
|
3190
3223
|
};
|
|
3191
3224
|
|
|
3192
3225
|
// src/index.ts
|
|
3193
|
-
var version = "0.1.13-beta.
|
|
3226
|
+
var version = "0.1.13-beta.3";
|
|
3194
3227
|
|
|
3195
3228
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
3196
3229
|
exports.Presentation = Presentation;
|