@netless/app-presentation 0.1.12 → 0.1.13-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.js CHANGED
@@ -1968,7 +1968,10 @@ var createDiagnosticLogger = (context) => {
1968
1968
  var _a;
1969
1969
  const createAppLogger = context.createLogger;
1970
1970
  if (typeof createAppLogger === "function") {
1971
- return createAppLogger.call(context, "camera", { debounceTime: 300, maxWaitTime: 2e3 });
1971
+ return createAppLogger.call(context, "camera", {
1972
+ debounceTime: 300,
1973
+ maxWaitTime: 2e3
1974
+ });
1972
1975
  }
1973
1976
  const roomLogger = (_a = context.getRoom()) == null ? void 0 : _a.logger;
1974
1977
  const prefix = `[Presentation][${context.appId}][camera]`;
@@ -2025,6 +2028,7 @@ var scenesEqual = (scenes1, scenes2) => {
2025
2028
  return scene.name === scene2.name && ((_a = scene.ppt) == null ? void 0 : _a.width) === ((_b = scene2.ppt) == null ? void 0 : _b.width) && ((_c = scene.ppt) == null ? void 0 : _c.height) === ((_d = scene2.ppt) == null ? void 0 : _d.height) && ((_e = scene.ppt) == null ? void 0 : _e.src) === ((_f = scene2.ppt) == null ? void 0 : _f.src);
2026
2029
  });
2027
2030
  };
