@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
@@ -1,5 +1,5 @@
1
1
  import { a as printUrls, i as printShortcutsHint, n as formatError, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
2
- import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-CNhYSo4C.js";
2
+ import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-D2Mq1vSW.js";
3
3
  import path from "node:path";
4
4
  import { existsSync } from "node:fs";
5
5
  import { fork } from "node:child_process";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as Plural, t as Locale } from "./types-BGUi9COY.js";
2
- import { t as OpenSlideConfig } from "./config-DHPbCCnt.js";
1
+ import { n as Plural, t as Locale } from "./types-DFK02XVv.js";
2
+ import { n as OpenSlideConfig, t as OpenSlideAgentConfig } from "./config-CDrYgaEj.js";
3
3
  import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
4
4
  //#region src/app/components/image-placeholder.d.ts
5
5
  type ImagePlaceholderProps = {
@@ -103,4 +103,4 @@ type InternalStepProps = StepProps & {
103
103
  };
104
104
  declare function Step({ children, duration, _revealed }: InternalStepProps): import("react").JSX.Element;
105
105
  //#endregion
106
- export { CANVAS_HEIGHT, CANVAS_WIDTH, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, ImagePlaceholder, type ImagePlaceholderProps, type Locale, MorphElement, type MorphElementProps, type MorphTransition, type OpenSlideConfig, type Page, type Plural, type SlideMeta, type SlideModule, type SlideTransition, Step, type StepProps, Steps, type StepsProps, type TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useIsActivePage, useSlidePageNumber };
106
+ export { CANVAS_HEIGHT, CANVAS_WIDTH, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, ImagePlaceholder, type ImagePlaceholderProps, type Locale, MorphElement, type MorphElementProps, type MorphTransition, type OpenSlideAgentConfig, type OpenSlideConfig, type Page, type Plural, type SlideMeta, type SlideModule, type SlideTransition, Step, type StepProps, Steps, type StepsProps, type TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useIsActivePage, useSlidePageNumber };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "./zh-tw-BbFb4PZW.js";
1
+ import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "./zh-tw-B1pkKQsc.js";
2
2
  import { n as defaultDesign, r as designToCssVars, t as cssVarsToString } from "./design-Cpqx7SJs.js";
3
3
  import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { toast } from "sonner";
@@ -1,4 +1,4 @@
1
- import { n as Plural, t as Locale } from "../types-BGUi9COY.js";
1
+ import { n as Plural, t as Locale } from "../types-DFK02XVv.js";
2
2
  //#region src/locale/en.d.ts
3
3
  declare const en: Locale;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "../zh-tw-BbFb4PZW.js";
1
+ import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "../zh-tw-B1pkKQsc.js";
2
2
  //#region src/locale/format.ts
3
3
  function format(template, vars) {
4
4
  return template.replace(/\{(\w+)\}/g, (m, key) => {
@@ -1,5 +1,5 @@
1
1
  import { a as printUrls, i as printShortcutsHint, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
2
- import { t as createViteConfig } from "./config-CNhYSo4C.js";
2
+ import { t as createViteConfig } from "./config-D2Mq1vSW.js";
3
3
  import { mergeConfig, preview as preview$1 } from "vite";
4
4
  //#region src/cli/preview.ts
5
5
  async function preview(opts = {}) {
@@ -1,3 +1,7 @@
1
+ //#region src/agent/types.d.ts
2
+ declare const AGENT_EFFORTS: readonly ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
3
+ type AgentEffort = (typeof AGENT_EFFORTS)[number];
4
+ //#endregion
1
5
  //#region src/locale/types.d.ts
2
6
  type Plural = {
3
7
  one: string;
@@ -99,6 +103,7 @@ type Locale = {
99
103
  pickIcon: string;
100
104
  };
101
105
  slide: {
106
+ resizeSidePanel: string;
102
107
  home: string;
103
108
  backToHome: string;
104
109
  agentConnected: string;
@@ -283,20 +288,25 @@ type Locale = {
283
288
  cropFitCover: string;
284
289
  cropFitContain: string;
285
290
  cropApply: string;
286
- leaveComment: string;
291
+ commentMode: string;
287
292
  commentPlaceholder: string;
288
- commentShortcutHint: string;
289
- addComment: string;
293
+ commentPost: string;
290
294
  /** templates: "{count} unsaved change" / "{count} unsaved changes" */
291
295
  unsavedChanges: Plural;
292
296
  /** templates: "{count} comment" / "{count} comments" */
293
297
  commentsCount: Plural;
294
298
  /** template: "line {n}" */
295
299
  commentLineLabel: string;
296
- commentsEmpty: string;
300
+ commentRegionLabel: string;
301
+ commentEmptyHint: string;
297
302
  commentsApplyHintPrefix: string;
298
303
  commentsApplyHintSuffix: string;
299
304
  commentDeleteAria: string;
305
+ /** Prefix for the toast shown when a comment edit fails to write to disk. */
306
+ commentUpdateFailed: string;
307
+ /** Prefix for the toast shown when a comment fails to write to disk. */
308
+ commentAddFailed: string;
309
+ commentRegionNoTarget: string;
300
310
  /** Prefix for the toast shown when one or more buffered edits fail to write to disk. */
301
311
  saveFailed: string;
302
312
  decreaseFontSize: string;
@@ -555,6 +565,111 @@ type Locale = {
555
565
  expandPromptAria: string;
556
566
  collapsePromptAria: string;
557
567
  };
568
+ agent: {
569
+ title: string;
570
+ beta: string;
571
+ betaTitle: string;
572
+ betaHint: string;
573
+ open: string;
574
+ openTitle: string;
575
+ close: string;
576
+ newSession: string;
577
+ sessions: string;
578
+ noSessions: string;
579
+ deleteSession: string;
580
+ historyThisDeck: string;
581
+ historyOtherDecks: string;
582
+ historyEmptyHint: string;
583
+ sessionRunning: string;
584
+ /** template: "Ask {provider} to create or edit slides…" */
585
+ composerPlaceholder: string;
586
+ send: string;
587
+ stop: string;
588
+ working: string;
589
+ /** template: "Page {n}" */
590
+ contextPage: string;
591
+ contextSelection: string;
592
+ /** plural, template: "{count} comments" */
593
+ pendingComments: Plural;
594
+ applyComments: string;
595
+ /** template: "Apply with {provider}" */
596
+ applyCommentsWith: string;
597
+ createDeck: string;
598
+ /** template: "Create a deck with {provider}" */
599
+ createDeckWith: string;
600
+ quickCreate: string;
601
+ quickCreateHint: string;
602
+ quickApply: string;
603
+ quickApplyHint: string;
604
+ quickTheme: string;
605
+ quickThemeHint: string;
606
+ quickEdit: string;
607
+ quickEditHint: string;
608
+ emptyTitle: string;
609
+ emptyHint: string;
610
+ questionSubmit: string;
611
+ questionOther: string;
612
+ questionOtherPlaceholder: string;
613
+ questionCancelled: string;
614
+ permissionTitle: string;
615
+ allow: string;
616
+ deny: string;
617
+ allowed: string;
618
+ denied: string;
619
+ autoApprove: string;
620
+ autoApproveHint: string;
621
+ resultDone: string;
622
+ resultStopped: string;
623
+ /** template: "{seconds}s" */
624
+ resultSeconds: string;
625
+ errorEyebrow: string;
626
+ statusLoading: string;
627
+ disabled: string;
628
+ connectTitle: string;
629
+ connectDescription: string;
630
+ connect: string;
631
+ connecting: string;
632
+ connected: string;
633
+ /** template: "Adds {pkg} to this workspace with {pm}." */
634
+ connectInstallHint: string;
635
+ /** template: "CLI found · v{version}" */
636
+ cliFound: string;
637
+ cliFoundNoVersion: string;
638
+ cliMissing: string;
639
+ /** template: "Install the {name} CLI and sign in once; the panel reuses its login." */
640
+ cliHint: string;
641
+ needCliTitle: string;
642
+ needCliDescription: string;
643
+ checkAgain: string;
644
+ retry: string;
645
+ /** template: "{name} connected" */
646
+ toastConnected: string;
647
+ /** template: "Could not install {pkg}" */
648
+ toastConnectFailed: string;
649
+ manageConnections: string;
650
+ backToChat: string;
651
+ toastSendFailed: string;
652
+ newDeckTitle: string;
653
+ newDeckHint: string;
654
+ newDeckPlaceholder: string;
655
+ toastCreateDeckFailed: string;
656
+ steps: Plural;
657
+ questionSkip: string;
658
+ copyMessage: string;
659
+ copied: string;
660
+ editMessage: string;
661
+ cancelEdit: string;
662
+ sendEdit: string;
663
+ editHint: string;
664
+ modelDefault: string;
665
+ reasoning: string;
666
+ effortAuto: string;
667
+ efforts: Record<AgentEffort, string>;
668
+ /** template: "{provider} is editing" */
669
+ presenceEditing: string;
670
+ presenceThinking: string;
671
+ presenceWaiting: string;
672
+ };
558
673
  };
559
674
  //#endregion
560
675
  export { Plural as n, Locale as t };
@@ -65,6 +65,10 @@ function validateMutationRequest(req, opts = {}) {
65
65
  };
66
66
  return { ok: true };
67
67
  }
68
+ function isLoopbackRequest(req) {
69
+ const address = req.socket.remoteAddress ?? "";
70
+ return address === "::1" || address.startsWith("127.") || address.startsWith("::ffff:127.");
71
+ }
68
72
  //#endregion
69
73
  //#region src/editing/slide-ops.ts
70
74
  const SLIDE_ID_RE = /^[a-z0-9_-]+$/i;
@@ -262,6 +266,106 @@ async function duplicateSlideDir(slidesRoot, slideId, desiredId) {
262
266
  };
263
267
  }
264
268
  }
269
+ const BLANK_SLIDE_TITLE = "Untitled";
270
+ function blankSlideSource(createdAt) {
271
+ return `import type { Page, SlideMeta } from '@open-slide/core';
272
+
273
+ export const meta: SlideMeta = { title: ${JSON.stringify(BLANK_SLIDE_TITLE)}, createdAt: ${JSON.stringify(createdAt)} };
274
+
275
+ const Blank: Page = () => <div style={{ width: '100%', height: '100%', background: '#ffffff' }} />;
276
+
277
+ export default [Blank] satisfies Page[];
278
+ `;
279
+ }
280
+ async function createBlankSlideDir(slidesRoot) {
281
+ const root = path.resolve(slidesRoot);
282
+ await fs.mkdir(root, { recursive: true });
283
+ for (let suffix = 1; suffix < 1e3; suffix++) {
284
+ const slideId = suffix === 1 ? "untitled" : `untitled-${suffix}`;
285
+ if (await slideIdTaken(root, slideId)) continue;
286
+ const dir = path.join(root, slideId);
287
+ try {
288
+ await fs.mkdir(dir);
289
+ } catch (err) {
290
+ if (err.code === "EEXIST") continue;
291
+ return {
292
+ ok: false,
293
+ status: 500,
294
+ error: String(err.message ?? err)
295
+ };
296
+ }
297
+ const file = path.join(dir, "index.tsx");
298
+ await fs.writeFile(file, blankSlideSource((/* @__PURE__ */ new Date()).toISOString()), "utf8");
299
+ return {
300
+ ok: true,
301
+ slideId,
302
+ file
303
+ };
304
+ }
305
+ return {
306
+ ok: false,
307
+ status: 409,
308
+ error: "no free slide id"
309
+ };
310
+ }
311
+ function slugifyTitle(title) {
312
+ return title.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+/, "").slice(0, 48).replace(/-+$/, "");
313
+ }
314
+ async function renameSlideDir(slidesRoot, slideId, desiredId) {
315
+ if (!SLIDE_ID_RE.test(slideId) || !SLIDE_ID_RE.test(desiredId)) return {
316
+ ok: false,
317
+ status: 400,
318
+ error: "invalid slideId"
319
+ };
320
+ const root = path.resolve(slidesRoot);
321
+ const from = path.resolve(root, slideId);
322
+ if (!from.startsWith(root + path.sep)) return {
323
+ ok: false,
324
+ status: 400,
325
+ error: "invalid slideId"
326
+ };
327
+ try {
328
+ await fs.access(path.join(from, "index.tsx"));
329
+ } catch {
330
+ return {
331
+ ok: false,
332
+ status: 404,
333
+ error: "slide not found"
334
+ };
335
+ }
336
+ for (let suffix = 1; suffix < 1e3; suffix++) {
337
+ const candidate = suffix === 1 ? desiredId : `${desiredId}-${suffix}`;
338
+ if (candidate === slideId) return {
339
+ ok: false,
340
+ status: 409,
341
+ error: "slide id unchanged"
342
+ };
343
+ if (await slideIdTaken(root, candidate)) continue;
344
+ const to = path.join(root, candidate);
345
+ try {
346
+ await fs.rename(from, to);
347
+ } catch (err) {
348
+ const code = err.code;
349
+ if (code === "EEXIST" || code === "ENOTEMPTY") continue;
350
+ return {
351
+ ok: false,
352
+ status: 500,
353
+ error: String(err.message ?? err)
354
+ };
355
+ }
356
+ return {
357
+ ok: true,
358
+ slideId: candidate,
359
+ from,
360
+ to
361
+ };
362
+ }
363
+ return {
364
+ ok: false,
365
+ status: 409,
366
+ error: "no free slide id"
367
+ };
368
+ }
265
369
  function resolveSlideEntry(slidesRoot, slideId) {
266
370
  if (!SLIDE_ID_RE.test(slideId)) return null;
267
371
  const dir = path.resolve(slidesRoot, slideId);
@@ -685,13 +789,29 @@ function makeContext(opts) {
685
789
  slidesRoot,
686
790
  globalAssetsRoot: path.resolve(userCwd, assetsDir),
687
791
  manifestPath: foldersManifestPath(slidesRoot),
688
- coreVersion: opts.coreVersion
792
+ coreVersion: opts.coreVersion,
793
+ agentEnabled: opts.agentEnabled
689
794
  };
690
795
  }
691
- async function readBody(req) {
796
+ var BodyTooLargeError = class extends Error {
797
+ constructor() {
798
+ super("request body too large");
799
+ this.name = "BodyTooLargeError";
800
+ }
801
+ };
802
+ async function readBody(req, limit = Number.POSITIVE_INFINITY) {
692
803
  return await new Promise((resolve, reject) => {
693
804
  const chunks = [];
694
- req.on("data", (c) => chunks.push(c));
805
+ let size = 0;
806
+ req.on("data", (c) => {
807
+ size += c.length;
808
+ if (size > limit) {
809
+ req.destroy();
810
+ reject(new BodyTooLargeError());
811
+ return;
812
+ }
813
+ chunks.push(c);
814
+ });
695
815
  req.on("end", () => {
696
816
  const raw = Buffer.concat(chunks).toString("utf8");
697
817
  if (!raw) return resolve({});
@@ -824,7 +944,7 @@ function localOpenSlideCommand(cwd) {
824
944
  function formatCommand(spec) {
825
945
  return [spec.cmd, ...spec.args].join(" ");
826
946
  }
827
- async function runCommand(spec, cwd) {
947
+ async function runCommand(spec, cwd, timeoutMs = COMMAND_TIMEOUT_MS) {
828
948
  await new Promise((resolve, reject) => {
829
949
  const child = spawn(spec.cmd, spec.args, {
830
950
  cwd,
@@ -834,13 +954,14 @@ async function runCommand(spec, cwd) {
834
954
  "ignore",
835
955
  "ignore",
836
956
  "pipe"
837
- ]
957
+ ],
958
+ windowsHide: true
838
959
  });
839
960
  let stderr = "";
840
961
  const timer = setTimeout(() => {
841
962
  child.kill();
842
963
  reject(/* @__PURE__ */ new Error(`${formatCommand(spec)} timed out`));
843
- }, COMMAND_TIMEOUT_MS);
964
+ }, timeoutMs);
844
965
  child.stderr.on("data", (chunk) => {
845
966
  stderr += chunk.toString("utf8");
846
967
  if (stderr.length > 2e3) stderr = stderr.slice(-2e3);
@@ -902,4 +1023,4 @@ function registerUpdateRoutes(server, ctx) {
902
1023
  });
903
1024
  }
904
1025
  //#endregion
905
- export { reorderDefaultExportPagesInSource as C, updateMetaTitleInSource as D, rmSlideDir as E, validateSlideName as O, removePageFromDefaultExportInSource as S, resolveSlideEntry as T, SLIDE_ID_RE as _, readBody as a, duplicateSlideDir as b, FOLDER_ID_RE as c, readManifest as d, validateIcon as f, shortId as g, writeManifest as h, makeContext as i, validateMutationRequest as k, foldersManifestPath as l, validateReorder as m, registerUpdateRoutes as n, readSlideSource as o, validateName as p, json as r, resolveSlideEntryPath as s, detectPackageManager as t, newFolderId as u, duplicateNotesElementInSource as v, reorderNotesArrayInSource as w, removeNotesElementInSource as x, duplicatePageInDefaultExportInSource as y };
1026
+ export { reorderNotesArrayInSource as A, duplicatePageInDefaultExportInSource as C, removePageFromDefaultExportInSource as D, removeNotesElementInSource as E, validateSlideName as F, isLoopbackRequest as I, validateMutationRequest as L, rmSlideDir as M, slugifyTitle as N, renameSlideDir as O, updateMetaTitleInSource as P, duplicateNotesElementInSource as S, readMetaTitleInSource as T, writeManifest as _, json as a, SLIDE_ID_RE as b, readSlideSource as c, foldersManifestPath as d, newFolderId as f, validateReorder as g, validateName as h, BodyTooLargeError as i, resolveSlideEntry as j, reorderDefaultExportPagesInSource as k, resolveSlideEntryPath as l, validateIcon as m, registerUpdateRoutes as n, makeContext as o, readManifest as p, runCommand as r, readBody as s, detectPackageManager as t, FOLDER_ID_RE as u, shortId as v, duplicateSlideDir as w, createBlankSlideDir as x, BLANK_SLIDE_TITLE as y };
@@ -1,4 +1,4 @@
1
- import { t as OpenSlideConfig } from "../config-DHPbCCnt.js";
1
+ import { n as OpenSlideConfig } from "../config-CDrYgaEj.js";
2
2
  import { InlineConfig } from "vite";
3
3
  //#region src/vite/config.d.ts
4
4
  type CreateViteConfigOptions = {
@@ -1,2 +1,2 @@
1
- import { t as createViteConfig } from "../config-CNhYSo4C.js";
1
+ import { t as createViteConfig } from "../config-D2Mq1vSW.js";
2
2
  export { createViteConfig };