@open-slide/core 2.0.0-beta.0 → 2.0.0-beta.2

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.
Files changed (46) hide show
  1. package/dist/build-Bzy-qlGc.js +19 -0
  2. package/dist/cli/bin.js +201 -21
  3. package/dist/{config-AtA2Bqtn.d.ts → config-DjWifhaA.d.ts} +1 -1
  4. package/dist/{dev-BChELmc-.js → dev-MXa5Tod4.js} +36 -10
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.js +1 -1
  7. package/dist/locale/index.d.ts +1 -1
  8. package/dist/locale/index.js +1 -1
  9. package/dist/preview-DEpQcKz3.js +24 -0
  10. package/dist/{types-BzPSOxe-.d.ts → types-BWg-Dtbg.d.ts} +1 -2
  11. package/dist/vite/index.d.ts +1 -1
  12. package/dist/vite/index.js +1 -1
  13. package/dist/{zh-tw-BxZ_pYqe.js → zh-tw-DlKyeNX7.js} +4 -8
  14. package/package.json +1 -1
  15. package/skills/slide-authoring/SKILL.md +3 -3
  16. package/skills/slide-authoring/references/morph.md +5 -5
  17. package/skills/slide-authoring/references/transitions.md +38 -37
  18. package/skills/slide-authoring/references/webfonts.md +25 -6
  19. package/src/app/components/command/slide-command-menu.tsx +10 -0
  20. package/src/app/components/slide-transition-layer.tsx +8 -1
  21. package/src/app/lib/export-pptx.ts +122 -193
  22. package/src/app/lib/pptx/color.ts +49 -0
  23. package/src/app/lib/pptx/css.test.ts +172 -0
  24. package/src/app/lib/pptx/css.ts +450 -0
  25. package/src/app/lib/pptx/fonts.ts +145 -0
  26. package/src/app/lib/pptx/images.ts +116 -0
  27. package/src/app/lib/pptx/measure.ts +1299 -0
  28. package/src/app/lib/pptx/ooxml.test.ts +199 -0
  29. package/src/app/lib/pptx/ooxml.ts +470 -0
  30. package/src/app/lib/pptx/raster.ts +189 -0
  31. package/src/app/lib/pptx/render.ts +102 -0
  32. package/src/app/lib/pptx/scene.ts +116 -0
  33. package/src/app/lib/pptx/text-lines.test.ts +82 -0
  34. package/src/app/lib/pptx/text-lines.ts +109 -0
  35. package/src/app/lib/pptx/units.ts +22 -0
  36. package/src/app/lib/transition.test.ts +31 -0
  37. package/src/app/lib/transition.ts +13 -0
  38. package/src/app/routes/slide.tsx +21 -27
  39. package/src/locale/en.ts +1 -3
  40. package/src/locale/ja.ts +1 -3
  41. package/src/locale/types.ts +1 -2
  42. package/src/locale/zh-cn.ts +1 -2
  43. package/src/locale/zh-tw.ts +1 -2
  44. package/dist/build-CfAxF6Dm.js +0 -14
  45. package/dist/preview-CcCQa268.js +0 -14
  46. package/dist/{config-C_VI2EpT.js → config-nbSvY7z_.js} +2 -2
@@ -0,0 +1,19 @@
1
+ import { r as printHeader, t as createCliLogger } from "./cli/bin.js";
2
+ import { t as createViteConfig } from "./config-nbSvY7z_.js";
3
+ import path from "node:path";
4
+ import { build as build$1, mergeConfig } from "vite";
5
+ //#region src/cli/build.ts
6
+ async function build(opts = {}) {
7
+ printHeader("building for production");
8
+ const base = await createViteConfig({
9
+ userCwd: process.cwd(),
10
+ mode: "build"
11
+ });
12
+ const config = mergeConfig(base, {
13
+ customLogger: createCliLogger(),
14
+ build: { ...opts.outDir !== void 0 ? { outDir: path.resolve(process.cwd(), opts.outDir) } : {} }
15
+ });
16
+ await build$1(config);
17
+ }
18
+ //#endregion
19
+ export { build };
package/dist/cli/bin.js CHANGED
@@ -1,12 +1,66 @@
1
1
  #!/usr/bin/env node
2
- import chalk from "chalk";
3
- import { cp, lstat, mkdir, readFile, readdir, readlink, rm, symlink } from "node:fs/promises";
4
2
  import path from "node:path";
5
3
  import * as readline from "node:readline/promises";
6
4
  import { fileURLToPath } from "node:url";
5
+ import chalk from "chalk";
7
6
  import { Command, Option } from "commander";
7
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
8
8
  import { createHash } from "node:crypto";
