@hiai-gg/docsmint 0.3.3 → 0.3.5
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 +18 -0
- package/dist/backend/index.js +214020 -0
- package/dist/backend-launcher.d.ts +40 -0
- package/dist/backend-launcher.js +114 -0
- package/dist/frontend/{SettingsDialog-DiAyhzw0.js → SettingsDialog-D4pgFD0D.js} +444 -410
- package/dist/frontend/{ShareDialog-DaZf1raY.js → ShareDialog-Dzh7rV7J.js} +1 -1
- package/dist/frontend/components/settings.js +1 -1
- package/dist/frontend/components/sidebar.js +2 -2
- package/dist/frontend/dashboard.js +1 -1
- package/dist/frontend/frontend.css +1 -1
- package/dist/frontend/search-preferences-B1GdbdUc.js +17 -0
- package/dist/frontend/search.js +94 -90
- package/dist/storage-quota.d.ts +56 -0
- package/dist/storage-quota.js +91 -0
- package/package.json +13 -1
- package/packages/cli/src/index.ts +1 -1
- package/packages/mcp-server/src/index.ts +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Server-only launcher for the bundled DocsMint backend runtime. */
|
|
2
|
+
export type DocsmintBackendEnvironment = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
export type LaunchDocsmintBackendOptions = Readonly<{
|
|
4
|
+
cwd?: string;
|
|
5
|
+
env?: DocsmintBackendEnvironment;
|
|
6
|
+
healthUrl?: string;
|
|
7
|
+
startupTimeoutMs?: number;
|
|
8
|
+
pollIntervalMs?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}>;
|
|
11
|
+
export type DocsmintBackendProcess = Readonly<{
|
|
12
|
+
pid: number;
|
|
13
|
+
exited: Promise<number>;
|
|
14
|
+
kill(signal: "SIGTERM" | "SIGKILL"): void;
|
|
15
|
+
}>;
|
|
16
|
+
export type DocsmintBackendSpawnSpec = Readonly<{
|
|
17
|
+
command: readonly string[];
|
|
18
|
+
cwd?: string;
|
|
19
|
+
env: Readonly<Record<string, string>>;
|
|
20
|
+
}>;
|
|
21
|
+
export type DocsmintBackendLauncherRuntime = Readonly<{
|
|
22
|
+
executable: string;
|
|
23
|
+
launcherModuleUrl?: string | URL;
|
|
24
|
+
spawn(spec: DocsmintBackendSpawnSpec): DocsmintBackendProcess;
|
|
25
|
+
fetch(input: string, init?: RequestInit): Promise<Response>;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
28
|
+
}>;
|
|
29
|
+
export type DocsmintBackendHandle = Readonly<{
|
|
30
|
+
pid: number;
|
|
31
|
+
ready: Promise<void>;
|
|
32
|
+
exited: Promise<number>;
|
|
33
|
+
stop(): Promise<void>;
|
|
34
|
+
}>;
|
|
35
|
+
export type DocsmintBackendLauncher = Readonly<{
|
|
36
|
+
launch(options?: LaunchDocsmintBackendOptions): DocsmintBackendHandle;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function resolveDocsmintBackendEntrypoint(launcherModuleUrl?: string | URL): URL;
|
|
39
|
+
export declare function createDocsmintBackendLauncher(runtime: DocsmintBackendLauncherRuntime): DocsmintBackendLauncher;
|
|
40
|
+
export declare function launchDocsmintBackend(options?: LaunchDocsmintBackendOptions): DocsmintBackendHandle;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Server-only launcher for the bundled DocsMint backend runtime. */
|
|
2
|
+
const DEFAULT_STARTUP_TIMEOUT_MS = 30_000;
|
|
3
|
+
const DEFAULT_POLL_INTERVAL_MS = 200;
|
|
4
|
+
const DEFAULT_API_PORT = "50700";
|
|
5
|
+
function assertPositiveMilliseconds(value, name) {
|
|
6
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
7
|
+
throw new TypeError(`${name} must be a positive safe integer`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function immutableEnvironment(overrides = {}) {
|
|
11
|
+
const merged = {};
|
|
12
|
+
for (const [key, value] of Object.entries({ ...process.env, ...overrides })) {
|
|
13
|
+
if (typeof value === "string")
|
|
14
|
+
merged[key] = value;
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze(merged);
|
|
17
|
+
}
|
|
18
|
+
export function resolveDocsmintBackendEntrypoint(launcherModuleUrl = import.meta.url) {
|
|
19
|
+
return new URL("./backend/index.js", launcherModuleUrl);
|
|
20
|
+
}
|
|
21
|
+
function defaultRuntime() {
|
|
22
|
+
if (typeof Bun === "undefined") {
|
|
23
|
+
throw new Error("DocsMint backend launcher requires the Bun runtime");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
executable: Bun.argv[0] ?? "bun",
|
|
27
|
+
spawn(spec) {
|
|
28
|
+
const child = Bun.spawn({
|
|
29
|
+
cmd: [...spec.command],
|
|
30
|
+
...(spec.cwd ? { cwd: spec.cwd } : {}),
|
|
31
|
+
env: { ...spec.env },
|
|
32
|
+
stdout: "inherit",
|
|
33
|
+
stderr: "inherit",
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
pid: child.pid,
|
|
37
|
+
exited: child.exited,
|
|
38
|
+
kill(signal) {
|
|
39
|
+
child.kill(signal);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
fetch: (input, init) => fetch(input, init),
|
|
44
|
+
now: Date.now,
|
|
45
|
+
sleep: (milliseconds) => Bun.sleep(milliseconds),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createDocsmintBackendLauncher(runtime) {
|
|
49
|
+
const now = runtime.now ?? Date.now;
|
|
50
|
+
const sleep = runtime.sleep ?? ((milliseconds) => Bun.sleep(milliseconds));
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
launch(options = {}) {
|
|
53
|
+
const startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_STARTUP_TIMEOUT_MS;
|
|
54
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
55
|
+
assertPositiveMilliseconds(startupTimeoutMs, "startupTimeoutMs");
|
|
56
|
+
assertPositiveMilliseconds(pollIntervalMs, "pollIntervalMs");
|
|
57
|
+
if (options.signal?.aborted) {
|
|
58
|
+
throw new DOMException("Backend launch aborted", "AbortError");
|
|
59
|
+
}
|
|
60
|
+
const env = immutableEnvironment(options.env);
|
|
61
|
+
const port = env.API_PORT ?? DEFAULT_API_PORT;
|
|
62
|
+
const healthUrl = options.healthUrl ?? `http://127.0.0.1:${port}/api/health`;
|
|
63
|
+
const entrypoint = resolveDocsmintBackendEntrypoint(runtime.launcherModuleUrl ?? import.meta.url);
|
|
64
|
+
const child = runtime.spawn(Object.freeze({
|
|
65
|
+
command: Object.freeze([runtime.executable, entrypoint.pathname]),
|
|
66
|
+
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
67
|
+
env,
|
|
68
|
+
}));
|
|
69
|
+
let stopped = false;
|
|
70
|
+
const stop = async () => {
|
|
71
|
+
if (stopped)
|
|
72
|
+
return;
|
|
73
|
+
stopped = true;
|
|
74
|
+
child.kill("SIGTERM");
|
|
75
|
+
};
|
|
76
|
+
const ready = (async () => {
|
|
77
|
+
const deadline = now() + startupTimeoutMs;
|
|
78
|
+
try {
|
|
79
|
+
while (now() <= deadline) {
|
|
80
|
+
if (options.signal?.aborted) {
|
|
81
|
+
throw new DOMException("Backend launch aborted", "AbortError");
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const response = await runtime.fetch(healthUrl, {
|
|
85
|
+
signal: options.signal,
|
|
86
|
+
});
|
|
87
|
+
if (response.ok)
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (options.signal?.aborted)
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
await sleep(pollIntervalMs);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`DocsMint backend did not become ready within ${startupTimeoutMs}ms`);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
await stop();
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
})();
|
|
103
|
+
return Object.freeze({
|
|
104
|
+
pid: child.pid,
|
|
105
|
+
ready,
|
|
106
|
+
exited: child.exited,
|
|
107
|
+
stop,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function launchDocsmintBackend(options = {}) {
|
|
113
|
+
return createDocsmintBackendLauncher(defaultRuntime()).launch(options);
|
|
114
|
+
}
|