@open-slide/core 2.3.1 → 2.4.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 (89) hide show
  1. package/dist/{build-8lRsgsO4.js → build-D7GwYl8d.js} +1 -1
  2. package/dist/cli/bin.js +4 -4
  3. package/dist/{config-CDrYgaEj.d.ts → config-CfhtJxQH.d.ts} +1 -1
  4. package/dist/{config-D2Mq1vSW.js → config-D4uPk_tM.js} +383 -138
  5. package/dist/{dev-BvefEp1Q.js → dev-DyCDMbHB.js} +10 -10
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +9 -1
  8. package/dist/locale/index.d.ts +1 -1
  9. package/dist/locale/index.js +1 -1
  10. package/dist/{preview-D8ognobz.js → preview-DjIFvt0K.js} +1 -1
  11. package/dist/{types-DFK02XVv.d.ts → types-ZfArJF0d.d.ts} +21 -13
  12. package/dist/{update-BivdNgL3.js → update-BKhRM7o4.js} +30 -3
  13. package/dist/vite/index.d.ts +1 -1
  14. package/dist/vite/index.js +1 -1
  15. package/dist/{zh-tw-B1pkKQsc.js → zh-tw-D7LfGVmA.js} +220 -65
  16. package/package.json +5 -6
  17. package/src/agent/provider.ts +8 -1
  18. package/src/agent/types.ts +17 -2
  19. package/src/app/app.tsx +2 -0
  20. package/src/app/components/agent/agent-markdown.tsx +3 -6
  21. package/src/app/components/agent/agent-panel.tsx +36 -258
  22. package/src/app/components/agent/agent-presence.tsx +1 -1
  23. package/src/app/components/agent/composer.tsx +52 -24
  24. package/src/app/components/agent/effort-slider.tsx +172 -0
  25. package/src/app/components/agent/model-menu.tsx +170 -0
  26. package/src/app/components/agent/permission-menu.tsx +88 -0
  27. package/src/app/components/agent/transcript.tsx +23 -31
  28. package/src/app/components/command/home-command-menu.tsx +4 -1
  29. package/src/app/components/command/slide-command-menu.tsx +4 -1
  30. package/src/app/components/export-progress-toast.tsx +3 -1
  31. package/src/app/components/inspector/asset-picker-dialog.tsx +1 -1
  32. package/src/app/components/inspector/comment-layer.tsx +3 -3
  33. package/src/app/components/inspector/inline-text-editor.tsx +1 -12
  34. package/src/app/components/inspector/inspect-overlay.tsx +9 -1
  35. package/src/app/components/inspector/inspector-panel.tsx +8 -35
  36. package/src/app/components/inspector/inspector-provider.tsx +177 -36
  37. package/src/app/components/inspector/page-panel.tsx +270 -0
  38. package/src/app/components/language-toggle.tsx +13 -11
  39. package/src/app/components/note-markdown.test.tsx +12 -6
  40. package/src/app/components/note-markdown.tsx +16 -21
  41. package/src/app/components/overview-grid.tsx +3 -3
  42. package/src/app/components/panel/editor-sidebar.tsx +43 -8
  43. package/src/app/components/panel/panel-shell.tsx +9 -5
  44. package/src/app/components/panel/save-card.tsx +1 -1
  45. package/src/app/components/player.tsx +105 -23
  46. package/src/app/components/present/curtain.tsx +52 -0
  47. package/src/app/components/present/last-slide-hint.tsx +36 -0
  48. package/src/app/components/sidebar/folder-item.tsx +4 -1
  49. package/src/app/components/sidebar/sidebar.tsx +11 -8
  50. package/src/app/components/slide-canvas.tsx +1 -1
  51. package/src/app/components/style-panel/design-provider.tsx +48 -11
  52. package/src/app/components/style-panel/use-design.ts +6 -1
  53. package/src/app/components/theme-toggle.tsx +16 -22
  54. package/src/app/components/thumbnail-rail.tsx +69 -50
  55. package/src/app/components/ui/context-menu.tsx +9 -10
  56. package/src/app/components/ui/dialog.tsx +2 -4
  57. package/src/app/components/ui/dropdown-menu.tsx +9 -10
  58. package/src/app/components/ui/popover.tsx +1 -1
  59. package/src/app/components/ui/select.tsx +2 -2
  60. package/src/app/components/ui/sonner.tsx +2 -2
  61. package/src/app/index.html +7 -0
  62. package/src/app/lib/agent/use-agent.ts +131 -37
  63. package/src/app/lib/desktop-host.ts +31 -0
  64. package/src/app/lib/desktop-routes.test.ts +54 -0
  65. package/src/app/lib/desktop-routes.ts +22 -0
  66. package/src/app/lib/desktop.ts +106 -0
  67. package/src/app/lib/export-pdf.ts +15 -7
  68. package/src/app/lib/inspector/color.ts +51 -0
  69. package/src/app/lib/inspector/fiber.ts +6 -0
  70. package/src/app/lib/inspector/use-editor.ts +2 -1
  71. package/src/app/lib/inspector/use-notes.test.ts +209 -0
  72. package/src/app/lib/inspector/use-notes.ts +331 -57
  73. package/src/app/lib/inspector/use-visual-editor.ts +9 -1
  74. package/src/app/lib/locale-store.ts +14 -2
  75. package/src/app/lib/note-markdown.test.ts +69 -5
  76. package/src/app/lib/note-markdown.ts +97 -22
  77. package/src/app/lib/transition.test.ts +84 -1
  78. package/src/app/lib/transition.ts +43 -0
  79. package/src/app/lib/unsaved.test.ts +253 -0
  80. package/src/app/lib/unsaved.ts +155 -0
  81. package/src/app/routes/home.tsx +14 -6
  82. package/src/app/routes/slide.tsx +184 -130
  83. package/src/app/styles.css +421 -1
  84. package/src/locale/en.ts +41 -15
  85. package/src/locale/es.ts +41 -17
  86. package/src/locale/ja.ts +41 -15
  87. package/src/locale/types.ts +20 -14
  88. package/src/locale/zh-cn.ts +41 -14
  89. package/src/locale/zh-tw.ts +41 -14
