@preptex/ui 0.0.0-stage → 0.1.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 (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -2
  3. package/dist/components/CatalogDialog.css +401 -0
  4. package/dist/components/CatalogDialog.d.ts +16 -0
  5. package/dist/components/CatalogDialog.js +224 -0
  6. package/dist/components/CatalogDialog.js.map +1 -0
  7. package/dist/components/Codeview.css +127 -0
  8. package/dist/components/Codeview.d.ts +14 -0
  9. package/dist/components/Codeview.js +74 -0
  10. package/dist/components/Codeview.js.map +1 -0
  11. package/dist/components/ConfigurationSummary.d.ts +18 -0
  12. package/dist/components/ConfigurationSummary.js +44 -0
  13. package/dist/components/ConfigurationSummary.js.map +1 -0
  14. package/dist/components/ControlPanel.css +792 -0
  15. package/dist/components/ControlPanel.d.ts +48 -0
  16. package/dist/components/ControlPanel.js +218 -0
  17. package/dist/components/ControlPanel.js.map +1 -0
  18. package/dist/components/EditPreviewDialog.css +308 -0
  19. package/dist/components/EditPreviewDialog.d.ts +18 -0
  20. package/dist/components/EditPreviewDialog.js +46 -0
  21. package/dist/components/EditPreviewDialog.js.map +1 -0
  22. package/dist/components/Filetree.css +344 -0
  23. package/dist/components/Filetree.d.ts +22 -0
  24. package/dist/components/Filetree.js +250 -0
  25. package/dist/components/Filetree.js.map +1 -0
  26. package/dist/components/LogDialog.css +154 -0
  27. package/dist/components/LogDialog.d.ts +16 -0
  28. package/dist/components/LogDialog.js +42 -0
  29. package/dist/components/LogDialog.js.map +1 -0
  30. package/dist/components/LogPanel.css +106 -0
  31. package/dist/components/LogPanel.d.ts +10 -0
  32. package/dist/components/LogPanel.js +30 -0
  33. package/dist/components/LogPanel.js.map +1 -0
  34. package/dist/components/MetadataDialog.css +275 -0
  35. package/dist/components/MetadataDialog.d.ts +13 -0
  36. package/dist/components/MetadataDialog.js +67 -0
  37. package/dist/components/MetadataDialog.js.map +1 -0
  38. package/dist/components/NodeActionBar.css +163 -0
  39. package/dist/components/NodeActionBar.d.ts +19 -0
  40. package/dist/components/NodeActionBar.js +114 -0
  41. package/dist/components/NodeActionBar.js.map +1 -0
  42. package/dist/components/OperationsDialog.css +154 -0
  43. package/dist/components/OperationsDialog.d.ts +8 -0
  44. package/dist/components/OperationsDialog.js +27 -0
  45. package/dist/components/OperationsDialog.js.map +1 -0
  46. package/dist/components/PrepTeXWorkspace.css +224 -0
  47. package/dist/components/PrepTeXWorkspace.d.ts +125 -0
  48. package/dist/components/PrepTeXWorkspace.js +593 -0
  49. package/dist/components/PrepTeXWorkspace.js.map +1 -0
  50. package/dist/components/ProjectSetupDialog.css +292 -0
  51. package/dist/components/ProjectSetupDialog.d.ts +18 -0
  52. package/dist/components/ProjectSetupDialog.js +134 -0
  53. package/dist/components/ProjectSetupDialog.js.map +1 -0
  54. package/dist/components/WelcomeEmptyState.css +105 -0
  55. package/dist/components/WelcomeEmptyState.d.ts +9 -0
  56. package/dist/components/WelcomeEmptyState.js +28 -0
  57. package/dist/components/WelcomeEmptyState.js.map +1 -0
  58. package/dist/components/WorkspaceHeader.css +410 -0
  59. package/dist/components/WorkspaceHeader.d.ts +66 -0
  60. package/dist/components/WorkspaceHeader.js +297 -0
  61. package/dist/components/WorkspaceHeader.js.map +1 -0
  62. package/dist/components/astview/ASTview.css +690 -0
  63. package/dist/components/astview/ASTview.d.ts +27 -0
  64. package/dist/components/astview/ASTview.js +314 -0
  65. package/dist/components/astview/ASTview.js.map +1 -0
  66. package/dist/components/astview/TreeNode.d.ts +8 -0
  67. package/dist/components/astview/TreeNode.js +237 -0
  68. package/dist/components/astview/TreeNode.js.map +1 -0
  69. package/dist/components/astview/treebuilder.d.ts +13 -0
  70. package/dist/components/astview/treebuilder.js +292 -0
  71. package/dist/components/astview/treebuilder.js.map +1 -0
  72. package/dist/components/index.d.ts +18 -0
  73. package/dist/components/index.js +19 -0
  74. package/dist/components/index.js.map +1 -0
  75. package/dist/docs/architecture.md +46 -0
  76. package/dist/docs/integration.md +107 -0
  77. package/dist/index.d.ts +14 -0
  78. package/dist/index.js +12 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/model/useArtifacts.d.ts +14 -0
  81. package/dist/model/useArtifacts.js +32 -0
  82. package/dist/model/useArtifacts.js.map +1 -0
  83. package/dist/model/useControl.d.ts +15 -0
  84. package/dist/model/useControl.js +19 -0
  85. package/dist/model/useControl.js.map +1 -0
  86. package/dist/model/useFiles.d.ts +53 -0
  87. package/dist/model/useFiles.js +283 -0
  88. package/dist/model/useFiles.js.map +1 -0
  89. package/dist/model/useProjectConfiguration.d.ts +32 -0
  90. package/dist/model/useProjectConfiguration.js +151 -0
  91. package/dist/model/useProjectConfiguration.js.map +1 -0
  92. package/dist/model/useWorkspaceLayout.d.ts +26 -0
  93. package/dist/model/useWorkspaceLayout.js +55 -0
  94. package/dist/model/useWorkspaceLayout.js.map +1 -0
  95. package/dist/services/zip.d.ts +24 -0
  96. package/dist/services/zip.js +279 -0
  97. package/dist/services/zip.js.map +1 -0
  98. package/dist/styles/bundle.css +4652 -0
  99. package/dist/styles/tokens.css +77 -0
  100. package/dist/types/LayoutNode.d.ts +30 -0
  101. package/dist/types/LayoutNode.js +18 -0
  102. package/dist/types/LayoutNode.js.map +1 -0
  103. package/dist/types/artifacts.d.ts +9 -0
  104. package/dist/types/artifacts.js +2 -0
  105. package/dist/types/artifacts.js.map +1 -0
  106. package/dist/types/errors.d.ts +14 -0
  107. package/dist/types/errors.js +2 -0
  108. package/dist/types/errors.js.map +1 -0
  109. package/dist/types/files.d.ts +12 -0
  110. package/dist/types/files.js +2 -0
  111. package/dist/types/files.js.map +1 -0
  112. package/dist/utils/dropEntries.d.ts +6 -0
  113. package/dist/utils/dropEntries.js +58 -0
  114. package/dist/utils/dropEntries.js.map +1 -0
  115. package/dist/utils/fileFilter.d.ts +10 -0
  116. package/dist/utils/fileFilter.js +68 -0
  117. package/dist/utils/fileFilter.js.map +1 -0
  118. package/dist/utils/transformOutput.d.ts +24 -0
  119. package/dist/utils/transformOutput.js +83 -0
  120. package/dist/utils/transformOutput.js.map +1 -0
  121. package/package.json +103 -4
@@ -0,0 +1,18 @@
1
+ export { default as Filetree, type FiletreeProps } from './Filetree.js';
2
+ export { default as ASTview, type ASTviewProps, type AstStructureMode } from './astview/ASTview.js';
3
+ export { TreeLayoutBuilder } from './astview/treebuilder.js';
4
+ export { default as ControlPanel, type ControlPanelProps, type TransformationScopeOption, type TransformDestination, type UnifiedTransformRequest, } from './ControlPanel.js';
5
+ export { default as Codeview, type CodeviewProps } from './Codeview.js';
6
+ export { default as LogPanel, type LogPanelProps } from './LogPanel.js';
7
+ export { default as LogDialog, type LogDialogProps } from './LogDialog.js';
8
+ export { default as OperationsDialog, type OperationsDialogProps } from './OperationsDialog.js';
9
+ export { default as CatalogDialog, type CatalogDialogProps, type CatalogFilter, type CatalogTab, } from './CatalogDialog.js';
10
+ export { default as MetadataDialog, type MetadataDialogProps } from './MetadataDialog.js';
11
+ export { default as TreeNode, type TreeNodeProps } from './astview/TreeNode.js';
12
+ export { default as WorkspaceHeader, type WorkspaceCustomMenuDescriptor, type WorkspaceHeaderProps, type WorkspaceMenuItemDescriptor, type WorkspaceViewDescriptor, } from './WorkspaceHeader.js';
13
+ export { default as WelcomeEmptyState, type WelcomeEmptyStateProps } from './WelcomeEmptyState.js';
14
+ export { EditPreviewDialog, type EditPreviewDialogProps } from './EditPreviewDialog.js';
15
+ export { NodeActionBar, type NodeActionBarProps, type SectionCommandName } from './NodeActionBar.js';
16
+ export { ProjectSetupDialog, type ProjectSetupDialogProps } from './ProjectSetupDialog.js';
17
+ export { ConfigurationSummary, type ConfigurationSummaryProps } from './ConfigurationSummary.js';
18
+ export { default as PrepTeXWorkspace, applyProjectEditsToFilesMap, DEFAULT_DEMO_PROJECT_FILES, getOperationHistoryLabel, usePrepTeXWorkspace, type CustomWorkspaceViewDescriptor, type PrepTeXWorkspaceContextValue, type PrepTeXWorkspaceProps, type StagedEditMetadata, type WorkspaceActionHandlers, type WorkspaceModelData, } from './PrepTeXWorkspace.js';
@@ -0,0 +1,19 @@
1
+ export { default as Filetree } from './Filetree.js';
2
+ export { default as ASTview } from './astview/ASTview.js';
3
+ export { TreeLayoutBuilder } from './astview/treebuilder.js';
4
+ export { default as ControlPanel, } from './ControlPanel.js';
5
+ export { default as Codeview } from './Codeview.js';
6
+ export { default as LogPanel } from './LogPanel.js';
7
+ export { default as LogDialog } from './LogDialog.js';
8
+ export { default as OperationsDialog } from './OperationsDialog.js';
9
+ export { default as CatalogDialog, } from './CatalogDialog.js';
10
+ export { default as MetadataDialog } from './MetadataDialog.js';
11
+ export { default as TreeNode } from './astview/TreeNode.js';
12
+ export { default as WorkspaceHeader, } from './WorkspaceHeader.js';
13
+ export { default as WelcomeEmptyState } from './WelcomeEmptyState.js';
14
+ export { EditPreviewDialog } from './EditPreviewDialog.js';
15
+ export { NodeActionBar } from './NodeActionBar.js';
16
+ export { ProjectSetupDialog } from './ProjectSetupDialog.js';
17
+ export { ConfigurationSummary } from './ConfigurationSummary.js';
18
+ export { default as PrepTeXWorkspace, applyProjectEditsToFilesMap, DEFAULT_DEMO_PROJECT_FILES, getOperationHistoryLabel, usePrepTeXWorkspace, } from './PrepTeXWorkspace.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,OAAO,EAA4C,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,OAAO,IAAI,YAAY,GAKxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAuB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAA8B,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EACL,OAAO,IAAI,aAAa,GAIzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,IAAI,cAAc,EAA4B,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,OAAO,IAAI,eAAe,GAK3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAA+B,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAA+B,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAoD,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAgC,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAkC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,OAAO,IAAI,gBAAgB,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,GAOpB,MAAM,oBAAoB,CAAC","sourcesContent":["export { default as Filetree, type FiletreeProps } from './Filetree';\nexport { default as ASTview, type ASTviewProps, type AstStructureMode } from './astview/ASTview';\nexport { TreeLayoutBuilder } from './astview/treebuilder';\nexport {\n default as ControlPanel,\n type ControlPanelProps,\n type TransformationScopeOption,\n type TransformDestination,\n type UnifiedTransformRequest,\n} from './ControlPanel';\nexport { default as Codeview, type CodeviewProps } from './Codeview';\nexport { default as LogPanel, type LogPanelProps } from './LogPanel';\nexport { default as LogDialog, type LogDialogProps } from './LogDialog';\nexport { default as OperationsDialog, type OperationsDialogProps } from './OperationsDialog';\nexport {\n default as CatalogDialog,\n type CatalogDialogProps,\n type CatalogFilter,\n type CatalogTab,\n} from './CatalogDialog';\nexport { default as MetadataDialog, type MetadataDialogProps } from './MetadataDialog';\nexport { default as TreeNode, type TreeNodeProps } from './astview/TreeNode';\nexport {\n default as WorkspaceHeader,\n type WorkspaceCustomMenuDescriptor,\n type WorkspaceHeaderProps,\n type WorkspaceMenuItemDescriptor,\n type WorkspaceViewDescriptor,\n} from './WorkspaceHeader';\nexport { default as WelcomeEmptyState, type WelcomeEmptyStateProps } from './WelcomeEmptyState';\nexport { EditPreviewDialog, type EditPreviewDialogProps } from './EditPreviewDialog';\nexport { NodeActionBar, type NodeActionBarProps, type SectionCommandName } from './NodeActionBar';\nexport { ProjectSetupDialog, type ProjectSetupDialogProps } from './ProjectSetupDialog';\nexport { ConfigurationSummary, type ConfigurationSummaryProps } from './ConfigurationSummary';\nexport {\n default as PrepTeXWorkspace,\n applyProjectEditsToFilesMap,\n DEFAULT_DEMO_PROJECT_FILES,\n getOperationHistoryLabel,\n usePrepTeXWorkspace,\n type CustomWorkspaceViewDescriptor,\n type PrepTeXWorkspaceContextValue,\n type PrepTeXWorkspaceProps,\n type StagedEditMetadata,\n type WorkspaceActionHandlers,\n type WorkspaceModelData,\n} from './PrepTeXWorkspace';\n"]}
@@ -0,0 +1,46 @@
1
+ # `@preptex/ui` Architecture
2
+
3
+ This document records the architecture, state ownership, and package boundaries of `@preptex/ui@0.1.0`.
4
+
5
+ ## Mission and Boundaries
6
+
7
+ `@preptex/ui` provides the shared React workspace shell, structural LaTeX inspector/editor views, pure UI state hooks, browser utilities, ZIP builder, and CSS design tokens for PrepTeX web applications:
8
+
9
+ - **Zero `@preptex/core` runtime logic:** `@preptex/ui` imports `@preptex/core` strictly via `import type` for TypeScript data contracts. None of the compiled JavaScript modules in `dist/` import or execute `@preptex/core`.
10
+ - **Full-stack / server-backed apps** run `@preptex/core` on the backend server and pass JSON-serialized model data (`WorkspaceModelData`) and API callbacks (`WorkspaceActionHandlers`) into `<PrepTeXWorkspace>`.
11
+ - **Standalone client-only apps (`website/`)** run `@preptex/core` in the browser and pass their local model/operation state into `<PrepTeXWorkspace>`.
12
+
13
+ ### Package Boundary Rules
14
+
15
+ - `src/index.ts` (`@preptex/ui`) is the single JS/TS public module entry point. Deep imports into `@preptex/ui/dist/*` are blocked by `package.json` `exports`.
16
+ - `@preptex/ui/tokens.css` exports the `:root` CSS custom properties and base element resets.
17
+ - `@preptex/ui/styles.css` exports the concatenated stylesheet bundle (`tokens.css` + `PrepTeXWorkspace.css` + all component stylesheets) for bundlers that do not import `.css` files from ESM modules in `node_modules`.
18
+ - `react`, `react-dom`, `@preptex/core`, `@codemirror/state`, and `@codemirror/view` are `peerDependencies` and are never bundled into `dist/`, preventing duplicate React or CodeMirror instances in consuming applications.
19
+
20
+ ## Components and Layers
21
+
22
+ | Layer / Component | Source Location | Responsibility |
23
+ | --- | --- | --- |
24
+ | `PrepTeXWorkspace` | `src/components/PrepTeXWorkspace.tsx` | Top-level workspace shell and `WorkspaceSessionContext` provider (`usePrepTeXWorkspace`). Coordinates file buffers, configuration, `@preptex/core` model, operations, view routing, `Split Code Companion`, and extension slots. |
25
+ | `WorkspaceHeader` | `src/components/WorkspaceHeader.tsx` | Top menubar (`File`, `Edit`, optional `extraMenus`, `View` drawer), keyboard roving/menu navigation, right-side alert pills (`pendingDiffCount`, `diagnosticCount`), optional `rightSlot`, and readiness status pill. |
26
+ | `WelcomeEmptyState` | `src/components/WelcomeEmptyState.tsx` | Empty-workspace dropzone supporting file/folder uploads, demo loading, and optional `extraActions`. |
27
+ | `Filetree` | `src/components/Filetree.tsx` | Collapsible file explorer with nested folders, path filtering, file/folder creation, entry selection, drag-and-drop directory ingestion, download, and deletion. |
28
+ | `Codeview` | `src/components/Codeview.tsx` | Read-only CodeMirror 6 viewer with UTF-16 range selection and 1-based line jumping. |
29
+ | `ASTview` & `TreeNode` | `src/components/astview/` | `Coarse`, `Structure` (`ConfiguredNode`), and `Source` (`SourceToken`) tree inspector with `Command` vs `Recursive` `\input` toggle, inline Phase 0 condition configuration, node filtering, and `Split` companion toggle. |
30
+ | `NodeActionBar` | `src/components/NodeActionBar.tsx` | Contextual action bar above `ASTview` for renaming, wrapping, unwrapping, removing, or reparsing selected AST nodes, plus optional `extraActions`. |
31
+ | `OperationsDialog` & `ControlPanel` | `src/components/OperationsDialog.tsx`, `src/components/ControlPanel.tsx` | Transformations view for `Realize Conditions`, `Suppress Comments`, `Remove Environments`, and `Expand / Flatten \input`, unified In-Place Diff Review vs New File(s) output, artifact downloads, and optional `extraContent`. |
32
+ | `CatalogDialog` | `src/components/CatalogDialog.tsx` | Symbol & construct catalog (commands, environments, conditions, labels, citations) with occurrence jumping, global refactoring, inline definition editing, and custom command arity overrides. |
33
+ | `MetadataDialog` | `src/components/MetadataDialog.tsx` | Document metadata (title, authors, date, abstract, documentclass, packages, bibliography, statistics) with diff-staged inline editing. |
34
+ | `LogDialog` & `LogPanel` | `src/components/LogDialog.tsx`, `src/components/LogPanel.tsx` | Diagnostics and analysis findings (`Check References`, `Check Commands`, plus optional `extraHeaderActions`) with source jump links. |
35
+ | `EditPreviewDialog` | `src/components/EditPreviewDialog.tsx` | Diff Review view for both `@preptex/core` transformations and external `stageEditPlan` proposals, supporting custom titles/subtitles, staleness alerts, and atomic application. |
36
+ | `ProjectSetupDialog` & `ConfigurationSummary` | `src/components/ProjectSetupDialog.tsx`, `src/components/ConfigurationSummary.tsx` | Project settings view for entry path, `\input` mode, traversal, condition policy, split companion toggle, and custom command signatures. |
37
+
38
+ ## State Hooks and Services
39
+
40
+ | Hook / Module | Location | Responsibility |
41
+ | --- | --- | --- |
42
+ | `useFiles` | `src/model/useFiles.ts` | Atomic reducer owning `FilesMap`, monotonic `sourceRevision`, per-file `fileVersions`, `selectedFile`, and bounded `past`/`future` undo/redo stacks. |
43
+ | `useProjectConfiguration` | `src/model/useProjectConfiguration.ts` | Owns `entryPath`, `traversal`, `inputs`, `conditionPolicy`, `customCommands`, `coarseTreeOptions`, and `recommendEntry()`. |
44
+ | `useWorkspaceLayout` | `src/model/useWorkspaceLayout.ts` | Manages `activeView`, `previousView` (`returnFromDiff`), `splitEnabled`, `sidebarCollapsed`, and `openMenu`. |
45
+ | `useControl` | `src/model/useControl.ts` | Owns `CoreOptionsUI` form state for transformations/exports. |
46
+ | `src/services/zip.ts` | `src/services/zip.ts` | Zero-dependency PKZIP 2.0 archive writer and reader (`createZipArchive`, `readZipFileNames`). |
@@ -0,0 +1,107 @@
1
+ # `@preptex/ui` Integration Guide
2
+
3
+ This guide explains how to consume `@preptex/ui` in both standalone client-only applications and full-stack applications with backend AI or transformation services.
4
+
5
+ ## 1. Installation & Peer Dependencies
6
+
7
+ Install `@preptex/ui` alongside its peer dependencies:
8
+
9
+ ```sh
10
+ npm install @preptex/ui @preptex/core @codemirror/state @codemirror/view react react-dom
11
+ ```
12
+
13
+ Import the design tokens in your application entry point (`src/index.tsx` or `src/main.tsx`):
14
+
15
+ ```tsx
16
+ import '@preptex/ui/tokens.css';
17
+ // If your bundler does not automatically process CSS imports inside node_modules ESM:
18
+ // import '@preptex/ui/styles.css';
19
+ ```
20
+
21
+ ## 2. Standalone Usage
22
+
23
+ ```tsx
24
+ import { DEFAULT_DEMO_PROJECT_FILES, PrepTeXWorkspace } from '@preptex/ui';
25
+
26
+ export default function App() {
27
+ return <PrepTeXWorkspace demoFiles={DEFAULT_DEMO_PROJECT_FILES} />;
28
+ }
29
+ ```
30
+
31
+ ## 3. Extending `<PrepTeXWorkspace>` with Custom Views, Menus, and Slots
32
+
33
+ Full-stack applications can inject new views (such as a Venue Adapter or AI Short/Long Builder), custom top-level menus, AST node actions, and header status indicators:
34
+
35
+ ```tsx
36
+ import {
37
+ PrepTeXWorkspace,
38
+ usePrepTeXWorkspace,
39
+ type CustomWorkspaceViewDescriptor,
40
+ } from '@preptex/ui';
41
+
42
+ function VenueStudioPane() {
43
+ const { effectiveEntry, projectModel, stageEditPlan } = usePrepTeXWorkspace();
44
+ // Read projectModel.snapshot, projectModel.metadata, projectModel.coarseTree
45
+ // Call backend API and stage returned ProjectEditPlan into Diff Review:
46
+ return (
47
+ <section className="WorkspaceViewPane" aria-label="Venue Studio">
48
+ <div className="WorkspaceViewCard">
49
+ <div className="WorkspaceViewBody">
50
+ <h2>Venue Studio ({effectiveEntry})</h2>
51
+ </div>
52
+ </div>
53
+ </section>
54
+ );
55
+ }
56
+
57
+ const EXTRA_VIEWS: readonly CustomWorkspaceViewDescriptor[] = [
58
+ {
59
+ id: 'venue-studio',
60
+ label: 'Venue Adapter',
61
+ shortLabel: 'Venue',
62
+ description: 'Convert template, preamble, and short/long profile for a target venue',
63
+ icon: '🏛',
64
+ render: () => <VenueStudioPane />,
65
+ },
66
+ ];
67
+
68
+ export function FullStackApp() {
69
+ return (
70
+ <PrepTeXWorkspace
71
+ brandLabel="PrepTeX Studio"
72
+ extraViews={EXTRA_VIEWS}
73
+ getExtraMenus={(ctx) => [
74
+ {
75
+ id: 'ai',
76
+ label: 'AI Tools',
77
+ items: [
78
+ {
79
+ id: 'open-venue',
80
+ label: 'Venue Adapter…',
81
+ hint: 'Convert template',
82
+ onSelect: () => ctx.layout.selectView('venue-studio'),
83
+ },
84
+ ],
85
+ },
86
+ ]}
87
+ renderAstNodeActions={(node, ctx) => (
88
+ <button
89
+ type="button"
90
+ className="action-btn"
91
+ onClick={() => ctx.layout.selectView('venue-studio')}
92
+ >
93
+ AI Split ({node.kind})
94
+ </button>
95
+ )}
96
+ />
97
+ );
98
+ }
99
+ ```
100
+
101
+ ## 4. Staging External / Backend `ProjectEditPlan` Proposals
102
+
103
+ When an external backend or AI service proposes source changes:
104
+
105
+ 1. Construct a `@preptex/core` `ProjectEditPlan` against `snapshot.id` (`viewId: null` for source-scoped edits), using inclusive UTF-16 `SourceRange` offsets (`{ line, start, end }`) and exact `expected` substrings.
106
+ 2. Call `ctx.stageEditPlan(plan, { title, subtitle, historyLabel })` (or `operations.stageExternalEditPlan(plan, metadata)`).
107
+ 3. `PrepTeXWorkspace` switches to `EditPreviewDialog` (`Diff Review`), checks snapshot staleness if files changed while the request was in flight, validates non-overlapping UTF-16 ranges and `expected` contents via `applyExternalProjectEditPlanAdapter`, applies edits atomically across `useFiles`, and records `historyLabel` in the Undo/Redo stack.
@@ -0,0 +1,14 @@
1
+ export * from './components/index.js';
2
+ export { useArtifacts, type UseArtifactsResult, } from './model/useArtifacts.js';
3
+ export { DEFAULT_CORE_OPTIONS, isInputHandlingOption, useControl, type CoreOptionsUI, type InputHandlingOption, } from './model/useControl.js';
4
+ export { normalizeUploadedBatch, useFiles, type FileHistoryEntry, type FilesState, type UpsertFilesOptions, type UpsertTextOptions, } from './model/useFiles.js';
5
+ export { DEFAULT_CONFIGURATION, recommendEntry, useProjectConfiguration, type ProjectConfigurationState, } from './model/useProjectConfiguration.js';
6
+ export { useWorkspaceLayout, type BuiltInWorkspaceMenuId, type BuiltInWorkspaceViewId, type WorkspaceLayoutState, type WorkspaceMenuId, type WorkspaceViewId, } from './model/useWorkspaceLayout.js';
7
+ export * from './services/zip.js';
8
+ export type { UIArtifactItem } from './types/artifacts.js';
9
+ export type { ProcessingError } from './types/errors.js';
10
+ export type { FilesMap, ViewedItem } from './types/files.js';
11
+ export { isLayoutNodeKind, LAYOUT_NODE_KINDS, type LayoutNode, type LayoutNodeKind, type LayoutSectionLevel, } from './types/LayoutNode.js';
12
+ export { extractDroppedFiles, type DroppedFileItem } from './utils/dropEntries.js';
13
+ export { filterUploadedBatch, IGNORED_FOLDER_SEGMENTS, isRelevantProjectFile, RELEVANT_TEX_EXTENSIONS, type FilteredUploadBatch, getFileExtension, } from './utils/fileFilter.js';
14
+ export { buildNewFileOutputs, normalizeOutputFolder, type BuildNewFileOutputsArgs, type BuildNewFileOutputsResult, } from './utils/transformOutput.js';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export * from './components/index.js';
2
+ export { useArtifacts, } from './model/useArtifacts.js';
3
+ export { DEFAULT_CORE_OPTIONS, isInputHandlingOption, useControl, } from './model/useControl.js';
4
+ export { normalizeUploadedBatch, useFiles, } from './model/useFiles.js';
5
+ export { DEFAULT_CONFIGURATION, recommendEntry, useProjectConfiguration, } from './model/useProjectConfiguration.js';
6
+ export { useWorkspaceLayout, } from './model/useWorkspaceLayout.js';
7
+ export * from './services/zip.js';
8
+ export { isLayoutNodeKind, LAYOUT_NODE_KINDS, } from './types/LayoutNode.js';
9
+ export { extractDroppedFiles } from './utils/dropEntries.js';
10
+ export { filterUploadedBatch, IGNORED_FOLDER_SEGMENTS, isRelevantProjectFile, RELEVANT_TEX_EXTENSIONS, getFileExtension, } from './utils/fileFilter.js';
11
+ export { buildNewFileOutputs, normalizeOutputFolder, } from './utils/transformOutput.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,YAAY,GAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,UAAU,GAGX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,QAAQ,GAKT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,uBAAuB,GAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,GAMnB,MAAM,4BAA4B,CAAC;AAEpC,cAAc,gBAAgB,CAAC;AAK/B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAIlB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAwB,MAAM,qBAAqB,CAAC;AAChF,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EAEvB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,yBAAyB,CAAC","sourcesContent":["export * from './components';\n\nexport {\n useArtifacts,\n type UseArtifactsResult,\n} from './model/useArtifacts';\nexport {\n DEFAULT_CORE_OPTIONS,\n isInputHandlingOption,\n useControl,\n type CoreOptionsUI,\n type InputHandlingOption,\n} from './model/useControl';\nexport {\n normalizeUploadedBatch,\n useFiles,\n type FileHistoryEntry,\n type FilesState,\n type UpsertFilesOptions,\n type UpsertTextOptions,\n} from './model/useFiles';\nexport {\n DEFAULT_CONFIGURATION,\n recommendEntry,\n useProjectConfiguration,\n type ProjectConfigurationState,\n} from './model/useProjectConfiguration';\nexport {\n useWorkspaceLayout,\n type BuiltInWorkspaceMenuId,\n type BuiltInWorkspaceViewId,\n type WorkspaceLayoutState,\n type WorkspaceMenuId,\n type WorkspaceViewId,\n} from './model/useWorkspaceLayout';\n\nexport * from './services/zip';\n\nexport type { UIArtifactItem } from './types/artifacts';\nexport type { ProcessingError } from './types/errors';\nexport type { FilesMap, ViewedItem } from './types/files';\nexport {\n isLayoutNodeKind,\n LAYOUT_NODE_KINDS,\n type LayoutNode,\n type LayoutNodeKind,\n type LayoutSectionLevel,\n} from './types/LayoutNode';\n\nexport { extractDroppedFiles, type DroppedFileItem } from './utils/dropEntries';\nexport {\n filterUploadedBatch,\n IGNORED_FOLDER_SEGMENTS,\n isRelevantProjectFile,\n RELEVANT_TEX_EXTENSIONS,\n type FilteredUploadBatch,\n getFileExtension,\n} from './utils/fileFilter';\nexport {\n buildNewFileOutputs,\n normalizeOutputFolder,\n type BuildNewFileOutputsArgs,\n type BuildNewFileOutputsResult,\n} from './utils/transformOutput';\n"]}
@@ -0,0 +1,14 @@
1
+ import type { UIArtifactItem } from '../types/artifacts.js';
2
+ export interface UseArtifactsResult {
3
+ readonly artifacts: readonly UIArtifactItem[];
4
+ readonly addArtifacts: (newItems: readonly {
5
+ readonly path: string;
6
+ readonly source: string;
7
+ readonly topology?: UIArtifactItem['topology'];
8
+ readonly remainingInputs?: readonly string[];
9
+ }[]) => readonly UIArtifactItem[];
10
+ readonly removeArtifact: (id: string) => void;
11
+ readonly clearArtifacts: () => void;
12
+ readonly getArtifact: (id: string) => UIArtifactItem | undefined;
13
+ }
14
+ export declare function useArtifacts(initial?: readonly UIArtifactItem[]): UseArtifactsResult;
@@ -0,0 +1,32 @@
1
+ import { useCallback, useState } from 'react';
2
+ let artifactCounter = 0;
3
+ export function useArtifacts(initial = []) {
4
+ const [artifacts, setArtifacts] = useState(initial);
5
+ const addArtifacts = useCallback((newItems) => {
6
+ const timestamp = Date.now();
7
+ const created = newItems.map((item) => ({
8
+ ...item,
9
+ id: 'artifact-' + (++artifactCounter) + '-' + timestamp,
10
+ timestamp,
11
+ }));
12
+ setArtifacts((prev) => [...prev, ...created]);
13
+ return created;
14
+ }, []);
15
+ const removeArtifact = useCallback((id) => {
16
+ setArtifacts((prev) => prev.filter((a) => a.id !== id));
17
+ }, []);
18
+ const clearArtifacts = useCallback(() => {
19
+ setArtifacts([]);
20
+ }, []);
21
+ const getArtifact = useCallback((id) => {
22
+ return artifacts.find((a) => a.id === id);
23
+ }, [artifacts]);
24
+ return {
25
+ artifacts,
26
+ addArtifacts,
27
+ removeArtifact,
28
+ clearArtifacts,
29
+ getArtifact,
30
+ };
31
+ }
32
+ //# sourceMappingURL=useArtifacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useArtifacts.js","sourceRoot":"","sources":["../../src/model/useArtifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgB9C,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,MAAM,UAAU,YAAY,CAAC,UAAqC,EAAE;IAClE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA4B,OAAO,CAAC,CAAC;IAE/E,MAAM,YAAY,GAAG,WAAW,CAAC,CAC/B,QAKG,EACwB,EAAE;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,OAAO,GAA8B,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjE,GAAG,IAAI;YACP,EAAE,EAAE,WAAW,GAAG,CAAC,EAAE,eAAe,CAAC,GAAG,GAAG,GAAG,SAAS;YACvD,SAAS;SACV,CAAC,CAAC,CAAC;QACJ,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,EAAU,EAAE,EAAE;QAChD,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;QACtC,YAAY,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,EAAU,EAAE,EAAE;QAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5C,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO;QACL,SAAS;QACT,YAAY;QACZ,cAAc;QACd,cAAc;QACd,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\nimport type { UIArtifactItem } from '../types/artifacts';\n\nexport interface UseArtifactsResult {\n readonly artifacts: readonly UIArtifactItem[];\n readonly addArtifacts: (newItems: readonly {\n readonly path: string;\n readonly source: string;\n readonly topology?: UIArtifactItem['topology'];\n readonly remainingInputs?: readonly string[];\n }[]) => readonly UIArtifactItem[];\n readonly removeArtifact: (id: string) => void;\n readonly clearArtifacts: () => void;\n readonly getArtifact: (id: string) => UIArtifactItem | undefined;\n}\n\nlet artifactCounter = 0;\n\nexport function useArtifacts(initial: readonly UIArtifactItem[] = []): UseArtifactsResult {\n const [artifacts, setArtifacts] = useState<readonly UIArtifactItem[]>(initial);\n\n const addArtifacts = useCallback((\n newItems: readonly {\n readonly path: string;\n readonly source: string;\n readonly topology?: UIArtifactItem['topology'];\n readonly remainingInputs?: readonly string[];\n }[],\n ): readonly UIArtifactItem[] => {\n const timestamp = Date.now();\n const created: readonly UIArtifactItem[] = newItems.map((item) => ({\n ...item,\n id: 'artifact-' + (++artifactCounter) + '-' + timestamp,\n timestamp,\n }));\n setArtifacts((prev) => [...prev, ...created]);\n return created;\n }, []);\n\n const removeArtifact = useCallback((id: string) => {\n setArtifacts((prev) => prev.filter((a) => a.id !== id));\n }, []);\n\n const clearArtifacts = useCallback(() => {\n setArtifacts([]);\n }, []);\n\n const getArtifact = useCallback((id: string) => {\n return artifacts.find((a) => a.id === id);\n }, [artifacts]);\n\n return {\n artifacts,\n addArtifacts,\n removeArtifact,\n clearArtifacts,\n getArtifact,\n };\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ export type InputHandlingOption = 'preserve' | 'inline';
3
+ export declare function isInputHandlingOption(value: string): value is InputHandlingOption;
4
+ export interface CoreOptionsUI {
5
+ readonly suppressComments: boolean;
6
+ readonly suppressCommentEnvironments: boolean;
7
+ readonly inputHandling: InputHandlingOption;
8
+ readonly stripDeclarationsAndSetters: boolean;
9
+ readonly outputName: string;
10
+ }
11
+ export declare const DEFAULT_CORE_OPTIONS: CoreOptionsUI;
12
+ export declare function useControl(initial?: Partial<CoreOptionsUI>): {
13
+ readonly options: CoreOptionsUI;
14
+ readonly setOptions: import("react").Dispatch<import("react").SetStateAction<CoreOptionsUI>>;
15
+ };
@@ -0,0 +1,19 @@
1
+ import { useState } from 'react';
2
+ export function isInputHandlingOption(value) {
3
+ return value === 'preserve' || value === 'inline';
4
+ }
5
+ export const DEFAULT_CORE_OPTIONS = {
6
+ suppressComments: false,
7
+ suppressCommentEnvironments: false,
8
+ inputHandling: 'preserve',
9
+ stripDeclarationsAndSetters: true,
10
+ outputName: '',
11
+ };
12
+ export function useControl(initial) {
13
+ const [options, setOptions] = useState(() => ({
14
+ ...DEFAULT_CORE_OPTIONS,
15
+ ...initial,
16
+ }));
17
+ return { options, setOptions };
18
+ }
19
+ //# sourceMappingURL=useControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useControl.js","sourceRoot":"","sources":["../../src/model/useControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC;AAUD,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,aAAa,EAAE,UAAU;IACzB,2BAA2B,EAAE,IAAI;IACjC,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,OAAgC;IACzD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,GAAG,EAAE,CAAC,CAAC;QAC3D,GAAG,oBAAoB;QACvB,GAAG,OAAO;KACX,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,OAAO,EAAE,UAAU,EAAW,CAAC;AAC1C,CAAC","sourcesContent":["import { useState } from 'react';\n\nexport type InputHandlingOption = 'preserve' | 'inline';\n\nexport function isInputHandlingOption(value: string): value is InputHandlingOption {\n return value === 'preserve' || value === 'inline';\n}\n\nexport interface CoreOptionsUI {\n readonly suppressComments: boolean;\n readonly suppressCommentEnvironments: boolean;\n readonly inputHandling: InputHandlingOption;\n readonly stripDeclarationsAndSetters: boolean;\n readonly outputName: string;\n}\n\nexport const DEFAULT_CORE_OPTIONS: CoreOptionsUI = {\n suppressComments: false,\n suppressCommentEnvironments: false,\n inputHandling: 'preserve',\n stripDeclarationsAndSetters: true,\n outputName: '',\n};\n\nexport function useControl(initial?: Partial<CoreOptionsUI>) {\n const [options, setOptions] = useState<CoreOptionsUI>(() => ({\n ...DEFAULT_CORE_OPTIONS,\n ...initial,\n }));\n return { options, setOptions } as const;\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { ProjectFilePath } from '@preptex/core';
2
+ import type { FilesMap } from '../types/files.js';
3
+ export interface FileHistoryEntry {
4
+ readonly filesByName: FilesMap;
5
+ readonly selectedFile: ProjectFilePath;
6
+ readonly label: string;
7
+ }
8
+ export interface FilesState {
9
+ readonly filesByName: FilesMap;
10
+ readonly fileVersions: Readonly<Record<ProjectFilePath, number>>;
11
+ readonly sourceRevision: number;
12
+ readonly selectedFile: ProjectFilePath;
13
+ readonly uploadError: string | null;
14
+ readonly uploadNotice: string | null;
15
+ readonly past: readonly FileHistoryEntry[];
16
+ readonly future: readonly FileHistoryEntry[];
17
+ }
18
+ export interface UpsertTextOptions {
19
+ readonly recordHistory?: boolean;
20
+ readonly label?: string;
21
+ }
22
+ export interface UpsertFilesOptions {
23
+ readonly filterExtensions?: boolean;
24
+ }
25
+ export declare function normalizeUploadedBatch(incoming: FilesMap, existing: FilesMap): FilesMap;
26
+ export declare function useFiles(initial?: FilesMap): {
27
+ readonly fileNames: string[];
28
+ readonly canGoBack: boolean;
29
+ readonly canGoForward: boolean;
30
+ readonly backLabel: string | null;
31
+ readonly forwardLabel: string | null;
32
+ readonly selectFile: (path: ProjectFilePath) => void;
33
+ readonly upsertFiles: (fileList: FileList | readonly File[], options?: UpsertFilesOptions) => Promise<void>;
34
+ readonly upsertFileItems: (items: ReadonlyArray<{
35
+ readonly file: File;
36
+ readonly relativePath: string;
37
+ readonly fromDirectory?: boolean;
38
+ }>) => Promise<void>;
39
+ readonly upsertTextFiles: (files: FilesMap, options?: UpsertTextOptions) => void;
40
+ readonly removeFile: (path: ProjectFilePath) => void;
41
+ readonly resetFiles: () => void;
42
+ readonly clearUploadNotice: () => void;
43
+ readonly goBack: () => void;
44
+ readonly goForward: () => void;
45
+ readonly filesByName: Readonly<Record<string, string>>;
46
+ readonly fileVersions: Readonly<Record<string, number>>;
47
+ readonly sourceRevision: number;
48
+ readonly selectedFile: string;
49
+ readonly uploadError: string | null;
50
+ readonly uploadNotice: string | null;
51
+ readonly past: readonly FileHistoryEntry[];
52
+ readonly future: readonly FileHistoryEntry[];
53
+ };