@open-slide/core 1.15.3 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ export const meta = { title: 'Hello' };
78
78
  import {
79
79
  CANVAS_WIDTH, // 1920
80
80
  CANVAS_HEIGHT, // 1080
81
- unstable_SharedElement, // match or fade objects across pages for shared element transitions
81
+ MorphElement, // match or fade objects across pages for morph transitions
82
82
  type Page,
83
83
  type SlideMeta,
84
84
  type SlideModule,
package/dist/index.d.ts CHANGED
@@ -24,19 +24,19 @@ declare function ImagePlaceholder({
24
24
  }: ImagePlaceholderProps): react_jsx_runtime0.JSX.Element;
25
25
 
26
26
  //#endregion
27
- //#region src/app/components/shared-element.d.ts
28
- type unstable_SharedElementProps = {
27
+ //#region src/app/components/morph-element.d.ts
28
+ type MorphElementProps = {
29
29
  id: string;
30
30
  children: ReactNode;
31
31
  className?: string;
32
32
  style?: CSSProperties;
33
33
  };
34
- declare function unstable_SharedElement({
34
+ declare function MorphElement({
35
35
  id,
36
36
  children,
37
37
  className,
38
38
  style
39
- }: unstable_SharedElementProps): react_jsx_runtime1.JSX.Element;
39
+ }: MorphElementProps): react_jsx_runtime1.JSX.Element;
40
40
 
41
41
  //#endregion
42
42
  //#region src/app/lib/design.d.ts
@@ -83,9 +83,9 @@ type SlideTransition = {
83
83
  easing?: string;
84
84
  enter?: TransitionPhase;
85
85
  exit?: TransitionPhase;
86
- sharedElements?: boolean | SharedElementTransition;
86
+ morph?: boolean | MorphTransition;
87
87
  };
88
- type SharedElementTransition = {
88
+ type MorphTransition = {
89
89
  duration?: number;
90
90
  easing?: string;
91
91
  delay?: number;
@@ -114,6 +114,7 @@ declare const CANVAS_HEIGHT = 1080;
114
114
 
115
115
  //#endregion
116
116
  //#region src/app/lib/step-context.d.ts
117
+ declare function useIsActivePage(): boolean;
117
118
  type StepsProps = PropsWithChildren;
118
119
  declare function Steps({
119
120
  children
@@ -131,4 +132,4 @@ declare function Step({
131
132
  }: InternalStepProps): react_jsx_runtime5.JSX.Element;
132
133
 
133
134
  //#endregion
134
- export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SharedElementTransition, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, unstable_SharedElementProps, useSlidePageNumber };
135
+ export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, MorphElement, MorphElementProps, MorphTransition, OpenSlideConfig, Page, Plural, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useIsActivePage, useSlidePageNumber };
package/dist/index.js CHANGED
@@ -334,11 +334,11 @@ function PlaceholderIcon() {
334
334
  }
335
335
 
336
336
  //#endregion
337
- //#region src/app/components/shared-element.tsx
338
- function unstable_SharedElement({ id, children, className, style }) {
337
+ //#region src/app/components/morph-element.tsx
338
+ function MorphElement({ id, children, className, style }) {
339
339
  const child = Children.toArray(children)[0] ?? null;
340
340
  if (Children.count(children) === 1 && isValidElement(child) && typeof child.type === "string") return cloneElement(child, {
341
- "data-osd-shared-element": id,
341
+ "data-osd-morph": id,
342
342
  className: [child.props.className, className].filter(Boolean).join(" ") || void 0,
343
343
  style: style ? {
344
344
  ...child.props.style,
@@ -348,7 +348,7 @@ function unstable_SharedElement({ id, children, className, style }) {
348
348
  return /* @__PURE__ */ jsx("div", {
349
349
  className,
350
350
  style,
351
- "data-osd-shared-element": id,
351
+ "data-osd-morph": id,
352
352
  children
353
353
  });
354
354
  }
@@ -396,6 +396,9 @@ const GLOBAL_KEY = "__open_slide_step_host_context__";
396
396
  const g = globalThis;
397
397
  if (!g[GLOBAL_KEY]) g[GLOBAL_KEY] = createContext(null);
398
398
  const StepHostContext = g[GLOBAL_KEY];
399
+ function useIsActivePage() {
400
+ return useContext(StepHostContext)?.isActivePage ?? false;
401
+ }
399
402
  function Steps({ children }) {
400
403
  const host = useContext(StepHostContext);
401
404
  const flat = Children.toArray(children);
@@ -466,4 +469,4 @@ function Step({ children, duration = 180, _revealed }) {
466
469
  }
467
470
 
468
471
  //#endregion
469
- export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, useSlidePageNumber };
472
+ export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, MorphElement, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, useIsActivePage, useSlidePageNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-slide/core",
3
- "version": "1.15.3",
3
+ "version": "1.16.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": {
@@ -66,7 +66,7 @@
66
66
  "@dnd-kit/sortable": "^10.0.0",
67
67
  "@dnd-kit/utilities": "^3.2.2",
68
68
  "@fontsource-variable/geist": "^5.2.8",
69
- "@tailwindcss/vite": "^4.2.2",
69
+ "@tailwindcss/vite": "^4.3.3",
70
70
  "@vitejs/plugin-react": "^4.3.3",
71
71
  "chalk": "^5.3.0",
72
72
  "class-variance-authority": "^0.7.1",
@@ -76,7 +76,7 @@
76
76
  "fast-glob": "^3.3.2",
77
77
  "fflate": "^0.8.3",
78
78
  "html-to-image": "^1.11.13",
79
- "lucide-react": "^1.8.0",
79
+ "lucide-react": "^1.25.0",
80
80
  "next-themes": "^0.4.6",
81
81
  "react": "^18.3.1",
82
82
  "react-dom": "^18.3.1",
@@ -28,13 +28,13 @@ Your job: read those markers, perform the described edits, and delete the marker
28
28
  ## Procedure
29
29
 
30
30
  1. **Identify the target slide(s).**
31
- - If the user names one (`example-slide`, `youbike-3-survey`, etc.), work on that single `slides/<slideId>/index.tsx`.
31
+ - If the user names one (`getting-started`, `q2-roadmap`, etc.), work on that single `slides/<slideId>/index.tsx`.
32
32
  - If they say "all" or don't specify, scan every `slides/*/index.tsx`. Process each slide one at a time.
33
33
 
34
34
  2. **Read the file and find all markers.**
35
35
  - Run the regex above against the whole file.
36
36
  - For each match, base64url-decode `text` and `JSON.parse` it to get `{ note, hint? }`.
37
- - Record each hit as `{ id, lineIndex (0-based), indent, note, hint }`.
37
+ - Record each hit as `{ id, lineIndex (0-based), note, hint }`.
38
38
  - If there are no markers, tell the user and stop.
39
39
 
40
40
  3. **Understand each comment in context.**
@@ -48,14 +48,14 @@ Your job: read those markers, perform the described edits, and delete the marker
48
48
 
49
49
  5. **Remove each marker after applying its edit.**
50
50
  - Delete the entire marker line including its trailing `\n`.
51
- - Never leave a marker behind. An un-removed marker signals a failure.
51
+ - Never leave a marker behind for an edit you applied — that signals a failure. Markers deliberately skipped per the edge cases below stay in place.
52
52
 
53
53
  6. **Verify.**
54
- - After all edits, re-read the file and confirm zero remaining markers.
55
- - Run `pnpm tsc --noEmit` and `pnpm biome check` (or `pnpm lint`). Fix any introduced errors.
54
+ - After all edits, re-read the file and confirm the only remaining markers are ones you reported as skipped.
55
+ - Confirm the edited JSX is well-formed (balanced tags, no dangling attributes). If the project's `package.json` has typecheck/lint scripts, run them with the project's package manager; scaffolded projects ship neither TypeScript nor a linter — there, rely on the running dev server (or the `build` script) to surface compile errors. Fix any errors you introduced.
56
56
 
57
57
  7. **Report.**
58
- - Summarise: `N applied, 0 remaining` plus a one-line description of each change (including the slide id).
58
+ - Summarise: `N applied, M skipped` plus a one-line description of each change (including the slide id).
59
59
 
60
60
  ## base64url decoding helper
61
61
 
@@ -71,8 +71,7 @@ You can run this inline via `node -e '...'` if you need to inspect a payload; ot
71
71
  ## Edge cases
72
72
 
73
73
  - **Marker with no enclosing JSX element** (shouldn't happen — the inspector won't write one — but if you find one): delete it and note as orphan.
74
- - **Multiple markers stacked on consecutive lines inside the same element**: they all refer to that enclosing element. Apply them in source order but still delete each line individually.
75
- - **`_debugSource` used SWC instead of Babel**: not your problem — the marker line is authoritative.
74
+ - **Multiple markers stacked on consecutive lines inside the same element**: they all refer to that enclosing element. Read their notes in source order to understand the combined intent, then apply and delete them bottom-up per step 4.
76
75
  - **Comment asks for something outside the target element's scope** (e.g. "add a new page"): do the closest-reasonable edit and mention the scope expansion in your summary.
77
76
  - **Can't resolve the comment** (e.g. truly ambiguous, or the file changed shape such that the target element doesn't exist): leave the marker in place and report it as skipped. Don't guess.
78
77
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: create-slide
3
- description: Use this skill when the user wants to create, draft, author, or generate new slides / a presentation in this open-slide repo. Triggers on phrases like "make slides about X", "create a presentation", "draft slides for", "new slide", or when the user asks to add content under `slides/`. Do NOT use for editing the framework itself — only for authoring content inside `slides/<id>/`.
3
+ description: Use this skill when the user wants to create, draft, author, or generate new slides / a presentation in this open-slide repo. Triggers on phrases like "make slides about X", "make a deck about X", "create a presentation", "draft slides for", "new slide", or when the user asks to add content under `slides/`. Do NOT use for editing the framework itself — only for authoring content inside `slides/<id>/`.
4
4
  ---
5
5
 
6
6
  # Create a slide in open-slide
@@ -11,16 +11,16 @@ You only write files under `slides/<id>/`. Never modify `package.json`, `open-sl
11
11
 
12
12
  ## Step 1 — Pick a theme
13
13
 
14
- List files under `themes/`. If any theme markdown files exist (anything other than `README.md`), call `AskUserQuestion` with each theme id as an option plus a final **"no theme — design from scratch"** option.
14
+ List files under `themes/`. If any theme markdown files exist (anything other than `README.md`), call `AskUserQuestion` with each theme id as an option plus a final **"no theme — design from scratch"** option. (`AskUserQuestion` holds at most 4 options — with 4+ themes, offer the 3 most topic-relevant plus "no theme"; the auto-added "Other" lets the user name any omitted theme.)
15
15
 
16
- - If the user picks a theme: read `themes/<id>.md` end-to-end. The theme's palette, typography, layout, and Title/Footer components are now authoritative — copy them directly into the slide. **Also set `theme: '<theme-id>'` on the `meta` export in `index.tsx`** (e.g. `export const meta: SlideMeta = { title: '…', theme: '<theme-id>' };`) so the slide back-links to the theme (chip on the slide card + listing on `/themes/<id>`). In Step 2, skip the **aesthetic direction** question (the theme already commits to one direction); you still need the topic itself, so confirm it before moving on. Page count, text density, and motion are independent of theme — ask those normally.
17
- - If the user picks "no theme", or `themes/` is empty (or contains only `README.md`): proceed to Step 2 unchanged.
16
+ - If the user picks a theme: read `themes/<id>.md` end-to-end. The theme's palette, typography, layout, and Title/Footer components are now authoritative — copy them directly into the slide. If the theme declares a webfont import, load it per `references/webfonts.md` in `slide-authoring` (module-level, slide-keyed injection) — don't let the slide silently fall back to system fonts. **Also set `theme: '<theme-id>'` on the `meta` export in `index.tsx`** (e.g. `export const meta: SlideMeta = { title: '…', createdAt: '…', theme: '<theme-id>' };` — `createdAt` per the file contract in `slide-authoring`) so the slide back-links to the theme (chip on the slide card + listing on `/themes/<id>`). In Step 2, skip the **aesthetic direction** question (the theme already commits to one direction); you still need the topic itself, so confirm it before moving on. Page count and text density are independent of theme — ask those normally. For motion, if the theme's Motion section commits to a philosophy, present it as the "(Recommended)" option and reuse the theme's paste-ready keyframes; the user can still override.
17
+ - If the user picks "no theme", or `themes/` contains no theme markdown files: proceed to Step 2 unchanged.
18
18
 
19
19
  If you skip the aesthetic question because a theme was picked, restate the theme name in Step 2 so the user can correct course before you start writing.
20
20
 
21
21
  ## Step 2 — Clarify requirements (MUST ask before writing code)
22
22
 
23
- **Before writing any code, lock in the four key style decisions below via `AskUserQuestion`.** They shape every downstream choice (layout, type scale, asset needs, motion code), so locking them in up front avoids rework. Only skip a question when the user's original message already gave an unambiguous answer for it — and if you skip, restate your assumption so they can correct it.
23
+ **Before writing any code, lock in the four key style decisions below via `AskUserQuestion`.** They shape every downstream choice (layout, type scale, asset needs, motion code), so locking them in up front avoids rework. Only skip a question when it's already unambiguously answered — by the user's original message, or by a theme picked in Step 1 (a theme settles aesthetic direction, so ask only the remaining three) — and if you skip, restate your assumption so they can correct it.
24
24
 
25
25
  **Topic comes first.** A meaningful aesthetic recommendation requires knowing what the deck is about. If the user's initial request is thin ("make me a deck", "draft some slides"), make a *separate* `AskUserQuestion` call first to gather topic, audience, and any draft outline. Skip this only if the topic is already clear from the user's message — in which case restate your reading of the topic in the next call so they can correct course.
26
26
 
@@ -35,9 +35,9 @@ Then ask these four in a single `AskUserQuestion` call (multi-question form):
35
35
 
36
36
  Mark the option that best fits the topic and audience as "(Recommended)" so the user has a sensible default. (`AskUserQuestion` already auto-adds "Other" — don't add a generic catch-all yourself.)
37
37
 
38
- 2. **Page count** — rough length. Offer brackets: 3–5 (short), 6–10 (standard), 11–20 (deep dive), custom.
38
+ 2. **Page count** — rough length. Offer brackets: 3–5 (short), 6–10 (standard), 11–20 (deep dive). The auto-added "Other" covers custom counts.
39
39
  3. **Text density per page** — how much copy lives on each page? Offer: minimal (one line / big number), light (heading + 2–3 bullets), standard (heading + 4–5 bullets or short paragraph), dense (multi-column / detailed). This directly drives type scale and layout.
40
- 4. **Motion** — does the user want CSS/React animations and transitions, or a fully static deck? Offer: static (no motion), subtle (fades / entrance only), rich (keyframes, staggered reveals, looping visuals). If animated, plan to use CSS `@keyframes` / inline `style` + `useEffect`; no extra libraries.
40
+ 4. **Motion** — does the user want CSS/React animations and transitions, or a fully static deck? Offer: static (no motion), subtle (fades / entrance only), rich (keyframes, staggered reveals, looping visuals). If animated, plan around the framework primitives first — `<Steps>`/`<Step>` for staged reveals, `SlideTransition` for page changes, morph for shared-element continuity (see `slide-authoring`) — plus CSS `@keyframes` / inline `style` + `useEffect` for in-page motion; no extra libraries.
41
41
 
42
42
  After those four, ask follow-ups **only if still unclear**: brand colors, required assets. Don't pad the conversation with questions already answered.
43
43
 
@@ -70,7 +70,7 @@ Pick one coherent palette / type scale / aesthetic and hold it across every page
70
70
 
71
71
  **Default: declare a top-level `export const design: DesignSystem = { … }`** at the top of `index.tsx` (after imports) using the chosen palette / type scale, and reference the values via `var(--osd-X)` from inline styles. This keeps the slide tweakable from the Design panel after generation, which is what the user almost always wants. Only skip the `design` const for a one-off slide whose palette is intentionally locked and not meant to be re-themed — in that case, fall back to the local `palette` constants pattern. The "Design system" section of `slide-authoring` covers the format and available tokens.
72
72
 
73
- Consult the `frontend-design` skill for deeper aesthetic guidance if the user wants something bold.
73
+ If the `frontend-design` skill is available, consult it for deeper aesthetic guidance when the user wants something bold.
74
74
 
75
75
  ## Step 6 — Write `slides/<id>/index.tsx`
76
76
 
@@ -86,6 +86,6 @@ Tell the user:
86
86
 
87
87
  - The slide id and file path you created.
88
88
  - That the dev server will hot-reload — they can open `http://localhost:5173/s/<id>` (or refresh the home page).
89
- - If dev isn't running: `pnpm dev` from the repo root.
89
+ - If dev isn't running: run the project's `dev` script from the project root with its package manager (`npm run dev`, `pnpm dev`, … — match the lockfile).
90
90
 
91
91
  Don't run the dev server yourself unless asked.
@@ -31,8 +31,8 @@ If the user's original message already specifies the inputs unambiguously, skip
31
31
  - **Images**: read each path with the `Read` tool (it accepts images). Note dominant colors as hex, type weight/style, layout rhythm, decorative motifs, and any recurring chrome (header bar, footer line, page numbers).
32
32
  - **Text**: extract explicit tokens (hex codes, font names, motion verbs) and implicit tone words ("editorial", "playful", "brutalist"). Resolve vague language into concrete decisions before writing.
33
33
  - **Existing slide**: read `slides/<id>/index.tsx` and pull:
34
- - The `palette` object → Palette section.
35
- - Font constants and any `font-size` patterns → Typography section.
34
+ - The `design.palette` object (or a legacy top-of-file `palette` const) → Palette section.
35
+ - `design.fonts` / font constants and any `font-size` patterns → Typography section.
36
36
  - Padding / alignment patterns → Layout section.
37
37
  - Recurring components (TrafficLights, Eyebrow, Footer-style helpers, WindowShell, …) → Fixed components section.
38
38
  - `@keyframes` blocks and the shared `styles` string → Motion section.
@@ -52,6 +52,7 @@ Produce a file with this exact section order. Section bodies adapt to the theme;
52
52
  ---
53
53
  name: <Human title, e.g. "Editorial Noir">
54
54
  description: <one-line elevator pitch>
55
+ mode: <dark | light — whichever matches the palette's bg>
55
56
  ---
56
57
 
57
58
  # <Theme name>
@@ -70,6 +71,7 @@ description: <one-line elevator pitch>
70
71
 
71
72
  - Display font: `<stack>` — weight 800–900 for headlines.
72
73
  - Body font: `<stack>` — weight 400–500.
74
+ - Webfont import (omit for system stacks): `<stylesheet URL>` — see `references/webfonts.md` in `slide-authoring` for loading rules.
73
75
  - Type-scale overrides (only list what differs from `slide-authoring` defaults):
74
76
  - Hero title: 180 px (default 140–200 ✓)
75
77
  - Body text: 36 px
@@ -183,8 +185,8 @@ Contract:
183
185
  - `import { type Page, useSlidePageNumber } from '@open-slide/core';`
184
186
  - Inline the **same** `Title`, `Footer`, `Eyebrow` components defined in the theme markdown — verbatim, no abstractions, no imports from elsewhere. The demo and the markdown must stay in lockstep so what the user sees in the panel matches what `create-slide` will paste into a real slide.
185
187
  - Export 2–3 `Page` components and a default array. Aim for: a Cover (Eyebrow + Title + subtitle), one Content page exercising body type + accent, and a Closer or "End" card. The "Example usage" block at the bottom of the markdown is a good starting point — extend it.
186
- - If the theme has runtime-tweakable tokens worth surfacing in the Design panel later, also `export const design: DesignSystem = {...}`.
187
- - No external assets, no `import` from `@/`, no slides-only helpers (e.g. `WindowShell` from a real slide). Demo files must be self-contained.
188
+ - If the theme has runtime-tweakable tokens worth surfacing in the Design panel later, also `export const design: DesignSystem = {...}` (add `import type { DesignSystem } from '@open-slide/core';` alongside the base import).
189
+ - No asset file imports, no `import` from `@/`, no slides-only helpers (e.g. `WindowShell` from a real slide). Webfont stylesheet `@import`s inside an inline `<style>` are fine here — a deliberate exception to `webfonts.md`'s loader rules, since the demo only mounts in the Themes panel. Demo files must be self-contained.
188
190
 
189
191
  Skeleton:
190
192
 
@@ -220,13 +222,14 @@ export default [Cover, Content, Closer];
220
222
  Run this checklist before finishing:
221
223
 
222
224
  - [ ] Palette covers `bg` / `text` / `accent` / `muted` at minimum, all as hex.
225
+ - [ ] Frontmatter includes `mode` matching the palette's background.
223
226
  - [ ] Type scale specifies hero, heading, body, caption sizes (or explicitly defers to `slide-authoring` defaults).
224
227
  - [ ] At least Title and Footer are defined as paste-ready React with concrete inline styles.
225
228
  - [ ] Motion section commits to one of static / subtle / rich.
226
229
  - [ ] Aesthetic paragraph names a single coherent direction.
227
230
  - [ ] Both files written: `themes/<id>.md` and `themes/<id>.demo.tsx`. No slide changes, no config changes.
228
231
  - [ ] Demo `.tsx` exports 2–3 pages and inlines the same Title/Footer/Eyebrow components defined in the markdown.
229
- - [ ] Demo opens cleanly in the **Themes** panel of the dev UI — re-checked by you only by reading the file (do not start a server).
232
+ - [ ] Demo `.tsx` will load cleanly in the **Themes** panel: verify it against the Step 4b contract by reading the file — do not start a server.
230
233
 
231
234
  ## Step 6 — Hand off
232
235
 
@@ -76,7 +76,7 @@ Path is relative to the project root (the user's `cwd`, the directory that conta
76
76
  `updatedAt` is the last time the user navigated. Treat it like a cache:
77
77
 
78
78
  - **Fresh (under ~5 minutes old)**: trust it. Open `pagePath`, do the work.
79
- - **Older than ~5 minutes, or older than your last interaction with the user**: confirm with the user before editing. The dev server may not be running; the user may have switched contexts.
79
+ - **Older than ~5 minutes**: confirm with the user before editing. The dev server may not be running; the user may have switched contexts.
80
80
  - **Hours/days old**: ignore it. Ask the user which slide they mean.
81
81
 
82
82
  A *newer* `updatedAt` than the one you saw last turn is the normal signal that the user has moved — switch to the new `slideId` / `pageIndex` / `selection` without asking.