@vocasync/astro 0.1.3 → 0.1.7
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 +32 -27
- package/dist/api/client.d.ts +10 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +11 -0
- package/dist/api/client.js.map +1 -1
- package/dist/cli.js +0 -0
- package/dist/components/AudioPlayer.astro +80 -32
- package/dist/config/schema.d.ts +6 -5
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +16 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/core/audio-map.js +1 -1
- package/dist/rehype/audio-words.d.ts.map +1 -1
- package/dist/rehype/audio-words.js +14 -4
- package/dist/rehype/audio-words.js.map +1 -1
- package/dist/styles/variables.css +3 -20
- package/dist/sync/orchestrator.d.ts.map +1 -1
- package/dist/sync/orchestrator.js +33 -2
- package/dist/sync/orchestrator.js.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -5
- package/src/api/client.ts +15 -0
- package/src/components/AudioPlayer.astro +80 -32
- package/src/config/schema.ts +16 -7
- package/src/core/audio-map.ts +1 -1
- package/src/data/audio-map.example.json +2 -5
- package/src/rehype/audio-words.ts +15 -4
- package/src/styles/variables.css +3 -20
- package/src/sync/orchestrator.ts +39 -2
- package/src/types/index.ts +13 -1
package/src/sync/orchestrator.ts
CHANGED
|
@@ -127,11 +127,43 @@ async function processItem(
|
|
|
127
127
|
const existingEntry = getAudioEntry(audioMap, item.slug);
|
|
128
128
|
const contentChanged = hasChanged(existingEntry?.contentHash, speechDoc.hash);
|
|
129
129
|
|
|
130
|
-
if
|
|
130
|
+
// Check if existing entry is missing publishable key (migration from v1)
|
|
131
|
+
const needsPublishableKey = existingEntry && !existingEntry.publishableKey;
|
|
132
|
+
|
|
133
|
+
if (!force && !contentChanged && existingEntry && !needsPublishableKey) {
|
|
131
134
|
onProgress(`⏭ ${item.slug} - unchanged`, "info");
|
|
132
135
|
return { slug: item.slug, status: "unchanged" };
|
|
133
136
|
}
|
|
134
137
|
|
|
138
|
+
// If only missing publishable key, create it without re-synthesizing
|
|
139
|
+
if (!force && !contentChanged && existingEntry && needsPublishableKey) {
|
|
140
|
+
onProgress(`🔑 ${item.slug} - creating missing publishable key...`, "info");
|
|
141
|
+
|
|
142
|
+
if (dryRun) {
|
|
143
|
+
onProgress(`🔍 ${item.slug} - would create publishable key (dry run)`, "info");
|
|
144
|
+
return { slug: item.slug, status: "unchanged" };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const { publishableKey } = await client.createPublishableKey(existingEntry.projectUuid);
|
|
149
|
+
|
|
150
|
+
// Update existing entry with publishable key
|
|
151
|
+
const updatedArtifact: AudioArtifact = {
|
|
152
|
+
...existingEntry,
|
|
153
|
+
publishableKey,
|
|
154
|
+
updatedAt: new Date().toISOString(),
|
|
155
|
+
};
|
|
156
|
+
setAudioEntry(audioMap, item.slug, updatedArtifact);
|
|
157
|
+
|
|
158
|
+
onProgress(`✅ ${item.slug} - publishable key added`, "success");
|
|
159
|
+
return { slug: item.slug, status: "updated", projectUuid: existingEntry.projectUuid };
|
|
160
|
+
} catch (error) {
|
|
161
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
162
|
+
onProgress(`❌ ${item.slug} - failed to create publishable key: ${message}`, "error");
|
|
163
|
+
return { slug: item.slug, status: "error", error: message };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
135
167
|
const status: SyncStatus = existingEntry ? "updated" : "new";
|
|
136
168
|
onProgress(`📤 ${item.slug} - ${status}, submitting...`, "info");
|
|
137
169
|
|
|
@@ -167,16 +199,21 @@ async function processItem(
|
|
|
167
199
|
|
|
168
200
|
const alignmentData = await client.getAlignment(finalStatus.alignmentJob.alignmentUrl);
|
|
169
201
|
|
|
202
|
+
// Create publishable key for public streaming access
|
|
203
|
+
onProgress(`🔑 ${item.slug} - creating publishable key...`, "info");
|
|
204
|
+
const { publishableKey } = await client.createPublishableKey(response.projectUuid);
|
|
205
|
+
|
|
170
206
|
// Get stable streaming URLs
|
|
171
207
|
const streamingUrls = getStreamingUrls(response.projectUuid);
|
|
172
208
|
|
|
173
|
-
// Create audio artifact
|
|
209
|
+
// Create audio artifact with publishable key
|
|
174
210
|
const artifact: AudioArtifact = {
|
|
175
211
|
projectUuid: response.projectUuid,
|
|
176
212
|
contentHash: speechDoc.hash,
|
|
177
213
|
duration: alignmentData.duration,
|
|
178
214
|
audioUrl: streamingUrls.synthesisUrl,
|
|
179
215
|
alignmentUrl: streamingUrls.alignmentUrl,
|
|
216
|
+
publishableKey,
|
|
180
217
|
createdAt: existingEntry?.createdAt || new Date().toISOString(),
|
|
181
218
|
updatedAt: new Date().toISOString(),
|
|
182
219
|
};
|
package/src/types/index.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface AudioArtifact {
|
|
|
52
52
|
audioUrl: string;
|
|
53
53
|
/** URL to fetch alignment JSON (stable, non-expiring) */
|
|
54
54
|
alignmentUrl: string;
|
|
55
|
+
/** Publishable key for streaming endpoint authentication */
|
|
56
|
+
publishableKey?: string;
|
|
55
57
|
/** When this artifact was created */
|
|
56
58
|
createdAt: string;
|
|
57
59
|
/** When this artifact was last updated */
|
|
@@ -63,7 +65,7 @@ export interface AudioArtifact {
|
|
|
63
65
|
*/
|
|
64
66
|
export interface AudioMap {
|
|
65
67
|
/** Version of the audio-map schema */
|
|
66
|
-
version: 1;
|
|
68
|
+
version: 1 | 2;
|
|
67
69
|
/** When the map was last updated */
|
|
68
70
|
updatedAt: string;
|
|
69
71
|
/** Map of slug -> audio artifact */
|
|
@@ -91,6 +93,16 @@ export interface SynthesisResponse {
|
|
|
91
93
|
estimatedCost: number;
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* VocaSync API publishable key response
|
|
98
|
+
*/
|
|
99
|
+
export interface PublishableKeyResponse {
|
|
100
|
+
publishableKey: string;
|
|
101
|
+
projectUuid: string;
|
|
102
|
+
prefix: string;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
94
106
|
/**
|
|
95
107
|
* Job status from VocaSync API
|
|
96
108
|
*/
|