@handylib/kai-code 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,69 @@
1
+ import * as react from 'react';
2
+ import { editor } from 'monaco-editor';
3
+
4
+ interface KaiCodeFile {
5
+ type: "file";
6
+ name: string;
7
+ path: string;
8
+ language?: string;
9
+ }
10
+ interface KaiCodeDirectory {
11
+ type: "directory";
12
+ name: string;
13
+ path: string;
14
+ }
15
+ type KaiCodeEntry = KaiCodeFile | KaiCodeDirectory;
16
+ /**
17
+ * The filesystem contract KaiCode uses to read and persist editor documents.
18
+ * Paths are adapter-defined strings; use the same format consistently across
19
+ * directory entries and file operations.
20
+ */
21
+ interface KaiCodeFileSystem {
22
+ readDirectory(path?: string): Promise<readonly KaiCodeEntry[]>;
23
+ readFile(path: string): Promise<string>;
24
+ writeFile(path: string, contents: string): Promise<void>;
25
+ createFile?(path: string, contents?: string): Promise<void>;
26
+ /** Enables creating empty directories from the Explorer. */
27
+ createDirectory?(path: string): Promise<void>;
28
+ deleteFile?(path: string): Promise<void>;
29
+ /** Must delete the directory and all of its descendants. */
30
+ deleteDirectory?(path: string): Promise<void>;
31
+ moveFile?(oldPath: string, newPath: string): Promise<void>;
32
+ /** Must move the directory and all of its descendants. */
33
+ moveDirectory?(oldPath: string, newPath: string): Promise<void>;
34
+ /** @deprecated Use `moveFile` instead. */
35
+ renameFile?(oldPath: string, newPath: string): Promise<void>;
36
+ watch?(listener: () => void): () => void;
37
+ }
38
+ /**
39
+ * Creates a small in-memory filesystem, useful for demos, tests, and
40
+ * applications that do not need to mount a persistent filesystem.
41
+ */
42
+ declare function createMemoryFileSystem(initialFiles?: Record<string, string>): KaiCodeFileSystem;
43
+ declare function normalizePath(path: string): string;
44
+
45
+ interface KaiCodeProps {
46
+ /** Filesystem to mount. If omitted, KaiCode uses an in-memory filesystem. */
47
+ fileSystem?: KaiCodeFileSystem;
48
+ /** Initial files used by the built-in in-memory filesystem. */
49
+ initialFiles?: Record<string, string>;
50
+ /** Path to select after the filesystem has loaded. */
51
+ initialActiveFile?: string;
52
+ /** Monaco theme name. Defaults to `vs-dark`. */
53
+ theme?: string;
54
+ /** Additional Monaco editor options. */
55
+ options?: editor.IStandaloneEditorConstructionOptions;
56
+ /** Component height. Defaults to 640px. */
57
+ height?: string | number;
58
+ /** Makes the editor read-only. */
59
+ readOnly?: boolean;
60
+ /** Optional class applied to the outermost element. */
61
+ className?: string;
62
+ /** Called as the editor's in-memory document changes. */
63
+ onFileChange?: (path: string, contents: string) => void;
64
+ /** Called after a document is successfully saved to the filesystem. */
65
+ onSave?: (path: string, contents: string) => void;
66
+ }
67
+ declare function KaiCode({ fileSystem, initialFiles, initialActiveFile, theme, options, height, readOnly, className, onFileChange, onSave, }: KaiCodeProps): react.JSX.Element;
68
+
69
+ export { KaiCode, type KaiCodeDirectory, type KaiCodeEntry, type KaiCodeFile, type KaiCodeFileSystem, type KaiCodeProps, createMemoryFileSystem, KaiCode as default, normalizePath };