@verbatra/studio 0.1.0-next.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.
- package/README.md +54 -0
- package/dist/app/assets/index-CxoW3Rct.js +9 -0
- package/dist/app/assets/index-mZ-7WS7w.css +1 -0
- package/dist/app/index.html +13 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +971 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { LoadedConfig, SdkFs, CheckDeps } from '@verbatra/sdk';
|
|
2
|
+
|
|
3
|
+
/** The result of one `execFileImpl` call: captured stdout and stderr, never a raw child_process error. */
|
|
4
|
+
interface ExecFileResult {
|
|
5
|
+
readonly stdout: string;
|
|
6
|
+
readonly stderr: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A bounded, argument-array process runner: `execFile(file, args, options)`, never a shell string.
|
|
10
|
+
* Mirrors `util.promisify(child_process.execFile)`. Consumed by the git-log history view, which
|
|
11
|
+
* runs `git` with an explicit `cwd` and never a `--follow` or other unbounded argument.
|
|
12
|
+
*/
|
|
13
|
+
type ExecFileImpl = (file: string, args: readonly string[], options: {
|
|
14
|
+
readonly cwd: string;
|
|
15
|
+
}) => Promise<ExecFileResult>;
|
|
16
|
+
/**
|
|
17
|
+
* A minimal change-event source for the live-refresh stream. Mirrors the shape of the sdk's own
|
|
18
|
+
* `Watcher` (see `@verbatra/sdk`'s `watch.ts`) but is studio-owned: production wraps chokidar directly
|
|
19
|
+
* (a studio dependency in its own right), tests inject a stub.
|
|
20
|
+
*/
|
|
21
|
+
interface StudioWatcher {
|
|
22
|
+
/** Register a listener invoked once per coalesced, debounced change event. */
|
|
23
|
+
onChange(listener: () => void): void;
|
|
24
|
+
/** Stop watching and release the underlying resources. */
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/** Builds a {@link StudioWatcher} over the given paths (the source file, target files, and the lock-file). */
|
|
28
|
+
type CreateStudioWatcher = (paths: readonly string[]) => StudioWatcher;
|
|
29
|
+
/**
|
|
30
|
+
* Every dependency an RPC handler or the server itself may need, across the whole dashboard, fully
|
|
31
|
+
* pre-declared up front so later handlers never widen this type. Most fields are unused until a
|
|
32
|
+
* later view lands; each doc comment names what consumes it.
|
|
33
|
+
*/
|
|
34
|
+
interface StudioServerDeps {
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the project configuration exactly once, at server startup, before the server starts
|
|
37
|
+
* listening. Every RPC handler receives that same resolved value for the life of the process; it
|
|
38
|
+
* is never re-invoked per request, and the server holds no other project-derived cache. Consumed
|
|
39
|
+
* by every RPC handler, starting with the project configuration snapshot.
|
|
40
|
+
*/
|
|
41
|
+
readonly loader: () => Promise<LoadedConfig>;
|
|
42
|
+
/** Bounded file-system seam for the status and diff drift views. */
|
|
43
|
+
readonly fs?: SdkFs;
|
|
44
|
+
/** Format-adapter registry override for the status and diff drift views; defaults to the sdk's own registry. */
|
|
45
|
+
readonly adapterRegistry?: NonNullable<CheckDeps["adapterRegistry"]>;
|
|
46
|
+
/** Bounded, argument-array process runner for the git-log history view. */
|
|
47
|
+
readonly execFileImpl?: ExecFileImpl;
|
|
48
|
+
/** Factory for the file watcher backing the live-refresh event stream. */
|
|
49
|
+
readonly createWatcher?: CreateStudioWatcher;
|
|
50
|
+
/** Interval between live-refresh heartbeat frames; injected so tests never depend on a real timer. */
|
|
51
|
+
readonly heartbeatIntervalMs?: number;
|
|
52
|
+
/** Bootstrap token the server accepts. Omit to have the server generate one from secure randomness. */
|
|
53
|
+
readonly token?: string;
|
|
54
|
+
/** Sink for the startup banner and the per-request log line. Defaults to writing to the console. */
|
|
55
|
+
readonly output?: (line: string) => void;
|
|
56
|
+
/** Overrides where static assets are served from; defaults to the built SPA next to this module. */
|
|
57
|
+
readonly assetsRoot?: URL;
|
|
58
|
+
}
|
|
59
|
+
/** Options accepted by {@link startStudioServer}: every {@link StudioServerDeps} field, plus the bind port and cwd. */
|
|
60
|
+
interface StudioServerOptions extends StudioServerDeps {
|
|
61
|
+
/** TCP port to bind. Omit for the default Studio port, or pass 0 to let the OS assign an ephemeral port (tests only). */
|
|
62
|
+
readonly port?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The project root every RPC handler resolves relative paths against: the source locale file,
|
|
65
|
+
* each target locale file, the lock file, and the git repository root for the history view.
|
|
66
|
+
* Omit to use `process.cwd()`, which is also the behavior of any existing caller that does not
|
|
67
|
+
* pass this.
|
|
68
|
+
*/
|
|
69
|
+
readonly cwd?: string;
|
|
70
|
+
}
|
|
71
|
+
/** A running Verbatra Studio server instance. */
|
|
72
|
+
interface StudioServer {
|
|
73
|
+
/** The loopback URL the server is reachable at, including the actual bound port. */
|
|
74
|
+
readonly url: string;
|
|
75
|
+
/** The actual bound TCP port (relevant when `port` was omitted or 0). */
|
|
76
|
+
readonly port: number;
|
|
77
|
+
/** Stops accepting new connections and closes the server. */
|
|
78
|
+
close(): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Starts the local Verbatra Studio server: a loopback-only HTTP server that serves the prebuilt
|
|
83
|
+
* SPA and gates every request behind a Host and Origin check, a bootstrap token, and a session
|
|
84
|
+
* cookie. There is no host option and no relaxed mode; the printed loopback URL, shown once at
|
|
85
|
+
* startup, is the only supported entry point.
|
|
86
|
+
*
|
|
87
|
+
* `options.loader` is resolved exactly once here, before the server starts listening (G11): every
|
|
88
|
+
* RPC handler for the life of this process receives that same resolved config, and it is never
|
|
89
|
+
* re-invoked on a later request, whatever the request does.
|
|
90
|
+
*
|
|
91
|
+
* Every RPC handler resolves relative paths against `options.cwd` when given, or `process.cwd()`
|
|
92
|
+
* otherwise; see {@link StudioServerOptions.cwd}.
|
|
93
|
+
*/
|
|
94
|
+
declare function startStudioServer(options: StudioServerOptions): Promise<StudioServer>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The port Verbatra Studio listens on when the caller does not specify one. Chosen once so the
|
|
98
|
+
* printed URL is stable and bookmarkable; there is no fallback to another port if it is busy.
|
|
99
|
+
*/
|
|
100
|
+
declare const DEFAULT_STUDIO_PORT = 5849;
|
|
101
|
+
|
|
102
|
+
/** Stable, machine-readable codes for a failure to start the local server. */
|
|
103
|
+
type StudioServerErrorCode = "PORT_IN_USE" | "BIND_FAILED";
|
|
104
|
+
/**
|
|
105
|
+
* A structured error for a failure to start the server, so a caller can branch on {@link code}
|
|
106
|
+
* instead of parsing a message. The message is always a fixed, safe string; it never embeds a
|
|
107
|
+
* filesystem path or other environment detail.
|
|
108
|
+
*/
|
|
109
|
+
declare class StudioServerStartError extends Error {
|
|
110
|
+
readonly code: StudioServerErrorCode;
|
|
111
|
+
readonly port: number;
|
|
112
|
+
constructor(code: StudioServerErrorCode, port: number, message: string);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { type CreateStudioWatcher, DEFAULT_STUDIO_PORT, type ExecFileImpl, type ExecFileResult, type StudioServer, type StudioServerDeps, type StudioServerErrorCode, type StudioServerOptions, StudioServerStartError, type StudioWatcher, startStudioServer };
|