@open-slide/core 2.1.0 → 2.3.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.
Files changed (53) hide show
  1. package/dist/{build-COxfoC_P.js → build-8lRsgsO4.js} +1 -1
  2. package/dist/cli/bin.js +4 -4
  3. package/dist/{config-DHPbCCnt.d.ts → config-CDrYgaEj.d.ts} +6 -2
  4. package/dist/{config-CNhYSo4C.js → config-D2Mq1vSW.js} +2162 -368
  5. package/dist/{dev-CujpTS3T.js → dev-BvefEp1Q.js} +1 -1
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.js +1 -1
  8. package/dist/locale/index.d.ts +1 -1
  9. package/dist/locale/index.js +1 -1
  10. package/dist/{preview-kU5R6QXJ.js → preview-D8ognobz.js} +1 -1
  11. package/dist/{types-BGUi9COY.d.ts → types-DFK02XVv.d.ts} +119 -4
  12. package/dist/{update-CPBitJQq.js → update-BivdNgL3.js} +128 -7
  13. package/dist/vite/index.d.ts +1 -1
  14. package/dist/vite/index.js +1 -1
  15. package/dist/{zh-tw-BbFb4PZW.js → zh-tw-B1pkKQsc.js} +570 -20
  16. package/package.json +5 -5
  17. package/skills/apply-comments/SKILL.md +9 -6
  18. package/src/app/components/agent/agent-dock.tsx +35 -0
  19. package/src/app/components/agent/agent-markdown.tsx +45 -0
  20. package/src/app/components/agent/agent-panel.tsx +692 -0
  21. package/src/app/components/agent/agent-presence.tsx +74 -0
  22. package/src/app/components/agent/composer.tsx +120 -0
  23. package/src/app/components/agent/connect-view.tsx +184 -0
  24. package/src/app/components/agent/history-view.tsx +135 -0
  25. package/src/app/components/agent/provider-logo.tsx +34 -0
  26. package/src/app/components/agent/transcript.tsx +609 -0
  27. package/src/app/components/command/slide-command-menu.tsx +10 -0
  28. package/src/app/components/icon-switcher-indicator.tsx +1 -1
  29. package/src/app/components/inspector/comment-layer.tsx +1011 -0
  30. package/src/app/components/inspector/image-crop-dialog.tsx +1 -5
  31. package/src/app/components/inspector/inspect-overlay.tsx +2 -39
  32. package/src/app/components/inspector/inspector-panel.tsx +10 -93
  33. package/src/app/components/inspector/inspector-provider.tsx +120 -46
  34. package/src/app/components/panel/editor-sidebar.tsx +85 -16
  35. package/src/app/components/panel/panel-shell.tsx +2 -2
  36. package/src/app/components/panel/resize-handle.tsx +129 -0
  37. package/src/app/components/player.tsx +0 -1
  38. package/src/app/components/thumbnail-rail.tsx +39 -1
  39. package/src/app/lib/agent/use-agent.ts +543 -0
  40. package/src/app/lib/inspector/freeze-motion.ts +61 -0
  41. package/src/app/lib/inspector/use-comments.ts +32 -3
  42. package/src/app/lib/use-auto-grow.ts +15 -0
  43. package/src/app/lib/utils.ts +4 -0
  44. package/src/app/routes/home.tsx +43 -7
  45. package/src/app/routes/slide.tsx +109 -109
  46. package/src/app/styles.css +234 -80
  47. package/src/locale/en.ts +113 -4
  48. package/src/locale/es.ts +115 -5
  49. package/src/locale/ja.ts +106 -5
  50. package/src/locale/types.ts +118 -4
  51. package/src/locale/zh-cn.ts +103 -4
  52. package/src/locale/zh-tw.ts +103 -4
  53. package/src/app/components/inspector/comment-widget.tsx +0 -119
