@joplo-app/core 0.8.0 → 0.8.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/entries.js +53 -4
- package/dist/guide.js +1 -1
- package/dist/step-plan.js +15 -1
- package/package.json +2 -2
package/dist/entries.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
/** 首页条目:外部只读此投影,作品可独立存在或挂在功能下面。 */
|
|
2
2
|
import { scenarioPlanMs } from "./step-plan.js";
|
|
3
|
+
const scenariosByWorkCache = new WeakMap();
|
|
4
|
+
function scenariosIndex(scenarios) {
|
|
5
|
+
const keys = Object.keys(scenarios);
|
|
6
|
+
const cached = scenariosByWorkCache.get(scenarios);
|
|
7
|
+
if (cached && cached.count === keys.length)
|
|
8
|
+
return cached.map;
|
|
9
|
+
const map = new Map();
|
|
10
|
+
for (const k of keys) {
|
|
11
|
+
const s = scenarios[k];
|
|
12
|
+
let list = map.get(s.workId);
|
|
13
|
+
if (!list) {
|
|
14
|
+
list = [];
|
|
15
|
+
map.set(s.workId, list);
|
|
16
|
+
}
|
|
17
|
+
list.push(s);
|
|
18
|
+
}
|
|
19
|
+
scenariosByWorkCache.set(scenarios, { count: keys.length, map });
|
|
20
|
+
return map;
|
|
21
|
+
}
|
|
3
22
|
/** 某个方案的场景,按声明顺序。 */
|
|
4
|
-
export const scenariosOf = (project, workId) => workId ?
|
|
23
|
+
export const scenariosOf = (project, workId) => workId ? (scenariosIndex(project.scenarios).get(workId) ?? []).slice() : [];
|
|
5
24
|
/**
|
|
6
25
|
* 连续播放的顺序(D92 U2 / R9;看板、发布站、嵌入与录制 --chain 共用):按声明顺序取不接力的场景(根),每个根之后
|
|
7
26
|
* 深度优先接上 from 接力它的章(多章接同一章时按声明顺序)。autoplay: false 的场景连同接在它后面的章都不进顺序。
|
|
@@ -35,6 +54,7 @@ export function rolesOf(project, workId) {
|
|
|
35
54
|
}
|
|
36
55
|
/** 切片键只在此处由已知 workId 的长度计算;不拆 ID 推断归属。 */
|
|
37
56
|
export const sliceKey = (scenario) => scenario.id.slice(scenario.workId.length + 1);
|
|
57
|
+
const entryCache = new WeakMap();
|
|
38
58
|
/** 一个首页条目的投影。 */
|
|
39
59
|
export function entryOf(project, id) {
|
|
40
60
|
if (!id)
|
|
@@ -44,10 +64,20 @@ export function entryOf(project, id) {
|
|
|
44
64
|
if (!f && (!w || w.featureId))
|
|
45
65
|
return null;
|
|
46
66
|
const workId = f ? (f.pick && project.works[f.pick] ? f.pick : f.workIds.find(id => project.works[id])) ?? null : id;
|
|
67
|
+
const workScenarios = workId ? (scenariosIndex(project.scenarios).get(workId) ?? []) : [];
|
|
68
|
+
let byId = entryCache.get(project);
|
|
69
|
+
if (!byId) {
|
|
70
|
+
byId = new Map();
|
|
71
|
+
entryCache.set(project, byId);
|
|
72
|
+
}
|
|
73
|
+
const hit = byId.get(id);
|
|
74
|
+
if (hit && hit.pick === f?.pick && hit.workId === workId && hit.scenarioCount === workScenarios.length) {
|
|
75
|
+
return hit.entry;
|
|
76
|
+
}
|
|
47
77
|
const active = workId ? project.works[workId] : undefined;
|
|
48
78
|
const sequence = playSequence(project, workId);
|
|
49
79
|
const inSequence = new Set(sequence.map((s) => s.id));
|
|
50
|
-
const ordered = [...sequence, ...
|
|
80
|
+
const ordered = [...sequence, ...workScenarios.filter((s) => !inSequence.has(s.id))];
|
|
51
81
|
const slices = ordered.map((s) => ({
|
|
52
82
|
id: s.id,
|
|
53
83
|
key: sliceKey(s),
|
|
@@ -58,7 +88,7 @@ export function entryOf(project, id) {
|
|
|
58
88
|
inSequence: inSequence.has(s.id),
|
|
59
89
|
}));
|
|
60
90
|
const roles = (f ? f.roles : rolesOf(project, workId)).map((r) => r.name.trim()).filter(Boolean);
|
|
61
|
-
|
|
91
|
+
const entry = {
|
|
62
92
|
id,
|
|
63
93
|
featureId: f?.id ?? null,
|
|
64
94
|
sequencing: active?.sequencing ?? 'independent',
|
|
@@ -71,8 +101,27 @@ export function entryOf(project, id) {
|
|
|
71
101
|
slices,
|
|
72
102
|
ms: slices.reduce((sum, s) => sum + (s.inSequence ? s.ms : 0), 0),
|
|
73
103
|
};
|
|
104
|
+
byId.set(id, { pick: f?.pick, workId, scenarioCount: workScenarios.length, entry });
|
|
105
|
+
return entry;
|
|
74
106
|
}
|
|
107
|
+
const entriesListCache = new WeakMap();
|
|
75
108
|
/** 项目里的全部作品,按演示顺序(entryIds)。首页的卡片、看板顶栏的下拉、outline 都从这里取。 */
|
|
76
109
|
export function entriesOf(project) {
|
|
77
|
-
|
|
110
|
+
const cached = entriesListCache.get(project);
|
|
111
|
+
if (cached && cached.count === project.entryIds.length) {
|
|
112
|
+
let valid = true;
|
|
113
|
+
for (let i = 0; i < project.entryIds.length; i++) {
|
|
114
|
+
const id = project.entryIds[i];
|
|
115
|
+
const cur = entryOf(project, id);
|
|
116
|
+
if (cur !== cached.items[i]) {
|
|
117
|
+
valid = false;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (valid)
|
|
122
|
+
return cached.items;
|
|
123
|
+
}
|
|
124
|
+
const items = project.entryIds.map(id => entryOf(project, id)).filter(Boolean);
|
|
125
|
+
entriesListCache.set(project, { count: project.entryIds.length, items });
|
|
126
|
+
return items;
|
|
78
127
|
}
|
package/dist/guide.js
CHANGED
|
@@ -1062,7 +1062,7 @@ The engine supplies authoring, compilation, state, scheduling and host services.
|
|
|
1062
1062
|
6. joplo components inspects only the enabled manifests; a named query gives that component's declarations and example. For full recipes/behavior read its plugin skill.
|
|
1063
1063
|
|
|
1064
1064
|
## Optional 3D
|
|
1065
|
-
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.8.
|
|
1065
|
+
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.8.1; default-import scene3d from that package in joplo.config.ts, add scene3d to config.plugins, then run npx joplo skill install. Read npx joplo skill scene3d, scene3d/models and scene3d/generation for rendering, existing assets and optional local generation. A key is unnecessary for existing assets; dry-run before approving any generation.
|
|
1066
1066
|
|
|
1067
1067
|
## Errors and trust
|
|
1068
1068
|
- UNKNOWN_PLUGIN: the element's author package is not enabled. Use its package provenance in the diagnostic to install/import it and add it to config.plugins. UNKNOWN_COMPONENT: no enabled manifest declares that element or intrinsic tag; read the installed catalogs.
|
package/dist/step-plan.js
CHANGED
|
@@ -89,9 +89,23 @@ export function stepPlan(project, step, o = {}) {
|
|
|
89
89
|
const leadMs = cursorMs + rippleMs + gestureMs;
|
|
90
90
|
return { cursorMs, rippleMs, gestureMs, leadMs, settleMs, dwellMs, voiceMs: voice, totalMs: leadMs + Math.max(dwellMs, voice), ...(timingSource ? { timingSource, audioMs } : {}) };
|
|
91
91
|
}
|
|
92
|
+
const defaultPlanMsCache = new WeakMap();
|
|
92
93
|
/** 一个场景按 1× 自动播放大约多久(毫秒):每一步 stepPlan 的合计之和。 */
|
|
93
94
|
export function scenarioPlanMs(project, steps, texts) {
|
|
94
|
-
|
|
95
|
+
if (!texts) {
|
|
96
|
+
let bySteps = defaultPlanMsCache.get(project);
|
|
97
|
+
if (!bySteps) {
|
|
98
|
+
bySteps = new WeakMap();
|
|
99
|
+
defaultPlanMsCache.set(project, bySteps);
|
|
100
|
+
}
|
|
101
|
+
const hit = bySteps.get(steps);
|
|
102
|
+
if (hit !== undefined)
|
|
103
|
+
return hit;
|
|
104
|
+
const total = steps.reduce((sum, step) => sum + stepPlan(project, step, {}).totalMs, 0);
|
|
105
|
+
bySteps.set(steps, total);
|
|
106
|
+
return total;
|
|
107
|
+
}
|
|
108
|
+
return steps.reduce((sum, step) => sum + stepPlan(project, step, { texts: texts(step) }).totalMs, 0);
|
|
95
109
|
}
|
|
96
110
|
/**
|
|
97
111
|
* 两次提交之间的时间(引擎毫秒,1×):第 index 步(0 起;-1 = 场景开始)提交之后,到下一步提交(最后一步之后 = 到场景播完)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Joplo 作品引擎:编译、校验与确定性播放,支持独立作品和功能方案评审",
|
|
5
5
|
"license": "PolyForm-Shield-1.0.0",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@joplo-app/kit": "0.8.
|
|
38
|
+
"@joplo-app/kit": "0.8.1",
|
|
39
39
|
"zod": "4.6.7"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|