@netless/app-presentation 0.1.13-beta.3 → 0.1.13-beta.4
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 +2 -2
- package/dist/index.global.js +62 -15
- package/dist/index.js +62 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +55 -11
- package/src/setup-ready.ts +9 -2
package/dist/index.d.ts
CHANGED
|
@@ -472,8 +472,8 @@ interface PresentationAppOptions {
|
|
|
472
472
|
/** useClipView is used to set the presentation use clip view, it will be used in the presentation, and the presentation will be use clip view when the app is initialized */
|
|
473
473
|
useClipView?: boolean;
|
|
474
474
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
475
|
+
* First-image warning threshold in ms. Default: 5_000. New lazy hosts
|
|
476
|
+
* await real readiness; legacy/eager hosts resolve on timeout.
|
|
477
477
|
*/
|
|
478
478
|
setupReadyTimeout?: number;
|
|
479
479
|
/**
|
package/dist/index.global.js
CHANGED
|
@@ -2016,9 +2016,10 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2016
2016
|
};
|
|
2017
2017
|
|
|
2018
2018
|
// src/setup-ready.ts
|
|
2019
|
-
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed) => {
|
|
2019
|
+
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed, options) => {
|
|
2020
2020
|
return new Promise((resolve) => {
|
|
2021
2021
|
let settled = false;
|
|
2022
|
+
let timedOut = false;
|
|
2022
2023
|
let pollTimer;
|
|
2023
2024
|
const settle = (result) => {
|
|
2024
2025
|
if (settled)
|
|
@@ -2029,13 +2030,22 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2029
2030
|
window.clearInterval(pollTimer);
|
|
2030
2031
|
resolve(result);
|
|
2031
2032
|
};
|
|
2032
|
-
const timeoutTimer = window.setTimeout(() =>
|
|
2033
|
+
const timeoutTimer = window.setTimeout(() => {
|
|
2034
|
+
timedOut = true;
|
|
2035
|
+
options == null ? void 0 : options.onTimeout();
|
|
2036
|
+
if (!(options == null ? void 0 : options.waitForReady()))
|
|
2037
|
+
settle("timeout");
|
|
2038
|
+
}, timeoutMs);
|
|
2033
2039
|
const check = () => {
|
|
2034
2040
|
var _a, _b;
|
|
2035
2041
|
if (isDisposed()) {
|
|
2036
2042
|
settle("disposed");
|
|
2037
2043
|
return;
|
|
2038
2044
|
}
|
|
2045
|
+
if (timedOut && !(options == null ? void 0 : options.waitForReady())) {
|
|
2046
|
+
settle("timeout");
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2039
2049
|
const img = getImage();
|
|
2040
2050
|
if (img == null ? void 0 : img.complete) {
|
|
2041
2051
|
if (img.naturalWidth > 0) {
|
|
@@ -2110,6 +2120,19 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2110
2120
|
const boxBlurClass = box.wrapClassName("blur");
|
|
2111
2121
|
let blurEpisode = false;
|
|
2112
2122
|
let reDegradeEnabled = false;
|
|
2123
|
+
let previewSuspended = false;
|
|
2124
|
+
let appliedFocusState = true;
|
|
2125
|
+
let logicalFocused = true;
|
|
2126
|
+
const activityBlocked = () => {
|
|
2127
|
+
var _a, _b;
|
|
2128
|
+
const wm = context.getWindowManager();
|
|
2129
|
+
if ((wm == null ? void 0 : wm.lazySetupInMaximizedMode) !== true)
|
|
2130
|
+
return false;
|
|
2131
|
+
const host = (_a = context.getRuntimeActivity) == null ? void 0 : _a.call(context);
|
|
2132
|
+
if (host)
|
|
2133
|
+
return document.visibilityState === "hidden" || !host.active;
|
|
2134
|
+
return document.visibilityState === "hidden" || wm.boxState === "minimized" || ((_b = wm.attributes) == null ? void 0 : _b.minimized) === true || context.getBoxStatus() === "minimized";
|
|
2135
|
+
};
|
|
2113
2136
|
let boxBlurred = box.$box.classList.contains(boxBlurClass);
|
|
2114
2137
|
const setBackgroundSuspended = (suspended) => {
|
|
2115
2138
|
app.whiteboardDOM.classList.toggle(
|
|
@@ -2124,7 +2147,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2124
2147
|
const thumbnailURL = page.thumbnail;
|
|
2125
2148
|
const img = findBackgroundImage(view);
|
|
2126
2149
|
if (!thumbnailURL || !hasUsableThumbnail(page)) {
|
|
2127
|
-
if (boxBlurred) {
|
|
2150
|
+
if (boxBlurred || activityBlocked()) {
|
|
2128
2151
|
setBackgroundSuspended(true);
|
|
2129
2152
|
if (img && resolveImageUrl(img.src) !== resolveImageUrl(TRANSPARENT_BACKGROUND)) {
|
|
2130
2153
|
img.src = TRANSPARENT_BACKGROUND;
|
|
@@ -2146,9 +2169,12 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2146
2169
|
setBackgroundSuspended(false);
|
|
2147
2170
|
};
|
|
2148
2171
|
const suspendCachedResources = () => {
|
|
2149
|
-
if (!blurEpisode || !boxBlurred)
|
|
2172
|
+
if (!blurEpisode || !boxBlurred && !activityBlocked())
|
|
2150
2173
|
return;
|
|
2151
|
-
|
|
2174
|
+
if (!previewSuspended) {
|
|
2175
|
+
previewSuspended = true;
|
|
2176
|
+
app.suspendPreviewResources();
|
|
2177
|
+
}
|
|
2152
2178
|
const page = pages[pageIndex$.value];
|
|
2153
2179
|
if (!page || !hasUsableThumbnail(page) || reDegradeEnabled) {
|
|
2154
2180
|
degrade();
|
|
@@ -2159,6 +2185,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2159
2185
|
return;
|
|
2160
2186
|
blurEpisode = false;
|
|
2161
2187
|
reDegradeEnabled = false;
|
|
2188
|
+
previewSuspended = false;
|
|
2162
2189
|
restore2();
|
|
2163
2190
|
app.preload.resume(pageIndex$.value);
|
|
2164
2191
|
};
|
|
@@ -2189,27 +2216,40 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2189
2216
|
return;
|
|
2190
2217
|
reDegradeEnabled = false;
|
|
2191
2218
|
};
|
|
2192
|
-
const
|
|
2219
|
+
const applyActivity = () => {
|
|
2220
|
+
var _a;
|
|
2221
|
+
const lazy = ((_a = context.getWindowManager()) == null ? void 0 : _a.lazySetupInMaximizedMode) === true;
|
|
2222
|
+
const isFocused = (!lazy || logicalFocused) && !activityBlocked();
|
|
2223
|
+
if (appliedFocusState === isFocused)
|
|
2224
|
+
return;
|
|
2225
|
+
if (!isFocused && !isBlurDegradationAllowed(context) && !activityBlocked())
|
|
2226
|
+
return;
|
|
2193
2227
|
if (isFocused) {
|
|
2194
2228
|
restoreFocusedResources();
|
|
2195
2229
|
} else {
|
|
2196
|
-
if (!isBlurDegradationAllowed(context))
|
|
2197
|
-
return;
|
|
2198
2230
|
blurEpisode = true;
|
|
2199
2231
|
reDegradeEnabled = true;
|
|
2200
2232
|
degrade();
|
|
2201
2233
|
app.preload.pause();
|
|
2202
2234
|
suspendCachedResources();
|
|
2203
2235
|
}
|
|
2236
|
+
appliedFocusState = isFocused;
|
|
2237
|
+
};
|
|
2238
|
+
const offFocus = context.emitter.on("focus", (isFocused) => {
|
|
2239
|
+
logicalFocused = isFocused;
|
|
2240
|
+
applyActivity();
|
|
2204
2241
|
});
|
|
2205
2242
|
dispose2.add(offFocus);
|
|
2243
|
+
dispose2.add(context.emitter.on("runtimeActivity", applyActivity));
|
|
2244
|
+
document.addEventListener("visibilitychange", applyActivity);
|
|
2245
|
+
dispose2.add(() => document.removeEventListener("visibilitychange", applyActivity));
|
|
2206
2246
|
const updateBoxBlurred = (blurred) => {
|
|
2207
2247
|
if (boxBlurred === blurred)
|
|
2208
2248
|
return;
|
|
2209
2249
|
boxBlurred = blurred;
|
|
2210
2250
|
if (blurred)
|
|
2211
2251
|
suspendCachedResources();
|
|
2212
|
-
else
|
|
2252
|
+
else if (logicalFocused && !activityBlocked())
|
|
2213
2253
|
restoreFocusedResources();
|
|
2214
2254
|
};
|
|
2215
2255
|
const onBoxBlur = () => updateBoxBlurred(true);
|
|
@@ -2656,7 +2696,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
2656
2696
|
options.useClipView
|
|
2657
2697
|
)
|
|
2658
2698
|
);
|
|
2659
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.
|
|
2699
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.4";
|
|
2660
2700
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
2661
2701
|
app.log = log;
|
|
2662
2702
|
app.warn = warn;
|
|
@@ -3128,11 +3168,18 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
3128
3168
|
const result = await waitForCurrentPageImage(
|
|
3129
3169
|
() => findBackgroundImage(view),
|
|
3130
3170
|
setupReadyTimeout,
|
|
3131
|
-
() => disposed
|
|
3171
|
+
() => disposed,
|
|
3172
|
+
{
|
|
3173
|
+
waitForReady: () => Boolean(context.waitForActualSetupReady),
|
|
3174
|
+
onTimeout: () => warn(`[Presentation] setup page image still pending after ${setupReadyTimeout}ms`)
|
|
3175
|
+
}
|
|
3132
3176
|
);
|
|
3133
|
-
if (
|
|
3134
|
-
|
|
3135
|
-
|
|
3177
|
+
if (disposed)
|
|
3178
|
+
throw new Error("[Presentation] disposed before setup ready");
|
|
3179
|
+
if (result === "error" && context.waitForActualSetupReady) {
|
|
3180
|
+
throw new Error("[Presentation] setup page image failed to load");
|
|
3181
|
+
}
|
|
3182
|
+
if (result === "error" && !disposed) {
|
|
3136
3183
|
warn("[Presentation] setup page image failed to load; continuing setup");
|
|
3137
3184
|
}
|
|
3138
3185
|
return controller;
|
|
@@ -3222,7 +3269,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
3222
3269
|
};
|
|
3223
3270
|
|
|
3224
3271
|
// src/index.ts
|
|
3225
|
-
var version = "0.1.13-beta.
|
|
3272
|
+
var version = "0.1.13-beta.4";
|
|
3226
3273
|
|
|
3227
3274
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
3228
3275
|
exports.Presentation = Presentation;
|
package/dist/index.js
CHANGED
|
@@ -2017,9 +2017,10 @@ var createPresentationRuntimeTeardown = (box, dispose2) => {
|
|
|
2017
2017
|
};
|
|
2018
2018
|
|
|
2019
2019
|
// src/setup-ready.ts
|
|
2020
|
-
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed) => {
|
|
2020
|
+
var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed, options) => {
|
|
2021
2021
|
return new Promise((resolve) => {
|
|
2022
2022
|
let settled = false;
|
|
2023
|
+
let timedOut = false;
|
|
2023
2024
|
let pollTimer;
|
|
2024
2025
|
const settle = (result) => {
|
|
2025
2026
|
if (settled)
|
|
@@ -2030,13 +2031,22 @@ var waitForCurrentPageImage = (getImage, timeoutMs, isDisposed) => {
|
|
|
2030
2031
|
window.clearInterval(pollTimer);
|
|
2031
2032
|
resolve(result);
|
|
2032
2033
|
};
|
|
2033
|
-
const timeoutTimer = window.setTimeout(() =>
|
|
2034
|
+
const timeoutTimer = window.setTimeout(() => {
|
|
2035
|
+
timedOut = true;
|
|
2036
|
+
options == null ? void 0 : options.onTimeout();
|
|
2037
|
+
if (!(options == null ? void 0 : options.waitForReady()))
|
|
2038
|
+
settle("timeout");
|
|
2039
|
+
}, timeoutMs);
|
|
2034
2040
|
const check = () => {
|
|
2035
2041
|
var _a, _b;
|
|
2036
2042
|
if (isDisposed()) {
|
|
2037
2043
|
settle("disposed");
|
|
2038
2044
|
return;
|
|
2039
2045
|
}
|
|
2046
|
+
if (timedOut && !(options == null ? void 0 : options.waitForReady())) {
|
|
2047
|
+
settle("timeout");
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2040
2050
|
const img = getImage();
|
|
2041
2051
|
if (img == null ? void 0 : img.complete) {
|
|
2042
2052
|
if (img.naturalWidth > 0) {
|
|
@@ -2111,6 +2121,19 @@ var setupBlurThumbnailDegradation = (config) => {
|
|
|
2111
2121
|
const boxBlurClass = box.wrapClassName("blur");
|
|
2112
2122
|
let blurEpisode = false;
|
|
2113
2123
|
let reDegradeEnabled = false;
|
|
2124
|
+
let previewSuspended = false;
|
|
2125
|
+
let appliedFocusState = true;
|
|
2126
|
+
let logicalFocused = true;
|
|
2127
|
+
const activityBlocked = () => {
|
|
2128
|
+
var _a, _b;
|
|
2129
|
+
const wm = context.getWindowManager();
|
|
2130
|
+
if ((wm == null ? void 0 : wm.lazySetupInMaximizedMode) !== true)
|
|
2131
|
+
return false;
|
|
2132
|
+
const host = (_a = context.getRuntimeActivity) == null ? void 0 : _a.call(context);
|
|
2133
|
+
if (host)
|
|
2134
|
+
return document.visibilityState === "hidden" || !host.active;
|
|
2135
|
+
return document.visibilityState === "hidden" || wm.boxState === "minimized" || ((_b = wm.attributes) == null ? void 0 : _b.minimized) === true || context.getBoxStatus() === "minimized";
|
|
2136
|
+
};
|
|
2114
2137
|
let boxBlurred = box.$box.classList.contains(boxBlurClass);
|
|
2115
2138
|
const setBackgroundSuspended = (suspended) => {
|
|
2116
2139
|
app.whiteboardDOM.classList.toggle(
|
|
@@ -2125,7 +2148,7 @@ var setupBlurThumbnailDegradation = (config) => {
|
|
|
2125
2148
|
const thumbnailURL = page.thumbnail;
|
|
2126
2149
|
const img = findBackgroundImage(view);
|
|
2127
2150
|
if (!thumbnailURL || !hasUsableThumbnail(page)) {
|
|
2128
|
-
if (boxBlurred) {
|
|
2151
|
+
if (boxBlurred || activityBlocked()) {
|
|
2129
2152
|
setBackgroundSuspended(true);
|
|
2130
2153
|
if (img && resolveImageUrl(img.src) !== resolveImageUrl(TRANSPARENT_BACKGROUND)) {
|
|
2131
2154
|
img.src = TRANSPARENT_BACKGROUND;
|
|
@@ -2147,9 +2170,12 @@ var setupBlurThumbnailDegradation = (config) => {
|
|
|
2147
2170
|
setBackgroundSuspended(false);
|
|
2148
2171
|
};
|
|
2149
2172
|
const suspendCachedResources = () => {
|
|
2150
|
-
if (!blurEpisode || !boxBlurred)
|
|
2173
|
+
if (!blurEpisode || !boxBlurred && !activityBlocked())
|
|
2151
2174
|
return;
|
|
2152
|
-
|
|
2175
|
+
if (!previewSuspended) {
|
|
2176
|
+
previewSuspended = true;
|
|
2177
|
+
app.suspendPreviewResources();
|
|
2178
|
+
}
|
|
2153
2179
|
const page = pages[pageIndex$.value];
|
|
2154
2180
|
if (!page || !hasUsableThumbnail(page) || reDegradeEnabled) {
|
|
2155
2181
|
degrade();
|
|
@@ -2160,6 +2186,7 @@ var setupBlurThumbnailDegradation = (config) => {
|
|
|
2160
2186
|
return;
|
|
2161
2187
|
blurEpisode = false;
|
|
2162
2188
|
reDegradeEnabled = false;
|
|
2189
|
+
previewSuspended = false;
|
|
2163
2190
|
restore2();
|
|
2164
2191
|
app.preload.resume(pageIndex$.value);
|
|
2165
2192
|
};
|
|
@@ -2190,27 +2217,40 @@ var setupBlurThumbnailDegradation = (config) => {
|
|
|
2190
2217
|
return;
|
|
2191
2218
|
reDegradeEnabled = false;
|
|
2192
2219
|
};
|
|
2193
|
-
const
|
|
2220
|
+
const applyActivity = () => {
|
|
2221
|
+
var _a;
|
|
2222
|
+
const lazy = ((_a = context.getWindowManager()) == null ? void 0 : _a.lazySetupInMaximizedMode) === true;
|
|
2223
|
+
const isFocused = (!lazy || logicalFocused) && !activityBlocked();
|
|
2224
|
+
if (appliedFocusState === isFocused)
|
|
2225
|
+
return;
|
|
2226
|
+
if (!isFocused && !isBlurDegradationAllowed(context) && !activityBlocked())
|
|
2227
|
+
return;
|
|
2194
2228
|
if (isFocused) {
|
|
2195
2229
|
restoreFocusedResources();
|
|
2196
2230
|
} else {
|
|
2197
|
-
if (!isBlurDegradationAllowed(context))
|
|
2198
|
-
return;
|
|
2199
2231
|
blurEpisode = true;
|
|
2200
2232
|
reDegradeEnabled = true;
|
|
2201
2233
|
degrade();
|
|
2202
2234
|
app.preload.pause();
|
|
2203
2235
|
suspendCachedResources();
|
|
2204
2236
|
}
|
|
2237
|
+
appliedFocusState = isFocused;
|
|
2238
|
+
};
|
|
2239
|
+
const offFocus = context.emitter.on("focus", (isFocused) => {
|
|
2240
|
+
logicalFocused = isFocused;
|
|
2241
|
+
applyActivity();
|
|
2205
2242
|
});
|
|
2206
2243
|
dispose2.add(offFocus);
|
|
2244
|
+
dispose2.add(context.emitter.on("runtimeActivity", applyActivity));
|
|
2245
|
+
document.addEventListener("visibilitychange", applyActivity);
|
|
2246
|
+
dispose2.add(() => document.removeEventListener("visibilitychange", applyActivity));
|
|
2207
2247
|
const updateBoxBlurred = (blurred) => {
|
|
2208
2248
|
if (boxBlurred === blurred)
|
|
2209
2249
|
return;
|
|
2210
2250
|
boxBlurred = blurred;
|
|
2211
2251
|
if (blurred)
|
|
2212
2252
|
suspendCachedResources();
|
|
2213
|
-
else
|
|
2253
|
+
else if (logicalFocused && !activityBlocked())
|
|
2214
2254
|
restoreFocusedResources();
|
|
2215
2255
|
};
|
|
2216
2256
|
const onBoxBlur = () => updateBoxBlurred(true);
|
|
@@ -2657,7 +2697,7 @@ var NetlessAppPresentation = {
|
|
|
2657
2697
|
options.useClipView
|
|
2658
2698
|
)
|
|
2659
2699
|
);
|
|
2660
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.
|
|
2700
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.4";
|
|
2661
2701
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
2662
2702
|
app.log = log;
|
|
2663
2703
|
app.warn = warn;
|
|
@@ -3129,11 +3169,18 @@ var NetlessAppPresentation = {
|
|
|
3129
3169
|
const result = await waitForCurrentPageImage(
|
|
3130
3170
|
() => findBackgroundImage(view),
|
|
3131
3171
|
setupReadyTimeout,
|
|
3132
|
-
() => disposed
|
|
3172
|
+
() => disposed,
|
|
3173
|
+
{
|
|
3174
|
+
waitForReady: () => Boolean(context.waitForActualSetupReady),
|
|
3175
|
+
onTimeout: () => warn(`[Presentation] setup page image still pending after ${setupReadyTimeout}ms`)
|
|
3176
|
+
}
|
|
3133
3177
|
);
|
|
3134
|
-
if (
|
|
3135
|
-
|
|
3136
|
-
|
|
3178
|
+
if (disposed)
|
|
3179
|
+
throw new Error("[Presentation] disposed before setup ready");
|
|
3180
|
+
if (result === "error" && context.waitForActualSetupReady) {
|
|
3181
|
+
throw new Error("[Presentation] setup page image failed to load");
|
|
3182
|
+
}
|
|
3183
|
+
if (result === "error" && !disposed) {
|
|
3137
3184
|
warn("[Presentation] setup page image failed to load; continuing setup");
|
|
3138
3185
|
}
|
|
3139
3186
|
return controller;
|
|
@@ -3223,7 +3270,7 @@ var install = (register, options = {}) => {
|
|
|
3223
3270
|
};
|
|
3224
3271
|
|
|
3225
3272
|
// src/index.ts
|
|
3226
|
-
var version = "0.1.13-beta.
|
|
3273
|
+
var version = "0.1.13-beta.4";
|
|
3227
3274
|
|
|
3228
3275
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
3229
3276
|
exports.Presentation = Presentation;
|