@@ -0,0 +1,129 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { clamp, cn } from '@/lib/utils';
3
+
4
+ export function useStoredWidth(key: string, fallback: number, min: number, max: number) {
5
+ const [width, setWidth] = useState<number>(() => {
6
+ try {
7
+ const parsed = Number(window.localStorage.getItem(key) ?? Number.NaN);
8
+ return Number.isFinite(parsed) ? clamp(parsed, min, max) : fallback;
9
+ } catch {
10
+ return fallback;
11
+ }
12
+ });
13
+ useEffect(() => {
14
+ try {
15
+ window.localStorage.setItem(key, String(width));
16
+ } catch {}
17
+ }, [key, width]);
18
+ return [width, setWidth] as const;
19
+ }
20
+
21
+ // A vertical splitter on one edge of a panel. `edge` is the side of the panel
22
+ // it sits on, so dragging away from the panel always makes it wider.
23
+ export function ResizeHandle({
24
+ width,
25
+ min,
26
+ max,
27
+ defaultWidth,
28
+ edge,
29
+ label,
30
+ onResize,
31
+ onResizingChange,
32
+ className,
33
+ }: {
34
+ width: number;
35
+ min: number;
36
+ max: number;
37
+ defaultWidth: number;
38
+ edge: 'left' | 'right';
39
+ label: string;
40
+ onResize: (width: number) => void;
41
+ onResizingChange?: (resizing: boolean) => void;
42
+ className?: string;
43
+ }) {
44
+ const [resizing, setResizing] = useState(false);
45
+ const dragRef = useRef<{ startX: number; startWidth: number } | null>(null);
46
+ const direction = edge === 'right' ? 1 : -1;
47
+
48
+ useEffect(() => {
49
+ onResizingChange?.(resizing);
50
+ if (!resizing) return;
51
+ const prev = {
52
+ cursor: document.body.style.cursor,
53
+ userSelect: document.body.style.userSelect,
54
+ };
55
+ document.body.style.cursor = 'col-resize';
56
+ document.body.style.userSelect = 'none';
57
+ return () => {
58
+ document.body.style.cursor = prev.cursor;
59
+ document.body.style.userSelect = prev.userSelect;
60
+ };
61
+ }, [resizing, onResizingChange]);
62
+
63
+ const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
64
+ e.preventDefault();
65
+ e.currentTarget.setPointerCapture(e.pointerId);
66
+ dragRef.current = { startX: e.clientX, startWidth: width };
67
+ setResizing(true);
68
+ };
69
+
70
+ const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
71
+ if (!dragRef.current) return;
72
+ const delta = (e.clientX - dragRef.current.startX) * direction;
73
+ onResize(clamp(dragRef.current.startWidth + delta, min, max));
74
+ };
75
+
76
+ const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
77
+ if (e.currentTarget.hasPointerCapture(e.pointerId)) {
78
+ e.currentTarget.releasePointerCapture(e.pointerId);
79
+ }
80
+ dragRef.current = null;
81
+ setResizing(false);
82
+ };
83
+
84
+ const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
85
+ const step = (e.shiftKey ? 32 : 8) * direction;
86
+ let next: number | null = null;
87
+ if (e.key === 'ArrowLeft') next = width - step;
88
+ else if (e.key === 'ArrowRight') next = width + step;
89
+ else if (e.key === 'Home') next = defaultWidth;
90
+ if (next === null) return;
91
+ e.preventDefault();
92
+ e.stopPropagation();
93
+ onResize(clamp(next, min, max));
94
+ };
95
+
96
+ return (
97
+ // biome-ignore lint/a11y/useSemanticElements: focusable resize handle (splitter pattern), not a static <hr>
98
+ <div
99
+ role="separator"
100
+ aria-orientation="vertical"
101
+ aria-label={label}
102
+ aria-valuenow={width}
103
+ aria-valuemin={min}
104
+ aria-valuemax={max}
105
+ tabIndex={0}
106
+ onPointerDown={onPointerDown}
107
+ onPointerMove={onPointerMove}
108
+ onPointerUp={onPointerUp}
109
+ onPointerCancel={onPointerUp}
110
+ onKeyDown={onKeyDown}
111
+ onDoubleClick={() => onResize(defaultWidth)}
112
+ className={cn(
113
+ 'group/resize absolute inset-y-0 z-20 w-1.5 cursor-col-resize touch-none outline-none',
114
+ 'focus-visible:bg-brand/20',
115
+ className,
116
+ )}
117
+ >
118
+ <span
119
+ aria-hidden
120
+ className={cn(
121
+ 'pointer-events-none absolute inset-y-0 w-px bg-brand opacity-0 transition-opacity duration-150',
122
+ edge === 'right' ? 'left-1/2 -translate-x-1/2' : 'left-0',
123
+ 'group-hover/resize:opacity-100 group-focus-visible/resize:opacity-100',
124
+ resizing && 'opacity-100',
125
+ )}
126
+ />
127
+ </div>
128
+ );
129
+ }
@@ -402,7 +402,6 @@ export function Player({
402
402
  controls && 'select-none',
403
403
  controls && (hideCursor ? 'cursor-none' : 'cursor-default'),
404
404
  )}
