@open-slide/core 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-DaL4Gjn-.js → build-CaV_vhIw.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-CYs4WJfL.d.ts → config-CDHB8Oow.d.ts} +2 -1
- package/dist/{config-CCHio3pk.js → config-GA6NMgs_.js} +1 -0
- package/dist/{dev-DLRQoCkT.js → dev-D57ui2yV.js} +1 -1
- package/dist/{format-CxPnpVRu.js → format-74A3B6zu.js} +16 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-D3qVGc0S.js → preview-D40Zw_o0.js} +1 -1
- package/dist/{types-Wz88-Fe1.d.ts → types-8HghULIe.d.ts} +3 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
- package/src/app/components/player.tsx +8 -1
- package/src/app/components/present/use-presenter-channel.ts +2 -1
- package/src/app/lib/export-html.ts +15 -2
- package/src/app/routes/presenter.tsx +214 -8
- package/src/app/routes/slide.tsx +60 -17
- package/src/locale/en.ts +3 -0
- package/src/locale/ja.ts +3 -0
- package/src/locale/types.ts +3 -0
- package/src/locale/zh-cn.ts +3 -0
- package/src/locale/zh-tw.ts +3 -0
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-
|
|
60
|
+
const { dev } = await import("../dev-D57ui2yV.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-
|
|
64
|
+
const { build } = await import("../build-CaV_vhIw.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-
|
|
68
|
+
const { preview } = await import("../preview-D40Zw_o0.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-
|
|
1
|
+
import { Locale } from "./types-8HghULIe.js";
|
|
2
2
|
|
|
3
3
|
//#region src/config.d.ts
|
|
4
4
|
type OpenSlideBuildConfig = {
|
|
@@ -12,6 +12,7 @@ type OpenSlideConfig = {
|
|
|
12
12
|
themesDir?: string;
|
|
13
13
|
assetsDir?: string;
|
|
14
14
|
port?: number;
|
|
15
|
+
allowedHosts?: string[] | true;
|
|
15
16
|
/**
|
|
16
17
|
* @deprecated Pick the UI language from the language switcher in the slide UI
|
|
17
18
|
* instead. When set, this only seeds the initial language until the user
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./design-cpzS8aud.js";
|
|
2
|
-
import { DEV_SUPERVISED_ENV, RESTART_EXIT_CODE, createViteConfig } from "./config-
|
|
2
|
+
import { DEV_SUPERVISED_ENV, RESTART_EXIT_CODE, createViteConfig } from "./config-GA6NMgs_.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -156,7 +156,10 @@ const en = {
|
|
|
156
156
|
elapsed: "Elapsed",
|
|
157
157
|
jump: "Jump",
|
|
158
158
|
loadingSlide: "Loading {slideId}…",
|
|
159
|
-
loadingAssets: "Loading assets…"
|
|
159
|
+
loadingAssets: "Loading assets…",
|
|
160
|
+
switchDeck: "Switch presentation",
|
|
161
|
+
searchDecks: "Search presentations…",
|
|
162
|
+
noDecksFound: "No presentations match"
|
|
160
163
|
},
|
|
161
164
|
present: {
|
|
162
165
|
prevSlideAria: "Previous slide (←)",
|
|
@@ -619,7 +622,10 @@ const ja = {
|
|
|
619
622
|
elapsed: "経過時間",
|
|
620
623
|
jump: "ジャンプ",
|
|
621
624
|
loadingSlide: "{slideId} を読み込み中…",
|
|
622
|
-
loadingAssets: "アセットを読み込み中…"
|
|
625
|
+
loadingAssets: "アセットを読み込み中…",
|
|
626
|
+
switchDeck: "デッキを切り替え",
|
|
627
|
+
searchDecks: "デッキを検索…",
|
|
628
|
+
noDecksFound: "一致するデッキがありません"
|
|
623
629
|
},
|
|
624
630
|
present: {
|
|
625
631
|
prevSlideAria: "前のスライド (←)",
|
|
@@ -1082,7 +1088,10 @@ const zhCN = {
|
|
|
1082
1088
|
elapsed: "已用时",
|
|
1083
1089
|
jump: "跳至",
|
|
1084
1090
|
loadingSlide: "正在加载 {slideId}…",
|
|
1085
|
-
loadingAssets: "正在加载资源…"
|
|
1091
|
+
loadingAssets: "正在加载资源…",
|
|
1092
|
+
switchDeck: "切换演示文稿",
|
|
1093
|
+
searchDecks: "搜索演示文稿…",
|
|
1094
|
+
noDecksFound: "没有匹配的演示文稿"
|
|
1086
1095
|
},
|
|
1087
1096
|
present: {
|
|
1088
1097
|
prevSlideAria: "上一张幻灯片 (←)",
|
|
@@ -1545,7 +1554,10 @@ const zhTW = {
|
|
|
1545
1554
|
elapsed: "已耗時",
|
|
1546
1555
|
jump: "跳至",
|
|
1547
1556
|
loadingSlide: "正在載入 {slideId}…",
|
|
1548
|
-
loadingAssets: "正在載入資源…"
|
|
1557
|
+
loadingAssets: "正在載入資源…",
|
|
1558
|
+
switchDeck: "切換簡報",
|
|
1559
|
+
searchDecks: "搜尋簡報…",
|
|
1560
|
+
noDecksFound: "沒有符合的簡報"
|
|
1549
1561
|
},
|
|
1550
1562
|
present: {
|
|
1551
1563
|
prevSlideAria: "上一張投影片 (←)",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Locale, Plural } from "./types-
|
|
2
|
-
import { OpenSlideConfig } from "./config-
|
|
1
|
+
import { Locale, Plural } from "./types-8HghULIe.js";
|
|
2
|
+
import { OpenSlideConfig } from "./config-CDHB8Oow.js";
|
|
3
3
|
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
4
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
4
|
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
5
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
6
7
|
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
7
|
-
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/app/components/image-placeholder.d.ts
|
|
10
10
|
type ImagePlaceholderProps = {
|
|
@@ -21,7 +21,7 @@ declare function ImagePlaceholder({
|
|
|
21
21
|
style,
|
|
22
22
|
className,
|
|
23
23
|
...rest
|
|
24
|
-
}: ImagePlaceholderProps):
|
|
24
|
+
}: ImagePlaceholderProps): react_jsx_runtime1.JSX.Element;
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/app/components/morph-element.d.ts
|
|
@@ -36,7 +36,7 @@ declare function MorphElement({
|
|
|
36
36
|
children,
|
|
37
37
|
className,
|
|
38
38
|
style
|
|
39
|
-
}: MorphElementProps):
|
|
39
|
+
}: MorphElementProps): react_jsx_runtime0.JSX.Element;
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/app/lib/design.d.ts
|
|
@@ -118,7 +118,7 @@ declare function useIsActivePage(): boolean;
|
|
|
118
118
|
type StepsProps = PropsWithChildren;
|
|
119
119
|
declare function Steps({
|
|
120
120
|
children
|
|
121
|
-
}: StepsProps):
|
|
121
|
+
}: StepsProps): react_jsx_runtime3.JSX.Element;
|
|
122
122
|
type StepProps = PropsWithChildren<{
|
|
123
123
|
duration?: number;
|
|
124
124
|
}>;
|
|
@@ -129,7 +129,7 @@ declare function Step({
|
|
|
129
129
|
children,
|
|
130
130
|
duration,
|
|
131
131
|
_revealed
|
|
132
|
-
}: InternalStepProps):
|
|
132
|
+
}: InternalStepProps): react_jsx_runtime4.JSX.Element;
|
|
133
133
|
|
|
134
134
|
//#endregion
|
|
135
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { en, ja, zhCN, zhTW } from "./format-
|
|
1
|
+
import { en, ja, zhCN, zhTW } from "./format-74A3B6zu.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";
|
package/dist/locale/index.d.ts
CHANGED
package/dist/locale/index.js
CHANGED
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-slide/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.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": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vite": "^5.4.10"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@playwright/test": "~1.
|
|
95
|
+
"@playwright/test": "~1.62.1",
|
|
96
96
|
"@types/node": "^22.19.17",
|
|
97
97
|
"@types/react": "^18.3.12",
|
|
98
98
|
"@types/react-dom": "^18.3.1",
|
|
@@ -40,6 +40,7 @@ type Props = {
|
|
|
40
40
|
allowExit?: boolean;
|
|
41
41
|
controls?: boolean;
|
|
42
42
|
slideId?: string;
|
|
43
|
+
onSwitchSlide?: (slideId: string) => void;
|
|
43
44
|
/**
|
|
44
45
|
* When true, the Player enters the browser Fullscreen API on mount.
|
|
45
46
|
* When false, it renders as a window-sized overlay (viewport-filling)
|
|
@@ -58,6 +59,7 @@ export function Player({
|
|
|
58
59
|
allowExit = true,
|
|
59
60
|
controls = false,
|
|
60
61
|
slideId,
|
|
62
|
+
onSwitchSlide,
|
|
61
63
|
fullscreen = true,
|
|
62
64
|
}: Props) {
|
|
63
65
|
const isMobile = useIsMobile();
|
|
@@ -250,9 +252,11 @@ export function Player({
|
|
|
250
252
|
setBlackout((cur) => (cur === msg.mode ? null : msg.mode));
|
|
251
253
|
} else if (msg.type === 'request-state') {
|
|
252
254
|
send({ type: 'state', state: presenterStateRef.current });
|
|
255
|
+
} else if (msg.type === 'switch-slide') {
|
|
256
|
+
if (msg.slideId !== slideId) onSwitchSlide?.(msg.slideId);
|
|
253
257
|
}
|
|
254
258
|
},
|
|
255
|
-
[goNext, goPrev, handleIndexChange, pages.length],
|
|
259
|
+
[goNext, goPrev, handleIndexChange, pages.length, slideId, onSwitchSlide],
|
|
256
260
|
);
|
|
257
261
|
|
|
258
262
|
const channel = usePresenterChannel(slideId ?? '__none__', (msg) => {
|
|
@@ -402,7 +406,10 @@ export function Player({
|
|
|
402
406
|
style={design ? { background: design.palette.bg } : undefined}
|
|
403
407
|
>
|
|
404
408
|
<SlideCanvas flat design={design}>
|
|
409
|
+
{/* Keyed per deck so a presenter-driven deck switch cuts instead of
|
|
410
|
+
animating a transition between two unrelated decks. */}
|
|
405
411
|
<SlideTransitionLayer
|
|
412
|
+
key={slideId}
|
|
406
413
|
pages={pages}
|
|
407
414
|
index={index}
|
|
408
415
|
total={pages.length}
|
|
@@ -16,7 +16,8 @@ export type PresenterCommand =
|
|
|
16
16
|
| { type: 'prev' }
|
|
17
17
|
| { type: 'request-state' }
|
|
18
18
|
| { type: 'restart-timer' }
|
|
19
|
-
| { type: 'toggle-blackout'; mode: 'black' | 'white' }
|
|
19
|
+
| { type: 'toggle-blackout'; mode: 'black' | 'white' }
|
|
20
|
+
| { type: 'switch-slide'; slideId: string };
|
|
20
21
|
|
|
21
22
|
type Handler = (msg: PresenterCommand) => void;
|
|
22
23
|
|
|
@@ -96,6 +96,9 @@ async function renderPagesToHtml(pages: NonNullable<SlideModule['default']>): Pr
|
|
|
96
96
|
);
|
|
97
97
|
await nextPaint();
|
|
98
98
|
await nextPaint();
|
|
99
|
+
for (const video of host.querySelectorAll('video')) {
|
|
100
|
+
video.defaultMuted = video.muted;
|
|
101
|
+
}
|
|
99
102
|
result.push(host.innerHTML);
|
|
100
103
|
root.unmount();
|
|
101
104
|
container.removeChild(host);
|
|
@@ -143,7 +146,7 @@ function collectExternalStylesheetLinks(): string {
|
|
|
143
146
|
|
|
144
147
|
function findHtmlAssetUrls(html: string): string[] {
|
|
145
148
|
const out: string[] = [];
|
|
146
|
-
const attrRe = /\s(?:src|href)="([^"]+)"/g;
|
|
149
|
+
const attrRe = /\s(?:src|href|poster)="([^"]+)"/g;
|
|
147
150
|
for (const m of html.matchAll(attrRe)) {
|
|
148
151
|
if (looksLikeAsset(m[1])) out.push(m[1]);
|
|
149
152
|
}
|
|
@@ -282,7 +285,17 @@ html, body { margin: 0; height: 100%; background: #000; overflow: hidden; font-f
|
|
|
282
285
|
}
|
|
283
286
|
function go(i) {
|
|
284
287
|
idx = Math.max(0, Math.min(pages.length - 1, i));
|
|
285
|
-
pages.forEach(function (p, n) {
|
|
288
|
+
pages.forEach(function (p, n) {
|
|
289
|
+
p.hidden = n !== idx;
|
|
290
|
+
p.querySelectorAll('video').forEach(function (video) {
|
|
291
|
+
if (p.hidden) {
|
|
292
|
+
video.pause();
|
|
293
|
+
try { video.currentTime = 0; } catch {}
|
|
294
|
+
} else if (video.autoplay) {
|
|
295
|
+
video.play().catch(function () {});
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
286
299
|
cur.textContent = String(idx + 1);
|
|
287
300
|
}
|
|
288
301
|
window.addEventListener('resize', fit);
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AArrowDown,
|
|
3
3
|
AArrowUp,
|
|
4
|
+
Check,
|
|
5
|
+
ChevronDown,
|
|
4
6
|
ChevronLeft,
|
|
5
7
|
ChevronRight,
|
|
6
8
|
RotateCcw,
|
|
7
9
|
Square,
|
|
8
10
|
Sun,
|
|
9
11
|
} from 'lucide-react';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
+
import {
|
|
13
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
useCallback,
|
|
16
|
+
useEffect,
|
|
17
|
+
useRef,
|
|
18
|
+
useState,
|
|
19
|
+
} from 'react';
|
|
20
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
12
21
|
import { Button } from '@/components/ui/button';
|
|
22
|
+
import { Dialog, DialogContent, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
|
13
23
|
import { format, useLocale } from '@/lib/use-locale';
|
|
14
24
|
import { cn } from '@/lib/utils';
|
|
15
25
|
import {
|
|
@@ -19,7 +29,8 @@ import {
|
|
|
19
29
|
import { SlideCanvas } from '../components/slide-canvas';
|
|
20
30
|
import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
|
|
21
31
|
import { SlidePageProvider } from '../lib/page-context';
|
|
22
|
-
import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../lib/sdk';
|
|
32
|
+
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from '../lib/sdk';
|
|
33
|
+
import { loadSlide, slideIds } from '../lib/slides';
|
|
23
34
|
import { type StepController, StepHost } from '../lib/step-context';
|
|
24
35
|
import { useSlideModule } from '../lib/use-slide-module';
|
|
25
36
|
|
|
@@ -50,7 +61,19 @@ export function Presenter() {
|
|
|
50
61
|
}
|
|
51
62
|
});
|
|
52
63
|
|
|
64
|
+
// A deck switch reuses this route instance, so the handshake state from
|
|
65
|
+
// the previous deck must be dropped before rejoining on the new channel.
|
|
66
|
+
// Render-phase reset so the new deck never renders with the old state.
|
|
67
|
+
const prevSlideIdRef = useRef(slideId);
|
|
68
|
+
if (prevSlideIdRef.current !== slideId) {
|
|
69
|
+
prevSlideIdRef.current = slideId;
|
|
70
|
+
setState(null);
|
|
71
|
+
setHasProjection(false);
|
|
72
|
+
requestedRef.current = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
53
75
|
// Hydrate from the projection window once.
|
|
76
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: slideId re-fires the handshake on a deck switch even when the channel memo keeps its identity (available toggling false→true in one commit nets to no change)
|
|
54
77
|
useEffect(() => {
|
|
55
78
|
if (!channel.available || requestedRef.current) return;
|
|
56
79
|
requestedRef.current = true;
|
|
@@ -58,9 +81,18 @@ export function Presenter() {
|
|
|
58
81
|
// If nothing answers within a beat, surface the "no projection" hint.
|
|
59
82
|
const t = setTimeout(() => setHasProjection((v) => v), 600);
|
|
60
83
|
return () => clearTimeout(t);
|
|
61
|
-
}, [channel]);
|
|
84
|
+
}, [channel, slideId]);
|
|
62
85
|
|
|
86
|
+
const navigate = useNavigate();
|
|
63
87
|
const send = channel.send;
|
|
88
|
+
const switchDeck = useCallback(
|
|
89
|
+
(id: string) => {
|
|
90
|
+
if (id === slideId) return;
|
|
91
|
+
send({ type: 'switch-slide', slideId: id });
|
|
92
|
+
navigate(`/s/${encodeURIComponent(id)}/presenter`, { replace: true });
|
|
93
|
+
},
|
|
94
|
+
[slideId, send, navigate],
|
|
95
|
+
);
|
|
64
96
|
const goPrev = useCallback(() => send({ type: 'prev' }), [send]);
|
|
65
97
|
const goNext = useCallback(() => send({ type: 'next' }), [send]);
|
|
66
98
|
const goTo = useCallback((i: number) => send({ type: 'goto', index: i }), [send]);
|
|
@@ -71,6 +103,8 @@ export function Presenter() {
|
|
|
71
103
|
// presenter can drive without the mouse.
|
|
72
104
|
useEffect(() => {
|
|
73
105
|
const onKey = (e: KeyboardEvent) => {
|
|
106
|
+
// The deck-switcher menu owns its own arrow-key navigation.
|
|
107
|
+
if (e.defaultPrevented) return;
|
|
74
108
|
if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
|
|
75
109
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
76
110
|
if (
|
|
@@ -175,8 +209,10 @@ export function Presenter() {
|
|
|
175
209
|
index={index}
|
|
176
210
|
total={total}
|
|
177
211
|
startedAt={startedAt}
|
|
212
|
+
slideId={slideId}
|
|
178
213
|
slideTitle={slide.meta?.title ?? slideId}
|
|
179
214
|
connected={hasProjection}
|
|
215
|
+
onSwitchDeck={switchDeck}
|
|
180
216
|
/>
|
|
181
217
|
|
|
182
218
|
<div className="grid min-h-0 flex-1 grid-cols-1 gap-6 px-6 pb-4 lg:grid-cols-[2fr_1fr]">
|
|
@@ -252,23 +288,31 @@ function PresenterTopBar({
|
|
|
252
288
|
index,
|
|
253
289
|
total,
|
|
254
290
|
startedAt,
|
|
291
|
+
slideId,
|
|
255
292
|
slideTitle,
|
|
256
293
|
connected,
|
|
294
|
+
onSwitchDeck,
|
|
257
295
|
}: {
|
|
258
296
|
index: number;
|
|
259
297
|
total: number;
|
|
260
298
|
startedAt: number;
|
|
299
|
+
slideId: string;
|
|
261
300
|
slideTitle: string;
|
|
262
301
|
connected: boolean;
|
|
302
|
+
onSwitchDeck: (slideId: string) => void;
|
|
263
303
|
}) {
|
|
264
304
|
const t = useLocale();
|
|
265
305
|
return (
|
|
266
306
|
<header className="flex h-12 shrink-0 items-center justify-between border-b border-hairline px-6">
|
|
267
|
-
<div className="flex items-
|
|
307
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
268
308
|
<span className="eyebrow text-white/45">{t.presenter.eyebrow}</span>
|
|
269
|
-
|
|
270
|
-
{slideTitle}
|
|
271
|
-
|
|
309
|
+
{slideIds.length > 1 ? (
|
|
310
|
+
<DeckSwitcher slideId={slideId} slideTitle={slideTitle} onSwitchDeck={onSwitchDeck} />
|
|
311
|
+
) : (
|
|
312
|
+
<span className="truncate font-heading text-[14px] font-semibold tracking-tight">
|
|
313
|
+
{slideTitle}
|
|
314
|
+
</span>
|
|
315
|
+
)}
|
|
272
316
|
{!connected && (
|
|
273
317
|
<span className="rounded-[3px] border border-amber-300/30 bg-amber-300/10 px-1.5 py-0.5 font-mono text-[10px] tracking-[0.06em] uppercase text-amber-200/85">
|
|
274
318
|
{t.presenter.notLinked}
|
|
@@ -288,6 +332,168 @@ function PresenterTopBar({
|
|
|
288
332
|
);
|
|
289
333
|
}
|
|
290
334
|
|
|
335
|
+
// Listing decks means importing every deck's chunk for its meta and pages.
|
|
336
|
+
// That warms the module cache for switches; assets only load on render, so
|
|
337
|
+
// this stays cheap.
|
|
338
|
+
function useDeckModules(): Record<string, SlideModule> {
|
|
339
|
+
const [modules, setModules] = useState<Record<string, SlideModule>>({});
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
let cancelled = false;
|
|
342
|
+
for (const id of slideIds) {
|
|
343
|
+
loadSlide(id)
|
|
344
|
+
.then((mod) => {
|
|
345
|
+
if (cancelled) return;
|
|
346
|
+
setModules((cur) => (cur[id] === mod ? cur : { ...cur, [id]: mod }));
|
|
347
|
+
})
|
|
348
|
+
.catch(() => {});
|
|
349
|
+
}
|
|
350
|
+
return () => {
|
|
351
|
+
cancelled = true;
|
|
352
|
+
};
|
|
353
|
+
}, []);
|
|
354
|
+
return modules;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function DeckSwitcher({
|
|
358
|
+
slideId,
|
|
359
|
+
slideTitle,
|
|
360
|
+
onSwitchDeck,
|
|
361
|
+
}: {
|
|
362
|
+
slideId: string;
|
|
363
|
+
slideTitle: string;
|
|
364
|
+
onSwitchDeck: (slideId: string) => void;
|
|
365
|
+
}) {
|
|
366
|
+
const t = useLocale();
|
|
367
|
+
const modules = useDeckModules();
|
|
368
|
+
const [open, setOpen] = useState(false);
|
|
369
|
+
const [query, setQuery] = useState('');
|
|
370
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
371
|
+
const listRef = useRef<HTMLDivElement | null>(null);
|
|
372
|
+
|
|
373
|
+
const trimmed = query.trim().toLowerCase();
|
|
374
|
+
const filtered = slideIds.filter((id) => {
|
|
375
|
+
if (!trimmed) return true;
|
|
376
|
+
const title = modules[id]?.meta?.title;
|
|
377
|
+
return id.toLowerCase().includes(trimmed) || title?.toLowerCase().includes(trimmed);
|
|
378
|
+
});
|
|
379
|
+
const active = Math.min(activeIndex, Math.max(0, filtered.length - 1));
|
|
380
|
+
|
|
381
|
+
const handleOpenChange = (next: boolean) => {
|
|
382
|
+
setOpen(next);
|
|
383
|
+
if (next) {
|
|
384
|
+
setQuery('');
|
|
385
|
+
setActiveIndex(0);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const select = (id: string) => {
|
|
390
|
+
setOpen(false);
|
|
391
|
+
onSwitchDeck(id);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
useEffect(() => {
|
|
395
|
+
listRef.current
|
|
396
|
+
?.querySelector(`[data-index="${active}"]`)
|
|
397
|
+
?.scrollIntoView({ block: 'nearest' });
|
|
398
|
+
}, [active]);
|
|
399
|
+
|
|
400
|
+
const onSearchKeyDown = (e: ReactKeyboardEvent<HTMLInputElement>) => {
|
|
401
|
+
if (e.nativeEvent.isComposing) return;
|
|
402
|
+
if (e.key === 'ArrowDown') {
|
|
403
|
+
e.preventDefault();
|
|
404
|
+
setActiveIndex(Math.min(filtered.length - 1, active + 1));
|
|
405
|
+
} else if (e.key === 'ArrowUp') {
|
|
406
|
+
e.preventDefault();
|
|
407
|
+
setActiveIndex(Math.max(0, active - 1));
|
|
408
|
+
} else if (e.key === 'Enter') {
|
|
409
|
+
e.preventDefault();
|
|
410
|
+
const id = filtered[active];
|
|
411
|
+
if (id) select(id);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<Dialog open={open} onOpenChange={handleOpenChange}>
|
|
417
|
+
<DialogTrigger
|
|
418
|
+
aria-label={t.presenter.switchDeck}
|
|
419
|
+
title={t.presenter.switchDeck}
|
|
420
|
+
className="group -mx-1.5 flex min-w-0 items-center gap-1 rounded-[5px] px-1.5 py-0.5 outline-none hover:bg-card focus-visible:ring-2 focus-visible:ring-ring/30"
|
|
421
|
+
>
|
|
422
|
+
<span className="truncate font-heading text-[14px] font-semibold tracking-tight">
|
|
423
|
+
{slideTitle}
|
|
424
|
+
</span>
|
|
425
|
+
<ChevronDown className="size-3.5 shrink-0 text-muted-foreground" />
|
|
426
|
+
</DialogTrigger>
|
|
427
|
+
<DialogContent
|
|
428
|
+
showCloseButton={false}
|
|
429
|
+
className="dark top-[16%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-lg"
|
|
430
|
+
>
|
|
431
|
+
<DialogTitle className="sr-only">{t.presenter.switchDeck}</DialogTitle>
|
|
432
|
+
<input
|
|
433
|
+
value={query}
|
|
434
|
+
onChange={(e) => {
|
|
435
|
+
setQuery(e.target.value);
|
|
436
|
+
setActiveIndex(0);
|
|
437
|
+
}}
|
|
438
|
+
onKeyDown={onSearchKeyDown}
|
|
439
|
+
placeholder={t.presenter.searchDecks}
|
|
440
|
+
className="w-full border-b border-hairline bg-transparent px-4 py-3 text-[13px] text-foreground outline-none placeholder:text-muted-foreground"
|
|
441
|
+
/>
|
|
442
|
+
<div ref={listRef} className="max-h-[55vh] overflow-y-auto p-1.5">
|
|
443
|
+
{filtered.length === 0 ? (
|
|
444
|
+
<div className="px-3 py-8 text-center text-[12px] text-muted-foreground">
|
|
445
|
+
{t.presenter.noDecksFound}
|
|
446
|
+
</div>
|
|
447
|
+
) : (
|
|
448
|
+
filtered.map((id, i) => {
|
|
449
|
+
const mod = modules[id];
|
|
450
|
+
const FirstPage = mod?.default[0];
|
|
451
|
+
return (
|
|
452
|
+
<button
|
|
453
|
+
type="button"
|
|
454
|
+
key={id}
|
|
455
|
+
data-index={i}
|
|
456
|
+
onClick={() => select(id)}
|
|
457
|
+
onMouseMove={() => setActiveIndex(i)}
|
|
458
|
+
className={cn(
|
|
459
|
+
'flex w-full items-center gap-3 rounded-[6px] p-2 text-left',
|
|
460
|
+
i === active && 'bg-muted',
|
|
461
|
+
)}
|
|
462
|
+
>
|
|
463
|
+
<div
|
|
464
|
+
className="w-24 shrink-0 overflow-hidden rounded-[4px] bg-black ring-1 ring-border"
|
|
465
|
+
style={{ aspectRatio: `${CANVAS_WIDTH}/${CANVAS_HEIGHT}` }}
|
|
466
|
+
>
|
|
467
|
+
{FirstPage && (
|
|
468
|
+
<SlideCanvas flat freezeMotion design={mod.design}>
|
|
469
|
+
<SlidePageProvider index={0} total={mod.default.length}>
|
|
470
|
+
<PreviewStepHost revealed={0}>
|
|
471
|
+
<FirstPage />
|
|
472
|
+
</PreviewStepHost>
|
|
473
|
+
</SlidePageProvider>
|
|
474
|
+
</SlideCanvas>
|
|
475
|
+
)}
|
|
476
|
+
</div>
|
|
477
|
+
<div className="min-w-0 flex-1">
|
|
478
|
+
<div className="truncate text-[13px] font-medium text-foreground">
|
|
479
|
+
{mod?.meta?.title ?? id}
|
|
480
|
+
</div>
|
|
481
|
+
<div className="mt-0.5 truncate font-mono text-[10.5px] text-muted-foreground">
|
|
482
|
+
{id}
|
|
483
|
+
{mod && ` · ${mod.default.length.toString().padStart(2, '0')}`}
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
{id === slideId && <Check className="size-3.5 shrink-0 text-muted-foreground" />}
|
|
487
|
+
</button>
|
|
488
|
+
);
|
|
489
|
+
})
|
|
490
|
+
)}
|
|
491
|
+
</div>
|
|
492
|
+
</DialogContent>
|
|
493
|
+
</Dialog>
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
291
497
|
function PresenterBottomBar({
|
|
292
498
|
index,
|
|
293
499
|
total,
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Terminal,
|
|
18
18
|
} from 'lucide-react';
|
|
19
19
|
import { type RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
-
import { Link, useParams, useSearchParams } from 'react-router-dom';
|
|
20
|
+
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
21
21
|
import { toast } from 'sonner';
|
|
22
22
|
import { AssetView } from '@/components/asset-view';
|
|
23
23
|
import { HistoryProvider } from '@/components/history-provider';
|
|
@@ -70,11 +70,24 @@ import { useSlideModule } from '../lib/use-slide-module';
|
|
|
70
70
|
|
|
71
71
|
const { showSlideUi, showSlideBrowser, allowHtmlDownload } = config.build;
|
|
72
72
|
|
|
73
|
+
const noop = () => {};
|
|
74
|
+
|
|
73
75
|
export function Slide() {
|
|
74
76
|
const { slideId = '' } = useParams();
|
|
75
77
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
78
|
+
const navigate = useNavigate();
|
|
76
79
|
const { slide, error } = useSlideModule(slideId);
|
|
77
80
|
const [playMode, setPlayMode] = useState<'window' | 'fullscreen' | null>(null);
|
|
81
|
+
// Last deck the Player showed. During a presenter-driven deck switch the
|
|
82
|
+
// route's slideId changes while the new module loads and warms; rendering
|
|
83
|
+
// from this cache keeps the Player mounted, which preserves fullscreen
|
|
84
|
+
// (re-entry needs a user gesture) and the elapsed timer.
|
|
85
|
+
const lastPresentedRef = useRef<{
|
|
86
|
+
slideId: string;
|
|
87
|
+
slide: SlideModule;
|
|
88
|
+
pages: SlideModule['default'];
|
|
89
|
+
index: number;
|
|
90
|
+
} | null>(null);
|
|
78
91
|
const [exporting, setExporting] = useState(false);
|
|
79
92
|
const [linkCopied, setLinkCopied] = useState(false);
|
|
80
93
|
const linkCopiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -120,6 +133,13 @@ export function Slide() {
|
|
|
120
133
|
});
|
|
121
134
|
}, [slideId, index, pageCount, slide, view]);
|
|
122
135
|
|
|
136
|
+
const switchPresentedSlide = useCallback(
|
|
137
|
+
(id: string) => {
|
|
138
|
+
navigate(`/s/${encodeURIComponent(id)}`, { replace: true });
|
|
139
|
+
},
|
|
140
|
+
[navigate],
|
|
141
|
+
);
|
|
142
|
+
|
|
123
143
|
const goTo = useCallback(
|
|
124
144
|
(i: number) => {
|
|
125
145
|
const clamped = Math.max(0, Math.min(pageCount - 1, i));
|
|
@@ -314,6 +334,45 @@ export function Slide() {
|
|
|
314
334
|
);
|
|
315
335
|
}
|
|
316
336
|
|
|
337
|
+
const presentReady = Boolean(slide) && pageCount > 0 && isDeckWarmed(slideId);
|
|
338
|
+
if (playMode && slide && presentReady) {
|
|
339
|
+
lastPresentedRef.current = { slideId, slide, pages, index };
|
|
340
|
+
}
|
|
341
|
+
const presented = playMode
|
|
342
|
+
? slide && presentReady
|
|
343
|
+
? { slideId, slide, pages, index }
|
|
344
|
+
: (lastPresentedRef.current ??
|
|
345
|
+
(slide && pageCount > 0 ? { slideId, slide, pages, index } : null))
|
|
346
|
+
: null;
|
|
347
|
+
|
|
348
|
+
if (playMode && presented) {
|
|
349
|
+
return (
|
|
350
|
+
<>
|
|
351
|
+
<Player
|
|
352
|
+
pages={presented.pages}
|
|
353
|
+
design={presented.slide.design}
|
|
354
|
+
transition={presented.slide.transition}
|
|
355
|
+
index={presented.index}
|
|
356
|
+
onIndexChange={presentReady ? goTo : noop}
|
|
357
|
+
onExit={() => setPlayMode(null)}
|
|
358
|
+
controls
|
|
359
|
+
slideId={presented.slideId}
|
|
360
|
+
onSwitchSlide={switchPresentedSlide}
|
|
361
|
+
fullscreen={playMode === 'fullscreen'}
|
|
362
|
+
/>
|
|
363
|
+
{!presentReady && slide && pageCount > 0 && (
|
|
364
|
+
<SlidePreloadLayer
|
|
365
|
+
pages={pages}
|
|
366
|
+
index={index}
|
|
367
|
+
design={slide.design}
|
|
368
|
+
includeCurrent
|
|
369
|
+
onDone={handleAssetsWarmed}
|
|
370
|
+
/>
|
|
371
|
+
)}
|
|
372
|
+
</>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
317
376
|
if (!slide) {
|
|
318
377
|
return (
|
|
319
378
|
<div className="grid min-h-dvh place-items-center px-8 text-muted-foreground">
|
|
@@ -401,22 +460,6 @@ export function Slide() {
|
|
|
401
460
|
);
|
|
402
461
|
}
|
|
403
462
|
|
|
404
|
-
if (playMode) {
|
|
405
|
-
return (
|
|
406
|
-
<Player
|
|
407
|
-
pages={pages}
|
|
408
|
-
design={slide.design}
|
|
409
|
-
transition={slide.transition}
|
|
410
|
-
index={index}
|
|
411
|
-
onIndexChange={goTo}
|
|
412
|
-
onExit={() => setPlayMode(null)}
|
|
413
|
-
controls
|
|
414
|
-
slideId={slideId}
|
|
415
|
-
fullscreen={playMode === 'fullscreen'}
|
|
416
|
-
/>
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
463
|
const title = slide.meta?.title ?? slideId;
|
|
421
464
|
|
|
422
465
|
const copyLink = async () => {
|
package/src/locale/en.ts
CHANGED
|
@@ -167,6 +167,9 @@ export const en: Locale = {
|
|
|
167
167
|
jump: 'Jump',
|
|
168
168
|
loadingSlide: 'Loading {slideId}…',
|
|
169
169
|
loadingAssets: 'Loading assets…',
|
|
170
|
+
switchDeck: 'Switch presentation',
|
|
171
|
+
searchDecks: 'Search presentations…',
|
|
172
|
+
noDecksFound: 'No presentations match',
|
|
170
173
|
},
|
|
171
174
|
|
|
172
175
|
present: {
|
package/src/locale/ja.ts
CHANGED
package/src/locale/types.ts
CHANGED
package/src/locale/zh-cn.ts
CHANGED
package/src/locale/zh-tw.ts
CHANGED