9
- import { existsSync } from "node:fs";
9
+ import { cp, lstat, mkdir, readFile, readdir, readlink, rm, symlink } from "node:fs/promises";
10
+ import * as readline$1 from "node:readline";
11
+ import { stripVTControlCharacters } from "node:util";
12
+ //#region src/cli/preflight.ts
13
+ const MIGRATION_URL = "https://open-slide.dev/docs/migrate-to-v2";
14
+ const VITE_CONSUMERS = ["@vitejs/plugin-react", "@tailwindcss/vite"];
15
+ function locatePackage(name, fromDir) {
16
+ let dir = fromDir;
17
+ while (true) {
18
+ const candidate = path.join(dir, "node_modules", name);
19
+ const pkgPath = path.join(candidate, "package.json");
20
+ if (existsSync(pkgPath)) {
21
+ let version = "unknown";
22
+ try {
23
+ version = JSON.parse(readFileSync(pkgPath, "utf8")).version ?? version;
24
+ } catch {}
25
+ return {
26
+ dir: realpathSync(candidate),
27
+ version
28
+ };
29
+ }
30
+ const parent = path.dirname(dir);
31
+ if (parent === dir) return null;
32
+ dir = parent;
33
+ }
34
+ }
35
+ function findViteMismatch(coreDir) {
36
+ const coreVite = locatePackage("vite", coreDir);
37
+ if (!coreVite) return null;
38
+ for (const consumer of VITE_CONSUMERS) {
39
+ const consumerPkg = locatePackage(consumer, coreDir);
40
+ if (!consumerPkg) continue;
41
+ const consumerVite = locatePackage("vite", consumerPkg.dir);
42
+ if (!consumerVite || consumerVite.version === coreVite.version) continue;
43
+ return {
44
+ consumer,
45
+ coreVite,
46
+ consumerVite
47
+ };
48
+ }
49
+ return null;
50
+ }
51
+ function formatViteMismatch(mismatch, cwd = process.cwd()) {
52
+ const rel = (dir) => path.relative(cwd, dir) || dir;
53
+ return [
54
+ `${mismatch.consumer} resolves vite@${mismatch.consumerVite.version} (${rel(mismatch.consumerVite.dir)}), but @open-slide/core ships vite@${mismatch.coreVite.version} (${rel(mismatch.coreVite.dir)}).`,
55
+ "A `vite` entry in your package.json (v1 workspaces had one) shadows the copy core depends on. Remove it and reinstall.",
56
+ `Migration guide: ${MIGRATION_URL}`
57
+ ].join("\n");
58
+ }
59
+ function assertViteResolvesToCore() {
60
+ const mismatch = findViteMismatch(realpathSync(path.dirname(fileURLToPath(import.meta.url))));
61
+ if (mismatch) throw new Error(formatViteMismatch(mismatch));
62
+ }
63
+ //#endregion
10
64
  //#region src/cli/sync.ts
