@open-slide/core 1.11.1 → 1.12.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.
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-Bk2i4eJ1.js";
2
+ import { createViteConfig } from "./config-OT4T-im0.js";
3
3
  import path from "node:path";
4
4
  import { build as build$1, mergeConfig } from "vite";
5
5
 
package/dist/cli/bin.js CHANGED
@@ -57,15 +57,15 @@ async function run(argv) {
57
57
  program.name("open-slide").description("Author slides — we handle the Vite/React stack.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-slide --help` for usage)"));
58
58
  program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").action(async (flags) => {
59
59
  if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
60
- const { dev } = await import("../dev-DplvRqZx.js");
60
+ const { dev } = await import("../dev-DJUpPCGT.js");
61
61
  await dev(flags);
62
62
  });
63
63
  program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
64
- const { build } = await import("../build-CtmQSpg-.js");
64
+ const { build } = await import("../build-L2yL1hTo.js");
65
65
  await build(flags);
66
66
  });
67
67
  program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
68
- const { preview } = await import("../preview-p4gcc8ip.js");
68
+ const { preview } = await import("../preview-Bf8up6-P.js");
69
69
  await preview(flags);
70
70
  });
71
71
  program.command("sync:skills").description("Sync built-in skills from @open-slide/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
@@ -1,4 +1,4 @@
1
- import { Locale } from "./types-D_q_ylIe.js";
1
+ import { Locale } from "./types-uNHQlioH.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  type OpenSlideBuildConfig = {
@@ -13,6 +13,7 @@ import * as t$1 from "@babel/types";
13
13
  import * as t from "@babel/types";
14
14
  import { isJSXElement, isJSXFragment } from "@babel/types";
15
15
  import { parse } from "@babel/parser";
16
+ import { spawn } from "node:child_process";
16
17
  import fg from "fast-glob";
17
18
  import { loadConfigFromFile, normalizePath } from "vite";
18
19
 
@@ -2767,7 +2768,9 @@ function registerSvglRoutes(server) {
2767
2768
  //#region src/vite/routes/update.ts
2768
2769
  const PKG = "@open-slide/core";
2769
2770
  const CACHE_TTL_MS = 10 * 60 * 1e3;
2771
+ const COMMAND_TIMEOUT_MS = 3e5;
2770
2772
  let cache = null;
2773
+ let updateInFlight = null;
2771
2774
  function parseSemver(v) {
2772
2775
  const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
2773
2776
  if (!m) return null;
@@ -2806,18 +2809,134 @@ async function fetchLatest(now) {
2806
2809
  return cache?.latest ?? null;
2807
2810
  }
2808
2811
  }
2809
- function registerUpdateRoutes(server, current) {
2812
+ async function fileExists(file) {
2813
+ try {
2814
+ await fs.access(file);
2815
+ return true;
2816
+ } catch {
2817
+ return false;
2818
+ }
2819
+ }
2820
+ async function detectPackageManager(cwd) {
2821
+ const ua = process.env.npm_config_user_agent ?? "";
2822
+ if (ua.startsWith("pnpm")) return "pnpm";
2823
+ if (ua.startsWith("yarn")) return "yarn";
2824
+ if (ua.startsWith("bun")) return "bun";
2825
+ if (ua.startsWith("npm")) return "npm";
2826
+ if (await fileExists(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
2827
+ if (await fileExists(path.join(cwd, "yarn.lock"))) return "yarn";
2828
+ if (await fileExists(path.join(cwd, "bun.lockb"))) return "bun";
2829
+ if (await fileExists(path.join(cwd, "bun.lock"))) return "bun";
2830
+ if (await fileExists(path.join(cwd, "package-lock.json"))) return "npm";
2831
+ return "npm";
2832
+ }
2833
+ function updateCommandFor(packageManager) {
2834
+ switch (packageManager) {
2835
+ case "pnpm": return {
2836
+ cmd: "pnpm",
2837
+ args: ["add", `${PKG}@latest`]
2838
+ };
2839
+ case "yarn": return {
2840
+ cmd: "yarn",
2841
+ args: ["add", `${PKG}@latest`]
2842
+ };
2843
+ case "bun": return {
2844
+ cmd: "bun",
2845
+ args: ["add", `${PKG}@latest`]
2846
+ };
2847
+ case "npm": return {
2848
+ cmd: "npm",
2849
+ args: ["install", `${PKG}@latest`]
2850
+ };
2851
+ }
2852
+ }
2853
+ function localOpenSlideCommand(cwd) {
2854
+ const bin = process.platform === "win32" ? "open-slide.cmd" : "open-slide";
2855
+ return {
2856
+ cmd: path.join(cwd, "node_modules", ".bin", bin),
2857
+ args: ["sync:skills"]
2858
+ };
2859
+ }
2860
+ function formatCommand(spec) {
2861
+ return [spec.cmd, ...spec.args].join(" ");
2862
+ }
2863
+ async function runCommand(spec, cwd) {
2864
+ await new Promise((resolve, reject) => {
2865
+ const child = spawn(spec.cmd, spec.args, {
2866
+ cwd,
2867
+ env: process.env,
2868
+ shell: process.platform === "win32",
2869
+ stdio: [
2870
+ "ignore",
2871
+ "ignore",
2872
+ "pipe"
2873
+ ]
2874
+ });
2875
+ let stderr = "";
2876
+ const timer = setTimeout(() => {
2877
+ child.kill();
2878
+ reject(new Error(`${formatCommand(spec)} timed out`));
2879
+ }, COMMAND_TIMEOUT_MS);
2880
+ child.stderr.on("data", (chunk) => {
2881
+ stderr += chunk.toString("utf8");
2882
+ if (stderr.length > 2e3) stderr = stderr.slice(-2e3);
2883
+ });
2884
+ child.on("error", (err) => {
2885
+ clearTimeout(timer);
2886
+ reject(err);
2887
+ });
2888
+ child.on("close", (code) => {
2889
+ clearTimeout(timer);
2890
+ if (code === 0) {
2891
+ resolve();
2892
+ return;
2893
+ }
2894
+ const detail = stderr.trim();
2895
+ reject(new Error(detail || `${formatCommand(spec)} exited with code ${code ?? "unknown"}`));
2896
+ });
2897
+ });
2898
+ }
2899
+ async function updatePackage(ctx) {
2900
+ const packageManager = await detectPackageManager(ctx.userCwd);
2901
+ const updateCommand = updateCommandFor(packageManager);
2902
+ const syncCommand = localOpenSlideCommand(ctx.userCwd);
2903
+ await runCommand(updateCommand, ctx.userCwd);
2904
+ await runCommand(syncCommand, ctx.userCwd);
2905
+ cache = null;
2906
+ const latest = await fetchLatest(Date.now());
2907
+ return {
2908
+ packageManager,
2909
+ command: `${formatCommand(updateCommand)} && open-slide sync:skills`,
2910
+ latest,
2911
+ message: "Updated @open-slide/core and synced skills."
2912
+ };
2913
+ }
2914
+ function registerUpdateRoutes(server, ctx) {
2810
2915
  server.middlewares.use("/__update-check", async (req, res, next) => {
2811
2916
  if ((req.method ?? "GET") !== "GET") return next();
2812
2917
  const latest = await fetchLatest(Date.now());
2813
2918
  const result = {
2814
- current,
2919
+ current: ctx.coreVersion,
2815
2920
  latest,
2816
- outdated: latest ? isOutdated(current, latest) : false
2921
+ outdated: latest ? isOutdated(ctx.coreVersion, latest) : false
2817
2922
  };
2818
2923
  res.setHeader("cache-control", "no-store");
2819
2924
  json(res, 200, result);
2820
2925
  });
2926
+ server.middlewares.use("/__update-package", async (req, res, next) => {
2927
+ if ((req.method ?? "GET") !== "POST") return next();
2928
+ const guard = validateMutationRequest(req);
2929
+ if (!guard.ok) return json(res, guard.status, { error: guard.error });
2930
+ try {
2931
+ updateInFlight ??= updatePackage(ctx).finally(() => {
2932
+ updateInFlight = null;
2933
+ });
2934
+ const result = await updateInFlight;
2935
+ json(res, 200, result);
2936
+ } catch (err) {
2937
+ json(res, 500, { error: err instanceof Error ? err.message : "update failed" });
2938
+ }
2939
+ });
2821
2940
  }
2822
2941
 
2823
2942
  //#endregion
@@ -2872,7 +2991,7 @@ function apiPlugin(opts) {
2872
2991
  registerAssetRoutes(server, ctx);
2873
2992
  registerSvglRoutes(server);
2874
2993
  registerFolderRoutes(server, ctx);
2875
- registerUpdateRoutes(server, ctx.coreVersion);
2994
+ registerUpdateRoutes(server, ctx);
2876
2995
  }
2877
2996
  };
2878
2997
  }
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-Bk2i4eJ1.js";
2
+ import { createViteConfig } from "./config-OT4T-im0.js";
3
3
  import { createServer, mergeConfig } from "vite";
4
4
 
5
5
  //#region src/cli/dev.ts
@@ -41,6 +41,10 @@ const en = {
41
41
  newFolder: "New folder",
42
42
  folderName: "Folder name",
43
43
  updateAvailable: "open-slide {version} is available — update the package to get the latest.",
44
+ updatePackage: "Update",
45
+ updatingPackage: "Updating",
46
+ updatePackageDone: "Updated. Restart the dev server to use the new version.",
47
+ updatePackageFailed: "Update failed. Check the dev server output.",
44
48
  changeIcon: "Change icon",
45
49
  iconEmojiTab: "Emoji",
46
50
  iconColorTab: "Color",
@@ -331,7 +335,8 @@ const en = {
331
335
  toastDeleteFailed: "Could not delete page",
332
336
  resizeRail: "Resize thumbnail rail",
333
337
  transitionIndicator: "Has slide transition",
334
- stepsIndicator: "Has step-by-step reveals"
338
+ stepsIndicator: "Has step-by-step reveals",
339
+ overviewAria: "Slide overview (O)"
335
340
  },
336
341
  pdfToast: {
337
342
  title: "Exporting PDF",
@@ -433,6 +438,10 @@ const ja = {
433
438
  newFolder: "新規フォルダ",
434
439
  folderName: "フォルダ名",
435
440
  updateAvailable: "open-slide {version} が利用可能です — パッケージを更新して最新版を入手してください。",
441
+ updatePackage: "更新",
442
+ updatingPackage: "更新中",
443
+ updatePackageDone: "更新しました。新しいバージョンを使うには dev server を再起動してください。",
444
+ updatePackageFailed: "更新に失敗しました。dev server の出力を確認してください。",
436
445
  changeIcon: "アイコンを変更",
437
446
  iconEmojiTab: "絵文字",
438
447
  iconColorTab: "カラー",
@@ -723,7 +732,8 @@ const ja = {
723
732
  toastDeleteFailed: "ページを削除できませんでした",
724
733
  resizeRail: "サムネイル幅を調整",
725
734
  transitionIndicator: "スライドトランジションあり",
726
- stepsIndicator: "ステップ表示あり"
735
+ stepsIndicator: "ステップ表示あり",
736
+ overviewAria: "スライド一覧 (O)"
727
737
  },
728
738
  pdfToast: {
729
739
  title: "PDF を書き出し中",
@@ -825,6 +835,10 @@ const zhCN = {
825
835
  newFolder: "新建文件夹",
826
836
  folderName: "文件夹名称",
827
837
  updateAvailable: "open-slide {version} 已发布,请更新软件包以获取最新版本。",
838
+ updatePackage: "更新",
839
+ updatingPackage: "更新中",
840
+ updatePackageDone: "已更新。请重启 dev server 以使用新版本。",
841
+ updatePackageFailed: "更新失败,请查看 dev server 输出。",
828
842
  changeIcon: "更换图标",
829
843
  iconEmojiTab: "Emoji",
830
844
  iconColorTab: "颜色",
@@ -1115,7 +1129,8 @@ const zhCN = {
1115
1129
  toastDeleteFailed: "无法删除页面",
1116
1130
  resizeRail: "调整缩略图栏宽度",
1117
1131
  transitionIndicator: "有换页转场",
1118
- stepsIndicator: "有逐步揭示"
1132
+ stepsIndicator: "有逐步揭示",
1133
+ overviewAria: "幻灯片总览 (O)"
1119
1134
  },
1120
1135
  pdfToast: {
1121
1136
  title: "导出 PDF",
@@ -1217,6 +1232,10 @@ const zhTW = {
1217
1232
  newFolder: "新增資料夾",
1218
1233
  folderName: "資料夾名稱",
1219
1234
  updateAvailable: "open-slide {version} 已發布,請更新套件以取得最新版本。",
1235
+ updatePackage: "更新",
1236
+ updatingPackage: "更新中",
1237
+ updatePackageDone: "已更新。請重新啟動 dev server 以使用新版本。",
1238
+ updatePackageFailed: "更新失敗,請查看 dev server 輸出。",
1220
1239
  changeIcon: "變更圖示",
1221
1240
  iconEmojiTab: "Emoji",
1222
1241
  iconColorTab: "顏色",
@@ -1507,7 +1526,8 @@ const zhTW = {
1507
1526
  toastDeleteFailed: "無法刪除頁面",
1508
1527
  resizeRail: "調整縮圖欄寬度",
1509
1528
  transitionIndicator: "有換頁轉場",
1510
- stepsIndicator: "有逐步揭示"
1529
+ stepsIndicator: "有逐步揭示",
1530
+ overviewAria: "投影片總覽 (O)"
1511
1531
  },
1512
1532
  pdfToast: {
1513
1533
  title: "匯出 PDF",
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Locale, Plural } from "./types-D_q_ylIe.js";
2
- import { OpenSlideConfig } from "./config-14qk4fP8.js";
1
+ import { Locale, Plural } from "./types-uNHQlioH.js";
2
+ import { OpenSlideConfig } from "./config-C2C3cut3.js";
3
3
  import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
  import * as react_jsx_runtime3 from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { en, ja, zhCN, zhTW } from "./format-BvBmqbNW.js";
1
+ import { en, ja, zhCN, zhTW } from "./format-zplQGJPI.js";
2
2
  import { cssVarsToString, defaultDesign, designToCssVars } from "./design-cpzS8aud.js";
3
3
  import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { toast } from "sonner";
@@ -1,4 +1,4 @@
1
- import { Locale, Plural } from "../types-D_q_ylIe.js";
1
+ import { Locale, Plural } from "../types-uNHQlioH.js";
2
2
 
3
3
  //#region src/locale/en.d.ts
4
4
  declare const en: Locale;
@@ -1,3 +1,3 @@
1
- import { en, format, ja, plural, zhCN, zhTW } from "../format-BvBmqbNW.js";
1
+ import { en, format, ja, plural, zhCN, zhTW } from "../format-zplQGJPI.js";
2
2
 
3
3
  export { en, format, ja, plural, zhCN, zhTW };
@@ -1,5 +1,5 @@
1
1
  import "./design-cpzS8aud.js";
2
- import { createViteConfig } from "./config-Bk2i4eJ1.js";
2
+ import { createViteConfig } from "./config-OT4T-im0.js";
3
3
  import { mergeConfig, preview as preview$1 } from "vite";
4
4
 
5
5
  //#region src/cli/preview.ts
@@ -45,6 +45,10 @@ type Locale = {
45
45
  newFolder: string;
46
46
  folderName: string;
47
47
  updateAvailable: string;
48
+ updatePackage: string;
49
+ updatingPackage: string;
50
+ updatePackageDone: string;
51
+ updatePackageFailed: string;
48
52
  changeIcon: string;
49
53
  iconEmojiTab: string;
50
54
  iconColorTab: string;
@@ -359,6 +363,7 @@ type Locale = {
359
363
  resizeRail: string;
360
364
  transitionIndicator: string;
361
365
  stepsIndicator: string;
366
+ overviewAria: string;
362
367
  };
363
368
  pdfToast: {
364
369
  title: string;
@@ -1,5 +1,5 @@
1
- import "../types-D_q_ylIe.js";
2
- import { OpenSlideConfig } from "../config-14qk4fP8.js";
1
+ import "../types-uNHQlioH.js";
2
+ import { OpenSlideConfig } from "../config-C2C3cut3.js";
3
3
  import { InlineConfig } from "vite";
4
4
 
5
5
  //#region src/vite/config.d.ts
@@ -1,4 +1,4 @@
1
1
  import "../design-cpzS8aud.js";
2
- import { createViteConfig } from "../config-Bk2i4eJ1.js";
2
+ import { createViteConfig } from "../config-OT4T-im0.js";
3
3
 
4
4
  export { createViteConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-slide/core",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -121,6 +121,26 @@ Pick a coherent look and hold it across every page:
121
121
 
122
122
  Consult the `frontend-design` skill for deeper aesthetic guidance if the user wants something bold.
123
123
 
124
+ ## Webfonts
125
+
126
+ The default is a system font stack — prefer it. When a deck genuinely needs a webfont (a brand font, or CJK / Thai / Arabic where system coverage is poor):
127
+
128
+ - **Load the stylesheet once, in `<head>` — never inside a per-page component.** Every page is mounted live at the same time (thumbnail rail, overview grid, and the PDF print root), so a `<style>@import>` / `<link>` rendered inside a `Page` registers the whole `@font-face` set once *per page*. Inject it once, idempotently:
129
+
130
+ ```tsx
131
+ const FONT_HREF = 'https://fonts.googleapis.com/css2?family=...&display=swap';
132
+ if (typeof document !== 'undefined' && !document.getElementById('osd-webfont')) {
133
+ const link = document.createElement('link');
134
+ link.id = 'osd-webfont';
135
+ link.rel = 'stylesheet';
136
+ link.href = FONT_HREF;
137
+ document.head.appendChild(link);
138
+ }
139
+ ```
140
+
141
+ - **List only the weights you actually use.** Each extra weight multiplies the number of `@font-face` rules.
142
+ - **CJK fonts are large.** A Google Fonts CJK family registers hundreds of `unicode-range` subset faces (Noto Sans TC ≈ 105 subsets × each weight), and PDF export waits on fonts before printing. If the deck's text is fixed, add `&text=<unique chars>` to the URL to request a tiny single-face subset instead of the full set.
143
+
124
144
  ## Themes
125
145
 
126
146
  If `themes/<id>.md` exists at the project root and the slide is meant to follow it, **the theme file overrides the defaults in this skill** — its palette, typography, layout padding, and Title/Footer components are authoritative. Read the theme file before applying anything else in this section.
@@ -1,15 +1,18 @@
1
+ import { X } from 'lucide-react';
1
2
  import { useEffect, useRef, useState } from 'react';
2
3
  import { format, useLocale } from '@/lib/use-locale';
3
4
  import { cn } from '@/lib/utils';
4
- import type { DesignSystem } from '../../lib/design';
5
- import { SlidePageProvider } from '../../lib/page-context';
6
- import type { Page } from '../../lib/sdk';
7
- import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../../lib/sdk';
8
- import { SlideCanvas } from '../slide-canvas';
5
+ import type { DesignSystem } from '../lib/design';
6
+ import { SlidePageProvider } from '../lib/page-context';
7
+ import type { Page } from '../lib/sdk';
8
+ import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../lib/sdk';
9
+ import { SlideCanvas } from './slide-canvas';
9
10
 
10
11
  const THUMB_W = 320;
11
12
  const THUMB_H = (THUMB_W * CANVAS_HEIGHT) / CANVAS_WIDTH;
12
13
 
14
+ export type OverviewVariant = 'present' | 'editor';
15
+
13
16
  type Props = {
14
17
  pages: Page[];
15
18
  design?: DesignSystem;
@@ -17,9 +20,18 @@ type Props = {
17
20
  current: number;
18
21
  onClose: () => void;
19
22
  onSelect: (index: number) => void;
23
+ variant?: OverviewVariant;
20
24
  };
21
25
 
22
- export function PresentOverviewGrid({ pages, design, open, current, onClose, onSelect }: Props) {
26
+ export function OverviewGrid({
27
+ pages,
28
+ design,
29
+ open,
30
+ current,
31
+ onClose,
32
+ onSelect,
33
+ variant = 'present',
34
+ }: Props) {
23
35
  const [focused, setFocused] = useState(current);
24
36
  const gridRef = useRef<HTMLDivElement>(null);
25
37
  const focusedRef = useRef<HTMLButtonElement | null>(null);
@@ -82,18 +94,34 @@ export function PresentOverviewGrid({ pages, design, open, current, onClose, onS
82
94
  }, [open, pages.length, focused, onClose, onSelect]);
83
95
 
84
96
  if (!open) return null;
97
+
98
+ const styles = variant === 'present' ? presentStyles : editorStyles;
99
+
85
100
  return (
86
101
  <div
87
102
  role="dialog"
88
103
  aria-modal="true"
89
104
  aria-label={t.present.overviewDialogAria}
90
- className="absolute inset-0 z-50 flex flex-col bg-black/95 backdrop-blur-sm"
105
+ className={cn('absolute inset-0 z-50 flex flex-col backdrop-blur-sm', styles.surface)}
91
106
  >
92
- <div className="flex shrink-0 items-baseline justify-between px-8 pt-6 pb-3">
93
- <span className="eyebrow text-white/55">{t.present.overviewEyebrow}</span>
94
- <span className="font-mono text-[11px] text-white/55 tabular-nums">
95
- {(focused + 1).toString().padStart(2, '0')} · {pages.length.toString().padStart(2, '0')}
96
- </span>
107
+ <div className="flex shrink-0 items-center justify-between px-8 pt-6 pb-3">
108
+ <span className={cn('eyebrow', styles.eyebrow)}>{t.present.overviewEyebrow}</span>
109
+ <div className="flex items-center gap-3">
110
+ <span className={cn('font-mono text-[11px] tabular-nums', styles.eyebrow)}>
111
+ {(focused + 1).toString().padStart(2, '0')} · {pages.length.toString().padStart(2, '0')}
112
+ </span>
113
+ <button
114
+ type="button"
115
+ onClick={onClose}
116
+ aria-label={t.common.close}
117
+ className={cn(
118
+ 'flex size-6 items-center justify-center rounded-[4px] outline-none transition-colors',
119
+ styles.closeButton,
120
+ )}
121
+ >
122
+ <X className="size-3.5" />
123
+ </button>
124
+ </div>
97
125
  </div>
98
126
  <div ref={gridRef} className="min-h-0 flex-1 overflow-auto px-8 pb-8">
99
127
  <div
@@ -120,13 +148,14 @@ export function PresentOverviewGrid({ pages, design, open, current, onClose, onS
120
148
  aria-current={isCurrent ? 'true' : undefined}
121
149
  className={cn(
122
150
  'group/thumb flex flex-col items-start gap-2 rounded-[6px] p-1.5 outline-none transition-colors',
123
- isFocused ? 'bg-white/10' : 'hover:bg-white/5',
151
+ isFocused ? styles.thumbFocused : styles.thumbHover,
124
152
  )}
125
153
  >
126
154
  <div
127
155
  className={cn(
128
- 'relative w-full overflow-hidden rounded-[4px] bg-black ring-1 ring-white/10 transition-shadow',
129
- isFocused && 'ring-2 ring-[var(--brand,#ef4444)]',
156
+ 'relative w-full overflow-hidden rounded-[4px] ring-1 transition-shadow',
157
+ styles.thumbSurface,
158
+ isFocused ? 'ring-2 ring-[var(--brand,#ef4444)]' : styles.thumbRing,
130
159
  )}
131
160
  style={{ height: THUMB_H }}
132
161
  >
@@ -153,7 +182,7 @@ export function PresentOverviewGrid({ pages, design, open, current, onClose, onS
153
182
  <span
154
183
  className={cn(
155
184
  'font-mono text-[10.5px] tracking-[0.08em] tabular-nums uppercase',
156
- isFocused || isCurrent ? 'text-white/85' : 'text-white/45',
185
+ isFocused || isCurrent ? styles.labelActive : styles.labelMuted,
157
186
  )}
158
187
  >
159
188
  {(i + 1).toString().padStart(2, '0')}
@@ -167,6 +196,32 @@ export function PresentOverviewGrid({ pages, design, open, current, onClose, onS
167
196
  );
168
197
  }
169
198
 
199
+ const presentStyles = {
200
+ surface: 'bg-black/95',
201
+ eyebrow: 'text-white/55',
202
+ thumbFocused: 'bg-white/10',
203
+ thumbHover: 'hover:bg-white/5',
204
+ thumbSurface: 'bg-black',
205
+ thumbRing: 'ring-white/10',
206
+ labelActive: 'text-white/85',
207
+ labelMuted: 'text-white/45',
208
+ closeButton:
209
+ 'text-white/55 hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white/40',
210
+ } as const;
211
+
212
+ const editorStyles = {
213
+ surface: 'bg-background/95',
214
+ eyebrow: 'text-muted-foreground',
215
+ thumbFocused: 'bg-muted',
216
+ thumbHover: 'hover:bg-muted/60',
217
+ thumbSurface: 'bg-card',
218
+ thumbRing: 'ring-hairline',
219
+ labelActive: 'text-foreground',
220
+ labelMuted: 'text-muted-foreground/60',
221
+ closeButton:
222
+ 'text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring',
223
+ } as const;
224
+
170
225
  function computeCols(grid: HTMLDivElement | null) {
171
226
  if (!grid) return 4;
172
227
  const inner = grid.firstElementChild as HTMLElement | null;
@@ -7,12 +7,12 @@ import type { Page } from '../lib/sdk';
7
7
  import type { EntryDirection, StepAggregate, StepController } from '../lib/step-context';
8
8
  import type { SlideTransition } from '../lib/transition';
9
9
  import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
10
+ import { OverviewGrid } from './overview-grid';
10
11
  import { PresentBlackoutOverlay } from './present/blackout-overlay';
11
12
  import { PresentControlBar } from './present/control-bar';
12
13
  import { PresentHelpOverlay } from './present/help-overlay';
13
14
  import { PresentJumpInput } from './present/jump-input';
14
15
  import { PresentLaserPointer } from './present/laser-pointer';
15
- import { PresentOverviewGrid } from './present/overview-grid';
16
16
  import { PresentProgressBar } from './present/progress-bar';
17
17
  import { useIdle } from './present/use-idle';
18
18
  import { usePointerNearBottom } from './present/use-pointer-near-bottom';
@@ -380,13 +380,14 @@ export function Player({
380
380
  onHelp={() => setHelpOpen(true)}
381
381
  onExit={onExit}
382
382
  />
383
- <PresentOverviewGrid
383
+ <OverviewGrid
384
384
  pages={pages}
385
385
  design={design}
386
386
  open={overviewOpen}
387
387
  current={index}
388
388
  onClose={() => setOverviewOpen(false)}
389
389
  onSelect={handleIndexChange}
390
+ variant="present"
390
391
  />
391
392
  <PresentHelpOverlay open={helpOpen} onOpenChange={setHelpOpen} container={rootEl} />
392
393
  </div>
@@ -1,13 +1,18 @@
1
1
  import config from 'virtual:open-slide/config';
2
+ import { Loader2, RefreshCw } from 'lucide-react';
2
3
  import { useEffect, useState } from 'react';
4
+ import { toast } from 'sonner';
5
+ import { Button } from '@/components/ui/button';
3
6
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
4
7
  import { format, useLocale } from '@/lib/use-locale';
5
8
 
6
9
  type UpdateCheck = { current: string; latest: string | null; outdated: boolean };
10
+ type UpdateStatus = 'idle' | 'running' | 'done' | 'error';
7
11
 
8
12
  export function SidebarFooter() {
9
13
  const t = useLocale();
10
14
  const [update, setUpdate] = useState<UpdateCheck | null>(null);
15
+ const [updateStatus, setUpdateStatus] = useState<UpdateStatus>('idle');
11
16
 
12
17
  useEffect(() => {
13
18
  if (!import.meta.env.DEV) return;
@@ -24,9 +29,24 @@ export function SidebarFooter() {
24
29
  }, []);
25
30
 
26
31
  const label = `v${config.version}`;
32
+ const isUpdating = updateStatus === 'running';
33
+
34
+ async function updatePackage() {
35
+ if (isUpdating) return;
36
+ setUpdateStatus('running');
37
+ try {
38
+ const res = await fetch('/__update-package', { method: 'POST' });
39
+ if (!res.ok) throw new Error('update failed');
40
+ setUpdateStatus('done');
41
+ toast.success(t.home.updatePackageDone);
42
+ } catch {
43
+ setUpdateStatus('error');
44
+ toast.error(t.home.updatePackageFailed);
45
+ }
46
+ }
27
47
 
28
48
  const versionRow = (
29
- <span className="inline-flex items-center gap-1.5">
49
+ <span className="inline-flex cursor-default items-center gap-1.5">
30
50
  {update?.latest && <span className="size-1.5 rounded-full bg-brand" aria-hidden />}
31
51
  {label}
32
52
  </span>
@@ -38,8 +58,42 @@ export function SidebarFooter() {
38
58
  <TooltipProvider delayDuration={200}>
39
59
  <Tooltip>
40
60
  <TooltipTrigger asChild>{versionRow}</TooltipTrigger>
41
- <TooltipContent side="top" sideOffset={6} className="max-w-56">
42
- {format(t.home.updateAvailable, { version: update.latest })}
61
+ <TooltipContent
62
+ side="top"
63
+ align="start"
64
+ alignOffset={-8}
65
+ sideOffset={9}
66
+ collisionPadding={12}
67
+ className="flex w-[232px] max-w-[calc(100vw-24px)] flex-col gap-2.5 rounded-[8px] border border-background/10 bg-foreground/95 p-2.5 text-[11.5px] leading-4 shadow-[0_12px_32px_oklch(0_0_0/0.28)] backdrop-blur"
68
+ >
69
+ <span className="pr-1 text-background/92">
70
+ {format(t.home.updateAvailable, { version: update.latest })}
71
+ </span>
72
+ <Button
73
+ type="button"
74
+ size="xs"
75
+ variant="secondary"
76
+ className="h-6 w-fit rounded-[5px] border border-background/15 bg-background/8 px-2 text-[11px] text-background shadow-none hover:bg-background/14"
77
+ disabled={isUpdating || updateStatus === 'done'}
78
+ onClick={updatePackage}
79
+ >
80
+ {isUpdating ? (
81
+ <Loader2 className="animate-spin" aria-hidden />
82
+ ) : (
83
+ <RefreshCw aria-hidden />
84
+ )}
85
+ {isUpdating ? t.home.updatingPackage : t.home.updatePackage}
86
+ </Button>
87
+ {updateStatus === 'done' && (
88
+ <span className="text-[11px] leading-4 text-background/65">
89
+ {t.home.updatePackageDone}
90
+ </span>
91
+ )}
92
+ {updateStatus === 'error' && (
93
+ <span className="text-[11px] leading-4 text-background/65">
94
+ {t.home.updatePackageFailed}
95
+ </span>
96
+ )}
43
97
  </TooltipContent>
44
98
  </Tooltip>
45
99
  </TooltipProvider>
@@ -15,7 +15,7 @@ import {
15
15
  verticalListSortingStrategy,
16
16
  } from '@dnd-kit/sortable';
17
17
  import { CSS } from '@dnd-kit/utilities';
18
- import { Copy, ListOrdered, type LucideIcon, Sparkles, Trash2 } from 'lucide-react';
18
+ import { Copy, Grid2x2, ListOrdered, type LucideIcon, Sparkles, Trash2 } from 'lucide-react';
19
19
  import { Fragment, useEffect, useRef, useState } from 'react';
20
20
  import {
21
21
  ContextMenu,
@@ -54,6 +54,8 @@ type Props = {
54
54
  width?: number;
55
55
  /** Deck-level transition default; used to flag pages that inherit a transition. */
56
56
  moduleTransition?: SlideTransition;
57
+ /** When provided, the vertical rail header renders a button that opens the overview grid. */
58
+ onOverview?: () => void;
57
59
  };
58
60
 
59
61
  const DEFAULT_VERTICAL_THUMB_WIDTH = 184;
@@ -71,6 +73,7 @@ export function ThumbnailRail({
71
73
  orientation = 'vertical',
72
74
  width,
73
75
  moduleTransition,
76
+ onOverview,
74
77
  }: Props) {
75
78
  const activeRef = useRef<HTMLButtonElement | null>(null);
76
79
  const t = useLocale();
@@ -214,10 +217,35 @@ export function ThumbnailRail({
214
217
  };
215
218
 
216
219
  const list = (
217
- <aside className="flex flex-col gap-2 px-3 py-3">
218
- <div className="flex items-baseline justify-between px-1 pb-1">
219
- <span className="eyebrow">{t.thumbnailRail.pages}</span>
220
- <span className="folio">{pages.length.toString().padStart(2, '0')}</span>
220
+ <aside className="flex flex-col gap-2 px-3 pb-3">
221
+ <div className="-mx-3 sticky top-0 z-10 bg-sidebar px-4 pt-3 pb-1">
222
+ <div className="flex items-center justify-between gap-2">
223
+ <span className="eyebrow">{t.thumbnailRail.pages}</span>
224
+ <div className="flex items-center gap-1.5">
225
+ <span className="folio">{pages.length.toString().padStart(2, '0')}</span>
226
+ {onOverview && (
227
+ <Tooltip>
228
+ <TooltipTrigger asChild>
229
+ <button
230
+ type="button"
231
+ onClick={onOverview}
232
+ aria-label={t.thumbnailRail.overviewAria}
233
+ className={cn(
234
+ 'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
235
+ 'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
236
+ 'focus-visible:ring-1 focus-visible:ring-brand',
237
+ )}
238
+ >
239
+ <Grid2x2 className="size-3.5" strokeWidth={1.75} />
240
+ </button>
241
+ </TooltipTrigger>
242
+ <TooltipContent side="bottom" sideOffset={6}>
243
+ {t.thumbnailRail.overviewAria}
244
+ </TooltipContent>
245
+ </Tooltip>
246
+ )}
247
+ </div>
248
+ </div>
221
249
  </div>
222
250
  {pages.map(renderThumb)}
223
251
  </aside>
@@ -226,14 +254,16 @@ export function ThumbnailRail({
226
254
  if (!onReorder) {
227
255
  return (
228
256
  <TooltipProvider delayDuration={200}>
229
- <ScrollArea className="h-full border-r border-hairline bg-sidebar">{list}</ScrollArea>
257
+ <ScrollArea className="h-full border-r border-hairline bg-sidebar [&_[data-slot=scroll-area-scrollbar]]:z-20">
258
+ {list}
259
+ </ScrollArea>
230
260
  </TooltipProvider>
231
261
  );
232
262
  }
233
263
 
234
264
  return (
235
265
  <TooltipProvider delayDuration={200}>
236
- <ScrollArea className="h-full border-r border-hairline bg-sidebar">
266
+ <ScrollArea className="h-full border-r border-hairline bg-sidebar [&_[data-slot=scroll-area-scrollbar]]:z-20">
237
267
  <SortableRail pages={pages} onReorder={onReorder} onSelect={onSelect}>
238
268
  {list}
239
269
  </SortableRail>
@@ -0,0 +1,32 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { waitForFonts } from './print-ready';
3
+
4
+ afterEach(() => {
5
+ vi.unstubAllGlobals();
6
+ });
7
+
8
+ describe('waitForFonts', () => {
9
+ it('awaits document.fonts.ready without force-loading any face', async () => {
10
+ const load = vi.fn();
11
+ const faces = [
12
+ { status: 'loaded', load },
13
+ { status: 'unloaded', load },
14
+ { status: 'unloaded', load },
15
+ ];
16
+ const fonts = {
17
+ ready: Promise.resolve(),
18
+ [Symbol.iterator]: () => faces[Symbol.iterator](),
19
+ };
20
+ vi.stubGlobal('document', { fonts });
21
+
22
+ await waitForFonts();
23
+
24
+ expect(load).not.toHaveBeenCalled();
25
+ });
26
+
27
+ it('resolves when the FontFaceSet API is unavailable', async () => {
28
+ vi.stubGlobal('document', {});
29
+
30
+ await expect(waitForFonts()).resolves.toBeUndefined();
31
+ });
32
+ });
@@ -1,15 +1,12 @@
1
1
  const DEFAULT_WAITFOR_TIMEOUT_MS = 10_000;
2
2
 
3
+ // `document.fonts.ready` already waits for every in-flight face. Never call
4
+ // `face.load()` on the rest: unloaded faces were never requested by CSS, and
5
+ // `load()` ignores `unicode-range`, so a subsetted CJK family (hundreds of
6
+ // faces) would be force-downloaded in full and hang or crash the tab.
3
7
  export async function waitForFonts(): Promise<void> {
4
8
  if (!('fonts' in document)) return;
5
9
  await document.fonts.ready;
6
- const pending: Promise<unknown>[] = [];
7
- for (const face of document.fonts) {
8
- if (face.status !== 'loaded') pending.push(face.load());
9
- }
10
- if (pending.length) {
11
- await Promise.all(pending.map((p) => p.catch(() => undefined)));
12
- }
13
10
  }
14
11
 
15
12
  export async function waitForDataWaitfor(
@@ -49,6 +49,7 @@ import { format, useLocale } from '@/lib/use-locale';
49
49
  import { useWheelPageNavigation } from '@/lib/use-wheel-page-navigation';
50
50
  import { cn } from '@/lib/utils';
51
51
  import { NotesDrawer } from '../components/notes-drawer';
52
+ import { OverviewGrid } from '../components/overview-grid';
52
53
  import { PdfProgressToast } from '../components/pdf-progress-toast';
53
54
  import { openPresenterWindow, Player } from '../components/player';
54
55
  import { PptxProgressToast } from '../components/pptx-progress-toast';
@@ -74,6 +75,7 @@ export function Slide() {
74
75
  const [linkCopied, setLinkCopied] = useState(false);
75
76
  const linkCopiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
76
77
  const [designOpen, setDesignOpen] = useState(false);
78
+ const [overviewOpen, setOverviewOpen] = useState(false);
77
79
 
78
80
  useEffect(() => {
79
81
  return () => {
@@ -237,6 +239,18 @@ export function Slide() {
237
239
  if (playMode) return;
238
240
  const onKey = (e: KeyboardEvent) => {
239
241
  if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
242
+ // Letter shortcuts only fire bare so browser combos (Cmd/Ctrl-P, ⌘F…) stay intact.
243
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
244
+ // Toggle overview from either state — the overview's own capture-phase
245
+ // handler doesn't consume O, so this stays consistent open ↔ closed.
246
+ if (e.key === 'o' || e.key === 'O') {
247
+ e.preventDefault();
248
+ setOverviewOpen((v) => !v);
249
+ return;
250
+ }
251
+ // Once overview owns focus, swallow everything else here — its
252
+ // capture-phase listener drives the focused thumbnail.
253
+ if (overviewOpen) return;
240
254
  if (
241
255
  e.key === 'ArrowRight' ||
242
256
  e.key === 'ArrowDown' ||
@@ -252,8 +266,6 @@ export function Slide() {
252
266
  goTo(index - 1);
253
267
  return;
254
268
  }
255
- // Letter shortcuts only fire bare so browser combos (Cmd/Ctrl-P, ⌘F…) stay intact.
256
- if (e.altKey || e.ctrlKey || e.metaKey) return;
257
269
  if (e.key === 'f' || e.key === 'F') {
258
270
  setPlayMode('fullscreen');
259
271
  } else if (e.key === 'Enter') {
@@ -267,7 +279,7 @@ export function Slide() {
267
279
  };
268
280
  window.addEventListener('keydown', onKey);
269
281
  return () => window.removeEventListener('keydown', onKey);
270
- }, [index, goTo, playMode, slideId]);
282
+ }, [index, goTo, playMode, slideId, overviewOpen]);
271
283
 
272
284
  if (error) {
273
285
  return (
@@ -653,7 +665,7 @@ export function Slide() {
653
665
  </div>
654
666
  ) : (
655
667
  <DesignProvider slideId={slideId}>
656
- <div className="flex min-h-0 flex-1 flex-col">
668
+ <div className="relative flex min-h-0 flex-1 flex-col">
657
669
  <div className="flex min-h-0 flex-1 flex-col md:flex-row">
658
670
  <ResizableRail
659
671
  pages={pages}
@@ -663,6 +675,7 @@ export function Slide() {
663
675
  onReorder={import.meta.env.DEV ? reorderPage : undefined}
664
676
  actions={thumbnailActions}
665
677
  moduleTransition={slide.transition}
678
+ onOverview={() => setOverviewOpen(true)}
666
679
  />
667
680
  <main
668
681
  ref={slideViewportRef}
@@ -716,6 +729,15 @@ export function Slide() {
716
729
  initial={slide.notes?.[index]}
717
730
  />
718
731
  )}
732
+ <OverviewGrid
733
+ pages={pages}
734
+ design={slide.design}
735
+ open={overviewOpen}
736
+ current={index}
737
+ onClose={() => setOverviewOpen(false)}
738
+ onSelect={goTo}
739
+ variant="editor"
740
+ />
719
741
  </div>
720
742
  </DesignProvider>
721
743
  )}
@@ -746,6 +768,7 @@ function ResizableRail(props: {
746
768
  onReorder?: (from: number, to: number) => void;
747
769
  actions?: ThumbnailActions;
748
770
  moduleTransition?: SlideModule['transition'];
771
+ onOverview?: () => void;
749
772
  }) {
750
773
  const t = useLocale();
751
774
  const [width, setWidth] = useState<number>(readStoredRailWidth);
package/src/locale/en.ts CHANGED
@@ -45,6 +45,10 @@ export const en: Locale = {
45
45
  newFolder: 'New folder',
46
46
  folderName: 'Folder name',
47
47
  updateAvailable: 'open-slide {version} is available — update the package to get the latest.',
48
+ updatePackage: 'Update',
49
+ updatingPackage: 'Updating',
50
+ updatePackageDone: 'Updated. Restart the dev server to use the new version.',
51
+ updatePackageFailed: 'Update failed. Check the dev server output.',
48
52
  changeIcon: 'Change icon',
49
53
  iconEmojiTab: 'Emoji',
50
54
  iconColorTab: 'Color',
@@ -345,6 +349,7 @@ export const en: Locale = {
345
349
  resizeRail: 'Resize thumbnail rail',
346
350
  transitionIndicator: 'Has slide transition',
347
351
  stepsIndicator: 'Has step-by-step reveals',
352
+ overviewAria: 'Slide overview (O)',
348
353
  },
349
354
 
350
355
  pdfToast: {
package/src/locale/ja.ts CHANGED
@@ -46,6 +46,10 @@ export const ja: Locale = {
46
46
  folderName: 'フォルダ名',
47
47
  updateAvailable:
48
48
  'open-slide {version} が利用可能です — パッケージを更新して最新版を入手してください。',
49
+ updatePackage: '更新',
50
+ updatingPackage: '更新中',
51
+ updatePackageDone: '更新しました。新しいバージョンを使うには dev server を再起動してください。',
52
+ updatePackageFailed: '更新に失敗しました。dev server の出力を確認してください。',
49
53
  changeIcon: 'アイコンを変更',
50
54
  iconEmojiTab: '絵文字',
51
55
  iconColorTab: 'カラー',
@@ -350,6 +354,7 @@ export const ja: Locale = {
350
354
  resizeRail: 'サムネイル幅を調整',
351
355
  transitionIndicator: 'スライドトランジションあり',
352
356
  stepsIndicator: 'ステップ表示あり',
357
+ overviewAria: 'スライド一覧 (O)',
353
358
  },
354
359
 
355
360
  pdfToast: {
@@ -45,6 +45,10 @@ export type Locale = {
45
45
  newFolder: string;
46
46
  folderName: string;
47
47
  updateAvailable: string;
48
+ updatePackage: string;
49
+ updatingPackage: string;
50
+ updatePackageDone: string;
51
+ updatePackageFailed: string;
48
52
  changeIcon: string;
49
53
  iconEmojiTab: string;
50
54
  iconColorTab: string;
@@ -366,6 +370,7 @@ export type Locale = {
366
370
  resizeRail: string;
367
371
  transitionIndicator: string;
368
372
  stepsIndicator: string;
373
+ overviewAria: string;
369
374
  };
370
375
 
371
376
  pdfToast: {
@@ -45,6 +45,10 @@ export const zhCN: Locale = {
45
45
  newFolder: '新建文件夹',
46
46
  folderName: '文件夹名称',
47
47
  updateAvailable: 'open-slide {version} 已发布,请更新软件包以获取最新版本。',
48
+ updatePackage: '更新',
49
+ updatingPackage: '更新中',
50
+ updatePackageDone: '已更新。请重启 dev server 以使用新版本。',
51
+ updatePackageFailed: '更新失败,请查看 dev server 输出。',
48
52
  changeIcon: '更换图标',
49
53
  iconEmojiTab: 'Emoji',
50
54
  iconColorTab: '颜色',
@@ -343,6 +347,7 @@ export const zhCN: Locale = {
343
347
  resizeRail: '调整缩略图栏宽度',
344
348
  transitionIndicator: '有换页转场',
345
349
  stepsIndicator: '有逐步揭示',
350
+ overviewAria: '幻灯片总览 (O)',
346
351
  },
347
352
 
348
353
  pdfToast: {
@@ -45,6 +45,10 @@ export const zhTW: Locale = {
45
45
  newFolder: '新增資料夾',
46
46
  folderName: '資料夾名稱',
47
47
  updateAvailable: 'open-slide {version} 已發布,請更新套件以取得最新版本。',
48
+ updatePackage: '更新',
49
+ updatingPackage: '更新中',
50
+ updatePackageDone: '已更新。請重新啟動 dev server 以使用新版本。',
51
+ updatePackageFailed: '更新失敗,請查看 dev server 輸出。',
48
52
  changeIcon: '變更圖示',
49
53
  iconEmojiTab: 'Emoji',
50
54
  iconColorTab: '顏色',
@@ -343,6 +347,7 @@ export const zhTW: Locale = {
343
347
  resizeRail: '調整縮圖欄寬度',
344
348
  transitionIndicator: '有換頁轉場',
345
349
  stepsIndicator: '有逐步揭示',
350
+ overviewAria: '投影片總覽 (O)',
346
351
  },
347
352
 
348
353
  pdfToast: {