@vocalstack/sanity 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VocalStack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # @vocalstack/sanity
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ VocalStack for [Sanity](https://www.sanity.io) Studio 3 and later: a **Transcribe** button next to every audio file. The transcript is saved on the document as text plus timed sentences.
4
+
5
+ Read more about the [VocalStack transcription plugin for Sanity](https://vocalstack.com/sanity-transcription-plugin/) on the [VocalStack website](https://vocalstack.com/).
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm i @vocalstack/sanity
11
+ ```
12
+
13
+ VocalStack API keys are for servers: the API refuses a key sent from a web page. So the plugin has two halves, the Studio plugin and a small server handler that holds the key.
14
+
15
+ **1. The handler.** A Web-standard `(Request) => Promise<Response>`. In a Next.js app (most Sanity sites have one):
16
+
17
+ ```ts
18
+ // app/api/vocalstack/[...path]/route.ts
19
+ import { createVocalStackHandler } from '@vocalstack/sanity/server'
20
+
21
+ const handler = createVocalStackHandler({
22
+ apiKey: process.env.VOCALSTACK_API_KEY, // the default; a vs_key_… key with Read and Write
23
+ sanity: {
24
+ projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
25
+ dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
26
+ token: process.env.SANITY_API_READ_TOKEN!, // a Viewer token is enough
27
+ },
28
+ })
29
+
30
+ export { handler as GET, handler as OPTIONS, handler as POST }
31
+ ```
32
+
33
+ Any other host works the same way: Remix, Hono, Bun, Deno, Cloudflare Workers, a Node server with a Fetch adapter. The handler matches the end of the path, so mount it under any prefix.
34
+
35
+ **2. The Studio plugin.**
36
+
37
+ ```ts
38
+ // sanity.config.ts
39
+ import { vocalstack } from '@vocalstack/sanity'
40
+
41
+ export default defineConfig({
42
+ // …
43
+ plugins: [
44
+ vocalstack({
45
+ handlerURL: 'https://www.example.com/api/vocalstack', // or '/api/vocalstack' for a Studio embedded in the same Next.js app
46
+ }),
47
+ ],
48
+ })
49
+ ```
50
+
51
+ Then add a transcript field next to the audio:
52
+
53
+ ```ts
54
+ defineType({
55
+ name: 'episode',
56
+ type: 'document',
57
+ fields: [
58
+ defineField({ name: 'title', type: 'string' }),
59
+ defineField({ name: 'audio', type: 'file', options: { accept: 'audio/*' } }),
60
+ defineField({ name: 'transcript', type: 'vocalstack.transcript' }),
61
+ ],
62
+ })
63
+ ```
64
+
65
+ ## What it adds
66
+
67
+ - **A `vocalstack.transcript` field type**, to put next to a `file` field (at the top level of a document, or inside an object). Its input has:
68
+ - the **workspace** the Studio is connected to, with its icon, at the top of the field (see [Workspace](#workspace));
69
+ - a **Transcribe** button, shown when the sibling file is `audio/*`. It shows progress and survives a reload mid-job, because `recordingId` and `status` are saved on the document. **Stop** ends a job you no longer want: the field goes back to how it was (an earlier transcript stays), and VocalStack keeps what it transcribed before the stop.
70
+ - the stored value:
71
+ - `transcript`: text you can edit; paragraphs break on a speaker change or a pause.
72
+ - `sentences`: `[{ start, end, speaker, text }]` in seconds.
73
+ - `status` (`idle`, `processing`, `done` or `failed`), `language`, `error`, `recordingId`, `transcriptionId` and `transcribedAt`.
74
+ - **A "Transcribe audio" document action** on every document type with a transcript field. It starts a job for each transcript field next to an audio file; the field follows the job from there.
75
+ - **The handler** (`@vocalstack/sanity/server`): `GET …/connection` (`{ connected, account, workspace: { id, name, personal, iconUrl } }`), `POST …/transcriptions`, `GET …/recordings/:id/job` and `POST …/recordings/:id/stop`.
76
+
77
+ Like any edit in the Studio, the transcript lands in the draft; publish to make it public. Transcripts are plain fields, so GROQ reads them like any other:
78
+
79
+ ```groq
80
+ *[_type == "episode"]{ title, "text": transcript.transcript, "captions": transcript.sentences }
81
+ ```
82
+
83
+ ## Options
84
+
85
+ The Studio plugin, `vocalstack({ … })`:
86
+
87
+ | Option | Default | |
88
+ |---|---|---|
89
+ | `handlerURL` | required | Where the handler is mounted. The Studio calls only this URL. |
90
+
91
+ A transcript field, `options: { … }`:
92
+
93
+ | Option | Default | |
94
+ |---|---|---|
95
+ | `audioField` | the first sibling `file` field holding `audio/*` | The name of the sibling file field to transcribe. |
96
+
97
+ The handler, `createVocalStackHandler({ … })`:
98
+
99
+ | Option | Default | |
100
+ |---|---|---|
101
+ | `apiKey` | `process.env.VOCALSTACK_API_KEY` | A `vs_key_…` key with Read and Write. |
102
+ | `sanity` | required | `{ projectId, dataset, token, apiVersion?, apiHost?, useProjectHostname? }`: the Studio's dataset, and a token that can read it. `apiHost` and `useProjectHostname` work as in `@sanity/client`, for a custom API domain. |
103
+ | `spokenLanguage` | auto-detect | A Whisper language code (`en`, `ro`, …). |
104
+ | `fileURL` | the asset's URL on Sanity's CDN | `(asset) => string`: the audio's address. Return a signed URL if your assets are private. |
105
+ | `allowedOrigins` | any | The Studio origins allowed to call the handler (CORS), e.g. `['https://example.sanity.studio']`. |
106
+ | `apiURL` | `https://api.vocalstack.com` | |
107
+
108
+ **How the audio reaches VocalStack.** The Studio sends the handler the file's asset id; the handler reads the asset from your dataset, checks that it is `audio/*`, and VocalStack fetches it from Sanity's CDN (`POST /v1/transcriptions { url }`). VocalStack does not fetch loopback or private addresses, so for those the handler reads the file and uploads it. The job runs on VocalStack, and the Studio polls the handler every 3 s. The key's workspace is billed per second, with a 5-minute minimum per transcription.
109
+
110
+ ## How the handler knows the caller
111
+
112
+ The handler only answers someone signed in to the Studio with permission to edit the dataset:
113
+
114
+ 1. The Studio makes a random secret and, with the editor's own Sanity login, creates a document `vocalstack-session.<sha256 of the secret>` (type `vocalstack.session`).
115
+ 2. Every call to the handler carries `Authorization: Bearer <secret>`. The handler hashes it and looks the document up with its own token; a session is good for 12 hours from the document's `_updatedAt`.
116
+
117
+ Only someone who can write to the dataset can create a session. The id has a dot in it, so Sanity never serves it to unauthenticated requests, even from a public dataset; project members who can read the dataset see the hash, never the secret. Expired sessions are swept by the Studio. The handler keeps no cookies, so CORS from any origin is safe; `allowedOrigins` narrows it further.
118
+
119
+ The VocalStack key never reaches a browser: it lives in the handler's environment only. Anyone who can edit the dataset can start, follow and stop transcriptions in that key's workspace.
120
+
121
+ ## Workspace
122
+
123
+ A VocalStack API key belongs to one workspace: every transcription the plugin makes lands in that workspace and is billed there. The transcript field shows which one, as the VocalStack Dashboard does: **Workspace**, its icon (its own picture, a person for the personal workspace, or its initials on its colour) and its name. The handler reads it from `GET /v1/me` and keeps it for five minutes, so a new name or icon shows up in the Studio without a redeploy.
124
+
125
+ There is no workspace switch in the Studio, because the key lives in the handler's environment. To use another workspace, set `VOCALSTACK_API_KEY` where the handler runs to a key made in that workspace: in the [Dashboard](https://app.vocalstack.com), switch to the workspace, then Developers → API keys. **Change**, next to the workspace's name, says the same.
126
+
127
+ After the key moves to another workspace, transcripts already saved on documents stay as they are. A job that was still running under the old key cannot be followed any more: its field says that the transcription is not in the connected workspace and offers **Transcribe again**, which makes a new one in the new workspace.
128
+
129
+ ## Testing
130
+
131
+ `pnpm test` builds `dist/` and runs the unit tests in `test/` (the workspace mark, the handler's `…/connection` answer). `e2e/run.sh` runs a real Studio on a fake Content Lake against the handler and a real VocalStack, in Chromium; see [e2e/README.md](e2e/README.md).
132
+
133
+ ## One-click connect
134
+
135
+ Not in this version. The handler has no storage of its own to keep a connected key in, and the Studio cannot redeem a connect code (the API refuses it from a web page), so the key goes in `VOCALSTACK_API_KEY`. Create one with Read and Write permissions under [Developers → API keys](https://app.vocalstack.com/developers/keys).
@@ -0,0 +1,13 @@
1
+ import type { DocumentActionComponent, SchemaType } from 'sanity';
2
+ import type { VocalStackPluginOptions, VocalStackTranscript } from './types.js';
3
+ type Found = {
4
+ path: string[];
5
+ siblings: Record<string, unknown> | undefined;
6
+ value: VocalStackTranscript | undefined;
7
+ audioField?: string;
8
+ };
9
+ /** Transcript fields in a document: top level and inside object fields (not arrays). */
10
+ export declare function transcriptFields(type: SchemaType | undefined, doc?: Record<string, unknown>, path?: string[], depth?: number): Found[];
11
+ /** "Transcribe audio": start a job for every transcript field next to an audio file. The field's input follows it. */
12
+ export declare const transcribeAction: (options: VocalStackPluginOptions) => DocumentActionComponent;
13
+ export {};
package/dist/action.js ADDED
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, Text } from '@sanity/ui';
3
+ import { useState } from 'react';
4
+ import { useDocumentOperation, useSchema } from 'sanity';
5
+ import { findAudio, jobName, siblingFileRefs, TRANSCRIPT_TYPE } from './core.js';
6
+ import { useHandler } from './handler.js';
7
+ import { Mark } from './components/Brand.js';
8
+ const isTranscript = (type) => {
9
+ for (let t = type; t; t = t.type)
10
+ if (t.name === TRANSCRIPT_TYPE)
11
+ return true;
12
+ return false;
13
+ };
14
+ /** Transcript fields in a document: top level and inside object fields (not arrays). */
15
+ export function transcriptFields(type, doc, path = [], depth = 0) {
16
+ if (!type || type.jsonType !== 'object' || depth > 4)
17
+ return [];
18
+ return type.fields.flatMap((field) => {
19
+ const value = doc?.[field.name];
20
+ if (isTranscript(field.type)) {
21
+ const audioField = field.type.options?.audioField;
22
+ return [{ audioField, path: [...path, field.name], siblings: doc, value: value }];
23
+ }
24
+ return field.type.jsonType === 'object' ? transcriptFields(field.type, value, [...path, field.name], depth + 1) : [];
25
+ });
26
+ }
27
+ /** "Transcribe audio": start a job for every transcript field next to an audio file. The field's input follows it. */
28
+ export const transcribeAction = (options) => {
29
+ const TranscribeAudioAction = (props) => {
30
+ const schema = useSchema();
31
+ const { call, client } = useHandler(options);
32
+ const { patch } = useDocumentOperation(props.id, props.type);
33
+ const [running, setRunning] = useState(false);
34
+ // What happened, in a popover under the action (Sanity UI moved its toasts between versions).
35
+ const [message, setMessage] = useState();
36
+ const doc = (props.draft ?? props.published);
37
+ const targets = transcriptFields(schema.get(props.type), doc ?? undefined).filter((t) => siblingFileRefs(t.siblings, t.audioField).length);
38
+ const idle = targets.filter((t) => t.value?.status !== 'processing');
39
+ return {
40
+ disabled: running || !doc || !idle.length || Boolean(patch.disabled),
41
+ icon: () => _jsx(Mark, { height: 16 }),
42
+ label: running ? 'Transcribing…' : 'Transcribe audio',
43
+ dialog: message
44
+ ? {
45
+ type: 'popover',
46
+ content: (_jsx(Box, { padding: 3, style: { maxWidth: 320 }, children: _jsx(Text, { size: 1, children: message }) })),
47
+ onClose: () => {
48
+ setMessage(undefined);
49
+ props.onComplete();
50
+ },
51
+ }
52
+ : undefined,
53
+ title: !targets.length ? 'Add an audio file first.' : !idle.length ? 'Already transcribing.' : undefined,
54
+ onHandle: async () => {
55
+ if (!doc)
56
+ return;
57
+ setRunning(true);
58
+ let started = 0;
59
+ try {
60
+ for (const t of idle) {
61
+ const asset = await findAudio(client, siblingFileRefs(t.siblings, t.audioField));
62
+ if (!asset)
63
+ continue;
64
+ const at = t.path.join('.');
65
+ const body = { assetId: asset._id, documentId: doc._id, fieldPath: at, name: jobName(doc, asset) };
66
+ const fields = await call('/transcriptions', { body, method: 'POST' });
67
+ patch.execute([
68
+ { setIfMissing: { [at]: { _type: TRANSCRIPT_TYPE } } },
69
+ { set: { [`${at}.status`]: fields.status, [`${at}.recordingId`]: fields.recordingId, [`${at}.transcriptionId`]: fields.transcriptionId } },
70
+ { unset: [`${at}.error`] },
71
+ ]);
72
+ started++;
73
+ }
74
+ setMessage(started ? 'Transcribing. The transcript appears in the field when it is ready.' : 'Only audio files can be transcribed.');
75
+ }
76
+ catch (err) {
77
+ setMessage(err.message);
78
+ }
79
+ finally {
80
+ setRunning(false);
81
+ }
82
+ },
83
+ };
84
+ };
85
+ return TranscribeAudioAction;
86
+ };
package/dist/api.d.ts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The handful of VocalStack API calls the plugin needs, on plain fetch (the
3
+ * SDK is not on npm yet). Contract: https://api.vocalstack.com/v1/openapi.json
4
+ */
5
+ import type { ConnectionWorkspace } from './wire.js';
6
+ export declare const DEFAULT_API_URL = "https://api.vocalstack.com";
7
+ /** Sent as the User-Agent of every call to VocalStack (they run in the
8
+ * handler, on the server): VocalStack lists the transcriptions it makes
9
+ * as made in Sanity. Keep it to package.json's version. */
10
+ export declare const PLUGIN_VERSION = "0.2.0";
11
+ export declare const DEFAULT_DASHBOARD_URL = "https://app.vocalstack.com";
12
+ export type JobState = 'cropping' | 'done' | 'failed' | 'fetching' | 'queued' | 'stopped' | 'transcribing';
13
+ export type Job = {
14
+ error?: null | string;
15
+ /** Why a failed job failed; `stopped` when its owner stopped it. */
16
+ errorCode?: null | string;
17
+ progress: {
18
+ pct: number;
19
+ phase?: null | string;
20
+ phasePct?: null | number;
21
+ processedS?: number;
22
+ totalS?: null | number;
23
+ };
24
+ recordingId: string;
25
+ state: JobState;
26
+ transcriptionId: string;
27
+ };
28
+ export type Transcription = {
29
+ id: string;
30
+ job?: Job | null;
31
+ name: string;
32
+ };
33
+ export type Transcript = {
34
+ lang?: null | string;
35
+ segments: {
36
+ end: number;
37
+ seq: number;
38
+ start: number;
39
+ suppressed?: boolean;
40
+ words?: {
41
+ end: number;
42
+ start: number;
43
+ text: string;
44
+ }[] | null;
45
+ }[];
46
+ sentences: {
47
+ end: number;
48
+ language?: null | string;
49
+ sentenceId: number;
50
+ speaker: number;
51
+ start: number;
52
+ suppressed?: boolean;
53
+ text: string;
54
+ }[];
55
+ };
56
+ export declare class VocalStackAPIError extends Error {
57
+ code: string;
58
+ status: number;
59
+ constructor(status: number, code: string, message: string);
60
+ }
61
+ export declare class VocalStackAPI {
62
+ private apiKey;
63
+ private baseURL;
64
+ constructor(apiKey: string, baseURL?: string);
65
+ private request;
66
+ me(): Promise<Record<string, unknown>>;
67
+ transcribeURL(url: string, opts: {
68
+ idempotencyKey: string;
69
+ name: string;
70
+ spokenLanguage?: string;
71
+ }): Promise<Transcription>;
72
+ transcribeFile(file: Blob, fileName: string, opts: {
73
+ idempotencyKey: string;
74
+ name: string;
75
+ spokenLanguage?: string;
76
+ }): Promise<Transcription>;
77
+ job(recordingId: string): Promise<Job>;
78
+ /** Stop a job before it is done. Its job fails with `stopped`; what was transcribed so far stays in VocalStack. */
79
+ stop(recordingId: string, reason?: string): Promise<unknown>;
80
+ transcript(recordingId: string): Promise<Transcript>;
81
+ }
82
+ /** A short label for the connected account, from whatever `/v1/me` carries. */
83
+ export declare function accountLabel(me: Record<string, unknown>): string | undefined;
84
+ /**
85
+ * The workspace the key belongs to, from `/v1/me` (`workspace: { id, name, personal,
86
+ * iconUrl }`), with the icon's link made absolute against the API's address. Undefined
87
+ * when the API does not say (an older VocalStack).
88
+ */
89
+ export declare function workspaceOf(me: Record<string, unknown>, baseURL?: string): ConnectionWorkspace | undefined;
package/dist/api.js ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The handful of VocalStack API calls the plugin needs, on plain fetch (the
3
+ * SDK is not on npm yet). Contract: https://api.vocalstack.com/v1/openapi.json
4
+ */
5
+ export const DEFAULT_API_URL = 'https://api.vocalstack.com';
6
+ /** Sent as the User-Agent of every call to VocalStack (they run in the
7
+ * handler, on the server): VocalStack lists the transcriptions it makes
8
+ * as made in Sanity. Keep it to package.json's version. */
9
+ export const PLUGIN_VERSION = '0.2.0';
10
+ export const DEFAULT_DASHBOARD_URL = 'https://app.vocalstack.com';
11
+ export class VocalStackAPIError extends Error {
12
+ code;
13
+ status;
14
+ constructor(status, code, message) {
15
+ super(message);
16
+ this.code = code;
17
+ this.status = status;
18
+ }
19
+ }
20
+ export class VocalStackAPI {
21
+ apiKey;
22
+ baseURL;
23
+ constructor(apiKey, baseURL = DEFAULT_API_URL) {
24
+ this.apiKey = apiKey;
25
+ this.baseURL = baseURL;
26
+ }
27
+ async request(method, path, body, headers = {}) {
28
+ const init = { headers: { accept: 'application/json', authorization: `Bearer ${this.apiKey}`, 'user-agent': `VocalStack-Sanity/${PLUGIN_VERSION}`, ...headers }, method };
29
+ if (body instanceof FormData)
30
+ init.body = body;
31
+ else if (body !== undefined) {
32
+ init.body = JSON.stringify(body);
33
+ init.headers['content-type'] = 'application/json';
34
+ }
35
+ const res = await fetch(`${this.baseURL}${path}`, init);
36
+ const data = await res.json().catch(() => undefined);
37
+ if (!res.ok) {
38
+ const err = (data?.error ?? data);
39
+ throw new VocalStackAPIError(res.status, err?.code ?? 'http_error', err?.message ?? `VocalStack answered ${res.status}`);
40
+ }
41
+ return data;
42
+ }
43
+ me() {
44
+ return this.request('GET', '/v1/me');
45
+ }
46
+ transcribeURL(url, opts) {
47
+ return this.request('POST', '/v1/transcriptions', { name: opts.name, settings: opts.spokenLanguage ? { spokenLanguage: opts.spokenLanguage } : undefined, url }, { 'idempotency-key': opts.idempotencyKey });
48
+ }
49
+ transcribeFile(file, fileName, opts) {
50
+ const form = new FormData();
51
+ form.append('options', JSON.stringify({ name: opts.name, settings: opts.spokenLanguage ? { spokenLanguage: opts.spokenLanguage } : undefined }));
52
+ form.append('file', file, fileName);
53
+ return this.request('POST', '/v1/transcriptions', form, { 'idempotency-key': opts.idempotencyKey });
54
+ }
55
+ job(recordingId) {
56
+ return this.request('GET', `/v1/recordings/${encodeURIComponent(recordingId)}/job`);
57
+ }
58
+ /** Stop a job before it is done. Its job fails with `stopped`; what was transcribed so far stays in VocalStack. */
59
+ stop(recordingId, reason) {
60
+ return this.request('POST', `/v1/recordings/${encodeURIComponent(recordingId)}/stop`, { reason: reason ?? null });
61
+ }
62
+ transcript(recordingId) {
63
+ return this.request('GET', `/v1/recordings/${encodeURIComponent(recordingId)}/transcript`);
64
+ }
65
+ }
66
+ /** A short label for the connected account, from whatever `/v1/me` carries. */
67
+ export function accountLabel(me) {
68
+ const pick = (o, ...keys) => {
69
+ if (!o || typeof o !== 'object')
70
+ return undefined;
71
+ for (const k of keys) {
72
+ const v = o[k];
73
+ if (typeof v === 'string' && v)
74
+ return v;
75
+ }
76
+ };
77
+ return pick(me.principal, 'name', 'displayName') ?? pick(me.organization, 'name') ?? pick(me.user, 'email', 'name') ?? pick(me, 'email', 'name', 'displayName');
78
+ }
79
+ /**
80
+ * The workspace the key belongs to, from `/v1/me` (`workspace: { id, name, personal,
81
+ * iconUrl }`), with the icon's link made absolute against the API's address. Undefined
82
+ * when the API does not say (an older VocalStack).
83
+ */
84
+ export function workspaceOf(me, baseURL = DEFAULT_API_URL) {
85
+ const w = me.workspace;
86
+ if (!w || typeof w !== 'object' || typeof w.id !== 'string' || !w.id || typeof w.name !== 'string' || !w.name.trim())
87
+ return undefined;
88
+ let iconUrl = null;
89
+ if (typeof w.iconUrl === 'string' && w.iconUrl) {
90
+ try {
91
+ const url = new URL(w.iconUrl, baseURL);
92
+ if (url.protocol === 'https:' || url.protocol === 'http:')
93
+ iconUrl = url.href;
94
+ }
95
+ catch { }
96
+ }
97
+ return { iconUrl, id: w.id, name: w.name, personal: w.personal === true };
98
+ }
@@ -0,0 +1,12 @@
1
+ /** Whether the Studio is in its dark scheme. */
2
+ export declare function useDark(): boolean;
3
+ /** The accent for progress bars, following the Studio's scheme. */
4
+ export declare const useAccent: () => "#245B8F" | "#55ABE5";
5
+ /** The VocalStack wordmark. */
6
+ export declare const Logo: React.FC<{
7
+ height?: number;
8
+ }>;
9
+ /** The V on its own, for small spaces (the tool's icon). */
10
+ export declare const Mark: React.FC<{
11
+ height?: number;
12
+ }>;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRootTheme } from '@sanity/ui';
3
+ import { BRAND, LOGO_DARK, LOGO_LIGHT, MARK_DARK, MARK_LIGHT } from './brandAssets.js';
4
+ /** Whether the Studio is in its dark scheme. */
5
+ export function useDark() {
6
+ try {
7
+ return useRootTheme().scheme === 'dark';
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ }
13
+ /** The accent for progress bars, following the Studio's scheme. */
14
+ export const useAccent = () => (useDark() ? BRAND.lightBlue : BRAND.blue);
15
+ /** The artwork has no width or height of its own: size it by the wrapper's height. */
16
+ const sized = (svg) => svg.replace('<svg ', '<svg style="height:100%;width:auto" ');
17
+ const Art = ({ dark, height, label, light }) => (_jsx("span", { "aria-label": label, dangerouslySetInnerHTML: { __html: sized(useDark() ? dark : light) }, role: label ? 'img' : undefined, style: { display: 'inline-flex', height, lineHeight: 0, verticalAlign: 'middle' } }));
18
+ /** The VocalStack wordmark. */
19
+ export const Logo = ({ height = 16 }) => _jsx(Art, { dark: LOGO_DARK, height: height, label: "VocalStack", light: LOGO_LIGHT });
20
+ /** The V on its own, for small spaces (the tool's icon). */
21
+ export const Mark = ({ height = 18 }) => _jsx(Art, { dark: MARK_DARK, height: height, light: MARK_LIGHT });
@@ -0,0 +1,7 @@
1
+ import type { ObjectInputProps, Path } from 'sanity';
2
+ import type { VocalStackPluginOptions, VocalStackTranscript } from '../types.js';
3
+ /** `['body', { _key: 'a1' }, 'transcript']` → `body[_key=="a1"].transcript`, for the job's idempotency key. */
4
+ export declare const pathString: (path: Path) => string;
5
+ export declare function TranscriptInput(props: ObjectInputProps<VocalStackTranscript> & {
6
+ pluginOptions: VocalStackPluginOptions;
7
+ }): import("react").JSX.Element;