405
- style={design ? { background: design.palette.bg } : undefined}
406
405
  >
407
406
  <SlideCanvas flat design={design}>
408
407
  {/* Keyed per deck so a presenter-driven deck switch cuts instead of
@@ -26,6 +26,7 @@ import {
26
26
  Trash2,
27
27
  } from 'lucide-react';
28
28
  import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
29
+ import { useOptionalInspector } from '@/components/inspector/inspector-provider';
29
30
  import { Button } from '@/components/ui/button';
30
31
  import {
31
32
  ContextMenu,
@@ -36,7 +37,7 @@ import {
36
37
  } from '@/components/ui/context-menu';
37
38
  import { ScrollArea } from '@/components/ui/scroll-area';
38
39
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
39
- import { format, useLocale } from '@/lib/use-locale';
40
+ import { format, plural, useLocale } from '@/lib/use-locale';
40
41
  import { cn, pad2 } from '@/lib/utils';
41
42
  import type { DesignSystem } from '../lib/design';
42
43
  import { SlidePageProvider } from '../lib/page-context';
@@ -74,6 +75,36 @@ type Props = {
74
75
  onOverview?: () => void;
75
76
  };
76
77
 
78
+ // Per-page pending comment counts, shown on the rail only while the
79
+ // comment tool is active.
80
+ function usePageCommentCounts(): Map<number, number> | null {
81
+ const inspector = useOptionalInspector();
82
+ if (!inspector?.commentMode) return null;
83
+ const counts = new Map<number, number>();
84
+ for (const comment of inspector.comments) {
85
+ if (comment.page === undefined) continue;
86
+ counts.set(comment.page, (counts.get(comment.page) ?? 0) + 1);
87
+ }
88
+ return counts;
89
+ }
90
+
91
+ function CommentCountBadge({ count, className }: { count: number; className?: string }) {
92
+ const t = useLocale();
93
+ return (
94
+ <span
95
+ role="img"
96
+ aria-label={format(plural(count, t.inspector.commentsCount), { count })}
97
+ data-page-comments={count}
98
+ className={cn(
99
+ 'flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 font-mono text-[9.5px] font-semibold leading-none text-brand-foreground tabular-nums',
100
+ className,
101
+ )}
102
+ >
103
+ {count}
104
+ </span>
105
+ );
106
+ }
107
+
77
108
  const DEFAULT_VERTICAL_THUMB_WIDTH = 184;
78
109
  const VERTICAL_RAIL_CHROME = 80;
79
110
  const MIN_VERTICAL_THUMB_WIDTH = 120;
@@ -522,10 +553,12 @@ function HorizontalVirtualThumbList({
522
553
  }, [current, itemWidth, pages.length, thumbWidth]);
523
554
 
524
555
  const visibleRange = clampVisibleRange(range, current, pages.length);
556
+ const commentCounts = usePageCommentCounts();
525
557
  const visible = [];
526
558
  for (let i = visibleRange.start; i < visibleRange.end; i++) {
527
559
  const PageComp = pages[i];
528
560
  const active = i === current;
561
+ const commentCount = commentCounts?.get(i) ?? 0;
529
562
  const button = (
530
563
  <button
531
564
  type="button"
@@ -562,6 +595,9 @@ function HorizontalVirtualThumbList({
562
595
  </SlidePageProvider>
563
596
  </SlideCanvas>
564
597
  </div>
598
+ {commentCount > 0 && (
599
+ <CommentCountBadge count={commentCount} className="absolute -top-0.5 -right-1" />
600
+ )}
565
601
  </button>
566
602
  );
567
603
 
@@ -798,6 +834,7 @@ function ThumbContents({
798
834
  }, [PageComp]);
799
835
 
800
836
  const hasTransition = Boolean(PageComp.transition ?? moduleTransition);
837
+ const commentCount = usePageCommentCounts()?.get(index) ?? 0;
801
838
 
802
839
  return (
803
840
  <>
@@ -810,6 +847,7 @@ function ThumbContents({
810
847
  >
811
848
  {pad2(index + 1)}
812
849
  </span>
850
+ {commentCount > 0 && <CommentCountBadge count={commentCount} />}
813
851
  {(hasTransition || hasSteps) && (
814
852
  <div className="flex flex-col items-end gap-0.5">
815
853
  {hasTransition && (