@opencode/plugin 0.0.0-dev-55 → 0.0.0-dev-57
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/dist/gui/browser.d.ts +36 -0
- package/dist/gui/browser.js +3 -0
- package/dist/gui/context.d.ts +223 -0
- package/dist/gui/context.js +0 -0
- package/dist/gui/core.d.ts +560 -0
- package/dist/gui/core.js +86 -0
- package/dist/gui/declarations.d.ts +24 -0
- package/dist/gui/declarations.js +0 -0
- package/dist/gui/file.d.ts +122 -0
- package/dist/gui/file.js +7 -0
- package/dist/gui/host-apis.d.ts +1109 -0
- package/dist/gui/host-apis.js +0 -0
- package/dist/gui/icon-name.d.ts +2 -0
- package/dist/gui/icon-name.js +1 -0
- package/dist/gui/index.d.ts +7 -0
- package/dist/gui/index.js +6 -0
- package/dist/gui/internal.d.ts +44 -0
- package/dist/gui/internal.js +33 -0
- package/dist/gui/main.d.ts +279 -0
- package/dist/gui/main.js +20 -0
- package/dist/gui/modules.d.ts +15 -0
- package/dist/gui/modules.js +30 -0
- package/dist/gui/plugin.d.ts +86 -0
- package/dist/gui/plugin.js +9 -0
- package/dist/gui/reactive.d.ts +93 -0
- package/dist/gui/reactive.js +130 -0
- package/dist/gui/registries.d.ts +770 -0
- package/dist/gui/registries.js +110 -0
- package/dist/gui/review.d.ts +73 -0
- package/dist/gui/review.js +3 -0
- package/dist/gui/scope.d.ts +64 -0
- package/dist/gui/scope.js +85 -0
- package/dist/gui/solid.d.ts +99 -0
- package/dist/gui/solid.js +74 -0
- package/dist/gui/vite.d.ts +24 -0
- package/dist/gui/vite.js +49 -0
- package/dist/host.d.ts +12 -1
- package/dist/host.js +34 -2
- package/dist/runtime-modules.js +3 -1
- package/package.json +54 -10
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Component, JSX } from "solid-js";
|
|
2
|
+
import type { ArtifactKind } from "@opencode/util/artifact";
|
|
3
|
+
import type { ChangeKind } from "./review.js";
|
|
4
|
+
import { Contract, Registry } from "./core.js";
|
|
5
|
+
import type { MountedSession, SessionScreen } from "./host-apis.js";
|
|
6
|
+
/** What `FileTree.Tree` renders: a tree of only the allowed workspace files. */
|
|
7
|
+
export interface FileTreeProps {
|
|
8
|
+
/** The session screen that owns the rendered files. */
|
|
9
|
+
readonly screen: SessionScreen;
|
|
10
|
+
/** The session whose workspace the files belong to. */
|
|
11
|
+
readonly session: MountedSession;
|
|
12
|
+
/** The files to show, as a tree of only these paths. */
|
|
13
|
+
readonly allowed: readonly string[];
|
|
14
|
+
/** Change markers by normalized path, such as `Changes.kinds(session)`; omit it to show none. */
|
|
15
|
+
readonly kinds?: ReadonlyMap<string, ChangeKind>;
|
|
16
|
+
/** Text after a folder row's name, such as how many entries it has. */
|
|
17
|
+
readonly labels?: ReadonlyMap<string, string>;
|
|
18
|
+
/** The selected file's path, if any. */
|
|
19
|
+
readonly active?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Runs when the user picks a file.
|
|
22
|
+
*
|
|
23
|
+
* @param path - The picked file's path.
|
|
24
|
+
*/
|
|
25
|
+
onFileClick(path: string): void;
|
|
26
|
+
}
|
|
27
|
+
/** What `FileTree.List` renders: a flat list of workspace files. */
|
|
28
|
+
export interface FileListProps {
|
|
29
|
+
/** The session screen that owns the rendered files. */
|
|
30
|
+
readonly screen: SessionScreen;
|
|
31
|
+
/** The session whose workspace the files belong to. */
|
|
32
|
+
readonly session: MountedSession;
|
|
33
|
+
/** The files to list, in order. */
|
|
34
|
+
readonly files: readonly string[];
|
|
35
|
+
/** Change markers by normalized path; omit it to show none. */
|
|
36
|
+
readonly kinds?: ReadonlyMap<string, ChangeKind>;
|
|
37
|
+
/** The selected file's path, if any. */
|
|
38
|
+
readonly active?: string;
|
|
39
|
+
/** Keyboard highlight of search results; takes over the selected row while set. */
|
|
40
|
+
readonly highlighted?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Runs when the user picks a file.
|
|
43
|
+
*
|
|
44
|
+
* @param path - The picked file's path.
|
|
45
|
+
*/
|
|
46
|
+
onFileClick(path: string): void;
|
|
47
|
+
}
|
|
48
|
+
/** The file browser's virtualized tree and flat list, for other panels that list workspace files. */
|
|
49
|
+
export interface FileTree {
|
|
50
|
+
/**
|
|
51
|
+
* Renders the files as a tree.
|
|
52
|
+
*
|
|
53
|
+
* @param props - What to show.
|
|
54
|
+
* @returns The tree.
|
|
55
|
+
*/
|
|
56
|
+
Tree(props: FileTreeProps): JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* Renders the files as a flat list.
|
|
59
|
+
*
|
|
60
|
+
* @param props - What to list.
|
|
61
|
+
* @returns The list.
|
|
62
|
+
*/
|
|
63
|
+
List(props: FileListProps): JSX.Element;
|
|
64
|
+
}
|
|
65
|
+
/** The file plugin provides this. */
|
|
66
|
+
export declare const FileTree: Contract<FileTree, "file.tree">;
|
|
67
|
+
/** What `OpenInApp.Button` opens. */
|
|
68
|
+
export interface OpenInAppProps {
|
|
69
|
+
/** The session screen whose workspace opens. */
|
|
70
|
+
readonly screen: SessionScreen;
|
|
71
|
+
/** The session whose workspace opens. */
|
|
72
|
+
readonly session: MountedSession;
|
|
73
|
+
}
|
|
74
|
+
/** The desktop "Open in" button, for a panel header that shows it in place of the tab strip's. */
|
|
75
|
+
export interface OpenInApp {
|
|
76
|
+
/**
|
|
77
|
+
* Renders nothing on the web or for a remote server. While it is mounted, the tab strip leaves out its own.
|
|
78
|
+
*
|
|
79
|
+
* @param props - The workspace to open.
|
|
80
|
+
* @returns The button.
|
|
81
|
+
*/
|
|
82
|
+
Button(props: OpenInAppProps): JSX.Element;
|
|
83
|
+
}
|
|
84
|
+
/** The file plugin provides this. */
|
|
85
|
+
export declare const OpenInApp: Contract<OpenInApp, "file.openInApp">;
|
|
86
|
+
/** What a `FileViewer`'s `View` receives. */
|
|
87
|
+
export interface FileViewerProps {
|
|
88
|
+
/**
|
|
89
|
+
* The file's bytes, which this view owns: it may move their buffer elsewhere, such as to a worker, instead of copying
|
|
90
|
+
* it. A new array is a reloaded file.
|
|
91
|
+
*/
|
|
92
|
+
readonly bytes: Uint8Array;
|
|
93
|
+
/**
|
|
94
|
+
* Shows facts about the file, such as "3 sheets", in the toolbar before its size.
|
|
95
|
+
*
|
|
96
|
+
* @param details - The facts, in order.
|
|
97
|
+
*/
|
|
98
|
+
onDetails(details: readonly string[]): void;
|
|
99
|
+
/**
|
|
100
|
+
* The file could not be opened; the file view shows its binary placeholder instead, with `reason` when given.
|
|
101
|
+
*
|
|
102
|
+
* @param reason - Why, for the placeholder.
|
|
103
|
+
*/
|
|
104
|
+
onError(reason?: string): void;
|
|
105
|
+
}
|
|
106
|
+
/** A viewer for a kind of file the file view does not render itself, such as an Office document. */
|
|
107
|
+
export interface FileViewer {
|
|
108
|
+
/** The kinds it renders. A file the first matching viewer cannot open, or no viewer lists, shows as binary. */
|
|
109
|
+
readonly kinds: readonly ArtifactKind[];
|
|
110
|
+
/**
|
|
111
|
+
* Why these bytes cannot be shown, checked before `View` or its engine loads, such as a file that is not in the
|
|
112
|
+
* format its name says. Returns undefined for bytes `View` should open.
|
|
113
|
+
*
|
|
114
|
+
* @param bytes - The file's bytes.
|
|
115
|
+
* @returns The reason, or undefined.
|
|
116
|
+
*/
|
|
117
|
+
problem?(bytes: Uint8Array): string | undefined;
|
|
118
|
+
/** Renders one file in the file view's stage. Bind it with `bindPlugin` in setup. A thrown error shows as binary. */
|
|
119
|
+
readonly View: Component<FileViewerProps>;
|
|
120
|
+
}
|
|
121
|
+
/** Viewers for file kinds the file view does not render itself. Contribute one with `ctx.add(FileViewer, viewer)`. */
|
|
122
|
+
export declare const FileViewer: Registry<FileViewer>;
|
package/dist/gui/file.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Contract, Registry } from "./core.js";
|
|
2
|
+
/** The file plugin provides this. */
|
|
3
|
+
export const FileTree = Contract.define("file.tree");
|
|
4
|
+
/** The file plugin provides this. */
|
|
5
|
+
export const OpenInApp = Contract.define("file.openInApp");
|
|
6
|
+
/** Viewers for file kinds the file view does not render itself. Contribute one with `ctx.add(FileViewer, viewer)`. */
|
|
7
|
+
export const FileViewer = Registry.define("file.viewer");
|