@@ -0,0 +1,155 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import type { UnsavedAction, UnsavedOutcome, UnsavedStatus } from './desktop-host';
3
+
4
+ export type UnsavedSource = {
5
+ // A draft waits for the user to save it; autosaved work is unsaved only until its write lands.
6
+ kind: 'draft' | 'autosave';
7
+ dirty: () => boolean;
8
+ save: () => Promise<void>;
9
+ discard: () => void;
10
+ };
11
+
12
+ type Write = () => Promise<unknown>;
13
+
14
+ const sources = new Set<UnsavedSource>();
15
+ const writes = new Map<unknown, Promise<unknown>>();
16
+ const failed = new Map<unknown, Write>();
17
+ const abandonListeners = new Set<() => void>();
18
+
19
+ export function registerUnsaved(source: UnsavedSource): () => void {
20
+ sources.add(source);
21
+ return () => {
22
+ sources.delete(source);
23
+ };
24
+ }
25
+
26
+ // For a write that outlives the component that started it, such as a flush on
27
+ // unmount. A failed one is retried on the next save until it lands or the work
28
+ // is abandoned; a newer write under the same key replaces it.
29
+ export function trackWrite(key: unknown, write: Write): void {
30
+ const attempt = write();
31
+ writes.set(key, attempt);
32
+ failed.delete(key);
33
+ const finish = (retry?: Write) => {
34
+ if (writes.get(key) !== attempt) return;
35
+ writes.delete(key);
36
+ if (retry) failed.set(key, retry);
37
+ };
38
+ attempt.then(
39
+ () => finish(),
40
+ () => finish(write),
41
+ );
42
+ }
43
+
44
+ export function onAbandon(listener: () => void): () => void {
45
+ abandonListeners.add(listener);
46
+ return () => {
47
+ abandonListeners.delete(listener);
48
+ };
49
+ }
50
+
51
+ // For work that reached disk some other way after its tracked write failed.
52
+ export function forgetWrite(key: unknown): void {
53
+ failed.delete(key);
54
+ }
55
+
56
+ export function unsavedStatus(): UnsavedStatus {
57
+ let drafts = false;
58
+ let pending = writes.size > 0 || failed.size > 0;
59
+ for (const source of sources) {
60
+ if (!source.dirty()) continue;
61
+ if (source.kind === 'draft') drafts = true;
62
+ else pending = true;
63
+ }
64
+ return { drafts, pending };
65
+ }
66
+
67
+ export function hasUnsaved(): boolean {
68
+ const { drafts, pending } = unsavedStatus();
69
+ return drafts || pending;
70
+ }
71
+
72
+ function describe(error: unknown): string {
73
+ return error instanceof Error ? error.message : String(error);
74
+ }
75
+
76
+ export async function settleUnsaved(action: UnsavedAction): Promise<UnsavedOutcome> {
77
+ const errors: string[] = [];
78
+ for (const source of [...sources]) {
79
+ if (!source.dirty()) continue;
80
+ if (action === 'abandon' || (action === 'discard' && source.kind === 'draft')) {
81
+ source.discard();
82
+ continue;
83
+ }
84
+ try {
85
+ await source.save();
86
+ } catch (err) {
87
+ errors.push(describe(err));
88
+ }
89
+ }
90
+ if (action === 'abandon') {
91
+ // In-flight writes too, so one that fails later is not kept for a retry.
92
+ writes.clear();
93
+ failed.clear();
94
+ for (const listener of abandonListeners) listener();
95
+ return { ok: true };
96
+ }
97
+ for (const [key, write] of [...failed]) trackWrite(key, write);
98
+ for (const result of await Promise.allSettled([...writes.values()])) {
99
+ if (result.status === 'rejected') errors.push(describe(result.reason));
100
+ }
101
+ if (errors.length > 0) return { ok: false, error: errors.join(' ') };
102
+ if (hasUnsaved()) {
103
+ return { ok: false, error: 'More changes were made while saving.' };
104
+ }
105
+ return { ok: true };
106
+ }
107
+
108
+ export function useUnsavedSource(source: UnsavedSource) {
109
+ const latest = useRef(source);
110
+ latest.current = source;
111
+ const { kind } = source;
112
+ useEffect(
113
+ () =>
114
+ registerUnsaved({
115
+ kind,
116
+ dirty: () => latest.current.dirty(),
117
+ save: () => latest.current.save(),
118
+ discard: () => latest.current.discard(),
119
+ }),
120
+ [kind],
121
+ );
122
+ }
123
+
124
+ // For writes that carry no base revision: a retried one would otherwise replace
125
+ // a value that a newer write has saved since.
126
+ export function createWriteLedger() {
127
+ let seq = 0;
128
+ const saved = new Map<string, number>();
129
+ const superseded = (key: string, writeSeq: number) =>
130
+ (saved.get(key) ?? Number.NEGATIVE_INFINITY) > writeSeq;
131
+ return {
132
+ next: () => ++seq,
133
+ superseded,
134
+ record(key: string, writeSeq: number) {
135
+ if (!superseded(key, writeSeq)) saved.set(key, writeSeq);
136
+ },
137
+ };
138
+ }
139
+
140
+ // Runs saves one after another, each starting once the previous one settles.
141
+ export function createSaveQueue() {
142
+ let tail: Promise<unknown> = Promise.resolve();
143
+ let size = 0;
144
+ return {
145
+ run<T>(task: () => Promise<T>, onIdle?: () => void): Promise<T> {
146
+ size++;
147
+ const result = tail.then(task).finally(() => {
148
+ if (--size === 0) onIdle?.();
149
+ });
150
+ tail = result.catch(() => {});
151
+ return result;
152
+ },
153
+ busy: () => size > 0,
154
+ };
155
+ }
@@ -323,10 +323,12 @@ function SortControl({ value, onChange }: { value: SortKey; onChange: (next: Sor
323
323
  );
324
324
  }
325
325
 
326
+ // Offered even before an agent is connected: the new deck opens the agent
327
+ // panel, which walks first-time users through installing one.
326
328
  function useCreateDeckWithAgent() {
327
- const { provider } = useAgentStatus();
329
+ const { enabled, provider } = useAgentStatus();
328
330
  const start = useCreateDeck();
329
- if (!provider) return null;
331
+ if (!enabled) return null;
330
332
  return { provider, start };
331
333
  }
332
334
 
@@ -339,7 +341,11 @@ function NewDeckButton() {
339
341
  size="sm"
340
342
  className="h-8 shrink-0"
341
343
  onClick={agent.start}
342
- title={format(t.agent.createDeckWith, { provider: agent.provider.name })}
344
+ title={
345
+ agent.provider
346
+ ? format(t.agent.createDeckWith, { provider: agent.provider.name })
347
+ : t.agent.createDeck
348
+ }
343
349
  >
344
350
  <Plus />
345
351
  {t.agent.createDeck}
@@ -404,8 +410,10 @@ function EmptyState({ isDraft, folderName }: { isDraft: boolean; folderName?: st
404
410
  </p>
405
411
  {agent ? (
406
412
  <Button size="sm" className="mt-4" onClick={agent.start}>
407
- <ProviderLogo provider={agent.provider.id} />
408
- {format(t.agent.createDeckWith, { provider: agent.provider.name })}
413
+ {agent.provider ? <ProviderLogo provider={agent.provider.id} /> : <Plus />}
414
+ {agent.provider
415
+ ? format(t.agent.createDeckWith, { provider: agent.provider.name })
416
+ : t.agent.createDeck}
409
417
  </Button>
410
418
  ) : (
411
419
  <p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
@@ -584,7 +592,7 @@ function SlideCard({
584
592
  <button
585
593
  type="button"
586
594
  onClick={(e) => e.stopPropagation()}
587
- className="flex size-7 items-center justify-center rounded-[5px] bg-card/90 text-foreground shadow-edge ring-1 ring-border opacity-0 outline-none backdrop-blur hover:bg-card group-hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-ring/40 aria-expanded:opacity-100 motion-safe:transition-opacity motion-safe:duration-150"
595
+ className="flex size-7 items-center justify-center rounded-[5px] bg-material text-foreground shadow-edge ring-1 ring-border opacity-0 outline-none backdrop-blur-xl backdrop-saturate-150 hover:bg-card group-hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-ring/40 aria-expanded:opacity-100 motion-safe:transition-opacity motion-safe:duration-150"
588
596
  aria-label={tCard.home.slideActions}
589
597
  >
590
598
  <MoreHorizontal className="size-3.5" />