@joplo-app/core 0.5.0 → 0.6.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.
Files changed (65) hide show
  1. package/dist/agent-skill.d.ts +7 -7
  2. package/dist/agent-skill.js +28 -25
  3. package/dist/authoring-works.d.ts +8 -0
  4. package/dist/authoring-works.js +46 -0
  5. package/dist/catalog.d.ts +2 -0
  6. package/dist/compile.d.ts +6 -3
  7. package/dist/compile.js +415 -340
  8. package/dist/content-i18n.js +9 -9
  9. package/dist/embed.d.ts +5 -5
  10. package/dist/embed.js +7 -7
  11. package/dist/entries.d.ts +63 -0
  12. package/dist/entries.js +78 -0
  13. package/dist/feature-diff.d.ts +7 -7
  14. package/dist/feature-diff.js +18 -17
  15. package/dist/features.d.ts +3 -3
  16. package/dist/features.js +3 -3
  17. package/dist/focus-check.js +2 -2
  18. package/dist/focus.d.ts +1 -5
  19. package/dist/focus.js +13 -35
  20. package/dist/guide.js +156 -66
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +2 -0
  23. package/dist/load.js +42 -11
  24. package/dist/local-review-files.js +17 -4
  25. package/dist/local-review.d.ts +8 -7
  26. package/dist/local-review.js +7 -6
  27. package/dist/outline.d.ts +21 -13
  28. package/dist/outline.js +27 -32
  29. package/dist/pace.d.ts +3 -4
  30. package/dist/pace.js +3 -4
  31. package/dist/playback.d.ts +57 -0
  32. package/dist/playback.js +317 -0
  33. package/dist/player.d.ts +9 -195
  34. package/dist/player.js +8 -633
  35. package/dist/playground.d.ts +1 -1
  36. package/dist/playground.js +4 -4
  37. package/dist/plugins/compiler.d.ts +16 -0
  38. package/dist/plugins/compiler.js +48 -9
  39. package/dist/presentation.d.ts +73 -0
  40. package/dist/presentation.js +163 -0
  41. package/dist/publication.d.ts +8 -0
  42. package/dist/publication.js +45 -0
  43. package/dist/result.d.ts +1 -1
  44. package/dist/review.d.ts +18 -10
  45. package/dist/review.js +62 -23
  46. package/dist/runtime.d.ts +2 -0
  47. package/dist/runtime.js +2 -0
  48. package/dist/scene-query.d.ts +77 -0
  49. package/dist/scene-query.js +246 -0
  50. package/dist/schema-issues.js +1 -1
  51. package/dist/schema.d.ts +108 -76
  52. package/dist/schema.js +48 -36
  53. package/dist/scope.d.ts +9 -9
  54. package/dist/scope.js +82 -49
  55. package/dist/selection.d.ts +1 -1
  56. package/dist/sequencing.d.ts +6 -0
  57. package/dist/sequencing.js +21 -0
  58. package/dist/step-plan.d.ts +55 -0
  59. package/dist/step-plan.js +90 -0
  60. package/dist/traits.d.ts +10 -0
  61. package/dist/traits.js +3 -0
  62. package/dist/validate.d.ts +1 -1
  63. package/dist/validate.js +75 -65
  64. package/dist/voice.js +2 -1
  65. package/package.json +15 -3
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ export * from './review.js';
15
15
  export * from './scope.js';
16
16
  export * from './agent-skill.js';
17
17
  export * from './pace.js';
18
+ export * from './step-plan.js';
19
+ export * from './entries.js';
18
20
  export * from './outline.js';
19
21
  export * from './voice.js';
20
22
  export * from './content-i18n.js';
package/dist/index.js CHANGED
@@ -15,6 +15,8 @@ export * from "./review.js";
15
15
  export * from "./scope.js";
16
16
  export * from "./agent-skill.js";
17
17
  export * from "./pace.js";
18
+ export * from "./step-plan.js";
19
+ export * from "./entries.js";
18
20
  export * from "./outline.js";
19
21
  export * from "./voice.js";
20
22
  export * from "./content-i18n.js";
package/dist/load.js CHANGED
@@ -6,7 +6,8 @@
6
6
  * layouts/<id>.tsx
7
7
  * routes/**\/page.tsx routes/page.tsx → /,routes/members/page.tsx → /members
8
8
  * features/<f>/feature.ts
9
- * features/<f>/options/<o>.tsx
9
+ * features/<f>/works/<o>.tsx
10
+ * works/<key>.tsx 影片 → 章节 → 步骤
10
11
  * themes/<name>.css 作者主题(D51),按原文读取
11
12
  * locales/<语言>.json 作者内容译文(D84):原文 → 译文
12
13
  */
