@joplo-app/plugin-content 0.8.0 → 0.8.2

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.
@@ -0,0 +1,18 @@
1
+ export declare const DEFAULT_MOVE_MS = 1200;
2
+ export declare const FRAMING: {
3
+ readonly overview: {
4
+ readonly pad: 128;
5
+ readonly zoom: 1.25;
6
+ readonly ms: 1400;
7
+ };
8
+ readonly medium: {
9
+ readonly pad: 64;
10
+ readonly zoom: 2;
11
+ readonly ms: 1200;
12
+ };
13
+ readonly detail: {
14
+ readonly pad: 16;
15
+ readonly zoom: 4;
16
+ readonly ms: 900;
17
+ };
18
+ };
@@ -0,0 +1,6 @@
1
+ export const DEFAULT_MOVE_MS = 1200;
2
+ export const FRAMING = {
3
+ overview: { pad: 128, zoom: 1.25, ms: 1400 },
4
+ medium: { pad: 64, zoom: 2, ms: DEFAULT_MOVE_MS },
5
+ detail: { pad: 16, zoom: 4, ms: 900 },
6
+ };
package/dist/guide.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const skill = "# Joplo content production: content\n\nFor explainers, tutorials, science and news-explainer pieces that should feel like a good video, not a deck: the viewer watches a world change while a voice explains it.\nAuthor one standalone work in works/<key>.tsx with work(); put chapter() slices under scenarios and narrate() in their steps. Chapters continue in declaration order by default. Works have covers and enter the project home page; no feature, review cases or pick is needed. Full example: examples/llm-explainer.\n\nInstall @joplo-app/plugin-content at the Joplo version; import content and add it to config.plugins. Import { Canvas, Split, camera } from this package; keep work, chapter, patch, narrate and hold from @joplo-app/kit. Use theme: 'content:studio' for the bundled CSS. No plugin is implicitly enabled.\n\n## Minimal work\nIn a project with content enabled in config.plugins (and the starter's type: module / JSX tsconfig):\n```tsx\n// works/explainer.tsx\nimport { work, chapter, narrate } from '@joplo-app/kit';\nimport { Canvas } from '@joplo-app/plugin-content';\nexport default work({ title: 'A request in motion', summary: 'Follow one request',\n stage: <Canvas w={1280} h={800} />,\n scenarios: {\n arrival: chapter('A request arrives', { expected: 'Understand where it starts' })\n .system('Arrive', narrate('A request arrives.')),\n response: chapter('The worker responds').system('Respond', narrate('The worker replies.')),\n },\n});\n```\nThis is the authoring skeleton; add a visible subject and real changing state before reviewing the film. stage/layers needs no routes/ directory. Use on/routes explicitly when reusing product pages. WORK_INVALID means repair the required fields or slice builders; WORK_SLICES_MIXED means use chapter() consistently; FROM_UNKNOWN lists valid keys; WORK_EMPTY means add your first slice. Keep render/deep-link ids from outline --format json (standalone: explainer.arrival; feature-attached: queue.a.waiting), while --work takes the public entry key.\n\n## 1. Before TSX: package and plan within the agreed scope\n- One thing the viewer should be able to repeat afterwards, in one sentence.\n- Package first: the title asks the question; a thumbnail line of at most five words gives the surprising answer (complement the title, never repeat it); chapter('Slice title', { description }) is the cover sentence. The share preview is the first scenario's first frame, so design that frame as a thumbnail: one big line, one focal object, high contrast.\n- If the framing is unresolved, offer two or three devices (one running example, misconception then correction, a number made tangible, before and after) with a recommendation. Reuse an already agreed design; do not repeat approval rounds the user has waived.\n- Chapters: one question per chapter. Chapter titles are questions ('What does it actually read?'); the UI adds their numbers automatically. chapter('Slice title', { expected }) is what the viewer can now say. List every point from the source material and map each to a chapter or drop it on purpose.\n- One running example through every chapter (the same prompt, person, or data set), so each chapter builds on what the viewer already saw.\n- Write the script as one line per step: ears (narrate), eyes (what changes on stage), source. Adjacent steps should connect with 'but' or 'so'; a chain of 'and then' is flat.\n- Budget: narration reads about 4.5 CJK characters (2.5 English words) per second; 45\u201390 s per chapter. About 400 CJK characters can already exceed 90 seconds. npx joplo outline counts narration in its estimates.\n\n## Asset-first preparation\nBefore building a device, historical interface or illustrated object, make an asset list. Prefer a suitable licensed library, icon set or model; do not hand-write complex SVG or build a model merely because JSX can draw it. Verify the actual asset license, collect files in assets/, retain licenses and record author, URL and modifications in assets/SOURCES.md. Historical facts and historical appearance are separate evidence: label stylized reconstructions and invented messages, and avoid copied logos/system icons. Use original work only when a suitable reusable asset is unavailable, keeping it simple.\n\n## 2. Hook (first chapter, 20\u201335 s)\n- Beat 1: a familiar scene that pays off the thumbnail. Never a logo, an agenda, or a definition first.\n- Beat 2: the twist, shown on stage (the answer splits into pieces with probabilities, a name changes on the second try).\n- Beat 3: pull back and name the questions the episode answers. Pin each question where it will be answered, and close every loop later.\n\n## Camera sequences and persistent materials\nUse cameraSequence for a single long explanation that needs deliberate framing throughout (not high-frequency drawing). Import it from @joplo-app/plugin-content and put it in a scripted system step:\n```ts\ncameraSequence([\n { atMs: 0, target: 'room', zoom: 1 },\n { atMs: 2500, target: 'message', zoom: 1.15, ease: 'easeInOut' },\n { atMs: 6500, target: 'message', zoom: 1.22, ease: 'easeOut' },\n])\n```\nWaypoints start at 0, increase strictly, end within 60000 ms, and use existing element IDs (or targets: [...] for a group). Each waypoint may set pad/zoom; ease belongs to the incoming segment (easeInOut default, easeOut or linear). The step stays at least until the last waypoint. Pause and speed follow engine time. Static renders, deep-link jumps, animate=false and reduced motion show the final waypoint. Free exploration yields to the final layout. Existing camera() and drift remain valid; a sequence replaces drift for that framing state. An ordinary next step inherits the current path; explicitly issuing even the same cameraSequence again restarts it. A continuing chapter inherits the final frame until it issues a new sequence. End with camera() when changing the subject.\n\nFor the same subject changing material, keep one motion key and bind the destination layout, borderRadius, color, backgroundColor, opacity and text to state. Content interpolates those supported style values along the same motion flight; changed text crossfades through a temporary inert, aria-hidden clone without a second motion identity. Static jumps show destination styles immediately. This is a transition between authored states, not arbitrary per-frame drawing. Keep interactive controls in the live subject: the fading clone has no hit area or focus identity. Test long text at both endpoints and play the transition with Voice on; do not infer continuous motion from static storyboard frames.\n\n## 3. Not slides: one world, continuous objects, a moving camera (the core)\nFailure mode, even with nice graphics: one board per chapter (big title, panels, footer), chapter title cards, cards of bullets, things fading in and out. Viewers read it as a deck. Instead:\n- One layer holding one <Canvas w={2560} h={1600}> world (the default view is 1280\u00D7800, scaled to fit, never re-laid out; in a container without a height it sizes itself from the view ratio, and render warns 'Canvas has no size' if it still has none). Place a few containers absolutely in design pixels; lay out inside them with flex.\n- Objects keep their identity: give each one motion=\"key\". Write each arrangement as static JSX switched with when, reusing the same key; between steps Joplo flies the object from its old place and size to the new one, also across containers. Morph, never replace: the question's words split into tokens, flip into ids, then fly onto a tape; bars rearrange into a lottery strip.\n- When the same key also changes its look, the flight carries the change (see \"Camera sequences and persistent materials\"): the keyed element's own borderRadius, color, backgroundColor and opacity interpolate, and when its text, class, inline style or inner structure differ (a plain word becoming a coloured token, a 1984 button becoming a 1995 button, a label \"45%\" becoming \"98%\"), the old look crossfades out along the same flight. This also happens in place, when only the look changed. Write the two looks as two same-key elements switched with when, or bind the styles to state; jumps and screenshots show the new look.\n- shot() draws the host focus ring and caps UI zoom at 1.25\u00D7; use camera() for traveling inside a Canvas without that ring.\n- For diagram trace inside Canvas, pass { focus: false } to trace(...ids, options) so only the Canvas camera owns framing.\n- When another plugin effect also suggests host focus (for example a diagram trace inside a Canvas), use an explicit shot() for the whole director layer if the Canvas camera should own the framing. Otherwise host zoom and Canvas zoom can multiply and push nearby text out of view. Verify the actual visible bounds in playback, not only DOM text.\n- Camera: camera('id', \u2026) frames those elements (Joplo measures them, adds pad, caps zoom); camera() shows the whole canvas. Establish wide, push in on detail, pull back for the payoff. Object flights in the same step follow the camera's timing, so both land together.\n- Chapters continue: chapter() starts from the previous chapter's last frame (state, camera, director layer) by default. Only use from: null to restart, or from: 'sliceKey' for another predecessor; keep all slices chapter() within this work. patch($.ui, { \u2026 }) changes several values in one step.\n- System-only chapters stay on the initial director layer unless camera(), shot(), a cue, or chapter('Slice title', { layer }) selects another layer. Continuing from a chapter inherits its final layer; do not copy its state by hand.\n- screen children of the Canvas stay fixed on screen: chapter label, source line, poster, end card.\n- Takeaways land on objects (a pinned question flips to '\u2713 answer'); the recap is a pull back to the whole world. Use .card() only when nothing on stage can carry the moment.\n```tsx\n<Canvas w={2560} h={1600}>\n <div id=\"tape\" style={{ position: 'absolute', left: 120, top: 960, display: 'flex', gap: 8 }}>\n {IDS.map((t, i) => <span when={eq($.ui.at, 'tape')} motion={`tok_${i}`} style={{ background: COLORS[i] }}>{t}</span>)}\n </div>\n <div screen style={{ position: 'absolute', left: 20, top: 16 }}>{$.ui.chapter}</div>\n</Canvas>\nchapter('What does it read?')\n .system('Split', 'Nine characters, seven pieces', patch($.ui, { mode: 'split' }), camera('bubble', { pad: 160 }))\n .system('To the tape', 'It reads these numbers', patch($.ui, { at: 'tape' }), camera('tape', 'meter'))\n```\n- Anti-deck test: three or more steps that only show or hide whole panels, or a frame that is mostly text, means rebuild those steps as objects that move or change.\n\n## 3b. Transitions, drift and the safe area\n- enter / exit on any element inside the Canvas (world or screen layer): fade, rise, zoom, shrink, wipe, iris, grow, growUp, blur. Timing: enterMs / enterDelay / exitMs / exitDelay (0\u201310000 ms literals; defaults 600 / 450). Each preset is an \"away\" pose: enter goes away \u2192 the element's own look, exit goes own look \u2192 away. The grow left edge and growUp bottom edge stay anchored throughout entry and exit; they do not slide toward the default center as the size changes. Verify a middle frame as well as the final frame when aligning a growing bar with nearby content. So rise enters from below and exits sinking back; zoom lands from slightly larger and exits flying toward the camera; shrink grows from smaller and exits receding; wipe reveals left \u2192 right; iris opens from the centre; grow scales up from the left edge (horizontal bars, timeline rules, underlines) and growUp from the bottom edge (columns); blur comes into focus from a soft blur. The direction of grow / growUp is never guessed from the element's size: a short horizontal bar is narrower than it is tall and is still a horizontal bar. Set transform-origin in CSS to say where zoom/shrink grow from (a menu from its taskbar, a bubble from its tail).\n- enter plays when an element first appears (a new DOM node) during playback; exit plays when when becomes false: a non-interactive ghost copy keeps the last look and animates out, then disappears. Put enter + exit on two exclusive siblings in the same step for a crossfade. A same-motion-key element that flies (FLIP) never also enters or leaves.\n- How it settles: enterEase / exitEase / motionEase (FLIP flights) take smooth (default curve of each), snappy (fast start, short settle), spring (overshoots a little and settles), bounce (overshoots more, wobbles) or linear. The spring is a CSS linear() curve over the same ms, so it pauses, seeks and records like every other entrance; browsers without linear() get an overshooting cubic-bezier. Use spring for things that land or snap into place (a token joining a tape, a bar reaching its value, a call to action), bounce for one playful accent per chapter, snappy for typed or printed pieces; keep text the viewer is reading on smooth or snappy. motionEase overrides the camera-synchronised curve of a flight, so leave it unset when the camera moves in the same step.\n- Stagger a batch: enterStagger={ms} / exitStagger={ms} (0\u20132000) on a container delays the descendants that enter (or leave) in the same step by rank \u00D7 ms, in document order, on top of their own enterDelay. Only elements that actually play count: a same-key element that flies instead of entering does not take a slot, so \"three new tokens plus one that flies in\" staggers 0 / ms / 2\u00B7ms for the new three. Do not compute per-element enterDelay or animationDelay for a batch.\n- <Split text by=\"word\"|\"char\"> renders text that enters piece by piece: enter / enterMs / enterEase / enterDelay apply to every piece (default enter rise), the root does not enter itself, and enterStagger defaults to 70 ms (word) or 30 ms (char). Words come from Intl.Segmenter, so Chinese splits into words too; punctuation stays on its word (opening quotes and brackets on the next one) and lines never break inside a word. Screen readers read the whole sentence once. text may be a state binding: a new value is a new set of pieces and enters again (a chapter label in the screen layer). exit applies to the whole Split. Use it for a headline, a chapter label or an answer appearing; a body paragraph the viewer reads should not split.\n- Pick by meaning: fade for a whole-world swap under cover, rise for things that come from below (menus from a taskbar, keyboards, receipts), shrink for windows opening, zoom for something punching toward the viewer, wipe for typed/printed results, iris for a reveal from a point. Keep two or three per piece; do not give every element the same entrance.\n- camera(\u2026, { drift }) keeps the camera moving after it lands: a number = zoom factor reached over ms (default 8000), or { zoom, x, y, ms } with x/y in design px; false stops it. <Canvas drift={\u2026}> sets the default for every step; without either, a subtle 4 % / 8 s push applies. Drift eases in and out and stops at its end point; it freezes on pause, records in video, and screenshots/deep links show the settled frame without drift. The next camera move starts from where the drifting camera actually is, including when only drift changes or is switched off; the configured camera ms eases back to the target before the next drift.\n- <Canvas safe={[top, right, bottom, left]}> (design px) is the part of the view your screen-layer chrome covers. Targeted camera() frames fit inside the rest, and drift zooms around its centre; camera() with no ids still shows the whole world full-bleed.\n- UI life inside one interface (a caret blink, a stepped menu drop) can be CSS @keyframes in the project theme: the engine clock samples them, pause freezes them, static frames show their end state.\n\n## 4. Choose the information shape, then the picture\n- A number landing; before and after; ranking (bars from zero, length proportional); part of a whole (a strip whose segment widths are the shares); a process (one object going around a loop); misconception then fact; a timeline; a place (tiles or a simple map).\n- Similar sentences get different pictures. Labels sit on the thing they name; no legends when a direct label fits.\n- Compute numbers in TS from one source (for example probabilities from one set of scores) so every number on screen agrees. Label illustrative numbers on screen ('illustrative'), separate from sourced facts.\n\n## 5. Motion and layout numbers\n- Camera moves 1\u20131.5 s, ease in-out. Object flights 0.9 s ease-out; stagger 60\u2013120 ms (motionDelay); slow a landing pointer to 1.5\u20132 s (motionMs).\n- One primary motion per step; text that is being read does not move.\n- Entrances and exits: use enter / exit with enterEase and a container enterStagger (section 3b); a typed or word-by-word reveal is <Split> (by=\"char\", enter=\"blur\" or \"fade\", enterMs about 200, enterStagger 60\u2013160). Only for effects the presets do not cover put @keyframes and classes in themes/<name>.css and use className. Screenshots, thumbnails, and jumps show the end state. A 1 ms steps(1) CSS animation can stay stuck invisible in Chromium.\n- One accent color with a fixed meaning; color means the same thing in every chapter.\n- Size text for the frame you show: about 28 design px is the floor at 1\u00D7 zoom; a wide shot at 0.5\u00D7 needs 40 or more, or enlarge the labels for that shot (a bigger variant under the same motion key).\n- Frame by content (camera ids), not by guessed coordinates. Lay the world out as shot-sized clusters of roughly 16:10 (a machine with its output bars and strip, a chat with its bubbles); a cluster much wider than that leaves half the frame empty however you aim.\n- Same subject, same frame: keep one camera for consecutive steps about the same cluster; frame what stays on stage (not a container that has just emptied).\n\n## 6. Narration, captions, numbers\n- Caption: what the eye needs, ideally at most 16 CJK characters (24 is the hard limit). narrate(): what a presenter says, one or two sentences (rules: story section 6).\n- One number per step, rounded and written as spoken; translate numbers ('one chance in 365'). Pointing words are fine ('look at the dashed line').\n- When narration is on, keep on-stage text to labels; do not put the narrated sentence on screen too.\n\n## 7. Facts and sources\n- All facts in one data module with source and date; a source line (screen element) per chapter; name studies in narration ('OpenAI, in a 2025 paper, explains \u2026').\n- Say only what the source says. Bars start at zero. Separate illustrative values from facts on screen.\n- Images: licensed or public domain, credited, CREDITS file next to them (story section 7).\n\n## 8. Ending\n- Pull back to the whole world: every pinned question now shows its answer. Then one concrete action the viewer can take right away, as a screen element. Stop once the value lands; no 'thanks for watching'.\n\n## 9. Required: review before handing over\n- npx joplo check until 0 errors, then npx joplo outline --work <key>: verify the chapter order, step counts and estimated duration. Standalone works do not run feature coverage or HAPPY_PATH_ONLY checks.\n- Storyboard every chapter: npx joplo render --scenario-id <id> --sheet --out board.png prints every step in one image with its caption and narration. Read it frame by frame and assume the first one has problems: half-empty frames, objects cut at the edge, labels overlapping, text too small in wide shots, the chapter label covering content. Fix, then storyboard again.\n- Film-strip every chain of chapters: npx joplo render <dir> --scenario-id <first> --film --chain --out film.png. Fix every red CUT (one-frame full-screen change) unless it is your one deliberate cut, and every grey STILL (no visible change for \u2265 1.5 s). The storyboard cannot show either. Engine checklist: npx joplo skill demo, \"Make it play like a film\".\n- Play each chapter in the board with Voice on: flights and camera land together, nothing leaves the frame mid-flight, narration finishes before the next step.\n- Evidence, not belief: 'it plays' needs check 0 errors plus a run in the board; 'it looks right' needs the rendered frames; 'it is clear' needs captions-only and frames-only passes that both tell the story.\n- Tell the user what you could not verify (a real voice on a phone, other window sizes).\n\n## Migrating an existing script safely\n- Freeze the previous dev IR before moving files. Compare all steps, plugin drawing/media snapshots and every stateAt position after migration; a flow-to-chapter rename does not prove the same continuous state, motion or sound.\n- A chapter that previously began independently needs from: null. Default continuation carries the previous ui/data/inputs and running music; use it only when the next chapter should inherit that ending.\n- Put audience descriptions from feature.roles into audience. Preserve real role() speakers, the role keys used by say(), and config.voice.roles together; verify the chosen voices in playback.\n- If the project already has a helper named chapter, rename that helper before importing chapter from the kit.\n- Remove manual numbering from the chapter title itself, not every identical string. A transition card or caption may still use the old source text; let i18n missing/stale/unused diagnostics determine which translation keys need changing.\n- Inspect a path page before deleting it. A Slot-only/empty wrapper can be removed for stage/layers; reuse actual picture content through explicit on or the work's routes.\n- To prove a draft did not publish, search all build artifacts for one complete sentence unique to the old work and absent as a substring of current copy. Keep the old work locally with draft: true; do not rely on the published menu alone.\n\n## Diagnostics and recovery\n- CAMERA_UNKNOWN: the id must exist in a current layer or stage; frame elements inside this Canvas. CAMERA_INVALID: pad 0\u20132000, zoom 0.1\u201310, ms 0\u201310000, drift false | 0.5\u20132 | { zoom 0.5\u20132, x/y \u22122000\u20132000, ms 500\u201360000 }, finite numbers only; <Canvas drift> takes the same values and <Canvas safe> is four numbers 0\u20132000.\n- CAMERA_TARGET_HIDDEN: a camera target (or its ancestor) is hidden in this step's declared state. Its DOM bounds cannot be measured, so the view may fall back to the whole canvas. For scenes swapped with when, aim at a separate always-visible, sized anchor at the same coordinates; alternatively switch to the new visible target in the same step, or call camera() to intentionally show the world. Check inherited camera targets at chapter starts too. This warning uses declared visibility, including ancestors and responsive gates; it cannot measure CSS layout. Do not retain a previous DOM measurement as a fix: direct links and screenshots must reproduce the same frame without playback history.\n- PLUGIN_PROPERTY_INVALID: motion is a nonempty string; motionDelay/motionMs/enterMs/enterDelay/exitMs/exitDelay are finite numbers 0\u201310000; enterStagger/exitStagger are 0\u20132000; screen is boolean; enter/exit are one of fade, rise, zoom, shrink, wipe, iris, grow, growUp, blur; enterEase/exitEase/motionEase are one of smooth, snappy, spring, bounce, linear.\n- SPLIT_INVALID: <Split> needs a nonempty text prop (a literal or a state binding), by is word or char, and the text goes in text, not in children. These universal properties are literals, not state bindings. Use separate same-key elements with when for a flight between containers.\n- Exit ghosts appear only during playback, never in screenshots, thumbnails, deep links, reduced motion or after a jump. They settle instantly (enter jumps to its end, ghosts vanish) on a jump, stop, scene change and the viewer's first input on the stage (a click, key or drag; the player's pause button keeps them frozen), so the input always acts on the final picture. The camera does not settle on input: it freezes where it is. Ghosts carry no id: camera, hints and Alt-click never target them.\n- Known limits (0.3.0): put exit on the removed container itself \u2014 an exit only on a child of a removed, transformed (scaled) container loses that ancestor's transform for its first frame. An element removed while its enter is still running exits from its base look (a small jump): keep enter shorter than the step. Two elements sharing a motion key with the same layout get neither enter nor exit: use different keys, or change the layout so a flight happens.\n- Give each visible object one motion key. Hidden previous locations remain available for a later same-key arrival. Avoid duplicate simultaneously visible keys. Independent translate/scale keeps the author's transform intact.\n- Cross-container flights temporarily lift clipping ancestors inside the world and restore their overflow at finish/cancel. During playground edits the flight yields its visual transform to the final usable layout while preserving its animation/time anchor for resume. Do not globally remove device clipping or duplicate the animated control to make it clickable; test first input during a flight.\n- Keep camera and FLIP duration together when both move; motionMs explicitly overrides duration, including 0. animate=false cancels an existing flight and renders the final layout.\n- A Canvas with no parent height uses its view aspect ratio; with an explicit parent height it fills that parent. A zero-sized parent still needs a layout fix; render reports the measured surface.\n- screen only separates direct Canvas children into the fixed overlay. Nested screen props remain ordinary descendants.\n- One world per continuous chapter; use chapter() default continuation to avoid manually copied end states. The initial frame and every step contain complete compiled drawing snapshots; deep links do not replay plugin logic.\n- HAPPY_PATH_ONLY belongs to feature review. If an explainer receives it, move the piece to works/<key>.tsx with work()/chapter() and remove its artificial cases; do not invent product failures. Review every storyboard and verify animation separately from static renders.\n";
2
- export declare const patterns = "\n## Updating a public design replay from implementation evidence\nPreserve historical scenarios and stable feature/work IDs; append a clearly labeled source-derived update instead of rewriting an old approval. Put current status and limits in the visible scene: local implementation, work in progress, deployed and published are different claims. Commands displayed in a prototype are not real execution evidence. Reuse a new director layer when a work is already layered; for a route-only work, add a work-local route so adding the evidence view does not replace the original default stage. Keep the host badge/narration safe areas visible during verification.\n\n## Dual-aspect explainers with source metadata\nWhen adapting one dataset to landscape and portrait, author two arrangements at readable design sizes; do not shrink the landscape composition wholesale. For native export also set the logical stage with render --viewport WIDTHxHEIGHT --no-frame; output --width/--height alone only change the surrounding frame. Reserve separate areas for brand, main subject, image credit, source/fact status and subtitles. Also leave room for host chrome: the step badge at the top and current narration/completion bar at the bottom. Check with chrome visible, not only clean video. Give photo panels an explicit image height and adjustable object-position; credit and archive year need their own measured height below the image. A title-first opening may place one main graphic below the title.\n\nFor bilingual quotations show the full original, a translation explicitly labeled as translation, name, role, date and source. Test long original text and a long source name in both aspects; their actual wrapped heights determine the layout, not a short placeholder. Status labels and explanations belong to the author: preserve their meaning rather than replacing prediction, announcement or confirmation with one generic badge.\n\nUse a two-ended proportion bar when a dense point plot becomes unreadable in portrait. Keep left + right <= total and show total-left-right as undecided; position optional thresholds against the full total, not only the decided portion. Test the pure ratio calculation, then inspect real rendered chapters for text overflow. Shared wrapper components should forward bindings and when/enter/exit/motion props.\n\nSee examples/explainer-layouts: shared fictional data, local original vector illustration explicitly labeled non-photographic, short/long quote chapters and customizable status. These components are example-owned; the independent templates repository is maintained separately. No external facts, paid generation or online images are required.\n# content recipes and pitfalls\n\n## Museum-film composition\n- Collect licensed artwork and a real subject asset first. Let an archival image supply the historical texture and the subject supply the action; use CSS only for framing, gradients and typography. Label illustrative artwork when it is not evidence of the place or event.\n- Put the Canvas inside a wrapper with an explicit height (for a board-filling root, height:100%). An auto-height wrapper can remain 800px tall while the board is shorter: exports look correct but lower controls are clipped. Test the actual board at a short height as well as render.\n- Keep chapter/source labels as direct screen children when the world camera travels. Nested screen does not escape its parent. Frame a stable hero cluster with a modest pad; an oversized pad may zoom out and expose empty margins instead of producing a close-up.\n- For a subject entering a device, establish the device first or in the same step, then shrink and move the subject into its screen. Keep the ending actionable through real forks or controls. Reuse the stable subject identity described below.\n- Match-cut the subject at a chapter boundary while changing its background and sound in that same scripted step. The input stays concrete: click the object, drag it to a visible destination, or choose an explicitly labeled branch. Avoid a slide of historical bullet points.\n\n## Shot grammar for a playable short film\nGive each chapter a visual arc: establish the whole interface/device, move in on the meaningful input or action, show its result, then pull back. Keep chapter numbers and explanations subordinate to the working surface. Judge text at its final painted size, including Canvas scale and camera zoom, rather than the font-size declaration alone.\n\nUse camera ids for the object that matters. Framing a wide window rarely produces a button close-up; frame the button for anticipation and button plus receipt for the result. Keep those targets inside one visual cluster. A deliberate crop is useful; a required action cropped out of the current frame is a broken shot.\n\nWhen a whole-stage camera would collide with navigation or titles, either put Canvas in a separately sized parent whose view matches the picture region (controls stay in the surrounding layout), or go full-bleed: put the title and timeline on the screen layer over the moving picture and give <Canvas safe={[top, right, bottom, left]}> the covered bands so targeted framings land in the clear part. Full-bleed lets a push-in fill the whole frame, which a boxed picture cannot.\n\n## Match cut through the subject (chapter seam)\nOne sentence: push in until the recurring object fills the frame, swap the world behind it, pull back to reveal the new world.\n- Use for: era/place/version changes where one object stays the subject (a button through four decades, a product through iterations). At most one signature seam style per piece; reuse it for every chapter seam.\n- Duration and energy: push 1.6\u20131.9 s, cover held about 1 s (the next action can happen under it), pull-back 2.4\u20132.8 s; high energy at the swap, calm after.\n- Set-up: put every version of the object with its centre on the same world point and add an invisible lens element there; give the versions one motion key so the new one morphs from the old size.\n- Beat 1 (end of chapter N): camera('lens', { pad: 0, zoom: 8\u20139, ms: 1800 }); start the next chapter's music here with fadeMs 2000\u20132600 (J-cut).\n- Beat 2 (first step of chapter N+1): switch the state that swaps the worlds (old interface exit=\"fade\", new interface enter=\"fade\", 800\u20131000 ms each) and in the same step camera('<new overview>', { ms: 2400\u20132800 }). The camera curve starts slowly, so the crossfade happens while the object still covers the frame, then the new world opens up. Put the chapter's timeline/scrubber movement and year label change in this same step.\n- Keep (do not downgrade): the shared centre point (otherwise the camera whips across the world at 8\u00D7 and the old ghost slides away), the slow-start pull-back, and exit/enter on whole interfaces rather than on each child.\n- Known pitfalls: a fine 1-px checker or hairline pattern behind the object shimmers (moir\u00E9) at high zoom \u2014 use a low-contrast texture; a deep link or timeline jump to beat 2 lands on the settled overview, which is what a viewer jumping chapters wants; verify the seam in the film strip (no red CUT) and at full size with --frames.\n- Reference: examples/button-40-years (works/forty.tsx, throughTheButton).\n\nAn older variant moves the object out of its interface into a central arrangement before the next chapter catches it (same motion key, exclusive when). It reads as a transfer beat rather than a cut; verify a mid-flight frame in playback because static sheets show only the declared endpoints.\n\n## A continuous object inside playable chapter interfaces\nUse one motion key for the recurring object and distinct element ids for its location in each mutually exclusive arrangement. Keep exactly one visible instance. Each interface should contain a real native input or declared local reaction: the same picture must make sense both during playback and after the viewer pauses.\n\nA useful story holds the message or task constant while the surrounding interface changes. The motion gives continuity; the input, menu and result prove the interaction paradigm. Label canned results explicitly when the audience can type arbitrary requests. Do not imply a model or backend computed a result.\n\nFor the match-cut transition above, use chapter() default continuation, and the engine's actionEntry: 'after' when a confirmed chapter drag should immediately show the new arrangement. Static storyboards prove layout; observe real playback to verify FLIP travel. If a flight does not appear, check for two visible same-key objects, a replaced Canvas/stage, or a manual jump with animate=false before changing the animation.\n\nKeep credits and sources outside the animated object area. Render every chapter and inspect the target frame after seeking; then test real typing, first-input pause, hover/touch, reset, continue and cross-chapter confirmation. A menu temporarily covering content is expected while open; verify it closes before the next action needs that content.\n\n## A news explainer as one map of clusters\nFor a topic explainer (an election, a policy, a market week), lay the whole episode out as one world of shot-sized clusters before writing steps.\n- Grid in narrative order: put clusters that hand over to each other side by side, so the adjacency is the camera route (ballot next to the seat chart, the map above the market it is called back to). A long diagonal move reads as a whip pan; use it once at most.\n- Reuse the same graphic across chapters instead of drawing a new board: a seat chart first lights up \"up for election\", then flips colour with the results, then gives up seats to a later chart. A map marks what is on the ballot, then the results, then is revisited for a later point (go back to one state).\n- Pin each opening question on the cluster that will answer it. When a chapter is on that cluster the tag says \"now\"; at the chapter end it turns into a short answer. Overview shots show a larger variant of the same tags (same motion key), so keep answers to about ten CJK characters and leave room for the large variant beside its cluster.\n- Make a number tangible by moving its marks: overlay the subset of marks that the number counts (for example the seats a party lost) with motion-keyed copies, light them up, then show the same keys arranged as a column in another cluster's chart while the camera moves there. The flight and the camera land together. Keep the original marks underneath so the source chart does not get holes, and size the dot grid so one dot equals one unit on the target chart's scale.\n- Results that pile up become the recap: a stamp lands large on the document it judges (enter=\"zoom\" with an enterDelay that waits for the document's flight), and on the next step the same motion key moves it into a row of small badges at the bottom. The chapter's summary step is a wide shot of that row, not a bullet card.\n- Keep one document object flying between two sides and change its text instead of fading documents in and out; a hidden object that reappears flies from its last location.\n- Chrome around the player's own overlays: the subtitle floats at the bottom centre and the step title pops at the top left, so put the chapter label at the top right with the source line under it, and give <Canvas safe> those bands. A closing call to action on the final overview goes at the top too, so it does not cover the answered question tags.\n- Cause near, effect far: when the control the viewer acts on (a ballot row) and the thing it changes (a map two clusters away) cannot share one readable frame, split the beat into the action step framed on the control and a system step that moves the camera to the result. Zooming out until both fit (below about 0.6\u00D7) makes both unreadable.\n- Count-in colour changes: when a chart recolours (seats flipping party), stagger each mark's transition-delay by its distance from the nearest end, so colour grows in from both sides like an election-night tally instead of switching at once.\n- Native controls inside a large world (Radio, Checkbox, Select) keep their own small font size; scale the control group with CSS zoom (about 1.3\u20131.5) rather than restyling its internals, and check the label size in the storyboard.\n- Source lines name only sources you actually have. For a rule, cite the rule itself (a constitutional article, a statute); never write \"see reports by X\" as a guess.\n\n## Remaking a deck-like piece as a film\nSymptoms in an existing piece: one board per chapter (label, big title, panels, footer), a title card opening each chapter, hard cuts between layers, an on-screen headline that repeats the caption and the narration, and opening questions that are never closed.\n- Keep the data module, sources and licensed assets; rebuild only the stage and the script. Create the remake as another work in works/<new-key>.tsx and mark the old work draft: true. Both remain accessible locally; only the ready work is published. Use build/share --work <key> to publish just one piece; selecting a draft is an error.\n- Before TSX, map each old board to a cluster of one world and each old title card to a camera move. Turn on-screen sentences into labels: the subtitle carries the sentence.\n- Then follow the review loop: storyboard every chapter, film-strip the chain until CUT and STILL are gone, and play it in the board. If playback stutters, measure before changing the piece (npx joplo skill demo).\n\n## Pitfalls that make a film feel like slides\n\n## Pitfalls that make a film feel like slides\n- Several steps under the same camera() go still once the drift reaches its end: the same target and drift do not restart it, and the film strip marks STILL. Let the camera follow the action (the side where the document lands, the panel that just opened, the end of the chart being discussed) or give the step a new drift.\n- camera({ zoom }) is a cap, not a forced zoom. Padding expands the target bounds before fitting: a target already as wide as the safe area will zoom OUT when pad > 0 (870px / (870px + 2 \u00D7 70px) \u2248 0.86). For a full-width portrait target use pad: 0; for smaller targets start with 12\u201318 design pixels and inspect the frame. There is no minimum zoom clamp; fitting a larger target may require zooming out. If a cluster's shape does not match the safe area, neighbouring clusters show at the edges. Shape the opening cluster to the frame for a clean thumbnail.\n- <br> is not an element; write line breaks as '\n' with whiteSpace: 'pre-line'.\n- Holds with a frozen camera: drift is on by default; do not turn it off for reading holds \u2014 a 1\u20138 % eased push is enough. If the film strip still marks STILL, the drift is too weak for that framing (flat UI shows little change); raise zoom or add x/y.\n- Every element using the same entrance: vary by meaning (section 3b) and stagger a batch with enterStagger on its container; let new things start before old ones finish leaving.\n- Everything springs: a spring on every entrance reads as a toy. Springs for things that land, smooth or snappy for text and frames, bounce at most once a chapter.\n- Put the look you want to interpolate on the element that carries the motion key. Changes inside it (an inner wrapper's background, a bevelled border, a gradient) only crossfade; border colours, shadows and background images do not interpolate.\n- Put enter (and enterEase) on the element that carries the motion key, not on a wrapper around it: when the key flies in from elsewhere the wrapper would still enter and the piece would both fly and fade.\n- A whole interface replaced in one frame (when swap without exit/enter) is a hard cut. Give both sides a transition or cover the swap with the subject.\n- Whole-screen white/colour flashes over a still picture look like a stalled player; keep the picture moving under any fade.\n\nFor runtime layout QA, use joplo render --audit-layout for a final-state screenshot and --film --audit-layout for motion. Declare important selectors, a content frame and reserved footer/subtitle rectangles; exclude intentional stamps/background overlays. Text Range bounds reflect loaded fonts and actual Canvas scaling. Canvas exposes its existing engine-clock camera, drift midpoint/end and sequence-waypoint deadlines only as DOM diagnostic hints; static/jump/exploration states do not claim future motion. A later step can interrupt a phase, and masks/rotation or hidden content remain unknown rather than \"visible\". Inspect evidence before changing intentional overlap.\n\nCommon pitfall: For visual explainers, read npx joplo skill content: keep a continuous visual story, storyboard every chapter, film-strip the chain, and verify playback before claiming it works";
1
+ export declare const skill = "# Joplo content production: content\n\nFor explainers, tutorials, science and news-explainer pieces that should feel like a good video, not a deck: the viewer watches a world change while a voice explains it.\nAuthor one standalone work in works/<key>.tsx with work(); put chapter() slices under scenarios and narrate() in their steps. Chapters continue in declaration order by default. Works have covers and enter the project home page; no feature, review cases or pick is needed. Full example: examples/llm-explainer.\n\nInstall @joplo-app/plugin-content at the Joplo version; import content and add it to config.plugins. Import { Canvas, ItemTrack, Split, camera } from this package; keep work, chapter, patch, narrate and hold from @joplo-app/kit. Use theme: 'content:studio' for the bundled CSS. No plugin is implicitly enabled.\n\n## Minimal work\nIn a project with content enabled in config.plugins (and the starter's type: module / JSX tsconfig):\n```tsx\n// works/explainer.tsx\nimport { work, chapter, narrate } from '@joplo-app/kit';\nimport { Canvas } from '@joplo-app/plugin-content';\nexport default work({ title: 'A request in motion', summary: 'Follow one request',\n stage: <Canvas w={1280} h={800} />,\n scenarios: {\n arrival: chapter('A request arrives', { expected: 'Understand where it starts' })\n .system('Arrive', narrate('A request arrives.')),\n response: chapter('The worker responds').system('Respond', narrate('The worker replies.')),\n },\n});\n```\nThis is the authoring skeleton; add a visible subject and real changing state before reviewing the film. stage/layers needs no routes/ directory. Use on/routes explicitly when reusing product pages. WORK_INVALID means repair the required fields or slice builders; WORK_SLICES_MIXED means use chapter() consistently; FROM_UNKNOWN lists valid keys; WORK_EMPTY means add your first slice. Keep render/deep-link ids from outline --format json (standalone: explainer.arrival; feature-attached: queue.a.waiting), while --work takes the public entry key.\n\n## 1. Before TSX: package and plan within the agreed scope\n- One thing the viewer should be able to repeat afterwards, in one sentence.\n- Package first: the title asks the question; a thumbnail line of at most five words gives the surprising answer (complement the title, never repeat it); chapter('Slice title', { description }) is the cover sentence. The share preview is the first scenario's first frame, so design that frame as a thumbnail: one big line, one focal object, high contrast.\n- If the framing is unresolved, offer two or three devices (one running example, misconception then correction, a number made tangible, before and after) with a recommendation. Reuse an already agreed design; do not repeat approval rounds the user has waived.\n- Chapters: one question per chapter. Chapter titles are questions ('What does it actually read?'); the UI adds their numbers automatically. chapter('Slice title', { expected }) is what the viewer can now say. List every point from the source material and map each to a chapter or drop it on purpose.\n- One running example through every chapter (the same prompt, person, or data set), so each chapter builds on what the viewer already saw.\n- Write the script as one line per step: ears (narrate), eyes (what changes on stage), source. Adjacent steps should connect with 'but' or 'so'; a chain of 'and then' is flat.\n- Budget: narration reads about 4.5 CJK characters (2.5 English words) per second; 45\u201390 s per chapter. About 400 CJK characters can already exceed 90 seconds. npx joplo outline counts narration in its estimates.\n\n## Asset-first preparation\nBefore building a device, historical interface or illustrated object, make an asset list. Prefer a suitable licensed library, icon set or model; do not hand-write complex SVG or build a model merely because JSX can draw it. Verify the actual asset license, collect files in assets/, retain licenses and record author, URL and modifications in assets/SOURCES.md. Historical facts and historical appearance are separate evidence: label stylized reconstructions and invented messages, and avoid copied logos/system icons. Use original work only when a suitable reusable asset is unavailable, keeping it simple.\n\n## 2. Hook (first chapter, 20\u201335 s)\n- Beat 1: a familiar scene that pays off the thumbnail. Never a logo, an agenda, or a definition first.\n- Beat 2: the twist, shown on stage (the answer splits into pieces with probabilities, a name changes on the second try).\n- Beat 3: pull back and name the questions the episode answers. Pin each question where it will be answered, and close every loop later.\n\n## Camera sequences and persistent materials\nUse cameraSequence for a single long explanation that needs deliberate framing throughout (not high-frequency drawing). Import it from @joplo-app/plugin-content and put it in a scripted system step:\n```ts\ncameraSequence([\n { atMs: 0, target: 'room', zoom: 1 },\n { atMs: 2500, target: 'message', zoom: 1.15, ease: 'easeInOut' },\n { atMs: 6500, target: 'message', zoom: 1.22, ease: 'easeOut' },\n])\n```\nWaypoints start at 0, increase strictly, end within 60000 ms, and use existing element IDs (or targets: [...] for a group). Each waypoint may set pad/zoom; ease belongs to the incoming segment (easeInOut default, easeOut or linear). The step stays at least until the last waypoint. Pause and speed follow engine time. Static renders, deep-link jumps, animate=false and reduced motion show the final waypoint. Free exploration yields to the final layout. Existing camera() and drift remain valid; a sequence replaces drift for that framing state. An ordinary next step inherits the current path; explicitly issuing even the same cameraSequence again restarts it. A continuing chapter inherits the final frame until it issues a new sequence. End with camera() when changing the subject.\n\nFor the same subject changing material, keep one motion key and bind the destination layout, borderRadius, color, backgroundColor, opacity and text to state. Content interpolates those supported style values along the same motion flight; changed text crossfades through a temporary inert, aria-hidden clone without a second motion identity. Static jumps show destination styles immediately. This is a transition between authored states, not arbitrary per-frame drawing. Keep interactive controls in the live subject: the fading clone has no hit area or focus identity. Test long text at both endpoints and play the transition with Voice on; do not infer continuous motion from static storyboard frames.\n\n## 3. Not slides: one world, continuous objects, a moving camera (the core)\nFailure mode, even with nice graphics: one board per chapter (big title, panels, footer), chapter title cards, cards of bullets, things fading in and out. Viewers read it as a deck. Instead:\n- One layer holding one <Canvas w={2560} h={1600}> world (the default view is 1280\u00D7800, scaled to fit, never re-laid out; in a container without a height it sizes itself from the view ratio, and render warns 'Canvas has no size' if it still has none). Place a few containers absolutely in design pixels; lay out inside them with flex.\n- Objects keep their identity: give each one motion=\"key\". Write each arrangement as static JSX switched with when, reusing the same key; between steps Joplo flies the object from its old place and size to the new one, also across containers. Morph, never replace: the question's words split into tokens, flip into ids, then fly onto a tape; bars rearrange into a lottery strip.\n- When the same key also changes its look, the flight carries the change (see \"Camera sequences and persistent materials\"): the keyed element's own borderRadius, color, backgroundColor and opacity interpolate, and when its text, class, inline style or inner structure differ (a plain word becoming a coloured token, a 1984 button becoming a 1995 button, a label \"45%\" becoming \"98%\"), the old look crossfades out along the same flight. This also happens in place, when only the look changed. Write the two looks as two same-key elements switched with when, or bind the styles to state; jumps and screenshots show the new look.\n- shot() draws the host focus ring and caps UI zoom at 1.25\u00D7; use camera() for traveling inside a Canvas without that ring.\n- For diagram trace inside Canvas, pass { focus: false } to trace(...ids, options) so only the Canvas camera owns framing.\n- When another plugin effect also suggests host focus (for example a diagram trace inside a Canvas), use an explicit shot() for the whole director layer if the Canvas camera should own the framing. Otherwise host zoom and Canvas zoom can multiply and push nearby text out of view. Verify the actual visible bounds in playback, not only DOM text.\n- Camera: camera('id', \u2026) frames those elements (Joplo measures them, adds pad, caps zoom); camera() shows the whole canvas. Establish wide, push in on detail, pull back for the payoff. Object flights in the same step follow the camera's timing, so both land together.\n- camera('cache', { framing: 'detail', waitForMove: true }) lands a close-up before advancing the step. Choose overview (128 px pad, 1.25\u00D7 cap, 1400 ms) for the whole group, medium (64 px, 2\u00D7, 1200 ms) for its neighbours, or detail (16 px, 4\u00D7, 900 ms) for one object. Explicit pad, zoom and ms override each preset independently. Without a preset the defaults remain 48 px, 3\u00D7 and 1200 ms.\n- waitForMove requests that many milliseconds of minimum step time. Other effects and narration can hold longer. Drift starts after landing and adds no wait; later steps inherit the framing without repeating the wait.\n- Chapters continue: chapter() starts from the previous chapter's last frame (state, camera, director layer) by default. Only use from: null to restart, or from: 'sliceKey' for another predecessor; keep all slices chapter() within this work. patch($.ui, { \u2026 }) changes several values in one step.\n- System-only chapters stay on the initial director layer unless camera(), shot(), a cue, or chapter('Slice title', { layer }) selects another layer. Continuing from a chapter inherits its final layer; do not copy its state by hand.\n- screen children of the Canvas stay fixed on screen: chapter label, source line, poster, end card.\n- Takeaways land on objects (a pinned question flips to '\u2713 answer'); the recap is a pull back to the whole world. Use .card() only when nothing on stage can carry the moment.\n```tsx\n<Canvas w={2560} h={1600}>\n <div id=\"tape\" style={{ position: 'absolute', left: 120, top: 960, display: 'flex', gap: 8 }}>\n {IDS.map((t, i) => <span when={eq($.ui.at, 'tape')} motion={`tok_${i}`} style={{ background: COLORS[i] }}>{t}</span>)}\n </div>\n <div screen style={{ position: 'absolute', left: 20, top: 16 }}>{$.ui.chapter}</div>\n</Canvas>\nchapter('What does it read?')\n .system('Split', 'Nine characters, seven pieces', patch($.ui, { mode: 'split' }), camera('bubble', { pad: 160 }))\n .system('To the tape', 'It reads these numbers', patch($.ui, { at: 'tape' }), camera('tape', 'meter'))\n```\n- Anti-deck test: three or more steps that only show or hide whole panels, or a frame that is mostly text, means rebuild those steps as objects that move or change.\n\n## 3b. Transitions, drift and the safe area\n- enter / exit on any element inside the Canvas (world or screen layer): fade, rise, zoom, shrink, wipe, iris, grow, growUp, blur. Timing: enterMs / enterDelay / exitMs / exitDelay (0\u201310000 ms literals; defaults 600 / 450). Each preset is an \"away\" pose: enter goes away \u2192 the element's own look, exit goes own look \u2192 away. The grow left edge and growUp bottom edge stay anchored throughout entry and exit; they do not slide toward the default center as the size changes. Verify a middle frame as well as the final frame when aligning a growing bar with nearby content. So rise enters from below and exits sinking back; zoom lands from slightly larger and exits flying toward the camera; shrink grows from smaller and exits receding; wipe reveals left \u2192 right; iris opens from the centre; grow scales up from the left edge (horizontal bars, timeline rules, underlines) and growUp from the bottom edge (columns); blur comes into focus from a soft blur. The direction of grow / growUp is never guessed from the element's size: a short horizontal bar is narrower than it is tall and is still a horizontal bar. Set transform-origin in CSS to say where zoom/shrink grow from (a menu from its taskbar, a bubble from its tail).\n- enter plays when an element first appears (a new DOM node) during playback; exit plays when when becomes false: a non-interactive ghost copy keeps the last look and animates out, then disappears. Put enter + exit on two exclusive siblings in the same step for a crossfade. A same-motion-key element that flies (FLIP) never also enters or leaves.\n- How it settles: enterEase / exitEase / motionEase (FLIP flights) take smooth (default curve of each), snappy (fast start, short settle), spring (overshoots a little and settles), bounce (overshoots more, wobbles) or linear. The spring is a CSS linear() curve over the same ms, so it pauses, seeks and records like every other entrance; browsers without linear() get an overshooting cubic-bezier. Use spring for things that land or snap into place (a token joining a tape, a bar reaching its value, a call to action), bounce for one playful accent per chapter, snappy for typed or printed pieces; keep text the viewer is reading on smooth or snappy. motionEase overrides the camera-synchronised curve of a flight, so leave it unset when the camera moves in the same step.\n- Stagger a batch: enterStagger={ms} / exitStagger={ms} (0\u20132000) on a container delays the descendants that enter (or leave) in the same step by rank \u00D7 ms, in document order, on top of their own enterDelay. Only elements that actually play count: a same-key element that flies instead of entering does not take a slot, so \"three new tokens plus one that flies in\" staggers 0 / ms / 2\u00B7ms for the new three. Do not compute per-element enterDelay or animationDelay for a batch.\n- <Split text by=\"word\"|\"char\"> renders text that enters piece by piece: enter / enterMs / enterEase / enterDelay apply to every piece (default enter rise), the root does not enter itself, and enterStagger defaults to 70 ms (word) or 30 ms (char). Words come from Intl.Segmenter, so Chinese splits into words too; punctuation stays on its word (opening quotes and brackets on the next one) and lines never break inside a word. Screen readers read the whole sentence once. text may be a state binding: a new value is a new set of pieces and enters again (a chapter label in the screen layer). exit applies to the whole Split. Use it for a headline, a chapter label or an answer appearing; a body paragraph the viewer reads should not split.\n- Pick by meaning: fade for a whole-world swap under cover, rise for things that come from below (menus from a taskbar, keyboards, receipts), shrink for windows opening, zoom for something punching toward the viewer, wipe for typed/printed results, iris for a reveal from a point. Keep two or three per piece; do not give every element the same entrance.\n- camera(\u2026, { drift }) keeps the camera moving after it lands: a number = zoom factor reached over ms (default 8000), or { zoom, x, y, ms } with x/y in design px; false stops it. <Canvas drift={\u2026}> sets the default for every step; without either, a subtle 4 % / 8 s push applies. Drift eases in and out and stops at its end point; it freezes on pause, records in video, and screenshots/deep links show the settled frame without drift. The next camera move starts from where the drifting camera actually is, including when only drift changes or is switched off; the configured camera ms eases back to the target before the next drift.\n- For a close reading of a Diff or a comparison of numbers, use <Canvas drift={false}>. Stable positions let the eye return to the same line or digit. Keep an intentional STILL in this reading step.\n- <Canvas safe={[top, right, bottom, left]}> (design px) is the part of the view your screen-layer chrome covers. Targeted camera() frames fit inside the rest, and drift zooms around its centre; camera() with no ids still shows the whole world full-bleed. For a final recap step with done() and bottom subtitles, pass all zone ids to camera('zone_a', 'zone_b', \u2026, { pad }) (with safe top/bottom \u2265 110) or leave \u2265 10% top/bottom world margin so host completion badges and subtitles never overlap top/bottom zone titles.\n- UI life inside one interface (a caret blink, a stepped menu drop) can be CSS @keyframes in the project theme: the engine clock samples them, pause freezes them, static frames show their end state.\n\n## 4. Choose the information shape, then the picture\n- A number landing; before and after; ranking (bars from zero, length proportional); part of a whole (a strip whose segment widths are the shares); a process (one object going around a loop); misconception then fact; a timeline; a place (tiles or a simple map).\n- Similar sentences get different pictures. Labels sit on the thing they name; no legends when a direct label fits.\n- Compute numbers in TS from one source (for example probabilities from one set of scores) so every number on screen agrees. Label illustrative numbers on screen ('illustrative'), separate from sourced facts.\n- Encode reuse and invariants with stillness contrast: keep cached, locked or unchanged items mounted in place with the same motion key while only the newly computed item moves in; stillness beside motion explains reuse without extra text. Pair a pointing beat with a silent step (narrate(false) + hold(2\u20133)) when objects fly across containers so viewers can watch the transfer uninterrupted.\n- Show trade-offs as coupled proportional geometry, not a two-column pros/cons card: drive two zero-anchored bars or slot grids from one TS parameter (for example compute per step dropping while memory footprint grows) and add native or onClick parameter switches so viewers can test the scaling while paused.\n- Show algebraic folding, pipeline fusion, or decoupling as physical motion rather than before/after formulas: give movable transforms a conserved motion key across exclusive when branches so they slide into neighboring stages to fuse, and fly any blocking constraint onto a separate parallel narrow rail during a silent observation step.\n\n### Fixed slots and object identity\n\nUse <ItemTrack id=\"cache\" capacity={4} items={$.data.entries} /> to show what gets reused. Initialize entries with [{ id: 'a', label: 'A' }]. A step with push($.data.entries, { id: 'b', label: 'B', accent: 'teal' }) fills the next slot. A later set($.data.entries, [b, a]) moves both existing objects to their new positions. The same array can be passed directly to items. Review the arrival in playback and the final order by jumping to that step.\n\ncapacity is a positive integer up to 4096. keyField, labelField and accentField default to id, label and accent. Choose a unique, stable string or numeric key for each object; keep the key when its label changes. direction=\"column\" stacks the slots vertically (default row). emptyLabel changes the empty slot caption (default \u7A7A\u69FD). ITEM_TRACK_INVALID identifies duplicate keys, missing identity, or more entries than slots. Fix the source array or increase capacity. During free exploration the track reports invalid data inline and displays the first distinct valid entries that fit.\n\n## 5. Motion and layout numbers\n- Camera moves 1\u20131.5 s, ease in-out. Object flights 0.9 s ease-out; stagger 60\u2013120 ms (motionDelay); slow a landing pointer to 1.5\u20132 s (motionMs).\n- One primary motion per step; text that is being read does not move.\n- Entrances and exits: use enter / exit with enterEase and a container enterStagger (section 3b); a typed or word-by-word reveal is <Split> (by=\"char\", enter=\"blur\" or \"fade\", enterMs about 200, enterStagger 60\u2013160). Only for effects the presets do not cover put @keyframes and classes in themes/<name>.css and use className. Screenshots, thumbnails, and jumps show the end state. A 1 ms steps(1) CSS animation can stay stuck invisible in Chromium.\n- One accent color with a fixed meaning; color means the same thing in every chapter.\n- Size text for the frame you show: about 28 design px is the floor at 1\u00D7 zoom; a wide shot at 0.5\u00D7 needs 40 or more, or enlarge the labels for that shot (a bigger variant under the same motion key).\n- Frame by content (camera ids), not by guessed coordinates. Lay the world out as shot-sized clusters of roughly 16:10 (a machine with its output bars and strip, a chat with its bubbles); a cluster much wider than that leaves half the frame empty however you aim.\n- Same subject, same frame: keep one camera for consecutive steps about the same cluster; frame what stays on stage (not a container that has just emptied).\n\n## 6. Narration, captions, numbers\n- Caption: what the eye needs, ideally at most 16 CJK characters (24 is the hard limit). narrate(): what a presenter says, one or two sentences (rules: story section 6).\n- One number per step, rounded and written as spoken; translate numbers ('one chance in 365'). Pointing words are fine ('look at the dashed line').\n- When narration is on, keep on-stage text to labels; do not put the narrated sentence on screen too.\n\n## 7. Facts and sources\n- All facts in one data module with source and date; a source line (screen element) per chapter; name studies in narration ('OpenAI, in a 2025 paper, explains \u2026').\n- Say only what the source says. Bars start at zero. Separate illustrative values from facts on screen.\n- Images: licensed or public domain, credited, CREDITS file next to them (story section 7).\n\n## 8. Ending\n- Pull back to the whole world: every pinned question now shows its answer. Then one concrete action the viewer can take right away, as a screen element. Stop once the value lands; no 'thanks for watching'.\n\n## 9. Required: review before handing over\n- npx joplo check until 0 errors, then npx joplo outline --work <key>: verify the chapter order, step counts and estimated duration. Standalone works do not run feature coverage or HAPPY_PATH_ONLY checks.\n- Storyboard every chapter: npx joplo render --scenario-id <id> --sheet --out board.png prints every step in one image with its caption and narration. Read it frame by frame and assume the first one has problems: half-empty frames, objects cut at the edge, labels overlapping, text too small in wide shots, the chapter label covering content. Fix, then storyboard again.\n- Film-strip every chain of chapters: npx joplo render <dir> --scenario-id <first> --film --chain --out film.png. Review red CUTs (one-frame full-screen changes) and grey STILLs (no visible change for \u2265 1.5 s). Fix accidental cuts and stalls. Keep a deliberate still frame when viewers need to read. The storyboard cannot show either. Engine checklist: npx joplo skill demo, \"Make it play like a film\".\n- Play each chapter in the board with Voice on: flights and camera land together, nothing leaves the frame mid-flight, narration finishes before the next step.\n- Evidence, not belief: 'it plays' needs check 0 errors plus a run in the board; 'it looks right' needs the rendered frames; 'it is clear' needs captions-only and frames-only passes that both tell the story.\n- Tell the user what you could not verify (a real voice on a phone, other window sizes).\n\n## Migrating an existing script safely\n- Freeze the previous dev IR before moving files. Compare all steps, plugin drawing/media snapshots and every stateAt position after migration; a flow-to-chapter rename does not prove the same continuous state, motion or sound.\n- A chapter that previously began independently needs from: null. Default continuation carries the previous ui/data/inputs and running music; use it only when the next chapter should inherit that ending.\n- Put audience descriptions from feature.roles into audience. Preserve real role() speakers, the role keys used by say(), and config.voice.roles together; verify the chosen voices in playback.\n- If the project already has a helper named chapter, rename that helper before importing chapter from the kit.\n- Remove manual numbering from the chapter title itself, not every identical string. A transition card or caption may still use the old source text; let i18n missing/stale/unused diagnostics determine which translation keys need changing.\n- Inspect a path page before deleting it. A Slot-only/empty wrapper can be removed for stage/layers; reuse actual picture content through explicit on or the work's routes.\n- To prove a draft did not publish, search all build artifacts for one complete sentence unique to the old work and absent as a substring of current copy. Keep the old work locally with draft: true; do not rely on the published menu alone.\n\n## Diagnostics and recovery\n- CAMERA_UNKNOWN: the id must exist in a current layer or stage; frame elements inside this Canvas. CAMERA_INVALID: framing accepts overview, medium or detail; waitForMove is boolean. Check pad 0\u20132000, zoom 0.1\u201310, ms 0\u201310000, drift false | 0.5\u20132 | { zoom 0.5\u20132, x/y \u22122000\u20132000, ms 500\u201360000 }, finite numbers only; <Canvas drift> takes the same values and <Canvas safe> is four numbers 0\u20132000.\n- CAMERA_TARGET_HIDDEN: a camera target (or its ancestor) is hidden in this step's declared state. Its DOM bounds cannot be measured, so the view may fall back to the whole canvas. For scenes swapped with when, aim at a separate always-visible, sized anchor at the same coordinates; alternatively switch to the new visible target in the same step, or call camera() to intentionally show the world. Check inherited camera targets at chapter starts too. This warning uses declared visibility, including ancestors and responsive gates; it cannot measure CSS layout. Do not retain a previous DOM measurement as a fix: direct links and screenshots must reproduce the same frame without playback history.\n- PLUGIN_PROPERTY_INVALID: motion is a nonempty string; motionDelay/motionMs/enterMs/enterDelay/exitMs/exitDelay are finite numbers 0\u201310000; enterStagger/exitStagger are 0\u20132000; screen is boolean; enter/exit are one of fade, rise, zoom, shrink, wipe, iris, grow, growUp, blur; enterEase/exitEase/motionEase are one of smooth, snappy, spring, bounce, linear.\n- SPLIT_INVALID: <Split> needs a nonempty text prop (a literal or a state binding), by is word or char, and the text goes in text, not in children. These universal properties are literals, not state bindings. Use separate same-key elements with when for a flight between containers.\n- Exit ghosts appear only during playback, never in screenshots, thumbnails, deep links, reduced motion or after a jump. They settle instantly (enter jumps to its end, ghosts vanish) on a jump, stop, scene change and the viewer's first input on the stage (a click, key or drag; the player's pause button keeps them frozen), so the input always acts on the final picture. The camera does not settle on input: it freezes where it is. Ghosts carry no id: camera, hints and Alt-click never target them.\n- Known limits (0.3.0): put exit on the removed container itself \u2014 an exit only on a child of a removed, transformed (scaled) container loses that ancestor's transform for its first frame. An element removed while its enter is still running exits from its base look (a small jump): keep enter shorter than the step. Two elements sharing a motion key with the same layout get neither enter nor exit: use different keys, or change the layout so a flight happens.\n- Give each visible object one motion key. Hidden previous locations remain available for a later same-key arrival. Avoid duplicate simultaneously visible keys. Independent translate/scale keeps the author's transform intact.\n- Cross-container flights temporarily lift clipping ancestors inside the world and restore their overflow at finish/cancel. During playground edits the flight yields its visual transform to the final usable layout while preserving its animation/time anchor for resume. Do not globally remove device clipping or duplicate the animated control to make it clickable; test first input during a flight.\n- Keep camera and FLIP duration together when both move; motionMs explicitly overrides duration, including 0. animate=false cancels an existing flight and renders the final layout.\n- A Canvas with no parent height uses its view aspect ratio; with an explicit parent height it fills that parent. A zero-sized parent still needs a layout fix; render reports the measured surface.\n- screen only separates direct Canvas children into the fixed overlay. Nested screen props remain ordinary descendants.\n- One world per continuous chapter; use chapter() default continuation to avoid manually copied end states. The initial frame and every step contain complete compiled drawing snapshots; deep links do not replay plugin logic.\n- HAPPY_PATH_ONLY belongs to feature review. If an explainer receives it, move the piece to works/<key>.tsx with work()/chapter() and remove its artificial cases; do not invent product failures. Review every storyboard and verify animation separately from static renders.\n";
2
+ export declare const patterns = "\n## Updating a public design replay from implementation evidence\nPreserve historical scenarios and stable feature/work IDs; append a clearly labeled source-derived update instead of rewriting an old approval. Put current status and limits in the visible scene: local implementation, work in progress, deployed and published are different claims. Commands displayed in a prototype are not real execution evidence. Reuse a new director layer when a work is already layered; for a route-only work, add a work-local route so adding the evidence view does not replace the original default stage. Keep the host badge/narration safe areas visible during verification.\n\n## Dual-aspect explainers with source metadata\nWhen adapting one dataset to landscape and portrait, author two arrangements at readable design sizes; do not shrink the landscape composition wholesale. For native export also set the logical stage with render --viewport WIDTHxHEIGHT --no-frame; output --width/--height alone only change the surrounding frame. Reserve separate areas for brand, main subject, image credit, source/fact status and subtitles. Also leave room for host chrome: the step badge at the top and current narration/completion bar at the bottom. Check with chrome visible, not only clean video. Give photo panels an explicit image height and adjustable object-position; credit and archive year need their own measured height below the image. A title-first opening may place one main graphic below the title.\n\nFor bilingual quotations show the full original, a translation explicitly labeled as translation, name, role, date and source. Test long original text and a long source name in both aspects; their actual wrapped heights determine the layout, not a short placeholder. Status labels and explanations belong to the author: preserve their meaning rather than replacing prediction, announcement or confirmation with one generic badge.\n\nUse a two-ended proportion bar when a dense point plot becomes unreadable in portrait. Keep left + right <= total and show total-left-right as undecided; position optional thresholds against the full total, not only the decided portion. Test the pure ratio calculation, then inspect real rendered chapters for text overflow. Shared wrapper components should forward bindings and when/enter/exit/motion props.\n\nSee examples/explainer-layouts: shared fictional data, local original vector illustration explicitly labeled non-photographic, short/long quote chapters and customizable status. These components are example-owned; the independent templates repository is maintained separately. No external facts, paid generation or online images are required.\n# content recipes and pitfalls\n\n## Museum-film composition\n- Collect licensed artwork and a real subject asset first. Let an archival image supply the historical texture and the subject supply the action; use CSS only for framing, gradients and typography. Label illustrative artwork when it is not evidence of the place or event.\n- Put the Canvas inside a wrapper with an explicit height (for a board-filling root, height:100%). An auto-height wrapper can remain 800px tall while the board is shorter: exports look correct but lower controls are clipped. Test the actual board at a short height as well as render.\n- Keep chapter/source labels as direct screen children when the world camera travels. Nested screen does not escape its parent. Frame a stable hero cluster with a modest pad; an oversized pad may zoom out and expose empty margins instead of producing a close-up.\n- For a subject entering a device, establish the device first or in the same step, then shrink and move the subject into its screen. Keep the ending actionable through real forks or controls. Reuse the stable subject identity described below.\n- Match-cut the subject at a chapter boundary while changing its background and sound in that same scripted step. The input stays concrete: click the object, drag it to a visible destination, or choose an explicitly labeled branch. Avoid a slide of historical bullet points.\n\n## Shot grammar for a playable short film\nGive each chapter a visual arc: establish the whole interface/device, move in on the meaningful input or action, show its result, then pull back. Keep chapter numbers and explanations subordinate to the working surface. Judge text at its final painted size, including Canvas scale and camera zoom, rather than the font-size declaration alone.\n\nUse camera ids for the object that matters. Framing a wide window rarely produces a button close-up; frame the button for anticipation and button plus receipt for the result. Keep those targets inside one visual cluster. A deliberate crop is useful; a required action cropped out of the current frame is a broken shot.\n\nWhen a whole-stage camera would collide with navigation or titles, either put Canvas in a separately sized parent whose view matches the picture region (controls stay in the surrounding layout), or go full-bleed: put the title and timeline on the screen layer over the moving picture and give <Canvas safe={[top, right, bottom, left]}> the covered bands so targeted framings land in the clear part. Full-bleed lets a push-in fill the whole frame, which a boxed picture cannot.\n\n## Match cut through the subject (chapter seam)\nOne sentence: push in until the recurring object fills the frame, swap the world behind it, pull back to reveal the new world.\n- Use for: era/place/version changes where one object stays the subject (a button through four decades, a product through iterations). At most one signature seam style per piece; reuse it for every chapter seam.\n- Duration and energy: push 1.6\u20131.9 s, cover held about 1 s (the next action can happen under it), pull-back 2.4\u20132.8 s; high energy at the swap, calm after.\n- Set-up: put every version of the object with its centre on the same world point and add an invisible lens element there; give the versions one motion key so the new one morphs from the old size.\n- Beat 1 (end of chapter N): camera('lens', { pad: 0, zoom: 8\u20139, ms: 1800 }); start the next chapter's music here with fadeMs 2000\u20132600 (J-cut).\n- Beat 2 (first step of chapter N+1): switch the state that swaps the worlds (old interface exit=\"fade\", new interface enter=\"fade\", 800\u20131000 ms each) and in the same step camera('<new overview>', { ms: 2400\u20132800 }). The camera curve starts slowly, so the crossfade happens while the object still covers the frame, then the new world opens up. Put the chapter's timeline/scrubber movement and year label change in this same step.\n- Keep (do not downgrade): the shared centre point (otherwise the camera whips across the world at 8\u00D7 and the old ghost slides away), the slow-start pull-back, and exit/enter on whole interfaces rather than on each child.\n- Known pitfalls: a fine 1-px checker or hairline pattern behind the object shimmers (moir\u00E9) at high zoom \u2014 use a low-contrast texture; a deep link or timeline jump to beat 2 lands on the settled overview, which is what a viewer jumping chapters wants; verify the seam in the film strip (no red CUT) and at full size with --frames.\n- Reference: examples/button-40-years (works/forty.tsx, throughTheButton).\n\nAn older variant moves the object out of its interface into a central arrangement before the next chapter catches it (same motion key, exclusive when). It reads as a transfer beat rather than a cut; verify a mid-flight frame in playback because static sheets show only the declared endpoints.\n\n## A continuous object inside playable chapter interfaces\nUse one motion key for the recurring object and distinct element ids for its location in each mutually exclusive arrangement. Keep exactly one visible instance. Each interface should contain a real native input or declared local reaction: the same picture must make sense both during playback and after the viewer pauses.\n\nA useful story holds the message or task constant while the surrounding interface changes. The motion gives continuity; the input, menu and result prove the interaction paradigm. Label canned results explicitly when the audience can type arbitrary requests. Do not imply a model or backend computed a result.\n\nFor the match-cut transition above, use chapter() default continuation, and the engine's actionEntry: 'after' when a confirmed chapter drag should immediately show the new arrangement. Static storyboards prove layout; observe real playback to verify FLIP travel. If a flight does not appear, check for two visible same-key objects, a replaced Canvas/stage, or a manual jump with animate=false before changing the animation.\n\nKeep credits and sources outside the animated object area. Render every chapter and inspect the target frame after seeking; then test real typing, first-input pause, hover/touch, reset, continue and cross-chapter confirmation. A menu temporarily covering content is expected while open; verify it closes before the next action needs that content.\n\n## A news explainer as one map of clusters\nFor a topic explainer (an election, a policy, a market week), lay the whole episode out as one world of shot-sized clusters before writing steps.\n- Grid in narrative order: put clusters that hand over to each other side by side, so the adjacency is the camera route (ballot next to the seat chart, the map above the market it is called back to). A long diagonal move reads as a whip pan; use it once at most.\n- Reuse the same graphic across chapters instead of drawing a new board: a seat chart first lights up \"up for election\", then flips colour with the results, then gives up seats to a later chart. A map marks what is on the ballot, then the results, then is revisited for a later point (go back to one state).\n- Pin each opening question on the cluster that will answer it. When a chapter is on that cluster the tag says \"now\"; at the chapter end it turns into a short answer. Overview shots show a larger variant of the same tags (same motion key), so keep answers to about ten CJK characters and leave room for the large variant beside its cluster.\n- Make a number tangible by moving its marks: overlay the subset of marks that the number counts (for example the seats a party lost) with motion-keyed copies, light them up, then show the same keys arranged as a column in another cluster's chart while the camera moves there. The flight and the camera land together. Keep the original marks underneath so the source chart does not get holes, and size the dot grid so one dot equals one unit on the target chart's scale.\n- Results that pile up become the recap: a stamp lands large on the document it judges (enter=\"zoom\" with an enterDelay that waits for the document's flight), and on the next step the same motion key moves it into a row of small badges at the bottom. The chapter's summary step is a wide shot of that row, not a bullet card.\n- Keep one document object flying between two sides and change its text instead of fading documents in and out; a hidden object that reappears flies from its last location.\n- Chrome around the player's own overlays: the subtitle floats at the bottom centre and the step title pops at the top left, so put the chapter label at the top right with the source line under it, and give <Canvas safe> those bands. A closing call to action on the final overview goes at the top too, so it does not cover the answered question tags.\n- Cause near, effect far: when the control the viewer acts on (a ballot row) and the thing it changes (a map two clusters away) cannot share one readable frame, split the beat into the action step framed on the control and a system step that moves the camera to the result. Zooming out until both fit (below about 0.6\u00D7) makes both unreadable.\n- Count-in colour changes: when a chart recolours (seats flipping party), stagger each mark's transition-delay by its distance from the nearest end, so colour grows in from both sides like an election-night tally instead of switching at once.\n- Native controls inside a large world (Radio, Checkbox, Select) keep their own small font size; scale the control group with CSS zoom (about 1.3\u20131.5) rather than restyling its internals, and check the label size in the storyboard.\n- Source lines name only sources you actually have. For a rule, cite the rule itself (a constitutional article, a statute); never write \"see reports by X\" as a guess.\n\n## Remaking a deck-like piece as a film\nSymptoms in an existing piece: one board per chapter (label, big title, panels, footer), a title card opening each chapter, hard cuts between layers, an on-screen headline that repeats the caption and the narration, and opening questions that are never closed.\n- Keep the data module, sources and licensed assets; rebuild only the stage and the script. Create the remake as another work in works/<new-key>.tsx and mark the old work draft: true. Both remain accessible locally; only the ready work is published. Use build/share --work <key> to publish just one piece; selecting a draft is an error.\n- Before TSX, map each old board to a cluster of one world and each old title card to a camera move. Turn on-screen sentences into labels: the subtitle carries the sentence.\n- Then follow the review loop: storyboard every chapter, film-strip the chain to catch accidental cuts and stalls, and play it in the board. If playback stutters, measure before changing the piece (npx joplo skill demo).\n\n## Pitfalls that make a film feel like slides\n\n## Pitfalls that make a film feel like slides\n- Several steps under the same camera() go still once the drift reaches its end: the same target and drift do not restart it, and the film strip marks STILL. If the action has moved, let the camera follow it (the side where the document lands, the panel that just opened, the end of the chart being discussed) or give the step a new drift.\n- camera({ zoom }) is a cap, not a forced zoom. Padding expands the target bounds before fitting: a target already as wide as the safe area will zoom OUT when pad > 0 (870px / (870px + 2 \u00D7 70px) \u2248 0.86). For a full-width portrait target use pad: 0; for smaller targets start with 12\u201318 design pixels and inspect the frame. There is no minimum zoom clamp; fitting a larger target may require zooming out. If a cluster's shape does not match the safe area, neighbouring clusters show at the edges. Shape the opening cluster to the frame for a clean thumbnail.\n- <br> is not an element; write line breaks as '\n' with whiteSpace: 'pre-line'.\n- For close reading of a Diff or comparing numbers, use <Canvas drift={false}>. Keeping lines and digits at fixed positions gives viewers time to compare them. A STILL on this beat is intentional. Keep the camera still even when the film strip flags it.\n- Every element using the same entrance: vary by meaning (section 3b) and stagger a batch with enterStagger on its container; let new things start before old ones finish leaving.\n- Everything springs: a spring on every entrance reads as a toy. Springs for things that land, smooth or snappy for text and frames, bounce at most once a chapter.\n- Put the look you want to interpolate on the element that carries the motion key. Changes inside it (an inner wrapper's background, a bevelled border, a gradient) only crossfade; border colours, shadows and background images do not interpolate.\n- Put enter (and enterEase) on the element that carries the motion key, not on a wrapper around it: when the key flies in from elsewhere the wrapper would still enter and the piece would both fly and fade.\n- A whole interface replaced in one frame (when swap without exit/enter) is a hard cut. Give both sides a transition or cover the swap with the subject.\n- Whole-screen white/colour flashes over a still picture look like a stalled player; keep the picture moving under any fade.\n\nFor runtime layout QA, use joplo render --audit-layout for a final-state screenshot and --film --audit-layout for motion. Declare important selectors, a content frame and reserved footer/subtitle rectangles; exclude intentional stamps/background overlays. Text Range bounds reflect loaded fonts and actual Canvas scaling. Canvas exposes its existing engine-clock camera, drift midpoint/end and sequence-waypoint deadlines only as DOM diagnostic hints; static/jump/exploration states do not claim future motion. A later step can interrupt a phase, and masks/rotation or hidden content remain unknown rather than \"visible\". Inspect evidence before changing intentional overlap.\n\nCommon pitfall: For visual explainers, read npx joplo skill content: keep a continuous visual story, storyboard every chapter, film-strip the chain, and verify playback before claiming it works";
package/dist/guide.js CHANGED
@@ -3,7 +3,7 @@ export const skill = `# Joplo content production: content
3
3
  For explainers, tutorials, science and news-explainer pieces that should feel like a good video, not a deck: the viewer watches a world change while a voice explains it.
4
4
  Author one standalone work in works/<key>.tsx with work(); put chapter() slices under scenarios and narrate() in their steps. Chapters continue in declaration order by default. Works have covers and enter the project home page; no feature, review cases or pick is needed. Full example: examples/llm-explainer.
5
5
 
6
- Install @joplo-app/plugin-content at the Joplo version; import content and add it to config.plugins. Import { Canvas, Split, camera } from this package; keep work, chapter, patch, narrate and hold from @joplo-app/kit. Use theme: 'content:studio' for the bundled CSS. No plugin is implicitly enabled.
6
+ Install @joplo-app/plugin-content at the Joplo version; import content and add it to config.plugins. Import { Canvas, ItemTrack, Split, camera } from this package; keep work, chapter, patch, narrate and hold from @joplo-app/kit. Use theme: 'content:studio' for the bundled CSS. No plugin is implicitly enabled.
7
7
 
8
8
  ## Minimal work
9
9
  In a project with content enabled in config.plugins (and the starter's type: module / JSX tsconfig):
@@ -61,6 +61,8 @@ Failure mode, even with nice graphics: one board per chapter (big title, panels,
61
61
  - For diagram trace inside Canvas, pass { focus: false } to trace(...ids, options) so only the Canvas camera owns framing.
62
62
  - When another plugin effect also suggests host focus (for example a diagram trace inside a Canvas), use an explicit shot() for the whole director layer if the Canvas camera should own the framing. Otherwise host zoom and Canvas zoom can multiply and push nearby text out of view. Verify the actual visible bounds in playback, not only DOM text.
63
63
  - Camera: camera('id', …) frames those elements (Joplo measures them, adds pad, caps zoom); camera() shows the whole canvas. Establish wide, push in on detail, pull back for the payoff. Object flights in the same step follow the camera's timing, so both land together.
64
+ - camera('cache', { framing: 'detail', waitForMove: true }) lands a close-up before advancing the step. Choose overview (128 px pad, 1.25× cap, 1400 ms) for the whole group, medium (64 px, 2×, 1200 ms) for its neighbours, or detail (16 px, 4×, 900 ms) for one object. Explicit pad, zoom and ms override each preset independently. Without a preset the defaults remain 48 px, 3× and 1200 ms.
65
+ - waitForMove requests that many milliseconds of minimum step time. Other effects and narration can hold longer. Drift starts after landing and adds no wait; later steps inherit the framing without repeating the wait.
64
66
  - Chapters continue: chapter() starts from the previous chapter's last frame (state, camera, director layer) by default. Only use from: null to restart, or from: 'sliceKey' for another predecessor; keep all slices chapter() within this work. patch($.ui, { … }) changes several values in one step.
65
67
  - System-only chapters stay on the initial director layer unless camera(), shot(), a cue, or chapter('Slice title', { layer }) selects another layer. Continuing from a chapter inherits its final layer; do not copy its state by hand.
66
68
  - screen children of the Canvas stay fixed on screen: chapter label, source line, poster, end card.
@@ -86,13 +88,23 @@ chapter('What does it read?')
86
88
  - <Split text by="word"|"char"> renders text that enters piece by piece: enter / enterMs / enterEase / enterDelay apply to every piece (default enter rise), the root does not enter itself, and enterStagger defaults to 70 ms (word) or 30 ms (char). Words come from Intl.Segmenter, so Chinese splits into words too; punctuation stays on its word (opening quotes and brackets on the next one) and lines never break inside a word. Screen readers read the whole sentence once. text may be a state binding: a new value is a new set of pieces and enters again (a chapter label in the screen layer). exit applies to the whole Split. Use it for a headline, a chapter label or an answer appearing; a body paragraph the viewer reads should not split.
87
89
  - Pick by meaning: fade for a whole-world swap under cover, rise for things that come from below (menus from a taskbar, keyboards, receipts), shrink for windows opening, zoom for something punching toward the viewer, wipe for typed/printed results, iris for a reveal from a point. Keep two or three per piece; do not give every element the same entrance.
88
90
  - camera(…, { drift }) keeps the camera moving after it lands: a number = zoom factor reached over ms (default 8000), or { zoom, x, y, ms } with x/y in design px; false stops it. <Canvas drift={…}> sets the default for every step; without either, a subtle 4 % / 8 s push applies. Drift eases in and out and stops at its end point; it freezes on pause, records in video, and screenshots/deep links show the settled frame without drift. The next camera move starts from where the drifting camera actually is, including when only drift changes or is switched off; the configured camera ms eases back to the target before the next drift.
89
- - <Canvas safe={[top, right, bottom, left]}> (design px) is the part of the view your screen-layer chrome covers. Targeted camera() frames fit inside the rest, and drift zooms around its centre; camera() with no ids still shows the whole world full-bleed.
91
+ - For a close reading of a Diff or a comparison of numbers, use <Canvas drift={false}>. Stable positions let the eye return to the same line or digit. Keep an intentional STILL in this reading step.
92
+ - <Canvas safe={[top, right, bottom, left]}> (design px) is the part of the view your screen-layer chrome covers. Targeted camera() frames fit inside the rest, and drift zooms around its centre; camera() with no ids still shows the whole world full-bleed. For a final recap step with done() and bottom subtitles, pass all zone ids to camera('zone_a', 'zone_b', …, { pad }) (with safe top/bottom ≥ 110) or leave ≥ 10% top/bottom world margin so host completion badges and subtitles never overlap top/bottom zone titles.
90
93
  - UI life inside one interface (a caret blink, a stepped menu drop) can be CSS @keyframes in the project theme: the engine clock samples them, pause freezes them, static frames show their end state.
91
94
 
92
95
  ## 4. Choose the information shape, then the picture
93
96
  - A number landing; before and after; ranking (bars from zero, length proportional); part of a whole (a strip whose segment widths are the shares); a process (one object going around a loop); misconception then fact; a timeline; a place (tiles or a simple map).
94
97
  - Similar sentences get different pictures. Labels sit on the thing they name; no legends when a direct label fits.
95
98
  - Compute numbers in TS from one source (for example probabilities from one set of scores) so every number on screen agrees. Label illustrative numbers on screen ('illustrative'), separate from sourced facts.
99
+ - Encode reuse and invariants with stillness contrast: keep cached, locked or unchanged items mounted in place with the same motion key while only the newly computed item moves in; stillness beside motion explains reuse without extra text. Pair a pointing beat with a silent step (narrate(false) + hold(2–3)) when objects fly across containers so viewers can watch the transfer uninterrupted.
100
+ - Show trade-offs as coupled proportional geometry, not a two-column pros/cons card: drive two zero-anchored bars or slot grids from one TS parameter (for example compute per step dropping while memory footprint grows) and add native or onClick parameter switches so viewers can test the scaling while paused.
101
+ - Show algebraic folding, pipeline fusion, or decoupling as physical motion rather than before/after formulas: give movable transforms a conserved motion key across exclusive when branches so they slide into neighboring stages to fuse, and fly any blocking constraint onto a separate parallel narrow rail during a silent observation step.
102
+
103
+ ### Fixed slots and object identity
104
+
105
+ Use <ItemTrack id="cache" capacity={4} items={$.data.entries} /> to show what gets reused. Initialize entries with [{ id: 'a', label: 'A' }]. A step with push($.data.entries, { id: 'b', label: 'B', accent: 'teal' }) fills the next slot. A later set($.data.entries, [b, a]) moves both existing objects to their new positions. The same array can be passed directly to items. Review the arrival in playback and the final order by jumping to that step.
106
+
107
+ capacity is a positive integer up to 4096. keyField, labelField and accentField default to id, label and accent. Choose a unique, stable string or numeric key for each object; keep the key when its label changes. direction="column" stacks the slots vertically (default row). emptyLabel changes the empty slot caption (default 空槽). ITEM_TRACK_INVALID identifies duplicate keys, missing identity, or more entries than slots. Fix the source array or increase capacity. During free exploration the track reports invalid data inline and displays the first distinct valid entries that fit.
96
108
 
97
109
  ## 5. Motion and layout numbers
98
110
  - Camera moves 1–1.5 s, ease in-out. Object flights 0.9 s ease-out; stagger 60–120 ms (motionDelay); slow a landing pointer to 1.5–2 s (motionMs).
@@ -119,7 +131,7 @@ chapter('What does it read?')
119
131
  ## 9. Required: review before handing over
120
132
  - npx joplo check until 0 errors, then npx joplo outline --work <key>: verify the chapter order, step counts and estimated duration. Standalone works do not run feature coverage or HAPPY_PATH_ONLY checks.
121
133
  - Storyboard every chapter: npx joplo render --scenario-id <id> --sheet --out board.png prints every step in one image with its caption and narration. Read it frame by frame and assume the first one has problems: half-empty frames, objects cut at the edge, labels overlapping, text too small in wide shots, the chapter label covering content. Fix, then storyboard again.
122
- - Film-strip every chain of chapters: npx joplo render <dir> --scenario-id <first> --film --chain --out film.png. Fix every red CUT (one-frame full-screen change) unless it is your one deliberate cut, and every grey STILL (no visible change for ≥ 1.5 s). The storyboard cannot show either. Engine checklist: npx joplo skill demo, "Make it play like a film".
134
+ - Film-strip every chain of chapters: npx joplo render <dir> --scenario-id <first> --film --chain --out film.png. Review red CUTs (one-frame full-screen changes) and grey STILLs (no visible change for ≥ 1.5 s). Fix accidental cuts and stalls. Keep a deliberate still frame when viewers need to read. The storyboard cannot show either. Engine checklist: npx joplo skill demo, "Make it play like a film".
123
135
  - Play each chapter in the board with Voice on: flights and camera land together, nothing leaves the frame mid-flight, narration finishes before the next step.
124
136
  - Evidence, not belief: 'it plays' needs check 0 errors plus a run in the board; 'it looks right' needs the rendered frames; 'it is clear' needs captions-only and frames-only passes that both tell the story.
125
137
  - Tell the user what you could not verify (a real voice on a phone, other window sizes).
@@ -134,7 +146,7 @@ chapter('What does it read?')
134
146
  - To prove a draft did not publish, search all build artifacts for one complete sentence unique to the old work and absent as a substring of current copy. Keep the old work locally with draft: true; do not rely on the published menu alone.
135
147
 
136
148
  ## Diagnostics and recovery
137
- - CAMERA_UNKNOWN: the id must exist in a current layer or stage; frame elements inside this Canvas. CAMERA_INVALID: pad 0–2000, zoom 0.1–10, ms 0–10000, drift false | 0.5–2 | { zoom 0.5–2, x/y −2000–2000, ms 500–60000 }, finite numbers only; <Canvas drift> takes the same values and <Canvas safe> is four numbers 0–2000.
149
+ - CAMERA_UNKNOWN: the id must exist in a current layer or stage; frame elements inside this Canvas. CAMERA_INVALID: framing accepts overview, medium or detail; waitForMove is boolean. Check pad 0–2000, zoom 0.1–10, ms 0–10000, drift false | 0.5–2 | { zoom 0.5–2, x/y −2000–2000, ms 500–60000 }, finite numbers only; <Canvas drift> takes the same values and <Canvas safe> is four numbers 0–2000.
138
150
  - CAMERA_TARGET_HIDDEN: a camera target (or its ancestor) is hidden in this step's declared state. Its DOM bounds cannot be measured, so the view may fall back to the whole canvas. For scenes swapped with when, aim at a separate always-visible, sized anchor at the same coordinates; alternatively switch to the new visible target in the same step, or call camera() to intentionally show the world. Check inherited camera targets at chapter starts too. This warning uses declared visibility, including ancestors and responsive gates; it cannot measure CSS layout. Do not retain a previous DOM measurement as a fix: direct links and screenshots must reproduce the same frame without playback history.
139
151
  - PLUGIN_PROPERTY_INVALID: motion is a nonempty string; motionDelay/motionMs/enterMs/enterDelay/exitMs/exitDelay are finite numbers 0–10000; enterStagger/exitStagger are 0–2000; screen is boolean; enter/exit are one of fade, rise, zoom, shrink, wipe, iris, grow, growUp, blur; enterEase/exitEase/motionEase are one of smooth, snappy, spring, bounce, linear.
140
152
  - SPLIT_INVALID: <Split> needs a nonempty text prop (a literal or a state binding), by is word or char, and the text goes in text, not in children. These universal properties are literals, not state bindings. Use separate same-key elements with when for a flight between containers.
@@ -216,15 +228,15 @@ For a topic explainer (an election, a policy, a market week), lay the whole epis
216
228
  Symptoms in an existing piece: one board per chapter (label, big title, panels, footer), a title card opening each chapter, hard cuts between layers, an on-screen headline that repeats the caption and the narration, and opening questions that are never closed.
217
229
  - Keep the data module, sources and licensed assets; rebuild only the stage and the script. Create the remake as another work in works/<new-key>.tsx and mark the old work draft: true. Both remain accessible locally; only the ready work is published. Use build/share --work <key> to publish just one piece; selecting a draft is an error.
218
230
  - Before TSX, map each old board to a cluster of one world and each old title card to a camera move. Turn on-screen sentences into labels: the subtitle carries the sentence.
219
- - Then follow the review loop: storyboard every chapter, film-strip the chain until CUT and STILL are gone, and play it in the board. If playback stutters, measure before changing the piece (npx joplo skill demo).
231
+ - Then follow the review loop: storyboard every chapter, film-strip the chain to catch accidental cuts and stalls, and play it in the board. If playback stutters, measure before changing the piece (npx joplo skill demo).
220
232
 
221
233
  ## Pitfalls that make a film feel like slides
222
234
 
223
235
  ## Pitfalls that make a film feel like slides
224
- - Several steps under the same camera() go still once the drift reaches its end: the same target and drift do not restart it, and the film strip marks STILL. Let the camera follow the action (the side where the document lands, the panel that just opened, the end of the chart being discussed) or give the step a new drift.
236
+ - Several steps under the same camera() go still once the drift reaches its end: the same target and drift do not restart it, and the film strip marks STILL. If the action has moved, let the camera follow it (the side where the document lands, the panel that just opened, the end of the chart being discussed) or give the step a new drift.
225
237
  - camera({ zoom }) is a cap, not a forced zoom. Padding expands the target bounds before fitting: a target already as wide as the safe area will zoom OUT when pad > 0 (870px / (870px + 2 × 70px) ≈ 0.86). For a full-width portrait target use pad: 0; for smaller targets start with 12–18 design pixels and inspect the frame. There is no minimum zoom clamp; fitting a larger target may require zooming out. If a cluster's shape does not match the safe area, neighbouring clusters show at the edges. Shape the opening cluster to the frame for a clean thumbnail.
226
238
  - <br> is not an element; write line breaks as '\n' with whiteSpace: 'pre-line'.
227
- - Holds with a frozen camera: drift is on by default; do not turn it off for reading holds — a 1–8 % eased push is enough. If the film strip still marks STILL, the drift is too weak for that framing (flat UI shows little change); raise zoom or add x/y.
239
+ - For close reading of a Diff or comparing numbers, use <Canvas drift={false}>. Keeping lines and digits at fixed positions gives viewers time to compare them. A STILL on this beat is intentional. Keep the camera still even when the film strip flags it.
228
240
  - Every element using the same entrance: vary by meaning (section 3b) and stagger a batch with enterStagger on its container; let new things start before old ones finish leaving.
229
241
  - Everything springs: a spring on every entrance reads as a toy. Springs for things that land, smooth or snappy for text and frames, bounce at most once a chapter.
230
242
  - Put the look you want to interpolate on the element that carries the motion key. Changes inside it (an inner wrapper's background, a bevelled border, a gradient) only crossfade; border colours, shadows and background images do not interpolate.
@@ -0,0 +1,4 @@
1
+ import type { ComponentCtx } from '@joplo-app/kit/plugin';
2
+ export declare function ItemTrackView({ ctx }: {
3
+ ctx: ComponentCtx;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRoot } from '@joplo-app/kit/renderer';
3
+ import { color } from '@joplo-app/kit/renderer-style';
4
+ import { readTrack } from "./item-track.js";
5
+ export function ItemTrackView({ ctx }) {
6
+ const { capacity, entries, direction, emptyLabel, issues } = readTrack(ctx.node.props);
7
+ const root = useRoot(ctx.model, ctx.node.props, { style: { width: '100%', minWidth: 0, position: 'relative' } });
8
+ return _jsxs("div", { ...root, "data-jitem-track": "", children: [_jsx("ol", { style: { display: 'grid', gridTemplateColumns: `repeat(${direction === 'column' ? 1 : Math.max(1, capacity)}, minmax(0, 1fr))`, gap: 8, margin: 0, padding: 0, listStyle: 'none' }, children: Array.from({ length: capacity }, (_, index) => {
9
+ const entry = entries[index];
10
+ const motion = entry ? JSON.stringify([ctx.node.id, entry.key]) : undefined;
11
+ const accent = color(entry?.accent) ?? entry?.accent ?? 'var(--jp-line-strong)';
12
+ return _jsx("li", { "data-jtrack-item": entry ? '' : undefined, "data-jp-content-motion": motion, "data-jp-content-enter": entry ? 'rise' : undefined, title: entry?.label, style: {
13
+ padding: '0 .65em', lineHeight: '2.5em', textAlign: 'center', borderRadius: 6,
14
+ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis',
15
+ border: entry ? `1px solid ${accent}` : '1px dashed var(--jp-line)',
16
+ color: entry ? 'var(--jp-ink)' : 'var(--jp-muted)', backgroundColor: entry ? 'var(--jp-surface)' : 'transparent',
17
+ }, children: entry?.label ?? emptyLabel }, motion ?? index);
18
+ }) }), issues.length > 0 && _jsxs("small", { role: "status", children: ["ItemTrack \u00B7 ", issues.join(' ')] })] });
19
+ }
@@ -0,0 +1,28 @@
1
+ import type { Bind } from '@joplo-app/kit/node';
2
+ import type { JoploProps } from '@joplo-app/kit/plugin';
3
+ export type ItemTrackProps = JoploProps & {
4
+ capacity: number;
5
+ items: readonly object[] | Bind;
6
+ keyField?: string;
7
+ labelField?: string;
8
+ accentField?: string;
9
+ direction?: 'row' | 'column';
10
+ emptyLabel?: string;
11
+ };
12
+ type Entry = {
13
+ key: string;
14
+ label: string;
15
+ accent?: string;
16
+ };
17
+ /** Both the compiler and the player apply the same identity and capacity rules to a snapshot. */
18
+ export declare function readTrack(props: Record<string, unknown>): {
19
+ entries: Entry[];
20
+ issues: string[];
21
+ capacity: number;
22
+ keyField?: string | undefined;
23
+ labelField?: string | undefined;
24
+ accentField?: string | undefined;
25
+ direction: string;
26
+ emptyLabel: string;
27
+ };
28
+ export {};
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ const field = z.string().trim().min(1);
3
+ const options = z.object({
4
+ capacity: z.number().int().min(1).max(4096),
5
+ keyField: field.default('id'),
6
+ labelField: field.default('label'),
7
+ accentField: field.default('accent'),
8
+ direction: z.enum(['row', 'column']).default('row'),
9
+ emptyLabel: z.string().default('空槽'),
10
+ });
11
+ /** Both the compiler and the player apply the same identity and capacity rules to a snapshot. */
12
+ export function readTrack(props) {
13
+ const entries = [];
14
+ const issues = [];
15
+ const parsed = options.safeParse(props);
16
+ const track = { capacity: 0, direction: 'row', emptyLabel: '空槽', ...parsed.data, entries, issues };
17
+ if (!parsed.success) {
18
+ for (const issue of parsed.error.issues)
19
+ issues.push(`${issue.path.join('.')}: ${issue.message}`);
20
+ return track;
21
+ }
22
+ if (!Array.isArray(props.items)) {
23
+ issues.push('items must be an array of objects (initialize an empty track with []).');
24
+ return track;
25
+ }
26
+ const { capacity, keyField, labelField, accentField } = parsed.data;
27
+ if (props.items.length > capacity)
28
+ issues.push(`items has ${props.items.length} entries for capacity ${capacity}. Remove entries or increase capacity.`);
29
+ const seen = new Set();
30
+ for (const [index, item] of props.items.entries()) {
31
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
32
+ issues.push(`items[${index}] must be an object with a stable ${keyField}.`);
33
+ continue;
34
+ }
35
+ const raw = Object.hasOwn(item, keyField) ? item[keyField] : undefined;
36
+ if (!(typeof raw === 'string' && raw.trim() || typeof raw === 'number' && Number.isFinite(raw))) {
37
+ issues.push(`items[${index}].${keyField} must be a nonempty string or finite number.`);
38
+ continue;
39
+ }
40
+ const key = String(raw);
41
+ if (seen.has(key)) {
42
+ issues.push(`items[${index}] repeats ${keyField} ${JSON.stringify(key)}. Give each object a unique, stable key.`);
43
+ continue;
44
+ }
45
+ seen.add(key);
46
+ if (entries.length < capacity) {
47
+ const label = item[labelField];
48
+ entries.push({ key, label: typeof label === 'string' || typeof label === 'number' ? String(label) : key, accent: typeof item[accentField] === 'string' ? item[accentField] : undefined });
49
+ }
50
+ }
51
+ return track;
52
+ }
package/dist/plugin.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { z } from 'zod';
2
+ import { FRAMING } from './camera-framing.js';
3
+ import { type JNode } from '@joplo-app/kit/node';
4
+ import { type ItemTrackProps } from './item-track.js';
5
+ export type { ItemTrackProps } from './item-track.js';
2
6
  /** 进退场预设(D92):每个预设是一个“离场姿态”,进场 = 离场姿态 → 原样,退场 = 原样 → 离场姿态。 */
3
7
  export declare const TRANSITIONS: readonly ["fade", "rise", "zoom", "shrink", "wipe", "iris", "grow", "growUp", "blur"];
4
8
  export type Transition = (typeof TRANSITIONS)[number];
@@ -15,6 +19,8 @@ export type Drift = number | false | {
15
19
  ms?: number;
16
20
  };
17
21
  export type CameraOpts = {
22
+ framing?: keyof typeof FRAMING;
23
+ waitForMove?: boolean;
18
24
  pad?: number;
19
25
  zoom?: number;
20
26
  ms?: number;
@@ -70,4 +76,5 @@ export type ContentFrame = z.infer<typeof Frame>;
70
76
  declare const content: import("@joplo-app/kit").PluginDef;
71
77
  export declare const Canvas: (props: import("@joplo-app/kit").JoploProps) => any;
72
78
  export declare const Split: (props: import("@joplo-app/kit").JoploProps) => any;
79
+ export declare const ItemTrack: (props: ItemTrackProps) => JNode;
73
80
  export default content;
package/dist/plugin.js CHANGED
@@ -3,6 +3,9 @@ import { z } from 'zod';
3
3
  import { definePlugin, pluginComponent, pluginEffect } from '@joplo-app/kit/plugin';
4
4
  import { studio } from "./theme.js";
5
5
  import { skill, patterns } from "./guide.js";
6
+ import { DEFAULT_MOVE_MS, FRAMING } from "./camera-framing.js";
7
+ import { isBind } from '@joplo-app/kit/node';
8
+ import { readTrack } from "./item-track.js";
6
9
  /** 进退场预设(D92):每个预设是一个“离场姿态”,进场 = 离场姿态 → 原样,退场 = 原样 → 离场姿态。 */
7
10
  export const TRANSITIONS = ['fade', 'rise', 'zoom', 'shrink', 'wipe', 'iris', 'grow', 'growUp', 'blur'];
8
11
  /** 缓动预设:进场、退场、变形各自的“怎么落定”。smooth = 各自的默认曲线;spring / bounce 会冲过终点再回来。 */
@@ -20,6 +23,7 @@ const Safe = z.tuple([z.number().min(0).max(2000), z.number().min(0).max(2000),
20
23
  const CameraBase = z.strictObject({ targets: z.array(z.string()), pad: z.number().min(0).max(2000).optional(), zoom: z.number().min(.1).max(10).optional(), ms: z.number().min(0).max(10000).optional(), drift: DriftSchema.optional() });
21
24
  const Waypoint = CameraBase.omit({ ms: true, drift: true }).extend({ atMs: z.number().min(0).max(60000), ease: z.enum(['easeInOut', 'easeOut', 'linear']).optional() });
22
25
  const Camera = CameraBase.extend({ sequence: z.array(Waypoint).min(2).max(32).optional(), sequenceId: z.number().int().nonnegative().optional() });
26
+ const CameraCommand = Camera.extend({ framing: z.enum(['overview', 'medium', 'detail']).optional(), waitForMove: z.boolean().optional() });
23
27
  /** Explicit state-to-state camera waypoints, milliseconds from this step commit. */
24
28
  export const cameraSequence = (points) => pluginEffect('content', 'camera', {
25
29
  targets: points.at(-1)?.targets ?? (points.at(-1)?.target ? [points.at(-1).target] : []),
@@ -32,6 +36,7 @@ const content = definePlugin({ skillTopics: { patterns: { description: 'Recipes
32
36
  id: 'content', title: 'Visual explainers', version: packageInfo.version,
33
37
  runtime: new URL(import.meta.url.endsWith('.ts') ? './runtime.tsx' : './runtime.js', import.meta.url),
34
38
  components: {
39
+ ItemTrack: { doc: 'capacity, items (array or binding), keyField="id", labelField="label", accentField="accent", direction="row"|"column", emptyLabel; fixed slots with keyed item flights', example: '<ItemTrack id="cache" capacity={4} items={$.data.entries} />', traits: { text: ['emptyLabel'], textPaths: [['items', '*', 'label']] }, selfEvident: true },
35
40
  Canvas: { doc: 'w, h, view=[1280,800], drift?, safe?=[top,right,bottom,left]; scaled design world with fixed screen children; drift = default camera drift; safe = the view area not covered by screen chrome, where targeted camera() frames land', selfEvident: true },
36
41
  Split: { doc: 'text, by="word"|"char"; text that enters piece by piece: enter / enterMs / enterEase apply to each piece, enterStagger (default word 70, char 30 ms) spaces them; screen readers get the whole text', example: '<Split text="It is not typing, it is guessing" enter="rise" enterEase="spring" />', traits: { text: ['text'] }, selfEvident: true },
37
42
  },
@@ -57,6 +62,13 @@ const content = definePlugin({ skillTopics: { patterns: { description: 'Recipes
57
62
  data: { step: { scope: [{ path: ['scenes'], kind: 'map', domain: 'scene', children: [{ path: ['camera', 'targets'], kind: 'values', domain: 'element' }, { path: ['camera', 'sequence', '*', 'targets'], kind: 'values', domain: 'element' }] }] } },
58
63
  compile: {
59
64
  node(node, ctx) {
65
+ if (node.type === 'content:ItemTrack') {
66
+ const props = node.props;
67
+ const track = readTrack(isBind(props.items) ? { ...props, items: [] } : props);
68
+ for (const issue of track.issues)
69
+ ctx.report('ITEM_TRACK_INVALID', `<ItemTrack> ${issue}`, node.source);
70
+ return;
71
+ }
60
72
  if (node.type === 'content:Split') {
61
73
  const text = node.props?.text;
62
74
  // 绑定状态($.ui.title)在这里不是字符串;只拦没写、空白和数字 / 布尔字面量
@@ -80,12 +92,16 @@ const content = definePlugin({ skillTopics: { patterns: { description: 'Recipes
80
92
  ctx.report('PLUGIN_EFFECT_UNKNOWN', `Unknown content effect ${effect.name}`, ctx.source);
81
93
  return;
82
94
  }
83
- const parsed = Camera.safeParse(effect.payload);
95
+ const parsed = CameraCommand.safeParse(effect.payload);
84
96
  if (!parsed.success) {
85
- ctx.report('CAMERA_INVALID', `camera(…): targets must be strings; pad 0–2000, zoom 0.1–10, ms 0–10000, drift false | 0.5–2 | { zoom 0.5–2, x/y −2000–2000, ms 500–60000 } (${parsed.error.issues.map(i => i.message).join('; ')})`, ctx.source);
97
+ ctx.report('CAMERA_INVALID', `camera(…): targets must be strings; pad 0–2000, zoom 0.1–10, ms 0–10000, drift false | 0.5–2 | { zoom 0.5–2, x/y −2000–2000, ms 500–60000 } (${parsed.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('; ')})`, ctx.source);
86
98
  return;
87
99
  }
88
- const value = parsed.data;
100
+ const { framing, waitForMove, ...settings } = parsed.data;
101
+ const preset = framing && FRAMING[framing];
102
+ const value = preset ? {
103
+ ...settings, pad: settings.pad ?? preset.pad, zoom: settings.zoom ?? preset.zoom, ms: settings.ms ?? preset.ms,
104
+ } : settings;
89
105
  if (value.sequence && (value.sequence[0].atMs !== 0 || value.sequence.some((p, i, a) => i > 0 && p.atMs <= a[i - 1].atMs))) {
90
106
  ctx.report('CAMERA_INVALID', 'cameraSequence starts at 0 and needs strictly increasing atMs', ctx.source);
91
107
  return;
@@ -97,16 +113,25 @@ const content = definePlugin({ skillTopics: { patterns: { description: 'Recipes
97
113
  ctx.report('CAMERA_UNKNOWN', `camera(${missing.map(m => JSON.stringify(m)).join(', ')}) target is not in any layer or the stage for this step; aim it at elements inside a <Canvas>`, ctx.source);
98
114
  return;
99
115
  }
116
+ const holdMs = value.sequence?.at(-1)?.atMs ?? (waitForMove ? Math.ceil(value.ms ?? DEFAULT_MOVE_MS) : undefined);
100
117
  return {
101
118
  writes: [{ path: 'ui.__plugins.content.camera', value }],
102
119
  data: { cameraIssued: true },
103
120
  references: targets,
104
- ...(value.sequence ? { holdMs: value.sequence.at(-1).atMs } : {}),
121
+ ...(holdMs !== undefined ? { holdMs } : {}),
105
122
  ...(value.targets.length ? { directorTarget: value.targets[0] } : {}),
106
123
  };
107
124
  },
108
125
  frame(ctx) {
109
- const scenes = ctx.scenes.filter(s => all(s.root).some(n => n.type === 'content:Canvas'));
126
+ const sceneNodes = ctx.scenes.map(scene => ({ id: scene.id, nodes: all(scene.root) }));
127
+ for (const scene of sceneNodes)
128
+ for (const node of scene.nodes) {
129
+ if (node.type !== 'content:ItemTrack' || typeof node.props?.items !== 'string')
130
+ continue;
131
+ for (const issue of readTrack(ctx.resolveProps(node)).issues)
132
+ ctx.report('ITEM_TRACK_INVALID', `<ItemTrack id="${node.id}"> at position ${ctx.position}: ${issue}`, node.source);
133
+ }
134
+ const scenes = sceneNodes.filter(s => s.nodes.some(n => n.type === 'content:Canvas'));
110
135
  if (!scenes.length)
111
136
  return;
112
137
  const value = ctx.state.ui.__plugins?.content?.camera;
@@ -118,17 +143,18 @@ const content = definePlugin({ skillTopics: { patterns: { description: 'Recipes
118
143
  // 历史 DOM 缓存无法在深链/静帧重现同样的取景;在编译快照中明确提示,作者可改用稳定锚点。
119
144
  const targets = new Set([...parsed.data.targets, ...parsed.data.sequence?.flatMap(p => p.targets) ?? []]);
120
145
  for (const scene of scenes) {
121
- const nodes = all(scene.root);
146
+ const nodes = scene.nodes;
122
147
  for (const id of targets) {
123
148
  const node = nodes.find(n => n.id === id);
124
149
  if (node && !ctx.isVisible(scene.id, id))
125
150
  ctx.report('CAMERA_TARGET_HIDDEN', `Camera target "${id}" is hidden at position ${ctx.position}; its bounds cannot be measured and framing may fall back to the whole canvas. Aim camera() at an always-visible anchor, switch to a visible target, or reset with camera().`, node.source, 'warning');
126
151
  }
127
152
  }
128
- return { scenes: Object.fromEntries(scenes.map(s => [s.id, { camera: { ...parsed.data, ...(parsed.data.sequence ? { sequenceId: ctx.position === 0 ? 0 : ctx.data?.cameraIssued ? ctx.position : ctx.previousData?.scenes[s.id]?.camera.sequenceId ?? 0 } : {}), targets: parsed.data.targets.filter(id => all(s.root).some(n => n.id === id)) } }])) };
153
+ return { scenes: Object.fromEntries(scenes.map(s => [s.id, { camera: { ...parsed.data, ...(parsed.data.sequence ? { sequenceId: ctx.position === 0 ? 0 : ctx.data?.cameraIssued ? ctx.position : ctx.previousData?.scenes[s.id]?.camera.sequenceId ?? 0 } : {}), targets: parsed.data.targets.filter(id => s.nodes.some(n => n.id === id)) } }])) };
129
154
  },
130
155
  },
131
156
  });
132
157
  export const Canvas = pluginComponent(content, 'Canvas');
133
158
  export const Split = pluginComponent(content, 'Split');
159
+ export const ItemTrack = pluginComponent(content, 'ItemTrack');
134
160
  export default content;
package/dist/runtime.js CHANGED
@@ -2,6 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLayoutEffect, useMemo, useRef, useState } from 'react';
3
3
  import { defineRuntime } from '@joplo-app/kit/plugin';
4
4
  import { useEngineFrame, useRoot } from '@joplo-app/kit/renderer';
5
+ import { DEFAULT_MOVE_MS } from "./camera-framing.js";
6
+ import { ItemTrackView } from "./item-track-view.js";
5
7
  const stillCss = '.jstage[data-jstill] [data-jcanvas],.jstage[data-jstill] [data-jcanvas] *{transition:none!important;animation-delay:0s!important;animation-duration:0s!important}';
6
8
  const subjectStyle = (el) => {
7
9
  // Read the authored destination, not this observer's currently interpolated style.
@@ -242,11 +244,11 @@ function Canvas({ ctx: context }) {
242
244
  const glide = timed && (camMoves || dk !== driftKey.current) && !jumped && mounted && !!clock?.running;
243
245
  driftKey.current = dk;
244
246
  const from = glide ? cameraAt(seg.current, now, lensView) : next;
245
- seg.current = { from, to: next, start: now, ms: glide ? cam?.ms ?? 1200 : 0, drift };
247
+ seg.current = { from, to: next, start: now, ms: glide ? cam?.ms ?? DEFAULT_MOVE_MS : 0, drift };
246
248
  redraw((n) => n + 1);
247
249
  }
248
250
  // 镜头同一步也在动:变形用镜头的时长与缓动,两者同步落定(否则屏幕上的轨迹会先冲过头再折回)
249
- const flight = camMoves && ctx.animate ? { ms: cam?.ms ?? 1200, ease: CAMERA_EASE } : { ms: MOTION_MS, ease: MOTION_EASE };
251
+ const flight = camMoves && ctx.animate ? { ms: cam?.ms ?? DEFAULT_MOVE_MS, ease: CAMERA_EASE } : { ms: MOTION_MS, ease: MOTION_EASE };
250
252
  w.dataset.flightMs = String(flight.ms);
251
253
  w.dataset.flightEase = flight.ease;
252
254
  });
@@ -259,7 +261,7 @@ function Canvas({ ctx: context }) {
259
261
  const ox = (box.w - view.w * s) / 2;
260
262
  const oy = (box.h - view.h * s) / 2;
261
263
  const frame = cam?.sequence && pathRef.current ? sequenceFrameAt(pathRef.current.frames, !timed || ctx.playground || !clock?.running && !clock?.paused ? Infinity : now - pathRef.current.start) : timed ? cameraAt(seg.current, now, lensView) : seg.current.to;
262
- const ms = cam?.ms ?? 1200;
264
+ const ms = cam?.ms ?? DEFAULT_MOVE_MS;
263
265
  return (_jsxs("div", { ...root, children: [_jsx("style", { children: stillCss }), _jsxs("div", { ref: outer, style: { position: 'absolute', inset: 0 }, "data-jcanvas": "", "data-jreport-surface": "Canvas", "data-joplo-audit-phases": timed && !ctx.playground && (clock?.running || clock?.paused) ? JSON.stringify({ clockMs: now, phases: pathRef.current
264
266
  ? pathRef.current.frames.map(point => ({ phase: 'camera-waypoint', atMs: pathRef.current.start + point.atMs }))
265
267
  : [{ phase: 'camera-end', atMs: seg.current.start + seg.current.ms }, ...(seg.current.drift ? [{ phase: 'drift-mid', atMs: seg.current.start + seg.current.ms + seg.current.drift.ms / 2 }, { phase: 'drift-end', atMs: seg.current.start + seg.current.ms + seg.current.drift.ms }] : [])],
@@ -625,7 +627,10 @@ export const observe = (root, initial) => {
625
627
  }
626
628
  }
627
629
  // 画布世界与固定屏幕层(screen 子元素:时间轴、角标)都是“表面”:进退场与变形在两者里都生效,镜头只动世界
628
- const worlds = [...root.querySelectorAll('[data-jcanvas-world],[data-jcanvas-screen]')];
630
+ const canvasSurface = '[data-jcanvas-world],[data-jcanvas-screen]';
631
+ // A standalone track supplies its own design space. Inside a Canvas the existing surface owns the flight.
632
+ const worlds = [...root.querySelectorAll(canvasSurface + ',[data-jitem-track]')]
633
+ .filter(w => w.dataset.jitemTrack === undefined || !w.closest(canvasSurface));
629
634
  for (const w of layouts.keys())
630
635
  if (!worlds.includes(w)) {
631
636
  cancel(w);
@@ -641,6 +646,10 @@ export const observe = (root, initial) => {
641
646
  const flight = { ms: Number(w.dataset.flightMs ?? MOTION_MS), ease: w.dataset.flightEase ?? MOTION_EASE };
642
647
  // 2) 变形(FLIP):同一个 motion 键的布局位置变了 → 从旧位置、旧大小补间到新位置
643
648
  const seen = new Map(previous);
649
+ // Track membership is explicit. After eviction the same object must enter the track afresh.
650
+ for (const [key, box] of previous)
651
+ if (box.trackItem)
652
+ seen.delete(key);
644
653
  for (const el of w.querySelectorAll('[data-jp-content-motion]')) {
645
654
  const key = el.dataset.jpContentMotion;
646
655
  const r = offsetIn(el, w);
@@ -651,7 +660,7 @@ export const observe = (root, initial) => {
651
660
  const shells = [];
652
661
  for (let p = el.parentElement; p && p !== w; p = p.parentElement)
653
662
  shells.push(p.cloneNode(false));
654
- seen.set(key, { ...r, style, text, look, clone: el.cloneNode(true), shells });
663
+ seen.set(key, { ...r, trackItem: el.dataset.jtrackItem !== undefined, style, text, look, clone: el.cloneNode(true), shells });
655
664
  if (!context.frame.animate) {
656
665
  for (const a of el.getAnimations?.() ?? [])
657
666
  if (a.id === 'jmotion')
@@ -755,4 +764,4 @@ export const observe = (root, initial) => {
755
764
  },
756
765
  };
757
766
  };
758
- export default defineRuntime({ id: 'content', observe, components: { Canvas: { react: Canvas }, Split: { react: Split } } });
767
+ export default defineRuntime({ id: 'content', observe, components: { Canvas: { react: Canvas }, Split: { react: Split }, ItemTrack: { react: ItemTrackView } } });
package/dist/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.8.0"
2
+ "version": "0.8.2"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joplo-app/plugin-content",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "joplo": {
6
6
  "api": 2
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "zod": "4.6.7",
25
- "@joplo-app/kit": "0.8.0",
25
+ "@joplo-app/kit": "0.8.2",
26
26
  "react": "19.3.1"
27
27
  },
28
28
  "devDependencies": {