@joplo-app/core 0.2.18 → 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.
- package/dist/actions.d.ts +6 -0
- package/dist/actions.js +34 -0
- package/dist/agent-skill.d.ts +9 -15
- package/dist/agent-skill.js +41 -44
- package/dist/auto-caption.d.ts +3 -0
- package/dist/auto-caption.js +33 -0
- package/dist/catalog.d.ts +39 -42
- package/dist/catalog.js +27 -329
- package/dist/compile.d.ts +2 -8
- package/dist/compile.js +225 -393
- package/dist/content-i18n.js +27 -16
- package/dist/feature-diff.d.ts +9 -9
- package/dist/feature-diff.js +28 -6
- package/dist/focus.d.ts +3 -1
- package/dist/focus.js +16 -34
- package/dist/guide.d.ts +10 -12
- package/dist/guide.js +363 -591
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/media.d.ts +10 -0
- package/dist/media.js +43 -0
- package/dist/node.d.ts +1 -2
- package/dist/node.js +1 -2
- package/dist/outline.js +1 -1
- package/dist/pace.d.ts +4 -1
- package/dist/pace.js +7 -3
- package/dist/player.d.ts +8 -41
- package/dist/player.js +83 -147
- package/dist/playground.d.ts +38 -0
- package/dist/playground.js +111 -0
- package/dist/plugin-data.d.ts +11 -0
- package/dist/plugin-data.js +96 -0
- package/dist/plugins/compiler.d.ts +66 -0
- package/dist/plugins/compiler.js +428 -0
- package/dist/plugins/data.d.ts +12 -0
- package/dist/plugins/data.js +120 -0
- package/dist/result.d.ts +1 -1
- package/dist/result.js +1 -0
- package/dist/runtime.d.ts +22 -0
- package/dist/runtime.js +18 -0
- package/dist/schema.d.ts +590 -112
- package/dist/schema.js +60 -52
- package/dist/scope.js +14 -5
- package/dist/step-identity.d.ts +1 -1
- package/dist/step-identity.js +1 -1
- package/dist/themes.d.ts +7 -0
- package/dist/themes.js +5 -0
- package/dist/traits.d.ts +7 -0
- package/dist/traits.js +26 -0
- package/dist/validate.js +17 -4
- package/package.json +7 -4
- package/dist/diagram/elk.d.ts +0 -6
- package/dist/diagram/elk.js +0 -56
- package/dist/diagram/graph-layout.d.ts +0 -123
- package/dist/diagram/graph-layout.js +0 -620
- package/dist/diagram/index.d.ts +0 -41
- package/dist/diagram/index.js +0 -92
- package/dist/diagram/model.d.ts +0 -217
- package/dist/diagram/model.js +0 -189
- package/dist/diagram/sequence-layout.d.ts +0 -12
- package/dist/diagram/sequence-layout.js +0 -185
package/dist/catalog.js
CHANGED
|
@@ -1,324 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const STRUCTURE = [
|
|
14
|
-
// 布局
|
|
15
|
-
'AppShell', 'AppShell.Header', 'AppShell.Navbar', 'AppShell.Main', 'AppShell.Aside', 'AppShell.Footer',
|
|
16
|
-
'Container', 'Stack', 'Group', 'Flex', 'Grid', 'Grid.Col', 'SimpleGrid', 'Center', 'Box', 'Space',
|
|
17
|
-
'Paper', 'Card', 'Card.Section', 'Divider', 'ScrollArea',
|
|
18
|
-
// 文字与展示
|
|
19
|
-
'Title', 'Text', 'Code', 'Kbd', 'Blockquote', 'List', 'List.Item', 'Badge', 'Avatar', 'Image', 'ThemeIcon', 'Indicator',
|
|
20
|
-
'Timeline', 'Timeline.Item',
|
|
21
|
-
'Table', 'Table.Thead', 'Table.Tbody', 'Table.Tr', 'Table.Th', 'Table.Td', 'DataTable',
|
|
22
|
-
'Accordion', 'Accordion.Item', 'Accordion.Panel',
|
|
23
|
-
'Radio',
|
|
24
|
-
// 导航
|
|
25
|
-
'Tabs.List', 'Tabs.Panel', 'Breadcrumbs', 'Stepper', 'Stepper.Step',
|
|
26
|
-
// 反馈与浮层
|
|
27
|
-
'Alert', 'Loader', 'Progress', 'RingProgress', 'Skeleton', 'Notification', 'Modal', 'Drawer',
|
|
28
|
-
// AI 交互(Joplo 自有)
|
|
29
|
-
'ChatMessage', 'ToolCall', 'Thinking', 'Artifact', 'Email', 'DataCard', 'StateFlow',
|
|
30
|
-
// 设备外框(Joplo 自有):终端与手机
|
|
31
|
-
'Terminal', 'Terminal.Command', 'Terminal.Output', 'Phone',
|
|
32
|
-
// 画布(Joplo 自有):讲解片与动态图形,设计尺寸等比缩放 + camera() 镜头 + motion 变形
|
|
33
|
-
'Canvas',
|
|
34
|
-
// 关系类图表(Joplo 自有,D41 / D69):布局在编译期算好;节点与连线的状态由 flow 步骤的 trace() 推算
|
|
35
|
-
'Diagram', 'Diagram.Group', 'Diagram.Node', 'Diagram.Edge',
|
|
36
|
-
'StateMachine', 'StateMachine.Group', 'StateMachine.State', 'StateMachine.Transition',
|
|
37
|
-
'Sequence', 'Sequence.Group', 'Sequence.Actor', 'Sequence.Message', 'Sequence.Block',
|
|
38
|
-
// 产品界面(D68):官网示例里反复手拼的常见界面,名字能对齐 Mantine 的就对齐(Menu、Avatar.Group、Radio.Card、BarChart、LineChart)
|
|
39
|
-
'Avatar.Group', 'Radio.Card', 'EmptyState', 'ListRow', 'Stat', 'KeyValue', 'BarChart', 'LineChart',
|
|
40
|
-
'Menu', 'Menu.Target', 'Menu.Dropdown', 'Menu.Label', 'Menu.Divider',
|
|
41
|
-
// HTML 兜底
|
|
42
|
-
...HTML,
|
|
43
|
-
// Joplo
|
|
44
|
-
'Placeholder', // props: label, h —— 图片/图表等占位
|
|
45
|
-
'Custom', // props: kind —— 逃生口:目录没有的组件,渲染为带说明的占位框
|
|
46
|
-
'#text', // 编译器生成的文本节点:props.text 为字面量或 `$ui.x` 绑定
|
|
47
|
-
];
|
|
48
|
-
/** 看起来可操作:必须有演示行为、明确禁用并说明原因,或标记 unmodeled。 */
|
|
49
|
-
const INTERACTIVE = [
|
|
50
|
-
'Button', 'ActionIcon', 'CloseButton', 'Anchor', 'a', 'NavLink', 'Burger',
|
|
51
|
-
'TextInput', 'PasswordInput', 'NumberInput', 'Textarea', 'Select', 'MultiSelect', 'Checkbox', 'Radio.Group', 'Switch',
|
|
52
|
-
'SegmentedControl', 'FileInput', 'Tabs', 'Tabs.Tab', 'Accordion.Control', 'Pagination', 'PromptInput', 'Terminal.Input',
|
|
53
|
-
'Artifact.Ref',
|
|
54
|
-
// 产品界面(D68)
|
|
55
|
-
'Menu.Item', 'TabBar',
|
|
56
|
-
];
|
|
57
|
-
export const COMPONENT_TYPES = [...STRUCTURE, ...INTERACTIVE];
|
|
58
|
-
export const INTERACTIVE_TYPES = new Set(INTERACTIVE);
|
|
59
|
-
/** 可接收输入值;type/select/toggle 动作写入 state.inputs[nodeId]。 */
|
|
60
|
-
export const VALUE_TYPES = new Set([
|
|
61
|
-
'TextInput', 'PasswordInput', 'NumberInput', 'Textarea', 'Select', 'MultiSelect', 'Checkbox', 'Radio.Group', 'Switch',
|
|
62
|
-
'SegmentedControl', 'FileInput', 'Tabs', 'Accordion', 'Pagination', 'PromptInput', 'Terminal.Input', 'TabBar',
|
|
63
|
-
]);
|
|
64
|
-
/**
|
|
65
|
-
* 只有 opened(兼容旧写法 open)为真时自身和子节点才可见的浮层。
|
|
66
|
-
* Menu.Dropdown(D68):作者把 opened 写在 Menu 上(与 Mantine 一致),编译器把它抄到菜单里的 Menu.Dropdown 上。
|
|
67
|
-
*/
|
|
68
|
-
export const GATED_CONTAINERS = new Set(['Modal', 'Drawer', 'Menu.Dropdown']);
|
|
69
|
-
/** Joplo 在 Mantine 属性之外追加的属性,编译器会从 props 中取出,放到节点字段上。 */
|
|
70
|
-
export const JOPLO_PROPS = ['id', 'when', 'disabledReason', 'unmodeled', 'note', 'redact', 'motion', 'motionDelay', 'motionMs', 'screen'];
|
|
71
|
-
/**
|
|
72
|
-
* 每个组件一行常用属性提示(`joplo skill components` 由此生成)。所有组件另外都接受:
|
|
73
|
-
* 样式属性 m/mt/mb/ml/mr/mx/my、p/pt/pb/pl/pr/px/py、w/h/miw/maw/mih/mah、c/bg/fz/fw/ta/ff/lh/opacity,
|
|
74
|
-
* 响应式写成 { base, xs, sm, md, lg, xl };visibleFrom / hiddenFrom;以及 Joplo 属性 id/when/disabled/disabledReason/unmodeled/note。
|
|
75
|
-
*/
|
|
76
|
-
export const COMPONENT_DOCS = {
|
|
77
|
-
AppShell: 'header={{ height }}, navbar={{ width, breakpoint, collapsed: { mobile, desktop } }}, aside={{ width, breakpoint, collapsed }}, footer={{ height }}, padding; navigation collapses below breakpoint and shows Burger',
|
|
78
|
-
'AppShell.Header': 'Header; p, px',
|
|
79
|
-
'AppShell.Navbar': 'Navigation sidebar; p; contains NavLink',
|
|
80
|
-
'AppShell.Main': 'Main content; contains <Outlet />',
|
|
81
|
-
'AppShell.Aside': 'Right sidebar; p',
|
|
82
|
-
'AppShell.Footer': 'Footer; p',
|
|
83
|
-
Container: 'size: xs|sm|md|lg|xl|number (default md), fluid',
|
|
84
|
-
Stack: 'gap (default md), align, justify; vertical layout',
|
|
85
|
-
Group: 'gap (default md), justify, align (default center), wrap, grow; horizontal layout',
|
|
86
|
-
Flex: 'direction, gap, rowGap, columnGap, align, justify, wrap; all responsive',
|
|
87
|
-
Grid: 'columns (default 12), gutter, justify, align, grow; Grid.Col children',
|
|
88
|
-
'Grid.Col': 'span: number|"auto"|"content"|{ base, md }, offset',
|
|
89
|
-
SimpleGrid: 'cols={{ base: 1, md: 3 }}, spacing, verticalSpacing',
|
|
90
|
-
Center: 'inline; centers content',
|
|
91
|
-
Box: 'Generic container; style props only',
|
|
92
|
-
Space: 'h, w; blank space',
|
|
93
|
-
Paper: 'p, withBorder, shadow, radius',
|
|
94
|
-
Card: 'padding (default md), withBorder, shadow, radius; Card.Section for edge-to-edge sections',
|
|
95
|
-
'Card.Section': 'withBorder, inheritPadding',
|
|
96
|
-
Divider: 'label, labelPosition: left|center|right, orientation, my',
|
|
97
|
-
ScrollArea: 'h, mah',
|
|
98
|
-
Title: 'order: 1-6; text in children',
|
|
99
|
-
Text: 'size: xs|sm|md|lg|xl, c: dimmed|red|green|…, fw, ta, truncate, lineClamp, span; preserves newlines',
|
|
100
|
-
Code: 'block (multiline code block), color',
|
|
101
|
-
Kbd: 'Keyboard key',
|
|
102
|
-
Blockquote: 'cite, color',
|
|
103
|
-
List: 'type: ordered|unordered, spacing; List.Item children',
|
|
104
|
-
'List.Item': 'List item',
|
|
105
|
-
Badge: 'color, variant: filled|light|outline|dot|default, size',
|
|
106
|
-
Avatar: 'name (shows first character), src, color, radius, size',
|
|
107
|
-
Image: 'src={asset("./photo.jpg")} (embeds a project image), alt, h, w, radius, fit: cover|contain (default cover), position (e.g. "center 20%"); other src values draw a placeholder with alt',
|
|
108
|
-
ThemeIcon: 'color, variant, size, radius; one character as child',
|
|
109
|
-
Indicator: 'label, color, disabled (hides the badge; can be a condition), processing; wraps one element with a corner badge',
|
|
110
|
-
Timeline: 'active (completed item index), bulletSize; Timeline.Item children',
|
|
111
|
-
'Timeline.Item': 'title, bullet; description in children',
|
|
112
|
-
Table: 'data={{ head: [...], body: [[...]] }} or Table.Thead/Tbody/Tr/Th/Td; striped, withTableBorder',
|
|
113
|
-
'Table.Thead': 'Table head',
|
|
114
|
-
'Table.Tbody': 'Table body',
|
|
115
|
-
'Table.Tr': 'Row',
|
|
116
|
-
'Table.Th': 'Header cell',
|
|
117
|
-
'Table.Td': 'Cell',
|
|
118
|
-
DataTable: 'records (can bind $.data.x), columns: [{ accessor, title, textAlign, width, sortable, badge: true | { value: color }, avatar: true }], sortStatus: { columnAccessor, direction: asc|desc } (arrow only; set sorted records yourself), selectedRecords (ids, checkbox column), idAccessor (default id), fetching (loading overlay), noRecordsText; matches mantine-datatable',
|
|
119
|
-
Accordion: 'value / defaultValue (expanded item); select sets the expanded item; Accordion.Item children',
|
|
120
|
-
'Accordion.Item': 'value; contains Accordion.Control and Accordion.Panel',
|
|
121
|
-
'Accordion.Panel': 'Content shown when expanded',
|
|
122
|
-
Radio: 'value, label; place inside Radio.Group',
|
|
123
|
-
'Tabs.List': 'Tab bar; contains Tabs.Tab',
|
|
124
|
-
'Tabs.Panel': 'value; current tab content',
|
|
125
|
-
Breadcrumbs: 'separator; Anchor or text children',
|
|
126
|
-
Stepper: 'active (zero-based); Stepper.Step children',
|
|
127
|
-
'Stepper.Step': 'label, description; step content in children (only current step shown)',
|
|
128
|
-
Alert: 'title, color (default blue), variant, icon (character), withCloseButton; description in children',
|
|
129
|
-
Loader: 'size, color, type; optional child text',
|
|
130
|
-
Progress: 'value 0-100, color, size, striped',
|
|
131
|
-
RingProgress: 'sections: [{ value, color }], label, size, thickness',
|
|
132
|
-
Skeleton: 'h, w, circle, radius, visible (false shows children), animate (pulse, default true)',
|
|
133
|
-
Notification: 'title, color, icon (character), loading, withCloseButton, position: top|top-left|top-right|bottom|bottom-left|bottom-right (floats over the page; show it with when); inline without position; Buttons in children (e.g. Undo)',
|
|
134
|
-
Modal: 'opened (gated, usually opened={$.ui.open}), title, size, centered, fullScreen',
|
|
135
|
-
Drawer: 'opened (gated), title, position: left|right|top|bottom (default left), size',
|
|
136
|
-
ChatMessage: "from: 'user'|'assistant', name; message content in children (preserves newlines)",
|
|
137
|
-
ToolCall: "title, state: 'running'|'done'|'error'; call details in children",
|
|
138
|
-
Email: 'from, to, subject, time; simple email card, body in children; can contain Button',
|
|
139
|
-
DataCard: 'title, value (object or state binding), fields?: [{ key, label }]; lists all keys by default; rows changed this step show old value → new value',
|
|
140
|
-
StateFlow: 'value (current state binding), states: string[], labels?: { state: name }; earlier states are completed, current state highlighted',
|
|
141
|
-
Thinking: 'title (current thought; can bind $.ui.x), active (thinking: title pulses), duration (shows "Thought for …" when finished), opened (expands the process); thinking process in children',
|
|
142
|
-
Artifact: "title, kind: 'doc'|'code'|'sheet'|'web'|'image', status: 'generating'|'ready'|'error', version; Agent artifact side panel, content in children",
|
|
143
|
-
Terminal: 'title; terminal window (CLI prototype), Terminal.Command / Terminal.Output / Terminal.Input children; scrolls internally when content exceeds h or mah',
|
|
144
|
-
Diagram: "h (height, default 420; h=\"100%\" fills a layer), direction: 'right'|'down' (omit it: chosen to fit the stage), aspect (target width/height); architecture / relationship diagram. Layout is computed at compile time (ELK layered with groups, orthogonal edges), deterministic, and identical in every step: state, when and trace never move nodes. Group nodes by business domain with Diagram.Group. Details: npx joplo skill diagram",
|
|
145
|
-
'Diagram.Group': "id (required when referenced), label, icon (preset: client|service|model|database|queue|storage|external|tool|user|cloud|gateway|lock|network|device|box|brain), tone: gray|blue|green|orange|red|purple|teal, group (parent group id, instead of nesting), pin: 'start'|'end'; nestable; edges may connect to a group; a trace through its nodes highlights it",
|
|
146
|
-
'Diagram.Node': "id (required for edges and trace), label, description (small second line), kind: 'client'|'service'|'model'|'database'|'queue'|'storage'|'external'|'tool'|'user', group (group id, instead of nesting), pin: 'start'|'end' (first / last layer within its group); optional state: 'idle'|'active'|'ok'|'error'|'dim' (omit it: trace() derives state)",
|
|
147
|
-
'Diagram.Edge': "from, to (Node or Group ids in the same Diagram), label, async (dashed), optional state; id defaults to \"from->to\". Use trace('app', 'biz') in steps (active, then ok), trace.fail(...) (error), trace.skip(...) (dim); for multiple edges in the same direction use trace('edge_id')",
|
|
148
|
-
StateMachine: "direction: 'right'|'down' (omit it: chosen to fit the stage), h, aspect, value (current state id, usually value={$.data.order.status}); lifecycle diagram with StateMachine.State / StateMachine.Transition / StateMachine.Group; the current state is highlighted and the transition taken this step lights up. Details: npx joplo skill diagram",
|
|
149
|
-
'StateMachine.Group': 'id, label, icon, tone, group; composite state box (substates inside)',
|
|
150
|
-
'StateMachine.State': 'id (required), label, description, initial (start dot points to it), final (double border), group, pin',
|
|
151
|
-
'StateMachine.Transition': "from, to (state ids), label (event [guard] / action); id defaults to \"from->to\" (\"from->to~2\" for repeats); trace('paid', 'shipped') or trace('transition_id')",
|
|
152
|
-
Sequence: 'h, numbered (default true: messages numbered in source order); sequence diagram: lifelines in source order, one row per message; trace message ids to light rows. Details: npx joplo skill diagram',
|
|
153
|
-
'Sequence.Group': 'id, label, icon; box around participant columns (business domain)',
|
|
154
|
-
'Sequence.Actor': "id (required), label, description, kind (same kinds as Diagram.Node); a participant column",
|
|
155
|
-
'Sequence.Message': "id (recommended for trace), from, to (actor ids; from === to is a self call), label, reply (dashed return), async (open arrow); rows follow source order",
|
|
156
|
-
'Sequence.Block': "label, kind: 'alt'|'opt'|'loop'|'par'|'break'|'critical' (default opt); fragment box around the messages inside it; nestable",
|
|
157
|
-
'Terminal.Command': 'prompt (default "$"); command text in children',
|
|
158
|
-
'Terminal.Output': "tone: 'plain'|'ok'|'warn'|'error' (default plain); output text in children (preserves newlines)",
|
|
159
|
-
Canvas: 'w, h (world size in design pixels, default the view), view ([width, height] design screen, default [1280, 800]), bg; a fixed-size design stage scaled to fit the layer (never re-laid out); children are placed in design pixels (style={{ position: "absolute", left, top }} or ordinary layout); move the camera with camera(…ids) in steps; elements with motion="key" fly from their old place to the new one between steps (motionDelay / motionMs per element); a direct child with screen stays fixed on screen in view coordinates (chapter labels, sources, a poster, an end card)',
|
|
160
|
-
Phone: 'scale (visual scale, default 1), h (screen height, default 844), landscape (turned sideways: content 772 × 358, notch on the left; use it for video-style or landscape mobile screens); phone frame, children laid out at mobile width 390 with breakpoints based on that width; viewport: "mobile" on a page adds it automatically; do not add Phone explicitly',
|
|
161
|
-
div: 'HTML fallback; prefer Box/Stack/Group',
|
|
162
|
-
span: 'HTML fallback; prefer Text span',
|
|
163
|
-
p: 'HTML fallback; prefer Text',
|
|
164
|
-
h1: 'HTML fallback; prefer Title order={1}',
|
|
165
|
-
h2: 'HTML fallback; prefer Title order={2}',
|
|
166
|
-
h3: 'HTML fallback; prefer Title order={3}',
|
|
167
|
-
h4: 'HTML fallback; prefer Title order={4}',
|
|
168
|
-
main: 'HTML fallback; prefer AppShell.Main',
|
|
169
|
-
section: 'HTML fallback; prefer Box',
|
|
170
|
-
header: 'HTML fallback; prefer AppShell.Header',
|
|
171
|
-
footer: 'HTML fallback; prefer AppShell.Footer',
|
|
172
|
-
nav: 'HTML fallback; prefer AppShell.Navbar',
|
|
173
|
-
aside: 'HTML fallback; prefer AppShell.Aside',
|
|
174
|
-
ul: 'HTML fallback; prefer List',
|
|
175
|
-
ol: 'HTML fallback; prefer List type="ordered"',
|
|
176
|
-
li: 'HTML fallback; prefer List.Item',
|
|
177
|
-
strong: 'HTML fallback; prefer Text fw={700} span',
|
|
178
|
-
em: 'HTML fallback; prefer Text fs="italic" span',
|
|
179
|
-
small: 'HTML fallback; prefer Text size="xs"',
|
|
180
|
-
code: 'HTML fallback; prefer Code',
|
|
181
|
-
'Avatar.Group': 'spacing (overlap, default sm); Avatar children shown as an overlapping stack',
|
|
182
|
-
'Radio.Card': 'value, label, description, leftSection (character); selectable card inside Radio.Group (select writes the group value)',
|
|
183
|
-
EmptyState: 'icon (character), title, description, withBorder, color; empty lists, 404 / expired / no-access pages, result pages; action Buttons in children',
|
|
184
|
-
ListRow: 'avatar (name) or icon (character), title, description, active, withBorder, color; list row with right-side content (Badge, Button, Text) in children; not clickable itself: use NavLink for a tappable row',
|
|
185
|
-
Stat: 'label, value, diff (e.g. "+12%", red when it starts with -), description, icon, color, progress (0-100); KPI card',
|
|
186
|
-
KeyValue: 'items: [{ label, value }] (values can bind $.data.x), total (bold last row), withDivider; order summary / details list',
|
|
187
|
-
BarChart: 'data: [{ month: "Jan", signups: 40 }] (can bind $.data.x), dataKey (x axis), series: [{ name, label?, color? }], h (default 220), unit, withLegend; low-fi bars, values animate when data changes',
|
|
188
|
-
LineChart: 'same props as BarChart; low-fi lines with points',
|
|
189
|
-
Menu: 'opened (usually opened={$.ui.menu}; dropdown shows only when true), position: bottom-start|bottom-end|top-start|top-end; Menu.Target + Menu.Dropdown children',
|
|
190
|
-
'Menu.Target': 'Wraps the trigger (ActionIcon or Button with its own id)',
|
|
191
|
-
'Menu.Dropdown': 'Menu items; visible only while the Menu is opened; floats above tables and cards',
|
|
192
|
-
'Menu.Label': 'Section label inside Menu.Dropdown',
|
|
193
|
-
'Menu.Divider': 'Divider inside Menu.Dropdown',
|
|
194
|
-
Placeholder: 'label, h; placeholder for images, charts, etc.',
|
|
195
|
-
Custom: 'kind; component absent from the catalog, rendered as a labeled placeholder box',
|
|
196
|
-
'#text': 'Compiler-generated text node (do not use directly)',
|
|
197
|
-
Button: 'variant: filled|light|outline|subtle|default|white, color, size, fullWidth, loading, leftSection / rightSection (character)',
|
|
198
|
-
ActionIcon: "Icon button: aria-label (required as name), variant, color, size; one character child such as '+'",
|
|
199
|
-
CloseButton: 'aria-label, size',
|
|
200
|
-
Anchor: 'href is display-only; clicking never navigates; use go() in the step; c, underline',
|
|
201
|
-
a: 'HTML fallback; prefer Anchor',
|
|
202
|
-
NavLink: 'label, description, href (highlighted when equal to current route), active, leftSection / rightSection (character or short text); nested NavLink allowed',
|
|
203
|
-
Burger: 'opened, aria-label; narrow-screen navigation toggle, usually with hiddenFrom="sm"',
|
|
204
|
-
TextInput: 'label, placeholder, description, error, withAsterisk, type; type action writes the value',
|
|
205
|
-
PasswordInput: 'label, placeholder, description, error; type action writes the value, shown as dots',
|
|
206
|
-
NumberInput: 'label, placeholder, min, max, suffix, prefix; type action writes the value',
|
|
207
|
-
Textarea: 'label, placeholder, description, error, minRows, autosize; type action writes the value',
|
|
208
|
-
Select: 'label, data: string[] | { value, label }[], placeholder, description; select accepts value or label',
|
|
209
|
-
MultiSelect: 'label, data, placeholder; each select toggles one option',
|
|
210
|
-
Checkbox: 'label, description, checked; toggle action writes the value',
|
|
211
|
-
'Radio.Group': 'label, value; Radio value/label children; select accepts value or label',
|
|
212
|
-
Switch: 'label, description, checked; toggle action writes the value',
|
|
213
|
-
SegmentedControl: 'data: string[] | { value, label }[], fullWidth; select accepts value or label',
|
|
214
|
-
FileInput: 'label, placeholder, accept; type action writes the filename',
|
|
215
|
-
Tabs: 'value / defaultValue; Tabs.Tab inside Tabs.List, content in Tabs.Panel; select switches tabs',
|
|
216
|
-
'Tabs.Tab': 'value, leftSection (character), rightSection (count or short text, e.g. 3)',
|
|
217
|
-
'Accordion.Control': 'Clickable heading (requires id)',
|
|
218
|
-
Pagination: 'total, value / defaultValue; select action writes the page number',
|
|
219
|
-
PromptInput: 'placeholder; AI input, type action writes the value; use ActionIcon or Button to send',
|
|
220
|
-
'Artifact.Ref': "title, kind, status; card linking to an artifact in the conversation (requires id; clickable)",
|
|
221
|
-
'Terminal.Input': 'prompt (default "$"), placeholder; terminal input line (requires id), type action writes the value',
|
|
222
|
-
'Menu.Item': 'leftSection (character), rightSection (text), color (red for destructive); clickable menu row (requires id)',
|
|
223
|
-
TabBar: 'data: string[] | [{ value, label, icon?, badge? }], value / defaultValue, aria-label; mobile bottom tab bar, select switches tabs; place it last in a full-height Stack',
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* 示例(D68,`npx joplo components <名字>` 输出):每个都能直接放进页面或层级里用;交互状态写成 $.ui / $.data 绑定,由步骤 set()。
|
|
227
|
-
* 只给最容易写错、或需要和步骤配合的组件;其余组件看 COMPONENT_DOCS 的一行提示就够。
|
|
228
|
-
*/
|
|
229
|
-
export const COMPONENT_EXAMPLES = {
|
|
230
|
-
Canvas: `// layer('World', <Canvas w={2560} h={1600}>…</Canvas>): one world for the whole explainer
|
|
231
|
-
<Canvas w={2560} h={1600}>
|
|
232
|
-
<div id="chat" style={{ position: 'absolute', left: 60, top: 60, width: 1180, height: 700 }}>…</div>
|
|
233
|
-
<div id="tape" style={{ position: 'absolute', left: 120, top: 960, display: 'flex', gap: 8 }}>
|
|
234
|
-
<span motion="tok_0" when={eq($.ui.at, 'tape')}>4912</span>
|
|
235
|
-
</div>
|
|
236
|
-
</Canvas>
|
|
237
|
-
// steps: .system('Zoom in', camera('chat')), .system('To the tape', set($.ui.at, 'tape'), camera('tape'))`,
|
|
238
|
-
EmptyState: `<EmptyState icon="✉" title="No members yet" description="Invite teammates to start working together">
|
|
239
|
-
<Button id="invite_first">Invite members</Button>
|
|
240
|
-
</EmptyState>`,
|
|
241
|
-
ListRow: `<Stack gap={0}>
|
|
242
|
-
<ListRow avatar="Ana Lee" title="Ana Lee" description="ana@example.com"><Badge color="green" variant="light">Admin</Badge></ListRow>
|
|
243
|
-
<ListRow avatar="Bo Chen" title="Bo Chen" description={$.ui.boStatus} active={$.ui.boNew}><Button id="resend" variant="subtle">Resend</Button></ListRow>
|
|
244
|
-
</Stack>`,
|
|
245
|
-
Menu: `<Menu opened={$.ui.rowMenu} position="bottom-end">
|
|
246
|
-
<Menu.Target><ActionIcon id="row_more" aria-label="More actions">⋯</ActionIcon></Menu.Target>
|
|
247
|
-
<Menu.Dropdown>
|
|
248
|
-
<Menu.Item id="copy_link" leftSection="🔗">Copy invite link</Menu.Item>
|
|
249
|
-
<Menu.Divider />
|
|
250
|
-
<Menu.Item id="revoke" color="red" leftSection="✕">Revoke invite</Menu.Item>
|
|
251
|
-
</Menu.Dropdown>
|
|
252
|
-
</Menu>
|
|
253
|
-
// steps: .click('row_more', set($.ui.rowMenu, true)).click('revoke', set($.ui.rowMenu, false), set($.ui.confirm, true))`,
|
|
254
|
-
TabBar: `<Stack h="100%" gap={0}>
|
|
255
|
-
<ScrollArea style={{ flex: 1, minHeight: 0 }}>…page…</ScrollArea>
|
|
256
|
-
<TabBar id="tabs" aria-label="Bottom navigation" data={[{ value: 'home', label: 'Home', icon: '⌂' }, { value: 'trips', label: 'Trips', icon: '⛺', badge: 2 }, { value: 'me', label: 'Me', icon: '☺' }]} />
|
|
257
|
-
</Stack>
|
|
258
|
-
// steps: .select('tabs', 'trips', go('/trips'))`,
|
|
259
|
-
Stat: `<SimpleGrid cols={3}>
|
|
260
|
-
<Stat label="Signups this week" value={$.data.signups} diff="+12%" icon="↗" />
|
|
261
|
-
<Stat label="Seats used" value="8 / 10" progress={80} description="2 seats left" />
|
|
262
|
-
<Stat label="Failed payments" value="3" diff="-2" color="red" />
|
|
263
|
-
</SimpleGrid>`,
|
|
264
|
-
KeyValue: `<KeyValue withDivider total items={[{ label: 'Seats', value: '5 × $9' }, { label: 'Tax', value: '$4.50' }, { label: 'Total', value: $.data.total }]} />`,
|
|
265
|
-
Image: `<Image src={asset('../../assets/capitol.jpg')} alt="U.S. Capitol" h={240} fit="cover" position="center 40%" radius="md" />
|
|
266
|
-
// import { asset } from '@joplo-app/kit'; the path is relative to this file. jpg/png/gif/webp/avif/svg, up to 2 MB each; compress first.
|
|
267
|
-
// The image is embedded, so the board, build and share show it offline. For a tinted or full-bleed background, use style={{ backgroundImage: \`url(\${asset('./bg.jpg')})\` }}.`,
|
|
268
|
-
BarChart: `<BarChart h={220} dataKey="week" unit="" data={$.data.weeks} series={[{ name: 'signups', label: 'Signups' }, { name: 'churn', label: 'Churn', color: 'red' }]} />
|
|
269
|
-
// state: data: { weeks: [{ week: 'W1', signups: 40, churn: 4 }, { week: 'W2', signups: 52, churn: 6 }] }; set() a new array to animate`,
|
|
270
|
-
LineChart: `<LineChart h={200} dataKey="day" data={[{ day: 'Mon', p95: 320 }, { day: 'Tue', p95: 280 }]} series={[{ name: 'p95', label: 'p95 latency' }]} unit="ms" />`,
|
|
271
|
-
DataTable: `<DataTable idAccessor="id" records={$.data.members} selectedRecords={$.ui.selected} fetching={$.ui.loading}
|
|
272
|
-
sortStatus={{ columnAccessor: 'joined', direction: 'desc' }}
|
|
273
|
-
columns={[{ accessor: 'name', title: 'Name', avatar: true }, { accessor: 'status', title: 'Status', badge: { Active: 'green', Pending: 'yellow', Expired: 'gray' } }, { accessor: 'joined', title: 'Joined', sortable: true }]} />`,
|
|
274
|
-
Notification: `<Notification when={$.ui.deleted} position="bottom" title="Invite revoked" icon="↺" withCloseButton={false}>
|
|
275
|
-
<Group justify="space-between">Ana can no longer join<Button id="undo" variant="subtle" size="xs">Undo</Button></Group>
|
|
276
|
-
</Notification>`,
|
|
277
|
-
'Radio.Card': `<Radio.Group id="plan" label="Plan">
|
|
278
|
-
<Stack gap="xs">
|
|
279
|
-
<Radio.Card value="team" label="Team" description="Up to 10 seats" leftSection="👥" />
|
|
280
|
-
<Radio.Card value="pro" label="Pro" description="Unlimited seats" leftSection="★" />
|
|
281
|
-
</Stack>
|
|
282
|
-
</Radio.Group>
|
|
283
|
-
// steps: .select('plan', 'pro')`,
|
|
284
|
-
'Avatar.Group': `<Avatar.Group><Avatar name="Ana Lee" /><Avatar name="Bo Chen" /><Avatar name="+3" /></Avatar.Group>`,
|
|
285
|
-
// 关系类图表(D69):npx joplo components Diagram / Sequence / StateMachine 也给一个能直接用的例子;分组、布局、取景的细节在 npx joplo skill diagram
|
|
286
|
-
Diagram: `<Diagram id="arch" direction="right" h={420}>
|
|
287
|
-
<Diagram.Group id="g_gw" label="Gateway" icon="gateway" tone="blue">
|
|
288
|
-
<Diagram.Node id="api" label="API" description="auth · rate limit" />
|
|
289
|
-
</Diagram.Group>
|
|
290
|
-
<Diagram.Group id="g_run" label="Runtime" icon="service" tone="purple">
|
|
291
|
-
<Diagram.Node id="kernel" label="Kernel" description="model + tool loop" />
|
|
292
|
-
</Diagram.Group>
|
|
293
|
-
<Diagram.Group id="g_data" label="Storage" icon="database">
|
|
294
|
-
<Diagram.Node id="pg" label="PostgreSQL" kind="database" />
|
|
295
|
-
</Diagram.Group>
|
|
296
|
-
<Diagram.Edge from="api" to="kernel" label="run" />
|
|
297
|
-
<Diagram.Edge from="kernel" to="pg" label="commit" async />
|
|
298
|
-
</Diagram>
|
|
299
|
-
// steps: .system('Run starts', trace('api', 'kernel', 'pg'), shot('kernel')); groups, layout, framing: npx joplo skill diagram`,
|
|
300
|
-
Sequence: `<Sequence id="login">
|
|
301
|
-
<Sequence.Actor id="web" label="Web" kind="client" />
|
|
302
|
-
<Sequence.Actor id="api" label="API" />
|
|
303
|
-
<Sequence.Actor id="db" label="DB" kind="database" />
|
|
304
|
-
<Sequence.Message id="m_req" from="web" to="api" label="POST /login" />
|
|
305
|
-
<Sequence.Message id="m_q" from="api" to="db" label="find user" />
|
|
306
|
-
<Sequence.Message id="m_ok" from="api" to="web" label="200 + session" reply />
|
|
307
|
-
</Sequence>
|
|
308
|
-
// steps: .system('Sign in', trace('m_req')).system('Look up the user', trace('m_q'))`,
|
|
309
|
-
StateMachine: `<StateMachine id="order_sm" value={$.data.order.status}>
|
|
310
|
-
<StateMachine.State id="created" label="Created" initial />
|
|
311
|
-
<StateMachine.State id="paid" label="Paid" />
|
|
312
|
-
<StateMachine.State id="closed" label="Closed" final />
|
|
313
|
-
<StateMachine.Transition from="created" to="paid" label="pay" />
|
|
314
|
-
<StateMachine.Transition from="created" to="closed" label="timeout 30 min" />
|
|
315
|
-
</StateMachine>
|
|
316
|
-
// steps: .system('Payment received', set($.data.order.status, 'paid')) lights created → paid`,
|
|
317
|
-
Modal: `<Modal id="confirm" opened={$.ui.confirm} title="Revoke this invite?" size="sm">
|
|
318
|
-
<Text>Ana's link stops working right away. You can invite her again later.</Text>
|
|
319
|
-
<Group justify="flex-end"><Button id="cancel_revoke" variant="default">Cancel</Button><Button id="do_revoke" color="red">Revoke</Button></Group>
|
|
320
|
-
</Modal>`,
|
|
1
|
+
export const COMPONENT_TYPES = ['Custom', '#text', '#fragment'];
|
|
2
|
+
export const JOPLO_PROPS = ['id', 'when', 'disabledReason', 'unmodeled', 'note', 'redact'];
|
|
3
|
+
// ---------- 插件组件(D86)----------
|
|
4
|
+
/** 插件组件的类型名:`<插件 id>:<组件名>`(例如 scene3d:Target)。目录组件的名字里没有冒号。 */
|
|
5
|
+
export const PLUGIN_TYPE = /^[a-z][a-z0-9-]*:[A-Za-z][A-Za-z0-9]*(\.[A-Za-z][A-Za-z0-9]*)*$/;
|
|
6
|
+
export const isPluginType = (type) => PLUGIN_TYPE.test(type);
|
|
7
|
+
/** 插件 id 与组件名:scene3d:Scene.Part → { plugin: 'scene3d', name: 'Scene.Part' }。 */
|
|
8
|
+
export const splitPluginType = (type) => {
|
|
9
|
+
if (!isPluginType(type))
|
|
10
|
+
return null;
|
|
11
|
+
const i = type.indexOf(':');
|
|
12
|
+
return { plugin: type.slice(0, i), name: type.slice(i + 1) };
|
|
321
13
|
};
|
|
14
|
+
/** 插件组件的声明;不是插件类型或插件没启用时为 null。 */
|
|
15
|
+
export function pluginSpec(plugins, type) {
|
|
16
|
+
const t = splitPluginType(type);
|
|
17
|
+
return (t && plugins?.[t.plugin]?.components[t.name]) || null;
|
|
18
|
+
}
|
|
19
|
+
/** 可操作的类型:声明了 interactive 的插件组件。 */
|
|
20
|
+
export function isInteractiveType(type, plugins) {
|
|
21
|
+
return pluginSpec(plugins, type)?.interactive === true;
|
|
22
|
+
}
|
|
322
23
|
// ---------- 响应式(Mantine 默认断点,按舞台宽度取值) ----------
|
|
323
24
|
/** Mantine 默认断点:36/48/62/75/88em,按 16px 换算。 */
|
|
324
25
|
export const BREAKPOINTS = { xs: 576, sm: 768, md: 992, lg: 1200, xl: 1408 };
|
|
@@ -373,15 +74,12 @@ export const SCENARIO_MS_MAX = 90_000;
|
|
|
373
74
|
export const PAGE_LAYER = '@page';
|
|
374
75
|
/** shot()(不带 id)在有层级的方案里:作用于“当时导演所在的层”,让它回到整体。 */
|
|
375
76
|
export const DIRECTOR_LAYER = '@director';
|
|
376
|
-
/**
|
|
377
|
-
export
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
/** 子节点排版用的宽度:Phone 内部按手机宽度(横放按横屏宽度;响应式取值、visibleFrom / hiddenFrom、AppShell 收起都按它算),其余节点沿用外部宽度。 */
|
|
381
|
-
export function childWidth(type, width, props) {
|
|
382
|
-
if (type !== 'Phone')
|
|
77
|
+
/** Child viewport width is declared by the plugin, never inferred from a type name. */
|
|
78
|
+
export function childWidth(node, width, props) {
|
|
79
|
+
const spec = node.traits?.childWidth;
|
|
80
|
+
if (!spec)
|
|
383
81
|
return width;
|
|
384
|
-
return props?.
|
|
82
|
+
return spec.when && props?.[spec.when.prop] === spec.when.value ? spec.when.width : spec.value;
|
|
385
83
|
}
|
|
386
84
|
/** 是否为响应式对象 `{ base, sm, md }`:普通对象,至少一个键,且全部键都是断点名。 */
|
|
387
85
|
export function isResponsive(v) {
|
|
@@ -462,7 +160,7 @@ export function nodeLabel(node) {
|
|
|
462
160
|
return v;
|
|
463
161
|
}
|
|
464
162
|
// 没有 label 的连线 / 转换 / 消息:「from → to」
|
|
465
|
-
if (
|
|
163
|
+
if (typeof p.from === 'string' && typeof p.to === 'string')
|
|
466
164
|
return `${p.from} → ${p.to}`;
|
|
467
165
|
const text = collectText(node).trim();
|
|
468
166
|
return text || node.type;
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ConfigDef, FeatureDef, LayoutDef, OptionDef, PageDef } from '@joplo-app/kit';
|
|
2
2
|
import { Project } from './schema.js';
|
|
3
3
|
import type { Diagnostic } from './result.js';
|
|
4
|
-
import { type
|
|
4
|
+
import { type CompileOptions } from './plugins/compiler.js';
|
|
5
|
+
export type { CompileOptions } from './plugins/compiler.js';
|
|
5
6
|
export type AuthoringProject = {
|
|
6
7
|
/** 项目根目录绝对路径,用于把源位置改成相对路径。 */
|
|
7
8
|
root: string;
|
|
@@ -33,13 +34,6 @@ export type CompileResult = {
|
|
|
33
34
|
diagnostics: Diagnostic[];
|
|
34
35
|
};
|
|
35
36
|
export type CompileMode = 'dev' | 'publish' | 'review';
|
|
36
|
-
export type CompileOptions = {
|
|
37
|
-
/**
|
|
38
|
-
* 图表布局引擎(D69):Node 端传 `elkLayout`(@joplo-app/core/node)。不传时图表退化为网格排列(engine = 'grid'),
|
|
39
|
-
* 只用于测试或不关心布局的调用方;dev、build、check 都传 ELK。
|
|
40
|
-
*/
|
|
41
|
-
layout?: GraphLayoutEngine;
|
|
42
|
-
};
|
|
43
37
|
export declare function compile(src: AuthoringProject, mode: CompileMode, opts?: CompileOptions): CompileResult;
|
|
44
38
|
/** 角色的颜色(D56):没写 color 时按声明顺序取。 */
|
|
45
39
|
export declare const ROLE_COLORS: readonly ["#E8590C", "#1971C2", "#2F9E44", "#9C36B5", "#C2255C", "#0C8599"];
|