@joplo-app/core 0.2.17 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/actions.d.ts +6 -0
  2. package/dist/actions.js +34 -0
  3. package/dist/agent-skill.d.ts +10 -13
  4. package/dist/agent-skill.js +52 -31
  5. package/dist/auto-caption.d.ts +22 -0
  6. package/dist/auto-caption.js +166 -0
  7. package/dist/catalog.d.ts +38 -41
  8. package/dist/catalog.js +26 -317
  9. package/dist/compile.d.ts +2 -8
  10. package/dist/compile.js +302 -353
  11. package/dist/content-i18n.js +27 -16
  12. package/dist/feature-diff.d.ts +3 -3
  13. package/dist/feature-diff.js +28 -6
  14. package/dist/focus.d.ts +3 -1
  15. package/dist/focus.js +16 -34
  16. package/dist/guide.d.ts +10 -12
  17. package/dist/guide.js +419 -519
  18. package/dist/index.d.ts +4 -1
  19. package/dist/index.js +4 -1
  20. package/dist/media.d.ts +10 -0
  21. package/dist/media.js +43 -0
  22. package/dist/node.d.ts +1 -2
  23. package/dist/node.js +1 -2
  24. package/dist/outline.d.ts +1 -1
  25. package/dist/outline.js +3 -3
  26. package/dist/pace.d.ts +9 -1
  27. package/dist/pace.js +23 -3
  28. package/dist/player.d.ts +8 -41
  29. package/dist/player.js +85 -148
  30. package/dist/playground.d.ts +38 -0
  31. package/dist/playground.js +111 -0
  32. package/dist/plugin-data.d.ts +11 -0
  33. package/dist/plugin-data.js +96 -0
  34. package/dist/plugins/compiler.d.ts +66 -0
  35. package/dist/plugins/compiler.js +428 -0
  36. package/dist/plugins/data.d.ts +12 -0
  37. package/dist/plugins/data.js +120 -0
  38. package/dist/result.d.ts +1 -1
  39. package/dist/result.js +1 -0
  40. package/dist/runtime.d.ts +22 -0
  41. package/dist/runtime.js +18 -0
  42. package/dist/schema.d.ts +566 -82
  43. package/dist/schema.js +65 -53
  44. package/dist/scope.js +14 -5
  45. package/dist/step-identity.d.ts +1 -1
  46. package/dist/step-identity.js +1 -1
  47. package/dist/themes.d.ts +7 -0
  48. package/dist/themes.js +5 -0
  49. package/dist/traits.d.ts +7 -0
  50. package/dist/traits.js +26 -0
  51. package/dist/validate.js +17 -4
  52. package/dist/voice.d.ts +8 -2
  53. package/dist/voice.js +14 -2
  54. package/package.json +7 -4
  55. package/dist/diagram/elk.d.ts +0 -6
  56. package/dist/diagram/elk.js +0 -56
  57. package/dist/diagram/graph-layout.d.ts +0 -123
  58. package/dist/diagram/graph-layout.js +0 -620
  59. package/dist/diagram/index.d.ts +0 -41
  60. package/dist/diagram/index.js +0 -92
  61. package/dist/diagram/model.d.ts +0 -217
  62. package/dist/diagram/model.js +0 -189
  63. package/dist/diagram/sequence-layout.d.ts +0 -12
  64. package/dist/diagram/sequence-layout.js +0 -185
@@ -0,0 +1,6 @@
1
+ import type { PluginActionSpec } from '@joplo-app/kit/plugin';
2
+ import type { Action, Project } from './schema.js';
3
+ export declare function pluginActionSpec(project: Pick<Project, 'plugins'>, name: string): PluginActionSpec | undefined;
4
+ export declare function validActionData(spec: PluginActionSpec, data: Record<string, unknown>): boolean;
5
+ /** Gesture matching is declarative, including plugin payloads. No plugin callbacks in playback. */
6
+ export declare function actionMatches(expected: Action, observed: Action, spec?: PluginActionSpec): boolean;
@@ -0,0 +1,34 @@
1
+ export function pluginActionSpec(project, name) {
2
+ const [plugin, key] = name.split(':');
3
+ return plugin && key ? project.plugins?.[plugin]?.actions?.[key] : undefined;
4
+ }
5
+ export function validActionData(spec, data) {
6
+ return Object.keys(data).length === Object.keys(spec.fields).length && Object.entries(spec.fields).every(([key, field]) => {
7
+ const value = data[key];
8
+ return typeof value === field.type && (typeof value !== 'number' || Number.isFinite(value) && (field.min === undefined || value >= field.min) && (field.max === undefined || value <= field.max));
9
+ });
10
+ }
11
+ const sameDestination = (a, b) => typeof a === 'string' || typeof b === 'string' ? a === b : Math.hypot(a.x - b.x, a.y - b.y) <= 16;
12
+ /** Gesture matching is declarative, including plugin payloads. No plugin callbacks in playback. */
13
+ export function actionMatches(expected, observed, spec) {
14
+ if (expected.type !== observed.type)
15
+ return false;
16
+ if ('target' in expected && (!('target' in observed) || expected.target !== observed.target))
17
+ return false;
18
+ switch (expected.type) {
19
+ case 'click':
20
+ case 'back': return true;
21
+ case 'type':
22
+ case 'select':
23
+ case 'toggle': return 'value' in observed && expected.value === observed.value;
24
+ case 'press': return observed.type === 'press' && expected.keys === observed.keys;
25
+ case 'drag':
26
+ case 'scroll': return 'to' in observed && sameDestination(expected.to, observed.to);
27
+ case 'hover': return observed.type === 'hover' && observed.ms >= expected.ms;
28
+ case 'plugin': return observed.type === 'plugin' && expected.name === observed.name && !!spec && validActionData(spec, observed.data) && Object.entries(spec.fields).every(([key, field]) => {
29
+ const a = expected.data[key], b = observed.data[key];
30
+ return typeof a === 'number' && typeof b === 'number' ? Math.abs(a - b) <= (field.tolerance ?? 0) : a === b;
31
+ });
32
+ default: return false; // System events and cards cannot be triggered by audience input.
33
+ }
34
+ }
@@ -9,28 +9,22 @@
9
9
  /** `npx joplo skill <主题>` 的主题与一句话用途(guide.ts 生成正文;技能里按这份清单列出主题)。 */