@@ -44,10 +45,13 @@ export function discoverFiles(root) {
44
45
  const ff = findFile(join(fd, 'feature'));
45
46
  if (ff)
46
47
  files.push(ff);
47
- for (const o of list(join(fd, 'options')))
48
+ for (const o of list(join(fd, 'works')))
48
49
  if (/\.(tsx|ts)$/.test(o))
49
- files.push(join(fd, 'options', o));
50
+ files.push(join(fd, 'works', o));
50
51
  }
52
+ for (const f of list(join(r, 'works')))
53
+ if (/\.(tsx|ts)$/.test(f) && !isDir(join(r, 'works', f)))
54
+ files.push(join(r, 'works', f));
51
55
  for (const f of list(join(r, 'themes')))
52
56
  if (/\.css$/.test(f))
53
57
  files.push(join(r, 'themes', f));
@@ -115,18 +119,33 @@ export async function loadAuthoring(root, importer) {
115
119
  const diags = [];
116
120
  const relp = (p) => relative(r, p).split(sep).join('/');
117
121
  const fail = (file, message, code = 'LOAD_FAILED') => diags.push({ severity: 'error', code, message, source: 'schema', at: `${relp(file)}:1:1` });
122
+ const missingConfig = !existsSync(join(r, 'tsconfig.json'));
123
+ const configurationFailure = (file, detail) => {
124
+ if (diags.some(d => d.code === 'PROJECT_MODULE_CONFIG'))
125
+ return;
126
+ fail(file, `Cannot load this project. Add tsconfig.json using jsx: "react-jsxdev" and jsxImportSource: "@joplo-app/kit" and package.json with "type": "module", then run check again (underlying error: ${detail})`, 'PROJECT_MODULE_CONFIG');
127
+ };
118
128
  const load = async (file, kind) => {
119
129
  try {
120
130
  const mod = await importer(file);
121
131
  const v = (mod.default ?? null);
122
132
  if (!v || v.kind !== kind) {
123
- fail(file, `Default export must be ${kind}(...); got ${v?.kind ?? typeof v}`, 'WRONG_EXPORT');
133
+ const detail = `Default export must be ${kind}(...); got ${v?.kind ?? typeof v}`;
134
+ if (missingConfig) {
135
+ configurationFailure(file, detail);
136
+ return null;
137
+ }
138
+ fail(file, detail, kind === 'work' ? 'WORK_INVALID' : 'WRONG_EXPORT');
124
139
  return null;
125
140
  }
126
141
  return { ...v, file: relp(file) };
127
142
  }
128
143
  catch (e) {
129
- fail(file, `Load failed: ${e instanceof Error ? e.message : String(e)}`);
144
+ const detail = e instanceof Error ? e.message : String(e);
145
+ if (missingConfig)
146
+ configurationFailure(file, detail);
147
+ else
148
+ fail(file, `Load failed: ${detail}`);
130
149
  return null;
131
150
  }
132
151
  };
@@ -136,6 +155,8 @@ export async function loadAuthoring(root, importer) {
136
155
  return { authoring: null, diagnostics: diags };
137
156
  }
138
157
  const config = await load(cfgFile, 'config');
158
+ if (!config && diags.some(d => d.code === 'PROJECT_MODULE_CONFIG'))
159
+ return { authoring: null, diagnostics: diags };
139
160
  const layouts = {};
140
161
  for (const f of list(join(r, 'layouts'))) {
141
162
  if (!/\.(tsx|ts)$/.test(f))
@@ -172,22 +193,32 @@ export async function loadAuthoring(root, importer) {
172
193
  fail(fd, `Feature directory ${fid} is missing feature.ts`, 'MISSING_FEATURE');
173
194
  continue;
174
195
  }
196
+ if (isDir(join(fd, 'options')))
197
+ fail(join(fd, 'options'), 'Rename this directory to works/ and migrate the authoring call to work({ title, summary })', 'OPTIONS_DIR_RENAMED');
175
198
  const def = await load(ff, 'feature');
176
199
  if (!def)
177
200
  continue;
178
- const options = {};
179
- for (const o of list(join(fd, 'options'))) {
201
+ const works = {};
202
+ for (const o of list(join(fd, 'works'))) {
180
203
  if (!/\.(tsx|ts)$/.test(o))
181
204
  continue;
182
- const v = await load(join(fd, 'options', o), 'option');
205
+ const v = await load(join(fd, 'works', o), 'work');
183
206
  if (v)
184
- options[stem(o)] = v;
207
+ works[stem(o)] = v;
185
208
  }
186
- features[fid] = { def, options };
209
+ features[fid] = { def, works };
210
+ }
211
+ const works = {};
212
+ for (const f of list(join(r, 'works'))) {
213
+ if (!/\.(tsx|ts)$/.test(f) || isDir(join(r, 'works', f)))
214
+ continue;
215
+ const v = await load(join(r, 'works', f), 'work');
216
+ if (v)
217
+ works[stem(f)] = v;
187
218
  }
188
219
  if (!config)
189
220
  return { authoring: null, diagnostics: diags };
190
221
  const loc = loadLocales(r);
191
222
  diags.push(...loc.diagnostics);
192
- return { authoring: { root: r, config, layouts, routes, features, themes: loadThemes(r), ...(Object.keys(loc.files).length ? { locales: loc.locales, localeFiles: loc.files } : {}) }, diagnostics: diags };
223
+ return { authoring: { root: r, config, layouts, routes, features, ...(Object.keys(works).length ? { works } : {}), themes: loadThemes(r), ...(Object.keys(loc.files).length ? { locales: loc.locales, localeFiles: loc.files } : {}) }, diagnostics: diags };
193
224
  }
@@ -2,7 +2,7 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import crypto from 'node:crypto';
5
- import { LOCAL_REVIEW_MAX_FILE_BYTES, LocalReviewId, LocalReviewSession } from "./local-review.js";
5
+ import { LOCAL_REVIEW_VERSION, LOCAL_REVIEW_MAX_FILE_BYTES, LocalReviewId, LocalReviewSession } from "./local-review.js";
6
6
  import { JoploError } from "./result.js";
7
7
  export const localReviewDir = (dir) => path.join(dir, '.joplo', 'reviews');
8
8
  export function localReviewFile(dir, sessionId) {
@@ -29,15 +29,25 @@ export function writeLocalReview(file, value) {
29
29
  fs.rmSync(tmp, { force: true });
30
30
  }
31
31
  }
32
- export function readLocalReview(dir, sessionId) {
32
+ function currentLocalReview(dir, sessionId) {
33
33
  const file = localReviewFile(dir, sessionId);
34
34
  if (fs.statSync(file).size > LOCAL_REVIEW_MAX_FILE_BYTES)
35
35
  throw new JoploError('INVALID_SCHEMA', 'Local review file exceeds 16 MiB');
36
- const result = LocalReviewSession.safeParse(JSON.parse(fs.readFileSync(file, 'utf8')));
36
+ const value = JSON.parse(fs.readFileSync(file, 'utf8'));
37
+ // 只读版本号;不解释、不迁移旧记录,当前版本损坏仍照常报错。
38
+ if (value && typeof value === 'object' && 'v' in value && value.v !== LOCAL_REVIEW_VERSION)
39
+ return null;
40
+ const result = LocalReviewSession.safeParse(value);
37
41
  if (!result.success || result.data.id !== sessionId || result.data.projectDir !== fs.realpathSync(dir))
38
42
  throw new JoploError('INVALID_SCHEMA', `Invalid local review file: ${file}`);
39
43
  return result.data;
40
44
  }
45
+ export function readLocalReview(dir, sessionId) {
46
+ const session = currentLocalReview(dir, sessionId);
47
+ if (!session)
48
+ throw new JoploError('NOT_FOUND', 'This review session was created by an older version of Joplo; start a new review');
49
+ return session;
50
+ }
41
51
  export function listLocalReviews(dir) {
42
52
  let files;
43
53
  try {
@@ -48,7 +58,10 @@ export function listLocalReviews(dir) {
48
58
  return [];
49
59
  throw e;
50
60
  }
51
- return files.filter(f => /^rv_[a-f0-9]{32}\.json$/.test(f)).map(f => readLocalReview(dir, f.slice(0, -5)))
61
+ return files.filter(f => /^rv_[a-f0-9]{32}\.json$/.test(f)).flatMap(f => {
62
+ const session = currentLocalReview(dir, f.slice(0, -5));
63
+ return session ? [session] : [];
64
+ })
52
65
  .sort((a, b) => b.createdAt.localeCompare(a.createdAt));
53
66
  }
54
67
  export function localReviewOwnerAlive(session) {
@@ -1,5 +1,6 @@
1
1
  /** 本地评审的持久化契约。浏览器、服务端和 CLI 共用;不依赖 Node。 */
2
2
  import { z } from 'zod';
3
+ export declare const LOCAL_REVIEW_VERSION: 2;
3
4
  export declare const LOCAL_REVIEW_MAX_BODY = 10000;
4
5
  export declare const LOCAL_REVIEW_MAX_EVENTS = 1000;
5
6
  export declare const LOCAL_REVIEW_MAX_FILE_BYTES: number;
@@ -49,7 +50,7 @@ export declare const LocalReviewEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
49
50
  reason: z.ZodEnum<{
50
51
  source_changed: "source_changed";
51
52
  compile_error: "compile_error";
52
- option_removed: "option_removed";
53
+ work_removed: "work_removed";
53
54
  server_stopped: "server_stopped";
54
55
  }>;
55
56
  sessionId: z.ZodString;
@@ -59,17 +60,17 @@ export declare const LocalReviewEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
60
  }, z.core.$strict>], "type">;
60
61
  export type LocalReviewEvent = z.infer<typeof LocalReviewEvent>;
61
62
  export declare const LocalReviewSession: z.ZodObject<{
62
- v: z.ZodLiteral<1>;
63
+ v: z.ZodLiteral<2>;
63
64
  id: z.ZodString;
64
65
  instanceId: z.ZodString;
65
66
  ownerPid: z.ZodNumber;
66
67
  projectId: z.ZodString;
67
68
  projectDir: z.ZodString;
68
69
  projectName: z.ZodString;
69
- featureId: z.ZodString;
70
- featureName: z.ZodString;
71
- optionId: z.ZodString;
72
- optionName: z.ZodString;
70
+ featureId: z.ZodNullable<z.ZodString>;
71
+ featureName: z.ZodNullable<z.ZodString>;
72
+ workId: z.ZodString;
73
+ workTitle: z.ZodString;
73
74
  revision: z.ZodString;
74
75
  createdAt: z.ZodISODateTime;
75
76
  url: z.ZodString;
@@ -101,7 +102,7 @@ export declare const LocalReviewSession: z.ZodObject<{
101
102
  reason: z.ZodEnum<{
102
103
  source_changed: "source_changed";
103
104
  compile_error: "compile_error";
104
- option_removed: "option_removed";
105
+ work_removed: "work_removed";
105
106
  server_stopped: "server_stopped";
106
107
  }>;
107
108
  sessionId: z.ZodString;
@@ -1,5 +1,6 @@
1
1
  /** 本地评审的持久化契约。浏览器、服务端和 CLI 共用;不依赖 Node。 */
2
2
  import { z } from 'zod';
3
+ export const LOCAL_REVIEW_VERSION = 2;
3
4
  export const LOCAL_REVIEW_MAX_BODY = 10_000;
4
5
  export const LOCAL_REVIEW_MAX_EVENTS = 1000;
5
6
  export const LOCAL_REVIEW_MAX_FILE_BYTES = 16 * 1024 * 1024;
@@ -26,20 +27,20 @@ const eventBase = {
26
27
  export const LocalReviewEvent = z.discriminatedUnion('type', [
27
28
  z.strictObject({ ...eventBase, type: z.literal('feedback'), body: z.string().trim().min(1).max(LOCAL_REVIEW_MAX_BODY), context: LocalReviewContext }),
28
29
  z.strictObject({ ...eventBase, type: z.literal('approved') }),
29
- z.strictObject({ ...eventBase, type: z.literal('closed'), reason: z.enum(['source_changed', 'compile_error', 'option_removed', 'server_stopped']) }),
30
+ z.strictObject({ ...eventBase, type: z.literal('closed'), reason: z.enum(['source_changed', 'compile_error', 'work_removed', 'server_stopped']) }),
30
31
  ]);
31
32
  export const LocalReviewSession = z.strictObject({
32
- v: z.literal(1),
33
+ v: z.literal(LOCAL_REVIEW_VERSION),
33
34
  id: LocalReviewId,
34
35
  instanceId: z.string().uuid(),
35
36
  ownerPid: z.number().int().positive(),
36
37
  projectId: ref,
37
38
  projectDir: z.string().min(1),
38
39
  projectName: z.string(),
39
- featureId: ref,
40
- featureName: z.string(),
41
- optionId: ref,
42
- optionName: z.string(),
40
+ featureId: ref.nullable(),
41
+ featureName: z.string().nullable(),
42
+ workId: ref,
43
+ workTitle: z.string(),
43
44
  revision: z.string().regex(/^[a-f0-9]{64}$/),
44
45
  createdAt: z.iso.datetime(),
45
46
  url: z.string().url(),
package/dist/outline.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- import type { Coverage, Project, Scenario, Step } from './schema.js';
1
+ /**
2
+ * 大纲(D67,`joplo outline`):不看看板也能检查一个演示“讲给谁、讲什么、讲多久”。只读现有 IR,不新增作者概念:
3
+ * - 功能:goal(解决什么)、roles(给谁,旧的名字数组也算)、cases(PM 的验收条件:维度、优先级、expected = Then)与每个方案的覆盖;
4
+ * - 方案与场景:步数、估算时长(与自动播放同一份 stepDwell)、是否以过渡卡开场 / 收尾、结局、覆盖的情况。
5
+ * 估算按 1× 速度、用 IR 里的英文字幕兜底,不含鼠标移动与逐字输入,所以只是“约”。
6
+ */
7
+ import { type Entry } from './entries.js';
8
+ import type { Coverage, Project, Scenario } from './schema.js';
2
9
  export type OutlineCase = {
3
10
  id: string;
4
11
  key: string;
@@ -25,34 +32,35 @@ export type OutlineScenario = {
25
32
  outcome: Scenario['mock']['outcome'];
26
33
  caseIds: string[];
27
34
  };
28
- export type OutlineOption = {
35
+ export type OutlineWork = {
29
36
  id: string;
30
37
  key: string;
31
- name: string;
38
+ title: string;
32
39
  picked: boolean;
33
40
  ms: number;
34
41
  missing: number;
35
42
  undecided: number;
36
43
  scenarios: OutlineScenario[];
37
44
  };
38
- export type OutlineFeature = {
45
+ export type OutlineEntry = {
46
+ featureId: string | null;
47
+ sequencing: Entry['sequencing'];
48
+ draft: boolean;
39
49
  id: string;
40
- name: string;
41
- goal: string;
50
+ title: string;
51
+ summary: string;
42
52
  roles: string[];
43
53
  pick: string | null;
44
54
  cases: OutlineCase[];
45
- options: OutlineOption[];
55
+ works: OutlineWork[];
46
56
  };
47
57
  export type Outline = {
48
58
  name: string;
49
59
  mode: Project['mode'];
50
- features: OutlineFeature[];
60
+ entries: OutlineEntry[];
51
61
  };
52
- /** 一步停留时要读的文字:说明、explain,过渡卡再加副标题与要点(与看板封面的估算同一口径)。 */
53
- export declare function stepTexts(step: Step): (string | undefined)[];
54
- /** 一个场景按 1× 自动播放大约多久(毫秒):每一步取 hold、阅读停留(stepDwell)与旁白朗读估算(narrate / say)中最长的,再求和。 */
55
- export declare function scenarioEstimateMs(scenario: Pick<Scenario, 'steps'>): number;
62
+ /** 一个场景按 1× 自动播放大约多久(毫秒):每一步的时间计划(stepPlan:操作演示 + 停留与朗读估算中较长者)之和。 */
63
+ export declare function scenarioEstimateMs(project: Pick<Project, 'plugins'>, scenario: Pick<Scenario, 'steps'>): number;
56
64
  export declare function outline(project: Project, opts?: {
57
- optionId?: string;
65
+ workId?: string;
58
66
  }): Outline;
package/dist/outline.js CHANGED
@@ -4,70 +4,65 @@
4
4
  * - 方案与场景:步数、估算时长(与自动播放同一份 stepDwell)、是否以过渡卡开场 / 收尾、结局、覆盖的情况。
5
5
  * 估算按 1× 速度、用 IR 里的英文字幕兜底,不含鼠标移动与逐字输入,所以只是“约”。
6
6
  */
7
- import { orderedFeatures } from "./features.js";
8
- import { holdMsOf } from "./focus.js";
9
- import { streamPlan } from "./player.js";
10
- import { stepDwell, voiceMs } from "./pace.js";
7
+ import { entriesOf, scenariosOf, sliceKey } from "./entries.js";
8
+ import { scenarioPlanMs } from "./step-plan.js";
11
9
  import { JoploError } from "./result.js";
12
- /** 一步停留时要读的文字:说明、explain,过渡卡再加副标题与要点(与看板封面的估算同一口径)。 */
13
- export function stepTexts(step) {
14
- return [step.caption, step.explain, ...(step.action.type === 'card' ? [step.action.sub, ...(step.action.points ?? [])] : [])];
15
- }
16
- /** 一个场景按 1× 自动播放大约多久(毫秒):每一步取 hold、阅读停留(stepDwell)与旁白朗读估算(narrate / say)中最长的,再求和。 */
17
- export function scenarioEstimateMs(scenario) {
18
- return scenario.steps.reduce((sum, step) => sum + Math.max(holdMsOf(step), voiceMs(step.narrate ?? step.say), stepDwell({ texts: stepTexts(step), paced: step.hold !== undefined, cameraMoved: step.shots.length > 0 || !!step.directorLayer, streamMs: Math.max(0, ...streamPlan(step, null).map((x) => x.ms)) })), 0);
10
+ /** 一个场景按 1× 自动播放大约多久(毫秒):每一步的时间计划(stepPlan:操作演示 + 停留与朗读估算中较长者)之和。 */
11
+ export function scenarioEstimateMs(project, scenario) {
12
+ return scenarioPlanMs(project, scenario.steps);
19
13
  }
20
14
  export function outline(project, opts = {}) {
21
- if (opts.optionId && !Object.hasOwn(project.options, opts.optionId))
22
- throw new JoploError('USAGE', `Option does not exist: ${opts.optionId}`);
23
- const only = opts.optionId ? project.options[opts.optionId].featureId : null;
24
- const features = [];
25
- for (const f of orderedFeatures(project)) {
26
- if (only && f.id !== only)
15
+ if (opts.workId && !Object.hasOwn(project.works, opts.workId))
16
+ throw new JoploError('USAGE', `Work does not exist: ${opts.workId}`);
17
+ const only = opts.workId ? project.works[opts.workId].featureId ?? opts.workId : null;
18
+ const entries = [];
19
+ for (const entry of entriesOf(project)) {
20
+ if (only && entry.id !== only)
27
21
  continue;
28
- const optionIds = f.optionIds.filter((id) => project.options[id] && (!opts.optionId || id === opts.optionId));
29
- const cases = f.caseIds.flatMap((cid) => {
22
+ const f = entry.featureId ? project.features[entry.featureId] : undefined;
23
+ const workIds = (f ? f.workIds : entry.workId ? [entry.workId] : []).filter(id => project.works[id] && (!opts.workId || id === opts.workId));
24
+ const cases = (f?.caseIds ?? []).flatMap((cid) => {
30
25
  const c = project.cases[cid];
31
26
  if (!c)
32
27
  return [];
33
28
  const coverage = {};
34
- for (const oid of optionIds) {
35
- const cov = project.options[oid].coverage[cid];
29
+ for (const oid of workIds) {
30
+ const cov = f?.alternatives[oid]?.coverage[cid];
36
31
  if (cov)
37
32
  coverage[oid] = cov.status;
38
33
  }
39
34
  return [{ id: c.id, key: c.id.slice(f.id.length + 1), title: c.title, dimension: c.dimension, priority: c.priority, expected: c.expected, coverage }];
40
35
  });
41
- const options = optionIds.map((oid) => {
42
- const o = project.options[oid];
43
- const scenarios = Object.values(project.scenarios)
44
- .filter((s) => s.optionId === oid)
36
+ const works = workIds.map((oid) => {
37
+ const o = project.works[oid];
38
+ const scenarios = scenariosOf(project, oid)
45
39
  .map((s) => ({
46
40
  id: s.id,
47
- key: s.id.slice(oid.length + 1),
41
+ key: sliceKey(s),
48
42
  name: s.name,
49
43
  description: s.description,
50
44
  steps: s.steps.length,
51
- ms: scenarioEstimateMs(s),
45
+ ms: scenarioEstimateMs(project, s),
52
46
  cards: s.steps.filter((st) => st.action.type === 'card').length,
53
47
  opening: s.steps[0]?.action.type === 'card',
54
48
  ending: s.steps.length > 0 && s.steps.at(-1).action.type === 'card',
55
49
  outcome: s.mock.outcome,
56
50
  caseIds: s.caseIds,
57
51
  }));
58
- const statuses = Object.values(o.coverage).map((c) => c.status);
52
+ const statuses = Object.values(f?.alternatives[oid]?.coverage ?? {}).map((c) => c.status);
59
53
  return {
60
54
  id: oid,
61
55
  key: o.key,
62
- name: o.name,
63
- picked: f.pick === oid,
56
+ title: o.title,
57
+ picked: !f || f.pick === oid,
64
58
  ms: scenarios.reduce((n, s) => n + s.ms, 0),
65
59
  missing: statuses.filter((s) => s === 'missing').length,
66
60
  undecided: statuses.filter((s) => s === 'undecided').length,
67
61
  scenarios,
68
62
  };
69
63
  });
70
- features.push({ id: f.id, name: f.name, goal: f.goal, roles: f.roles.map((r) => r.name), pick: f.pick, cases, options });
64
+ // Entry.workId may be a preview default; a feature decision must preserve its null pick.
65
+ entries.push({ featureId: entry.featureId, sequencing: entry.sequencing, draft: entry.draft, id: entry.id, title: entry.title, summary: entry.summary, roles: entry.roles, pick: f ? f.pick : entry.workId, cases, works });
71
66
  }
72
- return { name: project.name, mode: project.mode, features };
67
+ return { name: project.name, mode: project.mode, entries };
73
68
  }
package/dist/pace.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 自动播放的阅读节奏(T-director2,纯函数):演示页、发布站、视频录制、`joplo outline` 与 check 共用这一份。
3
3
  * - 阅读:说明 + 解说,中文每秒 8 字、拉丁文字每秒 15 个非空白字符,3–7 秒,再按速度缩放;
4
- * - 同时至少等到镜头过渡结束(CAMERA_MS)、本步 active 连线上的小点跑完一圈(dotMs),这两项与速度无关。
4
+ * - 同时至少等到镜头过渡结束(CAMERA_MS)。插件画面里更长的动画(连线上的小点、逐字打代码、片段)由插件效果的 holdMs 声明,不在这里。
5
5
  * 2026-11-06(D67)从 web 的 runtime/pace.ts 搬到 core,web 原地 re-export,数值与行为不变。
6
6
  */
7
7
  export declare const MS_PER_CHAR = 125;
@@ -24,13 +24,12 @@ export declare function readingMs(...texts: (string | null | undefined)[]): numb
24
24
  export declare function rawReadingMs(...texts: (string | null | undefined)[]): number;
25
25
  /**
26
26
  * 这一步提交之后至少停留多久(毫秒)。
27
- * text:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点);dotMs:本步 active 连线上小点跑一圈的最长时间(没有为 0)。
27
+ * texts:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点)。
28
28
  */
29
29
  export declare function stepDwell(o: {
30
30
  texts: (string | null | undefined)[];
31
31
  speed?: number;
32
- cameraMoved?: boolean;
33
- dotMs?: number; /** 本步流式输出的文字(D56):等它们出完再加阅读时间。 */
32
+ cameraMoved?: boolean; /** 本步流式输出的文字(D56):等它们出完再加阅读时间。 */
34
33
  streams?: string[]; /** 已经算好的流式输出时长(1×,见 player 的 streamPlan,D100):给了就用它,不再按 streams 的字数算。 */
35
34
  streamMs?: number; /** 作者写了 hold(D92):节奏由作者掌握,阅读时间不套 3 秒下限(仍按字数)。 */
36
35
  paced?: boolean;
package/dist/pace.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 自动播放的阅读节奏(T-director2,纯函数):演示页、发布站、视频录制、`joplo outline` 与 check 共用这一份。
3
3
  * - 阅读:说明 + 解说,中文每秒 8 字、拉丁文字每秒 15 个非空白字符,3–7 秒,再按速度缩放;
4
- * - 同时至少等到镜头过渡结束(CAMERA_MS)、本步 active 连线上的小点跑完一圈(dotMs),这两项与速度无关。
4
+ * - 同时至少等到镜头过渡结束(CAMERA_MS)。插件画面里更长的动画(连线上的小点、逐字打代码、片段)由插件效果的 holdMs 声明,不在这里。
5
5
  * 2026-11-06(D67)从 web 的 runtime/pace.ts 搬到 core,web 原地 re-export,数值与行为不变。
6
6
  */
7
7
  export const MS_PER_CHAR = 125;
@@ -51,17 +51,16 @@ export function rawReadingMs(...texts) {
51
51
  }
52
52
  /**
53
53
  * 这一步提交之后至少停留多久(毫秒)。
54
- * text:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点);dotMs:本步 active 连线上小点跑一圈的最长时间(没有为 0)。
54
+ * texts:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点)。
55
55
  */
56
56
  export function stepDwell(o) {
57
57
  const speed = o.speed && o.speed > 0 ? o.speed : 1;
58
58
  const read = (o.paced ? rawReadingMs(...o.texts) : readingMs(...o.texts)) / speed;
59
59
  const cam = o.cameraMoved ? CAMERA_MS + SETTLE : 0;
60
- const dots = o.dotMs && o.dotMs > 0 ? o.dotMs + SETTLE : 0;
61
60
  // 流式输出:先等最长的一段出完,再留出读完它的时间(按出完之后再读一遍的一半计)
62
61
  const longest = o.streamMs !== undefined ? Math.round(o.streamMs / speed) : Math.max(0, ...(o.streams ?? []).map((t) => streamMs(t, speed)));
63
62
  const streamed = longest ? longest + Math.max((o.paced ? 0 : MIN_DWELL) / speed, read / 2) : 0;
64
- return Math.round(Math.max(read, cam, dots, streamed));
63
+ return Math.round(Math.max(read, cam, streamed));
65
64
  }
66
65
  /** 朗读估算(旁白 / 台词):中日韩约每秒 4.5 字、拉丁文字约每秒 13 个非空白字符(约 2.5 词),读完再留 0.45 秒换气。 */
67
66
  export const VOICE_CJK_MS = 220;
@@ -0,0 +1,57 @@
1
+ import type { Project, Scenario, SceneNode, Step } from './schema.js';
2
+ import { JoploError, type Diagnostic } from './result.js';
3
+ import { type PlayState } from './scene-query.js';
4
+ export declare function initialState(project: Project, scenarioId: string): PlayState;
5
+ export declare class PlaybackError extends JoploError {
6
+ constructor(message: string, diagnostic: Diagnostic);
7
+ }
8
+ /**
9
+ * 校验当前步骤能否在给定状态下执行;返回诊断(null 表示可执行)。
10
+ * 手动体验时,UI 也用它判断用户点击的是不是“当前步骤的目标”。
11
+ */
12
+ export declare function checkStep(project: Project, scenario: Scenario, state: PlayState, step: Step): Diagnostic | null;
13
+ /** 执行 scenario.steps[state.position],返回新状态(不修改入参)。 */
14
+ export declare function applyStep(project: Project, scenario: Scenario, state: PlayState): PlayState;
15
+ /** 从初始状态重放到指定位置,不读也不写缓存。编译器在 IR 还没定稿(之后还会改场景的初始状态)时用它。 */
16
+ export declare function replayTo(project: Project, scenarioId: string, position: number): PlayState;
17
+ /** 挂在同一条时间线上的派生结果(例如每个位置的镜头):与状态一起缓存、一起作废。 */
18
+ export declare function timelineMemo<T>(project: Project, sc: Scenario, key: string, compute: () => T): T;
19
+ /** 时间线上第 position 步之后的状态(共享对象,调用方不得修改);这一步或之前的步骤回放失败时抛出当时的错误。 */
20
+ export declare function timelineState(project: Project, sc: Scenario, position: number): PlayState;
21
+ /** 第 position 步之后的状态(从时间线缓存取,返回独立副本)。 */
22
+ export declare function stateAt(project: Project, scenarioId: string, position: number): PlayState;
23
+ /** 时间线上每个位置的状态(0..步数);回放失败之后的位置为 null。共享对象,只读。 */
24
+ export declare function timelineStates(project: Project, scenarioId: string): (PlayState | null)[];
25
+ /** 步骤 ID → 该步骤执行之后的位置。 */
26
+ export declare function positionAfterStep(project: Project, scenarioId: string, stepId: string): number;
27
+ /** 完整回放一个场景,收集诊断而不抛出。供校验器使用。 */
28
+ export declare function replay(project: Project, scenarioId: string): {
29
+ finalState: PlayState | null;
30
+ reached: number;
31
+ diagnostics: Diagnostic[];
32
+ };
33
+ export type ClickVerdict = {
34
+ kind: 'advance';
35
+ } | {
36
+ kind: 'disabled';
37
+ reason: string | null;
38
+ } | {
39
+ kind: 'unmodeled';
40
+ label: string;
41
+ } | {
42
+ kind: 'out_of_order';
43
+ label: string;
44
+ expectedCaption: string | null;
45
+ } | {
46
+ kind: 'not_covered';
47
+ label: string;
48
+ } | {
49
+ kind: 'static';
50
+ };
51
+ /** 禁用原因的当前文字:字面量原样返回;绑定(`$ui.x`)读当前状态;空或不是文字时为 null(界面用默认说明)。 */
52
+ export declare function disabledReasonOf(node: SceneNode, state: Pick<PlayState, 'ui' | 'data' | 'inputs'>): string | null;
53
+ /**
54
+ * 演示模式下用户点击了某个元素:判断应推进步骤,还是提示“当前演示未覆盖”(PRD 8.2、AC-19)。
55
+ * 流程外点击绝不能被解释为成功。
56
+ */
57
+ export declare function explainClick(project: Project, state: PlayState, nodeId: string, sceneId?: string): ClickVerdict;