@open-slide/core 1.11.1 → 1.12.1

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) => {
@@ -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,4 +1,4 @@
1
- import { Locale } from "./types-D_q_ylIe.js";
1
+ import { Locale } from "./types-CHmFPIG_.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  type OpenSlideBuildConfig = {
@@ -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",
@@ -95,6 +99,7 @@ const en = {
95
99
  agentDisconnectedTooltip: "Lost connection to the dev server, so your agent can no longer see the current slide or inspector selection. Restart the dev server to restore the connection.",
96
100
  download: "Download",
97
101
  copyLink: "Copy link",
102
+ moreActions: "More actions",
98
103
  toastCopyLinkSuccess: "Link copied to clipboard",
99
104
  toastCopyLinkFailed: "Failed to copy link",
100
105
  exportAsHtml: "Export as HTML",
@@ -331,7 +336,8 @@ const en = {
331
336
  toastDeleteFailed: "Could not delete page",
332
337
  resizeRail: "Resize thumbnail rail",
333
338
  transitionIndicator: "Has slide transition",
334
- stepsIndicator: "Has step-by-step reveals"
339
+ stepsIndicator: "Has step-by-step reveals",
340
+ overviewAria: "Slide overview (O)"
335
341
  },
336
342
  pdfToast: {
337
343
  title: "Exporting PDF",
@@ -433,6 +439,10 @@ const ja = {
433
439
  newFolder: "新規フォルダ",
434
440
  folderName: "フォルダ名",
435
441
  updateAvailable: "open-slide {version} が利用可能です — パッケージを更新して最新版を入手してください。",
442
+ updatePackage: "更新",
443
+ updatingPackage: "更新中",
444
+ updatePackageDone: "更新しました。新しいバージョンを使うには dev server を再起動してください。",
445
+ updatePackageFailed: "更新に失敗しました。dev server の出力を確認してください。",
436
446
  changeIcon: "アイコンを変更",
437
447
  iconEmojiTab: "絵文字",
438
448
  iconColorTab: "カラー",
@@ -487,6 +497,7 @@ const ja = {
487
497
  backToHome: "ホームへ戻る",
488
498
  download: "ダウンロード",
489
499
  copyLink: "リンクをコピー",
500
+ moreActions: "その他の操作",
490
501
  toastCopyLinkSuccess: "リンクをクリップボードにコピーしました",
491
502
  toastCopyLinkFailed: "リンクのコピーに失敗しました",
492
503
  exportAsHtml: "HTML として書き出し",
@@ -723,7 +734,8 @@ const ja = {
723
734
  toastDeleteFailed: "ページを削除できませんでした",
724
735
  resizeRail: "サムネイル幅を調整",
725
736
  transitionIndicator: "スライドトランジションあり",
726
- stepsIndicator: "ステップ表示あり"
737
+ stepsIndicator: "ステップ表示あり",
738
+ overviewAria: "スライド一覧 (O)"
727
739
  },
728
740
  pdfToast: {
729
741
  title: "PDF を書き出し中",
@@ -825,6 +837,10 @@ const zhCN = {
825
837
  newFolder: "新建文件夹",
826
838
  folderName: "文件夹名称",
827
839
  updateAvailable: "open-slide {version} 已发布,请更新软件包以获取最新版本。",
840
+ updatePackage: "更新",
841
+ updatingPackage: "更新中",
842
+ updatePackageDone: "已更新。请重启 dev server 以使用新版本。",
843
+ updatePackageFailed: "更新失败,请查看 dev server 输出。",
828
844
  changeIcon: "更换图标",
829
845
  iconEmojiTab: "Emoji",
830
846
  iconColorTab: "颜色",
@@ -879,6 +895,7 @@ const zhCN = {
879
895
  backToHome: "返回首页",
880
896
  download: "下载",
881
897
  copyLink: "复制链接",
898
+ moreActions: "更多操作",
882
899
  toastCopyLinkSuccess: "已复制链接到剪贴板",
883
900
  toastCopyLinkFailed: "复制链接失败",
884
901
  exportAsHtml: "导出为 HTML",
@@ -1115,7 +1132,8 @@ const zhCN = {
1115
1132
  toastDeleteFailed: "无法删除页面",
1116
1133
  resizeRail: "调整缩略图栏宽度",
1117
1134
  transitionIndicator: "有换页转场",
1118
- stepsIndicator: "有逐步揭示"
1135
+ stepsIndicator: "有逐步揭示",
1136
+ overviewAria: "幻灯片总览 (O)"
1119
1137
  },
1120
1138
  pdfToast: {
1121
1139
  title: "导出 PDF",
@@ -1217,6 +1235,10 @@ const zhTW = {
1217
1235
  newFolder: "新增資料夾",
1218
1236
  folderName: "資料夾名稱",
1219
1237
  updateAvailable: "open-slide {version} 已發布,請更新套件以取得最新版本。",
1238
+ updatePackage: "更新",
1239
+ updatingPackage: "更新中",
1240
+ updatePackageDone: "已更新。請重新啟動 dev server 以使用新版本。",
1241
+ updatePackageFailed: "更新失敗,請查看 dev server 輸出。",
1220
1242
  changeIcon: "變更圖示",
1221
1243
  iconEmojiTab: "Emoji",
1222
1244
  iconColorTab: "顏色",
@@ -1271,6 +1293,7 @@ const zhTW = {
1271
1293
  backToHome: "返回首頁",
1272
1294
  download: "下載",
1273
1295
  copyLink: "複製連結",
1296
+ moreActions: "更多動作",
1274
1297
  toastCopyLinkSuccess: "已複製連結到剪貼簿",
1275
1298
  toastCopyLinkFailed: "複製連結失敗",
1276
1299
  exportAsHtml: "匯出為 HTML",
@@ -1507,7 +1530,8 @@ const zhTW = {
1507
1530
  toastDeleteFailed: "無法刪除頁面",
1508
1531
  resizeRail: "調整縮圖欄寬度",
1509
1532
  transitionIndicator: "有換頁轉場",
1510
- stepsIndicator: "有逐步揭示"
1533
+ stepsIndicator: "有逐步揭示",
1534
+ overviewAria: "投影片總覽 (O)"
1511
1535
  },
1512
1536
  pdfToast: {
1513
1537
  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-CHmFPIG_.js";
2
+ import { OpenSlideConfig } from "./config-x493taft.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-7j0EzhuV.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-CHmFPIG_.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-7j0EzhuV.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;
@@ -103,6 +107,7 @@ type Locale = {
103
107
  agentDisconnectedTooltip: string;
104
108
  download: string;
105
109
  copyLink: string;
110
+ moreActions: string;
106
111
  toastCopyLinkSuccess: string;
107
112
  toastCopyLinkFailed: string;
108
113
  exportAsHtml: string;
@@ -359,6 +364,7 @@ type Locale = {
359
364
  resizeRail: string;
360
365
  transitionIndicator: string;
361
366
  stepsIndicator: string;
367
+ overviewAria: string;
362
368
  };
363
369
  pdfToast: {
364
370
  title: string;
@@ -1,5 +1,5 @@
1
- import "../types-D_q_ylIe.js";
2
- import { OpenSlideConfig } from "../config-14qk4fP8.js";
1
+ import "../types-CHmFPIG_.js";
2
+ import { OpenSlideConfig } from "../config-x493taft.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.1",
4
4
  "description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -70,8 +70,8 @@
70
70
  "chalk": "^5.3.0",
71
71
  "class-variance-authority": "^0.7.1",
72
72
  "clsx": "^2.1.1",
73
- "commander": "^12.1.0",
74
- "emoji-picker-react": "^4.18.0",
73
+ "commander": "^15.0.0",
74
+ "emoji-picker-react": "^4.19.1",
75
75
  "fast-glob": "^3.3.2",
76
76
  "fflate": "^0.8.2",
77
77
  "html-to-image": "^1.11.13",
@@ -81,8 +81,8 @@
81
81
  "react": "^18.3.1",
82
82
  "react-dom": "^18.3.1",
83
83
  "react-image-crop": "^11.0.10",
84
- "react-router-dom": "^6.26.2",
85
- "shadcn": "^4.3.0",
84
+ "react-router-dom": "^7.18.0",
85
+ "shadcn": "^4.11.0",
86
86
  "sonner": "^2.0.7",
87
87
  "tailwind-merge": "^3.5.0",
88
88
  "tailwindcss": "^4.2.2",
@@ -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.
@@ -862,7 +862,11 @@ function AgentWatchingBadge() {
862
862
  {connected ? t.inspector.agentWatching : t.inspector.agentNotWatching}
863
863
  </button>
864
864
  </TooltipTrigger>
865
- <TooltipContent side="bottom" align="end" className="max-w-[260px] leading-relaxed">
865
+ <TooltipContent
866
+ side="bottom"
867
+ align="end"
868
+ className="w-max max-w-[min(520px,calc(100vw-2rem))] text-center leading-relaxed"
869
+ >
866
870
  {connected ? t.inspector.agentWatchingTooltip : t.inspector.agentNotWatchingTooltip}
867
871
  </TooltipContent>
868
872
  </Tooltip>