@lincyaw/workspace 1.0.0-rc.81 → 1.0.0-rc.83
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/package.json +6 -6
- package/src/node/document-voice.ts +5 -1
- package/src/node/serve.ts +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/workspace",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.83",
|
|
4
4
|
"description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"mime-types": "3.0.2",
|
|
35
35
|
"playwright-chromium": "1.64.1",
|
|
36
36
|
"yaml": "^2.9.1",
|
|
37
|
-
"@lincyaw/compiler": "1.0.0-rc.
|
|
38
|
-
"@lincyaw/server": "1.0.0-rc.
|
|
39
|
-
"@lincyaw/
|
|
40
|
-
"@lincyaw/
|
|
37
|
+
"@lincyaw/compiler": "1.0.0-rc.83",
|
|
38
|
+
"@lincyaw/server": "1.0.0-rc.83",
|
|
39
|
+
"@lincyaw/design": "1.0.0-rc.83",
|
|
40
|
+
"@lincyaw/kernel": "1.0.0-rc.83"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/mime-types": "^3.0.1",
|
|
44
|
-
"@lincyaw/mcp": "1.0.0-rc.
|
|
44
|
+
"@lincyaw/mcp": "1.0.0-rc.83"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -13,12 +13,14 @@ export interface DocumentVoiceServices { speech?: SpeechService, voiceover?: { v
|
|
|
13
13
|
export interface DocumentVoiceAuthoringOptions {
|
|
14
14
|
editor: SourceEditor
|
|
15
15
|
services(document: string, source: CanonicalSource): Promise<DocumentVoiceServices>
|
|
16
|
+
/** Prepare the current compiled document only for operations that need voice targets and timing. */
|
|
17
|
+
prepareExecution?(document: string, source: CanonicalSource, signal: AbortSignal): Promise<void>
|
|
16
18
|
revision?(document: string): string | undefined
|
|
17
19
|
uploads?: MediaUploadsOwner
|
|
18
20
|
}
|
|
19
21
|
const same = (a: CanonicalSource, b: CanonicalSource) => a.documentId === b.documentId && a.version === b.version && a.fingerprint === b.fingerprint
|
|
20
22
|
|
|
21
|
-
export function createDocumentVoiceAuthoring({ editor, services, revision, uploads }: DocumentVoiceAuthoringOptions) {
|
|
23
|
+
export function createDocumentVoiceAuthoring({ editor, services, prepareExecution, revision, uploads }: DocumentVoiceAuthoringOptions) {
|
|
22
24
|
const pending = new Set<{ controller: AbortController, finished: Promise<unknown> }>()
|
|
23
25
|
const owners = new Map<string, ReturnType<typeof createVoiceoverOwner>>()
|
|
24
26
|
const clones = new Map<string, { document: string, member: string, request: string, prepared: PreparedVoiceClone }>()
|
|
@@ -67,6 +69,8 @@ export function createDocumentVoiceAuthoring({ editor, services, revision, uploa
|
|
|
67
69
|
const execution = (document: string, member: Member) => async (expected: CanonicalSource | undefined, signal: AbortSignal) => {
|
|
68
70
|
const loaded = await load(document, member, signal, expected)
|
|
69
71
|
if (!loaded.voiceoverExecution) throw new RequestError(503, 'voiceover-unavailable')
|
|
72
|
+
await prepareExecution?.(document, loaded.source, signal)
|
|
73
|
+
signal.throwIfAborted(); current(document, member, loaded.source)
|
|
70
74
|
return loaded.voiceoverExecution
|
|
71
75
|
}
|
|
72
76
|
const isCurrent = (document: string, member: Member, job: VoiceoverJob): boolean | 'unknown' => {
|
package/src/node/serve.ts
CHANGED
|
@@ -442,7 +442,20 @@ async function startWorkspace(options: ServeOptions): Promise<WorkspaceServer> {
|
|
|
442
442
|
const running = server
|
|
443
443
|
serverServices = running.services
|
|
444
444
|
mediaUploads = createMediaUploads({ editor, url: () => `${publicOrigin()}${basePath.replace(/\/$/, '')}` })
|
|
445
|
-
voiceAuthoring = createDocumentVoiceAuthoring({
|
|
445
|
+
voiceAuthoring = createDocumentVoiceAuthoring({
|
|
446
|
+
editor, uploads: mediaUploads, services: authoringServices,
|
|
447
|
+
async prepareExecution(document, source, signal) {
|
|
448
|
+
signal.throwIfAborted()
|
|
449
|
+
const session = compileSessionOf(document)
|
|
450
|
+
const matches = (compilation: Compilation) => compilation.doc.source?.documentId === source.documentId && compilation.doc.source.version === source.version && compilation.doc.source.fingerprint === source.fingerprint
|
|
451
|
+
let compilation = await session.ready()
|
|
452
|
+
signal.throwIfAborted()
|
|
453
|
+
if (!matches(compilation)) compilation = await session.recompile()
|
|
454
|
+
signal.throwIfAborted()
|
|
455
|
+
if (!matches(compilation)) throw new RequestError(409, 'document-version-changed')
|
|
456
|
+
},
|
|
457
|
+
revision: document => { const latest = compileSessions.get(document)?.latest; return latest ? irRevision(latest.doc) : undefined },
|
|
458
|
+
})
|
|
446
459
|
workbench = createWorkbenchBackend({ root, compileSessionOf, serverHost, voices: voiceAuthoring.service, diagnostics: running.diagnostics, url: () => options.publicUrl ? new URL(options.publicUrl).origin : running.url, basePath, preview, log, warmSite: dir => site?.warm(dir) ?? Promise.resolve(), viewerPage: (dir, wait) => site?.app(dir, wait) ?? Promise.resolve(undefined) })
|
|
447
460
|
history = openHistory()
|
|
448
461
|
workspaceChanges = createWorkspaceChanges({ config, editor, locks, revisions: history?.revisions, changed: documentsChanged })
|