@aprovan/patchwork-editor 0.1.0 → 0.1.1-dev.6bd527d
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/.turbo/turbo-build.log +4 -7
- package/dist/components/CodeBlockExtension.d.ts +2 -0
- package/dist/components/CodePreview.d.ts +13 -0
- package/dist/components/MarkdownEditor.d.ts +10 -0
- package/dist/components/ServicesInspector.d.ts +49 -0
- package/dist/components/edit/CodeBlockView.d.ts +7 -0
- package/dist/components/edit/EditHistory.d.ts +10 -0
- package/dist/components/edit/EditModal.d.ts +20 -0
- package/dist/components/edit/FileTree.d.ts +8 -0
- package/dist/components/edit/MediaPreview.d.ts +6 -0
- package/dist/components/edit/SaveConfirmDialog.d.ts +9 -0
- package/dist/components/edit/api.d.ts +8 -0
- package/dist/components/edit/fileTypes.d.ts +14 -0
- package/dist/components/edit/index.d.ts +10 -0
- package/dist/components/edit/types.d.ts +41 -0
- package/dist/components/edit/useEditSession.d.ts +9 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/index.d.ts +3 -331
- package/dist/index.js +707 -142
- package/dist/lib/code-extractor.d.ts +44 -0
- package/dist/lib/diff.d.ts +90 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/vfs.d.ts +36 -0
- package/package.json +4 -4
- package/src/components/CodeBlockExtension.tsx +1 -1
- package/src/components/CodePreview.tsx +64 -4
- package/src/components/edit/CodeBlockView.tsx +72 -0
- package/src/components/edit/EditModal.tsx +169 -28
- package/src/components/edit/FileTree.tsx +67 -13
- package/src/components/edit/MediaPreview.tsx +106 -0
- package/src/components/edit/SaveConfirmDialog.tsx +60 -0
- package/src/components/edit/fileTypes.ts +125 -0
- package/src/components/edit/index.ts +4 -0
- package/src/components/edit/types.ts +3 -0
- package/src/components/edit/useEditSession.ts +56 -11
- package/src/index.ts +17 -0
- package/src/lib/diff.ts +2 -1
- package/src/lib/vfs.ts +28 -10
- package/tsup.config.ts +10 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
> @aprovan/patchwork-editor@0.1.
|
|
3
|
-
> tsup
|
|
2
|
+
> @aprovan/patchwork-editor@0.1.1 build /home/runner/work/patchwork/patchwork/packages/editor
|
|
3
|
+
> tsup && tsc --declaration --emitDeclarationOnly --outDir dist --jsx react-jsx --lib ES2022,DOM --skipLibCheck src/index.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
@@ -9,8 +9,5 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2022
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in 4970ms
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.32 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m78.44 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 242ms
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Compiler } from '@aprovan/patchwork-compiler';
|
|
2
|
+
interface CodePreviewProps {
|
|
3
|
+
code: string;
|
|
4
|
+
compiler: Compiler | null;
|
|
5
|
+
/** Optional entrypoint file for the widget (default: "index.ts") */
|
|
6
|
+
entrypoint?: string;
|
|
7
|
+
/** Available service namespaces for widget calls */
|
|
8
|
+
services?: string[];
|
|
9
|
+
/** Optional file path from code block attributes (e.g., "components/calculator.tsx") */
|
|
10
|
+
filePath?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function CodePreview({ code: originalCode, compiler, services, filePath, entrypoint }: CodePreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface MarkdownEditorProps {
|
|
2
|
+
value: string;
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
onSubmit: () => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function MarkdownEditor({ value, onChange, onSubmit, placeholder, disabled, className, }: MarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface ServiceInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
namespace: string;
|
|
4
|
+
procedure: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
jsonSchema: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface ServicesInspectorProps {
|
|
11
|
+
namespaces: string[];
|
|
12
|
+
services?: ServiceInfo[];
|
|
13
|
+
/** Custom badge component for rendering the service count */
|
|
14
|
+
BadgeComponent?: React.ComponentType<{
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
variant?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Custom collapsible components */
|
|
20
|
+
CollapsibleComponent?: React.ComponentType<{
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
defaultOpen?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
}>;
|
|
25
|
+
CollapsibleTriggerComponent?: React.ComponentType<{
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
className?: string;
|
|
28
|
+
}>;
|
|
29
|
+
CollapsibleContentComponent?: React.ComponentType<{
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
}>;
|
|
32
|
+
/** Custom dialog components */
|
|
33
|
+
DialogComponent?: React.ComponentType<{
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
open?: boolean;
|
|
36
|
+
onOpenChange?: (open: boolean) => void;
|
|
37
|
+
}>;
|
|
38
|
+
DialogHeaderComponent?: React.ComponentType<{
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
}>;
|
|
41
|
+
DialogContentComponent?: React.ComponentType<{
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
}>;
|
|
44
|
+
DialogCloseComponent?: React.ComponentType<{
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare function ServicesInspector({ namespaces, services, BadgeComponent, DialogComponent, }: ServicesInspectorProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface CodeBlockViewProps {
|
|
2
|
+
content: string;
|
|
3
|
+
language: string | null;
|
|
4
|
+
editable?: boolean;
|
|
5
|
+
onChange?: (content: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function CodeBlockView({ content, language, editable, onChange }: CodeBlockViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditHistoryEntry } from './types';
|
|
2
|
+
interface EditHistoryProps {
|
|
3
|
+
entries: EditHistoryEntry[];
|
|
4
|
+
streamingNotes: string[];
|
|
5
|
+
isStreaming: boolean;
|
|
6
|
+
pendingPrompt?: string | null;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function EditHistory({ entries, streamingNotes, isStreaming, pendingPrompt, className, }: EditHistoryProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type UseEditSessionOptions } from './useEditSession';
|
|
3
|
+
import type { VirtualProject } from '@aprovan/patchwork-compiler';
|
|
4
|
+
export interface EditModalProps extends UseEditSessionOptions {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
initialState?: Partial<{
|
|
7
|
+
showTree: boolean;
|
|
8
|
+
showPreview: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
hideFileTree?: boolean;
|
|
11
|
+
onClose: (finalCode: string, editCount: number) => void;
|
|
12
|
+
onSave?: (code: string) => Promise<void>;
|
|
13
|
+
onSaveProject?: (project: VirtualProject) => Promise<void>;
|
|
14
|
+
renderPreview: (code: string) => ReactNode;
|
|
15
|
+
renderLoading?: () => ReactNode;
|
|
16
|
+
renderError?: (error: string) => ReactNode;
|
|
17
|
+
previewError?: string | null;
|
|
18
|
+
previewLoading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function EditModal({ isOpen, onClose, onSave, onSaveProject, renderPreview, renderLoading, renderError, previewError, previewLoading, initialState, hideFileTree, ...sessionOptions }: EditModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VirtualFile } from '@aprovan/patchwork-compiler';
|
|
2
|
+
export interface FileTreeProps {
|
|
3
|
+
files: VirtualFile[];
|
|
4
|
+
activeFile: string;
|
|
5
|
+
onSelectFile: (path: string) => void;
|
|
6
|
+
onReplaceFile?: (path: string, content: string, encoding: 'utf8' | 'base64') => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function FileTree({ files, activeFile, onSelectFile, onReplaceFile }: FileTreeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SaveConfirmDialogProps {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
isSaving: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
onSave: () => void;
|
|
6
|
+
onDiscard: () => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function SaveConfirmDialog({ isOpen, isSaving, error, onSave, onDiscard, onCancel, }: SaveConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EditRequest, EditResponse } from './types';
|
|
2
|
+
export interface EditApiOptions {
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
onProgress?: (note: string) => void;
|
|
5
|
+
/** Automatically remove stray diff markers from output (default: true) */
|
|
6
|
+
sanitize?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function sendEditRequest(request: EditRequest, options?: EditApiOptions): Promise<EditResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type FileCategory = 'compilable' | 'text' | 'media' | 'binary';
|
|
2
|
+
export interface FileTypeInfo {
|
|
3
|
+
category: FileCategory;
|
|
4
|
+
language: string | null;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getFileType(path: string): FileTypeInfo;
|
|
8
|
+
export declare function isCompilable(path: string): boolean;
|
|
9
|
+
export declare function isMediaFile(path: string): boolean;
|
|
10
|
+
export declare function isTextFile(path: string): boolean;
|
|
11
|
+
export declare function getLanguageFromExt(path: string): string | null;
|
|
12
|
+
export declare function getMimeType(path: string): string;
|
|
13
|
+
export declare function isImageFile(path: string): boolean;
|
|
14
|
+
export declare function isVideoFile(path: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './api';
|
|
3
|
+
export * from './useEditSession';
|
|
4
|
+
export * from './EditHistory';
|
|
5
|
+
export * from './EditModal';
|
|
6
|
+
export * from './FileTree';
|
|
7
|
+
export * from './SaveConfirmDialog';
|
|
8
|
+
export * from './fileTypes';
|
|
9
|
+
export * from './CodeBlockView';
|
|
10
|
+
export * from './MediaPreview';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { VirtualProject, VirtualFile } from '@aprovan/patchwork-compiler';
|
|
2
|
+
export interface EditHistoryEntry {
|
|
3
|
+
prompt: string;
|
|
4
|
+
summary: string;
|
|
5
|
+
isRetry?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EditSessionState {
|
|
8
|
+
project: VirtualProject;
|
|
9
|
+
originalProject: VirtualProject;
|
|
10
|
+
activeFile: string;
|
|
11
|
+
history: EditHistoryEntry[];
|
|
12
|
+
isApplying: boolean;
|
|
13
|
+
error: string | null;
|
|
14
|
+
streamingNotes: string[];
|
|
15
|
+
pendingPrompt: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface EditSessionActions {
|
|
18
|
+
submitEdit: (prompt: string) => Promise<void>;
|
|
19
|
+
revert: () => void;
|
|
20
|
+
updateActiveFile: (content: string) => void;
|
|
21
|
+
setActiveFile: (path: string) => void;
|
|
22
|
+
clearError: () => void;
|
|
23
|
+
replaceFile: (path: string, content: string, encoding?: 'utf8' | 'base64') => void;
|
|
24
|
+
}
|
|
25
|
+
export type FileEncoding = 'utf8' | 'base64';
|
|
26
|
+
export declare function getActiveContent(state: EditSessionState): string;
|
|
27
|
+
export declare function getFiles(project: VirtualProject): VirtualFile[];
|
|
28
|
+
export interface EditRequest {
|
|
29
|
+
code: string;
|
|
30
|
+
prompt: string;
|
|
31
|
+
}
|
|
32
|
+
export interface EditResponse {
|
|
33
|
+
newCode: string;
|
|
34
|
+
summary: string;
|
|
35
|
+
progressNotes: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface CompileResult {
|
|
38
|
+
success: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
export type CompileFn = (code: string) => Promise<CompileResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VirtualProject } from "@aprovan/patchwork-compiler";
|
|
2
|
+
import type { EditSessionState, EditSessionActions, CompileFn } from "./types";
|
|
3
|
+
export interface UseEditSessionOptions {
|
|
4
|
+
originalCode?: string;
|
|
5
|
+
originalProject?: VirtualProject;
|
|
6
|
+
compile?: CompileFn;
|
|
7
|
+
apiEndpoint?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function useEditSession(options: UseEditSessionOptions): EditSessionState & EditSessionActions;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,331 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { ClassValue } from 'clsx';
|
|
6
|
-
|
|
7
|
-
declare const CodeBlockExtension: Node<any, any>;
|
|
8
|
-
|
|
9
|
-
interface CodePreviewProps {
|
|
10
|
-
code: string;
|
|
11
|
-
compiler: Compiler | null;
|
|
12
|
-
/** Available service namespaces for widget calls */
|
|
13
|
-
services?: string[];
|
|
14
|
-
/** Optional file path from code block attributes (e.g., "components/calculator.tsx") */
|
|
15
|
-
filePath?: string;
|
|
16
|
-
}
|
|
17
|
-
declare function CodePreview({ code: originalCode, compiler, services, filePath }: CodePreviewProps): react_jsx_runtime.JSX.Element;
|
|
18
|
-
|
|
19
|
-
interface MarkdownEditorProps {
|
|
20
|
-
value: string;
|
|
21
|
-
onChange: (value: string) => void;
|
|
22
|
-
onSubmit: () => void;
|
|
23
|
-
placeholder?: string;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
className?: string;
|
|
26
|
-
}
|
|
27
|
-
declare function MarkdownEditor({ value, onChange, onSubmit, placeholder, disabled, className, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
|
|
28
|
-
|
|
29
|
-
interface ServiceInfo {
|
|
30
|
-
name: string;
|
|
31
|
-
namespace: string;
|
|
32
|
-
procedure: string;
|
|
33
|
-
description: string;
|
|
34
|
-
parameters: {
|
|
35
|
-
jsonSchema: Record<string, unknown>;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
interface ServicesInspectorProps {
|
|
39
|
-
namespaces: string[];
|
|
40
|
-
services?: ServiceInfo[];
|
|
41
|
-
/** Custom badge component for rendering the service count */
|
|
42
|
-
BadgeComponent?: React.ComponentType<{
|
|
43
|
-
children: React.ReactNode;
|
|
44
|
-
variant?: string;
|
|
45
|
-
className?: string;
|
|
46
|
-
}>;
|
|
47
|
-
/** Custom collapsible components */
|
|
48
|
-
CollapsibleComponent?: React.ComponentType<{
|
|
49
|
-
children: React.ReactNode;
|
|
50
|
-
defaultOpen?: boolean;
|
|
51
|
-
className?: string;
|
|
52
|
-
}>;
|
|
53
|
-
CollapsibleTriggerComponent?: React.ComponentType<{
|
|
54
|
-
children: React.ReactNode;
|
|
55
|
-
className?: string;
|
|
56
|
-
}>;
|
|
57
|
-
CollapsibleContentComponent?: React.ComponentType<{
|
|
58
|
-
children: React.ReactNode;
|
|
59
|
-
}>;
|
|
60
|
-
/** Custom dialog components */
|
|
61
|
-
DialogComponent?: React.ComponentType<{
|
|
62
|
-
children: React.ReactNode;
|
|
63
|
-
open?: boolean;
|
|
64
|
-
onOpenChange?: (open: boolean) => void;
|
|
65
|
-
}>;
|
|
66
|
-
DialogHeaderComponent?: React.ComponentType<{
|
|
67
|
-
children: React.ReactNode;
|
|
68
|
-
}>;
|
|
69
|
-
DialogContentComponent?: React.ComponentType<{
|
|
70
|
-
children: React.ReactNode;
|
|
71
|
-
}>;
|
|
72
|
-
DialogCloseComponent?: React.ComponentType<{
|
|
73
|
-
onClose?: () => void;
|
|
74
|
-
}>;
|
|
75
|
-
}
|
|
76
|
-
declare function ServicesInspector({ namespaces, services, BadgeComponent, DialogComponent, }: ServicesInspectorProps): react_jsx_runtime.JSX.Element | null;
|
|
77
|
-
|
|
78
|
-
interface EditHistoryEntry {
|
|
79
|
-
prompt: string;
|
|
80
|
-
summary: string;
|
|
81
|
-
isRetry?: boolean;
|
|
82
|
-
}
|
|
83
|
-
interface EditSessionState {
|
|
84
|
-
project: VirtualProject;
|
|
85
|
-
originalProject: VirtualProject;
|
|
86
|
-
activeFile: string;
|
|
87
|
-
history: EditHistoryEntry[];
|
|
88
|
-
isApplying: boolean;
|
|
89
|
-
error: string | null;
|
|
90
|
-
streamingNotes: string[];
|
|
91
|
-
pendingPrompt: string | null;
|
|
92
|
-
}
|
|
93
|
-
interface EditSessionActions {
|
|
94
|
-
submitEdit: (prompt: string) => Promise<void>;
|
|
95
|
-
revert: () => void;
|
|
96
|
-
updateActiveFile: (content: string) => void;
|
|
97
|
-
setActiveFile: (path: string) => void;
|
|
98
|
-
clearError: () => void;
|
|
99
|
-
}
|
|
100
|
-
declare function getActiveContent(state: EditSessionState): string;
|
|
101
|
-
declare function getFiles(project: VirtualProject): VirtualFile[];
|
|
102
|
-
interface EditRequest {
|
|
103
|
-
code: string;
|
|
104
|
-
prompt: string;
|
|
105
|
-
}
|
|
106
|
-
interface EditResponse {
|
|
107
|
-
newCode: string;
|
|
108
|
-
summary: string;
|
|
109
|
-
progressNotes: string[];
|
|
110
|
-
}
|
|
111
|
-
interface CompileResult {
|
|
112
|
-
success: boolean;
|
|
113
|
-
error?: string;
|
|
114
|
-
}
|
|
115
|
-
type CompileFn = (code: string) => Promise<CompileResult>;
|
|
116
|
-
|
|
117
|
-
interface EditApiOptions {
|
|
118
|
-
endpoint?: string;
|
|
119
|
-
onProgress?: (note: string) => void;
|
|
120
|
-
/** Automatically remove stray diff markers from output (default: true) */
|
|
121
|
-
sanitize?: boolean;
|
|
122
|
-
}
|
|
123
|
-
declare function sendEditRequest(request: EditRequest, options?: EditApiOptions): Promise<EditResponse>;
|
|
124
|
-
|
|
125
|
-
interface UseEditSessionOptions {
|
|
126
|
-
originalCode: string;
|
|
127
|
-
compile?: CompileFn;
|
|
128
|
-
apiEndpoint?: string;
|
|
129
|
-
}
|
|
130
|
-
declare function useEditSession(options: UseEditSessionOptions): EditSessionState & EditSessionActions;
|
|
131
|
-
|
|
132
|
-
interface EditHistoryProps {
|
|
133
|
-
entries: EditHistoryEntry[];
|
|
134
|
-
streamingNotes: string[];
|
|
135
|
-
isStreaming: boolean;
|
|
136
|
-
pendingPrompt?: string | null;
|
|
137
|
-
className?: string;
|
|
138
|
-
}
|
|
139
|
-
declare function EditHistory({ entries, streamingNotes, isStreaming, pendingPrompt, className, }: EditHistoryProps): react_jsx_runtime.JSX.Element;
|
|
140
|
-
|
|
141
|
-
interface EditModalProps extends UseEditSessionOptions {
|
|
142
|
-
isOpen: boolean;
|
|
143
|
-
onClose: (finalCode: string, editCount: number) => void;
|
|
144
|
-
renderPreview: (code: string) => ReactNode;
|
|
145
|
-
renderLoading?: () => ReactNode;
|
|
146
|
-
renderError?: (error: string) => ReactNode;
|
|
147
|
-
previewError?: string | null;
|
|
148
|
-
previewLoading?: boolean;
|
|
149
|
-
}
|
|
150
|
-
declare function EditModal({ isOpen, onClose, renderPreview, renderLoading, renderError, previewError, previewLoading, ...sessionOptions }: EditModalProps): react_jsx_runtime.JSX.Element | null;
|
|
151
|
-
|
|
152
|
-
interface FileTreeProps {
|
|
153
|
-
files: VirtualFile[];
|
|
154
|
-
activeFile: string;
|
|
155
|
-
onSelectFile: (path: string) => void;
|
|
156
|
-
}
|
|
157
|
-
declare function FileTree({ files, activeFile, onSelectFile }: FileTreeProps): react_jsx_runtime.JSX.Element;
|
|
158
|
-
|
|
159
|
-
type TextPart = {
|
|
160
|
-
type: 'text';
|
|
161
|
-
content: string;
|
|
162
|
-
};
|
|
163
|
-
type CodePart = {
|
|
164
|
-
type: 'code' | string;
|
|
165
|
-
content: string;
|
|
166
|
-
language: 'jsx' | 'tsx' | string;
|
|
167
|
-
attributes?: Record<string, string>;
|
|
168
|
-
};
|
|
169
|
-
type ParsedPart = TextPart | CodePart;
|
|
170
|
-
interface ExtractOptions {
|
|
171
|
-
/** Only extract these languages (default: all) */
|
|
172
|
-
filterLanguages?: Set<string>;
|
|
173
|
-
/** Include unclosed code blocks at the end (for streaming) */
|
|
174
|
-
includeUnclosed?: boolean;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Extract code blocks from markdown text.
|
|
178
|
-
*/
|
|
179
|
-
declare function extractCodeBlocks(text: string, options?: ExtractOptions): ParsedPart[];
|
|
180
|
-
/**
|
|
181
|
-
* Find the first JSX/TSX block in the text.
|
|
182
|
-
* Returns null if no JSX block is found.
|
|
183
|
-
*/
|
|
184
|
-
declare function findFirstCodeBlock(text: string): CodePart | null;
|
|
185
|
-
/**
|
|
186
|
-
* Check if text contains any JSX/TSX code blocks.
|
|
187
|
-
*/
|
|
188
|
-
declare function hasCodeBlock(text: string): boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Get all unique languages found in code blocks.
|
|
191
|
-
*/
|
|
192
|
-
declare function getCodeBlockLanguages(text: string): Set<string>;
|
|
193
|
-
/**
|
|
194
|
-
* Extract code blocks as a VirtualProject.
|
|
195
|
-
* Groups files with path attributes into a multi-file project.
|
|
196
|
-
* Files without paths are treated as the main entry file.
|
|
197
|
-
*/
|
|
198
|
-
declare function extractProject(text: string, options?: ExtractOptions): {
|
|
199
|
-
project: VirtualProject;
|
|
200
|
-
textParts: TextPart[];
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
interface CodeBlockAttributes {
|
|
204
|
-
/** Progress note for UI display (optional but encouraged, comes first) */
|
|
205
|
-
note?: string;
|
|
206
|
-
/** Virtual file path for multi-file generation (uses \@/ prefix) */
|
|
207
|
-
path?: string;
|
|
208
|
-
/** Additional arbitrary attributes */
|
|
209
|
-
[key: string]: string | undefined;
|
|
210
|
-
}
|
|
211
|
-
interface CodeBlock {
|
|
212
|
-
/** Language identifier (e.g., tsx, json, diff) */
|
|
213
|
-
language: string;
|
|
214
|
-
/** Parsed attributes from the fence line */
|
|
215
|
-
attributes: CodeBlockAttributes;
|
|
216
|
-
/** Raw content between the fence markers */
|
|
217
|
-
content: string;
|
|
218
|
-
}
|
|
219
|
-
interface DiffBlock {
|
|
220
|
-
search: string;
|
|
221
|
-
replace: string;
|
|
222
|
-
/** Progress note from the code fence attributes */
|
|
223
|
-
note?: string;
|
|
224
|
-
/** Target file path for multi-file edits */
|
|
225
|
-
path?: string;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Parse attributes from a code fence line.
|
|
229
|
-
*
|
|
230
|
-
* Example input: 'note="Adding handler" path="\@/components/Button.tsx"'
|
|
231
|
-
*
|
|
232
|
-
* Returns: an object with note, path, and any other attributes
|
|
233
|
-
*/
|
|
234
|
-
declare function parseCodeBlockAttributes(attrString: string): CodeBlockAttributes;
|
|
235
|
-
/**
|
|
236
|
-
* Parse all code blocks from text, extracting language and attributes.
|
|
237
|
-
* Returns blocks in order of appearance.
|
|
238
|
-
*/
|
|
239
|
-
declare function parseCodeBlocks(text: string): CodeBlock[];
|
|
240
|
-
/**
|
|
241
|
-
* Check if text contains any diff markers.
|
|
242
|
-
* Returns the first marker found, or null if clean.
|
|
243
|
-
*/
|
|
244
|
-
declare function findDiffMarkers(text: string): string | null;
|
|
245
|
-
/**
|
|
246
|
-
* Remove stray diff markers from text.
|
|
247
|
-
* Use as a fallback when markers leak into output.
|
|
248
|
-
*/
|
|
249
|
-
declare function sanitizeDiffMarkers(text: string): string;
|
|
250
|
-
interface ParsedEditResponse {
|
|
251
|
-
/** Progress notes extracted from code block attributes (in order of appearance) */
|
|
252
|
-
progressNotes: string[];
|
|
253
|
-
/** Parsed diff blocks with their attributes */
|
|
254
|
-
diffs: DiffBlock[];
|
|
255
|
-
/** Summary markdown text (content outside of code blocks) */
|
|
256
|
-
summary: string;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Parse progress notes and diffs from an edit response.
|
|
260
|
-
*
|
|
261
|
-
* New format uses tagged attributes on code fences:
|
|
262
|
-
* ```diff note="Adding handler" path="@/components/Button.tsx"
|
|
263
|
-
* <<<<<<< SEARCH
|
|
264
|
-
* exact code
|
|
265
|
-
* =======
|
|
266
|
-
* replacement
|
|
267
|
-
* >>>>>>> REPLACE
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* Summary markdown is everything outside of code blocks.
|
|
271
|
-
*/
|
|
272
|
-
declare function parseEditResponse(text: string): ParsedEditResponse;
|
|
273
|
-
/**
|
|
274
|
-
* Parse diff blocks from text, extracting attributes from code fences.
|
|
275
|
-
* Supports both fenced code blocks with attributes and raw diff markers.
|
|
276
|
-
*/
|
|
277
|
-
declare function parseDiffs(text: string): DiffBlock[];
|
|
278
|
-
declare function applyDiffs(code: string, diffs: DiffBlock[], options?: {
|
|
279
|
-
sanitize?: boolean;
|
|
280
|
-
}): {
|
|
281
|
-
code: string;
|
|
282
|
-
applied: number;
|
|
283
|
-
failed: string[];
|
|
284
|
-
warning?: string;
|
|
285
|
-
};
|
|
286
|
-
declare function hasDiffBlocks(text: string): boolean;
|
|
287
|
-
declare function extractTextWithoutDiffs(text: string): string;
|
|
288
|
-
/**
|
|
289
|
-
* Extract the summary markdown from an edit response.
|
|
290
|
-
* Removes code blocks (with their attributes), and any leading/trailing whitespace.
|
|
291
|
-
* Preserves regular markdown prose outside of code blocks.
|
|
292
|
-
*/
|
|
293
|
-
declare function extractSummary(text: string): string;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Get VFS configuration from the server.
|
|
297
|
-
* Caches the result for subsequent calls.
|
|
298
|
-
*/
|
|
299
|
-
declare function getVFSConfig(): Promise<{
|
|
300
|
-
usePaths: boolean;
|
|
301
|
-
}>;
|
|
302
|
-
/**
|
|
303
|
-
* Get the VFS store instance (creates one if needed).
|
|
304
|
-
* Store uses LocalFSBackend to persist to the stitchery server.
|
|
305
|
-
*/
|
|
306
|
-
declare function getVFSStore(): VFSStore;
|
|
307
|
-
/**
|
|
308
|
-
* Save a virtual project to disk via the stitchery server.
|
|
309
|
-
* Projects are saved under their ID in the VFS directory.
|
|
310
|
-
*/
|
|
311
|
-
declare function saveProject(project: VirtualProject): Promise<void>;
|
|
312
|
-
/**
|
|
313
|
-
* Load a project from disk by ID.
|
|
314
|
-
*/
|
|
315
|
-
declare function loadProject(id: string): Promise<VirtualProject | null>;
|
|
316
|
-
/**
|
|
317
|
-
* List all stored project IDs.
|
|
318
|
-
*/
|
|
319
|
-
declare function listProjects(): Promise<string[]>;
|
|
320
|
-
/**
|
|
321
|
-
* Save a single file to the VFS.
|
|
322
|
-
*/
|
|
323
|
-
declare function saveFile(file: VirtualFile): Promise<void>;
|
|
324
|
-
/**
|
|
325
|
-
* Check if VFS is available (stitchery server is running with vfs-dir enabled).
|
|
326
|
-
*/
|
|
327
|
-
declare function isVFSAvailable(): Promise<boolean>;
|
|
328
|
-
|
|
329
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
330
|
-
|
|
331
|
-
export { type CodeBlock, type CodeBlockAttributes, CodeBlockExtension, type CodePart, CodePreview, type CompileFn, type CompileResult, type DiffBlock, type EditApiOptions, EditHistory, type EditHistoryEntry, EditModal, type EditModalProps, type EditRequest, type EditResponse, type EditSessionActions, type EditSessionState, type ExtractOptions, FileTree, type FileTreeProps, MarkdownEditor, type ParsedEditResponse, type ParsedPart, type ServiceInfo, ServicesInspector, type TextPart, type UseEditSessionOptions, applyDiffs, cn, extractCodeBlocks, extractProject, extractSummary, extractTextWithoutDiffs, findDiffMarkers, findFirstCodeBlock, getActiveContent, getCodeBlockLanguages, getFiles, getVFSConfig, getVFSStore, hasCodeBlock, hasDiffBlocks, isVFSAvailable, listProjects, loadProject, parseCodeBlockAttributes, parseCodeBlocks, parseDiffs, parseEditResponse, sanitizeDiffMarkers, saveFile, saveProject, sendEditRequest, useEditSession };
|
|
1
|
+
export { CodeBlockExtension, CodePreview, MarkdownEditor, ServicesInspector, type ServiceInfo, } from './components';
|
|
2
|
+
export { EditModal, EditHistory, FileTree, SaveConfirmDialog, CodeBlockView, MediaPreview, useEditSession, sendEditRequest, type EditModalProps, type UseEditSessionOptions, type EditHistoryEntry, type EditSessionState, type EditSessionActions, type EditRequest, type EditResponse, type CompileResult, type CompileFn, type EditApiOptions, type FileTreeProps, type SaveConfirmDialogProps, type CodeBlockViewProps, type MediaPreviewProps, type FileCategory, type FileTypeInfo, type FileEncoding, getActiveContent, getFiles, getFileType, isCompilable, isMediaFile, isTextFile, isImageFile, isVideoFile, getLanguageFromExt, getMimeType, } from './components/edit';
|
|
3
|
+
export { extractCodeBlocks, findFirstCodeBlock, hasCodeBlock, getCodeBlockLanguages, extractProject, type TextPart, type CodePart, type ParsedPart, type ExtractOptions, parseCodeBlockAttributes, parseCodeBlocks, findDiffMarkers, sanitizeDiffMarkers, parseEditResponse, parseDiffs, applyDiffs, hasDiffBlocks, extractTextWithoutDiffs, extractSummary, type CodeBlockAttributes, type CodeBlock, type DiffBlock, type ParsedEditResponse, getVFSConfig, getVFSStore, saveProject, loadProject, listProjects, saveFile, isVFSAvailable, cn, } from './lib';
|