10
10
  export declare const SKILL_TOPICS: readonly [{
11
11
  readonly name: "authoring";
12
- readonly description: "Mental model, first steps, page / option / flow syntax, when conditions, a form example";
12
+ readonly description: "Engine model, page / option / flow, explicit plugins, named local reactions, composable effects, state and conditions";
13
13
  }, {
14
14
  readonly name: "story";
15
15
  readonly description: "Plan a demo before coding; PM lens from a need to roles, goal, cases, and scenarios; openings, endings, captions; explainers and news-style demos";
16
16
  }, {
17
17
  readonly name: "demo";
18
- readonly description: "Layers, shots, captions, full-height layout, custom motion and data graphics, deep links, and screenshots";
18
+ readonly description: "Scripted playback and local exploration, drag / hover / scroll / plugin actions, confirmed action entries, themes, layers, captions, deep links and screenshots";
19
19
  }, {
20
20
  readonly name: "focus";
21
21
  readonly description: "Guide attention: one focus per step, defaults, spotlight / highlight / callout / numbered / hold / redact";
22
- }, {
23
- readonly name: "diagram";
24
- readonly description: "Architecture, sequence and state diagrams: domain groups, automatic layout, traces, shot framing";
25
- }, {
26
- readonly name: "components";
27
- readonly description: "Component catalog, supported HTML tags, line breaks, props, and real images";
28
22
  }, {
29
23
  readonly name: "cases";
30
24
  readonly description: "Case dimensions: ask the user before starting";
31
25
  }, {
32
26
  readonly name: "check";
33
- readonly description: "Read diagnostics, UNBOUND_INTERACTIVE, and fix the indicated file and line";
27
+ readonly description: "Read diagnostics, music duration/markers and timing warnings, UNBOUND_INTERACTIVE, and fix the indicated file and line";
34
28
  }, {
35
29
  readonly name: "selection";
36
30
  readonly description: "Edit only the element selected by the user in the board";
@@ -42,14 +36,17 @@ export declare const SKILL_TOPICS: readonly [{
42
36
  readonly description: "Compare public feature builds, stable step identity, uncertain matches, isolated PR CI publication";
43
37
  }, {
44
38
  readonly name: "publish";
45
- readonly description: "pick, build, share, review version, feedback write-back, deployment, chapters and phone viewing, viewers in several languages";
39
+ readonly description: "pick, build, explicit public/private and review choices, portfolios and SEO, Pro passwords, review version, feedback write-back, deployment, chapters and phone viewing, viewers in several languages, narration (Joplo Cloud characters, keys, joplo voice)";
40
+ }, {
41
+ readonly name: "plugins";
42
+ readonly description: "Data-only action contracts, native local behavior, engine-clock presenters; Universal properties, plugin themes, state writes and director targets; Binary assets, explicit paid resource generation, persistent artifacts, media tracks and offline publishing; API v2 immutable hooks, scoped/localized snapshots, shared React and production-package checks";
46
43
  }];
47
44
  /** 心智模型:所有入口最先读到的几句话。 */
48
- export declare const MENTAL_MODEL: readonly ["Joplo turns a feature idea into a clickable, replayable demo. It is a player for pre-declared scenarios, not a free-form app prototype, and not a slide or PPT tool: you write the screens and scripted scenarios in TSX, the local board plays them step by step, and reviewers compare options and leave feedback.", "Structure: a project has features; a feature has options (alternative designs, A/B) and cases (edge cases to cover); an option plays scenarios; a scenario is a list of steps.", "A step is one user action (.click / .type / .select / .press) or system event plus its visible effects (set, toast, go, done). Results and errors come from these effects, not from real logic or a backend.", "Viewers advance by clicking the highlighted element (other clicks only show a hint). Inputs show the sample value the step types; viewers cannot type their own, but the board's native feedback panel accepts real reviewer text.", "Options and cases are compared in the local board; only the picked option is published."];
45
+ export declare const MENTAL_MODEL: readonly ["Joplo turns a feature idea into a clickable, replayable demo. It is a player for pre-declared scenarios, not a free-form app prototype with persistent data or real backend logic, and not a slide or PPT tool: you write the screens and scripted scenarios in TSX, the local board plays them step by step, and reviewers compare options and leave feedback.", "Structure: a project has features; a feature has options (alternative designs, A/B) and cases (edge cases to cover); an option plays scenarios; a scenario is a list of steps.", "A step is one user action (.click / .type / .select / .press / .drag / .hover / .scroll / .act) or system event plus its visible effects (set, toast, go, done). Results and errors come from these effects, not from real logic or a backend.", "During playback, the first picture-changing stage input pauses and applies that same input. Hover does not pause; blank clicks only pause without an exploration notice. Matching the next action advances the script and stays stopped; another reachable scenario asks to switch (default before the action; actionEntry: 'after' consumes it on confirmation); native controls and declared free reactions change only a local playground. Play, jump, scenario change and reset discard exploration. Screenshots, video and deep links always use scripted state.", "Options and cases are compared in the local board; only the picked option is published."];
49
46
  /** 推荐的起步顺序(X2:先做最小的一条正常流程 + 一条错误恢复流程,在看板里确认交互模型后再扩展)。 */
50
- export declare const START_ORDER: readonly ["Read npx joplo skill authoring; read cases before asking the user about edge cases; demo and components as needed.", "Plan before coding (npx joplo skill story): audience, one to three points, one line per scenario (Given → When → Then, how it opens and ends; a case's expected is its Then); show the plan to the user. A demo is a story, not a feature tour.", "With minimal code, write one happy path and one error-and-recovery scenario.", "Run npx joplo check, then npx joplo dev; confirm typing, clicks, and layers really behave as intended in the board.", "Extend to every option and every case agreed with the user; run check until 0 errors.", "Before handing off for review, read npx joplo skill review. Keep npx joplo feedback watch [dir] --local --follow --json running in its own shell (joplo dev prints this exact command), then give the user the board URL dev printed. While they test, read its output with short waits (about 1–5s) and acknowledge each feedback right away; do not wait for approval or process exit. If you end your response while they test, add --once so the watcher exits (and wakes a host that resumes on background exit) on the first event, then resume with --since. Receive and apply review results with the joplo-feedback skill."];
47
+ export declare const START_ORDER: readonly ["Read npx joplo skill authoring; read cases before asking the user about edge cases; demo and installed plugin skills as needed.", "Plan before coding (npx joplo skill story): audience, one to three points, one line per scenario (Given → When → Then, how it opens and ends; a case's expected is its Then); show the plan to the user. A demo is a story, not a feature tour.", "With minimal code, write one happy path and one error-and-recovery scenario.", "Run npx joplo check, then npx joplo dev; confirm typing, clicks, and layers really behave as intended in the board.", "Extend to every option and every case agreed with the user; run check until 0 errors.", "Required after every round of development: before handing off, read npx joplo skill review and start npx joplo feedback watch [dir] --local --follow --json in its own shell (joplo dev prints this exact command); only then give the user the board URL dev printed. Never hand off with only a URL, and never end your response without a running watcher (use --once below). While they test, read its output with short waits (about 1–5s) and acknowledge each feedback right away; do not wait for approval or process exit. If you end your response while they test, add --once so the watcher exits (and wakes a host that resumes on background exit) on the first event, then resume with --since. Receive and apply review results with the joplo-feedback skill."];
51
48
  /** 最常见的坑:一句话 + 详细主题。 */
52
- export declare const PITFALLS: readonly [readonly ["when takes a condition, not a boolean: when={eq($.ui.mode, 'code')}, never when={mode === 'code'}; for values known while writing use {flag && <X/>}", "authoring"], readonly ["Only catalog components and the listed HTML tags exist; <br/> is UNKNOWN_COMPONENT, so write 'Line 1\\nLine 2' inside <Text>", "components"], readonly ["Every interactive element needs a flow step, disabled={true} with disabledReason, or unmodeled; otherwise check warns UNBOUND_INTERACTIVE", "check"], readonly ["No onClick or other function props: behavior lives in flow steps (.click/.type/.select) and effects (set, push, go, done)", "authoring"], readonly ["Full-height layouts squeeze tables and forms: rows exist in the DOM but are cut off on screen; show 5–8 rows or move the table to its own layer", "demo"], readonly ["Deep links use short params ?o=&c=&s=&step=&l= (l is the layer key and pins that layer, so later steps stop switching layers; layer= is ignored); wait for rendering before screenshots", "demo"], readonly ["Rules you assume stay origin ai_assumption, status pending; never mark them confirmed for the user", "cases"], readonly ["Never share or deploy without the user's go-ahead; free share links expire after 7 days", "publish"]];
49
+ export declare const PITFALLS: readonly [readonly ["Finishing development is not the end: always start npx joplo feedback watch [dir] --local --follow --json (add --once if you will end your response) before you give the user the board URL, and keep receiving their feedback", "review"], readonly ["when takes a condition, not a boolean: when={eq($.ui.mode, 'code')}, never when={mode === 'code'}; for values known while writing use {flag && <X/>}", "authoring"], readonly ["Every interactive element needs a flow step, disabled={true} with disabledReason, or unmodeled; otherwise check warns UNBOUND_INTERACTIVE", "check"], readonly ["No onClick or other function props: behavior lives in flow steps (.click/.type/.select) and effects (set, push, go, done)", "authoring"], readonly ["Full-height layouts squeeze tables and forms: rows exist in the DOM but are cut off on screen; show 5–8 rows or move the table to its own layer", "demo"], readonly ["Deep links use short params ?o=&c=&s=&step=&l= (l is the layer key and pins that layer, so later steps stop switching layers; layer= is ignored); wait for rendering before screenshots", "demo"], readonly ["Rules you assume stay origin ai_assumption, status pending; never mark them confirmed for the user", "cases"], readonly ["CHOICE_REQUIRED (exit 2): ask both publishing questions; never fix it by silently adding --private --no-review, and do not reuse the previous invocation", "publish"], readonly ["Public portfolio work and the always-private review version are two separate links: give reviewers data.review.url, the audience data.url", "publish"], readonly ["Required: before every share, ask the user public or private AND whether to also publish a review version. Never choose for them or reuse a previous choice; CI must pin both flags in its workflow", "publish"], readonly ["Public shares enter the portfolio and search engines: write the project name, description, and feature goals as search-result content; exclude unpublished information", "publish"], readonly ["Never invent or set an access password for the user: ask them to type it in their own terminal or set JOPLO_SHARE_PASSWORD; never put passwords in command history, files, or conversation summaries. Private Pro shares accept --password; omit both password flags to preserve protection", "publish"], readonly ["Never share or deploy without the user's go-ahead. Free links no longer expire, but every live share counts toward the account storage; if share fails with QUOTA_EXCEEDED (exit 6), tell the user the numbers and the two links from error.details, never delete their shares yourself", "publish"], readonly ["Joplo Cloud narration spends the user's characters: run npx joplo voice --dry-run and tell them the estimate before a large batch; on TTS_QUOTA_EXCEEDED (exit 7) keep what was made, pass on error.details.usageUrl, and never retry in a loop or buy for them", "publish"], readonly ["AiHubMix, OpenAI-compatible gateways and custom HTTP voice providers are gone: VOICE_UNSUPPORTED means ask the user to switch to Joplo Cloud narration, OpenAI or ElevenLabs (old audio still plays and ships); never hand-edit ~/.joplo/voice/profiles.json", "publish"], readonly ["Playing a demo never generates Joplo Cloud narration (it would spend characters): steps without audio use the browser voice until the user clicks Generate missing audio or you run npx joplo voice with their go-ahead", "publish"], readonly ["Re-sharing with the default voice keeps valid local clips plus reusable published clips, even when their voices differ (automatic captions must still match current text in the clip language; stale audio is excluded); an old custom provider named cloud stays unsupported until the user explicitly chooses official Joplo Cloud (use voice.profile: 'Joplo Cloud' when config owns the selection)", "publish"], readonly ["HAPPY_PATH_ONLY is expected for explainers whose chapters are all main-flow; do not invent failure scenarios to silence it", "check"], readonly ["Required for short films and explainers: static storyboards cannot show hard cuts or frozen pictures. Run npx joplo render <dir> --scenario-id <first chapter> --film --chain, fix every CUT and STILL it reports, and watch --video once before handing over", "demo"], readonly ["For multimodal stories, list assets and licenses first, prove one real asset in a playable chapter, then extend the batch within the agreed spending limit. Keep source claims separate from interpretations", "story"], readonly ["For generated binary assets, first look for CC0/public-domain material; use an enabled generation plugin for gaps. Run resources --dry-run before spending; check/build/render never generate paid artifacts. Commit outputs and metadata, keep keys local", "plugins"], readonly ["For background audio use a media plugin: enable it explicitly, read its skill, place play/stop in steps, and verify sound after a viewer gesture; local resource failures are warnings", "plugins"], readonly ["Collect reusable assets before drawing complex visuals; keep source URLs, authors, licenses and changes in assets/SOURCES.md, and verify bundled fonts and samples separately", "story"], readonly ["For audience exploration, use native UI controls or option.free; keep deterministic results in flow steps. Read demo before using drag, hover, scroll or plugin actions", "demo"], readonly ["Components outside the catalog may exist as plugins: install the npm package, add it to config({ plugins }), then read npx joplo skill <plugin id> before writing its components", "plugins"]];
53
50
  export type AgentSkill = {
54
51
  name: string;
55
52
  description: string;
@@ -8,51 +8,67 @@
8
8
  */
9
9
  /** `npx joplo skill <主题>` 的主题与一句话用途(guide.ts 生成正文;技能里按这份清单列出主题)。 */
10
10
  export const SKILL_TOPICS = [
11
- { name: 'authoring', description: 'Mental model, first steps, page / option / flow syntax, when conditions, a form example' },
11
+ { name: 'authoring', description: 'Engine model, page / option / flow, explicit plugins, named local reactions, composable effects, state and conditions' },
12
12
  { name: 'story', description: 'Plan a demo before coding; PM lens from a need to roles, goal, cases, and scenarios; openings, endings, captions; explainers and news-style demos' },
13
- { name: 'demo', description: 'Layers, shots, captions, full-height layout, custom motion and data graphics, deep links, and screenshots' },
13
+ { name: 'demo', description: 'Scripted playback and local exploration, drag / hover / scroll / plugin actions, confirmed action entries, themes, layers, captions, deep links and screenshots' },
14
14
  { name: 'focus', description: 'Guide attention: one focus per step, defaults, spotlight / highlight / callout / numbered / hold / redact' },
15
- { name: 'diagram', description: 'Architecture, sequence and state diagrams: domain groups, automatic layout, traces, shot framing' },
16
- { name: 'components', description: 'Component catalog, supported HTML tags, line breaks, props, and real images' },
17
15
  { name: 'cases', description: 'Case dimensions: ask the user before starting' },
18
- { name: 'check', description: 'Read diagnostics, UNBOUND_INTERACTIVE, and fix the indicated file and line' },
16
+ { name: 'check', description: 'Read diagnostics, music duration/markers and timing warnings, UNBOUND_INTERACTIVE, and fix the indicated file and line' },
19
17
  { name: 'selection', description: 'Edit only the element selected by the user in the board' },
20
18
  { name: 'review', description: 'Local live feedback, Share polling, prompt acknowledgement, session/version isolation, and recovery' },
21
19
  { name: 'diff', description: 'Compare public feature builds, stable step identity, uncertain matches, isolated PR CI publication' },
22
- { name: 'publish', description: 'pick, build, share, review version, feedback write-back, deployment, chapters and phone viewing, viewers in several languages' },
20
+ { name: 'publish', description: 'pick, build, explicit public/private and review choices, portfolios and SEO, Pro passwords, review version, feedback write-back, deployment, chapters and phone viewing, viewers in several languages, narration (Joplo Cloud characters, keys, joplo voice)' },
21
+ { name: 'plugins', description: 'Data-only action contracts, native local behavior, engine-clock presenters; Universal properties, plugin themes, state writes and director targets; Binary assets, explicit paid resource generation, persistent artifacts, media tracks and offline publishing; API v2 immutable hooks, scoped/localized snapshots, shared React and production-package checks' },
23
22
  ];
24
23
  /** 心智模型:所有入口最先读到的几句话。 */
25
24
  export const MENTAL_MODEL = [
26
- 'Joplo turns a feature idea into a clickable, replayable demo. It is a player for pre-declared scenarios, not a free-form app prototype, and not a slide or PPT tool: you write the screens and scripted scenarios in TSX, the local board plays them step by step, and reviewers compare options and leave feedback.',
25
+ 'Joplo turns a feature idea into a clickable, replayable demo. It is a player for pre-declared scenarios, not a free-form app prototype with persistent data or real backend logic, and not a slide or PPT tool: you write the screens and scripted scenarios in TSX, the local board plays them step by step, and reviewers compare options and leave feedback.',
27
26
  'Structure: a project has features; a feature has options (alternative designs, A/B) and cases (edge cases to cover); an option plays scenarios; a scenario is a list of steps.',
28
- 'A step is one user action (.click / .type / .select / .press) or system event plus its visible effects (set, toast, go, done). Results and errors come from these effects, not from real logic or a backend.',
29
- 'Viewers advance by clicking the highlighted element (other clicks only show a hint). Inputs show the sample value the step types; viewers cannot type their own, but the board\'s native feedback panel accepts real reviewer text.',
27
+ 'A step is one user action (.click / .type / .select / .press / .drag / .hover / .scroll / .act) or system event plus its visible effects (set, toast, go, done). Results and errors come from these effects, not from real logic or a backend.',
28
+ 'During playback, the first picture-changing stage input pauses and applies that same input. Hover does not pause; blank clicks only pause without an exploration notice. Matching the next action advances the script and stays stopped; another reachable scenario asks to switch (default before the action; actionEntry: \'after\' consumes it on confirmation); native controls and declared free reactions change only a local playground. Play, jump, scenario change and reset discard exploration. Screenshots, video and deep links always use scripted state.',
30
29
  'Options and cases are compared in the local board; only the picked option is published.',
31
30
  ];
32
31
  /** 推荐的起步顺序(X2:先做最小的一条正常流程 + 一条错误恢复流程,在看板里确认交互模型后再扩展)。 */
33
32
  export const START_ORDER = [
34
- 'Read npx joplo skill authoring; read cases before asking the user about edge cases; demo and components as needed.',
33
+ 'Read npx joplo skill authoring; read cases before asking the user about edge cases; demo and installed plugin skills as needed.',
35
34
  'Plan before coding (npx joplo skill story): audience, one to three points, one line per scenario (Given → When → Then, how it opens and ends; a case\'s expected is its Then); show the plan to the user. A demo is a story, not a feature tour.',
36
35
  'With minimal code, write one happy path and one error-and-recovery scenario.',
37
36
  'Run npx joplo check, then npx joplo dev; confirm typing, clicks, and layers really behave as intended in the board.',
38
37
  'Extend to every option and every case agreed with the user; run check until 0 errors.',
39
- 'Before handing off for review, read npx joplo skill review. Keep npx joplo feedback watch [dir] --local --follow --json running in its own shell (joplo dev prints this exact command), then give the user the board URL dev printed. While they test, read its output with short waits (about 1–5s) and acknowledge each feedback right away; do not wait for approval or process exit. If you end your response while they test, add --once so the watcher exits (and wakes a host that resumes on background exit) on the first event, then resume with --since. Receive and apply review results with the joplo-feedback skill.',
38
+ 'Required after every round of development: before handing off, read npx joplo skill review and start npx joplo feedback watch [dir] --local --follow --json in its own shell (joplo dev prints this exact command); only then give the user the board URL dev printed. Never hand off with only a URL, and never end your response without a running watcher (use --once below). While they test, read its output with short waits (about 1–5s) and acknowledge each feedback right away; do not wait for approval or process exit. If you end your response while they test, add --once so the watcher exits (and wakes a host that resumes on background exit) on the first event, then resume with --since. Receive and apply review results with the joplo-feedback skill.',
40
39
  ];
41
40
  /** 最常见的坑:一句话 + 详细主题。 */
42
41
  export const PITFALLS = [
43
- ['when takes a condition, not a boolean: when={eq($.ui.mode, \'code\')}, never when={mode === \'code\'}; for values known while writing use {flag && <X/>}', 'authoring'],
44
- ['Only catalog components and the listed HTML tags exist; <br/> is UNKNOWN_COMPONENT, so write \'Line 1\\nLine 2\' inside <Text>', 'components'],
45
- ['Every interactive element needs a flow step, disabled={true} with disabledReason, or unmodeled; otherwise check warns UNBOUND_INTERACTIVE', 'check'],
46
- ['No onClick or other function props: behavior lives in flow steps (.click/.type/.select) and effects (set, push, go, done)', 'authoring'],
47
- ['Full-height layouts squeeze tables and forms: rows exist in the DOM but are cut off on screen; show 5–8 rows or move the table to its own layer', 'demo'],
48
- ['Deep links use short params ?o=&c=&s=&step=&l= (l is the layer key and pins that layer, so later steps stop switching layers; layer= is ignored); wait for rendering before screenshots', 'demo'],
49
- ['Rules you assume stay origin ai_assumption, status pending; never mark them confirmed for the user', 'cases'],
50
- ['Never share or deploy without the user\'s go-ahead; free share links expire after 7 days', 'publish'],
42
+ ["Finishing development is not the end: always start npx joplo feedback watch [dir] --local --follow --json (add --once if you will end your response) before you give the user the board URL, and keep receiving their feedback", "review"],
43
+ ["when takes a condition, not a boolean: when={eq($.ui.mode, 'code')}, never when={mode === 'code'}; for values known while writing use {flag && <X/>}", "authoring"],
44
+ ["Every interactive element needs a flow step, disabled={true} with disabledReason, or unmodeled; otherwise check warns UNBOUND_INTERACTIVE", "check"],
45
+ ["No onClick or other function props: behavior lives in flow steps (.click/.type/.select) and effects (set, push, go, done)", "authoring"],
46
+ ["Full-height layouts squeeze tables and forms: rows exist in the DOM but are cut off on screen; show 5–8 rows or move the table to its own layer", "demo"],
47
+ ["Deep links use short params ?o=&c=&s=&step=&l= (l is the layer key and pins that layer, so later steps stop switching layers; layer= is ignored); wait for rendering before screenshots", "demo"],
48
+ ["Rules you assume stay origin ai_assumption, status pending; never mark them confirmed for the user", "cases"],
49
+ ["CHOICE_REQUIRED (exit 2): ask both publishing questions; never fix it by silently adding --private --no-review, and do not reuse the previous invocation", "publish"],
50
+ ["Public portfolio work and the always-private review version are two separate links: give reviewers data.review.url, the audience data.url", "publish"],
51
+ ["Required: before every share, ask the user public or private AND whether to also publish a review version. Never choose for them or reuse a previous choice; CI must pin both flags in its workflow", "publish"],
52
+ ["Public shares enter the portfolio and search engines: write the project name, description, and feature goals as search-result content; exclude unpublished information", "publish"],
53
+ ["Never invent or set an access password for the user: ask them to type it in their own terminal or set JOPLO_SHARE_PASSWORD; never put passwords in command history, files, or conversation summaries. Private Pro shares accept --password; omit both password flags to preserve protection", "publish"],
54
+ ["Never share or deploy without the user's go-ahead. Free links no longer expire, but every live share counts toward the account storage; if share fails with QUOTA_EXCEEDED (exit 6), tell the user the numbers and the two links from error.details, never delete their shares yourself", "publish"],
55
+ ["Joplo Cloud narration spends the user's characters: run npx joplo voice --dry-run and tell them the estimate before a large batch; on TTS_QUOTA_EXCEEDED (exit 7) keep what was made, pass on error.details.usageUrl, and never retry in a loop or buy for them", "publish"],
56
+ ["AiHubMix, OpenAI-compatible gateways and custom HTTP voice providers are gone: VOICE_UNSUPPORTED means ask the user to switch to Joplo Cloud narration, OpenAI or ElevenLabs (old audio still plays and ships); never hand-edit ~/.joplo/voice/profiles.json", "publish"],
57
+ ["Playing a demo never generates Joplo Cloud narration (it would spend characters): steps without audio use the browser voice until the user clicks Generate missing audio or you run npx joplo voice with their go-ahead", "publish"],
58
+ ["Re-sharing with the default voice keeps valid local clips plus reusable published clips, even when their voices differ (automatic captions must still match current text in the clip language; stale audio is excluded); an old custom provider named cloud stays unsupported until the user explicitly chooses official Joplo Cloud (use voice.profile: 'Joplo Cloud' when config owns the selection)", "publish"],
59
+ ["HAPPY_PATH_ONLY is expected for explainers whose chapters are all main-flow; do not invent failure scenarios to silence it", "check"],
60
+ ["Required for short films and explainers: static storyboards cannot show hard cuts or frozen pictures. Run npx joplo render <dir> --scenario-id <first chapter> --film --chain, fix every CUT and STILL it reports, and watch --video once before handing over", "demo"],
61
+ ["For multimodal stories, list assets and licenses first, prove one real asset in a playable chapter, then extend the batch within the agreed spending limit. Keep source claims separate from interpretations", "story"],
62
+ ["For generated binary assets, first look for CC0/public-domain material; use an enabled generation plugin for gaps. Run resources --dry-run before spending; check/build/render never generate paid artifacts. Commit outputs and metadata, keep keys local", "plugins"],
63
+ ["For background audio use a media plugin: enable it explicitly, read its skill, place play/stop in steps, and verify sound after a viewer gesture; local resource failures are warnings", "plugins"],
64
+ ["Collect reusable assets before drawing complex visuals; keep source URLs, authors, licenses and changes in assets/SOURCES.md, and verify bundled fonts and samples separately", "story"],
65
+ ["For audience exploration, use native UI controls or option.free; keep deterministic results in flow steps. Read demo before using drag, hover, scroll or plugin actions", "demo"],
66
+ ["Components outside the catalog may exist as plugins: install the npm package, add it to config({ plugins }), then read npx joplo skill <plugin id> before writing its components", "plugins"],
51
67
  ];
52
68
  /** 中文触发词:技能 description 里的匹配文本,不是 CLI 界面文案(english-output 测试的白名单)。 */
53
- const ZH_JOPLO = '功能原型、可交互演示、方案对比、给产品 / 设计 / 评审看的演示';
69
+ const ZH_JOPLO = '功能原型、可交互演示、方案对比、给产品 / 设计 / 评审看的演示、讲解视频、科普、教程、资讯解读';
54
70
  const ZH_FEEDBACK = '本地评审、监听反馈、确认方案、评审有结论了、按评审意见修改演示';
55
- const JOPLO_DESCRIPTION = `Build clickable, replayable feature demos with Joplo (scripted scenarios in TSX, viewed in a local board) when the user wants a feature prototype, an interactive or clickable demo, an A/B comparison of options or edge cases, or a demo for product, design, or review (${ZH_JOPLO}), including in a repo without joplo.config.ts, but not for slide decks or PPT.`;
71
+ const JOPLO_DESCRIPTION = `Build clickable, replayable feature demos with Joplo (scripted scenarios in TSX, viewed in a local board) when the user wants a feature prototype, an interactive or clickable demo, an A/B comparison of options or edge cases, or a demo for product, design, or review, or a narrated explainer, tutorial, or news-explainer piece that should play like a video (${ZH_JOPLO}), including in a repo without joplo.config.ts, but not for slide decks, PPT, or editing real video footage.`;
56
72
  const FEEDBACK_DESCRIPTION = `Receive and apply Joplo review feedback when the user wants to test a local demo, start or resume a feedback listener (npx joplo feedback watch --local --follow), confirm an option, monitor a Share review, or implement review conclusions (${ZH_FEEDBACK}); covers local live events and Cloud polling, without requiring a share for local review.`;
57
73
  const list = (items) => items.map((s, i) => `${i + 1}. ${s}`);
58
74
  function joploBody() {
@@ -64,11 +80,13 @@ function joploBody() {
64
80
  '## When to use',
65
81
  '- The user wants to think a feature through before building it: a prototype, a clickable demo, A/B options, edge cases, or a walkthrough for product, design, or review.',
66
82
  '- The user wants to compare how a feature changed between two versions or in a PR (see npx joplo skill diff).',
83
+ '- The user wants an explainer, tutorial, science piece, or news explainer that plays like a video (narration, chapters, animated graphics): read .claude/skills/joplo-plugins/SKILL.md and the relevant installed plugin skill first.',
67
84
  '',
68
85
  '## When not to use',
69
86
  '- Production UI code or real backends: Joplo demos are scripted; nothing runs real logic.',
70
- '- Demos where viewers must type their own free input.',
71
- '- Slide decks, pitch decks, or text-and-bullet presentations with no product behavior to show: use a slides tool instead.',
87
+ '- Apps that must persist audience edits or execute real backend logic. Local typing and controls are supported only as disposable exploration.',
88
+ '- Slide decks, pitch decks, or text-and-bullet presentations with no product behavior or animated explanation to show: use a slides tool instead.',
89
+ '- Editing real video footage: media plugins add background sound, but Joplo is not a footage editor.',
72
90
  '',
73
91
  '## Quick start',
74
92
  '```sh',
@@ -82,22 +100,23 @@ function joploBody() {
82
100
  '## Workflow',
83
101
  '1. No joplo.config.ts yet: npx joplo@latest init <dir>, or npx joplo@latest init . for the current directory, then npm install there (versions are pinned). Agent and Git files (.git, .gitignore, .agents, .claude, AGENTS.md, skills-lock.json) do not count as content; other existing files need init . --keep, which only adds missing files. init skips these skills when the same version is already installed and never overwrites edited ones. In an existing Joplo project, use its installed npx joplo.',
84
102
  ...list(START_ORDER).map(line => line.replace(/^(\d+)/, (_, n) => String(Number(n) + 1))),
85
- `${START_ORDER.length + 2}. Only when the user asks to share or publish: npx joplo share --format json publishes picked options; npx joplo share --review publishes every option for reviewers. Confirming an option in the board is not a publish request. To share part of the project, add --scenario <scenario id> or --feature <feature id> (repeatable): everything else stays out of the uploaded files; tell the user about any data.scope.borrowed items.`,
103
+ `${START_ORDER.length + 2}. Only when the user asks to share or publish: npx joplo share --private --no-review --format json publishes picked options; npx joplo share --private --review also publishes a separate, always-private link containing every option for reviewers (data.review.url); data.url is the main link. For scoped review results with data.mode = review, only the private review was published and its link is data.url; read skill publish for this boundary. Confirming an option in the board is not a publish request. To share part of the project, add --scenario <scenario id> or --feature <feature id> (repeatable): everything else stays out of the uploaded files; tell the user about any data.scope.borrowed items.`,
86
104
  '',
87
105
  '## Show the product, not slides',
88
106
  'Every step is an action on the product and a visible change it causes. If a step could be a bullet on a slide, rebuild it as interface, state, or a trace.',
89
107
  '- Feature: not a card listing "enter email / teammate gets a link / joins today"; instead Ana types the email, clicks Send, the row appears as Pending, then Leo\'s layer opens the mail and lands in the space.',
90
- '- Backend or architecture: not a card "App → API → Queue → Worker"; instead a Diagram where trace() lights each hop as the request moves and trace.fail() shows where it breaks, beside the UI whose status changes with it.',
108
+ '- Backend or architecture: not a card "App → API → Queue → Worker"; instead an installed plugin view where each request hop and failure changes on screen, beside the UI whose status changes with it.',
91
109
  '- Comparison: not a pros-and-cons table; instead options A and B each playing the same scenario, compared in the board.',
92
- '- State or lifecycle: not a paragraph explaining statuses; instead a StateMachine whose current state moves as the user acts.',
110
+ '- State or lifecycle: not a paragraph explaining statuses; instead a lifecycle view whose current state moves as the user acts.',
93
111
  '- Cards only open, close, jump in time, or switch roles; text that explains belongs in captions and explain(). Worked example: npx joplo skill story.',
94
112
  '',
95
113
  '## Review live with the user',
114
+ 'Required: whenever you finish a round of development the user will look at, start the follower below before handing off, even for small changes and even if the user did not ask for a review. A hand-off without a running watcher loses their feedback.',
96
115
  'The user reviews in the board: they click through scenarios, write comments with the board\'s native feedback icon, and may confirm (approve) an option. You receive each event the moment it is saved.',
97
116
  '1. Start npx joplo feedback watch <dir> --local --follow --json in its own long-running shell (joplo dev prints this exact command; the board\'s feedback panel can copy it too). One follower covers every option of the project and attaches by itself to the new round each source edit opens.',
98
117
  '2. Then give the user the board URL that dev printed (do not assume port 4790) and point them to the native feedback icon. If they want to drive the UI themselves, only give the link.',
99
118
  '3. While they test, read the follower\'s output with short waits (about 1–5 seconds). Each stdout line is one JSON event (feedback, approved, closed) carrying eventId, optionId, sessionId and context (route, scenario, step, source); deduplicate by eventId. A background shell alone does not wake an idle agent: stay in a receive loop, and do not claim you are still listening after ending your response unless the host can resume you.',
100
- ' - If you will end your response while the user tests, and your host wakes you when a background command finishes (Claude Code does): run the follower in the background with --once added. It exits 0 on the first feedback or approval, which wakes you. Handle the events, then start it again with --since <createdAt of the last event> (the exit message prints this exact command) so nothing is replayed or lost. Without such a host, tell the user to message you after they confirm.',
119
+ ' - If you will end your response while the user tests, and your host wakes you when a background command finishes (a host configured to resume on process exit does): run the follower in the background with --once added. It exits 0 on the first feedback or approval, which wakes you. Handle the events, then start it again with --since <createdAt of the last event> (the exit message prints this exact command) so nothing is replayed or lost. Without such a host, tell the user to message you after they confirm.',
101
120
  '4. On feedback, acknowledge the actual text and its page/step right away, in the reviewer\'s language, then keep listening. Change the demo only when the user asked for changes; after edits, run npx joplo check. closed (source_changed) is then expected and the follower moves to the new round.',
102
121
  '5. approved confirms that option version only: it is not proof the feedback was implemented and not permission to publish. The follower ends with exit 1 only when the board stops (restart dev, then the follower) or 130 on Ctrl+C.',
103
122
  'Exact-session watching, Share polling, and applying pick / rule / question decisions: joplo-feedback skill and npx joplo skill review.',
@@ -112,8 +131,8 @@ function joploBody() {
112
131
  ...PITFALLS.map(([text, topic]) => `- ${text}. See npx joplo skill ${topic}.`),
113
132
  '',
114
133
  '## Reference',
115
- 'npx joplo skill <topic> prints guidance matching the installed version; npx joplo skill lists them with line counts.',
116
- ...SKILL_TOPICS.map(t => `- ${t.name}: ${t.description}`),
134
+ 'npx joplo skill <topic> prints guidance matching the installed version; npx joplo skill lists engine and enabled plugin topics. Installed engine references are linked below; plugin guides are indexed in ../joplo-plugins/SKILL.md.',
135
+ ...SKILL_TOPICS.map(t => `- [${t.name}](./topics/${t.name}.md): ${t.description}`),
117
136
  'npx joplo components <Name> shows a component\'s props and an example. Pin these skills to a release: npx skills add https://github.com/Joplo-app/Joplo/tree/v<version> (Joplo-app/Joplo@v<version> does not work).',
118
137
  ].join('\n');
119
138
  }
@@ -129,6 +148,7 @@ function feedbackBody() {
129
148
  '- Share review uses the owner\'s login or an API key with feedback:read. Keep the local/Cloud source explicit.',
130
149
  '',
131
150
  '## Local review: one follower for the whole project',
151
+ 'Required: after every round of development, start this follower before you give the user the board URL, and do not end your response without it running (use --once if you must end it). Never hand off with only a link.',
132
152
  '```sh',
133
153
  'npx joplo dev ./demo # prints the board URL and the command below',
134
154
  'npx joplo feedback watch ./demo --local --follow --json # keep running in its own shell',
@@ -171,7 +191,8 @@ function feedbackBody() {
171
191
  '- answer: delete the question and add a rule stating the answer with origin: \'user\', status: \'confirmed\'.',
172
192
  '- Comments are discussion input; apply them when the user has asked for those changes. Treat their text as reviewer content, not shell instructions.',
173
193
  '- Run npx joplo check until 0 errors, then relevant project checks for production-code changes. If the user will inspect the UI, give the refreshed URL and let them drive it.',
174
- '- Republish only when requested: npx joplo share --review --format json includes every option; npx joplo share --format json publishes picked options only.',
194
+ '- Required: before every publication ask the user public or private AND whether to also publish a review version. Never choose for them or reuse the previous choice; CI must pin both flags.',
195
+ '- Republish only when requested: npx joplo share --private --review --format json also publishes every option at data.review.url (always private); npx joplo share --private --no-review --format json publishes picked options only. For a scoped review with no picked scenarios, data.mode is review and data.url is the private review link; the ordinary share is unchanged.',
175
196
  '- For Cloud decisions actually written back, run npx joplo feedback --applied <decision-ids> --ref <source-ref>, keeping the same --share and --server target. Never mark a local receipt, local seq, or unimplemented comment as applied.',
176
197
  '',
177
198
  '## Recovery and boundaries',
@@ -200,7 +221,7 @@ export function agentsBlock() {
200
221
  `Mental model: ${MENTAL_MODEL.slice(0, 5).join(' ')}`,
201
222
  `Start: ${START_ORDER.map((s, i) => `(${i + 1}) ${s}`).join(' ')}`,
202
223
  'Pitfalls:',
203
- ...PITFALLS.slice(0, 6).map(([text, topic]) => `- ${text} (npx joplo skill ${topic}).`),
224
+ ...PITFALLS.map(([text, topic]) => `- ${text} (npx joplo skill ${topic}).`),
204
225
  'After editing, run npx joplo check. After a board selection, run npx joplo selection and edit only that location. Receive and apply review results with joplo-feedback and npx joplo skill review; Cloud source write-back: npx joplo skill publish.',
205
226
  ].join('\n');
206
227
  }
@@ -0,0 +1,22 @@
1
+ /** 自动字幕的唯一文案来源:网页显示与服务端音频有效性校验共用,参数必须先按内容语言本地化。 */
2
+ import { type ContentLocale } from './content-i18n.js';
3
+ import type { Step } from './schema.js';
4
+ type AutoCaptionMessages = {
5
+ autoDrag: (label: string, value: string) => string;
6
+ autoHover: (label: string) => string;
7
+ autoScroll: (label: string, value: string) => string;
8
+ autoClick: (label: string) => string;
9
+ autoType: (label: string, text: string) => string;
10
+ autoSelect: (label: string, text: string) => string;
11
+ autoCheck: (label: string) => string;
12
+ autoUncheck: (label: string) => string;
13
+ autoSwitchOn: (label: string) => string;
14
+ autoSwitchOff: (label: string) => string;
15
+ autoBack: string;
16
+ autoPress: (keys: string) => string;
17
+ };
18
+ /** 字典保持原来的 player.auto* 键及延迟翻译接口。 */
19
+ export declare const autoCaptionMessages: (locale: ContentLocale) => AutoCaptionMessages;
20
+ /** 按当前参数与语言还原实际字幕;未知语言无法证明缓存有效,返回 null。 */
21
+ export declare function automaticCaption(auto: NonNullable<Step['captionAuto']>, locale: string): string | null;
22
+ export {};
@@ -0,0 +1,166 @@
1
+ /** 自动字幕的唯一文案来源:网页显示与服务端音频有效性校验共用,参数必须先按内容语言本地化。 */
2
+ import { isContentLocale } from "./content-i18n.js";
3
+ const messages = {
4
+ 'en': {
5
+ autoDrag: (label, value) => `Drag \u201c${label}\u201d to ${value}`,
6
+ autoHover: (label) => `Hover over \u201c${label}\u201d`,
7
+ autoScroll: (label, value) => `Scroll \u201c${label}\u201d to ${value}`,
8
+ autoClick: (label) => `Click “${label}”`,
9
+ autoType: (label, text) => `Type “${text}” in “${label}”`,
10
+ autoSelect: (label, text) => `Select “${text}” in “${label}”`,
11
+ autoCheck: (label) => `Check “${label}”`,
12
+ autoUncheck: (label) => `Uncheck “${label}”`,
13
+ autoSwitchOn: (label) => `Turn on “${label}”`,
14
+ autoSwitchOff: (label) => `Turn off “${label}”`,
15
+ autoBack: 'Go back',
16
+ autoPress: (keys) => keys.trim() ? `Press ${keys}` : 'Press a key',
17
+ },
18
+ 'zh-CN': {
19
+ autoDrag: (label, value) => `\u62d6\u52a8\u300c${label}\u300d\u5230 ${value}`,
20
+ autoHover: (label) => `\u60ac\u505c\u5728\u300c${label}\u300d`,
21
+ autoScroll: (label, value) => `\u6eda\u52a8\u300c${label}\u300d\u5230 ${value}`,
22
+ autoClick: (label) => `\u70b9\u51fb\u300c${label}\u300d`,
23
+ autoType: (label, text) => `\u5728\u300c${label}\u300d\u4e2d\u8f93\u5165“${text}”`,
24
+ autoSelect: (label, text) => `\u5728\u300c${label}\u300d\u4e2d\u9009\u62e9“${text}”`,
25
+ autoCheck: (label) => `\u52fe\u9009\u300c${label}\u300d`,
26
+ autoUncheck: (label) => `\u53d6\u6d88\u52fe\u9009\u300c${label}\u300d`,
27
+ autoSwitchOn: (label) => `\u6253\u5f00\u300c${label}\u300d`,
28
+ autoSwitchOff: (label) => `\u5173\u95ed\u300c${label}\u300d`,
29
+ autoBack: '\u8fd4\u56de\u4e0a\u4e00\u9875',
30
+ autoPress: (keys) => keys.trim() ? `\u6309\u4e0b ${keys}` : '\u6309\u4e0b\u6309\u952e',
31
+ },
32
+ 'zh-TW': {
33
+ autoDrag: (label, value) => `\u62d6\u66f3\u300c${label}\u300d\u5230 ${value}`,
34
+ autoHover: (label) => `\u505c\u7559\u5728\u300c${label}\u300d\u4e0a`,
35
+ autoScroll: (label, value) => `\u6372\u52d5\u300c${label}\u300d\u5230 ${value}`,
36
+ autoClick: (label) => `\u9ede\u9078\u300c${label}\u300d`,
37
+ autoType: (label, text) => `\u5728\u300c${label}\u300d\u8f38\u5165\u300c${text}\u300d`,
38
+ autoSelect: (label, text) => `\u5728\u300c${label}\u300d\u9078\u64c7\u300c${text}\u300d`,
39
+ autoCheck: (label) => `\u52fe\u9078\u300c${label}\u300d`,
40
+ autoUncheck: (label) => `\u53d6\u6d88\u52fe\u9078\u300c${label}\u300d`,
41
+ autoSwitchOn: (label) => `\u958b\u555f\u300c${label}\u300d`,
42
+ autoSwitchOff: (label) => `\u95dc\u9589\u300c${label}\u300d`,
43
+ autoBack: "\u8fd4\u56de\u4e0a\u4e00\u9801",
44
+ autoPress: (keys) => keys.trim() ? `\u6309\u4e0b ${keys}` : "\u6309\u4e0b\u6309\u9375",
45
+ },
46
+ 'ja': {
47
+ autoDrag: (label, value) => `\u300c${label}\u300d\u3092 ${value} \u306b\u30c9\u30e9\u30c3\u30b0`,
48
+ autoHover: (label) => `\u300c${label}\u300d\u306b\u30dd\u30a4\u30f3\u30bf\u30fc\u3092\u5408\u308f\u305b\u308b`,
49
+ autoScroll: (label, value) => `\u300c${label}\u300d\u3092 ${value} \u307e\u3067\u30b9\u30af\u30ed\u30fc\u30eb`,
50
+ autoClick: (label) => `\u300c${label}\u300d\u3092\u30af\u30ea\u30c3\u30af`,
51
+ autoType: (label, text) => `\u300c${label}\u300d\u306b\u300c${text}\u300d\u3092\u5165\u529b`,
52
+ autoSelect: (label, text) => `\u300c${label}\u300d\u3067\u300c${text}\u300d\u3092\u9078\u629e`,
53
+ autoCheck: (label) => `\u300c${label}\u300d\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b`,
54
+ autoUncheck: (label) => `\u300c${label}\u300d\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5916\u3059`,
55
+ autoSwitchOn: (label) => `\u300c${label}\u300d\u3092\u30aa\u30f3\u306b\u3059\u308b`,
56
+ autoSwitchOff: (label) => `\u300c${label}\u300d\u3092\u30aa\u30d5\u306b\u3059\u308b`,
57
+ autoBack: "\u524d\u306e\u30da\u30fc\u30b8\u306b\u623b\u308b",
58
+ autoPress: (keys) => keys.trim() ? `${keys} \u3092\u62bc\u3059` : "\u30ad\u30fc\u3092\u62bc\u3059",
59
+ },
60
+ 'ko': {
61
+ autoDrag: (label, value) => `\u201c${label}\u201d\uc744(\ub97c) ${value}(\uc73c)\ub85c \ub4dc\ub798\uadf8`,
62
+ autoHover: (label) => `\u201c${label}\u201d \uc704\uc5d0 \ud3ec\uc778\ud130 \ub193\uae30`,
63
+ autoScroll: (label, value) => `\u201c${label}\u201d\uc744(\ub97c) ${value}\uae4c\uc9c0 \uc2a4\ud06c\ub864`,
64
+ autoClick: (label) => `“${label}” \ud074\ub9ad`,
65
+ autoType: (label, text) => `“${label}”\uc5d0 “${text}” \uc785\ub825`,
66
+ autoSelect: (label, text) => `“${label}”\uc5d0\uc11c “${text}” \uc120\ud0dd`,
67
+ autoCheck: (label) => `“${label}” \uccb4\ud06c`,
68
+ autoUncheck: (label) => `“${label}” \uccb4\ud06c \ud574\uc81c`,
69
+ autoSwitchOn: (label) => `“${label}” \ucf1c\uae30`,
70
+ autoSwitchOff: (label) => `“${label}” \ub044\uae30`,
71
+ autoBack: "\uc774\uc804 \ud398\uc774\uc9c0\ub85c",
72
+ autoPress: (keys) => keys.trim() ? `${keys} \ub204\ub974\uae30` : "\ud0a4 \ub204\ub974\uae30",
73
+ },
74
+ 'es': {
75
+ autoDrag: (label, value) => `Arrastra \u00ab${label}\u00bb a ${value}`,
76
+ autoHover: (label) => `Mant\u00e9n el puntero sobre \u00ab${label}\u00bb`,
77
+ autoScroll: (label, value) => `Desplaza \u00ab${label}\u00bb hasta ${value}`,
78
+ autoClick: (label) => `Haz clic en «${label}»`,
79
+ autoType: (label, text) => `Escribe «${text}» en «${label}»`,
80
+ autoSelect: (label, text) => `Elige «${text}» en «${label}»`,
81
+ autoCheck: (label) => `Marca «${label}»`,
82
+ autoUncheck: (label) => `Desmarca «${label}»`,
83
+ autoSwitchOn: (label) => `Activa «${label}»`,
84
+ autoSwitchOff: (label) => `Desactiva «${label}»`,
85
+ autoBack: "Vuelve atrás",
86
+ autoPress: (keys) => keys.trim() ? `Pulsa ${keys}` : "Pulsa una tecla",
87
+ },
88
+ 'fr': {
89
+ autoDrag: (label, value) => `Glisser \u00ab ${label} \u00bb vers ${value}`,
90
+ autoHover: (label) => `Survoler \u00ab ${label} \u00bb`,
91
+ autoScroll: (label, value) => `Faire d\u00e9filer \u00ab ${label} \u00bb jusqu\u2019\u00e0 ${value}`,
92
+ autoClick: (label) => `Cliquer sur « ${label} »`,
93
+ autoType: (label, text) => `Saisir « ${text} » dans « ${label} »`,
94
+ autoSelect: (label, text) => `Choisir « ${text} » dans « ${label} »`,
95
+ autoCheck: (label) => `Cocher « ${label} »`,
96
+ autoUncheck: (label) => `Décocher « ${label} »`,
97
+ autoSwitchOn: (label) => `Activer « ${label} »`,
98
+ autoSwitchOff: (label) => `Désactiver « ${label} »`,
99
+ autoBack: "Revenir en arrière",
100
+ autoPress: (keys) => keys.trim() ? `Appuyer sur ${keys}` : "Appuyer sur une touche",
101
+ },
102
+ 'de': {
103
+ autoDrag: (label, value) => `\u201e${label}\u201c nach ${value} ziehen`,
104
+ autoHover: (label) => `Zeiger auf \u201e${label}\u201c halten`,
105
+ autoScroll: (label, value) => `\u201e${label}\u201c bis ${value} scrollen`,
106
+ autoClick: (label) => `„${label}“ anklicken`,
107
+ autoType: (label, text) => `„${text}“ in „${label}“ eingeben`,
108
+ autoSelect: (label, text) => `„${text}“ in „${label}“ wählen`,
109
+ autoCheck: (label) => `„${label}“ aktivieren`,
110
+ autoUncheck: (label) => `„${label}“ deaktivieren`,
111
+ autoSwitchOn: (label) => `„${label}“ einschalten`,
112
+ autoSwitchOff: (label) => `„${label}“ ausschalten`,
113
+ autoBack: "Zurückgehen",
114
+ autoPress: (keys) => keys.trim() ? `${keys} drücken` : "Taste drücken",
115
+ },
116
+ 'pt-BR': {
117
+ autoDrag: (label, value) => `Arraste \u201c${label}\u201d para ${value}`,
118
+ autoHover: (label) => `Mantenha o cursor sobre \u201c${label}\u201d`,
119
+ autoScroll: (label, value) => `Role \u201c${label}\u201d at\u00e9 ${value}`,
120
+ autoClick: (label) => `Clique em “${label}”`,
121
+ autoType: (label, text) => `Digite “${text}” em “${label}”`,
122
+ autoSelect: (label, text) => `Selecione “${text}” em “${label}”`,
123
+ autoCheck: (label) => `Marque “${label}”`,
124
+ autoUncheck: (label) => `Desmarque “${label}”`,
125
+ autoSwitchOn: (label) => `Ative “${label}”`,
126
+ autoSwitchOff: (label) => `Desative “${label}”`,
127
+ autoBack: "Volte",
128
+ autoPress: (keys) => keys.trim() ? `Pressione ${keys}` : "Pressione uma tecla",
129
+ },
130
+ 'ru': {
131
+ autoDrag: (label, value) => `\u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u044c \u00ab${label}\u00bb \u043a ${value}`,
132
+ autoHover: (label) => `\u041d\u0430\u0432\u0435\u0441\u0442\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u00ab${label}\u00bb`,
133
+ autoScroll: (label, value) => `\u041f\u0440\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u00ab${label}\u00bb \u0434\u043e ${value}`,
134
+ autoClick: (label) => `Нажать «${label}»`,
135
+ autoType: (label, text) => `Ввести «${text}» в «${label}»`,
136
+ autoSelect: (label, text) => `Выбрать «${text}» в «${label}»`,
137
+ autoCheck: (label) => `Отметить «${label}»`,
138
+ autoUncheck: (label) => `Снять отметку «${label}»`,
139
+ autoSwitchOn: (label) => `Включить «${label}»`,
140
+ autoSwitchOff: (label) => `Выключить «${label}»`,
141
+ autoBack: "Вернуться назад",
142
+ autoPress: (keys) => keys.trim() ? `Нажать ${keys}` : "Нажать клавишу",
143
+ },
144
+ };
145
+ /** 字典保持原来的 player.auto* 键及延迟翻译接口。 */
146
+ export const autoCaptionMessages = (locale) => messages[locale];
147
+ /** 按当前参数与语言还原实际字幕;未知语言无法证明缓存有效,返回 null。 */
148
+ export function automaticCaption(auto, locale) {
149
+ if (!isContentLocale(locale))
150
+ return null;
151
+ const t = autoCaptionMessages(locale);
152
+ switch (auto.kind) {
153
+ case 'drag': return t.autoDrag(auto.label, auto.value ?? '');
154
+ case 'hover': return t.autoHover(auto.label);
155
+ case 'scroll': return t.autoScroll(auto.label, auto.value ?? '');
156
+ case 'click': return t.autoClick(auto.label);
157
+ case 'type': return t.autoType(auto.label, auto.value ?? '');
158
+ case 'select': return t.autoSelect(auto.label, auto.value ?? '');
159
+ case 'check': return t.autoCheck(auto.label);
160
+ case 'uncheck': return t.autoUncheck(auto.label);
161
+ case 'switch_on': return t.autoSwitchOn(auto.label);
162
+ case 'switch_off': return t.autoSwitchOff(auto.label);
163
+ case 'back': return t.autoBack;
164
+ case 'press': return t.autoPress(auto.keys ?? '');
165
+ }
166
+ }