2031
+ var teardownByContext = /* @__PURE__ */ new WeakMap();
2028
2032
  var NetlessAppPresentation = {
2029
2033
  kind: "Presentation",
2030
2034
  setup(context) {
@@ -2032,33 +2036,52 @@ var NetlessAppPresentation = {
2032
2036
  const diagnosticLogger = createDiagnosticLogger(context);
2033
2037
  const view = context.getView();
2034
2038
  if (!view)
2035
- throw new Error("[Presentation]: no whiteboard view, make sure you have added options.scenePath in addApp()");
2039
+ throw new Error(
2040
+ "[Presentation]: no whiteboard view, make sure you have added options.scenePath in addApp()"
2041
+ );
2036
2042
  const options = context.getAppOptions() || {};
2037
2043
  const room = context.getRoom();
2038
2044
  const log = options.log || createLogger(room);
2039
2045
  const roomLogger = room == null ? void 0 : room.logger;
2040
2046
  const warn = (...data) => (roomLogger == null ? void 0 : roomLogger.warn) ? roomLogger.warn(...data) : log(...data);
2041
2047
  const configuredOriginSize = context.storage.state.originSize;
2042
- const originSize = isValidSize(configuredOriginSize) ? { width: configuredOriginSize.width, height: configuredOriginSize.height } : void 0;
2048
+ const originSize = isValidSize(configuredOriginSize) ? {
2049
+ width: configuredOriginSize.width,
2050
+ height: configuredOriginSize.height
2051
+ } : void 0;
2043
2052
  if (configuredOriginSize != null && !originSize) {
2044
- warn(`[Presentation] originSize should contain finite positive width and height, got ${JSON.stringify(configuredOriginSize)}`);
2053
+ warn(
2054
+ `[Presentation] originSize should contain finite positive width and height, got ${JSON.stringify(configuredOriginSize)}`
2055
+ );
2045
2056
  }
2046
2057
  const pages = (_a = context.getScenes()) == null ? void 0 : _a.map(({ ppt, name }) => ppt2page(ppt, name, originSize)).filter(Boolean);
2047
2058
  if (!pages || pages.length === 0)
2048
- throw new Error("[Presentation]: empty scenes, make sure you have added options.scenes in addApp()");
2059
+ throw new Error(
2060
+ "[Presentation]: empty scenes, make sure you have added options.scenes in addApp()"
2061
+ );
2049
2062
  if (pages[0].src.startsWith("ppt"))
2050
- throw new Error("[Presentation]: legacy dynamic PPT is unsupported, please use the projector converter and @netless/slide to render it");
2063
+ throw new Error(
2064
+ "[Presentation]: legacy dynamic PPT is unsupported, please use the projector converter and @netless/slide to render it"
2065
+ );
2051
2066
  const scenePath = context.getInitScenePath();
2052
2067
  let maxCameraScale = (_b = options.maxCameraScale) != null ? _b : 3;
2053
2068
  if (!(Number.isFinite(maxCameraScale) && maxCameraScale > 0)) {
2054
- warn(`[Presentation] maxCameraScale should be a positive number, got ${options.maxCameraScale}`);
2069
+ warn(
2070
+ `[Presentation] maxCameraScale should be a positive number, got ${options.maxCameraScale}`
2071
+ );
2055
2072
  maxCameraScale = 3;
2056
2073
  }
2057
2074
  log(`[Presentation] new ${context.appId}`);
2058
2075
  const dispose2 = disposableStore();
2059
2076
  dispose2.add(() => log(`[Presentation] dispose ${context.appId}`));
2060
2077
  dispose2.add(() => diagnosticLogger.flush());
2061
- const view$$ = context.createStorage("view", { uid: "", originX: 0, originY: 0, width: 0, height: 0 });
2078
+ const view$$ = context.createStorage("view", {
2079
+ uid: "",
2080
+ originX: 0,
2081
+ originY: 0,
2082
+ width: 0,
2083
+ height: 0
2084
+ });
2062
2085
  const _addScenePathListener = (name, listener) => {
2063
2086
  const windowManger = context.manager.windowManger;
2064
2087
  windowManger.emitter.on(name, listener);
@@ -2080,13 +2103,16 @@ var NetlessAppPresentation = {
2080
2103
  let pageIndex = getPageIndex(view);
2081
2104
  const pageIndex$ = readable(pageIndex, (set) => {
2082
2105
  set(pageIndex);
2083
- return _addScenePathListener("onAppScenePathChange", (payload) => {
2084
- const { appId } = payload;
2085
- if (appId === context.appId) {
2086
- const _pageIndex = getPageIndex(payload.view);
2087
- set(_pageIndex);
2106
+ return _addScenePathListener(
2107
+ "onAppScenePathChange",
2108
+ (payload) => {
2109
+ const { appId } = payload;
2110
+ if (appId === context.appId) {
2111
+ const _pageIndex = getPageIndex(payload.view);
2112
+ set(_pageIndex);
2113
+ }
2088
2114
  }
2089
- });
2115
+ );
2090
2116
  });
2091
2117
  dispose2.add(() => {
2092
2118
  pageIndex$.dispose();
@@ -2103,7 +2129,12 @@ var NetlessAppPresentation = {
2103
2129
  const p = pages[index];
2104
2130
  const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
2105
2131
  if (!scenes.some((scene) => scene.name === name)) {
2106
- await context.addPage({ scene: { name, ppt: { width: p.width, height: p.height, src: p.src } } });
2132
+ await context.addPage({
2133
+ scene: {
2134
+ name,
2135
+ ppt: { width: p.width, height: p.height, src: p.src }
2136
+ }
2137
+ });
2107
2138
  }
2108
2139
  if (logger) {
2109
2140
  logger.info(`[Presentation] syncPage ${scenePath}/${name}`);
@@ -2115,15 +2146,21 @@ var NetlessAppPresentation = {
2115
2146
  if (!context.isAddApp)
2116
2147
  return;
2117
2148
  if (pages.length > 100)
2118
- warn(`[Presentation]: too many pages (${pages.length}), may cause performance issues`);
2149
+ warn(
2150
+ `[Presentation]: too many pages (${pages.length}), may cause performance issues`
2151
+ );
2119
2152
  if (!room || !room.isWritable)
2120
2153
  return;
2121
2154
  if (pageIndex$.value < 0 || pageIndex$.value >= pages.length) {
2122
- throw new Error(`[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`);
2155
+ throw new Error(
2156
+ `[Presentation] Invalid page index: ${pageIndex$.value}, scenes length: ${pages.length}`
2157
+ );
2123
2158
  }
2124
2159
  const scenes = room.entireScenes()[scenePath];
2125
2160
  if (!scenes || !scenes[pageIndex$.value]) {
2126
- throw new Error(`[Presentation]: no initial scene found at ${scenePath}, page index: ${pageIndex$.value}`);
2161
+ throw new Error(
2162
+ `[Presentation]: no initial scene found at ${scenePath}, page index: ${pageIndex$.value}`
2163
+ );
2127
2164
  }
2128
2165
  const { name, ppt } = scenes[pageIndex$.value];
2129
2166
  const nextScenes = pages.map((page, index) => {
@@ -2152,16 +2189,22 @@ var NetlessAppPresentation = {
2152
2189
  const prepareScenesPromise = prepareScenes();
2153
2190
  const canJumpPage = (index) => {
2154
2191
  if (!context.getIsWritable()) {
2155
- warn("[Presentation]: no permission, make sure you have test room.isWritable");
2192
+ warn(
2193
+ "[Presentation]: no permission, make sure you have test room.isWritable"
2194
+ );
2156
2195
  return false;
2157
2196
  }
2158
2197
  if (!(0 <= index && index < pages.length)) {
2159
- warn(`[Presentation]: page ${index + 1} out of bounds [1, ${pages.length}]`);
2198
+ warn(
2199
+ `[Presentation]: page ${index + 1} out of bounds [1, ${pages.length}]`
2200
+ );
2160
2201
  return false;
2161
2202
  }
2162
2203
  const scenes = context.getDisplayer().entireScenes()[scenePath];
2163
2204
  if (!scenes) {
2164
- warn(`[Presentation]: no scenes found at ${scenePath}, make sure you have added options.scenePath in addApp()`);
2205
+ warn(
2206
+ `[Presentation]: no scenes found at ${scenePath}, make sure you have added options.scenePath in addApp()`
2207
+ );
2165
2208
  return false;
2166
2209
  }
2167
2210
  return true;
@@ -2267,13 +2310,20 @@ var NetlessAppPresentation = {
2267
2310
  try {
2268
2311
  const { camera, size } = view;
2269
2312
  const referenceSize = getCameraReferenceSize(originSize, page);
2270
- const viewport = cameraToSharedViewport(camera, size, referenceSize);
2313
+ const viewport = cameraToSharedViewport(
2314
+ camera,
2315
+ size,
2316
+ referenceSize
2317
+ );
2271
2318
  if (viewport)
2272
2319
  view$$.setState(__spreadValues({ uid: me }, viewport));
2273
2320
  if (pendingMoveCameraRequest) {
2274
2321
  diagnosticLogger.debouncedInfo(
2275
2322
  "moveCamera",
2276
- getCameraDiagnosticState("moveCamera", pendingMoveCameraRequest)
2323
+ getCameraDiagnosticState(
2324
+ "moveCamera",
2325
+ pendingMoveCameraRequest
2326
+ )
2277
2327
  );
2278
2328
  pendingMoveCameraRequest = void 0;
2279
2329
  }
@@ -2281,7 +2331,10 @@ var NetlessAppPresentation = {
2281
2331
  diagnosticLogger.error(
2282
2332
  "syncView.failed",
2283
2333
  error,
2284
- getCameraDiagnosticState("moveCamera", pendingMoveCameraRequest)
2334
+ getCameraDiagnosticState(
2335
+ "moveCamera",
2336
+ pendingMoveCameraRequest
2337
+ )
2285
2338
  );
2286
2339
  pendingMoveCameraRequest = void 0;
2287
2340
  }
@@ -2306,14 +2359,26 @@ var NetlessAppPresentation = {
2306
2359
  });
2307
2360
  }
2308
2361
  };
2309
- dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
2362
+ dispose2.add(
2363
+ view$$.addStateChangedListener(() => syncViewFromRemote(false, true))
2364
+ );
2310
2365
  const getPageSize = () => {
2311
2366
  const { width, height } = app.page() || {};
2312
2367
  return { width: width || 0, height: height || 0 };
2313
2368
  };
2314
2369
  const box = context.getBox();
2315
- const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
2316
- app.contentDOM.dataset.appPresentationVersion = "0.1.12";
2370
+ const app = dispose2.add(
2371
+ createPresentation(
2372
+ box,
2373
+ pages,
2374
+ jumpPage,
2375
+ pageIndex$,
2376
+ view,
2377
+ options.thumbnail,
2378
+ options.useClipView
2379
+ )
2380
+ );
2381
+ app.contentDOM.dataset.appPresentationVersion = "0.1.13-beta.0";
2317
2382
  app.scaleDocsToFit = scaleDocsToFit;
2318
2383
  app.log = log;
2319
2384
  app.warn = warn;
@@ -2360,12 +2425,14 @@ var NetlessAppPresentation = {
2360
2425
  };
2361
2426
  if (originSize) {
2362
2427
  let previousPageIndex = pageIndex$.value;
2363
- dispose2.add(pageIndex$.subscribe((nextPageIndex) => {
2364
- if (nextPageIndex === previousPageIndex)
2365
- return;
2366
- previousPageIndex = nextPageIndex;
2367
- scaleDocsToFit();
2368
- }));
2428
+ dispose2.add(
2429
+ pageIndex$.subscribe((nextPageIndex) => {
2430
+ if (nextPageIndex === previousPageIndex)
2431
+ return;
2432
+ previousPageIndex = nextPageIndex;
2433
+ scaleDocsToFit();
2434
+ })
2435
+ );
2369
2436
  }
2370
2437
  if (options.justDocsViewReadonly) {
2371
2438
  app.setDocsViewReadonly(true);
@@ -2414,9 +2481,11 @@ var NetlessAppPresentation = {
2414
2481
  });
2415
2482
  syncViewFromRemote(true);
2416
2483
  reportInitializedCamera("setup");
2417
- dispose2.add(context.emitter.on("writableChange", (isWritable) => {
2418
- app.setReadonly(!isWritable);
2419
- }));
2484
+ dispose2.add(
2485
+ context.emitter.on("writableChange", (isWritable) => {
2486
+ app.setReadonly(!isWritable);
2487
+ })
2488
+ );
2420
2489
  const getOriginScale = () => {
2421
2490
  const page = app.page();
2422
2491
  if (!page || !isValidSize(page))
@@ -2438,29 +2507,53 @@ var NetlessAppPresentation = {
2438
2507
  img.crossOrigin = "Anonymous";
2439
2508
  await new Promise((resolve, reject) => {
2440
2509
  img.onload = () => resolve();
2441
- img.onerror = () => reject(new Error(
2442
- `[Presentation]: failed to load screenshot page image: ${safeResourceLocation(src)}`
2443
- ));
2510
+ img.onerror = () => reject(
2511
+ new Error(
2512
+ `[Presentation]: failed to load screenshot page image: ${safeResourceLocation(src)}`
2513
+ )
2514
+ );
2444
2515
  img.src = src;
2445
2516
  });
2446
- _context.drawImage(img, 0, 0, width, height, 0, 0, _width || width, _height || height);
2517
+ _context.drawImage(
2518
+ img,
2519
+ 0,
2520
+ 0,
2521
+ width,
2522
+ height,
2523
+ 0,
2524
+ 0,
2525
+ _width || width,
2526
+ _height || height
2527
+ );
2447
2528
  const currentScenePath = view.focusScenePath;
2448
2529
  if (!currentScenePath) {
2449
2530
  throw new Error("[Presentation]: current scene path not found");
2450
2531
  }
2451
2532
  const windowManger = context.getWindowManager();
2452
2533
  if (windowManger._appliancePlugin) {
2453
- await windowManger._appliancePlugin.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
2454
- centerX: 0,
2455
- centerY: 0,
2456
- scale: _width && _height ? Math.min(_width / width, _height / height) : 1
2457
- });
2534
+ await windowManger._appliancePlugin.screenshotToCanvasAsync(
2535
+ _context,
2536
+ currentScenePath,
2537
+ _width || width,
2538
+ _height || height,
2539
+ {
2540
+ centerX: 0,
2541
+ centerY: 0,
2542
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
2543
+ }
2544
+ );
2458
2545
  } else {
2459
- await view.screenshotToCanvasAsync(_context, currentScenePath, _width || width, _height || height, {
2460
- centerX: 0,
2461
- centerY: 0,
2462
- scale: _width && _height ? Math.min(_width / width, _height / height) : 1
2463
- });
2546
+ await view.screenshotToCanvasAsync(
2547
+ _context,
2548
+ currentScenePath,
2549
+ _width || width,
2550
+ _height || height,
2551
+ {
2552
+ centerX: 0,
2553
+ centerY: 0,
2554
+ scale: _width && _height ? Math.min(_width / width, _height / height) : 1
2555
+ }
2556
+ );
2464
2557
  }
2465
2558
  };
2466
2559
  const screenshotCurrentPageAsync = async (_context, _width, _height) => {
@@ -2478,21 +2571,27 @@ var NetlessAppPresentation = {
2478
2571
  let scrollbar;
2479
2572
  if (options.useScrollbar) {
2480
2573
  dispose2.make(() => {
2481
- scrollbar = new Scrollbar(app.contentDOM, {
2482
- appId: context.appId,
2483
- getPageSize,
2484
- getOriginScale,
2485
- syncView,
2486
- getWritable: () => context.getIsWritable(),
2487
- scrollbarEventCallback: options.scrollbarEventCallback
2488
- }, view);
2574
+ scrollbar = new Scrollbar(
2575
+ app.contentDOM,
2576
+ {
2577
+ appId: context.appId,
2578
+ getPageSize,
2579
+ getOriginScale,
2580
+ syncView,
2581
+ getWritable: () => context.getIsWritable(),
2582
+ scrollbarEventCallback: options.scrollbarEventCallback
2583
+ },
2584
+ view
2585
+ );
2489
2586
  return () => scrollbar == null ? void 0 : scrollbar.destroy();
2490
2587
  });
2491
2588
  }
2492
2589
  const moveCamera = (camera) => {
2493
2590
  try {
2494
2591
  if (!context.getIsWritable()) {
2495
- throw new Error("[Presentation]: moveCamera must be called in writable room");
2592
+ throw new Error(
2593
+ "[Presentation]: moveCamera must be called in writable room"
2594
+ );
2496
2595
  }
2497
2596
  pendingMoveCameraRequest = __spreadValues({}, camera);
2498
2597
  if (scrollbar) {
@@ -2513,9 +2612,29 @@ var NetlessAppPresentation = {
2513
2612
  throw error;
2514
2613
  }
2515
2614
  };
2516
- context.emitter.on("destroy", () => dispose2());
2615
+ let disposed = false;
2616
+ let offDestroy;
2617
+ const teardown = () => {
2618
+ if (disposed)
2619
+ return;
2620
+ disposed = true;
2621
+ const removeDestroy = offDestroy;
2622
+ offDestroy = void 0;
2623
+ removeDestroy == null ? void 0 : removeDestroy();
2624
+ dispose2();
2625
+ };
2626
+ offDestroy = context.emitter.on("destroy", teardown);
2627
+ teardownByContext.set(context, teardown);
2517
2628
  const reportProgress = (progress, result) => {
2518
- window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
2629
+ window.postMessage(
2630
+ {
2631
+ type: "@netless/_result_save_pdf_",
2632
+ appId: context.appId,
2633
+ progress,
2634
+ result
2635
+ },
2636
+ "*"
2637
+ );
2519
2638
  return result;
2520
2639
  };
2521
2640
  const base64url = async (url) => {
@@ -2555,7 +2674,9 @@ var NetlessAppPresentation = {
2555
2674
  }
2556
2675
  const scenes = context.getDisplayer().entireScenes()[scenePath];
2557
2676
  if (!scenes) {
2558
- throw new Error(`[Presentation]: no scenes found while exporting PDF: ${scenePath}`);
2677
+ throw new Error(
2678
+ `[Presentation]: no scenes found while exporting PDF: ${scenePath}`
2679
+ );
2559
2680
  }
2560
2681
  const stage_canvas = document.createElement("canvas");
2561
2682
  stage_canvas.width = pdfWidth;
@@ -2580,20 +2701,32 @@ var NetlessAppPresentation = {
2580
2701
  const img = document.createElement("img");
2581
2702
  await new Promise((resolve, reject) => {
2582
2703
  img.onload = () => resolve();
2583
- img.onerror = () => reject(new Error(
2584
- `[Presentation]: failed to load PDF page image, page index: ${index}`
2585
- ));
2704
+ img.onerror = () => reject(
2705
+ new Error(
2706
+ `[Presentation]: failed to load PDF page image, page index: ${index}`
2707
+ )
2708
+ );
2586
2709
  img.src = url;
2587
2710
  });
2588
2711
  stage.drawImage(img, 0, 0, width2, height2);
2589
2712
  wb.clearRect(0, 0, pdfWidth, pdfHeight);
2590
2713
  const name = (_a2 = p.name) != null ? _a2 : String(index + 1);
2591
2714
  if (scenes.some((scene) => scene.name == name)) {
2592
- const camera = { centerX: 0, centerY: 0, scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2) };
2715
+ const camera = {
2716
+ centerX: 0,
2717
+ centerY: 0,
2718
+ scale: Math.min(wb_canvas.width / width2, wb_canvas.height / height2)
2719
+ };
2593
2720
  const sPath = `${scenePath}/${name}`;
2594
2721
  const windowManger = context.getWindowManager();
2595
2722
  if (windowManger._appliancePlugin) {
2596
- await windowManger._appliancePlugin.screenshotToCanvasAsync(wb, sPath, wb_canvas.width, wb_canvas.height, camera);
2723
+ await windowManger._appliancePlugin.screenshotToCanvasAsync(
2724
+ wb,
2725
+ sPath,
2726
+ wb_canvas.width,
2727
+ wb_canvas.height,
2728
+ camera
2729
+ );
2597
2730
  } else {
2598
2731
  await view.screenshotToCanvasAsync(
2599
2732
  wb,
@@ -2640,14 +2773,20 @@ var NetlessAppPresentation = {
2640
2773
  throw error;
2641
2774
  }
2642
2775
  };
2643
- dispose2.add(listen(window, "message", (ev) => {
2644
- if (ev.data && ev.data.type == "@netless/_request_save_pdf_" && ev.data.appId == context.appId) {
2645
- toPdf().catch((err) => {
2646
- warn(err);
2647
- reportProgress(100, null);
2648
- });
2649
- }
2650
- }));
2776
+ dispose2.add(
2777
+ listen(
2778
+ window,
2779
+ "message",
2780
+ (ev) => {
2781
+ if (ev.data && ev.data.type == "@netless/_request_save_pdf_" && ev.data.appId == context.appId) {
2782
+ toPdf().catch((err) => {
2783
+ warn(err);
2784
+ reportProgress(100, null);
2785
+ });
2786
+ }
2787
+ }
2788
+ )
2789
+ );
2651
2790
  const setDocsViewReadonly = (bol) => {
2652
2791
  app.setDocsViewReadonly(bol);
2653
2792
  };
@@ -2658,19 +2797,52 @@ var NetlessAppPresentation = {
2658
2797
  scrollbar.setReadonly(bol);
2659
2798
  }
2660
2799
  };
2661
- const controller = { app, view, context, jumpPage, prevPage, nextPage, jumpPageAsync, prevPageAsync, nextPageAsync, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale, getPageSize, screenshotCurrentPageAsync };
2662
- dispose2.add(listen(window, "message", (ev) => {
2663
- if (ev.data === "@netless/_presentation_") {
2664
- if (typeof window !== "undefined")
2665
- dispose2.make(() => {
2666
- const debug = window._presentation_ || (window._presentation_ = /* @__PURE__ */ new Set());
2667
- debug.add(controller);
2668
- return () => debug.delete(controller);
2669
- });
2670
- console.log(controller);
2671
- }
2672
- }));
2673
- return prepareScenesPromise.then(() => controller);
2800
+ const controller = {
2801
+ app,
2802
+ view,
2803
+ context,
2804
+ jumpPage,
2805
+ prevPage,
2806
+ nextPage,
2807
+ jumpPageAsync,
2808
+ prevPageAsync,
2809
+ nextPageAsync,
2810
+ pageState,
2811
+ toPdf,
2812
+ log,
2813
+ setDocsViewReadonly,
2814
+ setReadonly,
2815
+ moveCamera,
2816
+ getOriginScale,
2817
+ getScale,
2818
+ getPageSize,
2819
+ screenshotCurrentPageAsync
2820
+ };
2821
+ dispose2.add(
2822
+ listen(
2823
+ window,
2824
+ "message",
2825
+ (ev) => {
2826
+ if (ev.data === "@netless/_presentation_") {
2827
+ if (typeof window !== "undefined")
2828
+ dispose2.make(() => {
2829
+ const debug = window._presentation_ || (window._presentation_ = /* @__PURE__ */ new Set());
2830
+ debug.add(controller);
2831
+ return () => debug.delete(controller);
2832
+ });
2833
+ console.log(controller);
2834
+ }
2835
+ }
2836
+ )
2837
+ );
2838
+ return prepareScenesPromise.then(
2839
+ () => controller
2840
+ );
2841
+ },
2842
+ teardown(context) {
2843
+ var _a;
2844
+ (_a = teardownByContext.get(context)) == null ? void 0 : _a();
2845
+ teardownByContext.delete(context);
2674
2846
  }
2675
2847
  };
2676
2848
  var AppPresentation = class extends Presentation {
@@ -2690,19 +2862,29 @@ var AppPresentation = class extends Presentation {
2690
2862
  if (0 <= index && index < this.pages.length) {
2691
2863
  this.jumpPage(index);
2692
2864
  } else {
2693
- (_a = this.warn) == null ? void 0 : _a.call(this, `[Presentation]: page index ${index} out of bounds [0, ${this.pages.length - 1}]`);
2865
+ (_a = this.warn) == null ? void 0 : _a.call(
2866
+ this,
2867
+ `[Presentation]: page index ${index} out of bounds [0, ${this.pages.length - 1}]`
2868
+ );
2694
2869
  }
2695
2870
  }
2696
2871
  };
2697
2872
  function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, useClipView) {
2698
2873
  box.mountStyles(style_default);
2699
- const app = new AppPresentation({ pages, readonly: box.readonly, jumpPage, thumbnail });
2874
+ const app = new AppPresentation({
2875
+ pages,
2876
+ readonly: box.readonly,
2877
+ jumpPage,
2878
+ thumbnail
2879
+ });
2700
2880
  app.box = box;
2701
2881
  box.mountContent(app.contentDOM);
2702
2882
  box.mountFooter(app.footerDOM);
2703
- app.dispose.add(pageIndex$.subscribe((pageIndex) => {
2704
- app.setPageIndex(pageIndex);
2705
- }));
2883
+ app.dispose.add(
2884
+ pageIndex$.subscribe((pageIndex) => {
2885
+ app.setPageIndex(pageIndex);
2886
+ })
2887
+ );
2706
2888
  if (useClipView && view) {
2707
2889
  const onCameraUpdatedEffectForMaskView = (0, import_debounce2.default)(() => {
2708
2890
  const { width: pageWidth, height: pageHeight } = app.page() || {};
@@ -2711,8 +2893,12 @@ function createPresentation(box, pages, jumpPage, pageIndex$, view, thumbnail, u
2711
2893
  }
2712
2894
  const { scale } = view.camera;
2713
2895
  const { width, height } = view.size;
2714
- const pageRatioX = Math.round((1 - pageWidth * scale / width) / 2 * 100);
2715
- const pageRatioY = Math.round((1 - pageHeight * scale / height) / 2 * 100);
2896
+ const pageRatioX = Math.round(
2897
+ (1 - pageWidth * scale / width) / 2 * 100
2898
+ );
2899
+ const pageRatioY = Math.round(
2900
+ (1 - pageHeight * scale / height) / 2 * 100
2901
+ );
2716
2902
  app.whiteboardDOM.style.clipPath = `inset(${pageRatioY}% ${pageRatioX}%)`;
2717
2903
  }, 50);
2718
2904
  onCameraUpdatedEffectForMaskView();
@@ -2737,7 +2923,7 @@ var install = (register, options = {}) => {
2737
2923
  };
2738
2924
 
2739
2925
  // src/index.ts
2740
- var version = "0.1.12";
2926
+ var version = "0.1.13-beta.0";
2741
2927
 
2742
2928
  exports.NetlessAppPresentation = NetlessAppPresentation;
2743
2929
  exports.Presentation = Presentation;