@joplo-app/core 0.3.0 → 0.5.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/catalog.d.ts +0 -5
- package/dist/catalog.js +0 -5
- package/dist/compile.js +20 -2
- package/dist/focus.d.ts +3 -1
- package/dist/focus.js +12 -2
- package/dist/guide.js +34 -14
- package/dist/outline.js +2 -1
- package/dist/pace.d.ts +7 -1
- package/dist/pace.js +9 -1
- package/dist/player.d.ts +15 -0
- package/dist/player.js +16 -1
- package/dist/plugins/compiler.d.ts +1 -0
- package/dist/plugins/compiler.js +10 -4
- package/dist/schema.d.ts +13 -0
- package/dist/schema.js +6 -1
- package/dist/voice.js +3 -0
- package/package.json +2 -2
package/dist/catalog.d.ts
CHANGED
|
@@ -55,11 +55,6 @@ export declare const VIEWPORT_SIZE: {
|
|
|
55
55
|
readonly height: 844;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
/**
|
|
59
|
-
* 字幕区:画面下方、播放控制上方的一块固定高度区域,最多两行:一行本步说明(大字),一行 explain(小一号)。
|
|
60
|
-
* 演示页、发布站、renderStep 截图、导出图片与视频都把它放在舞台正下方,宽度与舞台(手机含外框)相同。
|
|
61
|
-
*/
|
|
62
|
-
export declare const SUBTITLE_HEIGHT = 84;
|
|
63
58
|
/**
|
|
64
59
|
* 内置主题(D51):每个主题是一个只写 CSS 变量(--jp-*)的样式表,CSS 在 web 包里(renderer/themes.ts)。
|
|
65
60
|
* 作者可以在项目根目录 themes/<name>.css 写自己的主题;与内置同名时用作者的。
|
package/dist/catalog.js
CHANGED
|
@@ -26,11 +26,6 @@ export const BREAKPOINTS = { xs: 576, sm: 768, md: 992, lg: 1200, xl: 1408 };
|
|
|
26
26
|
const BP_KEYS = ['base', 'xs', 'sm', 'md', 'lg', 'xl'];
|
|
27
27
|
/** 页面 viewport 对应的舞台尺寸。 */
|
|
28
28
|
export const VIEWPORT_SIZE = { desktop: { width: 1280, height: 800 }, mobile: { width: 390, height: 844 } };
|
|
29
|
-
/**
|
|
30
|
-
* 字幕区:画面下方、播放控制上方的一块固定高度区域,最多两行:一行本步说明(大字),一行 explain(小一号)。
|
|
31
|
-
* 演示页、发布站、renderStep 截图、导出图片与视频都把它放在舞台正下方,宽度与舞台(手机含外框)相同。
|
|
32
|
-
*/
|
|
33
|
-
export const SUBTITLE_HEIGHT = 84;
|
|
34
29
|
/**
|
|
35
30
|
* 内置主题(D51):每个主题是一个只写 CSS 变量(--jp-*)的样式表,CSS 在 web 包里(renderer/themes.ts)。
|
|
36
31
|
* 作者可以在项目根目录 themes/<name>.css 写自己的主题;与内置同名时用作者的。
|
package/dist/compile.js
CHANGED
|
@@ -377,7 +377,10 @@ export function compile(src, mode, opts = {}) {
|
|
|
377
377
|
const ruleIds = [];
|
|
378
378
|
const explains = [];
|
|
379
379
|
const says = [];
|
|
380
|
+
let sayRole = null;
|
|
380
381
|
const narrates = [];
|
|
382
|
+
/** 插件效果声明的最短停留(D98):同一步取最大值。 */
|
|
383
|
+
let effectHoldMs = 0;
|
|
381
384
|
const ext = {};
|
|
382
385
|
const references = [];
|
|
383
386
|
const pluginFocus = [];
|
|
@@ -401,13 +404,24 @@ export function compile(src, mode, opts = {}) {
|
|
|
401
404
|
}
|
|
402
405
|
else if (e.type === 'set' || e.type === 'append')
|
|
403
406
|
effects.push({ type: e.type, path: e.path, value: e.value });
|
|
404
|
-
else if (e.type === 'stream')
|
|
405
|
-
|
|
407
|
+
else if (e.type === 'stream') {
|
|
408
|
+
if (e.pace !== undefined && e.pace !== 'voice')
|
|
409
|
+
err('STREAM_PACE_INVALID', `stream() pace must be 'voice' (got ${JSON.stringify(e.pace)}); omit it to stream at model-output speed`, st.source);
|
|
410
|
+
effects.push({ type: 'stream', path: e.path, value: e.value, ...(e.pace === 'voice' ? { pace: 'voice' } : {}) });
|
|
411
|
+
}
|
|
406
412
|
else if (e.type === 'toast')
|
|
407
413
|
effects.push({ type: 'toast', text: e.text, tone: e.tone });
|
|
408
414
|
else if (e.type === 'shot' || e.type === 'mark' || e.type === 'fork' || e.type === 'cue' || e.type === 'callout' || e.type === 'hold')
|
|
409
415
|
continue; // 镜头与焦点提示不是状态变化,下面单独归类
|
|
410
416
|
else if (e.type === 'say') {
|
|
417
|
+
if (e.role !== undefined) {
|
|
418
|
+
if (typeof e.role !== 'string' || !roleKeys.has(e.role))
|
|
419
|
+
err('ROLE_UNKNOWN', `say() role "${String(e.role)}" is not in feature.roles${roleKeys.size ? ` (available: ${[...roleKeys].join(', ')})` : ' (feature.roles must use { key: role(\'Name\') })'}`, st.source);
|
|
420
|
+
else if (sayRole !== null && sayRole !== e.role)
|
|
421
|
+
err('SAY_ROLE_CONFLICT', `One step has say() lines from two roles ("${sayRole}" and "${e.role}"); split them into two steps`, st.source);
|
|
422
|
+
else
|
|
423
|
+
sayRole = e.role;
|
|
424
|
+
}
|
|
411
425
|
if (typeof e.text === 'string' && e.text.trim())
|
|
412
426
|
says.push(e.text.trim());
|
|
413
427
|
else
|
|
@@ -429,6 +443,8 @@ export function compile(src, mode, opts = {}) {
|
|
|
429
443
|
effects.push(...(lowered.writes ?? []).map(w => ({ type: 'set', path: w.path, value: w.value })));
|
|
430
444
|
if (lowered.directorTarget)
|
|
431
445
|
directorTargets.push(lowered.directorTarget);
|
|
446
|
+
if (lowered.holdMs)
|
|
447
|
+
effectHoldMs = Math.max(effectHoldMs, lowered.holdMs);
|
|
432
448
|
if (lowered.media?.length) {
|
|
433
449
|
const key = `${sid}#${i + 1}`;
|
|
434
450
|
host.mediaCommands.set(key, [...(host.mediaCommands.get(key) ?? []), ...lowered.media]);
|
|
@@ -605,7 +621,9 @@ export function compile(src, mode, opts = {}) {
|
|
|
605
621
|
...(cues.length ? { cues } : {}),
|
|
606
622
|
...(callouts.length ? { callouts } : {}),
|
|
607
623
|
...(holdMs !== undefined ? { hold: holdMs } : {}),
|
|
624
|
+
...(effectHoldMs > 0 ? { effectHold: effectHoldMs } : {}),
|
|
608
625
|
...(says.length ? { say: says.join(' ') } : {}),
|
|
626
|
+
...(says.length && sayRole ? { sayRole } : {}),
|
|
609
627
|
...(narrates.length ? { narrate: narrates.join(' ') } : {}),
|
|
610
628
|
...(st.source ? { source: rel(st.source) } : {}),
|
|
611
629
|
};
|
package/dist/focus.d.ts
CHANGED
|
@@ -48,5 +48,7 @@ export declare function inShotFrame(root: SceneNode, id: string, frameTargets: r
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function focusAt(project: Project, scenarioId: string | null | undefined, position: number): FocusState;
|
|
50
50
|
/** 自动播放时这一步至少停留多久(毫秒,已按速度缩放;0 = 没写 hold)。 */
|
|
51
|
-
export declare function holdMsOf(step: Pick<Step, 'hold'> | undefined, speed?: number): number;
|
|
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;
|
|
52
54
|
export {};
|
package/dist/focus.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 作者写的:shot / trace / spotlight / highlight / numbered / callout / mark 的目标(source = explicit);
|
|
9
9
|
* 默认推导(source = auto):
|
|
10
10
|
* scene 换页、导演换层:整个新画面就是焦点(先看全局);
|
|
11
|
-
* elements 用户操作 = 被操作的元素(呈现就是鼠标与点击波纹);系统步骤 =
|
|
11
|
+
* elements 用户操作 = 被操作的元素(呈现就是鼠标与点击波纹);系统步骤 = 本步新出现或变化的元素,以及插件效果引用的元素(D98,插件自己表现变化,不加脉冲);
|
|
12
12
|
* toast 画面里没变,只弹了 Toast;
|
|
13
13
|
* caption 画面上没有新东西,只看字幕(source = none)。
|
|
14
14
|
*
|
|
@@ -203,6 +203,11 @@ export function focusTimeline(project, scenarioId) {
|
|
|
203
203
|
prevChanged.add(`^${h.parent}`);
|
|
204
204
|
}
|
|
205
205
|
const targets = [...(actionTarget ? [actionTarget] : []), ...hits.map((h) => h.id)];
|
|
206
|
+
// 插件效果改的是插件自己的画面(编辑器打字、3D、镜头……),状态里看不出来:它引用的元素就是这一步的焦点对象(D98)。
|
|
207
|
+
// 插件自己表现变化,不加默认脉冲(reveal 只来自 hits)。
|
|
208
|
+
for (const id of step.references ?? [])
|
|
209
|
+
if (!targets.includes(id))
|
|
210
|
+
targets.push(id);
|
|
206
211
|
if (targets.length)
|
|
207
212
|
Object.assign(f, { subject: 'elements', source: 'auto', targets });
|
|
208
213
|
else if (after.toasts.length)
|
|
@@ -251,6 +256,11 @@ export function focusAt(project, scenarioId, position) {
|
|
|
251
256
|
}
|
|
252
257
|
/** 自动播放时这一步至少停留多久(毫秒,已按速度缩放;0 = 没写 hold)。 */
|
|
253
258
|
export function holdMsOf(step, speed = 1) {
|
|
254
|
-
|
|
259
|
+
// 作者的 hold 与插件效果时长(D98)取较大值
|
|
260
|
+
const ms = Math.max(step?.hold ?? 0, step?.effectHold ?? 0);
|
|
255
261
|
return ms > 0 ? Math.round(ms / (speed > 0 ? speed : 1)) : 0;
|
|
256
262
|
}
|
|
263
|
+
/** 媒体锚点(配乐跳转、接力)按每步推进的时长:作者 hold(缺省 3000)与效果时长(D98)取较大值,未按速度缩放。 */
|
|
264
|
+
export function stepAnchorMs(step) {
|
|
265
|
+
return Math.max(step.hold ?? 3000, step.effectHold ?? 0);
|
|
266
|
+
}
|
package/dist/guide.js
CHANGED
|
@@ -88,7 +88,7 @@ Joplo compiles trusted TS/TSX into deterministic scenes and schedules their play
|
|
|
88
88
|
4. Required before handing a development round to the user: read npx joplo skill review and start npx joplo feedback watch [dir] --local --follow --json. A running board alone does not receive feedback for the agent.
|
|
89
89
|
|
|
90
90
|
## Binary assets
|
|
91
|
-
- asset('./file.glb') embeds a self-contained GLB; MP3/WAV/OGG/M4A/FLAC are supported too. Paths are relative to the calling source file. Images retain a 2 MB limit; binary files have a 50 MB limit. Dev serves binary bytes by content hash;
|
|
91
|
+
- asset('./file.glb') embeds a self-contained GLB; MP3/WAV/OGG/M4A/FLAC are supported too. Paths are relative to the calling source file. Images retain a 2 MB limit; binary files have a 50 MB limit. Dev serves binary bytes by content hash; npx joplo build writes every asset as its own file (assets/<hash>.<ext>), so the built site must be opened over HTTP: npx joplo preview, a share, or any static server. Double-clicking index.html (file://) is not supported.
|
|
92
92
|
- Prefer existing CC0 assets and public-domain reference images, then use a generation plugin to fill gaps in an original style. Read the enabled plugin's skill before generation. Commit persistent artifacts and metadata; never put API keys in project source.
|
|
93
93
|
- npx joplo resources --dry-run lists missing persistent resources and estimated credits. Interactive resources confirms each item; unattended generation requires --allow-spend. check/build/render remain offline for these artifacts. Missing or corrupt output gives diagnostics, not an implicit paid retry. Keep large GLB files below 5 MB where possible and inspect MODEL_SIZE warnings before sharing.
|
|
94
94
|
|
|
@@ -130,6 +130,7 @@ Declare both success and recovery cases in the feature. View code belongs to the
|
|
|
130
130
|
- .click(id), .type(id, value), .select(id, value), .toggle(id, boolean), .press(keys), .back(), .drag(id, destination), .hover(id, ms), .scroll(id, destination), .act(pluginAction, id, data). Read demo and the action-owning plugin skill for recognition requirements.
|
|
131
131
|
- .system('event', ...effects) models a response, not a real request. .card() creates a transition. Strings are captions; other arguments are effects. Step arguments and card accept effect arrays.
|
|
132
132
|
- set(path, value) replaces; push(path, value) appends; patch(path, object) expands to sets (nested objects replace, not deep-merge). go(route) navigates in this option; back returns to the prior route.
|
|
133
|
+
- stream(path, text, { pace? }) writes like set, but during playback the bound text appears character by character (a model answering, speech being transcribed); jumps, screenshots and deep links show the full text. When the new value starts with the old one, only the added characters stream, so write each step's full value (previous text + the new words) rather than juggling separate fragments. pace: 'voice' spreads the new characters over this step's narrate()/say() line, so the words land as they are spoken; the default pace is model-output speed. Only a plain text child bound to the path streams ({$.ui.reply}); stream values are translated like other on-screen text, so keep every language's successive values prefix-consistent.
|
|
133
134
|
- toast(text), toast.success/error/info(text) show an engine message. done(result, outcome?) ends a scenario; outcomes success/failure/cancelled must agree with flow's badge. uses(ruleKey, ...) links rules; it is an effect, not a flow method.
|
|
134
135
|
- free.click/type/select/toggle/drag/hover/scroll/act in option.free declare local reactions. free is a named object, not an array: free: { open: free.click('open', set($.ui.open, true)) }. Only set, push and toast are local effects; navigation, completion and media remain scripted. Play/jump/scenario/reset discard the local layer.
|
|
135
136
|
|
|
@@ -186,6 +187,7 @@ Backend behind the same feature: put a diagram component in its own layer and .s
|
|
|
186
187
|
- Scenario list, one line per scenario: Given (who, where, starting state) → When (the user's actions) → Then (the visible result), plus how it opens and how it ends.
|
|
187
188
|
- Length: a scenario is usually 5–12 steps, about 20–60 s at 1×. check flags one over 90 s; npx joplo outline prints every estimate.
|
|
188
189
|
- Unsure how to frame it? Offer two or three one-line framings and let the user pick.
|
|
190
|
+
- Recreating an existing video, GIF or screen recording: read it before planning. Extract frames into contact sheets (for example ffmpeg -i ref.gif -vf "fps=1,tile=3x3" sheet%02d.png, written outside the project) and list its chapters, the states each chapter passes through and every on-screen sentence; those become cases, steps and narration. Map the reference's own chrome to the player's instead of redrawing it: its chapter label → case title and the player's step title, its bottom progress → the player's chapter list, its key badge → the host key record after .press(), its spoken captions → narrate()/say(). Ask about anything the reference does not show (chapters cut off, unseen states) instead of inventing it; replace third-party logos with neutral shapes.
|
|
189
191
|
|
|
190
192
|
## 3. PM lens: from a need to roles, goal, cases, and scenarios
|
|
191
193
|
Joplo already has the parts of a user story; fill them in that spirit.
|
|
@@ -229,7 +231,11 @@ When the board or the published site reads a demo aloud, each step reads, in ord
|
|
|
229
231
|
- Transitions carry the story: role switches, time jumps, and closing cards need a line that tells the viewer why we moved.
|
|
230
232
|
- Plain and concrete, not flowery: no metaphors, slogans, or hype. Vivid means specific: real names, amounts, and times.
|
|
231
233
|
- Not every step needs its own line: a trivial step can keep its short caption, and a character's say() can carry a moment ('Count me in!').
|
|
234
|
+
- Once a piece will be heard, every step without narrate()/say() reads its caption aloud ('Hover the mic', 'Click Done'), which sounds like a screen reader. Listen for those: merge a hover or setup step into the step that explains it, give a short narrate() to the clicks that stay, or drop steps that only exist to show a tooltip.
|
|
235
|
+
- An on-screen headline and narration play together: narrate the point in spoken words (the why, the consequence) rather than reading the headline back, since the subtitle would show the same sentence twice.
|
|
232
236
|
- say() is first person, what the character would really say; narration about the characters goes in narrate().
|
|
237
|
+
- Who says it: a user action's say() uses the role of the layer it lands on. A system step has no acting person, so it reads in the narrator's voice unless you name the speaker: say('Book it for Friday', { role: 'me' }). Use that for a person talking to the product (voice input, a call, a voice assistant) while the screen reacts in system steps.
|
|
238
|
+
- Voice input / dictation: one system step per spoken phrase, say(phrase, { role }) plus stream($.ui.text, fullTextSoFar, { pace: 'voice' }), so the subtitle shows the phrase, the speaker's voice reads it and the transcript grows in step with the voice. Put the presenter's explanation in narrate() on separate steps (pauses, results); one step reads only one line, and narrate() wins over say().
|
|
233
239
|
- Open with the person and their goal; close with the one to three points, as speech, not a list read aloud. Write in the demo's language.
|
|
234
240
|
Wrong, it reads the interface: .click('share', 'Xiaoyu shares the itinerary', narrate('Click Share to share the itinerary.'))
|
|
235
241
|
Right, it says why: .click('share', 'Xiaoyu shares the itinerary', narrate('She sends it as a link, so Ajie needs no app.'))
|
|
@@ -280,6 +286,7 @@ The engine renders scripted state at step k, plus disposable local exploration.
|
|
|
280
286
|
- .drag(target, destination) accepts an element id or stage pixel point; .scroll(target, destination) accepts an element id or content offset. Declare the correct source and endpoint.
|
|
281
287
|
- .hover(target, ms) expresses a dwell; .act(name, target, data) uses the enabled plugin's data-only contract. Read its installed skill for field types, ranges, matching tolerance and presentation duration.
|
|
282
288
|
- Engine frames expose clock time, speed, running/paused state and gesture progress. Presenters sample it; independent timers must not drive the timeline. Pausing freezes cursor, gestures, media, text and plugin animation together.
|
|
289
|
+
- Only per-frame presenters re-render on every clock frame; ordinary elements re-render when state, run/pause or speed changes. If playback still stutters, measure before changing the piece: open the scenario in a browser, press Play, and record requestAnimationFrame intervals (fps, median, frames over 50 ms) or a CPU profile for 10–15 s. Time in React rendering points at the engine or a presenter re-rendering too much; time in paint points at heavy filters, masks or blend modes. A slow step change in the board can come from development-mode React; check the built site before cutting elements.
|
|
283
290
|
- Inputs belonging to another scenario prompt before switching. The default actionEntry: 'before' enters immediately before the matching action, useful for guided practice. For direct manipulation such as a chapter scrubber, set flow({ actionEntry: 'after' }) on the destination scenario: confirmation lands after the matched action exactly once, showing its scripted result and leaving subsequent steps pending. Cancel preserves exploration; confirm discards it. Before-action entry at step zero exposes the selected action without reopening the inert scenario cover; ordinary reset or chapter selection still shows the cover. This does not change autoplay, normal case selection or from continuity.
|
|
284
291
|
|
|
285
292
|
## A draggable chapter entry
|
|
@@ -307,7 +314,7 @@ Viewers call a piece "a slide deck" when pictures swap in one frame and then sit
|
|
|
307
314
|
- One main motion per beat; most beats 2–3 s. hold(seconds) is the author's pacing: a step with hold no longer gets the 3 s reading floor (caption reading time per character and narration still extend it). System steps show their event for about 0.9 s before committing; narration waits keep the engine clock (and therefore drift and transitions) running.
|
|
308
315
|
- Anti-deck gate: before building, write one line per beat — the main moving object, its start → end state, and the verb (push, morph, rise, swap…). If most beats are only fades or panels appearing, redesign them. A contact sheet that reads like slide thumbnails fails.
|
|
309
316
|
- Chapters: chain them with flow({ from }); sequential playback of a from chapter continues in the same shot (no countdown, no reset, music keeps playing). Bring the next chapter's music in on the beat before the visual swap (play the next score with fadeMs; the old track fades out under it — a J-cut). Play the same score again to keep it going. Stop music only at the real ending.
|
|
310
|
-
- Required review: run npx joplo render <dir> --scenario-id <first chapter> --film --chain --out film.png and read every page (one per chapter; red = one-frame full-screen change, grey = nothing visible changed for ≥ 1.5 s). The CLI prints every CUT and STILL with time and step; film.json beside it has the largest adjacent-frame change around every step. Fix every CUT that is not a deliberate signature and every STILL, then film again. Also record --video (real time) and watch it once start to end. Cells are samples on the engine clock; check a suspicious moment with --frames <dir> at full size before changing code — fine textures (1-px checkers, hairlines) shimmer as moiré under zoom or drift and show up as cuts.
|
|
317
|
+
- Required review: run npx joplo render <dir> --scenario-id <first chapter> --film --chain --out film.png and read every page (one per chapter; red = one-frame full-screen change, grey = nothing visible changed for ≥ 1.5 s). The CLI prints every CUT and STILL with time and step; film.json beside it has the largest adjacent-frame change around every step. Fix every CUT that is not a deliberate signature and every STILL, then film again. Also record --video (real time) and watch it once start to end. Cells are samples on the engine clock; check a suspicious moment with --frames <dir> at full size before changing code — fine textures (1-px checkers, hairlines) shimmer as moiré under zoom or drift and show up as cuts. The opposite also happens: in a product-recording piece the real change is a few characters, a caret or a timer, below the STILL threshold, so a typing sequence can be reported as one long STILL. Crop the changing area across consecutive --frames before adding motion only to satisfy the detector.
|
|
311
318
|
- Review as a picky viewer, not the author: list issues with time code, evidence (frame/metric), impact, severity (blocker / major / minor / note) and verdict (APPROVE / APPROVE_WITH_NOTES / REVISE). Check mechanics first (cuts, stills, overlaps, cropped text), then meaning, then taste; "not cinematic enough" without evidence is not a finding. Do at least two rounds of film → issues → fix, and finish one chapter seam to delivery quality before copying the technique to the others.
|
|
312
319
|
- Static frames (render, --sheet, thumbnails, deep links) show settled pictures: no drift, no half-finished transitions. That is deliberate and is why the film strip is the motion check.
|
|
313
320
|
- Boundary (D94): "like a video" is a quality bar, not a motion-graphics engine. Joplo's timeline is made of real, interactive states (steps), not frames. Reach the bar with the small set of glue tools above — transitions between states (enter/exit, match cuts), camera (framing, drift, safe area), media continuity, and the film/video review. There are no keyframe timelines, compositions, per-frame drawing APIs or particle effects; when a piece needs showy motion graphics, render that clip with another tool and embed it as an asset through a plugin. Ask of any new idea: does it describe how states change and are seen (fine), or how pixels are drawn over time (out of scope)?
|
|
@@ -323,7 +330,7 @@ A camera close-up must not enlarge or move the controls viewers need to pause, s
|
|
|
323
330
|
The host can draw an input/keyboard record after a type/press step, and toasts can move it upward. Reserve a clear band for those host overlays, then inspect the type step in both render --sheet and live playback. Do not infer safety from the authored tree alone or hide host overlays with project CSS. A camera can intentionally crop contextual menus during a close-up; the current action and its result still need to be visible and reachable.
|
|
324
331
|
|
|
325
332
|
## Frames, deep links and verification
|
|
326
|
-
- outline lists scenario and step ids. Use those ids in render/export; a deep link chooses where viewing starts and is not an access boundary.
|
|
333
|
+
- outline lists scenario and step ids. Use those ids in render/export; a deep link chooses where viewing starts and is not an access boundary. render takes qualified ids: --scenario-id <feature>.<option>.<scenario> and --step-id '<feature>.<option>.<scenario>#<n>' (the NOT_FOUND message lists the available scenario ids).
|
|
327
334
|
- joplo render --scenario-id <id> --step-id <id> --out frame.png renders timeline state. --sheet --columns 3 renders every step with captions/narration (settled frames only). --film [--chain] [--every 250] samples real playback on the engine clock for motion review; --video records a webm. Both need the export component (npx joplo setup).
|
|
328
335
|
- A full-size render can pass while a shorter board clips the input area. Check the actual visible hitbox with real pointer input in the board and the built site; DOM text existing is not proof it can be used.
|
|
329
336
|
- Fixed render dimensions are a capture size; viewport belongs to page/layer. In a browser wait for fonts and [data-jcamera][data-camera-settled="1"] plus two animation frames. Do not mistake DOM progress for painted pixels.
|
|
@@ -331,7 +338,7 @@ The host can draw an input/keyboard record after a type/press step, and toasts c
|
|
|
331
338
|
- For layout, visual motion, shapes, charts and component APIs use the installed plugin skills. The engine has no built-in component vocabulary.
|
|
332
339
|
|
|
333
340
|
## Write a theme
|
|
334
|
-
A project theme is themes/<name>.css selected by config({ theme: '<name>' }). Define --jp-bg, --jp-ink, --jp-surface and --jp-font; set --jp-stroke: clean for ordinary CSS borders (omitting it inherits hand-drawn strokes). Scope ordinary selectors to an authored root class so third-party libraries do not recolor the player. Include required font bytes as data URLs or use an already installed platform font; remote CSS/font URLs are not an offline asset pipeline. Verify computed styles and
|
|
341
|
+
A project theme is themes/<name>.css selected by config({ theme: '<name>' }). Define --jp-bg, --jp-ink, --jp-surface and --jp-font; set --jp-stroke: clean for ordinary CSS borders (omitting it inherits hand-drawn strokes). Scope ordinary selectors to an authored root class so third-party libraries do not recolor the player. Include required font bytes as data URLs or use an already installed platform font; remote CSS/font URLs are not an offline asset pipeline. Verify computed styles in the board and in the built site (npx joplo preview). Component defaults and styling recipes belong to the owning plugin.
|
|
335
342
|
|
|
336
343
|
## Branches, annotations and appearance
|
|
337
344
|
- fork(label, scenarioKey) adds a labeled route to another scenario; it does not silently branch automatic playback. Feature diffs report action-entry and autoplay policy changes separately, even when their static pictures are identical. Mark the optional destination flow with autoplay:false so sequential playback skips it; fork alone is a navigation choice, not an autoplay exclusion. Return links to main chapters must not mark those chapters optional.
|
|
@@ -517,6 +524,8 @@ Example: features/invite/options/a.tsx:12:5 warning UNBOUND_INTERACTIVE Inter
|
|
|
517
524
|
- EXPLAIN_TOO_LONG: Shorten the explain note to about 48 units, using the same CJK 1 / other 0.5 calculation. Put detailed rationale in a separate explanation layer. See demo.
|
|
518
525
|
- SAY_TOO_LONG / NARRATE_TOO_LONG (warning): a say() or narrate() line over about 80 units (about 10 seconds aloud). Autoplay waits until it is read; say less or split the step.
|
|
519
526
|
- SAY_EMPTY / NARRATE_EMPTY: say() needs the character's words, narrate() the narrator's. Remove it to fall back to the caption.
|
|
527
|
+
- SAY_ROLE_CONFLICT: one step has say(…, { role }) lines from two different roles. A step reads one speaker; split the lines into consecutive steps.
|
|
528
|
+
- STREAM_PACE_INVALID: stream()'s pace is only 'voice' (follow this step's spoken line); omit it for model-output speed.
|
|
520
529
|
- VOICE_CONFIG_INVALID: config({ voice }) takes { profile?, narrator?, roles?: { roleKey: 'voice' }, locales?: { ja: { narrator?, roles? } } } with non-empty strings. API keys never go in the config.
|
|
521
530
|
- LOCALES_INVALID / LOCALES_UNDECLARED: config({ locales }) lists supported languages once each, source language first; every locales/<lang>.json must be listed there and must not be the source language. LOCALE_FILE_INVALID: the file must be one JSON object of "source text": "translation" strings.
|
|
522
531
|
- I18N_MISSING / I18N_STALE / I18N_UNUSED (warnings): texts with no translation (viewers see the source text), a source text that changed (the closest old entry is shown: rename the key and update the translation), entries nothing uses. npx joplo i18n add <lang> adds the missing keys.
|
|
@@ -524,7 +533,7 @@ Example: features/invite/options/a.tsx:12:5 warning UNBOUND_INTERACTIVE Inter
|
|
|
524
533
|
- CARD_TEXT_TOO_LONG (info): a transition card's sub is over 48 units, a point over 24, or more than 4 points. Keep one sentence and a few short points; move details into steps.
|
|
525
534
|
- SCENARIO_TOO_LONG (info): the scenario plays over 90 s at 1×. One scenario tells one thing: split it (happy path, then each recovery) or branch with fork(). npx joplo outline shows the pacing.
|
|
526
535
|
- HAPPY_PATH_ONLY (info): every case is a main-flow case and every scenario succeeds. Ask about input, permission, async, and lifecycle cases (see cases), then add an error-and-recovery scenario. Do not invent behavior. Explainers and other content whose chapters are all main-flow can ignore it (see content).
|
|
527
|
-
- ROLE_UNKNOWN: A layer or
|
|
536
|
+
- ROLE_UNKNOWN: A layer, card or say() role is not in feature.roles. Declare roles as { key: role('Name') }; see demo.
|
|
528
537
|
- ICON_UNKNOWN: A layer icon is not a preset. Use one of window, browser, mobile, desktop, terminal, chat, agent, server, data, email, doc, flow; see demo.
|
|
529
538
|
- FORK_UNKNOWN: fork must target another scenario key in the same option; it cannot reference itself.
|
|
530
539
|
- MARK_UNKNOWN: The mark target is absent from this step's route stage (after go() and back() in earlier steps) or, with layers, from every layer. Check the element id; currently hidden targets are valid references.
|
|
@@ -727,7 +736,7 @@ Compare cases and options in the board, then decide which option to publish for
|
|
|
727
736
|
- Pages and layouts compose the whole product; picked options add elements to routes or add routes.
|
|
728
737
|
|
|
729
738
|
## build
|
|
730
|
-
- Run npx joplo check in the author project, then npx joplo build.
|
|
739
|
+
- Run npx joplo check in the author project, then npx joplo build, then npx joplo preview to open the built site over HTTP (assets are separate files; file:// is not supported).
|
|
731
740
|
- Default output: dist/. Set --out-dir <dir> to change it.
|
|
732
741
|
- Nonempty output directories are rejected. After confirming the old output can be discarded, pass --overwrite to clear and rebuild.
|
|
733
742
|
- The published site contains only feature names, goals, scenario demos, step captions, and the overall layout.
|
|
@@ -738,10 +747,12 @@ Compare cases and options in the board, then decide which option to publish for
|
|
|
738
747
|
- The published site uses the same layout as the local board, with authoring details such as rules, gaps, and source locations removed.
|
|
739
748
|
- Layer switching, Follow director, replaying one layer, shot focus, and captions all work on the published site. See demo for syntax.
|
|
740
749
|
- Fullscreen works on the published site: F enters/toggles, spacebar plays/pauses, ←/→ steps back/forward, Esc exits. Like a video, ←/→ during playback skips one step and keeps playing; while paused it steps once and stays paused.
|
|
741
|
-
-
|
|
750
|
+
- On every surface (board, published site, fullscreen, embed, screenshots, image and video export) two things float over the stage. The subtitle at the bottom centre shows what is being said: narrate(), else say() with the speaker's avatar and name, else the caption; cards and the cover show it only for narrate / say. The step title pops out at the top left when the step changes (number, caption, explain on a second line, branch links), stays about 2.5–5 s of timeline time, then shrinks to a dot the viewer can click to reopen; static frames show it open.
|
|
751
|
+
- Design for that: keep important content out of the bottom centre of every screen (about the bottom 12%) and expect the top-left corner to be briefly covered when a step starts. Put the reason in explain() or narrate(), not in a long caption: the caption is a short title.
|
|
752
|
+
- Fullscreen keeps only the stage (with its subtitle and step title). Playback controls float below and hide automatically.
|
|
742
753
|
- Autoplay plays the picked option's scenarios back to back, like chapters of one video: after the last step of a scenario an Up next card names the next one and counts down 3 seconds (Play now / Cancel; pausing pauses the countdown), then it starts; after the last scenario it stops. Stepping by hand never jumps. So order scenarios as chapters (the first one is the hook) and end each on a clear result. Use flow({ autoplay:false }) for optional branches: they remain manually selectable but are skipped by continuous playback, and stop at their own ending. A fork or return link alone does not remove a chapter from autoplay.
|
|
743
754
|
- On phones the published site becomes a video player: the 1280 × 800 desktop stage is scaled as a whole with black bars (never re-laid out to the phone width); portrait shows the video, full captions, one row of controls and the chapter list; turning the phone sideways (or tapping Landscape) fills the screen with stage and captions plus a separate control bar. Stage taps pause/explore and stage drags belong to the prototype; use the control bar to step. On an iPhone, which cannot fullscreen a page or lock orientation, the stage is rotated 90° until the phone is turned.
|
|
744
|
-
- Design for that: text on a 1280 × 800 stage shrinks to about 30% in portrait, so keep key text large (24px or more) and let shots zoom into details
|
|
755
|
+
- Design for that: text on a 1280 × 800 stage shrinks to about 30% in portrait, so keep key text large (24px or more) and let shots zoom into details.
|
|
745
756
|
- Both local and published views can export images. Video export is local only.
|
|
746
757
|
- Local image and video export use the Joplo export component (Playwright + Chromium, kept under ~/.joplo, not in the project). If it is missing, the board's Export menu offers Install export component (about 100 MB) and continues the export after installing; in a terminal, run npx joplo setup export.
|
|
747
758
|
|
|
@@ -779,6 +790,7 @@ Deploy only dist output, not author source files. MCP, comments, and collaborati
|
|
|
779
790
|
- Voice sources are only: browser voice (free, local), Joplo Cloud narration (signed in, no key, billed in characters), and official OpenAI / ElevenLabs (the user's own key; the API address is fixed). AiHubMix, OpenAI-compatible gateways with a custom Base URL and custom HTTP providers were removed: an old one shows "No longer supported" in the board. Audio it already generated still plays and is still bundled by build and share; it cannot make new audio. Ask the user to switch sources; do not edit ~/.joplo/voice/profiles.json yourself. An old OpenAI / ElevenLabs entry pointed at another address (a proxy), headers or response format is also "No longer supported": its key was for that proxy and is never sent to the official API; deleting it in Manage keys restores the official provider.
|
|
780
791
|
- Default: a project that never chose a source and has no config voice.profile uses Joplo Cloud narration when the user is signed in, otherwise the browser voice. Choosing Browser voice in the board sticks. Re-sharing a project that never chose a source prefers valid audio already generated for the current default, then reuses matching text from the previous share. Different voices can coexist per language, role and text; the published playback index preserves their real fingerprints, including on a later update from another machine. Do not regenerate everything or explicitly change sources just to make an update include new clips; an explicit source change deliberately stops inheriting the old source.
|
|
781
792
|
- After changing an automatic caption's label, input/selected value or keys, rebuild before sharing: audio is eligible only if its text matches the current caption in that clip's language. Valid local audio takes priority over reusable published audio only after this check. Stale text, unknown languages or mismatched cache keys are excluded from the site files and playback index; a step with no valid clip counts as missing and uses the browser voice. Do not treat matching step IDs or a previous successful generation as proof that a clip is current; preserve valid clips in the other interface languages instead of deleting the whole cache.
|
|
793
|
+
- Roles need their own voice: a feature role without config({ voice: { roles: { key: '<voice id>' } } }) speaks in the narrator's voice, so a person talking and the presenter sound identical. Pick a contrasting voice (another gender or register) from the board's voice panel; with Joplo Cloud the ids are multilingual and apply to every content language unless voice.locales overrides them. Set this before generating, because changing a voice regenerates its clips.
|
|
782
794
|
- Joplo Cloud narration is requested only when the user clicks Generate missing audio or runs npx joplo voice: playback never generates or prefetches it (that would spend characters). Steps without audio use the browser voice, marked "Browser voice" in the caption area. OpenAI / ElevenLabs with the user's own key still generate the step being played and prefetch the next few.
|
|
783
795
|
- An old custom provider whose id was cloud keeps its original fingerprint and No longer supported state, including existing board/config references. To deliberately switch, choose Joplo Cloud in the board; when voice.profile is in config, set it to the unambiguous official name 'Joplo Cloud' (config still takes priority over the board). This does not send the old provider's key to the official service.
|
|
784
796
|
- Per-language voices are pinned: the first successful clip in a non-default content language records the Joplo Cloud voice picked for it (the cloud's recommended voice for that language: the current voice stays if it is recommended, otherwise the first recommended one of the same gender) in .joplo/voice/index.json (pins). Later builds, shares and machines use the pinned voice, so recommendation changes never invalidate audio or charge again; config({ voice: { locales } }) still overrides. Invalid pin languages, maps or voice IDs are ignored individually and valid entries remain; a missing/invalid entry uses the normal recommendation rule and is saved after successful generation. Do not delete the whole voice index or edit it by hand to recover pins, because it also indexes the audio cache.
|
|
@@ -823,6 +835,8 @@ Deploy only dist output, not author source files. MCP, comments, and collaborati
|
|
|
823
835
|
- Write the source files in one language. To add another: npx joplo i18n add <lang> (first time also --source <source lang>). It adds the language to config({ locales }) (the first entry is the source language) and writes locales/<lang>.json as "source text": "" for every text viewers see: screens, captions, narrate / say, cards, toasts, done, feature and scenario names, displayed sample data, and board-only texts (case titles and expected results, rules, questions, element notes).
|
|
824
836
|
- Translate every "" yourself, whole sentences, keeping on-screen names consistent where captions quote them; narration as people say it in that language. Do not put t() calls or per-language objects in the TSX. Then npx joplo check: I18N_MISSING lists what is left, I18N_STALE means a source text changed (it shows the closest old entry: rename the key and update the translation).
|
|
825
837
|
- After editing source texts, run npx joplo i18n add <lang> again for each language: it adds new keys and keeps existing translations (--prune drops unused ones).
|
|
838
|
+
- A sentence assembled from several state values (the words before the cursor + new words + the words after it, a label + a value) is joined with no separator. Chinese and Japanese need none; in languages that separate words with spaces, put the space inside the translations at the seams (a 'before' ending in a space, an 'after' starting with one). Successive stream() values must stay prefix-consistent in every language (each step's value = the previous one + the new words). Check both with a small script over locales/<lang>.json, then render --content <lang> the steps where pieces meet.
|
|
839
|
+
- Longer languages overflow layouts written for the source: let headlines wrap instead of white-space: nowrap, and break long words with overflow-wrap: anywhere rather than word-break: break-all.
|
|
826
840
|
- One link serves everyone: viewers get their browser language, ?lang=<lang> picks one, and languages the project lacks fall back to the source language. The board's content-language menu previews each language; npx joplo render --content <lang> screenshots one.
|
|
827
841
|
- Narration: generate audio per language in the board, or npx joplo voice (every content language; --locale <lang> for one). Joplo Cloud narration sends the content language with each clip and picks the cloud's recommended voice for that language (a voice already in the recommendation stays); other providers pick a native preset voice when they have one. config({ voice: { locales: { ja: { narrator } } } }) overrides both. Languages without audio use the viewer's browser voice. Re-sharing reuses the audio already in the previous share (same text and voice). On another computer (no .joplo/cloud.json) run npx joplo share --private --no-review --update <share link>: it updates that share (free and Pro alike) and reuses its audio instead of regenerating it.
|
|
828
842
|
|
|
@@ -870,7 +884,7 @@ The engine supplies authoring, compilation, state, scheduling and host services.
|
|
|
870
884
|
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.
|
|
871
885
|
|
|
872
886
|
## Optional 3D
|
|
873
|
-
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.
|
|
887
|
+
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.5.0; 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.
|
|
874
888
|
|
|
875
889
|
## Errors and trust
|
|
876
890
|
- 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.
|
|
@@ -881,20 +895,26 @@ The starter does not include 3D or its large browser dependency. To add it: npm
|
|
|
881
895
|
## Write a plugin
|
|
882
896
|
- Export definePlugin({ id, packageName, title, version, components, skill, skillTopics?, runtime, compile?, properties?, themes?, actions?, data?, schemas?, local?, keys? }) from @joplo-app/kit/plugin. Ship compiled JS and declarations; runtime and optional local entries are URLs resolved relative to the package.
|
|
883
897
|
- components maps names to doc/example, interaction and declarative traits. Export pluginComponent(manifest, name) markers from this package. Intrinsic tag ownership is explicit and unique. No kit component forwarding or bare-name adapters.
|
|
884
|
-
- Runtime CSS imports and emitted local assets are bundled with the plugin: CSS is installed as a per-plugin style sheet, and local URLs become typed data URLs, including CSS images/fonts and imports above the normal inline threshold. Exercise source dev, npm prebuilt dev and
|
|
898
|
+
- Runtime CSS imports and emitted local assets are bundled with the plugin: CSS is installed as a per-plugin style sheet, and local URLs become typed data URLs, including CSS images/fonts and imports above the normal inline threshold. Exercise source dev, npm prebuilt dev and the built site served by npx joplo preview (no other network) with real asset loading checks; a successful JS import alone does not prove styles or textures were delivered. Generated asset references that cannot be resolved fail explicitly.
|
|
885
899
|
- Verify both source development and the installed production package in a real browser. A prebuilt host must share its own React instance with dynamic plugin modules; serving a raw CommonJS dependency URL is not sufficient. Production dev and offline publish use the same bundling/shared-module contract.
|
|
886
900
|
- skill is the entry guide: when to use, how to enable/import, the smallest correct example, success checks, pitfalls and recovery. skillTopics maps topic keys to { description, body }; installed references and CLI topics come from this exact version. Do not put private project data or credentials in guides.
|
|
887
901
|
- Node hooks normalize/derive/frame/effect/validate trusted author data. Outputs must be finite JSON within supported depth/size, immutable across calls, identity-safe, and serializable. Functions/prototypes/cycles are rejected. Hooks and source instructions are never shipped as runtime IR.
|
|
888
|
-
-
|
|
902
|
+
- derive runs once for every node of your plugin and sees only that node's subtree. Validate references between elements (an arrow's from/to, a mark's target) from the container that holds them all, and return early for other nodes; validating at the referring node reports every target as unknown.
|
|
903
|
+
- Effect compilers return declarative writes, references, optional directorTarget, media commands, derived data and optional holdMs. Preserve source ordering.
|
|
904
|
+
- references name the elements an effect changes (an editor, a 3D object). They become the step's focus subject, so check does not report FOCUS_IDLE for steps that only change plugin drawing; the host adds no default pulse, so the plugin must show the change itself.
|
|
905
|
+
- holdMs (0–60000, engine ms) is how long the step must at least stay for this effect: a code typing run, a clip, a Lottie. The host takes the largest holdMs of the step and the author's hold() for autoplay, cover and outline durations and media anchors. Derive it from the content (characters × per-character time, the clip's duration from resourceInfo), never a guess; animate by the engine clock so pause and speed match. It does not remove the reading-time floor; only the author's hold() does. Native behavior, choices, gates, text paths and action matching are manifest declarations, not host branches for a component name.
|
|
889
906
|
- actions declares field types/ranges/tolerances, targets, caption and duration. Runtime recognizers use ctx.act; frame.gesture and frame.clock present the same action. Do not accumulate private timeline time or advance state from a drawing callback.
|
|
890
907
|
|
|
891
908
|
## Runtime and projection
|
|
892
909
|
- Export defineRuntime({ id, components, observe? }) with the current API version. mount returns update/destroy; renderChildren preserves host rendering. Every targetable element needs an anchor carrying all supplied attrs, and canvas hits report through ctx.click/ctx.act. Report raycast hover with ctx.hover?.(id), and null on leave or drag start; the host resolves the declared dwell, cancels it on reset/resume, and never pauses playback for hover. Do not run a private hover timer or guess the author duration.
|
|
910
|
+
- To draw something attached to other elements (connectors, annotation rings), find them by data-jid inside your own container and measure the offsetLeft/offsetTop chain up to that container. This is the final layout, independent of camera zoom and in-flight FLIP transforms, so getBoundingClientRect is wrong here. Re-measure with ResizeObserver, a subtree MutationObserver (targets appear/disappear through when) and document.fonts.ready; skip a target that is not rendered instead of drawing to a stale point.
|
|
893
911
|
- For a canvas drag, report a named hit or stage CSS-pixel point through ctx.act. The host resolves points against declared drop-zone anchors, including ordinary DOM targets outside the canvas. Keep anchors current after camera/scale changes; do not report canvas-local pixels as stage pixels.
|
|
894
912
|
- frame contains resolved state, drawing snapshot, animate, clock/gesture, local playground and reset epoch. animate=false renders final layout; use ctx.hold while required assets load. Stop handled gesture propagation where ownership requires it.
|
|
913
|
+
- frame.clock (and useCtx().clock) is a coarse frame: its object changes only when running, paused or speed changes, while timeMs/elapsedMs/rawMs read the live engine time whenever you read them. The stage does not re-render every frame, so a large scene stays smooth during playback. A React presenter that must redraw every frame (a camera, a dot moving along a path, typed text) calls useEngineFrame() from @joplo-app/kit/renderer, and should memoize the children it renders so its subtree does not re-render with it. Imperative mount/update components already get update() every frame. Reading clock.timeMs in render or as an effect dependency without useEngineFrame() freezes the animation.
|
|
914
|
+
- Testing an engine or plugin change from your own checkout: npx joplo dev joins any board already running under the same JOPLO_HOME, and that board serves its own build, so your change will not appear. Start a separate board with JOPLO_HOME=<empty dir> npx joplo dev <dir> --port <free port>, and run feedback watch with the same JOPLO_HOME.
|
|
895
915
|
- Use @joplo-app/kit/renderer and renderer-style services instead of internal source imports. Share React through the published bridge; clean up observers/listeners and animation on destroy.
|
|
896
916
|
- properties declares literal types, constraints and namespaced DOM attributes. Attributes propagate to every anchor. An observe instance is local to a stage/runtime and updates after layout; switching/unmount destroys it. Exceptions disable that instance, not the engine.
|
|
897
|
-
- themes is named CSS; the engine namespaces it by plugin id. Keep visual semantics in the plugin. Same deterministic snapshot must draw identically in board,
|
|
917
|
+
- themes is named CSS; the engine namespaces it by plugin id. Keep visual semantics in the plugin. Same deterministic snapshot must draw identically in board, built site, render and video.
|
|
898
918
|
- data declares text and scope projections for node/step slots. Missing projection stops scoped publication; never leave cut content merely hidden in DOM. Translation changes only declared display paths, not ids, colors or structural values.
|
|
899
919
|
|
|
900
920
|
## Local resources and media
|
|
@@ -905,8 +925,8 @@ The starter does not include 3D or its large browser dependency. To add it: npm
|
|
|
905
925
|
- Local credential clients must serialize requests with JSON.stringify and never log request bodies. Malformed JSON returns a fixed 400 USAGE message without request excerpts; correct serialization locally without copying the secret into diagnostics. A 404 means the plugin/key pair is not declared by the current project: reload its enabled declarations and use an existing card instead of guessing identities.
|
|
906
926
|
- Release ctx.hold on success, error, superseded requests and unmount, after drawing the ready frame. Recheck scope before inlining assets; unused resources must not ship.
|
|
907
927
|
- Step effects can emit play/stop commands for named tracks. Replay uses fixed step anchors and one engine clock; jumping/replaying resets to the same snapshot. Pause, speed, fade and narration ducking are host behavior, synthesis belongs to the plugin.
|
|
908
|
-
- Free reactions are playback data: public payloads retain option.free after scope filtering, while authoring notes and source positions are stripped. Validate the actual built
|
|
909
|
-
- Scope before
|
|
928
|
+
- Free reactions are playback data: public payloads retain option.free after scope filtering, while authoring notes and source positions are stripped. Validate the actual built site (npx joplo preview) with arbitrary input and a secondary reaction; replay-only tests cannot detect a dropped free map.
|
|
929
|
+
- Scope before writing media. Build writes validated resources as separate asset files (assets/<hash>.<ext>, uploaded once per content by share) and inlines plugin runtimes; the site needs HTTP but no other network. In runtimes, accept asset URLs with embeddedAsset(src, kind) from @joplo-app/kit/plugin instead of testing for data: URLs. Video mixing capability is separate from playback support—state its actual limit.
|
|
910
930
|
|
|
911
931
|
## Verify the package
|
|
912
932
|
Run typecheck and relevant schema, compiler, projection and real-browser tests. Use a second unrelated plugin to test generic hooks. Pack and install into an isolated project, enable it explicitly, check/build/render and test playback without network. Keep skill, manifest, runtime and package exports at the same version.`,
|
package/dist/outline.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { orderedFeatures } from "./features.js";
|
|
8
8
|
import { holdMsOf } from "./focus.js";
|
|
9
|
+
import { streamPlan } from "./player.js";
|
|
9
10
|
import { stepDwell, voiceMs } from "./pace.js";
|
|
10
11
|
import { JoploError } from "./result.js";
|
|
11
12
|
/** 一步停留时要读的文字:说明、explain,过渡卡再加副标题与要点(与看板封面的估算同一口径)。 */
|
|
@@ -14,7 +15,7 @@ export function stepTexts(step) {
|
|
|
14
15
|
}
|
|
15
16
|
/** 一个场景按 1× 自动播放大约多久(毫秒):每一步取 hold、阅读停留(stepDwell)与旁白朗读估算(narrate / say)中最长的,再求和。 */
|
|
16
17
|
export function scenarioEstimateMs(scenario) {
|
|
17
|
-
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,
|
|
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);
|
|
18
19
|
}
|
|
19
20
|
export function outline(project, opts = {}) {
|
|
20
21
|
if (opts.optionId && !Object.hasOwn(project.options, opts.optionId))
|
package/dist/pace.d.ts
CHANGED
|
@@ -31,7 +31,8 @@ export declare function stepDwell(o: {
|
|
|
31
31
|
speed?: number;
|
|
32
32
|
cameraMoved?: boolean;
|
|
33
33
|
dotMs?: number; /** 本步流式输出的文字(D56):等它们出完再加阅读时间。 */
|
|
34
|
-
streams?: string[]; /**
|
|
34
|
+
streams?: string[]; /** 已经算好的流式输出时长(1×,见 player 的 streamPlan,D100):给了就用它,不再按 streams 的字数算。 */
|
|
35
|
+
streamMs?: number; /** 作者写了 hold(D92):节奏由作者掌握,阅读时间不套 3 秒下限(仍按字数)。 */
|
|
35
36
|
paced?: boolean;
|
|
36
37
|
}): number;
|
|
37
38
|
/** 朗读估算(旁白 / 台词):中日韩约每秒 4.5 字、拉丁文字约每秒 13 个非空白字符(约 2.5 词),读完再留 0.45 秒换气。 */
|
|
@@ -39,3 +40,8 @@ export declare const VOICE_CJK_MS = 220;
|
|
|
39
40
|
export declare const VOICE_LATIN_MS = 75;
|
|
40
41
|
/** 一段旁白大约读多久(毫秒,1×);没有文字时为 0。自动播放以真实读完为准,这个只用于封面、outline 与 check 的估算。 */
|
|
41
42
|
export declare function voiceMs(text: string | null | undefined, speed?: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* 跟着朗读出字(stream pace: 'voice',D100):一句话读完大约要多久(1×,不含换气),整段至少 STREAM_MIN。
|
|
45
|
+
* 用 voiceMs 的同一套估算,所以没开声音、或声音还没生成时,字出完的时间也和朗读估算一致。
|
|
46
|
+
*/
|
|
47
|
+
export declare function voicePacedMs(line: string | null | undefined): number;
|
package/dist/pace.js
CHANGED
|
@@ -59,7 +59,7 @@ export function stepDwell(o) {
|
|
|
59
59
|
const cam = o.cameraMoved ? CAMERA_MS + SETTLE : 0;
|
|
60
60
|
const dots = o.dotMs && o.dotMs > 0 ? o.dotMs + SETTLE : 0;
|
|
61
61
|
// 流式输出:先等最长的一段出完,再留出读完它的时间(按出完之后再读一遍的一半计)
|
|
62
|
-
const longest = Math.max(0, ...(o.streams ?? []).map((t) => streamMs(t, speed)));
|
|
62
|
+
const longest = o.streamMs !== undefined ? Math.round(o.streamMs / speed) : Math.max(0, ...(o.streams ?? []).map((t) => streamMs(t, speed)));
|
|
63
63
|
const streamed = longest ? longest + Math.max((o.paced ? 0 : MIN_DWELL) / speed, read / 2) : 0;
|
|
64
64
|
return Math.round(Math.max(read, cam, dots, streamed));
|
|
65
65
|
}
|
|
@@ -79,3 +79,11 @@ export function voiceMs(text, speed = 1) {
|
|
|
79
79
|
}
|
|
80
80
|
return ms ? Math.round((ms + VOICE_EST_BREATH_MS) / (speed > 0 ? speed : 1)) : 0;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* 跟着朗读出字(stream pace: 'voice',D100):一句话读完大约要多久(1×,不含换气),整段至少 STREAM_MIN。
|
|
84
|
+
* 用 voiceMs 的同一套估算,所以没开声音、或声音还没生成时,字出完的时间也和朗读估算一致。
|
|
85
|
+
*/
|
|
86
|
+
export function voicePacedMs(line) {
|
|
87
|
+
const ms = voiceMs(line);
|
|
88
|
+
return ms ? Math.max(STREAM_MIN, ms - VOICE_EST_BREATH_MS) : 0;
|
|
89
|
+
}
|
package/dist/player.d.ts
CHANGED
|
@@ -160,7 +160,22 @@ export declare function roleOfScene(project: Project, sceneId: string | null | u
|
|
|
160
160
|
export declare function streamsOf(step: Step | undefined): {
|
|
161
161
|
path: string;
|
|
162
162
|
value: string;
|
|
163
|
+
pace?: 'voice';
|
|
163
164
|
}[];
|
|
165
|
+
/** 一段流式输出怎么出字:keep 个字一开始就在(原来的值),其余的字在 ms 毫秒(1×)里逐字出现。 */
|
|
166
|
+
export type StreamPlan = {
|
|
167
|
+
path: string;
|
|
168
|
+
value: string;
|
|
169
|
+
keep: number;
|
|
170
|
+
ms: number;
|
|
171
|
+
pace?: 'voice';
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* 这一步的流式输出怎么出字(D56,D100)。prev 是这一步之前的状态;不知道时传 null(整段重新出,用于估算)。
|
|
175
|
+
* - 接着往后写:新值以原来的值开头时,原有的字直接显示,只有新加的字逐字出现;
|
|
176
|
+
* - pace: 'voice':新加的字在这一步朗读(narrate ?? say)的估算时长里出完,读到哪写到哪;没有朗读时退回按字数。
|
|
177
|
+
*/
|
|
178
|
+
export declare function streamPlan(step: Step | undefined, prev: Pick<PlayState, 'ui' | 'data' | 'inputs'> | null): StreamPlan[];
|
|
164
179
|
/** 动作和业务效果完全相同的公共前缀步数;字幕、镜头、分叉等展示信息不参与。 */
|
|
165
180
|
export declare function commonPrefix(a: readonly Pick<Step, 'action' | 'effects'>[], b: readonly Pick<Step, 'action' | 'effects'>[]): number;
|
|
166
181
|
export declare function forksAt(project: Project, scenarioId: string | null | undefined, position: number): Step['forks'];
|
package/dist/player.js
CHANGED
|
@@ -8,6 +8,7 @@ import { pluginActionSpec, validActionData } from "./actions.js";
|
|
|
8
8
|
*/
|
|
9
9
|
import { DIRECTOR_LAYER, PAGE_LAYER, isInteractiveType, VIEWPORT_SIZE, atWidth, childWidth, breakpointPx, choicesFromData, hiddenAtWidth, matchChoice, nodeLabel } from "./catalog.js";
|
|
10
10
|
import { JoploError } from "./result.js";
|
|
11
|
+
import { streamMs, voicePacedMs } from "./pace.js";
|
|
11
12
|
// ---------- 查找 ----------
|
|
12
13
|
export function getScenario(project, scenarioId) {
|
|
13
14
|
const sc = project.scenarios[scenarioId];
|
|
@@ -558,7 +559,21 @@ export function roleOfScene(project, sceneId) {
|
|
|
558
559
|
}
|
|
559
560
|
/** 第 index 步(0 起)流式输出的状态路径与文字。 */
|
|
560
561
|
export function streamsOf(step) {
|
|
561
|
-
return (step?.effects ?? []).flatMap((e) => (e.type === 'stream' ? [{ path: e.path, value: e.value }] : []));
|
|
562
|
+
return (step?.effects ?? []).flatMap((e) => (e.type === 'stream' ? [{ path: e.path, value: e.value, ...(e.pace ? { pace: e.pace } : {}) }] : []));
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* 这一步的流式输出怎么出字(D56,D100)。prev 是这一步之前的状态;不知道时传 null(整段重新出,用于估算)。
|
|
566
|
+
* - 接着往后写:新值以原来的值开头时,原有的字直接显示,只有新加的字逐字出现;
|
|
567
|
+
* - pace: 'voice':新加的字在这一步朗读(narrate ?? say)的估算时长里出完,读到哪写到哪;没有朗读时退回按字数。
|
|
568
|
+
*/
|
|
569
|
+
export function streamPlan(step, prev) {
|
|
570
|
+
return streamsOf(step).map((s) => {
|
|
571
|
+
const before = prev ? readPath(prev, s.path) : undefined;
|
|
572
|
+
const keep = typeof before === 'string' && before && s.value.startsWith(before) ? [...before].length : 0;
|
|
573
|
+
const fresh = [...s.value].slice(keep).join('');
|
|
574
|
+
const voiced = s.pace === 'voice' ? voicePacedMs(step?.narrate ?? step?.say) : 0;
|
|
575
|
+
return { path: s.path, value: s.value, keep, ms: fresh ? (voiced || streamMs(fresh)) : 0, ...(s.pace ? { pace: s.pace } : {}) };
|
|
576
|
+
});
|
|
562
577
|
}
|
|
563
578
|
// ---------- 分叉、标注与变化(D56 P1) ----------
|
|
564
579
|
/** 动作和业务效果完全相同的公共前缀步数;字幕、镜头、分叉等展示信息不参与。 */
|
package/dist/plugins/compiler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PluginAction } from "../schema.js";
|
|
2
2
|
import { ElementTraitsSchema, InheritSchema } from "../traits.js";
|
|
3
3
|
import { advanceMedia } from "../media.js";
|
|
4
|
+
import { stepAnchorMs } from "../focus.js";
|
|
4
5
|
import { jsonData, snapshot, object, strings, syncResult, authoringData, materialize, errorMessage } from "./data.js";
|
|
5
6
|
/** Node-side plugin host. Callbacks never enter IR or the player. */
|
|
6
7
|
import { isNode } from '@joplo-app/kit/node';
|
|
@@ -280,7 +281,7 @@ export class PluginCompiler {
|
|
|
280
281
|
} }), source);
|
|
281
282
|
if (result === undefined)
|
|
282
283
|
return;
|
|
283
|
-
if (!object(result) || Object.keys(result).some(k => !['data', 'targets', 'references', 'media', 'writes', 'directorTarget'].includes(k)) || result.targets !== undefined && !strings(result.targets) || result.references !== undefined && !strings(result.references)) {
|
|
284
|
+
if (!object(result) || Object.keys(result).some(k => !['data', 'targets', 'references', 'media', 'writes', 'directorTarget', 'holdMs'].includes(k)) || result.targets !== undefined && !strings(result.targets) || result.references !== undefined && !strings(result.references)) {
|
|
284
285
|
this.invalid(p, source);
|
|
285
286
|
return;
|
|
286
287
|
}
|
|
@@ -296,12 +297,17 @@ export class PluginCompiler {
|
|
|
296
297
|
this.invalid(p, source);
|
|
297
298
|
return;
|
|
298
299
|
}
|
|
300
|
+
// 效果时长(D98):这一步至少停留多久(引擎毫秒,0–60000)
|
|
301
|
+
if (result.holdMs !== undefined && (typeof result.holdMs !== 'number' || !Number.isFinite(result.holdMs) || result.holdMs < 0 || result.holdMs > 60_000)) {
|
|
302
|
+
this.invalid(p, source);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
299
305
|
const writes = result.writes === undefined ? undefined : this.envelope(p, result.writes, source);
|
|
300
306
|
if (result.writes !== undefined && writes === undefined)
|
|
301
307
|
return;
|
|
302
308
|
const media = result.media?.map(c => ({ ...c, plugin: p.id }));
|
|
303
309
|
const value = result.data === undefined ? undefined : this.envelope(p, result.data, source);
|
|
304
|
-
return { ...(writes ? { writes } : {}), ...(result.directorTarget ? { directorTarget: result.directorTarget } : {}), ...(media ? { media } : {}), ...(value !== undefined ? { data: value } : {}), ...(result.targets ? { targets: [...result.targets] } : {}), ...(result.references ? { references: [...result.references] } : {}) };
|
|
310
|
+
return { ...(writes ? { writes } : {}), ...(result.directorTarget ? { directorTarget: result.directorTarget } : {}), ...(result.holdMs ? { holdMs: Math.round(result.holdMs) } : {}), ...(media ? { media } : {}), ...(value !== undefined ? { data: value } : {}), ...(result.targets ? { targets: [...result.targets] } : {}), ...(result.references ? { references: [...result.references] } : {}) };
|
|
305
311
|
});
|
|
306
312
|
}
|
|
307
313
|
frames(project) {
|
|
@@ -323,7 +329,7 @@ export class PluginCompiler {
|
|
|
323
329
|
const scenes = Object.values(project.scenes).filter(s => s.optionId === sc.optionId || s.optionId == null).map(s => ({ id: s.id, root: s.root }));
|
|
324
330
|
const roots = scenes.map(s => s.root);
|
|
325
331
|
const prev = sc.from ? project.scenarios[sc.from] : undefined;
|
|
326
|
-
let media = prev && ended.has(prev.id) ? advanceMedia(ended.get(prev.id), prev.steps.length ? prev.steps[prev.steps.length - 1]
|
|
332
|
+
let media = prev && ended.has(prev.id) ? advanceMedia(ended.get(prev.id), prev.steps.length ? stepAnchorMs(prev.steps[prev.steps.length - 1]) : 0) : {};
|
|
327
333
|
const hasMedia = Object.keys(media).length > 0 || sc.steps.some(step => this.mediaCommands.has(step.id));
|
|
328
334
|
let previousState;
|
|
329
335
|
let state = initialState(project, sc.id);
|
|
@@ -338,7 +344,7 @@ export class PluginCompiler {
|
|
|
338
344
|
const target = i ? sc.steps[i - 1] : sc;
|
|
339
345
|
const ext = { ...target.ext };
|
|
340
346
|
if (i) {
|
|
341
|
-
media = advanceMedia(media, i > 1 ? (sc.steps[i - 2]
|
|
347
|
+
media = advanceMedia(media, i > 1 ? stepAnchorMs(sc.steps[i - 2]) : 0);
|
|
342
348
|
for (const c of this.mediaCommands.get(sc.steps[i - 1].id) ?? []) {
|
|
343
349
|
const key = `${c.plugin}:${c.track}`;
|
|
344
350
|
const current = media[key];
|
package/dist/schema.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ export declare const Effect: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
179
179
|
type: z.ZodLiteral<"stream">;
|
|
180
180
|
path: z.ZodString;
|
|
181
181
|
value: z.ZodString;
|
|
182
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
182
183
|
}, z.core.$strict>], "type">;
|
|
183
184
|
/** 镜头(D43):这一步在某个层级里对准哪些元素;targets 为空 = 这一层的整体。 */
|
|
184
185
|
export declare const Shot: z.ZodObject<{
|
|
@@ -357,6 +358,7 @@ export declare const Step: z.ZodObject<{
|
|
|
357
358
|
type: z.ZodLiteral<"stream">;
|
|
358
359
|
path: z.ZodString;
|
|
359
360
|
value: z.ZodString;
|
|
361
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
360
362
|
}, z.core.$strict>], "type">>>;
|
|
361
363
|
ruleIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
362
364
|
shots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -402,7 +404,9 @@ export declare const Step: z.ZodObject<{
|
|
|
402
404
|
}>>;
|
|
403
405
|
}, z.core.$strict>>>;
|
|
404
406
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
407
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
405
408
|
say: z.ZodOptional<z.ZodString>;
|
|
409
|
+
sayRole: z.ZodOptional<z.ZodString>;
|
|
406
410
|
narrate: z.ZodOptional<z.ZodString>;
|
|
407
411
|
source: z.ZodOptional<z.ZodString>;
|
|
408
412
|
}, z.core.$strict>;
|
|
@@ -568,6 +572,7 @@ export declare const Scenario: z.ZodObject<{
|
|
|
568
572
|
type: z.ZodLiteral<"stream">;
|
|
569
573
|
path: z.ZodString;
|
|
570
574
|
value: z.ZodString;
|
|
575
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
571
576
|
}, z.core.$strict>], "type">>>;
|
|
572
577
|
ruleIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
573
578
|
shots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -613,7 +618,9 @@ export declare const Scenario: z.ZodObject<{
|
|
|
613
618
|
}>>;
|
|
614
619
|
}, z.core.$strict>>>;
|
|
615
620
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
621
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
616
622
|
say: z.ZodOptional<z.ZodString>;
|
|
623
|
+
sayRole: z.ZodOptional<z.ZodString>;
|
|
617
624
|
narrate: z.ZodOptional<z.ZodString>;
|
|
618
625
|
source: z.ZodOptional<z.ZodString>;
|
|
619
626
|
}, z.core.$strict>>>;
|
|
@@ -772,6 +779,7 @@ export declare const FreeReaction: z.ZodObject<{
|
|
|
772
779
|
type: z.ZodLiteral<"stream">;
|
|
773
780
|
path: z.ZodString;
|
|
774
781
|
value: z.ZodString;
|
|
782
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
775
783
|
}, z.core.$strict>], "type">>>;
|
|
776
784
|
source: z.ZodOptional<z.ZodString>;
|
|
777
785
|
}, z.core.$strict>;
|
|
@@ -861,6 +869,7 @@ export declare const Option: z.ZodObject<{
|
|
|
861
869
|
type: z.ZodLiteral<"stream">;
|
|
862
870
|
path: z.ZodString;
|
|
863
871
|
value: z.ZodString;
|
|
872
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
864
873
|
}, z.core.$strict>], "type">>>;
|
|
865
874
|
source: z.ZodOptional<z.ZodString>;
|
|
866
875
|
}, z.core.$strict>>>;
|
|
@@ -1225,6 +1234,7 @@ export declare const Project: z.ZodObject<{
|
|
|
1225
1234
|
type: z.ZodLiteral<"stream">;
|
|
1226
1235
|
path: z.ZodString;
|
|
1227
1236
|
value: z.ZodString;
|
|
1237
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
1228
1238
|
}, z.core.$strict>], "type">>>;
|
|
1229
1239
|
source: z.ZodOptional<z.ZodString>;
|
|
1230
1240
|
}, z.core.$strict>>>;
|
|
@@ -1468,6 +1478,7 @@ export declare const Project: z.ZodObject<{
|
|
|
1468
1478
|
type: z.ZodLiteral<"stream">;
|
|
1469
1479
|
path: z.ZodString;
|
|
1470
1480
|
value: z.ZodString;
|
|
1481
|
+
pace: z.ZodOptional<z.ZodLiteral<"voice">>;
|
|
1471
1482
|
}, z.core.$strict>], "type">>>;
|
|
1472
1483
|
ruleIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1473
1484
|
shots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -1513,7 +1524,9 @@ export declare const Project: z.ZodObject<{
|
|
|
1513
1524
|
}>>;
|
|
1514
1525
|
}, z.core.$strict>>>;
|
|
1515
1526
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
1527
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
1516
1528
|
say: z.ZodOptional<z.ZodString>;
|
|
1529
|
+
sayRole: z.ZodOptional<z.ZodString>;
|
|
1517
1530
|
narrate: z.ZodOptional<z.ZodString>;
|
|
1518
1531
|
source: z.ZodOptional<z.ZodString>;
|
|
1519
1532
|
}, z.core.$strict>>>;
|
package/dist/schema.js
CHANGED
|
@@ -95,7 +95,8 @@ export const Effect = z.discriminatedUnion('type', [
|
|
|
95
95
|
z.strictObject({ type: z.literal('navigate'), sceneId: Qid }),
|
|
96
96
|
z.strictObject({ type: z.literal('complete'), text: z.string().min(1), outcome: z.enum(['success', 'failure', 'cancelled']) }),
|
|
97
97
|
/** 流式输出(D56):状态上等同 set;播放到这一步时绑定它的文字逐字出现。 */
|
|
98
|
-
|
|
98
|
+
/** pace: 'voice'(D100):新加的字跟着这一步的朗读出;没有时按模型输出的速度。 */
|
|
99
|
+
z.strictObject({ type: z.literal('stream'), path: StatePath, value: z.string(), pace: z.literal('voice').optional() }),
|
|
99
100
|
]);
|
|
100
101
|
/** 镜头(D43):这一步在某个层级里对准哪些元素;targets 为空 = 这一层的整体。 */
|
|
101
102
|
export const Shot = z.strictObject({ layer: z.string().min(1), targets: z.array(z.string().min(1)) });
|
|
@@ -152,8 +153,12 @@ export const Step = z.strictObject({
|
|
|
152
153
|
callouts: z.array(Callout).optional(),
|
|
153
154
|
/** 自动播放时这一步至少停留的毫秒数(D70,来自 hold;未按速度缩放);没有时省略。 */
|
|
154
155
|
hold: z.number().int().positive().max(30_000).optional(),
|
|
156
|
+
/** 插件效果声明的最短停留(D98,毫秒、未按速度缩放):同一步各效果 holdMs 的最大值;没有时省略。 */
|
|
157
|
+
effectHold: z.number().int().positive().max(60_000).optional(),
|
|
155
158
|
/** 角色台词(D74,来自 say(),多个按空格连接):用这一步角色的声音读;没有时省略。发布站保留。 */
|
|
156
159
|
say: z.string().min(1).optional(),
|
|
160
|
+
/** 台词是谁说的(D100,来自 say(…, { role }),feature.roles 的键):优先于“操作步骤取导演层的角色”;没有时省略。 */
|
|
161
|
+
sayRole: z.string().min(1).optional(),
|
|
157
162
|
/** 旁白(D74,来自 narrate()):用旁白的声音读,优先于台词和字幕;没有时省略。发布站保留。 */
|
|
158
163
|
narrate: z.string().min(1).optional(),
|
|
159
164
|
source: Source,
|
package/dist/voice.js
CHANGED
|
@@ -49,6 +49,9 @@ export function narrationText(step, caption) {
|
|
|
49
49
|
/** 第 index 步(1 起)的说话角色:用户操作取这一步之后导演所在层画面的角色 id;没有角色、系统步骤与过渡卡为 null。say() 用它的声音。 */
|
|
50
50
|
export function speakerRoleAt(project, scenarioId, index) {
|
|
51
51
|
const step = project.scenarios[scenarioId]?.steps[index - 1];
|
|
52
|
+
// say(…, { role }) 写明了是谁(D100):任何步骤都以它为准(系统步骤没有“操作的人”)
|
|
53
|
+
if (step?.say && step.sayRole)
|
|
54
|
+
return step.sayRole;
|
|
52
55
|
if (!step || step.kind !== 'user')
|
|
53
56
|
return null;
|
|
54
57
|
const layer = cameraAt(project, scenarioId, index).directorLayer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Joplo 编译器、校验器与播放器(IR v2)",
|
|
5
5
|
"license": "PolyForm-Shield-1.0.0",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@joplo-app/kit": "0.
|
|
26
|
+
"@joplo-app/kit": "0.5.0",
|
|
27
27
|
"zod": "4.6.7"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|