@radheim/plugin 0.0.0-stage → 2.4.3

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 (170) hide show
  1. package/README.md +19 -3
  2. package/dist/app.d.ts +5 -0
  3. package/dist/app.js +0 -0
  4. package/dist/effect/agent.d.ts +15 -0
  5. package/dist/effect/agent.js +0 -0
  6. package/dist/effect/aisdk.d.ts +20 -0
  7. package/dist/effect/aisdk.js +0 -0
  8. package/dist/effect/artifact.d.ts +42 -0
  9. package/dist/effect/artifact.js +0 -0
  10. package/dist/effect/command.d.ts +23 -0
  11. package/dist/effect/command.js +0 -0
  12. package/dist/effect/event.d.ts +9 -0
  13. package/dist/effect/event.js +0 -0
  14. package/dist/effect/index.d.ts +20 -0
  15. package/dist/effect/index.js +19 -0
  16. package/dist/effect/integration.d.ts +103 -0
  17. package/dist/effect/integration.js +3 -0
  18. package/dist/effect/mcp.d.ts +15 -0
  19. package/dist/effect/mcp.js +0 -0
  20. package/dist/effect/model.d.ts +29 -0
  21. package/dist/effect/model.js +0 -0
  22. package/dist/effect/permission.d.ts +30 -0
  23. package/dist/effect/permission.js +0 -0
  24. package/dist/effect/plugin.d.ts +69 -0
  25. package/dist/effect/plugin.js +3 -0
  26. package/dist/effect/provider.d.ts +34 -0
  27. package/dist/effect/provider.js +0 -0
  28. package/dist/effect/push.d.ts +52 -0
  29. package/dist/effect/push.js +0 -0
  30. package/dist/effect/reference.d.ts +14 -0
  31. package/dist/effect/reference.js +0 -0
  32. package/dist/effect/registration.d.ts +13 -0
  33. package/dist/effect/registration.js +0 -0
  34. package/dist/effect/rpc.d.ts +19 -0
  35. package/dist/effect/rpc.js +0 -0
  36. package/dist/effect/session.d.ts +217 -0
  37. package/dist/effect/session.js +0 -0
  38. package/dist/effect/shell.d.ts +14 -0
  39. package/dist/effect/shell.js +0 -0
  40. package/dist/effect/skill.d.ts +15 -0
  41. package/dist/effect/skill.js +1 -0
  42. package/dist/effect/storage.d.ts +8 -0
  43. package/dist/effect/storage.js +0 -0
  44. package/dist/effect/tool.d.ts +60 -0
  45. package/dist/effect/tool.js +1 -0
  46. package/dist/effect/vcs.d.ts +43 -0
  47. package/dist/effect/vcs.js +0 -0
  48. package/dist/effect/websearch.d.ts +20 -0
  49. package/dist/effect/websearch.js +0 -0
  50. package/dist/effect/worktree.d.ts +18 -0
  51. package/dist/effect/worktree.js +0 -0
  52. package/dist/gui/browser.d.ts +54 -0
  53. package/dist/gui/browser.js +3 -0
  54. package/dist/gui/context.d.ts +287 -0
  55. package/dist/gui/context.js +0 -0
  56. package/dist/gui/core.d.ts +581 -0
  57. package/dist/gui/core.js +86 -0
  58. package/dist/gui/declarations.d.ts +47 -0
  59. package/dist/gui/declarations.js +0 -0
  60. package/dist/gui/file.d.ts +122 -0
  61. package/dist/gui/file.js +7 -0
  62. package/dist/gui/host-apis.d.ts +2239 -0
  63. package/dist/gui/host-apis.js +0 -0
  64. package/dist/gui/icon-name.d.ts +2 -0
  65. package/dist/gui/icon-name.js +1 -0
  66. package/dist/gui/index.d.ts +7 -0
  67. package/dist/gui/index.js +6 -0
  68. package/dist/gui/internal.d.ts +44 -0
  69. package/dist/gui/internal.js +33 -0
  70. package/dist/gui/main.d.ts +279 -0
  71. package/dist/gui/main.js +20 -0
  72. package/dist/gui/modules.d.ts +15 -0
  73. package/dist/gui/modules.js +30 -0
  74. package/dist/gui/plugin.d.ts +87 -0
  75. package/dist/gui/plugin.js +9 -0
  76. package/dist/gui/reactive.d.ts +93 -0
  77. package/dist/gui/reactive.js +130 -0
  78. package/dist/gui/registries.d.ts +1045 -0
  79. package/dist/gui/registries.js +153 -0
  80. package/dist/gui/review.d.ts +74 -0
  81. package/dist/gui/review.js +3 -0
  82. package/dist/gui/scope.d.ts +64 -0
  83. package/dist/gui/scope.js +85 -0
  84. package/dist/gui/solid.d.ts +111 -0
  85. package/dist/gui/solid.js +74 -0
  86. package/dist/gui/vite.d.ts +24 -0
  87. package/dist/gui/vite.js +49 -0
  88. package/dist/host.d.ts +23 -0
  89. package/dist/host.js +65 -0
  90. package/dist/options.d.ts +1 -0
  91. package/dist/options.js +0 -0
  92. package/dist/permission.d.ts +22 -0
  93. package/dist/permission.js +12 -0
  94. package/dist/promise/adapter.d.ts +12 -0
  95. package/dist/promise/adapter.js +576 -0
  96. package/dist/promise/agent.d.ts +15 -0
  97. package/dist/promise/agent.js +0 -0
  98. package/dist/promise/aisdk.d.ts +20 -0
  99. package/dist/promise/aisdk.js +0 -0
  100. package/dist/promise/artifact.d.ts +49 -0
  101. package/dist/promise/artifact.js +0 -0
  102. package/dist/promise/command.d.ts +22 -0
  103. package/dist/promise/command.js +0 -0
  104. package/dist/promise/event.d.ts +7 -0
  105. package/dist/promise/event.js +0 -0
  106. package/dist/promise/index.d.ts +20 -0
  107. package/dist/promise/index.js +18 -0
  108. package/dist/promise/integration.d.ts +102 -0
  109. package/dist/promise/integration.js +3 -0
  110. package/dist/promise/mcp.d.ts +15 -0
  111. package/dist/promise/mcp.js +0 -0
  112. package/dist/promise/model.d.ts +29 -0
  113. package/dist/promise/model.js +0 -0
  114. package/dist/promise/permission.d.ts +29 -0
  115. package/dist/promise/permission.js +0 -0
  116. package/dist/promise/plugin.d.ts +70 -0
  117. package/dist/promise/plugin.js +3 -0
  118. package/dist/promise/provider.d.ts +34 -0
  119. package/dist/promise/provider.js +0 -0
  120. package/dist/promise/push.d.ts +50 -0
  121. package/dist/promise/push.js +0 -0
  122. package/dist/promise/reference.d.ts +13 -0
  123. package/dist/promise/reference.js +0 -0
  124. package/dist/promise/registration.d.ts +12 -0
  125. package/dist/promise/registration.js +0 -0
  126. package/dist/promise/rpc.d.ts +22 -0
  127. package/dist/promise/rpc.js +0 -0
  128. package/dist/promise/session.d.ts +217 -0
  129. package/dist/promise/session.js +0 -0
  130. package/dist/promise/shell.d.ts +14 -0
  131. package/dist/promise/shell.js +0 -0
  132. package/dist/promise/skill.d.ts +15 -0
  133. package/dist/promise/skill.js +0 -0
  134. package/dist/promise/storage.d.ts +8 -0
  135. package/dist/promise/storage.js +0 -0
  136. package/dist/promise/tool.d.ts +71 -0
  137. package/dist/promise/tool.js +2 -0
  138. package/dist/promise/vcs.d.ts +53 -0
  139. package/dist/promise/vcs.js +0 -0
  140. package/dist/promise/websearch.d.ts +21 -0
  141. package/dist/promise/websearch.js +0 -0
  142. package/dist/promise/worktree.d.ts +23 -0
  143. package/dist/promise/worktree.js +0 -0
  144. package/dist/rpc.d.ts +1 -0
  145. package/dist/rpc.js +1 -0
  146. package/dist/runtime-modules.d.ts +6 -0
  147. package/dist/runtime-modules.js +103 -0
  148. package/dist/runtime.d.ts +4 -0
  149. package/dist/runtime.js +46 -0
  150. package/dist/source.bun.d.ts +4 -0
  151. package/dist/source.bun.js +75 -0
  152. package/dist/source.d.ts +8 -0
  153. package/dist/source.js +59 -0
  154. package/dist/source.node.d.ts +5 -0
  155. package/dist/source.node.js +55 -0
  156. package/dist/source.package.d.ts +1 -0
  157. package/dist/source.package.js +15 -0
  158. package/dist/storage.d.ts +14 -0
  159. package/dist/storage.js +0 -0
  160. package/dist/tui/context.d.ts +500 -0
  161. package/dist/tui/context.js +0 -0
  162. package/dist/tui/index.d.ts +2 -0
  163. package/dist/tui/index.js +2 -0
  164. package/dist/tui/plugin.d.ts +8 -0
  165. package/dist/tui/plugin.js +3 -0
  166. package/dist/tui/solid.d.ts +7 -0
  167. package/dist/tui/solid.js +16 -0
  168. package/dist/worktree.d.ts +18 -0
  169. package/dist/worktree.js +0 -0
  170. package/package.json +137 -4
