@joplo-app/server 0.6.2 → 0.7.1
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/asset-usage.d.ts +48 -0
- package/dist/asset-usage.js +174 -0
- package/dist/capture.d.ts +15 -0
- package/dist/capture.js +49 -0
- package/dist/checkpoint.d.ts +10 -0
- package/dist/checkpoint.js +75 -0
- package/dist/contract.d.ts +62 -0
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +9 -4
- package/dist/export.d.ts +6 -0
- package/dist/export.js +5 -2
- package/dist/film.d.ts +10 -1
- package/dist/film.js +201 -25
- package/dist/index.d.ts +6 -1
- package/dist/index.js +4 -1
- package/dist/layout-audit-browser.js +114 -0
- package/dist/layout-audit.d.ts +94 -0
- package/dist/layout-audit.js +86 -0
- package/dist/local-resources.js +2 -0
- package/dist/media-check.d.ts +2 -0
- package/dist/media-check.js +31 -1
- package/dist/output-file.d.ts +3 -0
- package/dist/output-file.js +23 -0
- package/dist/project.d.ts +1 -0
- package/dist/project.js +3 -1
- package/dist/render.d.ts +2 -0
- package/dist/render.js +24 -10
- package/dist/timeline.d.ts +76 -0
- package/dist/timeline.js +139 -0
- package/dist/video-format.d.ts +2 -0
- package/dist/video-format.js +12 -0
- package/dist/vite-shared.d.ts +1 -1
- package/dist/vite-shared.js +2 -2
- package/dist/voice-http.js +2 -2
- package/dist/voice-run.d.ts +16 -1
- package/dist/voice-run.js +45 -6
- package/dist/voice.js +2 -2
- package/dist/watch-config.d.ts +3 -0
- package/dist/watch-config.js +10 -0
- package/package.json +4 -4
package/dist/voice-run.d.ts
CHANGED
|
@@ -21,13 +21,27 @@ export type VoiceRunOptions = {
|
|
|
21
21
|
/** 托管朗读(CLI 的 cloud bridge 的 voice)。 */
|
|
22
22
|
cloud?: CloudVoiceBridge;
|
|
23
23
|
dryRun?: boolean;
|
|
24
|
+
/** Exact compiled work id; CLI resolves standalone entry keys without splitting ids. */
|
|
25
|
+
workId?: string;
|
|
26
|
+
scenarioId?: string;
|
|
24
27
|
/** 只做这几种内容语言(必须是项目声明的);缺省全部。 */
|
|
25
28
|
locales?: string[];
|
|
26
29
|
onProgress?: (line: string) => void;
|
|
27
30
|
/** 测试:OpenAI / ElevenLabs 的 fetch。 */
|
|
28
31
|
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
29
32
|
};
|
|
33
|
+
/** Estimates use local cache only; remote Cloud cache hits can reduce the actual charge to zero. */
|
|
34
|
+
export type VoiceStepDetail = {
|
|
35
|
+
workId: string;
|
|
36
|
+
scenarioId: string;
|
|
37
|
+
stepId: string;
|
|
38
|
+
text: string;
|
|
39
|
+
chars: number;
|
|
40
|
+
missing: boolean;
|
|
41
|
+
estimatedBillableChars: number;
|
|
42
|
+
};
|
|
30
43
|
export type VoiceRunLocale = {
|
|
44
|
+
details?: VoiceStepDetail[];
|
|
31
45
|
locale: string | null;
|
|
32
46
|
segments: number;
|
|
33
47
|
missing: number;
|
|
@@ -67,5 +81,6 @@ export type VoiceRunResult = {
|
|
|
67
81
|
} | null;
|
|
68
82
|
};
|
|
69
83
|
/** 选定方案的全部场景里,每一步要读的段(文字为空的跳过)。 */
|
|
70
|
-
export declare function
|
|
84
|
+
export declare function voiceScenarioIds(project: Project, scope?: Pick<VoiceRunOptions, 'workId' | 'scenarioId'>): Set<string>;
|
|
85
|
+
export declare function projectSegments(project: Project, scope?: Pick<VoiceRunOptions, 'workId' | 'scenarioId'>): Segment[];
|
|
71
86
|
export declare function generateProjectVoice(opts: VoiceRunOptions): Promise<VoiceRunResult>;
|
package/dist/voice-run.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import { localizeProject, speakerRoleAt, spokenLine } from '@joplo-app/core';
|
|
1
|
+
import { JoploError, localizeProject, speakerRoleAt, spokenLine, spokenChars } from '@joplo-app/core';
|
|
2
2
|
import { joploHome } from "./home.js";
|
|
3
3
|
import { ProfileStore, UNSUPPORTED_MESSAGE, VoiceCache, VoiceError, estimateVoice, resolveVoices, voiceLocaleOf } from "./voice.js";
|
|
4
4
|
/** 选定方案的全部场景里,每一步要读的段(文字为空的跳过)。 */
|
|
5
|
-
export function
|
|
5
|
+
export function voiceScenarioIds(project, scope = {}) {
|
|
6
|
+
const { workId, scenarioId } = scope;
|
|
7
|
+
if (workId && (!project.works[workId] || project.works[workId].draft))
|
|
8
|
+
throw new JoploError('USAGE', `Unknown or draft work: ${workId}`);
|
|
9
|
+
if (scenarioId && (!project.scenarios[scenarioId] || project.works[project.scenarios[scenarioId].workId]?.draft))
|
|
10
|
+
throw new JoploError('USAGE', `Unknown or draft scenario: ${scenarioId}`);
|
|
11
|
+
if (workId && scenarioId && project.scenarios[scenarioId]?.workId !== workId)
|
|
12
|
+
throw new JoploError('USAGE', `Scenario ${scenarioId} does not belong to work ${workId}`);
|
|
6
13
|
const picked = new Set(Object.values(project.works).filter(w => !w.draft && (!w.featureId || project.features[w.featureId]?.pick === w.id)).map(w => w.id));
|
|
14
|
+
const ids = new Set(Object.values(project.scenarios).filter(sc => scenarioId ? sc.id === scenarioId : workId ? sc.workId === workId : picked.has(sc.workId)).map(sc => sc.id));
|
|
15
|
+
// Continuing chapters depend on their predecessors, even when selecting one chapter.
|
|
16
|
+
for (const id of ids) {
|
|
17
|
+
const from = project.scenarios[id]?.from;
|
|
18
|
+
if (from && project.scenarios[from] && !project.works[project.scenarios[from].workId]?.draft)
|
|
19
|
+
ids.add(from);
|
|
20
|
+
}
|
|
21
|
+
return ids;
|
|
22
|
+
}
|
|
23
|
+
export function projectSegments(project, scope = {}) {
|
|
24
|
+
const ids = voiceScenarioIds(project, scope);
|
|
7
25
|
const out = [];
|
|
8
26
|
for (const sc of Object.values(project.scenarios)) {
|
|
9
|
-
if (!
|
|
27
|
+
if (!ids.has(sc.id))
|
|
10
28
|
continue;
|
|
11
29
|
sc.steps.forEach((st, i) => {
|
|
12
30
|
const line = spokenLine(st, st.caption, speakerRoleAt(project, sc.id, i + 1));
|
|
@@ -17,6 +35,7 @@ export function projectSegments(project) {
|
|
|
17
35
|
return out;
|
|
18
36
|
}
|
|
19
37
|
export async function generateProjectVoice(opts) {
|
|
38
|
+
voiceScenarioIds(opts.project, opts);
|
|
20
39
|
const status = opts.cloud ? await opts.cloud.status().catch(() => null) : null;
|
|
21
40
|
const live = status?.signedIn && status.voice ? status.voice : null;
|
|
22
41
|
const store = new ProfileStore(opts.home ?? joploHome(), process.env, { catalog: () => live });
|
|
@@ -55,9 +74,29 @@ export async function generateProjectVoice(opts) {
|
|
|
55
74
|
for (const locale of locales) {
|
|
56
75
|
const p = locale ? localizeProject(project, locale) : project;
|
|
57
76
|
const resolved = resolveVoices(project.voiceConfig, selected, store, voiceLocaleOf(project, locale), fallback, cache.pins(), cache.officialCloud());
|
|
58
|
-
const segments = projectSegments(p);
|
|
77
|
+
const segments = projectSegments(p, opts);
|
|
59
78
|
const est = estimateVoice(segments, resolved, cache);
|
|
60
|
-
const
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
const segmentById = new Map(segments.map(s => [s.stepId, s]));
|
|
81
|
+
const selectedIds = voiceScenarioIds(p, opts);
|
|
82
|
+
const details = [];
|
|
83
|
+
for (const sc of Object.values(p.scenarios))
|
|
84
|
+
for (const st of sc.steps) {
|
|
85
|
+
if (!selectedIds.has(sc.id))
|
|
86
|
+
continue;
|
|
87
|
+
const seg = segmentById.get(st.id);
|
|
88
|
+
if (!seg) {
|
|
89
|
+
details.push({ workId: sc.workId, scenarioId: sc.id, stepId: st.id, text: '', chars: 0, missing: false, estimatedBillableChars: 0 });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const planned = cache.plan(seg, resolved);
|
|
93
|
+
const missing = !!planned && !cache.clipOf(planned.key);
|
|
94
|
+
const estimatedBillableChars = missing && planned && !seen.has(planned.key) ? spokenChars(planned.text) : 0;
|
|
95
|
+
if (planned)
|
|
96
|
+
seen.add(planned.key);
|
|
97
|
+
details.push({ workId: sc.workId, scenarioId: sc.id, stepId: st.id, text: seg.text, chars: spokenChars(seg.text), missing, estimatedBillableChars });
|
|
98
|
+
}
|
|
99
|
+
const row = { details, locale, segments: segments.length, missing: est.steps, chars: est.chars, generated: 0, skipped: 0, failed: [] };
|
|
61
100
|
result.locales.push(row);
|
|
62
101
|
result.total.segments += segments.length;
|
|
63
102
|
result.total.missing += est.steps;
|
|
@@ -65,7 +104,7 @@ export async function generateProjectVoice(opts) {
|
|
|
65
104
|
if (opts.dryRun || !est.steps || result.exhausted)
|
|
66
105
|
continue;
|
|
67
106
|
opts.onProgress?.(`Generating ${est.steps} clip(s)${locale ? ` for ${locale}` : ''} with ${base.profile.name} (about ${est.chars} characters)...`);
|
|
68
|
-
const summary = await cache.generate(segments, locale ?? '
|
|
107
|
+
const summary = await cache.generate(segments, locale ?? 'und', resolved, store, {
|
|
69
108
|
cloud: opts.cloud,
|
|
70
109
|
fetch: opts.fetch,
|
|
71
110
|
project: project.name,
|
package/dist/voice.js
CHANGED
|
@@ -827,7 +827,7 @@ export async function reuseSharedVoice(projectDir, project, shared, store, devCo
|
|
|
827
827
|
continue;
|
|
828
828
|
const file = rel.replace(/^voice\//, '');
|
|
829
829
|
const bytes = await shared.fetch(rel).catch(() => null);
|
|
830
|
-
if (bytes && cache.adopt(key, file, bytes, { stepId: st.id, fp, text, locale: locale ?? '
|
|
830
|
+
if (bytes && cache.adopt(key, file, bytes, { stepId: st.id, fp, text, locale: locale ?? project.i18n?.default ?? 'und', origin: 'shared' }))
|
|
831
831
|
reused++;
|
|
832
832
|
}
|
|
833
833
|
return reused;
|
|
@@ -883,7 +883,7 @@ export function bundleVoice(projectDir, project, outDir, store, devConfig, fallb
|
|
|
883
883
|
.filter(([key, c]) => {
|
|
884
884
|
if (c.stepId !== st.id || (locale && c.locale !== locale) || typeof c.text !== 'string')
|
|
885
885
|
return false;
|
|
886
|
-
const expected = automaticCaption(st.captionAuto, c.locale);
|
|
886
|
+
const expected = c.locale === 'und' ? st.caption : automaticCaption(st.captionAuto, c.locale);
|
|
887
887
|
// 先证明文字仍属于当前内容,再考虑来源优先级;未知语言、旧文字或错配缓存键均不能发布。
|
|
888
888
|
return expected !== null && c.text.replace(/\s+/g, ' ').trim() === expected.replace(/\s+/g, ' ').trim()
|
|
889
889
|
&& key === clipKey(c.fp, expected) && !!cache.clipOf(key);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Dev-service policy, deliberately outside the playback/compiler model. */
|
|
2
|
+
export function watchConfigDiagnostics(value, at = 'joplo.config.ts:1:1') {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return [];
|
|
5
|
+
const w = value;
|
|
6
|
+
if (!w || typeof w !== 'object' || Array.isArray(w) || Object.keys(w).some(k => k !== 'ignore') ||
|
|
7
|
+
(w.ignore !== undefined && (!Array.isArray(w.ignore) || w.ignore.some(p => typeof p !== 'string' || !p || /[\\:*?\[\]{}\x00]/.test(p) || p.startsWith('/') || p.split('/').some(s => !s || s === '.' || s === '..') || /^joplo\.config\.tsx?$/.test(p)))))
|
|
8
|
+
return [{ code: 'WATCH_CONFIG_INVALID', severity: 'error', source: 'schema', at, message: 'watch.ignore must contain project-relative file or directory paths (no globs, dot segments, or joplo.config.ts); restart dev after changing it' }];
|
|
9
|
+
return [];
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Joplo 作品本地服务:dev 看板、build 静态发布站、render 截图,服务链接与嵌入交付",
|
|
5
5
|
"license": "PolyForm-Shield-1.0.0",
|
|
6
6
|
"type": "module",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@joplo-app/core": "0.
|
|
19
|
-
"@joplo-app/kit": "0.
|
|
20
|
-
"@joplo-app/web": "0.
|
|
18
|
+
"@joplo-app/core": "0.7.1",
|
|
19
|
+
"@joplo-app/kit": "0.7.1",
|
|
20
|
+
"@joplo-app/web": "0.7.1",
|
|
21
21
|
"@tailwindcss/vite": "4.3.4",
|
|
22
22
|
"mediabunny": "1.65.2",
|
|
23
23
|
"tailwindcss": "4.3.4",
|