@voxd/client 0.1.0
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/client.d.ts +71 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +170 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { VoxHealth, VoxCapabilities, CreateJobOptions, JobAccepted, JobStatus, AlignmentResult, CompanionState, VoxDClientOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Browser client for the Vox Companion local transcription runtime.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { VoxDClient } from "@voxd/client";
|
|
8
|
+
*
|
|
9
|
+
* const vox = new VoxDClient();
|
|
10
|
+
*
|
|
11
|
+
* if (await vox.probe()) {
|
|
12
|
+
* const caps = await vox.capabilities();
|
|
13
|
+
* if (caps.features.alignment) {
|
|
14
|
+
* const result = await vox.align({
|
|
15
|
+
* source: { audioUrl: "https://example.com/clip.mp3" },
|
|
16
|
+
* });
|
|
17
|
+
* console.log(result.words);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class VoxDClient {
|
|
23
|
+
private readonly base;
|
|
24
|
+
private readonly probeTimeout;
|
|
25
|
+
private readonly pollInterval;
|
|
26
|
+
private _state;
|
|
27
|
+
constructor(options?: VoxDClientOptions);
|
|
28
|
+
/** Current connection state. */
|
|
29
|
+
get state(): CompanionState;
|
|
30
|
+
/** Whether the companion is connected and responding. */
|
|
31
|
+
get isConnected(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Probe the companion. Returns true if reachable.
|
|
34
|
+
* Safe to call on every page load — fails fast and silently.
|
|
35
|
+
*/
|
|
36
|
+
probe(): Promise<boolean>;
|
|
37
|
+
/** Fetch the health status. Throws if companion is unreachable. */
|
|
38
|
+
health(): Promise<VoxHealth>;
|
|
39
|
+
/** Fetch capabilities — features, backends, models. */
|
|
40
|
+
capabilities(): Promise<VoxCapabilities>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a job on the companion.
|
|
43
|
+
* Returns the accepted job with its ID.
|
|
44
|
+
*/
|
|
45
|
+
createJob(options: CreateJobOptions): Promise<JobAccepted>;
|
|
46
|
+
/** Poll a job's status by ID. */
|
|
47
|
+
getJob(jobId: string): Promise<JobStatus>;
|
|
48
|
+
/**
|
|
49
|
+
* Submit an alignment job and wait for the result.
|
|
50
|
+
* This is the high-level convenience method most apps should use.
|
|
51
|
+
*
|
|
52
|
+
* @returns The alignment result with word-level timestamps.
|
|
53
|
+
* @throws If the job fails or the companion is unreachable.
|
|
54
|
+
*/
|
|
55
|
+
align(options: Omit<CreateJobOptions, "type">): Promise<AlignmentResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Attempt to launch the companion via deep link.
|
|
58
|
+
* Useful when `probe()` returns false.
|
|
59
|
+
*/
|
|
60
|
+
launch(): void;
|
|
61
|
+
/** Open the companion settings window. */
|
|
62
|
+
openSettings(): void;
|
|
63
|
+
private waitForJob;
|
|
64
|
+
private fetch;
|
|
65
|
+
}
|
|
66
|
+
/** Error thrown by the VoxD client. */
|
|
67
|
+
export declare class VoxDError extends Error {
|
|
68
|
+
readonly code: "network_error" | "http_error" | "job_failed" | "no_result" | "timeout";
|
|
69
|
+
constructor(message: string, code: "network_error" | "http_error" | "job_failed" | "no_result" | "timeout");
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src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AAe,GACf,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,SAAS;CAKhB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const DEFAULT_PORT = 43115;
|
|
2
|
+
const DEFAULT_PROBE_TIMEOUT = 2000;
|
|
3
|
+
const DEFAULT_POLL_INTERVAL = 500;
|
|
4
|
+
/**
|
|
5
|
+
* Browser client for the Vox Companion local transcription runtime.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { VoxDClient } from "@voxd/client";
|
|
10
|
+
*
|
|
11
|
+
* const vox = new VoxDClient();
|
|
12
|
+
*
|
|
13
|
+
* if (await vox.probe()) {
|
|
14
|
+
* const caps = await vox.capabilities();
|
|
15
|
+
* if (caps.features.alignment) {
|
|
16
|
+
* const result = await vox.align({
|
|
17
|
+
* source: { audioUrl: "https://example.com/clip.mp3" },
|
|
18
|
+
* });
|
|
19
|
+
* console.log(result.words);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class VoxDClient {
|
|
25
|
+
base;
|
|
26
|
+
probeTimeout;
|
|
27
|
+
pollInterval;
|
|
28
|
+
_state = "unknown";
|
|
29
|
+
constructor(options) {
|
|
30
|
+
const port = options?.port ?? DEFAULT_PORT;
|
|
31
|
+
this.base = `http://127.0.0.1:${port}`;
|
|
32
|
+
this.probeTimeout = options?.probeTimeout ?? DEFAULT_PROBE_TIMEOUT;
|
|
33
|
+
this.pollInterval = options?.pollInterval ?? DEFAULT_POLL_INTERVAL;
|
|
34
|
+
}
|
|
35
|
+
/** Current connection state. */
|
|
36
|
+
get state() {
|
|
37
|
+
return this._state;
|
|
38
|
+
}
|
|
39
|
+
/** Whether the companion is connected and responding. */
|
|
40
|
+
get isConnected() {
|
|
41
|
+
return this._state === "connected";
|
|
42
|
+
}
|
|
43
|
+
// ── Discovery ────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* Probe the companion. Returns true if reachable.
|
|
46
|
+
* Safe to call on every page load — fails fast and silently.
|
|
47
|
+
*/
|
|
48
|
+
async probe() {
|
|
49
|
+
this._state = "probing";
|
|
50
|
+
try {
|
|
51
|
+
const res = await this.fetch("/health", { timeout: this.probeTimeout });
|
|
52
|
+
const data = await res.json();
|
|
53
|
+
this._state = data.ok ? "connected" : "unavailable";
|
|
54
|
+
return data.ok;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
this._state = "unavailable";
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Fetch the health status. Throws if companion is unreachable. */
|
|
62
|
+
async health() {
|
|
63
|
+
const res = await this.fetch("/health");
|
|
64
|
+
return res.json();
|
|
65
|
+
}
|
|
66
|
+
/** Fetch capabilities — features, backends, models. */
|
|
67
|
+
async capabilities() {
|
|
68
|
+
const res = await this.fetch("/capabilities");
|
|
69
|
+
return res.json();
|
|
70
|
+
}
|
|
71
|
+
// ── Jobs ─────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Create a job on the companion.
|
|
74
|
+
* Returns the accepted job with its ID.
|
|
75
|
+
*/
|
|
76
|
+
async createJob(options) {
|
|
77
|
+
const res = await this.fetch("/jobs", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify(options),
|
|
81
|
+
});
|
|
82
|
+
return res.json();
|
|
83
|
+
}
|
|
84
|
+
/** Poll a job's status by ID. */
|
|
85
|
+
async getJob(jobId) {
|
|
86
|
+
const res = await this.fetch(`/jobs/${jobId}`);
|
|
87
|
+
return res.json();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Submit an alignment job and wait for the result.
|
|
91
|
+
* This is the high-level convenience method most apps should use.
|
|
92
|
+
*
|
|
93
|
+
* @returns The alignment result with word-level timestamps.
|
|
94
|
+
* @throws If the job fails or the companion is unreachable.
|
|
95
|
+
*/
|
|
96
|
+
async align(options) {
|
|
97
|
+
const { jobId } = await this.createJob({ ...options, type: "alignment" });
|
|
98
|
+
return this.waitForJob(jobId);
|
|
99
|
+
}
|
|
100
|
+
// ── Deep links ───────────────────────────────────────────
|
|
101
|
+
/**
|
|
102
|
+
* Attempt to launch the companion via deep link.
|
|
103
|
+
* Useful when `probe()` returns false.
|
|
104
|
+
*/
|
|
105
|
+
launch() {
|
|
106
|
+
window.location.href = "vox://launch";
|
|
107
|
+
}
|
|
108
|
+
/** Open the companion settings window. */
|
|
109
|
+
openSettings() {
|
|
110
|
+
window.location.href = "vox://settings";
|
|
111
|
+
}
|
|
112
|
+
// ── Internals ────────────────────────────────────────────
|
|
113
|
+
async waitForJob(jobId) {
|
|
114
|
+
const maxAttempts = 600; // 5 minutes at 500ms
|
|
115
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
116
|
+
const status = await this.getJob(jobId);
|
|
117
|
+
if (status.status === "completed") {
|
|
118
|
+
if (!status.result?.alignment) {
|
|
119
|
+
throw new VoxDError("Job completed but no alignment result", "no_result");
|
|
120
|
+
}
|
|
121
|
+
return status.result.alignment;
|
|
122
|
+
}
|
|
123
|
+
if (status.status === "failed") {
|
|
124
|
+
throw new VoxDError(status.error ?? "Job failed", "job_failed");
|
|
125
|
+
}
|
|
126
|
+
await sleep(this.pollInterval);
|
|
127
|
+
}
|
|
128
|
+
throw new VoxDError("Job timed out", "timeout");
|
|
129
|
+
}
|
|
130
|
+
async fetch(path, init) {
|
|
131
|
+
const { timeout, ...fetchInit } = init ?? {};
|
|
132
|
+
const controller = new AbortController();
|
|
133
|
+
const timer = timeout
|
|
134
|
+
? setTimeout(() => controller.abort(), timeout)
|
|
135
|
+
: undefined;
|
|
136
|
+
try {
|
|
137
|
+
const res = await globalThis.fetch(`${this.base}${path}`, {
|
|
138
|
+
...fetchInit,
|
|
139
|
+
signal: controller.signal,
|
|
140
|
+
});
|
|
141
|
+
if (!res.ok) {
|
|
142
|
+
const body = await res.text().catch(() => "");
|
|
143
|
+
throw new VoxDError(`${res.status} ${res.statusText}: ${body}`, "http_error");
|
|
144
|
+
}
|
|
145
|
+
return res;
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (err instanceof VoxDError)
|
|
149
|
+
throw err;
|
|
150
|
+
throw new VoxDError(err instanceof Error ? err.message : "Companion unreachable", "network_error");
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
if (timer)
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Error thrown by the VoxD client. */
|
|
159
|
+
export class VoxDError extends Error {
|
|
160
|
+
code;
|
|
161
|
+
constructor(message, code) {
|
|
162
|
+
super(message);
|
|
163
|
+
this.code = code;
|
|
164
|
+
this.name = "VoxDError";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function sleep(ms) {
|
|
168
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAWA,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,UAAU;IACJ,IAAI,CAAS;IACb,YAAY,CAAS;IACrB,YAAY,CAAS;IAC9B,MAAM,GAAmB,SAAS,CAAC;IAE3C,YAAY,OAA2B;QACrC,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,YAAY,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,oBAAoB,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,qBAAqB,CAAC;QACnE,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AAC;YACJ,CAAC;YAED,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,SAAS;gBAAE,MAAM,GAAG,CAAC;YACxC,MAAM,IAAI,SAAS,CACjB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,EAC5D,eAAe,CAChB,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF;AAED,uCAAuC;AACvC,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGhB;IAFlB,YACE,OAAe,EACC,IAKH;QAEb,KAAK,CAAC,OAAO,CAAC,CAAC;QAPC,SAAI,GAAJ,IAAI,CAKP;QAGb,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { VoxDClient, VoxDError } from "./client.js";
|
|
2
|
+
export type { VoxHealth, VoxCapabilities, CreateJobOptions, JobAccepted, JobStatus, JobSource, JobMetadata, JobStage, AlignedWord, AlignmentResult, CompanionState, VoxDClientOptions, } from "./types.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** Health check response from the companion. */
|
|
2
|
+
export interface VoxHealth {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
service: string;
|
|
5
|
+
version: string;
|
|
6
|
+
port: number;
|
|
7
|
+
}
|
|
8
|
+
/** Companion capability report. */
|
|
9
|
+
export interface VoxCapabilities {
|
|
10
|
+
running: boolean;
|
|
11
|
+
version: string;
|
|
12
|
+
features: {
|
|
13
|
+
alignment?: boolean;
|
|
14
|
+
local_asr?: boolean;
|
|
15
|
+
streaming_progress?: boolean;
|
|
16
|
+
};
|
|
17
|
+
backends: {
|
|
18
|
+
parakeet?: boolean;
|
|
19
|
+
mlx?: boolean;
|
|
20
|
+
ane?: boolean;
|
|
21
|
+
};
|
|
22
|
+
daemon?: Record<string, unknown>;
|
|
23
|
+
models?: unknown[];
|
|
24
|
+
}
|
|
25
|
+
/** Audio source for an alignment job. */
|
|
26
|
+
export interface JobSource {
|
|
27
|
+
audioUrl: string;
|
|
28
|
+
format?: "mp3" | "wav" | "aac" | "opus";
|
|
29
|
+
}
|
|
30
|
+
/** Metadata attached to a job for downstream use. */
|
|
31
|
+
export interface JobMetadata {
|
|
32
|
+
documentId?: string;
|
|
33
|
+
pageNumber?: number;
|
|
34
|
+
paragraphId?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** Options for creating an alignment job. */
|
|
38
|
+
export interface CreateJobOptions {
|
|
39
|
+
type: "alignment";
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
source: JobSource;
|
|
42
|
+
metadata?: JobMetadata;
|
|
43
|
+
}
|
|
44
|
+
/** Accepted job response. */
|
|
45
|
+
export interface JobAccepted {
|
|
46
|
+
jobId: string;
|
|
47
|
+
accepted: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** Job status stages. */
|
|
50
|
+
export type JobStage = "accepted" | "fetching_audio" | "preparing" | "transcribing" | "aligning" | "finalizing" | "processing" | "completed" | "failed";
|
|
51
|
+
/** Word-level alignment timing. */
|
|
52
|
+
export interface AlignedWord {
|
|
53
|
+
word: string;
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
}
|
|
57
|
+
/** Alignment result payload. */
|
|
58
|
+
export interface AlignmentResult {
|
|
59
|
+
words: AlignedWord[];
|
|
60
|
+
text?: string;
|
|
61
|
+
durationMs: number;
|
|
62
|
+
}
|
|
63
|
+
/** Full job status response. */
|
|
64
|
+
export interface JobStatus {
|
|
65
|
+
jobId: string;
|
|
66
|
+
type: string;
|
|
67
|
+
status: JobStage;
|
|
68
|
+
result?: {
|
|
69
|
+
alignment?: AlignmentResult;
|
|
70
|
+
};
|
|
71
|
+
error?: string;
|
|
72
|
+
}
|
|
73
|
+
/** Companion connection state. */
|
|
74
|
+
export type CompanionState = "unknown" | "probing" | "connected" | "unavailable";
|
|
75
|
+
/** Options for the VoxD client. */
|
|
76
|
+
export interface VoxDClientOptions {
|
|
77
|
+
/** Companion bridge port. Default: 43115 */
|
|
78
|
+
port?: number;
|
|
79
|
+
/** Probe timeout in ms. Default: 2000 */
|
|
80
|
+
probeTimeout?: number;
|
|
81
|
+
/** Polling interval in ms when waiting for a job. Default: 500 */
|
|
82
|
+
pollInterval?: number;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,M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ACd,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,yBAAyB;AACzB,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,gBAAgB,GAChB,WAAW,GACX,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,QAAQ,CAAC;AAEb,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gCAAgC;AAChC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,gCAAgC;AAChC,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,eAAe,CAAC;KAC7B,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kCAAkC;AAClC,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,SAAS,GACT,WAAW,GACX,aAAa,CAAC;AAElB,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voxd/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Browser client for the Vox Companion local transcription runtime.",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/arach/vox.git",
|
|
24
|
+
"directory": "packages/web-client"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"prepublishOnly": "bun run build"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.9.2"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"vox",
|
|
35
|
+
"transcription",
|
|
36
|
+
"local",
|
|
37
|
+
"asr",
|
|
38
|
+
"speech-to-text",
|
|
39
|
+
"companion"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|