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