@netless/app-presentation 0.1.13-beta.1 → 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 +73 -1
- package/dist/index.global.js +223 -82
- package/dist/index.js +223 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/app-presentation.ts +146 -81
- package/src/preload.ts +23 -11
- package/src/presentation.ts +18 -1
- package/src/runtime-lifecycle.ts +31 -0
- package/src/setup-ready.ts +39 -0
- package/src/style.scss +7 -1
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
|
@@ -143,6 +143,40 @@ interface DisposableStore extends DisposableDisposer {
|
|
|
143
143
|
*/
|
|
144
144
|
size(): number;
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a {@link DisposableStore} that manages {@link Disposer}s and {@link IDisposable}s.
|
|
148
|
+
*
|
|
149
|
+
* A {@link DisposableStore} is also a {@link Disposer}, which means it can be the `dispose` method of an {@link IDisposable}.
|
|
150
|
+
*
|
|
151
|
+
* A {@link DisposableStore} is also an {@link IDisposable}, which means it can be managed by another {@link DisposableStore}.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { type IDisposable, disposableStore } from "@wopjs/disposable";
|
|
156
|
+
*
|
|
157
|
+
* class A implements IDisposable {
|
|
158
|
+
* dispose = disposableStore()
|
|
159
|
+
* constructor() {
|
|
160
|
+
* this.dispose.add(...);
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* class B implements IDisposable {
|
|
165
|
+
* dispose = disposableStore()
|
|
166
|
+
* a = this.dispose.add(new A())
|
|
167
|
+
* constructor() {
|
|
168
|
+
* this.dispose.add(...);
|
|
169
|
+
* }
|
|
170
|
+
* }
|
|
171
|
+
*
|
|
172
|
+
* const b = new B();
|
|
173
|
+
* b.dispose(); // dispose both `b` and `b.a`.
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @param disposables Optional array of {@link DisposableType}s added to the store.
|
|
177
|
+
* @returns A disposable store.
|
|
178
|
+
*/
|
|
179
|
+
declare function disposableStore(disposables?: DisposableType[]): DisposableStore;
|
|
146
180
|
|
|
147
181
|
interface ILazyLoadInstance {
|
|
148
182
|
/**
|
|
@@ -219,11 +253,13 @@ declare class Preload implements IDisposable {
|
|
|
219
253
|
touchIndex: number;
|
|
220
254
|
preloadSize: number;
|
|
221
255
|
paused: boolean;
|
|
256
|
+
private disposed;
|
|
222
257
|
constructor(pages: PresentationPage[]);
|
|
223
258
|
pause(): void;
|
|
224
259
|
resume(index?: number): void;
|
|
225
260
|
touch(index: number, force?: boolean): void;
|
|
226
261
|
private createLink;
|
|
262
|
+
private removeLink;
|
|
227
263
|
private destroySomeLink;
|
|
228
264
|
private requestAsyncCallBack;
|
|
229
265
|
dispose(): void;
|
|
@@ -302,15 +338,27 @@ declare class Presentation implements IDisposable<void> {
|
|
|
302
338
|
setReadonly(readonly: boolean): void;
|
|
303
339
|
setPageIndex(pageIndex: number): void;
|
|
304
340
|
togglePreview(showPreview?: boolean): void;
|
|
341
|
+
/** Release preview images while this presentation stays in the runtime cache. */
|
|
342
|
+
suspendPreviewResources(): void;
|
|
305
343
|
onNewPageIndex(index: number, _origin: "navigation" | "keydown" | "input" | "preview"): void;
|
|
306
344
|
page(): PresentationPage | undefined;
|
|
307
345
|
updateImage(): void;
|
|
308
346
|
/** Returns a modified URL that points to the thumbnail image. */
|
|
309
347
|
thumbnail(src: string): string;
|
|
348
|
+
private destroyPreviewLazyload;
|
|
310
349
|
private c;
|
|
311
350
|
private isEditable;
|
|
312
351
|
}
|
|
313
352
|
|
|
353
|
+
type Subscriber<T> = (value: T) => void;
|
|
354
|
+
type Unsubscriber = () => void;
|
|
355
|
+
interface Readable<T> {
|
|
356
|
+
readonly value: T;
|
|
357
|
+
subscribe(this: void, run: Subscriber<T>): Unsubscriber;
|
|
358
|
+
reaction(this: void, run: Subscriber<T>): Unsubscriber;
|
|
359
|
+
dispose(value?: T): void;
|
|
360
|
+
}
|
|
361
|
+
|
|
314
362
|
interface ScrollbarOption {
|
|
315
363
|
appId: string;
|
|
316
364
|
readonly?: boolean;
|
|
@@ -483,6 +531,30 @@ interface PresentationController {
|
|
|
483
531
|
/** screenshot the current page */
|
|
484
532
|
screenshotCurrentPageAsync: (context: CanvasRenderingContext2D, width?: number, height?: number) => Promise<void>;
|
|
485
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Blur thumbnail degradation (see lazy-setup design doc §15): when the app
|
|
536
|
+
* loses focus but stays cached (multi-runtime cache mode), swap the scene
|
|
537
|
+
* background `<img>` src to the low-res `PptDescription.previewURL`
|
|
538
|
+
* (`page.thumbnail`) via a pure DOM change and pause full-image preloading;
|
|
539
|
+
* restore the full image when focus comes back. A page without a real
|
|
540
|
+
* thumbnail keeps its measurable view container, but its background layer is
|
|
541
|
+
* hidden and replaced with a static pixel after TeleBox commits the blur.
|
|
542
|
+
*
|
|
543
|
+
* While degraded, every load of a background `<img>` is re-degraded
|
|
544
|
+
* immediately via a capture-phase `load` listener on the document, filtered
|
|
545
|
+
* to the current view container
|
|
546
|
+
* (`load` does not bubble but capture works). This covers remote page turns,
|
|
547
|
+
* SDK React re-renders and the SDK's own background-image onError retries —
|
|
548
|
+
* any path that (re)renders the full-size image while the app stays blurred.
|
|
549
|
+
*/
|
|
550
|
+
declare const setupBlurThumbnailDegradation: (config: {
|
|
551
|
+
context: AppContext;
|
|
552
|
+
view: View;
|
|
553
|
+
pages: PresentationPage[];
|
|
554
|
+
pageIndex$: Readable<number>;
|
|
555
|
+
app: Presentation;
|
|
556
|
+
dispose: ReturnType<typeof disposableStore>;
|
|
557
|
+
}) => void;
|
|
486
558
|
declare const NetlessAppPresentation: NetlessApp<PresentationAttributes, {}, PresentationAppOptions, PresentationController> & {
|
|
487
559
|
teardown(context: AppContext): void;
|
|
488
560
|
};
|
|
@@ -510,5 +582,5 @@ declare const install: (register: RegisterFn, options?: InstallOptions) => Promi
|
|
|
510
582
|
|
|
511
583
|
declare const version: string;
|
|
512
584
|
|
|
513
|
-
export { NetlessAppPresentation, Presentation, Scrollbar, NetlessAppPresentation as default, install, version };
|
|
585
|
+
export { NetlessAppPresentation, Presentation, Scrollbar, NetlessAppPresentation as default, install, setupBlurThumbnailDegradation, version };
|
|
514
586
|
export type { InstallOptions, Logger, PresentationAppOptions, PresentationAttributes, PresentationConfig, PresentationController, PresentationPage, RegisterFn, ScrollbarEventCallback, ScrollbarOption };
|