@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.
- package/dist/agent-skill.d.ts +7 -7
- package/dist/agent-skill.js +28 -25
- package/dist/authoring-works.d.ts +8 -0
- package/dist/authoring-works.js +46 -0
- package/dist/catalog.d.ts +2 -0
- package/dist/compile.d.ts +6 -3
- package/dist/compile.js +415 -340
- package/dist/content-i18n.js +9 -9
- package/dist/embed.d.ts +5 -5
- package/dist/embed.js +7 -7
- package/dist/entries.d.ts +63 -0
- package/dist/entries.js +78 -0
- package/dist/feature-diff.d.ts +7 -7
- package/dist/feature-diff.js +18 -17
- package/dist/features.d.ts +3 -3
- package/dist/features.js +3 -3
- package/dist/focus-check.js +2 -2
- package/dist/focus.d.ts +1 -5
- package/dist/focus.js +13 -35
- package/dist/guide.js +156 -66
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/load.js +42 -11
- package/dist/local-review-files.js +17 -4
- package/dist/local-review.d.ts +8 -7
- package/dist/local-review.js +7 -6
- package/dist/outline.d.ts +21 -13
- package/dist/outline.js +27 -32
- package/dist/pace.d.ts +3 -4
- package/dist/pace.js +3 -4
- package/dist/playback.d.ts +57 -0
- package/dist/playback.js +317 -0
- package/dist/player.d.ts +9 -195
- package/dist/player.js +8 -633
- package/dist/playground.d.ts +1 -1
- package/dist/playground.js +4 -4
- package/dist/plugins/compiler.d.ts +16 -0
- package/dist/plugins/compiler.js +48 -9
- package/dist/presentation.d.ts +73 -0
- package/dist/presentation.js +163 -0
- package/dist/publication.d.ts +8 -0
- package/dist/publication.js +45 -0
- package/dist/result.d.ts +1 -1
- package/dist/review.d.ts +18 -10
- package/dist/review.js +62 -23
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -0
- package/dist/scene-query.d.ts +77 -0
- package/dist/scene-query.js +246 -0
- package/dist/schema-issues.js +1 -1
- package/dist/schema.d.ts +108 -76
- package/dist/schema.js +48 -36
- package/dist/scope.d.ts +9 -9
- package/dist/scope.js +82 -49
- package/dist/selection.d.ts +1 -1
- package/dist/sequencing.d.ts +6 -0
- package/dist/sequencing.js +21 -0
- package/dist/step-plan.d.ts +55 -0
- package/dist/step-plan.js +90 -0
- package/dist/traits.d.ts +10 -0
- package/dist/traits.js +3 -0
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +75 -65
- package/dist/voice.js +2 -1
- package/package.json +15 -3
package/dist/content-i18n.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { INTERNAL_BLANK_TITLE } from "./entries.js";
|
|
1
2
|
import { pluginActionSpec } from "./actions.js";
|
|
2
3
|
import { pluginSpec } from "./catalog.js";
|
|
3
4
|
import { mapSlotTexts, mapTextPaths } from "./plugin-data.js";
|
|
@@ -127,23 +128,22 @@ function mapScenario(sc, visit, plugins) {
|
|
|
127
128
|
}
|
|
128
129
|
/** 对 IR 里所有作者内容字符串调用 visit,返回替换后的新 IR(不改原对象)。 */
|
|
129
130
|
function mapProject(p, visit) {
|
|
130
|
-
//
|
|
131
|
+
// 不完整的待校验输入或测试输入原样保留,不补空对象
|
|
131
132
|
const obj = (o, f) => (o ? Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)])) : o);
|
|
132
133
|
const arr = (a, f) => (a ? a.map(f) : a);
|
|
133
134
|
return {
|
|
134
135
|
...p,
|
|
135
136
|
name: visit(p.name, 'text'),
|
|
136
137
|
description: t(p.description, visit) ?? '',
|
|
137
|
-
routes: obj(p.routes, (r) => ({ ...r, title: visit(r.title, 'text', r.source) })),
|
|
138
|
-
features: obj(p.features, (f) => ({ ...f, name: visit(f.name, 'text', f.source), goal: visit(f.goal, 'text', f.source), roles: arr(f.roles, (r) => ({ ...r, name: visit(r.name, 'text', f.source), ...(r.desc ? { desc: visit(r.desc, 'text', f.source) } : {}) })), constraints: arr(f.constraints, (c) => ({ ...c, text: visit(c.text, 'text', f.source) })) })),
|
|
139
|
-
|
|
138
|
+
routes: obj(p.routes, (r) => ({ ...r, title: r.title === INTERNAL_BLANK_TITLE ? r.title : visit(r.title, 'text', r.source) })),
|
|
139
|
+
features: obj(p.features, (f) => ({ ...f, name: visit(f.name, 'text', f.source), goal: visit(f.goal, 'text', f.source), roles: arr(f.roles, (r) => ({ ...r, name: visit(r.name, 'text', f.source), ...(r.desc ? { desc: visit(r.desc, 'text', f.source) } : {}) })), alternatives: obj(f.alternatives, a => ({ ...a, decisionFocus: t(a.decisionFocus, visit, f.source) ?? '', tradeoffs: arr(a.tradeoffs, x => visit(x, 'text', f.source)), coverage: obj(a.coverage, c => c.reason ? { ...c, reason: visit(c.reason, 'text', f.source) } : c) })), constraints: arr(f.constraints, (c) => ({ ...c, text: visit(c.text, 'text', f.source) })) })),
|
|
140
|
+
works: obj(p.works, (o) => ({
|
|
140
141
|
...o,
|
|
141
142
|
...(o.free ? { free: obj(o.free, r => ({ ...r, action: mapAction(r.action, visit, p.plugins, r.source), effects: mapEffects(r.effects, visit, r.source) })) } : {}),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
...(o.
|
|
145
|
-
|
|
146
|
-
coverage: obj(o.coverage, (c) => (c.reason ? { ...c, reason: visit(c.reason, 'text', o.source) } : c)),
|
|
143
|
+
title: visit(o.title, 'text', o.source),
|
|
144
|
+
summary: visit(o.summary, 'text', o.source),
|
|
145
|
+
...(o.audience !== undefined ? { audience: visit(o.audience, 'text', o.source) } : {}),
|
|
146
|
+
roles: arr(o.roles, r => ({ ...r, name: visit(r.name, 'text', o.source), ...(r.desc ? { desc: visit(r.desc, 'text', o.source) } : {}) })),
|
|
147
147
|
layers: obj(o.layers, (l) => ({ ...l, title: visit(l.title, 'text', o.source) })),
|
|
148
148
|
})),
|
|
149
149
|
// 创作侧信息(看板与评审里显示;发布站不带,所以发布 IR 里收不到也不带译文)
|
package/dist/embed.d.ts
CHANGED
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
* - 可播放的场景:按功能在 IR 里的顺序,每个功能的选定方案(没有选定时用第一个方案)的场景,按场景在 IR 里的顺序;
|
|
5
5
|
* - 默认场景是其中第一个;`scenario` 参数指向列表里的场景时从它开始,写错(不存在、为空、不是字符串)时退回默认,不报错。
|
|
6
6
|
*
|
|
7
|
-
* 只读 features /
|
|
7
|
+
* 只读 features / works / scenarios 的少量字段,所以既能用于完整 IR,也能用于发布站内联的发布 IR。
|
|
8
8
|
*/
|
|
9
9
|
type EmbedProject = {
|
|
10
|
-
|
|
10
|
+
entryIds: readonly string[];
|
|
11
11
|
features: Record<string, {
|
|
12
12
|
id: string;
|
|
13
|
-
|
|
13
|
+
workIds: readonly string[];
|
|
14
14
|
pick?: string | null;
|
|
15
15
|
}>;
|
|
16
|
-
|
|
16
|
+
works: Record<string, {
|
|
17
17
|
id: string;
|
|
18
18
|
}>;
|
|
19
19
|
scenarios: Record<string, {
|
|
20
20
|
id: string;
|
|
21
|
-
|
|
21
|
+
workId: string;
|
|
22
22
|
}>;
|
|
23
23
|
};
|
|
24
24
|
/** 嵌入模式里可以播放和切换的场景 ID(有序、不重复)。 */
|
package/dist/embed.js
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
* - 可播放的场景:按功能在 IR 里的顺序,每个功能的选定方案(没有选定时用第一个方案)的场景,按场景在 IR 里的顺序;
|
|
5
5
|
* - 默认场景是其中第一个;`scenario` 参数指向列表里的场景时从它开始,写错(不存在、为空、不是字符串)时退回默认,不报错。
|
|
6
6
|
*
|
|
7
|
-
* 只读 features /
|
|
7
|
+
* 只读 features / works / scenarios 的少量字段,所以既能用于完整 IR,也能用于发布站内联的发布 IR。
|
|
8
8
|
*/
|
|
9
|
-
import { orderedFeatures } from "./features.js";
|
|
10
9
|
/** 嵌入模式里可以播放和切换的场景 ID(有序、不重复)。 */
|
|
11
10
|
export function embedScenarioIds(project) {
|
|
12
11
|
const ids = [];
|
|
13
12
|
const scenarios = Object.values(project.scenarios ?? {});
|
|
14
|
-
for (const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
13
|
+
for (const id of project.entryIds) {
|
|
14
|
+
const f = project.features[id];
|
|
15
|
+
const workIds = (f?.workIds ?? []).filter((id) => project.works?.[id]);
|
|
16
|
+
const workId = !f ? project.works[id]?.id : f.pick && project.works[f.pick] ? f.pick : workIds[0];
|
|
17
|
+
if (!workId)
|
|
18
18
|
continue;
|
|
19
19
|
for (const s of scenarios)
|
|
20
|
-
if (s.
|
|
20
|
+
if (s.workId === workId && !ids.includes(s.id))
|
|
21
21
|
ids.push(s.id);
|
|
22
22
|
}
|
|
23
23
|
return ids;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Project, Scenario } from './schema.js';
|
|
2
|
+
/** 作品里可以单独打开的一段:功能演示的场景、影片的章节。 */
|
|
3
|
+
export type EntrySlice = {
|
|
4
|
+
/** 场景 id(深链、分享、导出都用它)。 */
|
|
5
|
+
id: string;
|
|
6
|
+
/** 作者写的键(场景键 / 章节键)。 */
|
|
7
|
+
key: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
steps: number;
|
|
11
|
+
/** 按 1× 自动播放的估算时长(毫秒,stepPlan 之和)。 */
|
|
12
|
+
ms: number;
|
|
13
|
+
/** 是否在连续播放的顺序里(autoplay: false 的支线不在)。 */
|
|
14
|
+
inSequence: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Entry = {
|
|
17
|
+
/** 功能 id 或独立作品 id。 */
|
|
18
|
+
id: string;
|
|
19
|
+
/** 功能所属 id;独立作品为 null,不从情况或方案数量推断。 */
|
|
20
|
+
featureId: string | null;
|
|
21
|
+
/** 播放用作品的切片接续能力,与是否挂功能相互独立。 */
|
|
22
|
+
sequencing: 'independent' | 'linear';
|
|
23
|
+
title: string;
|
|
24
|
+
/** 一句话简介:功能演示是目标(goal),影片是 summary。 */
|
|
25
|
+
summary: string;
|
|
26
|
+
/** 给谁看的一句话:影片的 audience;没写时为 null。 */
|
|
27
|
+
audience: string | null;
|
|
28
|
+
/** 角色的名字(去重,按声明顺序):功能演示用它表达“面向谁”,影片里是出场说话的人。界面按自己的语言连接。 */
|
|
29
|
+
roles: string[];
|
|
30
|
+
/** 草稿:不进发布与分享。 */
|
|
31
|
+
draft: boolean;
|
|
32
|
+
/** 播放用的作品:独立作品是自身;功能演示是选定的方案,没有选定时取第一个;没有方案时为 null。 */
|
|
33
|
+
workId: string | null;
|
|
34
|
+
/** 切片:先是连续播放顺序里的(playSequence),再是不在顺序里的支线,各自按声明顺序。 */
|
|
35
|
+
slices: EntrySlice[];
|
|
36
|
+
/** 连续播放顺序里各切片的时长之和(毫秒)。 */
|
|
37
|
+
ms: number;
|
|
38
|
+
};
|
|
39
|
+
/** 某个方案的场景,按声明顺序。 */
|
|
40
|
+
export declare const scenariosOf: (project: Pick<Project, "scenarios">, workId: string | null | undefined) => Scenario[];
|
|
41
|
+
/**
|
|
42
|
+
* 连续播放的顺序(D92 U2 / R9;看板、发布站、嵌入与录制 --chain 共用):按声明顺序取不接力的场景(根),每个根之后
|
|
43
|
+
* 深度优先接上 from 接力它的章(多章接同一章时按声明顺序)。autoplay: false 的场景连同接在它后面的章都不进顺序。
|
|
44
|
+
*/
|
|
45
|
+
export declare function playSequence(project: Pick<Project, 'scenarios'>, workId: string | null | undefined): Scenario[];
|
|
46
|
+
/** 合成空白页的非显示内部标记;路径列表与翻译必须过滤它。 */
|
|
47
|
+
export declare const INTERNAL_BLANK_TITLE = "__joplo_internal_blank__";
|
|
48
|
+
export declare const visibleRoutes: (project: Pick<Project, "routes">) => {
|
|
49
|
+
path: string;
|
|
50
|
+
title: string;
|
|
51
|
+
layout: string | null;
|
|
52
|
+
slots: string[];
|
|
53
|
+
addedBy?: string | undefined;
|
|
54
|
+
source?: string | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
/** 唯一的角色读取入口:功能下的作品继承功能角色。 */
|
|
57
|
+
export declare function rolesOf(project: Pick<Project, 'works' | 'features'>, workId: string | null | undefined): Project['features'][string]['roles'];
|
|
58
|
+
/** 切片键只在此处由已知 workId 的长度计算;不拆 ID 推断归属。 */
|
|
59
|
+
export declare const sliceKey: (scenario: Pick<Scenario, "id" | "workId">) => string;
|
|
60
|
+
/** 一个首页条目的投影。 */
|
|
61
|
+
export declare function entryOf(project: Project, id: string | null | undefined): Entry | null;
|
|
62
|
+
/** 项目里的全部作品,按演示顺序(entryIds)。首页的卡片、看板顶栏的下拉、outline 都从这里取。 */
|
|
63
|
+
export declare function entriesOf(project: Project): Entry[];
|
package/dist/entries.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** 首页条目:外部只读此投影,作品可独立存在或挂在功能下面。 */
|
|
2
|
+
import { scenarioPlanMs } from "./step-plan.js";
|
|
3
|
+
/** 某个方案的场景,按声明顺序。 */
|
|
4
|
+
export const scenariosOf = (project, workId) => workId ? Object.values(project.scenarios).filter((s) => s.workId === workId) : [];
|
|
5
|
+
/**
|
|
6
|
+
* 连续播放的顺序(D92 U2 / R9;看板、发布站、嵌入与录制 --chain 共用):按声明顺序取不接力的场景(根),每个根之后
|
|
7
|
+
* 深度优先接上 from 接力它的章(多章接同一章时按声明顺序)。autoplay: false 的场景连同接在它后面的章都不进顺序。
|
|
8
|
+
*/
|
|
9
|
+
export function playSequence(project, workId) {
|
|
10
|
+
const all = scenariosOf(project, workId);
|
|
11
|
+
const ids = new Set(all.map((s) => s.id));
|
|
12
|
+
const out = [];
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
const visit = (s) => {
|
|
15
|
+
if (seen.has(s.id) || s.autoplay === false)
|
|
16
|
+
return;
|
|
17
|
+
seen.add(s.id);
|
|
18
|
+
out.push(s);
|
|
19
|
+
for (const child of all)
|
|
20
|
+
if (child.from === s.id)
|
|
21
|
+
visit(child);
|
|
22
|
+
};
|
|
23
|
+
for (const s of all)
|
|
24
|
+
if (!s.from || !ids.has(s.from))
|
|
25
|
+
visit(s);
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** 合成空白页的非显示内部标记;路径列表与翻译必须过滤它。 */
|
|
29
|
+
export const INTERNAL_BLANK_TITLE = '__joplo_internal_blank__';
|
|
30
|
+
export const visibleRoutes = (project) => Object.values(project.routes).filter(r => r.title !== INTERNAL_BLANK_TITLE);
|
|
31
|
+
/** 唯一的角色读取入口:功能下的作品继承功能角色。 */
|
|
32
|
+
export function rolesOf(project, workId) {
|
|
33
|
+
const w = workId ? project.works[workId] : undefined;
|
|
34
|
+
return w ? (w.featureId ? project.features[w.featureId]?.roles ?? [] : w.roles) : [];
|
|
35
|
+
}
|
|
36
|
+
/** 切片键只在此处由已知 workId 的长度计算;不拆 ID 推断归属。 */
|
|
37
|
+
export const sliceKey = (scenario) => scenario.id.slice(scenario.workId.length + 1);
|
|
38
|
+
/** 一个首页条目的投影。 */
|
|
39
|
+
export function entryOf(project, id) {
|
|
40
|
+
if (!id)
|
|
41
|
+
return null;
|
|
42
|
+
const f = project.features[id];
|
|
43
|
+
const w = project.works[id];
|
|
44
|
+
if (!f && (!w || w.featureId))
|
|
45
|
+
return null;
|
|
46
|
+
const workId = f ? (f.pick && project.works[f.pick] ? f.pick : f.workIds.find(id => project.works[id])) ?? null : id;
|
|
47
|
+
const active = workId ? project.works[workId] : undefined;
|
|
48
|
+
const sequence = playSequence(project, workId);
|
|
49
|
+
const inSequence = new Set(sequence.map((s) => s.id));
|
|
50
|
+
const ordered = [...sequence, ...scenariosOf(project, workId).filter((s) => !inSequence.has(s.id))];
|
|
51
|
+
const slices = ordered.map((s) => ({
|
|
52
|
+
id: s.id,
|
|
53
|
+
key: sliceKey(s),
|
|
54
|
+
title: s.name,
|
|
55
|
+
description: s.description,
|
|
56
|
+
steps: s.steps.length,
|
|
57
|
+
ms: scenarioPlanMs(project, s.steps),
|
|
58
|
+
inSequence: inSequence.has(s.id),
|
|
59
|
+
}));
|
|
60
|
+
const roles = (f ? f.roles : rolesOf(project, workId)).map((r) => r.name.trim()).filter(Boolean);
|
|
61
|
+
return {
|
|
62
|
+
id,
|
|
63
|
+
featureId: f?.id ?? null,
|
|
64
|
+
sequencing: active?.sequencing ?? 'independent',
|
|
65
|
+
title: f ? f.name : w.title,
|
|
66
|
+
summary: f ? f.goal : w.summary,
|
|
67
|
+
audience: w?.audience?.trim() || null,
|
|
68
|
+
roles: [...new Set(roles)],
|
|
69
|
+
draft: w?.draft === true,
|
|
70
|
+
workId,
|
|
71
|
+
slices,
|
|
72
|
+
ms: slices.reduce((sum, s) => sum + (s.inSequence ? s.ms : 0), 0),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** 项目里的全部作品,按演示顺序(entryIds)。首页的卡片、看板顶栏的下拉、outline 都从这里取。 */
|
|
76
|
+
export function entriesOf(project) {
|
|
77
|
+
return project.entryIds.map(id => entryOf(project, id)).filter(Boolean);
|
|
78
|
+
}
|
package/dist/feature-diff.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare const DiffStep: z.ZodObject<{
|
|
|
35
35
|
reasons: z.ZodArray<z.ZodString>;
|
|
36
36
|
results: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
37
|
kind: z.ZodEnum<{
|
|
38
|
-
state: "state";
|
|
39
38
|
outcome: "outcome";
|
|
39
|
+
state: "state";
|
|
40
40
|
message: "message";
|
|
41
41
|
}>;
|
|
42
42
|
label: z.ZodString;
|
|
@@ -45,8 +45,8 @@ export declare const DiffStep: z.ZodObject<{
|
|
|
45
45
|
}, z.core.$strict>>>;
|
|
46
46
|
}, z.core.$strict>;
|
|
47
47
|
export declare const DiffScenario: z.ZodObject<{
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
entryId: z.ZodString;
|
|
49
|
+
entryTitle: z.ZodString;
|
|
50
50
|
name: z.ZodString;
|
|
51
51
|
before: z.ZodNullable<z.ZodString>;
|
|
52
52
|
after: z.ZodNullable<z.ZodString>;
|
|
@@ -88,8 +88,8 @@ export declare const DiffScenario: z.ZodObject<{
|
|
|
88
88
|
reasons: z.ZodArray<z.ZodString>;
|
|
89
89
|
results: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
90
|
kind: z.ZodEnum<{
|
|
91
|
-
state: "state";
|
|
92
91
|
outcome: "outcome";
|
|
92
|
+
state: "state";
|
|
93
93
|
message: "message";
|
|
94
94
|
}>;
|
|
95
95
|
label: z.ZodString;
|
|
@@ -120,8 +120,8 @@ export declare const FeatureDiffManifest: z.ZodObject<{
|
|
|
120
120
|
removed: z.ZodArray<z.ZodString>;
|
|
121
121
|
}, z.core.$strict>;
|
|
122
122
|
scenarios: z.ZodArray<z.ZodObject<{
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
entryId: z.ZodString;
|
|
124
|
+
entryTitle: z.ZodString;
|
|
125
125
|
name: z.ZodString;
|
|
126
126
|
before: z.ZodNullable<z.ZodString>;
|
|
127
127
|
after: z.ZodNullable<z.ZodString>;
|
|
@@ -163,8 +163,8 @@ export declare const FeatureDiffManifest: z.ZodObject<{
|
|
|
163
163
|
reasons: z.ZodArray<z.ZodString>;
|
|
164
164
|
results: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
165
165
|
kind: z.ZodEnum<{
|
|
166
|
-
state: "state";
|
|
167
166
|
outcome: "outcome";
|
|
167
|
+
state: "state";
|
|
168
168
|
message: "message";
|
|
169
169
|
}>;
|
|
170
170
|
label: z.ZodString;
|
package/dist/feature-diff.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { entryOf, rolesOf } from "./entries.js";
|
|
1
2
|
import { projectThemes } from "./themes.js";
|
|
2
3
|
import { jsonData } from "./plugins/data.js";
|
|
3
4
|
/** Public feature comparison. Positional ids are addresses, never cross-version identities. */
|
|
4
5
|
import { z } from 'zod';
|
|
5
|
-
import { Project } from "./schema.js";
|
|
6
|
+
import { Project, SCHEMA_VERSION } from "./schema.js";
|
|
6
7
|
import { JoploError } from "./result.js";
|
|
7
8
|
export const GitSha = z.string().regex(/^[a-f0-9]{40}$/);
|
|
8
9
|
export const DiffSource = z.strictObject({ sha: GitSha.nullable() });
|
|
@@ -20,7 +21,7 @@ export const DiffStep = z.strictObject({
|
|
|
20
21
|
results: z.array(Result).max(12).optional(),
|
|
21
22
|
});
|
|
22
23
|
export const DiffScenario = z.strictObject({
|
|
23
|
-
|
|
24
|
+
entryId: z.string(), entryTitle: z.string(), name: z.string(),
|
|
24
25
|
before: z.string().nullable(), after: z.string().nullable(), status: Status,
|
|
25
26
|
reasons: z.array(z.string()), steps: z.array(DiffStep),
|
|
26
27
|
});
|
|
@@ -181,13 +182,13 @@ export function readPublicProject(value) {
|
|
|
181
182
|
const nodePrivate = (n) => n.source !== undefined || n.note !== undefined || (n.children ?? []).some(nodePrivate);
|
|
182
183
|
if (Object.keys(p.rules).length || Object.keys(p.cases).length || Object.keys(p.issues).length || p.voiceConfig ||
|
|
183
184
|
Object.values(p.routes).some(r => r.source) || Object.values(p.scenes).some(s => nodePrivate(s.root)) ||
|
|
184
|
-
Object.values(p.features).some(f => f.source || f.constraints.length || f.caseIds.length) ||
|
|
185
|
-
Object.values(p.
|
|
185
|
+
Object.values(p.features).some(f => f.source || f.constraints.length || f.caseIds.length || Object.values(f.alternatives).some(a => a.decisionFocus || a.tradeoffs.length || Object.keys(a.coverage).length)) ||
|
|
186
|
+
Object.values(p.works).some(o => o.source || o.draft) ||
|
|
186
187
|
Object.values(p.scenarios).some(s => s.source || s.caseIds.length || s.steps.some(st => st.source || st.ruleIds.length)))
|
|
187
188
|
throw new JoploError('INVALID_SCHEMA', 'Private authoring data found; rebuild both sites with joplo build');
|
|
188
189
|
for (const [id, sc] of Object.entries(p.scenarios)) {
|
|
189
|
-
const op = p.
|
|
190
|
-
if (sc.id !== id || !op || !p.features[op.featureId] || !p.scenes[sc.initial.sceneId] ||
|
|
190
|
+
const op = p.works[sc.workId];
|
|
191
|
+
if (sc.id !== id || !op || (op.featureId && !p.features[op.featureId]) || !p.scenes[sc.initial.sceneId] ||
|
|
191
192
|
Object.values(op.layers).some(l => !p.scenes[l.sceneId]) ||
|
|
192
193
|
sc.steps.some(st => st.effects.some(e => e.type === 'navigate' && !p.scenes[e.sceneId])) ||
|
|
193
194
|
new Set(sc.steps.map(st => st.id)).size !== sc.steps.length)
|
|
@@ -196,7 +197,7 @@ export function readPublicProject(value) {
|
|
|
196
197
|
return p;
|
|
197
198
|
}
|
|
198
199
|
function sceneInputs(p, s) {
|
|
199
|
-
const ids = new Set([s.initial.sceneId, ...Object.values(p.
|
|
200
|
+
const ids = new Set([s.initial.sceneId, ...Object.values(p.works[s.workId]?.layers ?? {}).map(l => l.sceneId)]);
|
|
200
201
|
for (const st of s.steps)
|
|
201
202
|
for (const e of st.effects)
|
|
202
203
|
if (e.type === 'navigate')
|
|
@@ -204,7 +205,7 @@ function sceneInputs(p, s) {
|
|
|
204
205
|
return [...ids].sort().map(id => p.scenes[id] ?? { missing: id });
|
|
205
206
|
}
|
|
206
207
|
function actionContracts(p, s) {
|
|
207
|
-
const actions = [...s.steps.map(st => st.action), ...Object.values(p.
|
|
208
|
+
const actions = [...s.steps.map(st => st.action), ...Object.values(p.works[s.workId]?.free ?? {}).map(r => r.action)];
|
|
208
209
|
const names = [...new Set(actions.flatMap(a => a.type === 'plugin' ? [a.name] : []))].sort();
|
|
209
210
|
return names.map(name => { const [id, key] = name.split(':'); return [name, p.plugins?.[id]?.actions?.[key]]; });
|
|
210
211
|
}
|
|
@@ -213,25 +214,25 @@ export function featureDiff(before, after, source = {}) {
|
|
|
213
214
|
throw new JoploError('USAGE', 'Source SHAs must be normalized 40-character hexadecimal git commits');
|
|
214
215
|
const base = DiffSource.parse({ sha: source.baseSha ?? null }), head = DiffSource.parse({ sha: source.headSha ?? null });
|
|
215
216
|
const result = { formatVersion: 1, kind: 'joplo-feature-diff', base, head, status: 'unchanged', reasons: [], summary: { added: [], modified: [], removed: [] }, scenarios: [] };
|
|
216
|
-
if (before?.schemaVersion !==
|
|
217
|
+
if (before?.schemaVersion !== SCHEMA_VERSION || after?.schemaVersion !== SCHEMA_VERSION)
|
|
217
218
|
return { ...result, status: 'incompatible', reasons: ['schema-version'] };
|
|
218
219
|
const b = readPublicProject(before), a = readPublicProject(after);
|
|
219
220
|
for (const id of new Set([...Object.keys(a.scenarios), ...Object.keys(b.scenarios)])) {
|
|
220
221
|
const old = b.scenarios[id], next = a.scenarios[id], s = next ?? old, p = next ? a : b;
|
|
221
|
-
const
|
|
222
|
+
const work = p.works[s.workId], feature = entryOf(p, work?.featureId ?? work?.id);
|
|
222
223
|
if (!feature)
|
|
223
224
|
throw new JoploError('INVALID_SCHEMA', 'Scenario references a missing public feature');
|
|
224
225
|
const steps = compareSteps(old?.steps ?? [], next?.steps ?? []), reasons = [];
|
|
225
226
|
let status = !old ? 'added' : !next ? 'removed' : 'unchanged';
|
|
226
227
|
if (old && next) {
|
|
227
|
-
const bo = b.
|
|
228
|
+
const bo = b.works[old.workId], bf = entryOf(b, bo?.featureId ?? bo?.id);
|
|
228
229
|
if (canonical([old.initial, old.ext]) !== canonical([next.initial, next.ext]))
|
|
229
230
|
reasons.push('initial-state');
|
|
230
231
|
if (canonical(sceneInputs(b, old)) !== canonical(sceneInputs(a, next)))
|
|
231
232
|
reasons.push('scenes');
|
|
232
233
|
if (canonical([b.theme, projectThemes(b), b.autoFocus]) !== canonical([a.theme, projectThemes(a), a.autoFocus]))
|
|
233
234
|
reasons.push('theme');
|
|
234
|
-
if (canonical(bo?.free) !== canonical(
|
|
235
|
+
if (canonical(bo?.free) !== canonical(work?.free))
|
|
235
236
|
reasons.push('free-reactions');
|
|
236
237
|
if ((old.actionEntry ?? 'before') !== (next.actionEntry ?? 'before'))
|
|
237
238
|
reasons.push('action-entry');
|
|
@@ -239,19 +240,19 @@ export function featureDiff(before, after, source = {}) {
|
|
|
239
240
|
reasons.push('autoplay');
|
|
240
241
|
if (canonical(actionContracts(b, old)) !== canonical(actionContracts(a, next)))
|
|
241
242
|
reasons.push('action-contracts');
|
|
242
|
-
if (canonical([bo?.layers,
|
|
243
|
+
if (canonical([bo?.layers, rolesOf(b, old.workId)]) !== canonical([work?.layers, rolesOf(a, next.workId)]))
|
|
243
244
|
reasons.push('layers-roles');
|
|
244
|
-
if (canonical([old.name, old.description, old.expected, old.mock, bf?.
|
|
245
|
+
if (canonical([old.name, old.description, old.expected, old.mock, bf?.title, bf?.summary, bo?.title, bo?.summary]) !== canonical([next.name, next.description, next.expected, next.mock, feature.title, feature.summary, work?.title, work?.summary]))
|
|
245
246
|
reasons.push('description');
|
|
246
247
|
status = steps.some(st => st.status === 'uncertain') ? 'uncertain' : reasons.length || steps.some(st => st.status !== 'unchanged') ? 'modified' : 'unchanged';
|
|
247
248
|
}
|
|
248
|
-
result.scenarios.push({
|
|
249
|
+
result.scenarios.push({ entryId: feature.id, entryTitle: feature.title, name: s.name, before: old?.id ?? null, after: next?.id ?? null, status, reasons, steps });
|
|
249
250
|
const group = status === 'uncertain' ? 'modified' : status;
|
|
250
251
|
if (group !== 'unchanged' && result.summary[group].length < 100)
|
|
251
|
-
result.summary[group].push(`${feature.
|
|
252
|
+
result.summary[group].push(`${feature.title} / ${s.name}`.slice(0, 200));
|
|
252
253
|
}
|
|
253
254
|
// Project metadata / unused shared scenes still changed even when no scenario can display it.
|
|
254
|
-
if (canonical([b.name, b.description, b.features, b.
|
|
255
|
+
if (canonical([b.name, b.description, b.features, b.works, b.scenes, b.theme, projectThemes(b), b.routes, b.entryIds, b.autoFocus]) !== canonical([a.name, a.description, a.features, a.works, a.scenes, a.theme, projectThemes(a), a.routes, a.entryIds, a.autoFocus]))
|
|
255
256
|
result.reasons.push('project-presentation');
|
|
256
257
|
result.status = result.scenarios.some(s => s.status === 'uncertain') ? 'uncertain' : result.reasons.length || result.scenarios.some(s => s.status !== 'unchanged') ? 'changed' : 'unchanged';
|
|
257
258
|
return FeatureDiffManifest.parse(result);
|
package/dist/features.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare function
|
|
1
|
+
/** 按首页条目顺序读取真正的功能,作品由 entries.ts 投影。 */
|
|
2
|
+
export declare function featuresOf<T>(project: {
|
|
3
3
|
features: Record<string, T>;
|
|
4
|
-
|
|
4
|
+
entryIds: readonly string[];
|
|
5
5
|
}): T[];
|
package/dist/features.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export function
|
|
3
|
-
return
|
|
1
|
+
/** 按首页条目顺序读取真正的功能,作品由 entries.ts 投影。 */
|
|
2
|
+
export function featuresOf(project) {
|
|
3
|
+
return project.entryIds.map(id => project.features[id]).filter((f) => f !== undefined);
|
|
4
4
|
}
|
package/dist/focus-check.js
CHANGED
|
@@ -17,7 +17,7 @@ export function focusStructureDiagnostics(p, scenarios, emit) {
|
|
|
17
17
|
const sceneOfLayer = (lk) => p.scenes[layers.find((l) => l.id === lk)?.sceneId ?? ''];
|
|
18
18
|
sc.steps.forEach((st, i) => {
|
|
19
19
|
const at = st.source ?? sc.source;
|
|
20
|
-
const ref = { kind: 'step', id: st.id,
|
|
20
|
+
const ref = { kind: 'step', id: st.id, workId: sc.workId, stepId: st.id };
|
|
21
21
|
for (const c of st.callouts ?? []) {
|
|
22
22
|
const n = captionLength(c.text);
|
|
23
23
|
if (n > CAPTION_MAX)
|
|
@@ -64,7 +64,7 @@ export function focusReplayDiagnostics(p, sc, emit) {
|
|
|
64
64
|
const flush = () => {
|
|
65
65
|
if (run.length >= FOCUS_IDLE_RUN) {
|
|
66
66
|
const first = sc.steps[run[0]];
|
|
67
|
-
emit('info', 'FOCUS_IDLE', `${run.length} system steps in a row (${run.map((i) => i + 1).join(', ')}) change nothing on stage, so viewers only read captions. Merge them into one step, or show what happens: shot / highlight / callout the element, or set() state that the stage displays`, first.source ?? sc.source, { kind: 'step', id: first.id,
|
|
67
|
+
emit('info', 'FOCUS_IDLE', `${run.length} system steps in a row (${run.map((i) => i + 1).join(', ')}) change nothing on stage, so viewers only read captions. Merge them into one step, or show what happens: shot / highlight / callout the element, or set() state that the stage displays`, first.source ?? sc.source, { kind: 'step', id: first.id, workId: sc.workId, stepId: first.id });
|
|
68
68
|
}
|
|
69
69
|
run = [];
|
|
70
70
|
};
|
package/dist/focus.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PlayState } from './player.js';
|
|
2
|
-
import type { Callout, Project, Scene, SceneNode
|
|
2
|
+
import type { Callout, Project, Scene, SceneNode } from './schema.js';
|
|
3
3
|
export declare const HOLD_MIN_SECONDS = 0.5;
|
|
4
4
|
export declare const HOLD_MAX_SECONDS = 30;
|
|
5
5
|
/** 默认揭晓最多提示几处;更多时不提示。 */
|
|
@@ -47,8 +47,4 @@ export declare function inShotFrame(root: SceneNode, id: string, frameTargets: r
|
|
|
47
47
|
* 返回新对象,调用方可以随意修改。
|
|
48
48
|
*/
|
|
49
49
|
export declare function focusAt(project: Project, scenarioId: string | null | undefined, position: number): FocusState;
|
|
50
|
-
/** 自动播放时这一步至少停留多久(毫秒,已按速度缩放;0 = 没写 hold)。 */
|
|
51
|
-
export declare function holdMsOf(step: Pick<Step, 'hold' | 'effectHold'> | undefined, speed?: number): number;
|
|
52
|
-
/** 媒体锚点(配乐跳转、接力)按每步推进的时长:作者 hold(缺省 3000)与效果时长(D98)取较大值,未按速度缩放。 */
|
|
53
|
-
export declare function stepAnchorMs(step: Pick<Step, 'hold' | 'effectHold'>): number;
|
|
54
50
|
export {};
|
package/dist/focus.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* config({ autoFocus: false }) 关掉默认呈现(reveal 恒为空);焦点对象仍照常推导,check 用它判断“长时间没有焦点”。
|
|
20
20
|
*/
|
|
21
21
|
import { DIRECTOR_LAYER, PAGE_LAYER, childWidth, pluginSpec } from "./catalog.js";
|
|
22
|
-
import { layoutRegions,
|
|
22
|
+
import { layoutRegions, cameraAt, timelineStates, isNodeDisabled, isSelfVisible, layersOf, resolveProps, sceneWidth } from "./player.js";
|
|
23
23
|
export const HOLD_MIN_SECONDS = 0.5;
|
|
24
24
|
export const HOLD_MAX_SECONDS = 30;
|
|
25
25
|
/** 默认揭晓最多提示几处;更多时不提示。 */
|
|
@@ -52,8 +52,11 @@ function changedElements(scene, before, after, plugins) {
|
|
|
52
52
|
const va = visibleIds(scene, after);
|
|
53
53
|
const hits = [];
|
|
54
54
|
const parents = new Map();
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const added = new Set();
|
|
56
|
+
const add = (n, appended) => { if (n && !added.has(n.id)) {
|
|
57
|
+
added.add(n.id);
|
|
58
|
+
hits.push({ id: n.id, type: n.type, selfEvident: n.traits?.selfEvident || pluginSpec(plugins, n.type)?.selfEvident, parent: parents.get(n.id) ?? null, appended: appended && n.type !== '#text' });
|
|
59
|
+
} };
|
|
57
60
|
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
58
61
|
const rec = (n, parent) => {
|
|
59
62
|
parents.set(n.id, parent?.id ?? null);
|
|
@@ -71,8 +74,12 @@ function changedElements(scene, before, after, plugins) {
|
|
|
71
74
|
};
|
|
72
75
|
rec(scene.root, null);
|
|
73
76
|
// 只留最外层:祖先已经在列表里的去掉
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
// 沿上面记下的父链往上找(不为每一对元素整棵搜两遍:一步改了几百个元素的大画布上那是几秒)
|
|
78
|
+
const hit = new Set(hits.map((h) => h.id));
|
|
79
|
+
const hasHitAncestor = (id) => { for (let up = parents.get(id) ?? null; up; up = parents.get(up) ?? null)
|
|
80
|
+
if (hit.has(up))
|
|
81
|
+
return true; return false; };
|
|
82
|
+
return hits.filter((h) => !hasHitAncestor(h.id));
|
|
76
83
|
}
|
|
77
84
|
function findIn(node, id) {
|
|
78
85
|
if (node.id === id)
|
|
@@ -132,26 +139,7 @@ export function focusTimeline(project, scenarioId) {
|
|
|
132
139
|
}
|
|
133
140
|
const auto = project.autoFocus !== false;
|
|
134
141
|
// 逐步回放(与 stateAt 同一个 applyStep);回放失败之后的位置没有状态,只给作者写的焦点
|
|
135
|
-
const states =
|
|
136
|
-
let s = null;
|
|
137
|
-
try {
|
|
138
|
-
s = initialState(project, scenarioId);
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
s = null;
|
|
142
|
-
}
|
|
143
|
-
states.push(s);
|
|
144
|
-
for (let i = 0; i < sc.steps.length; i++) {
|
|
145
|
-
if (s) {
|
|
146
|
-
try {
|
|
147
|
-
s = applyStep(project, sc, s);
|
|
148
|
-
}
|
|
149
|
-
catch {
|
|
150
|
-
s = null;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
states.push(s);
|
|
154
|
-
}
|
|
142
|
+
const states = timelineStates(project, scenarioId);
|
|
155
143
|
out.push(EMPTY(shownScene(project, scenarioId, 0, states[0] ?? null).layer, 'cover'));
|
|
156
144
|
/** 上一步变化过的元素与它们所在的容器(连续性:同一处连续变化只在第一次提示)。 */
|
|
157
145
|
let prevChanged = new Set();
|
|
@@ -254,13 +242,3 @@ export function focusAt(project, scenarioId, position) {
|
|
|
254
242
|
const k = Math.max(0, Math.min(tl.length - 1, Number.isFinite(position) ? Math.trunc(position) : 0));
|
|
255
243
|
return structuredClone(tl[k]);
|
|
256
244
|
}
|
|
257
|
-
/** 自动播放时这一步至少停留多久(毫秒,已按速度缩放;0 = 没写 hold)。 */
|
|
258
|
-
export function holdMsOf(step, speed = 1) {
|
|
259
|
-
// 作者的 hold 与插件效果时长(D98)取较大值
|
|
260
|
-
const ms = Math.max(step?.hold ?? 0, step?.effectHold ?? 0);
|
|
261
|
-
return ms > 0 ? Math.round(ms / (speed > 0 ? speed : 1)) : 0;
|
|
262
|
-
}
|
|
263
|
-
/** 媒体锚点(配乐跳转、接力)按每步推进的时长:作者 hold(缺省 3000)与效果时长(D98)取较大值,未按速度缩放。 */
|
|
264
|
-
export function stepAnchorMs(step) {
|
|
265
|
-
return Math.max(step.hold ?? 3000, step.effectHold ?? 0);
|
|
266
|
-
}
|