opencode-skills-collection 4.0.69 → 4.0.70
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/bundled-skills/.antigravity-install-manifest.json +39 -1
- package/bundled-skills/api-integration-architect/SKILL.md +241 -0
- package/bundled-skills/apify-generate-output-schema/SKILL.md +438 -0
- package/bundled-skills/apify-integration-development/SKILL.md +168 -0
- package/bundled-skills/apify-integration-development/references/ai-framework-package.md +158 -0
- package/bundled-skills/apify-integration-development/references/ai-harness-plugin.md +192 -0
- package/bundled-skills/apify-integration-development/references/sdk-integration.md +236 -0
- package/bundled-skills/apify-integration-development/references/workflow-automation.md +163 -0
- package/bundled-skills/architecture-review/README.md +42 -0
- package/bundled-skills/architecture-review/SKILL.md +77 -0
- package/bundled-skills/architecture-review/examples.md +11 -0
- package/bundled-skills/architecture-review/reference/best-practices.md +7 -0
- package/bundled-skills/architecture-review/reference/capabilities.md +20 -0
- package/bundled-skills/architecture-review/reference/fallbacks.md +11 -0
- package/bundled-skills/architecture-review/reference/graph.md +15 -0
- package/bundled-skills/architecture-review/reference/mcp.md +14 -0
- package/bundled-skills/architecture-review/reference/workflow.md +15 -0
- package/bundled-skills/architecture-review/templates/architecture-review.md +21 -0
- package/bundled-skills/code-review-sensei/SKILL.md +177 -0
- package/bundled-skills/codebase-onboarding/README.md +42 -0
- package/bundled-skills/codebase-onboarding/SKILL.md +77 -0
- package/bundled-skills/codebase-onboarding/examples.md +11 -0
- package/bundled-skills/codebase-onboarding/reference/best-practices.md +7 -0
- package/bundled-skills/codebase-onboarding/reference/capabilities.md +20 -0
- package/bundled-skills/codebase-onboarding/reference/fallbacks.md +11 -0
- package/bundled-skills/codebase-onboarding/reference/graph.md +15 -0
- package/bundled-skills/codebase-onboarding/reference/mcp.md +14 -0
- package/bundled-skills/codebase-onboarding/reference/workflow.md +15 -0
- package/bundled-skills/codebase-onboarding/templates/repository-onboarding.md +21 -0
- package/bundled-skills/connection-auth-rules/SKILL.md +199 -0
- package/bundled-skills/connection-auth-rules/fetch_schema.py +320 -0
- package/bundled-skills/dependency-analysis/README.md +42 -0
- package/bundled-skills/dependency-analysis/SKILL.md +76 -0
- package/bundled-skills/dependency-analysis/examples.md +11 -0
- package/bundled-skills/dependency-analysis/reference/best-practices.md +7 -0
- package/bundled-skills/dependency-analysis/reference/capabilities.md +20 -0
- package/bundled-skills/dependency-analysis/reference/fallbacks.md +11 -0
- package/bundled-skills/dependency-analysis/reference/graph.md +15 -0
- package/bundled-skills/dependency-analysis/reference/mcp.md +14 -0
- package/bundled-skills/dependency-analysis/reference/workflow.md +15 -0
- package/bundled-skills/dependency-analysis/templates/dependency-review.md +21 -0
- package/bundled-skills/devops-pipeline-builder/SKILL.md +200 -0
- package/bundled-skills/eas-app-stores/SKILL.md +197 -0
- package/bundled-skills/eas-app-stores/agents/openai.yaml +4 -0
- package/bundled-skills/eas-app-stores/references/app-store-metadata.md +497 -0
- package/bundled-skills/eas-app-stores/references/ios-app-store.md +376 -0
- package/bundled-skills/eas-app-stores/references/native-ios.md +167 -0
- package/bundled-skills/eas-app-stores/references/play-store.md +244 -0
- package/bundled-skills/eas-app-stores/references/testflight.md +62 -0
- package/bundled-skills/eas-app-stores/references/workflows.md +120 -0
- package/bundled-skills/eas-hosting/SKILL.md +448 -0
- package/bundled-skills/eas-hosting/agents/openai.yaml +4 -0
- package/bundled-skills/eas-observe/SKILL.md +75 -0
- package/bundled-skills/eas-observe/agents/openai.yaml +4 -0
- package/bundled-skills/eas-observe/references/metrics.md +98 -0
- package/bundled-skills/eas-observe/references/queries.md +403 -0
- package/bundled-skills/eas-observe/references/setup.md +476 -0
- package/bundled-skills/eas-observe/references/third-party.md +136 -0
- package/bundled-skills/eas-simulator/SKILL.md +251 -0
- package/bundled-skills/eas-simulator/agents/openai.yaml +4 -0
- package/bundled-skills/eas-simulator/references/controllers.md +135 -0
- package/bundled-skills/eas-simulator/references/run-your-app.md +240 -0
- package/bundled-skills/eas-simulator/references/troubleshooting.md +47 -0
- package/bundled-skills/eas-workflows/SKILL.md +119 -0
- package/bundled-skills/eas-workflows/agents/openai.yaml +4 -0
- package/bundled-skills/eas-workflows/scripts/fetch.js +109 -0
- package/bundled-skills/expo-animation/LICENSE +21 -0
- package/bundled-skills/expo-animation/RECIPES.md +385 -0
- package/bundled-skills/expo-animation/SKILL.md +295 -0
- package/bundled-skills/expo-animation/agents/openai.yaml +4 -0
- package/bundled-skills/fact-check-x-unified/SKILL.md +178 -0
- package/bundled-skills/fact-check-x-unified/agents/openai.yaml +4 -0
- package/bundled-skills/fact-check-x-unified/references/acceptance-criteria.md +44 -0
- package/bundled-skills/fact-check-x-unified/references/contracts.md +39 -0
- package/bundled-skills/fact-check-x-unified/scripts/common.py +31 -0
- package/bundled-skills/fact-check-x-unified/scripts/fact_check_x.py +1832 -0
- package/bundled-skills/fact-check-x-unified/scripts/trusted_search_config.py +324 -0
- package/bundled-skills/fact-check-x-unified/tests/anchor_downgrade_test.py +90 -0
- package/bundled-skills/fact-check-x-unified/tests/multi_platform_test.py +369 -0
- package/bundled-skills/fact-check-x-unified/tests/smoke_test.py +740 -0
- package/bundled-skills/fact-check-x-unified/tests/stage_checkpoint_test.py +103 -0
- package/bundled-skills/fact-check-x-unified/tests/trusted_search_config_test.py +156 -0
- package/bundled-skills/gpt-taste/SKILL.md +8 -1
- package/bundled-skills/hf-cli/SKILL.md +263 -0
- package/bundled-skills/huggingface-community-evals/SKILL.md +228 -0
- package/bundled-skills/huggingface-community-evals/examples/.env.example +3 -0
- package/bundled-skills/huggingface-community-evals/examples/USAGE_EXAMPLES.md +101 -0
- package/bundled-skills/huggingface-community-evals/scripts/inspect_eval_uv.py +104 -0
- package/bundled-skills/huggingface-community-evals/scripts/inspect_vllm_uv.py +306 -0
- package/bundled-skills/huggingface-community-evals/scripts/lighteval_vllm_uv.py +297 -0
- package/bundled-skills/huggingface-datasets/SKILL.md +130 -0
- package/bundled-skills/jev-social/SKILL.md +182 -0
- package/bundled-skills/longbridge-derivatives/SKILL.md +117 -0
- package/bundled-skills/longbridge-derivatives/references/option.md +36 -0
- package/bundled-skills/longbridge-derivatives/references/options-advanced.md +101 -0
- package/bundled-skills/longbridge-derivatives/references/options-pnl.md +74 -0
- package/bundled-skills/longbridge-derivatives/references/options-strategy.md +82 -0
- package/bundled-skills/longbridge-derivatives/references/options-volatility.md +70 -0
- package/bundled-skills/longbridge-derivatives/references/warrant.md +12 -0
- package/bundled-skills/longbridge-quant/SKILL.md +151 -0
- package/bundled-skills/longbridge-quant/references/correlation.md +51 -0
- package/bundled-skills/longbridge-quant/references/execution-model.md +68 -0
- package/bundled-skills/longbridge-quant/references/factor-research.md +95 -0
- package/bundled-skills/longbridge-quant/references/factor-screen.md +101 -0
- package/bundled-skills/longbridge-quant/references/hedging.md +136 -0
- package/bundled-skills/longbridge-quant/references/ml-strategy.md +77 -0
- package/bundled-skills/longbridge-quant/references/multifactor.md +68 -0
- package/bundled-skills/longbridge-quant/references/pairs-trading.md +61 -0
- package/bundled-skills/longbridge-quant/references/quant-cli.md +133 -0
- package/bundled-skills/longbridge-quant/references/quant-stats.md +150 -0
- package/bundled-skills/longbridge-quant/references/seasonality.md +50 -0
- package/bundled-skills/longbridge-quant/references/strategy-optimizer.md +68 -0
- package/bundled-skills/longbridge-quant/references/volatility-strategy.md +52 -0
- package/bundled-skills/longbridge-research/SKILL.md +187 -0
- package/bundled-skills/longbridge-research/references/company-profile.md +96 -0
- package/bundled-skills/longbridge-research/references/company-tearsheet.md +82 -0
- package/bundled-skills/longbridge-research/references/competitive-analysis.md +81 -0
- package/bundled-skills/longbridge-research/references/consensus.md +92 -0
- package/bundled-skills/longbridge-research/references/coverage-initiation.md +76 -0
- package/bundled-skills/longbridge-research/references/defi-yield.md +60 -0
- package/bundled-skills/longbridge-research/references/finance-calendar.md +165 -0
- package/bundled-skills/longbridge-research/references/financial-planning.md +77 -0
- package/bundled-skills/longbridge-research/references/forecast-eps.md +39 -0
- package/bundled-skills/longbridge-research/references/fund-holder.md +44 -0
- package/bundled-skills/longbridge-research/references/hkipo-analysis.md +101 -0
- package/bundled-skills/longbridge-research/references/industry-peers.md +46 -0
- package/bundled-skills/longbridge-research/references/industry-rank.md +62 -0
- package/bundled-skills/longbridge-research/references/insider-trades.md +48 -0
- package/bundled-skills/longbridge-research/references/institution-rating.md +62 -0
- package/bundled-skills/longbridge-research/references/investment-ideas.md +69 -0
- package/bundled-skills/longbridge-research/references/investment-proposal.md +95 -0
- package/bundled-skills/longbridge-research/references/investors.md +87 -0
- package/bundled-skills/longbridge-research/references/onchain.md +70 -0
- package/bundled-skills/longbridge-research/references/post-investment.md +76 -0
- package/bundled-skills/longbridge-research/references/shareholder.md +72 -0
- package/bundled-skills/longbridge-research/references/short-positions.md +50 -0
- package/bundled-skills/longbridge-research/references/short-trades.md +50 -0
- package/bundled-skills/longbridge-research/references/stock-research.md +61 -0
- package/bundled-skills/longbridge-research/references/thesis-tracker.md +64 -0
- package/bundled-skills/makepad-2-0-animation/SKILL.md +318 -0
- package/bundled-skills/makepad-2-0-animation/references/animator-reference.md +433 -0
- package/bundled-skills/makepad-2-0-dsl/SKILL.md +492 -0
- package/bundled-skills/makepad-2-0-dsl/references/dsl-syntax-reference.md +511 -0
- package/bundled-skills/makepad-2-0-dsl/references/extended-guide.md +56 -0
- package/bundled-skills/makepad-2-0-dsl/references/property-system.md +757 -0
- package/bundled-skills/makepad-2-0-events/SKILL.md +497 -0
- package/bundled-skills/makepad-2-0-events/references/event-patterns.md +802 -0
- package/bundled-skills/makepad-2-0-events/references/extended-guide.md +590 -0
- package/bundled-skills/makepad-2-0-layout/SKILL.md +499 -0
- package/bundled-skills/makepad-2-0-layout/references/extended-guide.md +243 -0
- package/bundled-skills/makepad-2-0-layout/references/layout-patterns.md +881 -0
- package/bundled-skills/makepad-2-0-widgets/SKILL.md +261 -0
- package/bundled-skills/makepad-2-0-widgets/references/widget-advanced.md +648 -0
- package/bundled-skills/makepad-2-0-widgets/references/widget-catalog.md +547 -0
- package/bundled-skills/meeting-distiller-pro/SKILL.md +120 -0
- package/bundled-skills/monte-carlo-analyze-root-cause/SKILL.md +12 -1
- package/bundled-skills/monte-carlo-asset-health/SKILL.md +12 -1
- package/bundled-skills/monte-carlo-context-detection/SKILL.md +170 -0
- package/bundled-skills/monte-carlo-context-detection/references/signal-definitions.md +46 -0
- package/bundled-skills/remotion-captions/SKILL.md +57 -0
- package/bundled-skills/remotion-captions/agents/openai.yaml +7 -0
- package/bundled-skills/remotion-captions/assets/remotion-icon.svg +4 -0
- package/bundled-skills/remotion-captions/display-captions.md +190 -0
- package/bundled-skills/remotion-captions/import-srt-captions.md +73 -0
- package/bundled-skills/remotion-captions/transcribe-captions.md +70 -0
- package/bundled-skills/remotion-create/SKILL.md +106 -0
- package/bundled-skills/remotion-create/agents/openai.yaml +7 -0
- package/bundled-skills/remotion-create/assets/remotion-icon.svg +4 -0
- package/bundled-skills/remotion-create/tailwind.md +11 -0
- package/bundled-skills/remotion-create/video-layout.md +9 -0
- package/bundled-skills/remotion-docs/SKILL.md +67 -0
- package/bundled-skills/remotion-docs/agents/openai.yaml +7 -0
- package/bundled-skills/remotion-docs/assets/remotion-icon.svg +4 -0
- package/bundled-skills/remotion-interactivity/SKILL.md +270 -0
- package/bundled-skills/remotion-interactivity/agents/openai.yaml +7 -0
- package/bundled-skills/remotion-interactivity/assets/remotion-icon.svg +4 -0
- package/bundled-skills/remotion-render/SKILL.md +48 -0
- package/bundled-skills/remotion-render/agents/openai.yaml +7 -0
- package/bundled-skills/remotion-render/assets/remotion-icon.svg +4 -0
- package/bundled-skills/remotion-render/transparent-videos.md +106 -0
- package/bundled-skills/saas-pricing-strategist/SKILL.md +169 -0
- package/bundled-skills/score-eval/SKILL.md +35 -0
- package/bundled-skills/writing-guidelines/SKILL.md +60 -0
- package/package.json +1 -1
- package/skills_index.json +980 -3
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: makepad-2-0-dsl
|
|
3
|
+
description: Makepad 2.0 guidance for dsl; use when building or debugging Makepad UI code.
|
|
4
|
+
source_repo: zhanghandong/makepad-skills
|
|
5
|
+
source_type: community
|
|
6
|
+
source: community
|
|
7
|
+
date_added: '2026-09-21'
|
|
8
|
+
risk: unknown
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Limitations
|
|
12
|
+
|
|
13
|
+
- Verify against current Makepad 2.0 docs; upstream APIs change frequently.
|
|
14
|
+
- Do not run bundled scripts without explicit user approval.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
- Use when this upstream workflow matches the user's stated goal.
|
|
18
|
+
- Use when the task requires the procedures documented in this skill.
|
|
19
|
+
|
|
20
|
+
# Makepad 2.0 DSL Syntax Skill
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
Makepad 2.0 replaced the compile-time `live_design!` macro with the runtime `script_mod!` macro, powered by the Splash scripting language. This skill covers the complete DSL syntax, property system, registration patterns, and common pitfalls.
|
|
25
|
+
|
|
26
|
+
## Key Syntax Rules
|
|
27
|
+
|
|
28
|
+
### Property Assignment: Colon, NOT Equals
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
key: value // CORRECT - colon syntax
|
|
32
|
+
key = value // WRONG - old 1.x syntax, no longer works
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Properties are whitespace/newline separated. No commas between siblings.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
View{
|
|
39
|
+
width: Fill
|
|
40
|
+
height: Fit
|
|
41
|
+
flow: Down
|
|
42
|
+
spacing: 10
|
|
43
|
+
padding: 15
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Named Instances: `:=` Operator
|
|
48
|
+
|
|
49
|
+
Use `:=` to create addressable, named widget instances:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
my_button := Button{ text: "Click me" }
|
|
53
|
+
title := Label{ text: "Hello" }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Named instances are:
|
|
57
|
+
- Addressable from Rust code via `id!(my_button)` or `ids!(my_button)`
|
|
58
|
+
- Overridable via dot-path syntax: `MyTemplate{ title.text: "New text" }`
|
|
59
|
+
- Stored in the script object's `vec` (not `map`)
|
|
60
|
+
|
|
61
|
+
Regular properties use `:` and go into `map`:
|
|
62
|
+
```
|
|
63
|
+
width: Fill // regular property -> map
|
|
64
|
+
label := Label{} // named child -> vec
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Merge Operator: `+:`
|
|
68
|
+
|
|
69
|
+
The `+:` operator extends/merges with the parent instead of replacing:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
draw_bg +: {
|
|
73
|
+
color: #f00 // Only overrides color, keeps all other draw_bg properties
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Without `+:`, you REPLACE the entire property:
|
|
78
|
+
```
|
|
79
|
+
draw_bg: { color: #f00 } // REPLACES all of draw_bg - loses hover, border, etc.
|
|
80
|
+
draw_bg +: { color: #f00 } // MERGES - only changes color, keeps everything else
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Dot-Path Shorthand
|
|
84
|
+
|
|
85
|
+
Dot-path is syntactic sugar for merge:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
draw_bg.color: #f00
|
|
89
|
+
// is equivalent to:
|
|
90
|
+
draw_bg +: { color: #f00 }
|
|
91
|
+
|
|
92
|
+
draw_text.text_style.font_size: 14
|
|
93
|
+
// is equivalent to:
|
|
94
|
+
draw_text +: { text_style +: { font_size: 14 } }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Let Bindings: Local Templates
|
|
98
|
+
|
|
99
|
+
`let` creates local, reusable templates within a `script_mod!` block:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
let MyCard = RoundedView{
|
|
103
|
+
width: Fill height: Fit
|
|
104
|
+
padding: 16 flow: Down spacing: 8
|
|
105
|
+
draw_bg.color: #2a2a3d
|
|
106
|
+
draw_bg.border_radius: 8.0
|
|
107
|
+
title := Label{ text: "Default Title" draw_text.color: #fff }
|
|
108
|
+
body := Label{ text: "" draw_text.color: #aaa }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Instantiate and override:
|
|
112
|
+
MyCard{ title.text: "Card 1" body.text: "Content here" }
|
|
113
|
+
MyCard{ title.text: "Card 2" body.text: "More content" }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**IMPORTANT**: `let` bindings are LOCAL to the `script_mod!` block. They cannot be accessed from other `script_mod!` blocks. To share across modules, store in `mod.widgets.*`.
|
|
117
|
+
|
|
118
|
+
### Spread Operator: `..`
|
|
119
|
+
|
|
120
|
+
Inherit all properties from another definition:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
set_type_default() do #(DrawMyShader::script_shader(vm)){
|
|
124
|
+
..mod.draw.DrawQuad // Inherit from DrawQuad
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Script Module Structure
|
|
129
|
+
|
|
130
|
+
### Basic App Structure
|
|
131
|
+
|
|
132
|
+
```rust
|
|
133
|
+
use makepad_widgets::*;
|
|
134
|
+
|
|
135
|
+
app_main!(App);
|
|
136
|
+
|
|
137
|
+
script_mod!{
|
|
138
|
+
use mod.prelude.widgets.*
|
|
139
|
+
|
|
140
|
+
load_all_resources() do #(App::script_component(vm)){
|
|
141
|
+
ui: Root{
|
|
142
|
+
main_window := Window{
|
|
143
|
+
window.inner_size: vec2(800, 600)
|
|
144
|
+
body +: {
|
|
145
|
+
// UI content here
|
|
146
|
+
my_button := Button{ text: "Click" }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
impl App {
|
|
154
|
+
fn run(vm: &mut ScriptVm) -> Self {
|
|
155
|
+
crate::makepad_widgets::script_mod(vm); // 1. Register base widgets
|
|
156
|
+
App::from_script_mod(vm, self::script_mod)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#[derive(Script, ScriptHook)]
|
|
161
|
+
pub struct App {
|
|
162
|
+
#[source] source: ScriptObjectRef, // REQUIRED for Script-derived structs
|
|
163
|
+
#[live] ui: WidgetRef,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
impl MatchEvent for App {
|
|
167
|
+
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
|
|
168
|
+
if self.ui.button(ids!(my_button)).clicked(actions) {
|
|
169
|
+
log!("Button clicked!");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
impl AppMain for App {
|
|
175
|
+
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
|
|
176
|
+
self.match_event(cx, event);
|
|
177
|
+
self.ui.handle_event(cx, event, &mut Scope::empty());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Widget Definition Module
|
|
183
|
+
|
|
184
|
+
```rust
|
|
185
|
+
script_mod!{
|
|
186
|
+
use mod.prelude.widgets_internal.* // For widget library internals
|
|
187
|
+
use mod.widgets.* // Access other registered widgets
|
|
188
|
+
|
|
189
|
+
// Step 1: Register the Rust struct as a widget base
|
|
190
|
+
mod.widgets.MyWidgetBase = #(MyWidget::register_widget(vm))
|
|
191
|
+
|
|
192
|
+
// Step 2: Create a styled variant with default properties
|
|
193
|
+
mod.widgets.MyWidget = set_type_default() do mod.widgets.MyWidgetBase{
|
|
194
|
+
width: Fill
|
|
195
|
+
height: Fit
|
|
196
|
+
padding: theme.space_2
|
|
197
|
+
|
|
198
|
+
draw_bg +: {
|
|
199
|
+
color: theme.color_bg_app
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Registration Patterns
|
|
206
|
+
|
|
207
|
+
### Widget Registration
|
|
208
|
+
|
|
209
|
+
For structs that implement the `Widget` trait:
|
|
210
|
+
|
|
211
|
+
```rust
|
|
212
|
+
mod.widgets.MyWidgetBase = #(MyWidget::register_widget(vm))
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Rust side:
|
|
216
|
+
```rust
|
|
217
|
+
#[derive(Script, ScriptHook, Widget)]
|
|
218
|
+
pub struct MyWidget {
|
|
219
|
+
#[source] source: ScriptObjectRef, // REQUIRED
|
|
220
|
+
#[walk] walk: Walk,
|
|
221
|
+
#[layout] layout: Layout,
|
|
222
|
+
#[redraw] #[live] draw_bg: DrawQuad,
|
|
223
|
+
#[live] draw_text: DrawText,
|
|
224
|
+
#[rust] my_state: i32, // Runtime-only, not exposed to script
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Component Registration
|
|
229
|
+
|
|
230
|
+
For non-widget structs that need script integration:
|
|
231
|
+
|
|
232
|
+
```rust
|
|
233
|
+
mod.widgets.MyComponentBase = #(MyComponent::script_component(vm))
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Draw Shader Registration
|
|
237
|
+
|
|
238
|
+
For custom draw types with shader fields:
|
|
239
|
+
|
|
240
|
+
```rust
|
|
241
|
+
set_type_default() do #(DrawMyShader::script_shader(vm)){
|
|
242
|
+
..mod.draw.DrawQuad // Inherit from DrawQuad
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Rust side:
|
|
247
|
+
```rust
|
|
248
|
+
#[derive(Script, ScriptHook)]
|
|
249
|
+
#[repr(C)]
|
|
250
|
+
pub struct DrawMyShader {
|
|
251
|
+
#[deref] draw_super: DrawQuad,
|
|
252
|
+
#[live] my_param: f32,
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Setting Type Defaults
|
|
257
|
+
|
|
258
|
+
```rust
|
|
259
|
+
mod.widgets.MyWidget = set_type_default() do mod.widgets.MyWidgetBase{
|
|
260
|
+
width: Fill height: Fit
|
|
261
|
+
draw_bg +: { color: theme.color_bg_app }
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Registration Order (CRITICAL)
|
|
266
|
+
|
|
267
|
+
Widget modules MUST be registered BEFORE UI modules that use them:
|
|
268
|
+
|
|
269
|
+
```rust
|
|
270
|
+
impl App {
|
|
271
|
+
fn run(vm: &mut ScriptVm) -> Self {
|
|
272
|
+
crate::makepad_widgets::script_mod(vm); // 1. Base widgets FIRST
|
|
273
|
+
crate::my_widgets::script_mod(vm); // 2. Custom widgets SECOND
|
|
274
|
+
crate::app_ui::script_mod(vm); // 3. UI using widgets THIRD
|
|
275
|
+
App::from_script_mod(vm, self::script_mod) // 4. App component LAST
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Multi-Module Aggregation (lib.rs pattern)
|
|
281
|
+
|
|
282
|
+
```rust
|
|
283
|
+
pub fn script_mod(vm: &mut ScriptVm) {
|
|
284
|
+
crate::module_a::script_mod(vm);
|
|
285
|
+
crate::module_b::script_mod(vm);
|
|
286
|
+
// ... all widget modules
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Prelude System
|
|
291
|
+
|
|
292
|
+
### Available Preludes
|
|
293
|
+
|
|
294
|
+
| Prelude | Use Case |
|
|
295
|
+
|---------|----------|
|
|
296
|
+
| `mod.prelude.widgets.*` | App development - includes all standard widgets |
|
|
297
|
+
| `mod.prelude.widgets_internal.*` | Widget library internal development |
|
|
298
|
+
|
|
299
|
+
### Prelude Alias Syntax
|
|
300
|
+
|
|
301
|
+
```rust
|
|
302
|
+
mod.prelude.widgets = {
|
|
303
|
+
..mod.std, // Spread all of mod.std into scope
|
|
304
|
+
theme:mod.theme, // Create 'theme' as alias for mod.theme
|
|
305
|
+
draw:mod.draw, // Create 'draw' as alias for mod.draw
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Without the alias (`mod.theme,` without `theme:`), the module is included but has no accessible name.
|
|
310
|
+
|
|
311
|
+
## Cross-Module Sharing
|
|
312
|
+
|
|
313
|
+
### The `mod` Object is the ONLY Way to Share
|
|
314
|
+
|
|
315
|
+
```rust
|
|
316
|
+
// In widget_module.rs - export to mod.widgets namespace
|
|
317
|
+
script_mod!{
|
|
318
|
+
use mod.prelude.widgets_internal.*
|
|
319
|
+
mod.widgets.MyWidget = set_type_default() do mod.widgets.MyWidgetBase{ ... }
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// In app_ui.rs - import via mod.widgets
|
|
323
|
+
script_mod!{
|
|
324
|
+
use mod.prelude.widgets.*
|
|
325
|
+
use mod.widgets.* // Now MyWidget is in scope
|
|
326
|
+
// ...
|
|
327
|
+
MyWidget{}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**`use crate.module.*` does NOT work** - the `crate.` prefix is not available in script_mod.
|
|
332
|
+
|
|
333
|
+
## Runtime Property Updates
|
|
334
|
+
|
|
335
|
+
Use `script_apply_eval!` instead of the old `apply_over` + `live!`:
|
|
336
|
+
|
|
337
|
+
```rust
|
|
338
|
+
// Old system
|
|
339
|
+
item.apply_over(cx, live!{ height: (height) });
|
|
340
|
+
|
|
341
|
+
// New system - use #(expr) for Rust expression interpolation
|
|
342
|
+
script_apply_eval!(cx, item, {
|
|
343
|
+
height: #(height)
|
|
344
|
+
draw_bg: { is_even: #(if is_even { 1.0 } else { 0.0 }) }
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Debug Logging
|
|
349
|
+
|
|
350
|
+
Use `~expression` to log values during script evaluation:
|
|
351
|
+
|
|
352
|
+
```rust
|
|
353
|
+
script_mod!{
|
|
354
|
+
~mod.theme // Logs the theme object
|
|
355
|
+
~mod.prelude.widgets // Logs what's in the prelude
|
|
356
|
+
~some_variable // Logs a variable's value
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Common Pitfalls
|
|
361
|
+
|
|
362
|
+
### 1. Missing `#[source] source: ScriptObjectRef`
|
|
363
|
+
|
|
364
|
+
All `Script`-derived structs MUST have this field:
|
|
365
|
+
|
|
366
|
+
```rust
|
|
367
|
+
#[derive(Script, ScriptHook)]
|
|
368
|
+
pub struct MyStruct {
|
|
369
|
+
#[source] source: ScriptObjectRef, // REQUIRED - will fail without it
|
|
370
|
+
// ...
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### 2. Missing `height: Fit` on Containers
|
|
375
|
+
|
|
376
|
+
Default height is `Fill`. In a `Fit` parent, `Fill` creates a circular dependency = 0 height = invisible:
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
// WRONG - invisible!
|
|
380
|
+
View{ flow: Down
|
|
381
|
+
Label{ text: "You can't see me" }
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// CORRECT
|
|
385
|
+
View{ height: Fit flow: Down
|
|
386
|
+
Label{ text: "Visible!" }
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### 3. Confusing `:` vs `:=`
|
|
391
|
+
|
|
392
|
+
- `key: value` -- sets a property (stored in map)
|
|
393
|
+
- `name := Widget{}` -- creates a named, addressable child (stored in vec)
|
|
394
|
+
- `label := Label{ text: "x" }` -- named, overridable via `Template{ label.text: "y" }`
|
|
395
|
+
- `label: Label{ text: "x" }` -- anonymous, NOT addressable, overrides fail silently
|
|
396
|
+
|
|
397
|
+
### 4. Forgetting `+:` Merge Operator
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
// WRONG - replaces ALL of draw_bg (loses hover, border, animations)
|
|
401
|
+
draw_bg: { color: #f00 }
|
|
402
|
+
|
|
403
|
+
// CORRECT - merges, only changes color
|
|
404
|
+
draw_bg +: { color: #f00 }
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### 5. Wrong Theme Access
|
|
408
|
+
|
|
409
|
+
```
|
|
410
|
+
// WRONG
|
|
411
|
+
color: THEME_COLOR_BG // old 1.x constant syntax
|
|
412
|
+
color: (THEME_COLOR_BG) // old 1.x parenthesized reference
|
|
413
|
+
|
|
414
|
+
// CORRECT
|
|
415
|
+
color: theme.color_bg_app
|
|
416
|
+
padding: theme.space_2
|
|
417
|
+
font_size: theme.font_size_p
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### 6. Hex Colors Containing 'e' Need `#x` Prefix
|
|
421
|
+
|
|
422
|
+
The Rust tokenizer interprets `e`/`E` in hex literals as scientific notation exponent:
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
// WRONG - Rust parse error: "expected at least one digit in exponent"
|
|
426
|
+
color: #2ecc71
|
|
427
|
+
color: #1e1e2e
|
|
428
|
+
|
|
429
|
+
// CORRECT - use #x prefix
|
|
430
|
+
color: #x2ecc71
|
|
431
|
+
color: #x1e1e2e
|
|
432
|
+
|
|
433
|
+
// Colors without 'e' work fine with plain #
|
|
434
|
+
color: #ff4444 // OK
|
|
435
|
+
color: #44cc44 // OK
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### 7. `pub` Keyword Invalid in script_mod
|
|
439
|
+
|
|
440
|
+
```
|
|
441
|
+
// WRONG
|
|
442
|
+
pub mod.widgets.MyWidget = ...
|
|
443
|
+
|
|
444
|
+
// CORRECT - visibility is controlled by Rust module system
|
|
445
|
+
mod.widgets.MyWidget = ...
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### 8. `Inset{...}` Constructor Syntax for Margins/Padding
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
// WRONG
|
|
452
|
+
margin: { left: 10 }
|
|
453
|
+
align: { x: 0.5 y: 0.5 }
|
|
454
|
+
|
|
455
|
+
// CORRECT - use constructor syntax
|
|
456
|
+
margin: Inset{ left: 10 }
|
|
457
|
+
align: Align{ x: 0.5 y: 0.5 }
|
|
458
|
+
padding: Inset{ top: 5 bottom: 5 left: 10 right: 10 }
|
|
459
|
+
|
|
460
|
+
// Bare number for uniform values is OK
|
|
461
|
+
padding: 15
|
|
462
|
+
margin: 0.
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### 9. Draw Shader Struct Field Ordering with `#[repr(C)]`
|
|
466
|
+
|
|
467
|
+
Non-instance data (`#[rust]`, non-instance `#[live]` fields) MUST go BEFORE `#[deref]`. Only instance fields (shader inputs) go AFTER:
|
|
468
|
+
|
|
469
|
+
```rust
|
|
470
|
+
// CORRECT
|
|
471
|
+
#[derive(Script, ScriptHook)]
|
|
472
|
+
#[repr(C)]
|
|
473
|
+
pub struct MyDrawShader {
|
|
474
|
+
#[live] pub svg: Option<ScriptHandleRef>, // non-instance, BEFORE deref
|
|
475
|
+
#[rust] my_state: bool, // non-instance, BEFORE deref
|
|
476
|
+
#[deref] pub draw_super: DrawQuad, // contains DrawVars + base instances
|
|
477
|
+
#[live] pub tint: Vec4f, // instance field, AFTER deref - OK
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// WRONG - #[rust] after instance fields corrupts GPU buffer
|
|
481
|
+
#[derive(Script, ScriptHook)]
|
|
482
|
+
#[repr(C)]
|
|
483
|
+
pub struct MyDrawShader {
|
|
484
|
+
#[deref] pub draw_super: DrawQuad,
|
|
485
|
+
#[live] pub tint: Vec4f,
|
|
486
|
+
#[rust] my_state: bool, // BAD: between instance fields
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### 10. No Comments Before First Code in script_mod!
|
|
491
|
+
|
|
492
|
+
See [references/extended-guide.md](references/extended-guide.md) for comment-order pitfalls and more examples.
|