@joplo-app/core 0.3.0 → 0.4.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/catalog.d.ts +0 -5
- package/dist/catalog.js +0 -5
- package/dist/compile.js +5 -0
- package/dist/focus.d.ts +3 -1
- package/dist/focus.js +12 -2
- package/dist/guide.js +17 -11
- package/dist/plugins/compiler.d.ts +1 -0
- package/dist/plugins/compiler.js +10 -4
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +2 -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
|
@@ -378,6 +378,8 @@ export function compile(src, mode, opts = {}) {
|
|
|
378
378
|
const explains = [];
|
|
379
379
|
const says = [];
|
|
380
380
|
const narrates = [];
|
|
381
|
+
/** 插件效果声明的最短停留(D98):同一步取最大值。 */
|
|
382
|
+
let effectHoldMs = 0;
|
|
381
383
|
const ext = {};
|
|
382
384
|
const references = [];
|
|
383
385
|
const pluginFocus = [];
|
|
@@ -429,6 +431,8 @@ export function compile(src, mode, opts = {}) {
|
|
|
429
431
|
effects.push(...(lowered.writes ?? []).map(w => ({ type: 'set', path: w.path, value: w.value })));
|
|
430
432
|
if (lowered.directorTarget)
|
|
431
433
|
directorTargets.push(lowered.directorTarget);
|
|
434
|
+
if (lowered.holdMs)
|
|
435
|
+
effectHoldMs = Math.max(effectHoldMs, lowered.holdMs);
|
|
432
436
|
if (lowered.media?.length) {
|
|
433
437
|
const key = `${sid}#${i + 1}`;
|
|
434
438
|
host.mediaCommands.set(key, [...(host.mediaCommands.get(key) ?? []), ...lowered.media]);
|
|
@@ -605,6 +609,7 @@ export function compile(src, mode, opts = {}) {
|
|
|
605
609
|
...(cues.length ? { cues } : {}),
|
|
606
610
|
...(callouts.length ? { callouts } : {}),
|
|
607
611
|
...(holdMs !== undefined ? { hold: holdMs } : {}),
|
|
612
|
+
...(effectHoldMs > 0 ? { effectHold: effectHoldMs } : {}),
|
|
608
613
|
...(says.length ? { say: says.join(' ') } : {}),
|
|
609
614
|
...(narrates.length ? { narrate: narrates.join(' ') } : {}),
|
|
610
615
|
...(st.source ? { source: rel(st.source) } : {}),
|
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
|
|
|
@@ -331,7 +331,7 @@ The host can draw an input/keyboard record after a type/press step, and toasts c
|
|
|
331
331
|
- For layout, visual motion, shapes, charts and component APIs use the installed plugin skills. The engine has no built-in component vocabulary.
|
|
332
332
|
|
|
333
333
|
## 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
|
|
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 in the board and in the built site (npx joplo preview). Component defaults and styling recipes belong to the owning plugin.
|
|
335
335
|
|
|
336
336
|
## Branches, annotations and appearance
|
|
337
337
|
- 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.
|
|
@@ -727,7 +727,7 @@ Compare cases and options in the board, then decide which option to publish for
|
|
|
727
727
|
- Pages and layouts compose the whole product; picked options add elements to routes or add routes.
|
|
728
728
|
|
|
729
729
|
## build
|
|
730
|
-
- Run npx joplo check in the author project, then npx joplo build.
|
|
730
|
+
- 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
731
|
- Default output: dist/. Set --out-dir <dir> to change it.
|
|
732
732
|
- Nonempty output directories are rejected. After confirming the old output can be discarded, pass --overwrite to clear and rebuild.
|
|
733
733
|
- The published site contains only feature names, goals, scenario demos, step captions, and the overall layout.
|
|
@@ -738,10 +738,12 @@ Compare cases and options in the board, then decide which option to publish for
|
|
|
738
738
|
- The published site uses the same layout as the local board, with authoring details such as rules, gaps, and source locations removed.
|
|
739
739
|
- Layer switching, Follow director, replaying one layer, shot focus, and captions all work on the published site. See demo for syntax.
|
|
740
740
|
- 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
|
-
-
|
|
741
|
+
- 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.
|
|
742
|
+
- 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.
|
|
743
|
+
- Fullscreen keeps only the stage (with its subtitle and step title). Playback controls float below and hide automatically.
|
|
742
744
|
- 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
745
|
- 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
|
|
746
|
+
- 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
747
|
- Both local and published views can export images. Video export is local only.
|
|
746
748
|
- 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
749
|
|
|
@@ -870,7 +872,7 @@ The engine supplies authoring, compilation, state, scheduling and host services.
|
|
|
870
872
|
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
873
|
|
|
872
874
|
## Optional 3D
|
|
873
|
-
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.
|
|
875
|
+
The starter does not include 3D or its large browser dependency. To add it: npm install @joplo-app/plugin-3d@0.4.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.
|
|
874
876
|
|
|
875
877
|
## Errors and trust
|
|
876
878
|
- 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 +883,24 @@ The starter does not include 3D or its large browser dependency. To add it: npm
|
|
|
881
883
|
## Write a plugin
|
|
882
884
|
- 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
885
|
- 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
|
|
886
|
+
- 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
887
|
- 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
888
|
- 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
889
|
- 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
|
-
-
|
|
890
|
+
- 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.
|
|
891
|
+
- Effect compilers return declarative writes, references, optional directorTarget, media commands, derived data and optional holdMs. Preserve source ordering.
|
|
892
|
+
- 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.
|
|
893
|
+
- 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
894
|
- 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
895
|
|
|
891
896
|
## Runtime and projection
|
|
892
897
|
- 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.
|
|
898
|
+
- 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
899
|
- 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
900
|
- 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.
|
|
895
901
|
- 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
902
|
- 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,
|
|
903
|
+
- 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
904
|
- 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
905
|
|
|
900
906
|
## Local resources and media
|
|
@@ -905,8 +911,8 @@ The starter does not include 3D or its large browser dependency. To add it: npm
|
|
|
905
911
|
- 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
912
|
- 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
913
|
- 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
|
|
914
|
+
- 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.
|
|
915
|
+
- 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
916
|
|
|
911
917
|
## Verify the package
|
|
912
918
|
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/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
|
@@ -402,6 +402,7 @@ export declare const Step: z.ZodObject<{
|
|
|
402
402
|
}>>;
|
|
403
403
|
}, z.core.$strict>>>;
|
|
404
404
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
405
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
405
406
|
say: z.ZodOptional<z.ZodString>;
|
|
406
407
|
narrate: z.ZodOptional<z.ZodString>;
|
|
407
408
|
source: z.ZodOptional<z.ZodString>;
|
|
@@ -613,6 +614,7 @@ export declare const Scenario: z.ZodObject<{
|
|
|
613
614
|
}>>;
|
|
614
615
|
}, z.core.$strict>>>;
|
|
615
616
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
617
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
616
618
|
say: z.ZodOptional<z.ZodString>;
|
|
617
619
|
narrate: z.ZodOptional<z.ZodString>;
|
|
618
620
|
source: z.ZodOptional<z.ZodString>;
|
|
@@ -1513,6 +1515,7 @@ export declare const Project: z.ZodObject<{
|
|
|
1513
1515
|
}>>;
|
|
1514
1516
|
}, z.core.$strict>>>;
|
|
1515
1517
|
hold: z.ZodOptional<z.ZodNumber>;
|
|
1518
|
+
effectHold: z.ZodOptional<z.ZodNumber>;
|
|
1516
1519
|
say: z.ZodOptional<z.ZodString>;
|
|
1517
1520
|
narrate: z.ZodOptional<z.ZodString>;
|
|
1518
1521
|
source: z.ZodOptional<z.ZodString>;
|
package/dist/schema.js
CHANGED
|
@@ -152,6 +152,8 @@ export const Step = z.strictObject({
|
|
|
152
152
|
callouts: z.array(Callout).optional(),
|
|
153
153
|
/** 自动播放时这一步至少停留的毫秒数(D70,来自 hold;未按速度缩放);没有时省略。 */
|
|
154
154
|
hold: z.number().int().positive().max(30_000).optional(),
|
|
155
|
+
/** 插件效果声明的最短停留(D98,毫秒、未按速度缩放):同一步各效果 holdMs 的最大值;没有时省略。 */
|
|
156
|
+
effectHold: z.number().int().positive().max(60_000).optional(),
|
|
155
157
|
/** 角色台词(D74,来自 say(),多个按空格连接):用这一步角色的声音读;没有时省略。发布站保留。 */
|
|
156
158
|
say: z.string().min(1).optional(),
|
|
157
159
|
/** 旁白(D74,来自 narrate()):用旁白的声音读,优先于台词和字幕;没有时省略。发布站保留。 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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.4.1",
|
|
27
27
|
"zod": "4.6.7"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|