11
65
  async function detectSkillsDrift(skillsDir) {
12
66
  if (!existsSync(skillsDir)) return [];
@@ -136,13 +190,133 @@ function printSummary(results, dryRun) {
136
190
  process.stdout.write(chalk.dim(`\n${counts.added} added, ${counts.updated} updated, ${counts.unchanged} unchanged.\n`));
137
191
  }
138
192
  //#endregion
139
- //#region src/cli/run.ts
140
- async function readVersion() {
141
- const here = path.dirname(fileURLToPath(import.meta.url));
142
- const pkgPath = path.resolve(here, "..", "..", "package.json");
143
- const raw = await readFile(pkgPath, "utf8");
144
- return JSON.parse(raw).version;
193
+ //#region src/cli/ui.ts
194
+ const UNICODE = process.platform !== "win32" || Boolean(process.env.WT_SESSION) || process.env.TERM_PROGRAM === "vscode";
195
+ const glyph = {
196
+ bar: UNICODE ? "┃" : "|",
197
+ warn: UNICODE ? "▲" : "!",
198
+ cross: UNICODE ? "✖" : "x"
199
+ };
200
+ function readVersion() {
201
+ let dir = path.dirname(fileURLToPath(import.meta.url));
202
+ while (dir !== path.dirname(dir)) {
203
+ const pkgPath = path.join(dir, "package.json");
204
+ if (existsSync(pkgPath)) {
205
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
206
+ if (pkg.name === "@open-slide/core" && pkg.version) return pkg.version;
207
+ }
208
+ dir = path.dirname(dir);
209
+ }
210
+ return "0.0.0";
211
+ }
212
+ function brand() {
213
+ return chalk.inverse.bold(" open-slide ");
214
+ }
215
+ function printHeader(status) {
216
+ const parts = [brand(), chalk.dim(`v${readVersion()}`)];
217
+ if (status) parts.push(chalk.dim(status));
218
+ process.stdout.write(`\n ${parts.join(" ")}\n\n`);
145
219
  }
220
+ function startupDuration() {
221
+ return `ready in ${Math.round(process.uptime() * 1e3)} ms`;
222
+ }
223
+ function printUrls(urls, host) {
224
+ if (!urls) return;
225
+ const rows = [];
226
+ for (const url of urls.local) rows.push(urlRow("Local", chalk.cyan(url)));
227
+ urls.network.forEach((url, index) => {
228
+ const iface = urls.networkInterfaceNames?.[index];
229
+ rows.push(urlRow("Network", chalk.cyan(url) + (iface ? ` ${chalk.dim(iface)}` : "")));
230
+ });
231
+ if (urls.network.length === 0 && host === void 0) rows.push(urlRow("Network", chalk.dim("use --host to expose")));
232
+ process.stdout.write(`${rows.join("\n")}\n`);
233
+ }
234
+ function urlRow(label, value) {
235
+ return ` ${chalk.dim(glyph.bar)} ${chalk.bold(label.padEnd(8))} ${value}`;
236
+ }
237
+ function shortcutsEnabled() {
238
+ return Boolean(process.stdin.isTTY) && !process.env.CI;
239
+ }
240
+ function printShortcutsHint() {
241
+ process.stdout.write(`\n ${chalk.dim("press")} ${chalk.bold("h + enter")} ${chalk.dim("for shortcuts")}\n`);
242
+ }
243
+ function formatError(message) {
244
+ return `\n ${chalk.red(glyph.cross)} ${message}\n`;
245
+ }
246
+ const DROPPED = [/^vite v\d+\.\d+\.\d+ building /];
247
+ const REWRITES = [
248
+ [/hmr update /, "updated "],
249
+ [/hmr invalidate /, "invalidated "],
250
+ [/trigger page reload /, "full reload "],
251
+ [/page reload/, "full reload"],
252
+ [/server restarted\./, "server restarted"],
253
+ [/optimized dependencies changed\. reloading/, "dependencies changed, reloading"],
254
+ [/Re-optimizing dependencies because vite config has changed/, "config changed, re-bundling"],
255
+ [/Re-optimizing dependencies because lockfile has changed/, "lockfile changed, re-bundling"],
256
+ [/Forced re-optimization of dependencies/, "re-bundling dependencies"],
257
+ [/\[plugin builtin:vite-[a-z-]+\] ?\n?/, ""],
258
+ [/\[vite\] ?/g, ""]
259
+ ];
260
+ function rewriteViteMessage(msg) {
261
+ const plain = stripVTControlCharacters(msg);
262
+ if (DROPPED.some((re) => re.test(plain))) return null;
263
+ let out = msg;
264
+ for (const [re, replacement] of REWRITES) out = out.replace(re, replacement);
265
+ return out;
266
+ }
267
+ function timestamp() {
268
+ return (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hourCycle: "h23" });
269
+ }
270
+ function formatLine(type, text, opts) {
271
+ if (!opts?.timestamp) return text;
272
+ const mark = type === "warn" ? `${chalk.yellow(glyph.warn)} ` : type === "error" ? `${chalk.red(glyph.cross)} ` : "";
273
+ return ` ${chalk.dim(timestamp())} ${mark}${text}`;
274
+ }
275
+ function clearTerminal() {
276
+ if (!process.stdout.isTTY || process.env.CI) return;
277
+ const blank = "\n".repeat(Math.max(process.stdout.rows - 2, 0));
278
+ console.log(blank);
279
+ readline$1.cursorTo(process.stdout, 0, 0);
280
+ readline$1.clearScreenDown(process.stdout);
281
+ }
282
+ function createCliLogger() {
283
+ const loggedErrors = /* @__PURE__ */ new WeakSet();
284
+ const warnedOnce = /* @__PURE__ */ new Set();
285
+ const write = (type, msg, opts) => {
286
+ const text = rewriteViteMessage(msg);
287
+ if (text === null) return;
288
+ console[type === "info" ? "log" : type](formatLine(type, text, opts));
289
+ };
290
+ const logger = {
291
+ hasWarned: false,
292
+ info(msg, opts) {
293
+ write("info", msg, opts);
294
+ },
295
+ warn(msg, opts) {
296
+ logger.hasWarned = true;
297
+ write("warn", msg, opts);
298
+ },
299
+ warnOnce(msg, opts) {
300
+ if (warnedOnce.has(msg)) return;
301
+ warnedOnce.add(msg);
302
+ logger.warn(msg, opts);
303
+ },
304
+ error(msg, opts) {
305
+ logger.hasWarned = true;
306
+ if (opts?.error) loggedErrors.add(opts.error);
307
+ write("error", msg, opts);
308
+ },
309
+ clearScreen() {
310
+ clearTerminal();
311
+ },
312
+ hasErrorLogged(error) {
313
+ return loggedErrors.has(error);
314
+ }
315
+ };
316
+ return logger;
317
+ }
318
+ //#endregion
319
+ //#region src/cli/run.ts
146
320
  function parsePort(value) {
147
321
  const n = Number(value);
148
322
  if (!Number.isInteger(n) || n < 0 || n > 65535) throw new Error(`Invalid port: ${value}`);
@@ -159,8 +333,10 @@ async function runSkillsDriftCheck(skillsDir) {
159
333
  const stale = drift.filter((d) => d.status !== "unchanged");
160
334
  if (stale.length === 0) return;
161
335
  const names = stale.map((d) => d.name).join(", ");
162
- if (!Boolean(process.stdin.isTTY && process.stdout.isTTY)) {
163
- process.stderr.write(`${chalk.yellow("!")} Skills out of date (${names}). Run \`open-slide sync:skills\` to update.\n`);
336
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
337
+ const notice = `${chalk.yellow(glyph.warn)} Built-in skills are out of date: ${chalk.bold(names)}`;
338
+ if (!interactive) {
339
+ process.stderr.write(`\n ${notice}\n ${chalk.dim("Run `open-slide sync:skills` to update.")}\n`);
164
340
  return;
165
341
  }
166
342
  const rl = readline.createInterface({
@@ -168,9 +344,11 @@ async function runSkillsDriftCheck(skillsDir) {
168
344
  output: process.stdout
169
345
  });
170
346
  try {
171
- const answer = (await rl.question(`${chalk.yellow("!")} Skills out of date: ${chalk.bold(names)}. Sync now? ${chalk.dim("(Y/n) ")}`)).trim().toLowerCase();
172
- if (answer === "" || answer === "y" || answer === "yes") await syncSkills(skillsDir);
173
- else process.stdout.write(chalk.dim("Skipped. Run `open-slide sync:skills` later to update.\n"));
347
+ const answer = (await rl.question(`\n ${notice}\n Sync now? ${chalk.dim("(Y/n)")} `)).trim().toLowerCase();
348
+ if (answer === "" || answer === "y" || answer === "yes") {
349
+ process.stdout.write("\n");
350
+ await syncSkills(skillsDir);
351
+ } else process.stdout.write(chalk.dim(" Skipped. Run `open-slide sync:skills` later to update.\n"));
174
352
  } finally {
175
353
  rl.close();
176
354
  }
@@ -180,20 +358,22 @@ function resolveBuiltinSkillsDir() {
180
358
  return path.resolve(here, "..", "..", "skills");
181
359
  }
182
360
  async function run(argv) {
183
- const version = await readVersion();
184
361
  const program = new Command();
185
- 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)"));
362
+ program.name("open-slide").description("Author slides in React — open-slide runs the rest.").version(readVersion(), "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-slide --help` for usage)"));
186
363
  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) => {
187
364
  if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
188
- const { dev } = await import("../dev-BChELmc-.js");
365
+ assertViteResolvesToCore();
366
+ const { dev } = await import("../dev-MXa5Tod4.js");
189
367
  await dev(flags);
190
368
  });
191
369
  program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
192
- const { build } = await import("../build-CfAxF6Dm.js");
370
+ assertViteResolvesToCore();
371
+ const { build } = await import("../build-Bzy-qlGc.js");
193
372
  await build(flags);
194
373
  });
