@open-slide/core 1.12.1 → 1.13.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.
- package/README.md +2 -0
- package/dist/{build-L2yL1hTo.js → build-OAZ8maw5.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-OT4T-im0.js → config-CU_NISD6.js} +49 -4
- package/dist/{dev-DJUpPCGT.js → dev-C78J1TLR.js} +1 -1
- package/dist/index.d.ts +29 -7
- package/dist/index.js +21 -1
- package/dist/{preview-Bf8up6-P.js → preview-DZLZ3L9v.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/app/components/inspector/inspect-overlay.tsx +39 -18
- package/src/app/components/inspector/inspector-provider.tsx +54 -6
- package/src/app/components/player.tsx +64 -3
- package/src/app/components/present/control-bar.tsx +99 -7
- package/src/app/components/shared-element.tsx +48 -0
- package/src/app/components/slide-canvas.tsx +23 -14
- package/src/app/components/slide-transition-layer.tsx +654 -4
- package/src/app/components/thumbnail-rail.tsx +223 -66
- package/src/app/lib/transition.ts +7 -0
- package/src/app/lib/use-click-page-navigation.ts +10 -2
- package/src/app/routes/slide.tsx +4 -3
package/README.md
CHANGED
|
@@ -78,9 +78,11 @@ 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
82
|
type Page,
|
|
82
83
|
type SlideMeta,
|
|
83
84
|
type SlideModule,
|
|
85
|
+
type SlideTransition,
|
|
84
86
|
type OpenSlideConfig,
|
|
85
87
|
} from '@open-slide/core';
|
|
86
88
|
```
|
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-C78J1TLR.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-OAZ8maw5.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-DZLZ3L9v.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) => {
|
|
@@ -1642,9 +1642,52 @@ function reorderNotesArrayInSource(source, order) {
|
|
|
1642
1642
|
if (found === null) return source;
|
|
1643
1643
|
const { arrayStart, arrayEnd, elementTexts } = found;
|
|
1644
1644
|
const pick = (i) => i >= 0 && i < elementTexts.length ? elementTexts[i] : "undefined";
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1645
|
+
return rebuildNotesArray(source, arrayStart, arrayEnd, order.map(pick));
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Remove the note aligned with the page at `index` so the `notes` export stays
|
|
1649
|
+
* index-aligned with `export default [...]` after a page deletion. Mirrors
|
|
1650
|
+
* {@link removePageFromDefaultExportInSource}.
|
|
1651
|
+
*
|
|
1652
|
+
* Returns the rewritten source, the original source if no `notes` export exists
|
|
1653
|
+
* or the index falls past the recorded notes, or `null` if the `notes` export's
|
|
1654
|
+
* shape is too surprising to touch safely.
|
|
1655
|
+
*/
|
|
1656
|
+
function removeNotesElementInSource(source, index) {
|
|
1657
|
+
if (!Number.isInteger(index) || index < 0) return null;
|
|
1658
|
+
const found = findNotesArray(source);
|
|
1659
|
+
if (found === "invalid") return null;
|
|
1660
|
+
if (found === null) return source;
|
|
1661
|
+
const { arrayStart, arrayEnd, elementTexts } = found;
|
|
1662
|
+
if (index >= elementTexts.length) return source;
|
|
1663
|
+
const next = elementTexts.slice();
|
|
1664
|
+
next.splice(index, 1);
|
|
1665
|
+
return rebuildNotesArray(source, arrayStart, arrayEnd, next);
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Duplicate the note aligned with the page at `index`, inserting the copy right
|
|
1669
|
+
* after it so the `notes` export stays index-aligned with `export default [...]`
|
|
1670
|
+
* after a page duplication. Mirrors {@link duplicatePageInDefaultExportInSource}.
|
|
1671
|
+
*
|
|
1672
|
+
* Returns the rewritten source, the original source if no `notes` export exists
|
|
1673
|
+
* or the index falls past the recorded notes (the new slot and everything after
|
|
1674
|
+
* it are absent, so nothing shifts), or `null` if the shape is too surprising.
|
|
1675
|
+
*/
|
|
1676
|
+
function duplicateNotesElementInSource(source, index) {
|
|
1677
|
+
if (!Number.isInteger(index) || index < 0) return null;
|
|
1678
|
+
const found = findNotesArray(source);
|
|
1679
|
+
if (found === "invalid") return null;
|
|
1680
|
+
if (found === null) return source;
|
|
1681
|
+
const { arrayStart, arrayEnd, elementTexts } = found;
|
|
1682
|
+
if (index >= elementTexts.length) return source;
|
|
1683
|
+
const next = elementTexts.slice();
|
|
1684
|
+
next.splice(index + 1, 0, next[index]);
|
|
1685
|
+
return rebuildNotesArray(source, arrayStart, arrayEnd, next);
|
|
1686
|
+
}
|
|
1687
|
+
function rebuildNotesArray(source, arrayStart, arrayEnd, elements) {
|
|
1688
|
+
const trimmed = elements.slice();
|
|
1689
|
+
while (trimmed.length > 0 && trimmed[trimmed.length - 1] === "undefined") trimmed.pop();
|
|
1690
|
+
const replacement = trimmed.length === 0 ? "[]" : `[\n${trimmed.map((s) => ` ${s},`).join("\n")}\n]`;
|
|
1648
1691
|
if (replacement === source.slice(arrayStart, arrayEnd)) return source;
|
|
1649
1692
|
return source.slice(0, arrayStart) + replacement + source.slice(arrayEnd);
|
|
1650
1693
|
}
|
|
@@ -2647,7 +2690,9 @@ function registerSlideRoutes(server, ctx) {
|
|
|
2647
2690
|
}
|
|
2648
2691
|
const updated = isDelete ? removePageFromDefaultExportInSource(source, pageIndex) : duplicatePageInDefaultExportInSource(source, pageIndex);
|
|
2649
2692
|
if (updated === null) return json(res, 422, { error: isDelete ? "could not delete page — index out of range or default export is not an array" : "could not duplicate page — index out of range or default export is not an array" });
|
|
2650
|
-
|
|
2693
|
+
const withNotes = isDelete ? removeNotesElementInSource(updated, pageIndex) : duplicateNotesElementInSource(updated, pageIndex);
|
|
2694
|
+
if (withNotes === null) return json(res, 422, { error: isDelete ? "could not delete page — `notes` export has an unexpected shape" : "could not duplicate page — `notes` export has an unexpected shape" });
|
|
2695
|
+
if (withNotes !== source) await fs.writeFile(entry, withNotes, "utf8");
|
|
2651
2696
|
return json(res, 200, {
|
|
2652
2697
|
ok: true,
|
|
2653
2698
|
slideId: slideId$1,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Locale, Plural } from "./types-CHmFPIG_.js";
|
|
2
2
|
import { OpenSlideConfig } from "./config-x493taft.js";
|
|
3
|
-
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren } from "react";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
3
|
+
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
4
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
5
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
6
6
|
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
7
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
7
8
|
|
|
8
9
|
//#region src/app/components/image-placeholder.d.ts
|
|
9
10
|
type ImagePlaceholderProps = {
|
|
@@ -20,7 +21,22 @@ declare function ImagePlaceholder({
|
|
|
20
21
|
style,
|
|
21
22
|
className,
|
|
22
23
|
...rest
|
|
23
|
-
}: ImagePlaceholderProps):
|
|
24
|
+
}: ImagePlaceholderProps): react_jsx_runtime1.JSX.Element;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/app/components/shared-element.d.ts
|
|
28
|
+
type unstable_SharedElementProps = {
|
|
29
|
+
id: string;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
};
|
|
34
|
+
declare function unstable_SharedElement({
|
|
35
|
+
id,
|
|
36
|
+
children,
|
|
37
|
+
className,
|
|
38
|
+
style
|
|
39
|
+
}: unstable_SharedElementProps): react_jsx_runtime2.JSX.Element;
|
|
24
40
|
|
|
25
41
|
//#endregion
|
|
26
42
|
//#region src/app/lib/design.d.ts
|
|
@@ -67,6 +83,12 @@ type SlideTransition = {
|
|
|
67
83
|
easing?: string;
|
|
68
84
|
enter?: TransitionPhase;
|
|
69
85
|
exit?: TransitionPhase;
|
|
86
|
+
sharedElements?: boolean | SharedElementTransition;
|
|
87
|
+
};
|
|
88
|
+
type SharedElementTransition = {
|
|
89
|
+
duration?: number;
|
|
90
|
+
easing?: string;
|
|
91
|
+
delay?: number;
|
|
70
92
|
};
|
|
71
93
|
|
|
72
94
|
//#endregion
|
|
@@ -95,7 +117,7 @@ declare const CANVAS_HEIGHT = 1080;
|
|
|
95
117
|
type StepsProps = PropsWithChildren;
|
|
96
118
|
declare function Steps({
|
|
97
119
|
children
|
|
98
|
-
}: StepsProps):
|
|
120
|
+
}: StepsProps): react_jsx_runtime4.JSX.Element;
|
|
99
121
|
type StepProps = PropsWithChildren<{
|
|
100
122
|
duration?: number;
|
|
101
123
|
}>;
|
|
@@ -106,7 +128,7 @@ declare function Step({
|
|
|
106
128
|
children,
|
|
107
129
|
duration,
|
|
108
130
|
_revealed
|
|
109
|
-
}: InternalStepProps):
|
|
131
|
+
}: InternalStepProps): react_jsx_runtime5.JSX.Element;
|
|
110
132
|
|
|
111
133
|
//#endregion
|
|
112
|
-
export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -331,6 +331,26 @@ function PlaceholderIcon() {
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/app/components/shared-element.tsx
|
|
336
|
+
function unstable_SharedElement({ id, children, className, style }) {
|
|
337
|
+
const child = Children.toArray(children)[0] ?? null;
|
|
338
|
+
if (Children.count(children) === 1 && isValidElement(child) && typeof child.type === "string") return cloneElement(child, {
|
|
339
|
+
"data-osd-shared-element": id,
|
|
340
|
+
className: [child.props.className, className].filter(Boolean).join(" ") || void 0,
|
|
341
|
+
style: style ? {
|
|
342
|
+
...child.props.style,
|
|
343
|
+
...style
|
|
344
|
+
} : child.props.style
|
|
345
|
+
});
|
|
346
|
+
return /* @__PURE__ */ jsx("div", {
|
|
347
|
+
className,
|
|
348
|
+
style,
|
|
349
|
+
"data-osd-shared-element": id,
|
|
350
|
+
children
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
334
354
|
//#endregion
|
|
335
355
|
//#region src/app/lib/page-context.tsx
|
|
336
356
|
const GLOBAL_KEY$1 = "__open_slide_page_context__";
|
|
@@ -444,4 +464,4 @@ function Step({ children, duration = 180, _revealed }) {
|
|
|
444
464
|
}
|
|
445
465
|
|
|
446
466
|
//#endregion
|
|
447
|
-
export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
|
|
467
|
+
export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, useSlidePageNumber };
|
package/dist/vite/index.js
CHANGED
package/package.json
CHANGED
|
@@ -16,17 +16,13 @@ const FRAME_MORPH_MS = 180;
|
|
|
16
16
|
const LAYOUT_TRACK_MS = PANEL_TRANSITION_MS + FRAME_MORPH_MS;
|
|
17
17
|
|
|
18
18
|
export function InspectOverlay() {
|
|
19
|
-
const { active, slideId, selected, setSelected, cancel, openCrop } = useInspector();
|
|
19
|
+
const { active, activate, slideId, selected, setSelected, cancel, openCrop } = useInspector();
|
|
20
20
|
const overlayRef = useRef<HTMLDivElement>(null);
|
|
21
21
|
const [hover, setHover] = useState<Highlight | null>(null);
|
|
22
22
|
|
|
23
23
|
useEffect(() => {
|
|
24
|
-
if (!active) {
|
|
25
|
-
setHover(null);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
const onKey = (e: KeyboardEvent) => {
|
|
25
|
+
if (!active) return;
|
|
30
26
|
if (e.key === 'Escape') {
|
|
31
27
|
e.preventDefault();
|
|
32
28
|
e.stopPropagation();
|
|
@@ -35,52 +31,66 @@ export function InspectOverlay() {
|
|
|
35
31
|
};
|
|
36
32
|
|
|
37
33
|
const onMove = (e: PointerEvent) => {
|
|
34
|
+
if (!active) return;
|
|
38
35
|
if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) {
|
|
39
36
|
return setHover(null);
|
|
40
37
|
}
|
|
41
|
-
const
|
|
42
|
-
if (!el) return setHover(null);
|
|
43
|
-
const hit = findSlideSource(el, slideId, { hostOnly: true });
|
|
38
|
+
const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
|
|
44
39
|
if (!hit) return setHover(null);
|
|
45
40
|
setHover({ hit });
|
|
46
41
|
};
|
|
47
42
|
|
|
43
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
44
|
+
if (!active && e.detail < 2) return;
|
|
45
|
+
if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
|
|
46
|
+
const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
|
|
47
|
+
if (!hit) return;
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
};
|
|
50
|
+
|
|
48
51
|
const onClick = (e: MouseEvent) => {
|
|
52
|
+
if (!active) return;
|
|
49
53
|
if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
|
|
50
|
-
const
|
|
51
|
-
if (!el) return;
|
|
52
|
-
const hit = findSlideSource(el, slideId, { hostOnly: true });
|
|
54
|
+
const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
|
|
53
55
|
if (!hit) return;
|
|
54
56
|
e.preventDefault();
|
|
55
57
|
e.stopPropagation();
|
|
58
|
+
clearTextSelection();
|
|
59
|
+
activate();
|
|
56
60
|
setSelected({ line: hit.line, column: hit.column, anchor: hit.anchor });
|
|
57
61
|
setHover({ hit });
|
|
58
62
|
};
|
|
59
63
|
|
|
60
64
|
const onDblClick = (e: MouseEvent) => {
|
|
61
65
|
if (e.target instanceof Element && e.target.closest('[data-inspector-ui]')) return;
|
|
62
|
-
const
|
|
63
|
-
if (!el) return;
|
|
64
|
-
const hit = findSlideSource(el, slideId, { hostOnly: true });
|
|
66
|
+
const hit = findInspectorHitAtPoint(e.clientX, e.clientY, slideId);
|
|
65
67
|
if (!hit) return;
|
|
66
|
-
if (!(hit.anchor instanceof HTMLImageElement)) return;
|
|
67
68
|
e.preventDefault();
|
|
68
69
|
e.stopPropagation();
|
|
70
|
+
clearTextSelection();
|
|
71
|
+
if (!active) activate();
|
|
69
72
|
setSelected({ line: hit.line, column: hit.column, anchor: hit.anchor });
|
|
70
|
-
|
|
73
|
+
setHover({ hit });
|
|
74
|
+
if (active && hit.anchor instanceof HTMLImageElement) openCrop(hit.anchor);
|
|
71
75
|
};
|
|
72
76
|
|
|
73
77
|
window.addEventListener('pointermove', onMove, true);
|
|
78
|
+
window.addEventListener('mousedown', onMouseDown, true);
|
|
74
79
|
window.addEventListener('click', onClick, true);
|
|
75
80
|
window.addEventListener('dblclick', onDblClick, true);
|
|
76
81
|
window.addEventListener('keydown', onKey, true);
|
|
77
82
|
return () => {
|
|
78
83
|
window.removeEventListener('pointermove', onMove, true);
|
|
84
|
+
window.removeEventListener('mousedown', onMouseDown, true);
|
|
79
85
|
window.removeEventListener('click', onClick, true);
|
|
80
86
|
window.removeEventListener('dblclick', onDblClick, true);
|
|
81
87
|
window.removeEventListener('keydown', onKey, true);
|
|
82
88
|
};
|
|
83
|
-
}, [active, slideId, setSelected, cancel, openCrop]);
|
|
89
|
+
}, [active, activate, slideId, setSelected, cancel, openCrop]);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!active) setHover(null);
|
|
93
|
+
}, [active]);
|
|
84
94
|
|
|
85
95
|
const hoverAnchor = hover?.hit.anchor.isConnected ? hover.hit.anchor : null;
|
|
86
96
|
const selectedAnchor = selected?.anchor.isConnected ? selected.anchor : null;
|
|
@@ -319,6 +329,17 @@ function pickElement(x: number, y: number): HTMLElement | null {
|
|
|
319
329
|
return null;
|
|
320
330
|
}
|
|
321
331
|
|
|
332
|
+
function findInspectorHitAtPoint(x: number, y: number, slideId: string): SlideSourceHit | null {
|
|
333
|
+
const el = pickInspectorTarget(pickElement(x, y));
|
|
334
|
+
if (!el) return null;
|
|
335
|
+
return findSlideSource(el, slideId, { hostOnly: true });
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function clearTextSelection() {
|
|
339
|
+
const selection = window.getSelection();
|
|
340
|
+
if (selection && !selection.isCollapsed) selection.removeAllRanges();
|
|
341
|
+
}
|
|
342
|
+
|
|
322
343
|
const INLINE_TEXT_TAGS = new Set([
|
|
323
344
|
'B',
|
|
324
345
|
'CODE',
|
|
@@ -244,6 +244,7 @@ function replayDomTextRangeStyles(el: HTMLElement, html: string, ops: TextRangeS
|
|
|
244
244
|
type InspectorCtx = {
|
|
245
245
|
slideId: string;
|
|
246
246
|
active: boolean;
|
|
247
|
+
activate: () => void;
|
|
247
248
|
toggle: () => void;
|
|
248
249
|
cancel: () => void;
|
|
249
250
|
comments: SlideComment[];
|
|
@@ -284,11 +285,14 @@ export function InspectorProvider({
|
|
|
284
285
|
pageIndex: number;
|
|
285
286
|
children: ReactNode;
|
|
286
287
|
}) {
|
|
287
|
-
const [
|
|
288
|
+
const [manualActive, setManualActive] = useState(false);
|
|
289
|
+
const [heldActive, setHeldActive] = useState(false);
|
|
288
290
|
const [selected, setSelected] = useState<SelectedTarget | null>(null);
|
|
289
291
|
const { comments, error, refetch, add, remove } = useComments(slideId);
|
|
290
292
|
const { applyEdit, applyEdits } = useEditor(slideId);
|
|
291
293
|
const history = useHistory();
|
|
294
|
+
const active = manualActive || heldActive;
|
|
295
|
+
const manualActiveRef = useRef(manualActive);
|
|
292
296
|
|
|
293
297
|
const pendingRef = useRef<Map<string, Bucket>>(new Map());
|
|
294
298
|
const instanceCounterRef = useRef(0);
|
|
@@ -915,15 +919,24 @@ export function InspectorProvider({
|
|
|
915
919
|
return () => observer.disconnect();
|
|
916
920
|
}, [selected]);
|
|
917
921
|
|
|
922
|
+
const activate = useCallback(() => {
|
|
923
|
+
manualActiveRef.current = true;
|
|
924
|
+
setManualActive(true);
|
|
925
|
+
}, []);
|
|
926
|
+
|
|
918
927
|
const toggle = useCallback(() => {
|
|
919
|
-
|
|
920
|
-
if (a) setSelected(null);
|
|
921
|
-
|
|
928
|
+
setManualActive((a) => {
|
|
929
|
+
if (a && !heldActive) setSelected(null);
|
|
930
|
+
const next = !a;
|
|
931
|
+
manualActiveRef.current = next;
|
|
932
|
+
return next;
|
|
922
933
|
});
|
|
923
|
-
}, []);
|
|
934
|
+
}, [heldActive]);
|
|
924
935
|
|
|
925
936
|
const cancel = useCallback(() => {
|
|
926
|
-
|
|
937
|
+
manualActiveRef.current = false;
|
|
938
|
+
setManualActive(false);
|
|
939
|
+
setHeldActive(false);
|
|
927
940
|
setSelected(null);
|
|
928
941
|
}, []);
|
|
929
942
|
|
|
@@ -948,6 +961,39 @@ export function InspectorProvider({
|
|
|
948
961
|
return () => window.removeEventListener('keydown', onKey);
|
|
949
962
|
}, [toggle]);
|
|
950
963
|
|
|
964
|
+
useEffect(() => {
|
|
965
|
+
if (import.meta.env.PROD) return;
|
|
966
|
+
|
|
967
|
+
const isApplePlatform = /Mac|iPhone|iPad|iPod/.test(
|
|
968
|
+
`${navigator.platform} ${navigator.userAgent}`,
|
|
969
|
+
);
|
|
970
|
+
const holdKey = isApplePlatform ? 'Meta' : 'Control';
|
|
971
|
+
|
|
972
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
973
|
+
if (e.repeat) return;
|
|
974
|
+
if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
|
|
975
|
+
if (e.key !== holdKey) return;
|
|
976
|
+
setHeldActive(true);
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
const releaseHeld = (e?: KeyboardEvent) => {
|
|
980
|
+
if (e && e.key !== holdKey) return;
|
|
981
|
+
setHeldActive(false);
|
|
982
|
+
if (!manualActiveRef.current) setSelected(null);
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
const onBlur = () => releaseHeld();
|
|
986
|
+
|
|
987
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
988
|
+
window.addEventListener('keyup', releaseHeld, true);
|
|
989
|
+
window.addEventListener('blur', onBlur, true);
|
|
990
|
+
return () => {
|
|
991
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
992
|
+
window.removeEventListener('keyup', releaseHeld, true);
|
|
993
|
+
window.removeEventListener('blur', onBlur, true);
|
|
994
|
+
};
|
|
995
|
+
}, []);
|
|
996
|
+
|
|
951
997
|
const openCrop = useCallback((anchor: HTMLImageElement) => {
|
|
952
998
|
const loc = anchor.dataset.slideLoc;
|
|
953
999
|
if (!loc) return;
|
|
@@ -973,6 +1019,7 @@ export function InspectorProvider({
|
|
|
973
1019
|
() => ({
|
|
974
1020
|
slideId,
|
|
975
1021
|
active,
|
|
1022
|
+
activate,
|
|
976
1023
|
toggle,
|
|
977
1024
|
cancel,
|
|
978
1025
|
comments,
|
|
@@ -995,6 +1042,7 @@ export function InspectorProvider({
|
|
|
995
1042
|
[
|
|
996
1043
|
slideId,
|
|
997
1044
|
active,
|
|
1045
|
+
activate,
|
|
998
1046
|
toggle,
|
|
999
1047
|
cancel,
|
|
1000
1048
|
comments,
|
|
@@ -6,6 +6,7 @@ import type { DesignSystem } from '../lib/design';
|
|
|
6
6
|
import type { Page } from '../lib/sdk';
|
|
7
7
|
import type { EntryDirection, StepAggregate, StepController } from '../lib/step-context';
|
|
8
8
|
import type { SlideTransition } from '../lib/transition';
|
|
9
|
+
import { useIsMobile } from '../lib/use-is-mobile';
|
|
9
10
|
import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
10
11
|
import { OverviewGrid } from './overview-grid';
|
|
11
12
|
import { PresentBlackoutOverlay } from './present/blackout-overlay';
|
|
@@ -27,6 +28,7 @@ import { SlideTransitionLayer } from './slide-transition-layer';
|
|
|
27
28
|
|
|
28
29
|
const IDLE_HIDE_MS = 2000;
|
|
29
30
|
const BAR_HOTZONE_PX = 160;
|
|
31
|
+
const MOBILE_CHROME_HIDE_MS = 2200;
|
|
30
32
|
|
|
31
33
|
type Props = {
|
|
32
34
|
pages: Page[];
|
|
@@ -58,6 +60,7 @@ export function Player({
|
|
|
58
60
|
slideId,
|
|
59
61
|
fullscreen = true,
|
|
60
62
|
}: Props) {
|
|
63
|
+
const isMobile = useIsMobile();
|
|
61
64
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
62
65
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
63
66
|
// Mirrored as state so descendants portaling *into* the player subtree
|
|
@@ -74,6 +77,8 @@ export function Player({
|
|
|
74
77
|
const [blackout, setBlackout] = useState<'black' | 'white' | null>(null);
|
|
75
78
|
const [laser, setLaser] = useState(false);
|
|
76
79
|
const [keyboardDriven, setKeyboardDriven] = useState(false);
|
|
80
|
+
const [mobileChromeVisible, setMobileChromeVisible] = useState(false);
|
|
81
|
+
const [mobileChromeDeadline, setMobileChromeDeadline] = useState(0);
|
|
77
82
|
const [startedAt] = useState(() => Date.now());
|
|
78
83
|
const [windowed, setWindowed] = useState(!fullscreen);
|
|
79
84
|
// Mirror windowed into a ref so the fullscreenchange listener can read the
|
|
@@ -118,6 +123,54 @@ export function Player({
|
|
|
118
123
|
}, [index, pages.length, handleIndexChange]);
|
|
119
124
|
|
|
120
125
|
const overlayActive = controls && (overviewOpen || helpOpen);
|
|
126
|
+
const overlayActiveRef = useRef(overlayActive);
|
|
127
|
+
const showMobileChrome = useCallback(() => {
|
|
128
|
+
if (!controls || !isMobile) return;
|
|
129
|
+
setMobileChromeVisible(true);
|
|
130
|
+
setMobileChromeDeadline(Date.now() + MOBILE_CHROME_HIDE_MS);
|
|
131
|
+
}, [controls, isMobile]);
|
|
132
|
+
const handleMobileViewportClick = useCallback(
|
|
133
|
+
({ y }: { x: number; y: number }) => {
|
|
134
|
+
if (!controls || !isMobile || y < 0.5) return;
|
|
135
|
+
showMobileChrome();
|
|
136
|
+
},
|
|
137
|
+
[controls, isMobile, showMobileChrome],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!controls || !isMobile) {
|
|
142
|
+
setMobileChromeVisible(false);
|
|
143
|
+
setMobileChromeDeadline(0);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setMobileChromeVisible(true);
|
|
147
|
+
setMobileChromeDeadline(Date.now() + MOBILE_CHROME_HIDE_MS);
|
|
148
|
+
}, [controls, isMobile]);
|
|
149
|
+
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const wasOverlayActive = overlayActiveRef.current;
|
|
152
|
+
overlayActiveRef.current = overlayActive;
|
|
153
|
+
if (wasOverlayActive && !overlayActive) showMobileChrome();
|
|
154
|
+
}, [overlayActive, showMobileChrome]);
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (
|
|
158
|
+
!controls ||
|
|
159
|
+
!isMobile ||
|
|
160
|
+
overlayActive ||
|
|
161
|
+
!mobileChromeVisible ||
|
|
162
|
+
mobileChromeDeadline === 0
|
|
163
|
+
) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const id = window.setTimeout(
|
|
167
|
+
() => {
|
|
168
|
+
setMobileChromeVisible(false);
|
|
169
|
+
},
|
|
170
|
+
Math.max(0, mobileChromeDeadline - Date.now()),
|
|
171
|
+
);
|
|
172
|
+
return () => window.clearTimeout(id);
|
|
173
|
+
}, [controls, isMobile, mobileChromeDeadline, mobileChromeVisible, overlayActive]);
|
|
121
174
|
|
|
122
175
|
useClickPageNavigation({
|
|
123
176
|
ref: rootRef,
|
|
@@ -126,6 +179,7 @@ export function Player({
|
|
|
126
179
|
canNext,
|
|
127
180
|
onPrev: goPrev,
|
|
128
181
|
onNext: goNext,
|
|
182
|
+
onViewportClick: controls && isMobile ? handleMobileViewportClick : undefined,
|
|
129
183
|
});
|
|
130
184
|
|
|
131
185
|
useWheelPageNavigation({
|
|
@@ -318,8 +372,11 @@ export function Player({
|
|
|
318
372
|
// The control bar + progress strip only surface when the pointer is in
|
|
319
373
|
// the bottom hot zone. Keyboard nav (arrows / space / PgDn) never reveals
|
|
320
374
|
// them — intentional so the deck stays clean during a talk.
|
|
321
|
-
const pointerNearBottom = usePointerNearBottom(
|
|
322
|
-
|
|
375
|
+
const pointerNearBottom = usePointerNearBottom(
|
|
376
|
+
BAR_HOTZONE_PX,
|
|
377
|
+
controls && !overlayActive && !isMobile,
|
|
378
|
+
);
|
|
379
|
+
const chromeVisible = overlayActive || (isMobile ? mobileChromeVisible : pointerNearBottom);
|
|
323
380
|
const idle = useIdle(IDLE_HIDE_MS, controls && !overlayActive);
|
|
324
381
|
|
|
325
382
|
useEffect(() => {
|
|
@@ -330,7 +387,9 @@ export function Player({
|
|
|
330
387
|
}, [keyboardDriven]);
|
|
331
388
|
|
|
332
389
|
const hideCursor =
|
|
333
|
-
controls &&
|
|
390
|
+
controls &&
|
|
391
|
+
!isMobile &&
|
|
392
|
+
(laser || keyboardDriven || (idle && !overlayActive && !pointerNearBottom));
|
|
334
393
|
|
|
335
394
|
return (
|
|
336
395
|
<div
|
|
@@ -340,6 +399,7 @@ export function Player({
|
|
|
340
399
|
controls && 'select-none',
|
|
341
400
|
controls && (hideCursor ? 'cursor-none' : 'cursor-default'),
|
|
342
401
|
)}
|
|
402
|
+
style={design ? { background: design.palette.bg } : undefined}
|
|
343
403
|
>
|
|
344
404
|
<SlideCanvas flat design={design}>
|
|
345
405
|
<SlideTransitionLayer
|
|
@@ -372,6 +432,7 @@ export function Player({
|
|
|
372
432
|
windowed={windowed}
|
|
373
433
|
onPrev={goPrev}
|
|
374
434
|
onNext={goNext}
|
|
435
|
+
onMobileInteraction={showMobileChrome}
|
|
375
436
|
onOverview={() => setOverviewOpen(true)}
|
|
376
437
|
onBlackout={(mode) => setBlackout((c) => (c === mode ? null : mode))}
|
|
377
438
|
onLaser={() => setLaser((v) => !v)}
|