@@ -0,0 +1,47 @@
1
+ import type { Catalog, OS, StoreDeclaration } from "./core.js";
2
+ /** The stores a plugin's GUI may declare. */
3
+ export type Stores = Readonly<Record<string, StoreDeclaration>>;
4
+ /** The icons a plugin's GUI may declare: each icon's SVG document, by the icon's name. */
5
+ export type Icons = Readonly<Record<string, string>>;
6
+ /**
7
+ * What a plugin's GUI declares: its window state, its icons, its copy and the systems it runs on. `Plugin.define`
8
+ * returns this for a definition without setups, so setups in other files are typed from it
9
+ * (`Plugin.Setup<typeof definition>`). The host reads it before any setup runs. The plugin's id is not declared here:
10
+ * the host assigns it (`ctx.id`), from the server plugin for a `./gui-experimental` bundle. Contracts are provided and
11
+ * read at runtime, with `ctx.provide`, `ctx.use` and `ctx.main`.
12
+ */
13
+ export interface Declarations<S extends Stores = Stores, I extends Icons = Icons> {
14
+ /**
15
+ * The operating systems the plugin runs on. Omit it to run on every OS. A plugin from the config runs only in the
16
+ * desktop app; a built-in that lists any OS does not run on the web, where no OS is known.
17
+ */
18
+ readonly os?: readonly OS[];
19
+ /** The plugin's copy. `ctx.t` reads it first, then the app's shared keys such as `common.*`. */
20
+ readonly i18n?: Catalog;
21
+ /**
22
+ * Window state the host stores for the plugin, by store name, loaded before it is read. See `Store`. Keys known only
23
+ * at runtime, and every main-process value, go through `ctx.storage.store`.
24
+ */
25
+ readonly stores?: S;
26
+ /**
27
+ * The plugin's own icons, by name, for artwork the app's icon catalog does not have. Each value is an SVG document
28
+ * as text, as a design tool exports it; a bundle built with `gui()` imports the file with `?raw`. The host registers
29
+ * them before setup, and `ctx.icons` gives each one's name for every SDK icon field and for `ctx.ui.Icon`. A value
30
+ * that is not an SVG document fails the plugin when it starts.
31
+ * - The document's `viewBox` frames the drawing, else its `width` and `height`. The host scales the drawing to the
32
+ * place that shows it, so draw on the app's 16px grid.
33
+ * - Draw with `currentColor`: the icon takes the color of the place that shows it, such as a pill's `tone`.
34
+ * - A drawing may move with SVG animation elements (`animate`, `animateTransform`). Every place that shows the icon
35
+ * moves in step, and the animation goes on while the host renders that place again. Under the user's reduced
36
+ * motion setting the host holds the icon on its first frame, so make that frame the resting drawing.
37
+ * - An `id` in the drawing is the whole window's; keep it unique, or leave it out.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import logo from "./logo.svg?raw"
42
+ *
43
+ * export default Plugin.define({ icons: { logo }, setup })
44
+ * ```
45
+ */
46
+ readonly icons?: I;
47
+ }
File without changes
@@ -0,0 +1,122 @@
1
+ import type { Component, JSX } from "solid-js";
2
+ import type { ArtifactKind } from "@radheim/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 such as the review's. */
75
+ export interface OpenInApp {
76
+ /**
77
+ * Renders nothing on the web or for a remote server.
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>;
@@ -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");