195
374
  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) => {
196
- const { preview } = await import("../preview-CcCQa268.js");
375
+ assertViteResolvesToCore();
376
+ const { preview } = await import("../preview-DEpQcKz3.js");
197
377
  await preview(flags);
198
378
  });
199
379
  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) => {
@@ -205,8 +385,8 @@ async function run(argv) {
205
385
  //#region src/cli/bin.ts
206
386
  run(process.argv.slice(2)).catch((err) => {
207
387
  const message = err instanceof Error ? err.message : String(err);
208
- process.stderr.write(`${chalk.red("error:")} ${message}\n`);
388
+ process.stderr.write(formatError(message));
209
389
  process.exit(1);
210
390
  });
211
391
  //#endregion
212
- export {};
392
+ export { printUrls as a, printShortcutsHint as i, formatError as n, shortcutsEnabled as o, printHeader as r, startupDuration as s, createCliLogger as t };
@@ -1,4 +1,4 @@
1
- import { t as Locale } from "./types-BzPSOxe-.js";
1
+ import { t as Locale } from "./types-BWg-Dtbg.js";
2
2
  //#region src/config.d.ts
3
3
  type OpenSlideBuildConfig = {
4
4
  showSlideBrowser?: boolean;
@@ -1,5 +1,5 @@
1
- import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-C_VI2EpT.js";
2
- import chalk from "chalk";
1
+ import { a as printUrls, i as printShortcutsHint, n as formatError, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
2
+ import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-nbSvY7z_.js";
3
3
  import path from "node:path";
4
4
  import { existsSync } from "node:fs";
5
5
  import { fork } from "node:child_process";
@@ -14,21 +14,47 @@ async function dev(opts = {}) {
14
14
  }
15
15
  async function startServer(opts) {
16
16
  const base = await createViteConfig({ userCwd: process.cwd() });
17
- const config = mergeConfig(base, { server: {
18
- ...opts.port !== void 0 ? { port: opts.port } : {},
19
- ...opts.host !== void 0 ? { host: opts.host } : {},
20
- ...opts.open !== void 0 ? { open: opts.open } : {}
21
- } });
17
+ const config = mergeConfig(base, {
18
+ customLogger: createCliLogger(),
19
+ server: {
20
+ ...opts.port !== void 0 ? { port: opts.port } : {},
21
+ ...opts.host !== void 0 ? { host: opts.host } : {},
22
+ ...opts.open !== void 0 ? { open: opts.open } : {}
23
+ }
24
+ });
22
25
  const server = await createServer(config);
23
26
  await server.listen();
24
- server.printUrls();
25
- server.bindCLIShortcuts({ print: true });
27
+ printHeader(startupDuration());
28
+ printUrls(server.resolvedUrls, opts.host);
29
+ if (shortcutsEnabled()) {
30
+ printShortcutsHint();
31
+ server.bindCLIShortcuts({ customShortcuts: devShortcuts(opts) });
32
+ }
26
33
  const address = server.httpServer?.address();
27
34
  if (process.send && address && typeof address === "object") process.send({
28
35
  type: "open-slide:listening",
29
36
  port: address.port
30
37
  });
31
38
  }
39
+ function devShortcuts(opts) {
40
+ const showUrls = (server) => {
41
+ console.log("");
42
+ printUrls(server.resolvedUrls, opts.host);
43
+ };
44
+ return [{
45
+ key: "r",
46
+ description: "restart the server",
47
+ async action(server) {
48
+ const before = JSON.stringify(server.resolvedUrls);
49
+ await server.restart();
50
+ if (JSON.stringify(server.resolvedUrls) !== before) showUrls(server);
51
+ }
52
+ }, {
53
+ key: "u",
54
+ description: "show server url",
55
+ action: showUrls
56
+ }];
57
+ }
32
58
  function supervise(opts) {
33
59
  const userCwd = process.cwd();
34
60
  let port = opts.port;
@@ -49,7 +75,7 @@ function supervise(opts) {
49
75
  }
50
76
  });
51
77
  child.on("error", (err) => {
52
- process.stderr.write(`${chalk.red("error:")} ${err.message}\n`);
78
+ process.stderr.write(formatError(err.message));
53
79
  process.exit(1);
54
80
  });
55
81
  child.on("message", (message) => {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as Plural, t as Locale } from "./types-BzPSOxe-.js";
2
- import { t as OpenSlideConfig } from "./config-AtA2Bqtn.js";
1
+ import { n as Plural, t as Locale } from "./types-BWg-Dtbg.js";
2
+ import { t as OpenSlideConfig } from "./config-DjWifhaA.js";
3
3
  import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
4
4
  //#region src/app/components/image-placeholder.d.ts
5
5
  type ImagePlaceholderProps = {
@@ -63,6 +63,7 @@ type SlideTransition = {
63
63
  enter?: TransitionPhase;
64
64
  exit?: TransitionPhase;
65
65
  morph?: boolean | MorphTransition;
66
+ throughBackground?: boolean;
66
67
  };
67
68
  type MorphTransition = {
68
69
  duration?: number;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as en, n as zhCN, r as ja, t as zhTW } from "./zh-tw-BxZ_pYqe.js";
1
+ import { i as en, n as zhCN, r as ja, t as zhTW } from "./zh-tw-DlKyeNX7.js";
2
2
  import { n as defaultDesign, r as designToCssVars, t as cssVarsToString } from "./design-Cpqx7SJs.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 { n as Plural, t as Locale } from "../types-BzPSOxe-.js";
1
+ import { n as Plural, t as Locale } from "../types-BWg-Dtbg.js";
2
2
  //#region src/locale/en.d.ts
3
3
  declare const en: Locale;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { i as en, n as zhCN, r as ja, t as zhTW } from "../zh-tw-BxZ_pYqe.js";
1
+ import { i as en, n as zhCN, r as ja, t as zhTW } from "../zh-tw-DlKyeNX7.js";
2
2
  //#region src/locale/format.ts
3
3
  function format(template, vars) {
4
4
  return template.replace(/\{(\w+)\}/g, (m, key) => {
@@ -0,0 +1,24 @@
1
+ import { a as printUrls, i as printShortcutsHint, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
2
+ import { t as createViteConfig } from "./config-nbSvY7z_.js";
3
+ import { mergeConfig, preview as preview$1 } from "vite";
4
+ //#region src/cli/preview.ts
5
+ async function preview(opts = {}) {
6
+ const base = await createViteConfig({ userCwd: process.cwd() });
7
+ const config = mergeConfig(base, {
8
+ customLogger: createCliLogger(),
9
+ preview: {
10
+ ...opts.port !== void 0 ? { port: opts.port } : {},
11
+ ...opts.host !== void 0 ? { host: opts.host } : {},
12
+ ...opts.open !== void 0 ? { open: opts.open } : {}
13
+ }
14
+ });
15
+ const server = await preview$1(config);
16
+ printHeader(`preview · ${startupDuration()}`);
17
+ printUrls(server.resolvedUrls, opts.host);
18
+ if (shortcutsEnabled()) {
19
+ printShortcutsHint();
20
+ server.bindCLIShortcuts();
21
+ }
22
+ }
23
+ //#endregion
24
+ export { preview };
@@ -114,9 +114,8 @@ type Locale = {
114
114
  exportAsPdf: string;
115
115
  exportAsImagePptx: string;
116
116
  exportAsPptx: string;
117
- comingSoon: string;
118
- pptxComingSoonTooltip: string;
119
117
  pdfExportFailed: string;
118
+ pptxExportFailed: string;
120
119
  imagePptxExportFailed: string;
121
120
  pdfExportSafariUnsupported: string;
122
121
  present: string;
@@ -1,4 +1,4 @@
1
- import { t as OpenSlideConfig } from "../config-AtA2Bqtn.js";
1
+ import { t as OpenSlideConfig } from "../config-DjWifhaA.js";
2
2
  import { InlineConfig } from "vite";
3
3
  //#region src/vite/config.d.ts
4
4
  type CreateViteConfigOptions = {
@@ -1,2 +1,2 @@
1
- import { t as createViteConfig } from "../config-C_VI2EpT.js";
1
+ import { t as createViteConfig } from "../config-nbSvY7z_.js";
2
2
  export { createViteConfig };
@@ -106,9 +106,8 @@ const en = {
106
106
  exportAsPdf: "Export as PDF",
107
107
  exportAsImagePptx: "Export as image PPTX",
108
108
  exportAsPptx: "Export as PPTX",
109
- comingSoon: "Coming soon",
110
- pptxComingSoonTooltip: "Editable PPTX export isn’t ready yet. For now, use “Export as image PPTX” instead.",
111
109
  pdfExportFailed: "PDF export failed",
110
+ pptxExportFailed: "PPTX export failed",
112
111
  imagePptxExportFailed: "PPTX export failed",
113
112
  pdfExportSafariUnsupported: "Export as PDF is not supported on Safari. Please try a Chromium-based browser instead.",
114
113
  present: "Present",
@@ -566,9 +565,8 @@ const ja = {
566
565
  exportAsPdf: "PDF として書き出し",
567
566
  exportAsImagePptx: "画像 PPTX として書き出し",
568
567
  exportAsPptx: "PPTX として書き出し",
569
- comingSoon: "近日公開",
570
- pptxComingSoonTooltip: "編集可能な PPTX の書き出しはまだ対応していません。それまでは「画像 PPTX として書き出し」をご利用ください。",
571
568
  pdfExportFailed: "PDF の書き出しに失敗しました",
569
+ pptxExportFailed: "PPTX の書き出しに失敗しました",
572
570
  imagePptxExportFailed: "PPTX の書き出しに失敗しました",
573
571
  pdfExportSafariUnsupported: "PDF の書き出しは現在 Safari では対応していません。Chromium ベースのブラウザでお試しください。",
574
572
  present: "発表",
@@ -1026,9 +1024,8 @@ const zhCN = {
1026
1024
  exportAsPdf: "导出为 PDF",
1027
1025
  exportAsImagePptx: "导出图片 PPTX",
1028
1026
  exportAsPptx: "导出 PPTX",
1029
- comingSoon: "即将推出",
1030
- pptxComingSoonTooltip: "可编辑的 PPTX 导出尚未支持,在此之前可以先使用“导出图片 PPTX”。",
1031
1027
  pdfExportFailed: "PDF 导出失败",
1028
+ pptxExportFailed: "PPTX 导出失败",
1032
1029
  imagePptxExportFailed: "PPTX 导出失败",
1033
1030
  pdfExportSafariUnsupported: "导出 PDF 目前不支持 Safari 设备,请尝试使用基于 Chromium 的浏览器替代。",
1034
1031
  present: "演示",
@@ -1486,9 +1483,8 @@ const zhTW = {
1486
1483
  exportAsPdf: "匯出為 PDF",
1487
1484
  exportAsImagePptx: "匯出圖片 PPTX",
1488
1485
  exportAsPptx: "匯出 PPTX",
1489
- comingSoon: "即將推出",
1490
- pptxComingSoonTooltip: "可編輯的 PPTX 匯出尚未支援,在此之前可以先使用「匯出圖片 PPTX」。",
1491
1486
  pdfExportFailed: "PDF 匯出失敗",
1487
+ pptxExportFailed: "PPTX 匯出失敗",
1492
1488
  imagePptxExportFailed: "PPTX 匯出失敗",
1493
1489
  pdfExportSafariUnsupported: "匯出 PDF 目前不支援 Safari 裝置,請嘗試用 Chromium 基底瀏覽器替代。",
1494
1490
  present: "簡報",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-slide/core",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -274,7 +274,7 @@ Read `references/steps.md` before authoring a stepped page — it covers composi
274
274
 
275
275
  ## Page transitions
276
276
 
277
- The framework can run an enter/exit animation between slide changes, declared as a `SlideTransition` (module-level default, per-page override; the **incoming page wins**). There's **no default** — pages snap unless you opt in, and snap-swap is a perfectly tasteful default. If you do opt in: one motion DNA per deck, 140–280 ms, magnitude under 12 px / 3% scale, opacity always part of it.
277
+ The framework can run an enter/exit animation between slide changes, declared as a `SlideTransition` (module-level default, per-page override; the **incoming page wins**). There's **no default** — pages snap unless you opt in, and snap-swap is a perfectly tasteful default. If you do opt in: one motion DNA per deck, 200–280 ms, magnitude under 12 px / 3% scale, the outgoing page holds while the incoming page fades in on top (the framework ignores exit opacity unless `throughBackground: true`).
278
278
 
279
279
  Read `references/transitions.md` before declaring one — it has the full type contract, design principles, a six-member "tasteful family" of ready-to-use transitions sharing one DNA, direction-aware keyframes, and the anti-pattern list.
280
280
 
@@ -282,7 +282,7 @@ Read `references/transitions.md` before declaring one — it has the full type c
282
282
 
283
283
  When the *same visual object* exists on two adjacent pages, wrap it on both pages in `MorphElement` with the same `id` and enable `morph` on the incoming page's transition — position, size, radius, and colors interpolate in one continuous move (Keynote's "Magic Move"). Morph is for **state continuity** (a toggle sliding, a card expanding, a box joining a row); don't morph decoration.
284
284
 
285
- Read `references/morph.md` before writing one — the seven rules there (opacity-only enter/exit, deterministic geometry, no `transform` on the morph node, `useIsActivePage()` gating, …) were each earned on a real deck, and violating any of them produces a visibly broken morph.
285
+ Read `references/morph.md` before writing one — the seven rules there (held exit + opacity-only enter, deterministic geometry, no `transform` on the morph node, `useIsActivePage()` gating, …) were each earned on a real deck, and violating any of them produces a visibly broken morph.
286
286
 
287
287
  ## Repeated elements: component, not `map`
288
288
 
@@ -350,7 +350,7 @@ This applies whenever the *visual element* repeats, not whenever the *data* does
350
350
  - [ ] All imported assets exist on disk — slide-local under `slides/<id>/assets/`, or global under `assets/` (imported via `@assets/...`).
351
351
  - [ ] Every `<ImagePlaceholder>` corresponds to a real image the user must supply — not decorative filler. If it could be replaced by typography or layout, it should be.
352
352
  - [ ] If a page uses `<Steps>`/`<Step>`, every `<Step>` is a direct child of a `<Steps>`, and the page still reads as complete when jumped to via the overview grid (entering forward builds up; jumping in shows it fully revealed).
353
- - [ ] If a `SlideTransition` is declared, every page sits in one family — same duration band (140–280 ms), same easing pair, same out-then-in stagger, magnitude under 12 px / 3%. No six-different-vocabularies decks. When in doubt, omit transitions entirely. (Pages that opt into `morph` may exceed the band to match the morph — see `references/morph.md`.)
353
+ - [ ] If a `SlideTransition` is declared, every page sits in one family — same duration band (200–280 ms), same easing pair, same hold-then-fade-in shape (no enter delay, no `throughBackground` outside a deliberate section break), magnitude under 12 px / 3%. No six-different-vocabularies decks. When in doubt, omit transitions entirely. (Pages that opt into `morph` may exceed the band to match the morph — see `references/morph.md`.)
354
354
  - [ ] If a transition opts into `morph`: every morph `id` is unique per page and stable across the pair, morph geometry is pixel-constant (never measured after mount), no `transform` sits on the morph node, and entrance animations are gated behind `useIsActivePage()`.
355
355
  - [ ] If the user asked for a speech script / speaker notes, it lives in `export const notes` (index-aligned with the page array) — not in a markdown or text file.
356
356
  - [ ] Nothing outside `slides/<id>/` was edited.
@@ -11,11 +11,11 @@ When the *same visual object* exists on two adjacent pages, the runtime can morp
11
11
  import { MorphElement, type Page, type SlideTransition } from '@open-slide/core';
12
12
  import type { CSSProperties } from 'react';
13
13
 
14
- // Morph transition — opacity-only enter/exit keeps all the motion on the clones (see rules).
14
+ // Morph transition — a held exit and an opacity-only enter keep all the motion on the clones (see rules).
15
15
  const morphTransition: SlideTransition = {
16
16
  duration: 280,
17
- exit: { duration: 224, easing: 'cubic-bezier(0.4, 0, 1, 1)', keyframes: [{ opacity: 1 }, { opacity: 0 }] },
18
- enter: { duration: 308, delay: 112, easing: 'cubic-bezier(0, 0, 0.2, 1)', keyframes: [{ opacity: 0 }, { opacity: 1 }] },
17
+ exit: { duration: 308, easing: 'cubic-bezier(0.4, 0, 1, 1)', keyframes: [{ opacity: 1 }, { opacity: 1 }] },
18
+ enter: { duration: 308, easing: 'cubic-bezier(0, 0, 0.2, 1)', keyframes: [{ opacity: 0 }, { opacity: 1 }] },
19
19
  morph: { duration: 868, easing: 'cubic-bezier(0.4, 0, 0.2, 1)' },
20
20
  };
21
21
 
@@ -38,7 +38,7 @@ Narrow.transition = morphTransition; // backward: Wide → Narrow morphs it back
38
38
 
39
39
  ## Contract
40
40
 
41
- - `morph: true` inherits the transition's top-level `duration`/`easing`; pass `{ duration?, easing?, delay? }` to time the morph independently of the page cross-fade. Morphs usually read best 2–4× longer than the fade (e.g. 280 ms fade, 868 ms morph). Fade phases on morphing pages may run past the 140–280 ms band in `transitions.md` — they're timed against the longer morph, not the standard cut; the band still binds non-morph pages.
41
+ - `morph: true` inherits the transition's top-level `duration`/`easing`; pass `{ duration?, easing?, delay? }` to time the morph independently of the page cross-fade. Morphs usually read best 2–4× longer than the fade (e.g. 280 ms fade, 868 ms morph). Fade phases on morphing pages may run past the 200–280 ms band in `transitions.md` — they're timed against the longer morph, not the standard cut; the band still binds non-morph pages.
42
42
  - Elements pair by `id` across the cut. A matched pair FLIP-morphs: the runtime measures both rects, clones the outgoing element into an overlay above both pages, hides the originals, and animates transform + border-radius + colors (border widths ride a separate frame so they don't stretch with the box). Keep each `id` unique within a page; don't nest one `MorphElement` inside another.
43
43
  - An `id` present on only one side fades in/out **in place**. This is how "a third box joins the row" reads: carried boxes glide to their new slots, the new one materializes.
44
44
  - Colors on the morph node *and its descendants* interpolate too — a label that flips black → white mid-glide just works.
@@ -46,7 +46,7 @@ Narrow.transition = morphTransition; // backward: Wide → Narrow morphs it back
46
46
 
47
47
  ## Rules — each one earned on a real deck
48
48
 
49
- 1. **Prefer opacity-only enter/exit on morphing pages.** Any transition family composes correctly with the morph (shared rects are measured before the phases start), but while clones glide, a transform-bearing enter also slides the rest of the page — two competing motions. Giving the clones all the motion and fading everything else is what makes a morph read as one confident gesture.
49
+ 1. **Prefer a held exit and an opacity-only enter on morphing pages.** Any transition family composes correctly with the morph (shared rects are measured before the phases start), but while clones glide, a transform-bearing enter also slides the rest of the page — two competing motions. Giving the clones all the motion and fading the incoming page in over the held outgoing page is what makes a morph read as one confident gesture. (Exit opacity is held by the framework anyway — see `transitions.md`; morph originals are hidden with `visibility`, so the held outgoing page never shows a duplicate.)
50
50
  2. **Morph geometry must be deterministic at mount.** Rects are snapshotted once at the cut. Position morph elements with pixel constants — never with a value measured in an effect after mount (the re-render shifts the target mid-morph and the move jumps). If text inside a morph box grows over time (typewriter etc.), render a hidden full-width spacer so the measured box never changes size.
51
51
  3. **No `transform` on the morph node itself.** A percentage translate (`translate(-50%, -50%)`) gets mis-scaled by the morph and lands the clone tens of px off. Put centering/positioning transforms on a plain wrapper `<div>` *around* the `MorphElement`.
52
52
  4. **`MorphElement` merges `className`/`style` onto its single host child** (it adds no wrapper when the child is a lone DOM element). A crop box (`overflow: hidden` + fixed width) therefore needs an explicit nested `<div>` — otherwise the box collapses onto the `<img>` inside and squishes it.