claudecode-omc 5.6.6 → 5.6.8
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/.local/skills/THIRD_PARTY_LICENSES/AvdLee-SwiftUI-Agent-Skill.LICENSE +21 -0
- package/.local/skills/THIRD_PARTY_LICENSES/Dimillian-Skills.LICENSE +21 -0
- package/.local/skills/THIRD_PARTY_LICENSES/README.md +36 -0
- package/.local/skills/THIRD_PARTY_LICENSES/twostraws-swiftui-agent-skill.LICENSE +21 -0
- package/.local/skills/h5-to-swiftui/SKILL.md +201 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/README.md +176 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/h5-twin/index.html +52 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/h5-twin/style.css +133 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin/Package.swift +26 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin/Sources/CalibrationScreen/CalibrationScreen.swift +142 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin-divergent/Package.swift +32 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin-divergent/Sources/CalibrationScreenDivergent/CalibrationScreenDivergent.swift +122 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/tokens.json +42 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/index.html +14 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/package.json +20 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/public/api/articles/001.json +96 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/public/api/articles/index.json +89 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/App.jsx +22 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/App.module.css +11 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/ArticleCard.jsx +53 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/ArticleCard.module.css +139 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/NavBar.jsx +37 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/NavBar.module.css +72 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TagCloud.jsx +30 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TagCloud.module.css +50 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TrendChart.jsx +159 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TrendChart.module.css +21 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/main.jsx +12 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/ArticleScreen.jsx +182 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/ArticleScreen.module.css +294 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/FeedScreen.jsx +147 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/FeedScreen.module.css +161 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/styles/global.css +50 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/styles/tokens.css +103 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/vite.config.js +6 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/data/tasks.js +67 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/index.html +26 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/router.js +73 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/detail.js +164 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/home.js +53 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/list.js +87 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/styles/app.css +342 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/styles/tokens.css +68 -0
- package/.local/skills/h5-to-swiftui/references/css-to-swiftui-map.md +205 -0
- package/.local/skills/h5-to-swiftui/references/design-token-extraction.md +209 -0
- package/.local/skills/h5-to-swiftui/references/high-risk-triage.md +209 -0
- package/.local/skills/h5-to-swiftui/references/render-equivalence-calibration.md +193 -0
- package/.local/skills/h5-to-swiftui/references/stack-detection.md +160 -0
- package/.local/skills/h5-to-swiftui/references/visual-diff-loop-protocol.md +365 -0
- package/.local/skills/h5-to-swiftui/scripts/_calib-consts.mjs +150 -0
- package/.local/skills/h5-to-swiftui/scripts/_imglib.mjs +547 -0
- package/.local/skills/h5-to-swiftui/scripts/_provenance.mjs +123 -0
- package/.local/skills/h5-to-swiftui/scripts/calibrate-render.mjs +625 -0
- package/.local/skills/h5-to-swiftui/scripts/capture-reference.mjs +386 -0
- package/.local/skills/h5-to-swiftui/scripts/detect-stack.mjs +305 -0
- package/.local/skills/h5-to-swiftui/scripts/evaluate-convergence.mjs +1093 -0
- package/.local/skills/h5-to-swiftui/scripts/extract-tokens.mjs +600 -0
- package/.local/skills/h5-to-swiftui/scripts/mark-overlay.mjs +379 -0
- package/.local/skills/h5-to-swiftui/scripts/pixel-diff.mjs +530 -0
- package/.local/skills/h5-to-swiftui/scripts/sim-screenshot.sh +544 -0
- package/.local/skills/ios-debugger-agent/SKILL.md +51 -0
- package/.local/skills/ios-debugger-agent/agents/openai.yaml +4 -0
- package/.local/skills/swift-concurrency-expert/SKILL.md +105 -0
- package/.local/skills/swift-concurrency-expert/agents/openai.yaml +4 -0
- package/.local/skills/swift-concurrency-expert/references/approachable-concurrency.md +63 -0
- package/.local/skills/swift-concurrency-expert/references/swift-6-2-concurrency.md +272 -0
- package/.local/skills/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +33 -0
- package/.local/skills/swiftui-expert-skill/SKILL.md +162 -0
- package/.local/skills/swiftui-expert-skill/references/accessibility-patterns.md +215 -0
- package/.local/skills/swiftui-expert-skill/references/animation-advanced.md +403 -0
- package/.local/skills/swiftui-expert-skill/references/animation-basics.md +284 -0
- package/.local/skills/swiftui-expert-skill/references/animation-transitions.md +326 -0
- package/.local/skills/swiftui-expert-skill/references/charts-accessibility.md +135 -0
- package/.local/skills/swiftui-expert-skill/references/charts.md +602 -0
- package/.local/skills/swiftui-expert-skill/references/focus-patterns.md +299 -0
- package/.local/skills/swiftui-expert-skill/references/image-optimization.md +203 -0
- package/.local/skills/swiftui-expert-skill/references/latest-apis.md +488 -0
- package/.local/skills/swiftui-expert-skill/references/layout-best-practices.md +266 -0
- package/.local/skills/swiftui-expert-skill/references/liquid-glass.md +423 -0
- package/.local/skills/swiftui-expert-skill/references/list-patterns.md +446 -0
- package/.local/skills/swiftui-expert-skill/references/macos-scenes.md +318 -0
- package/.local/skills/swiftui-expert-skill/references/macos-views.md +357 -0
- package/.local/skills/swiftui-expert-skill/references/macos-window-styling.md +303 -0
- package/.local/skills/swiftui-expert-skill/references/performance-patterns.md +403 -0
- package/.local/skills/swiftui-expert-skill/references/scroll-patterns.md +293 -0
- package/.local/skills/swiftui-expert-skill/references/sheet-navigation-patterns.md +363 -0
- package/.local/skills/swiftui-expert-skill/references/state-management.md +388 -0
- package/.local/skills/swiftui-expert-skill/references/text-patterns.md +32 -0
- package/.local/skills/swiftui-expert-skill/references/trace-analysis.md +295 -0
- package/.local/skills/swiftui-expert-skill/references/trace-recording.md +134 -0
- package/.local/skills/swiftui-expert-skill/references/view-structure.md +780 -0
- package/.local/skills/swiftui-expert-skill/scripts/__pycache__/analyze_trace.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/__pycache__/record_trace.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/analyze_trace.py +301 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__init__.py +1 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/__init__.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/causes.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/correlate.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/events.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/hangs.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/hitches.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/summary.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/swiftui.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/time_profiler.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/xctrace.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/xml_utils.cpython-313.pyc +0 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/causes.py +187 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/correlate.py +179 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/events.py +291 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/hangs.py +108 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/hitches.py +145 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/summary.py +243 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/swiftui.py +195 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/time_profiler.py +135 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/xctrace.py +117 -0
- package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/xml_utils.py +224 -0
- package/.local/skills/swiftui-expert-skill/scripts/record_trace.py +252 -0
- package/.local/skills/swiftui-liquid-glass/SKILL.md +90 -0
- package/.local/skills/swiftui-liquid-glass/agents/openai.yaml +4 -0
- package/.local/skills/swiftui-liquid-glass/references/liquid-glass.md +280 -0
- package/.local/skills/swiftui-performance-audit/SKILL.md +106 -0
- package/.local/skills/swiftui-performance-audit/agents/openai.yaml +4 -0
- package/.local/skills/swiftui-performance-audit/references/code-smells.md +150 -0
- package/.local/skills/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +46 -0
- package/.local/skills/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +29 -0
- package/.local/skills/swiftui-performance-audit/references/profiling-intake.md +44 -0
- package/.local/skills/swiftui-performance-audit/references/report-template.md +47 -0
- package/.local/skills/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +33 -0
- package/.local/skills/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +52 -0
- package/.local/skills/swiftui-pro/SKILL.md +108 -0
- package/.local/skills/swiftui-pro/agents/openai.yaml +10 -0
- package/.local/skills/swiftui-pro/assets/swiftui-pro-icon.png +0 -0
- package/.local/skills/swiftui-pro/assets/swiftui-pro-icon.svg +29 -0
- package/.local/skills/swiftui-pro/references/accessibility.md +13 -0
- package/.local/skills/swiftui-pro/references/api.md +39 -0
- package/.local/skills/swiftui-pro/references/data.md +43 -0
- package/.local/skills/swiftui-pro/references/design.md +32 -0
- package/.local/skills/swiftui-pro/references/hygiene.md +9 -0
- package/.local/skills/swiftui-pro/references/navigation.md +14 -0
- package/.local/skills/swiftui-pro/references/performance.md +46 -0
- package/.local/skills/swiftui-pro/references/swift.md +56 -0
- package/.local/skills/swiftui-pro/references/views.md +36 -0
- package/.local/skills/swiftui-ui-patterns/SKILL.md +95 -0
- package/.local/skills/swiftui-ui-patterns/agents/openai.yaml +4 -0
- package/.local/skills/swiftui-ui-patterns/references/app-wiring.md +201 -0
- package/.local/skills/swiftui-ui-patterns/references/async-state.md +96 -0
- package/.local/skills/swiftui-ui-patterns/references/components-index.md +50 -0
- package/.local/skills/swiftui-ui-patterns/references/controls.md +57 -0
- package/.local/skills/swiftui-ui-patterns/references/deeplinks.md +66 -0
- package/.local/skills/swiftui-ui-patterns/references/focus.md +90 -0
- package/.local/skills/swiftui-ui-patterns/references/form.md +97 -0
- package/.local/skills/swiftui-ui-patterns/references/grids.md +71 -0
- package/.local/skills/swiftui-ui-patterns/references/haptics.md +71 -0
- package/.local/skills/swiftui-ui-patterns/references/input-toolbar.md +51 -0
- package/.local/skills/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
- package/.local/skills/swiftui-ui-patterns/references/list.md +86 -0
- package/.local/skills/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
- package/.local/skills/swiftui-ui-patterns/references/macos-settings.md +71 -0
- package/.local/skills/swiftui-ui-patterns/references/matched-transitions.md +59 -0
- package/.local/skills/swiftui-ui-patterns/references/media.md +73 -0
- package/.local/skills/swiftui-ui-patterns/references/menu-bar.md +101 -0
- package/.local/skills/swiftui-ui-patterns/references/navigationstack.md +159 -0
- package/.local/skills/swiftui-ui-patterns/references/overlay.md +45 -0
- package/.local/skills/swiftui-ui-patterns/references/performance.md +62 -0
- package/.local/skills/swiftui-ui-patterns/references/previews.md +48 -0
- package/.local/skills/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
- package/.local/skills/swiftui-ui-patterns/references/scrollview.md +87 -0
- package/.local/skills/swiftui-ui-patterns/references/searchable.md +71 -0
- package/.local/skills/swiftui-ui-patterns/references/sheets.md +155 -0
- package/.local/skills/swiftui-ui-patterns/references/split-views.md +72 -0
- package/.local/skills/swiftui-ui-patterns/references/tabview.md +114 -0
- package/.local/skills/swiftui-ui-patterns/references/theming.md +71 -0
- package/.local/skills/swiftui-ui-patterns/references/title-menus.md +93 -0
- package/.local/skills/swiftui-ui-patterns/references/top-bar.md +49 -0
- package/.local/skills/swiftui-view-refactor/SKILL.md +202 -0
- package/.local/skills/swiftui-view-refactor/agents/openai.yaml +4 -0
- package/.local/skills/swiftui-view-refactor/references/mv-patterns.md +161 -0
- package/bundled/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# CSS → SwiftUI Mapping Reference — Stage 4
|
|
2
|
+
|
|
3
|
+
This is the lookup table used by the Stage 4 LLM prompt and the idiomatic-lint
|
|
4
|
+
checker. Accuracy is critical — this directly drives code generation. Every row
|
|
5
|
+
includes a caveat column because a mapping without its caveat is incomplete.
|
|
6
|
+
|
|
7
|
+
Source: findings.md RQ5 (kean.blog; Hacking with Swift; Swift with Majid;
|
|
8
|
+
swiftuifieldguide; Apple WWDC22-10056; tonsky.me; fatbobman).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Flexbox → SwiftUI
|
|
13
|
+
|
|
14
|
+
| CSS property / value | SwiftUI equivalent | Caveat |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `display: flex; flex-direction: row` | `HStack(alignment:, spacing:)` | Default `HStack()` spacing is non-zero (system-defined); **always pass `spacing: 0`** then add explicit spacing between children |
|
|
17
|
+
| `display: flex; flex-direction: column` | `VStack(alignment:, spacing:)` | Same spacing caveat — pass `spacing: 0` |
|
|
18
|
+
| `flex-direction: row-reverse` | `HStack` + `.environment(\.layoutDirection, .rightToLeft)` or reverse the child array | Prefer reversing child array when order is data-driven |
|
|
19
|
+
| `flex-direction: column-reverse` | `VStack` + reversed child array | No native reverse stack; reversing in data source is cleanest |
|
|
20
|
+
| `justify-content: flex-start` | Default (leading) | No modifier needed |
|
|
21
|
+
| `justify-content: flex-end` | `Spacer()` before first child | `Spacer()` expands to fill available space |
|
|
22
|
+
| `justify-content: center` | `Spacer()` + children + `Spacer()` | Or `.frame(maxWidth: .infinity, alignment: .center)` on the container |
|
|
23
|
+
| `justify-content: space-between` | `Spacer()` between each pair of children | Must insert N−1 spacers manually |
|
|
24
|
+
| `justify-content: space-around` | `Spacer()` before first, between each, after last | Each spacer gets equal weight; use `Spacer(minLength: 0)` |
|
|
25
|
+
| `justify-content: space-evenly` | `Spacer()` at all gaps including edges | Same as `space-around` implementation in SwiftUI |
|
|
26
|
+
| `align-items: flex-start` | `HStack(alignment: .top)` / `VStack(alignment: .leading)` | |
|
|
27
|
+
| `align-items: center` | `HStack(alignment: .center)` / `VStack(alignment: .center)` | `.center` is the default for HStack |
|
|
28
|
+
| `align-items: flex-end` | `HStack(alignment: .bottom)` / `VStack(alignment: .trailing)` | |
|
|
29
|
+
| `align-items: stretch` | Default HStack/VStack behavior for views with no explicit frame | Add `.frame(maxWidth: .infinity)` on children that need to stretch |
|
|
30
|
+
| `align-items: baseline` | `HStack(alignment: .firstTextBaseline)` | Also `.lastTextBaseline`; applies only to text-bearing children |
|
|
31
|
+
| `align-self: <value>` | `.alignmentGuide(alignment, computeValue:)` on the individual child | No direct `align-self` equivalent; alignment guides are complex — use only when necessary |
|
|
32
|
+
| `flex-grow: 1` (uniform on all siblings) | `.frame(maxWidth: .infinity)` (in HStack) or `.frame(maxHeight: .infinity)` (in VStack) | Only correct when all siblings have the same grow ratio |
|
|
33
|
+
| `flex-grow` (non-uniform ratios) | **Custom `Layout` protocol (iOS 16+)** | See "When you MUST use custom Layout" section below |
|
|
34
|
+
| `flex-shrink: 0` | `.fixedSize()` or explicit `.frame(width:, height:)` | Prevents the view from shrinking below its ideal size |
|
|
35
|
+
| `flex-shrink: 1` (default) | Default SwiftUI behavior | SwiftUI views compress by default when space is tight |
|
|
36
|
+
| `flex-basis: <value>` | `.frame(width: value)` / `.frame(height: value)` | Approximate only; no exact CSS `flex-basis` semantics in SwiftUI |
|
|
37
|
+
| `flex-wrap: wrap` | **Custom `Layout` protocol (iOS 16+)** — `FlowLayout` | No `LazyHGrid`/`LazyVGrid` equivalent for true wrapping; see FlowLayout sketch below |
|
|
38
|
+
| `flex-wrap: nowrap` | Default HStack/VStack (no wrapping) | |
|
|
39
|
+
| `gap: <value>` | `spacing: value` parameter on HStack/VStack | Both row-gap and column-gap map to the same `spacing` param — if they differ, use custom Layout |
|
|
40
|
+
| `row-gap: <value>` | `spacing: value` on VStack | |
|
|
41
|
+
| `column-gap: <value>` | `spacing: value` on HStack | |
|
|
42
|
+
| `order: <n>` | Reorder child array in data source | SwiftUI renders children in declaration order; no runtime reorder modifier exists |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## CSS Grid → SwiftUI
|
|
47
|
+
|
|
48
|
+
SwiftUI's grid support is intentionally limited. Know the ceiling.
|
|
49
|
+
|
|
50
|
+
| CSS Grid construct | SwiftUI equivalent | Caveat |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `grid-template-columns: repeat(N, 1fr)` | `LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: N))` | Only works for uniform fraction columns; not for mixed units |
|
|
53
|
+
| `grid-template-columns: auto-fill minmax(min, max)` | `LazyVGrid(columns: [GridItem(.adaptive(minimum: min, maximum: max))])` | `.adaptive` fills available width automatically |
|
|
54
|
+
| `fr` ratios (non-uniform, e.g. `1fr 2fr 1fr`) | **Custom `Layout` protocol (iOS 16+)** | No `LazyVGrid` equivalent; fr ratios require measuring total space and distributing proportionally |
|
|
55
|
+
| `grid-template-areas` | Not supported in LazyVGrid/Grid | Use `ZStack` + `.position` for named-area layouts, or custom Layout |
|
|
56
|
+
| `grid-column: span N` (eager Grid) | `.gridCellColumns(N)` on the child | Only works inside `Grid` (eager), not `LazyVGrid` |
|
|
57
|
+
| `grid-row: span N` | Not supported in LazyVGrid | Requires `Grid` (eager) or custom Layout |
|
|
58
|
+
| Explicit line placement (`grid-column: 2 / 4`) | Not supported natively | Custom Layout required |
|
|
59
|
+
| Auto-placement (dense) | LazyVGrid default | LazyVGrid uses source order auto-placement; no `grid-auto-flow: dense` |
|
|
60
|
+
| `gap` / `column-gap` / `row-gap` | `spacing` on `LazyVGrid` or `Grid` | Sets both axes uniformly; split-axis gap requires custom Layout |
|
|
61
|
+
| `Grid` (eager, iOS 16+) | `Grid { GridRow { … } }` | Full alignment control; use for small, known-count grids |
|
|
62
|
+
| `LazyVGrid` | `LazyVGrid(columns:, spacing:)` | For large/dynamic lists; less alignment control than `Grid` |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Positioning → SwiftUI
|
|
67
|
+
|
|
68
|
+
| CSS value | SwiftUI equivalent | Caveat |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `position: static` (default) | Default SwiftUI layout flow | No modifier needed |
|
|
71
|
+
| `position: relative` + `top/left/right/bottom` | `.offset(x:, y:)` | `.offset` shifts visually but preserves the layout space — the element still occupies its original slot; this matches CSS `relative` semantics |
|
|
72
|
+
| `position: absolute` + `top/left/width/height` | `ZStack` + `.position(x: left + width/2, y: top + height/2)` | **`.position()` takes CENTER coordinates, not top-left.** Compute: `cx = left + width/2`, `cy = top + height/2`. Must be inside a `ZStack` or the position is relative to the parent frame |
|
|
73
|
+
| `position: fixed` | `.overlay(alignment:)` on the root view, or `.safeAreaInset(edge:)` | Fixed elements must be moved outside the scrollable content entirely; common for navbars and tab bars |
|
|
74
|
+
| `position: sticky` | Manual: `onScrollGeometryChange` (iOS 18+) or `ScrollViewReader` + preference key | No built-in sticky modifier before iOS 18 |
|
|
75
|
+
| `z-index: <n>` | `.zIndex(n)` | **Only affects sibling ordering within the same `ZStack`.** A `zIndex` on a view nested inside a VStack has no effect relative to views outside that VStack |
|
|
76
|
+
| `inset: 0` (fill parent) | `.frame(maxWidth: .infinity, maxHeight: .infinity)` inside a ZStack | |
|
|
77
|
+
| `transform: translate(x, y)` | `.offset(x:, y:)` | |
|
|
78
|
+
| `transform: scale(n)` | `.scaleEffect(n)` | Scales visually; does not affect layout space |
|
|
79
|
+
| `transform: rotate(deg)` | `.rotationEffect(.degrees(deg))` | |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Box-model drift — the four sources of invisible divergence
|
|
84
|
+
|
|
85
|
+
These are not missing mappings — they are cases where the CSS and SwiftUI
|
|
86
|
+
constructs look equivalent but behave differently. Each one causes layout
|
|
87
|
+
divergence that passes code review.
|
|
88
|
+
|
|
89
|
+
### 1. Margin collapse
|
|
90
|
+
**CSS:** Adjacent vertical margins collapse to `max(m1, m2)`.
|
|
91
|
+
**SwiftUI:** `VStack(spacing:)` accumulates; two views each with `.padding(.bottom, 16)` produce 32 pt gap, not 16.
|
|
92
|
+
**Fix:** Use `VStack(spacing: max(m1, m2))` and remove per-child bottom padding, or set `spacing: 0` and add padding only to one side of each separator pair.
|
|
93
|
+
|
|
94
|
+
### 2. Border draws inside (not outside)
|
|
95
|
+
**CSS default (`content-box`):** `border` expands the element's visible size outward. The content area stays at declared width.
|
|
96
|
+
**SwiftUI `.border()`:** draws _inside_ the frame, equivalent to CSS `outline`. The frame size does not change.
|
|
97
|
+
**Fix:** Add `.padding(borderWidth)` before `.border()` to match CSS border-box behavior, or use `.overlay(RoundedRectangle(...).stroke(...))` which also draws inside.
|
|
98
|
+
|
|
99
|
+
### 3. No native percentage sizing
|
|
100
|
+
**CSS:** `width: 50%` is resolved by the containing block.
|
|
101
|
+
**SwiftUI:** No `%` sizing modifier exists.
|
|
102
|
+
**Fix:** Use `GeometryReader` — but **only in `.background{}` or `.overlay{}`**, never as a layout container. `GeometryReader` is greedy (takes all proposed space); using it as a primary layout view breaks parent constraints.
|
|
103
|
+
|
|
104
|
+
```swift
|
|
105
|
+
// Correct pattern for percentage width:
|
|
106
|
+
Color.clear
|
|
107
|
+
.frame(maxWidth: .infinity)
|
|
108
|
+
.overlay(
|
|
109
|
+
GeometryReader { geo in
|
|
110
|
+
Rectangle()
|
|
111
|
+
.frame(width: geo.size.width * 0.5)
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. `line-height` vs `.lineSpacing` differ
|
|
117
|
+
**CSS `line-height: 1.5` on 16px font:** applies half-leading (equal space above and below each line). Total line height = 24 px; each side gets 4 px extra.
|
|
118
|
+
**SwiftUI `.lineSpacing(n)`:** adds `n` points of space _below_ each line only (no leading above the first line).
|
|
119
|
+
**Conversion formula:** `lineSpacing = (cssLineHeight_px − coreTextLineHeight_px)` — i.e., the extra space only, applied as below-line gap.
|
|
120
|
+
**iOS 26+:** `.lineHeight(.exact: value)` sets exact line height matching CSS semantics. Use this when `--ios-floor >= 26`.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## When you MUST use the custom `Layout` protocol (iOS 16+)
|
|
125
|
+
|
|
126
|
+
These CSS patterns have **no stock SwiftUI equivalent**. Attempting to approximate
|
|
127
|
+
them with HStack/VStack produces incorrect layout. Use `Layout` protocol.
|
|
128
|
+
|
|
129
|
+
| CSS pattern | Why stock views fail |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `flex-wrap: wrap` | HStack never wraps; LazyHGrid/LazyVGrid are scroll containers, not inline wrapping layouts |
|
|
132
|
+
| Non-uniform `flex-grow` ratios (e.g. `flex-grow: 2` on one child, `flex-grow: 1` on others) | `.frame(maxWidth: .infinity)` distributes equally; no per-child weight |
|
|
133
|
+
| Non-uniform `fr` ratios (e.g. `1fr 2fr`) | `GridItem(.flexible())` is always equal weight |
|
|
134
|
+
| Radial / circular layouts | No stock radial container exists |
|
|
135
|
+
|
|
136
|
+
### Minimal correct FlowLayout sketch (iOS 16+)
|
|
137
|
+
|
|
138
|
+
```swift
|
|
139
|
+
struct FlowLayout: Layout {
|
|
140
|
+
var spacing: CGFloat = 8
|
|
141
|
+
|
|
142
|
+
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
|
143
|
+
let maxWidth = proposal.width ?? .infinity
|
|
144
|
+
var x: CGFloat = 0
|
|
145
|
+
var y: CGFloat = 0
|
|
146
|
+
var rowHeight: CGFloat = 0
|
|
147
|
+
|
|
148
|
+
for view in subviews {
|
|
149
|
+
let size = view.sizeThatFits(.unspecified)
|
|
150
|
+
if x + size.width > maxWidth, x > 0 {
|
|
151
|
+
y += rowHeight + spacing
|
|
152
|
+
x = 0
|
|
153
|
+
rowHeight = 0
|
|
154
|
+
}
|
|
155
|
+
x += size.width + spacing
|
|
156
|
+
rowHeight = max(rowHeight, size.height)
|
|
157
|
+
}
|
|
158
|
+
return CGSize(width: maxWidth, height: y + rowHeight)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
|
|
162
|
+
let maxWidth = bounds.maxX
|
|
163
|
+
var x = bounds.minX
|
|
164
|
+
var y = bounds.minY
|
|
165
|
+
var rowHeight: CGFloat = 0
|
|
166
|
+
|
|
167
|
+
for view in subviews {
|
|
168
|
+
let size = view.sizeThatFits(.unspecified)
|
|
169
|
+
if x + size.width > maxWidth, x > bounds.minX {
|
|
170
|
+
y += rowHeight + spacing
|
|
171
|
+
x = bounds.minX
|
|
172
|
+
rowHeight = 0
|
|
173
|
+
}
|
|
174
|
+
view.place(at: CGPoint(x: x, y: y), proposal: ProposedViewSize(size))
|
|
175
|
+
x += size.width + spacing
|
|
176
|
+
rowHeight = max(rowHeight, size.height)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This is a production-usable starting point. Add `alignment` and RTL support as
|
|
183
|
+
needed. The `cache` type is `Void` (no measurement caching) — add a `Cache` type
|
|
184
|
+
when subview measurement is expensive.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Quick-reference: CSS visual properties → SwiftUI modifiers
|
|
189
|
+
|
|
190
|
+
| CSS | SwiftUI | Note |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `border-radius: N` | `.cornerRadius(N)` or `.clipShape(RoundedRectangle(cornerRadius: N))` | `.cornerRadius` is deprecated in iOS 17+ for `.clipShape` |
|
|
193
|
+
| `box-shadow: x y blur spread color` | `.shadow(color:, radius:, x:, y:)` | No `spread` equivalent; `radius` ≈ CSS `blur / 2` |
|
|
194
|
+
| `opacity: N` | `.opacity(N)` | |
|
|
195
|
+
| `background-color` | `.background(Color.token)` | Use token, not hex |
|
|
196
|
+
| `color` | `.foregroundStyle(Color.token)` | `.foregroundColor` deprecated iOS 17+ |
|
|
197
|
+
| `font-size` / `font-weight` | `.font(DesignTokens.Typography.body)` | Use extracted token; never hardcode `Font.system(size: 16)` |
|
|
198
|
+
| `letter-spacing: N` | `.kerning(N)` | Units: CSS `em`-based vs SwiftUI `pt`-based; convert |
|
|
199
|
+
| `text-transform: uppercase` | `.textCase(.uppercase)` | |
|
|
200
|
+
| `text-decoration: underline` | `.underline()` | |
|
|
201
|
+
| `overflow: hidden` | `.clipped()` | |
|
|
202
|
+
| `border: N solid color` | `.overlay(Rectangle().stroke(color, lineWidth: N))` | Draws inside frame |
|
|
203
|
+
| `pointer-events: none` | `.allowsHitTesting(false)` | |
|
|
204
|
+
| `cursor: pointer` | No equivalent; tap gesture implied by `Button` | |
|
|
205
|
+
| `display: none` / `visibility: hidden` | `if condition { view }` or `.opacity(0)` | `if` removes from layout; `.opacity(0)` preserves layout space — choose by CSS analogue |
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Design Token Extraction — Stage 1
|
|
2
|
+
|
|
3
|
+
Used by `scripts/extract-tokens.mjs`. Produces `tokens.json` (W3C DTCG format)
|
|
4
|
+
and `token-gaps.json`. Both files are mandatory inputs to Stage 3 (scaffold) and
|
|
5
|
+
Stage 4 (per-component rewrite). Stage 4 must never inline a value that belongs
|
|
6
|
+
in `token-gaps.json` — see the token-miss rule below.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## The static ∪ runtime pipeline
|
|
11
|
+
|
|
12
|
+
Two extraction passes run unconditionally. Their outputs are merged then
|
|
13
|
+
normalized. Neither pass alone is sufficient.
|
|
14
|
+
|
|
15
|
+
| Pass | What it gives | What it misses | How to run |
|
|
16
|
+
|---|---|---|---|
|
|
17
|
+
| Static parse | All _declared_ custom props, Tailwind config, Sass vars — complete enumeration including unused tokens | Values behind `calc()`, `var()` chains, media-query overrides, `@layer` override priority | Read source files: CSS `--*` props; `tailwind.config.js` `theme.extend`; `@theme` blocks (Tailwind v4); compiled `.css` output of Sass |
|
|
18
|
+
| Runtime `getComputedStyle` | _Resolved_ values as the browser actually computes them — ground truth for any `calc`, `var`, inheritance, or conditional override | Tokens that are declared but never applied to a rendered element | Playwright: load each page, call `getComputedStyle` on a representative element per token class; run twice — once with `prefers-color-scheme: light`, once with `dark` |
|
|
19
|
+
|
|
20
|
+
Merge rule: static gives the token namespace; runtime gives the resolved value.
|
|
21
|
+
If a static token has no runtime-resolved value, keep static value with
|
|
22
|
+
`"source": "static-only"` and flag in `token-gaps.json` if the value contains
|
|
23
|
+
unresolved `var()` or `calc()`.
|
|
24
|
+
|
|
25
|
+
Source: findings.md RQ3 (W3C DTCG draft format; Project Wallace; Style
|
|
26
|
+
Dictionary v4; Tokens Studio).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Tradeoff table
|
|
31
|
+
|
|
32
|
+
| Criterion | Static parse only | Runtime only | Static ∪ runtime |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| Completeness | High — all declared tokens found | Low — only tokens applied to visible elements | High |
|
|
35
|
+
| Resolved truth | Low — `var()`/`calc()` unresolved | High — browser computed values | High |
|
|
36
|
+
| Dark-mode pairs | Manual inference required | Automatic (run twice) | Automatic |
|
|
37
|
+
| Build required | No | Yes (Playwright + dev server or static build) | Dev server preferred; static build acceptable |
|
|
38
|
+
| Speed | Fast | Slow (~5–30 s per page) | Moderate (static fast, runtime adds per page) |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Normalization steps (run after merge, in order)
|
|
43
|
+
|
|
44
|
+
### 1. Color deduplication
|
|
45
|
+
Compare all color values using CIEDE2000 (ΔE00). If ΔE00 < 2 between two colors,
|
|
46
|
+
they are the same perceptual token — keep the one with the more semantic name
|
|
47
|
+
(e.g. `--color-primary` over `--tw-color-blue-600`) and discard the duplicate.
|
|
48
|
+
This typically collapses "25 grays" from Tailwind into 4–6 semantic tokens.
|
|
49
|
+
|
|
50
|
+
### 2. Spacing scale inference
|
|
51
|
+
Collect all spacing values (padding, margin, gap, width/height in px/rem). Detect
|
|
52
|
+
the base unit: if values cluster around multiples of 4 px (or 0.25 rem), the
|
|
53
|
+
project uses a 4 px grid. Flag values that do not fit the inferred scale in
|
|
54
|
+
`token-gaps.json` (they may be one-offs or errors). Map to SwiftUI `CGFloat`
|
|
55
|
+
points (1 pt = 1 CSS px at 1× logical resolution).
|
|
56
|
+
|
|
57
|
+
### 3. Type scale grouping
|
|
58
|
+
Group font-size values by recurrence. A value appearing on 3+ elements is a
|
|
59
|
+
type-scale step. Assign semantic names: `body`, `caption`, `title`, `headline`,
|
|
60
|
+
`largeTitle` (follow Apple HIG naming where possible for SwiftUI
|
|
61
|
+
`Font.TextStyle` matching). Record both `size` and `weight` per step.
|
|
62
|
+
|
|
63
|
+
### 4. Light/dark pairing
|
|
64
|
+
For each color token, pair the light-scheme resolved value with the dark-scheme
|
|
65
|
+
resolved value. Unpaired tokens (no dark equivalent found) are flagged in
|
|
66
|
+
`token-gaps.json` with `"issue": "no-dark-pair"`.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## `tokens.json` (W3C DTCG draft format — `$value`/`$type`)
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"color": {
|
|
75
|
+
"primary": {
|
|
76
|
+
"$value": "#0A7AFF",
|
|
77
|
+
"$type": "color",
|
|
78
|
+
"$description": "Brand primary, resolved from --color-primary via runtime",
|
|
79
|
+
"dark": { "$value": "#3395FF" }
|
|
80
|
+
},
|
|
81
|
+
"background": {
|
|
82
|
+
"$value": "#FFFFFF",
|
|
83
|
+
"$type": "color",
|
|
84
|
+
"dark": { "$value": "#000000" }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"spacing": {
|
|
88
|
+
"base": { "$value": "4px", "$type": "dimension" },
|
|
89
|
+
"md": { "$value": "16px", "$type": "dimension" },
|
|
90
|
+
"lg": { "$value": "24px", "$type": "dimension" }
|
|
91
|
+
},
|
|
92
|
+
"typography": {
|
|
93
|
+
"body": {
|
|
94
|
+
"$type": "typography",
|
|
95
|
+
"$value": { "fontSize": "16px", "fontWeight": "400", "lineHeight": "1.5" }
|
|
96
|
+
},
|
|
97
|
+
"title": {
|
|
98
|
+
"$type": "typography",
|
|
99
|
+
"$value": { "fontSize": "20px", "fontWeight": "600", "lineHeight": "1.3" }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
All values use CSS-native units in the DTCG file. Stage 3 (scaffold) converts to
|
|
106
|
+
SwiftUI `CGFloat` / `Font` equivalents during the `DesignTokens` enum generation.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## `token-gaps.json` shape
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"schema": "h5-to-swiftui/token-gaps@1",
|
|
115
|
+
"gaps": [
|
|
116
|
+
{
|
|
117
|
+
"property": "border-radius",
|
|
118
|
+
"css_value": "var(--radius-card)",
|
|
119
|
+
"resolved_value": null,
|
|
120
|
+
"issue": "unresolved-var",
|
|
121
|
+
"source_file": "src/components/Card.module.css",
|
|
122
|
+
"source_line": 14,
|
|
123
|
+
"action": "manual-extraction-required"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"property": "color",
|
|
127
|
+
"css_value": "#9B9B9B",
|
|
128
|
+
"issue": "no-dark-pair",
|
|
129
|
+
"source_file": "src/components/Label.tsx",
|
|
130
|
+
"source_line": 8,
|
|
131
|
+
"action": "verify-dark-contrast"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## The token-miss rule (hard constraint for Stage 4)
|
|
140
|
+
|
|
141
|
+
> **Any CSS value with no extractable token in `tokens.json` goes to
|
|
142
|
+
> `token-gaps.json` and is NEVER silently inlined by Stage 4.**
|
|
143
|
+
|
|
144
|
+
Stage 4's LLM prompt must include the full `tokens.json` vocabulary and must
|
|
145
|
+
instruct the model: "Use only tokens from the provided vocabulary. If a required
|
|
146
|
+
value is not in the vocabulary, emit a `// TOKEN-MISSING: <property>` comment and
|
|
147
|
+
use the closest token — do not hardcode the raw value."
|
|
148
|
+
|
|
149
|
+
This rule exists because inlined magic numbers break:
|
|
150
|
+
- Dark-mode adaptation (`.colorset` references the token name, not the hex)
|
|
151
|
+
- The convergence loop's color ΔE tracking (tokens give expected values)
|
|
152
|
+
- Any future design-system update
|
|
153
|
+
|
|
154
|
+
A Stage 4 component that contains hardcoded color hex, raw spacing numbers, or
|
|
155
|
+
raw font sizes without a corresponding `tokens.json` entry fails the idiomatic
|
|
156
|
+
lint check and is reprocessed, not delivered.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Style Dictionary → SwiftUI output (Stage 3)
|
|
161
|
+
|
|
162
|
+
Stage 3 runs Style Dictionary v4 (DTCG-native) on `tokens.json` to produce:
|
|
163
|
+
|
|
164
|
+
### `DesignTokens.swift` — a Swift enum namespace
|
|
165
|
+
|
|
166
|
+
```swift
|
|
167
|
+
// Auto-generated by extract-tokens.mjs — do not edit manually
|
|
168
|
+
import SwiftUI
|
|
169
|
+
|
|
170
|
+
enum DesignTokens {
|
|
171
|
+
enum Color {
|
|
172
|
+
static let primary = SwiftUI.Color("dt/primary")
|
|
173
|
+
static let background = SwiftUI.Color("dt/background")
|
|
174
|
+
}
|
|
175
|
+
enum Spacing {
|
|
176
|
+
static let base: CGFloat = 4
|
|
177
|
+
static let md: CGFloat = 16
|
|
178
|
+
static let lg: CGFloat = 24
|
|
179
|
+
}
|
|
180
|
+
enum Typography {
|
|
181
|
+
static let body = Font.system(size: 16, weight: .regular)
|
|
182
|
+
static let title = Font.system(size: 20, weight: .semibold)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### XCAssets `.colorset` files (dark-mode automatic)
|
|
188
|
+
|
|
189
|
+
For each color token pair, Style Dictionary emits a `.colorset` directory with
|
|
190
|
+
`Contents.json` containing both light and dark `value` entries. The `dt/<name>`
|
|
191
|
+
asset catalog name matches the `SwiftUI.Color("dt/<name>")` initializer above.
|
|
192
|
+
|
|
193
|
+
This means dark mode requires **no conditional code** in Stage 4 components —
|
|
194
|
+
`DesignTokens.Color.primary` automatically resolves to the correct scheme.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Extraction strategy by detected styling system
|
|
199
|
+
|
|
200
|
+
From `stack-report.json` (`styling` field), `extract-tokens.mjs` selects:
|
|
201
|
+
|
|
202
|
+
| Detected styling | Static strategy |
|
|
203
|
+
|---|---|
|
|
204
|
+
| `tailwind-v3` | Parse `tailwind.config.js` `theme` + `theme.extend`; resolve `colors`, `spacing`, `fontSize`, `fontWeight`, `borderRadius` |
|
|
205
|
+
| `tailwind-v4` | Parse `@theme` block in the primary CSS entry point; no config file exists |
|
|
206
|
+
| `css-modules` | Parse each `.module.css` file for `--*` custom properties; also scan for Compose-style utility patterns |
|
|
207
|
+
| `sass` | Parse compiled CSS output (run `sass` if build script present); scan `.scss` for `$var` declarations |
|
|
208
|
+
| `css-in-js` | Static parse is limited (values are runtime JS expressions); rely more heavily on the runtime `getComputedStyle` pass; flag all JS-expression values in `token-gaps.json` |
|
|
209
|
+
| `plain-css` | Parse all `--*` custom properties in CSS files imported by the entry point |
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# High-Risk Surface Triage — Stage 1
|
|
2
|
+
|
|
3
|
+
Triage runs during Stage 1 (static analysis), **before any code generation**. Its
|
|
4
|
+
output is `risk-triage.json`. Every surface in the tier catalog below is evaluated
|
|
5
|
+
against every discovered usage in the source. Tier assignment is final for a given
|
|
6
|
+
iOS floor — it is not re-evaluated per component.
|
|
7
|
+
|
|
8
|
+
Source: findings.md RQ6 (Android→iOS pilot 2507.16037; lottie-ios 4.3; rive-ios;
|
|
9
|
+
Stripe iOS; Firebase iOS; Google Maps SPM; Apple WWDC; WebRTC iOS).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Tier definitions
|
|
14
|
+
|
|
15
|
+
| Tier | Name | What the skill emits | Compiler behavior | Human action required |
|
|
16
|
+
|---|---|---|---|---|
|
|
17
|
+
| 1 | **Auto** | Full, correct native implementation | Compiles and runs | Verify behavior, no code change expected |
|
|
18
|
+
| 2 | **Assisted** | Compiling stub with `// VERIFY` comment at every deviation | Compiles; may not match source behavior exactly | Review marked deviations; test on device |
|
|
19
|
+
| 3 | **Human-only** | Non-compiling stub with `fatalError` + `// OMC-CONVERSION: HUMAN-ONLY` block | **Does not compile by design** | Must be replaced before the app ships |
|
|
20
|
+
|
|
21
|
+
Tier 3 stubs **must fail to ship**. Using `fatalError`/`preconditionFailure`
|
|
22
|
+
ensures the Xcode build reminder is the app crashing at the stub call site during
|
|
23
|
+
testing — not a subtle runtime wrong behavior that reaches users. (findings.md RQ6
|
|
24
|
+
cites the 2507.16037 pilot: 43.2% of auto-converted files were invalid with no
|
|
25
|
+
clean build "without substantial human effort".)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## iOS floor awareness
|
|
30
|
+
|
|
31
|
+
Some conversions are only available above a minimum iOS version. When
|
|
32
|
+
`--ios-floor` is below the listed floor, the tier upgrades one level (Tier 1 →
|
|
33
|
+
Tier 2 if a workaround exists, Tier 2 → Tier 3 if not).
|
|
34
|
+
|
|
35
|
+
| API | Minimum iOS |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `KeyframeAnimator` | 17 |
|
|
38
|
+
| `scrollTransition` | 17 |
|
|
39
|
+
| `onScrollGeometryChange` | 18 |
|
|
40
|
+
| Swift Charts (`Chart`) | 16 |
|
|
41
|
+
| `Canvas` | 15 |
|
|
42
|
+
| `Layout` protocol | 16 |
|
|
43
|
+
| `AVPlayer` with HLS | 7 (always available in v1 scope) |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Tier catalog
|
|
48
|
+
|
|
49
|
+
Detection signal: file/line reference from static scan + grep of source, not
|
|
50
|
+
runtime behavior. The `detect` column is what `scripts/detect-stack.mjs` and the
|
|
51
|
+
Stage 1 static analyzer grep for.
|
|
52
|
+
|
|
53
|
+
| Surface | Detection signal in source | Native iOS counterpart | Tier | Fidelity risk |
|
|
54
|
+
|---|---|---|---|---|
|
|
55
|
+
| **Lottie `.json` / `.lottie`** | `lottie-web` dep; `new Lottie.loadAnimation`; `.lottie` file references | `lottie-ios 4.3` — same asset file, `LottieAnimationView` | **1 Auto** | Low — asset file identical, timing matches |
|
|
56
|
+
| **Rive `.riv`** | `@rive-app/canvas` dep; `new Rive(...)` with `.riv` file | `rive-ios` — same `.riv` asset, `RiveViewModel` | **1 Auto** | Low — asset file identical |
|
|
57
|
+
| **REST + JSON** | `fetch('/api/...')`, `axios.get`, `XMLHttpRequest` JSON endpoints | `URLSession.shared.data(from:)` async/await | **1 Auto** | None — semantics equivalent; ATS flag applies to `http://` |
|
|
58
|
+
| **HLS `<video>`** | `<video src="...m3u8">`, HLS.js dep | `AVPlayer` + `AVPlayerViewController` or custom `VideoPlayer` | **1 Auto** | Low — HLS is a first-class iOS media format |
|
|
59
|
+
| **`localStorage` KV** | `localStorage.getItem`, `localStorage.setItem` | `UserDefaults.standard` | **1 Auto** (non-secrets only) | **Critical caveat:** auth tokens/secrets must NOT go to UserDefaults — see anti-pattern section |
|
|
60
|
+
| **Chart.js / D3 charts** | `chart.js` dep; `new Chart(ctx, {type:...})`; `d3` dep with `d3.select` | Swift Charts (`Chart`) iOS 16+ | **2 Assisted** | Medium — data series ports cleanly; custom chart types (radar, custom scales) may not |
|
|
61
|
+
| **Static SVG** | Inline `<svg>` elements or `.svg` file `<img>` embeds with no animation | SwiftUI `Path` / `Image(systemName:)` / `Canvas` | **2 Assisted** | Medium — simple shapes port; complex filters, patterns, and gradients require `// VERIFY` |
|
|
62
|
+
| **Scroll-linked effects** | `window.addEventListener('scroll', ...)`, `IntersectionObserver`, `scroll-timeline` CSS | `.scrollTransition` (iOS 17+) / `onScrollGeometryChange` (iOS 18+) | **2 Assisted** | Medium — parallax and fade effects port; physics-based scroll effects are Tier 3 |
|
|
63
|
+
| **Maps (basic region + markers)** | `google.maps.Map`, `mapboxgl.Map`, `<MapContainer>` (leaflet) basic usage | `MapKit` / `Map` SwiftUI view (iOS 17+) | **2 Assisted** | Medium — region display and pin markers port; custom tile layers, routing UI, Street View are Tier 3 |
|
|
64
|
+
| **GSAP / CSS keyframes (linear/cubic)** | `gsap.to(...)` linear/cubic easing; `@keyframes` with `from`/`to` or step keyframes | `KeyframeAnimator` (iOS 17+) / `withAnimation(.easeInOut)` | **2 Assisted** | Medium — simple easing ports; spring physics, morphing, and stagger sequences are Tier 3 |
|
|
65
|
+
| **`http://` REST endpoints** | `fetch('http://...')` or `axios.get('http://...')` with non-TLS scheme | `URLSession` with ATS exemption or enforce TLS | **2 Assisted** | High — ATS blocks `http://` by default; emit `// WARNING: ATS — this URL must be upgraded to HTTPS or an ATS exception added to Info.plist` |
|
|
66
|
+
| **`IndexedDB` / complex storage** | `indexedDB.open(...)`, `idb` dep | No direct equivalent; use CoreData, SwiftData (iOS 17+), or SQLite | **2 Assisted** | High — data model ports; query API is completely different |
|
|
67
|
+
| **Canvas 2D (non-chart)** | `canvas.getContext('2d')`, `ctx.drawImage`, `ctx.fillRect` as primary rendering | SwiftUI `Canvas` (iOS 15+) / `drawRect` in `UIView` | **2 Assisted** (simple drawing) / **3** (pixel-manipulation shaders) | High — drawing commands port individually; `getImageData`/`putImageData` pixel manipulation is Tier 3 |
|
|
68
|
+
| **WebGL / WebGPU** | `canvas.getContext('webgl')`, `canvas.getContext('webgpu')`, `three.js`, `babylon.js` deps | Metal / MetalKit / RealityKit (requires GLSL→MSL translation, state model redesign) | **3 Human-only** | Critical — GLSL and WGSL do not mechanically translate to MSL; coordinate system, depth buffer conventions, and GPU state model differ; no automatable path |
|
|
69
|
+
| **`requestAnimationFrame` physics** | `requestAnimationFrame` in a game loop or physics update; Matter.js, Cannon.js deps | UIKit `CADisplayLink` or custom physics engine | **3 Human-only** | Critical — frame-loop physics is architectural; no declarative SwiftUI equivalent |
|
|
70
|
+
| **WebRTC** | `RTCPeerConnection`, `navigator.mediaDevices.getUserMedia`, `simple-peer` dep | `WebRTC.framework` (Google) or `LiveKit` SDK; requires entitlements + provisioning | **3 Human-only** | Critical — signaling protocol, ICE, and media pipeline require full reimplementation |
|
|
71
|
+
| **Stripe.js / payment surfaces** | `@stripe/stripe-js`, `loadStripe(...)`, `CardElement` | Stripe iOS SDK + Apple Pay entitlement | **3 Human-only** | Critical — publishable key handling, webhook secrets, and PCI compliance require human audit; never auto-port |
|
|
72
|
+
| **Firebase / OAuth provisioning** | `firebase/auth`, `GoogleSignIn`, `signInWithPopup` | Firebase iOS SDK / GoogleSignIn iOS; requires `GoogleService-Info.plist`, URL schemes, entitlements | **3 Human-only** | High — client IDs, redirect URIs, and entitlement provisioning cannot be inferred from web config |
|
|
73
|
+
| **Analytics / ATT** | `gtag`, `mixpanel`, `amplitude`, `posthog`; any event tracking | ATT framework (`AppTrackingTransparency`); native analytics SDK | **3 Human-only** | High — ATT permission prompt must appear before any IDFA access; timing and phrasing are legally significant in some jurisdictions |
|
|
74
|
+
| **`SessionStorage` / auth tokens in storage** | `sessionStorage.setItem('token', ...)`, `localStorage.setItem('authToken', ...)` | `Keychain` via `Security.framework` | **3 Human-only** | Critical — see anti-pattern section |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Anti-pattern call-out (never emit these)
|
|
79
|
+
|
|
80
|
+
These three patterns are the canonical examples of **confident, compiling, subtly
|
|
81
|
+
wrong code** — the exact failure mode the skill forbids.
|
|
82
|
+
|
|
83
|
+
### 1. Auth tokens in UserDefaults (not Keychain)
|
|
84
|
+
```swift
|
|
85
|
+
// WRONG — never emit this for auth tokens
|
|
86
|
+
UserDefaults.standard.set(token, forKey: "authToken")
|
|
87
|
+
|
|
88
|
+
// Correct — emit a Tier-3 stub instead
|
|
89
|
+
// OMC-CONVERSION: HUMAN-ONLY
|
|
90
|
+
// Reason: auth tokens must be stored in Keychain (Security.framework kSecClassGenericPassword),
|
|
91
|
+
// not UserDefaults. UserDefaults is not encrypted at rest and is accessible without the
|
|
92
|
+
// Secure Enclave. Port this using SecItemAdd/SecItemCopyMatching or a Keychain wrapper library.
|
|
93
|
+
preconditionFailure("Token storage not implemented — see conversion-report.json")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 2. ATS-dropped `http://` URLs
|
|
97
|
+
```swift
|
|
98
|
+
// WRONG — compiles but ATS blocks this at runtime on all iOS apps without an exception
|
|
99
|
+
let url = URL(string: "http://api.example.com/data")!
|
|
100
|
+
|
|
101
|
+
// Correct — emit Tier-2 stub with explicit warning
|
|
102
|
+
// VERIFY: ATS blocks http:// by default. Either:
|
|
103
|
+
// (a) Upgrade the server to https:// (preferred), or
|
|
104
|
+
// (b) Add NSAppTransportSecurity > NSAllowsArbitraryLoads exception to Info.plist (not recommended for production).
|
|
105
|
+
let url = URL(string: "http://api.example.com/data")! // ATS WARNING — see above
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 3. Fake-timed `withAnimation` (mimicking CSS duration with a hardcoded constant)
|
|
109
|
+
```swift
|
|
110
|
+
// WRONG — not an animation port, it is a guess that will look wrong on different devices
|
|
111
|
+
withAnimation(.easeInOut(duration: 0.3)) { ... }
|
|
112
|
+
|
|
113
|
+
// Correct for Tier-2 (when CSS timing is known):
|
|
114
|
+
// VERIFY: CSS animation was 'transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
|
|
115
|
+
// The cubic-bezier maps to approximately .timingCurve(0.4, 0, 0.2, 1, duration: 0.3)
|
|
116
|
+
// Verify visually against the reference render.
|
|
117
|
+
withAnimation(.timingCurve(0.4, 0, 0.2, 1, duration: 0.3)) { ... } // VERIFY
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Tier-3 non-compiling stub format
|
|
123
|
+
|
|
124
|
+
Every Tier-3 stub must include the machine-parseable block. This format allows
|
|
125
|
+
`conversion-report.json` to be generated by grep, not by LLM post-processing.
|
|
126
|
+
|
|
127
|
+
```swift
|
|
128
|
+
// OMC-CONVERSION: HUMAN-ONLY
|
|
129
|
+
// surface: WebGL
|
|
130
|
+
// file: src/components/Globe.tsx
|
|
131
|
+
// reason: WebGL (Three.js) cannot be automatically converted to Metal/MetalKit.
|
|
132
|
+
// GLSL shaders require manual translation to MSL. GPU state model and coordinate
|
|
133
|
+
// conventions differ. Suggested native counterpart: Metal + SceneKit or RealityKit.
|
|
134
|
+
// action: Replace this stub with a Metal-based implementation before shipping.
|
|
135
|
+
struct GlobeView: View {
|
|
136
|
+
var body: some View {
|
|
137
|
+
fatalError("GlobeView: WebGL conversion not implemented — OMC-CONVERSION: HUMAN-ONLY")
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The `// OMC-CONVERSION: HUMAN-ONLY` marker on the first line is the grep anchor.
|
|
143
|
+
Fields `surface`, `file`, and `reason` are on subsequent `//` lines in `key: value`
|
|
144
|
+
format. The `fatalError` is the last statement in `body`.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## `conversion-report.json` schema
|
|
149
|
+
|
|
150
|
+
Aggregated at Stage 7. One entry per triaged surface (all tiers — Tier 1/2 entries
|
|
151
|
+
confirm what was auto-handled; Tier 3 entries are the required human action list).
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"schema": "h5-to-swiftui/conversion-report@1",
|
|
156
|
+
"generated_at": "2026-05-19T12:00:00Z",
|
|
157
|
+
"ios_floor": 17,
|
|
158
|
+
"surfaces": [
|
|
159
|
+
{
|
|
160
|
+
"surface": "WebGL",
|
|
161
|
+
"file": "Sources/App/Globe/GlobeView.swift",
|
|
162
|
+
"line": 12,
|
|
163
|
+
"severity": "critical",
|
|
164
|
+
"tier": 3,
|
|
165
|
+
"native_counterpart": "Metal + SceneKit or RealityKit",
|
|
166
|
+
"action_required": "Replace fatalError stub with Metal-based implementation; translate GLSL shaders to MSL manually"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"surface": "Lottie",
|
|
170
|
+
"file": "Sources/App/Onboarding/OnboardingAnimationView.swift",
|
|
171
|
+
"line": 8,
|
|
172
|
+
"severity": "none",
|
|
173
|
+
"tier": 1,
|
|
174
|
+
"native_counterpart": "lottie-ios 4.3 LottieAnimationView",
|
|
175
|
+
"action_required": "None — auto-converted; verify animation timing on device"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"surface": "http-endpoint",
|
|
179
|
+
"file": "Sources/App/Network/APIClient.swift",
|
|
180
|
+
"line": 34,
|
|
181
|
+
"severity": "high",
|
|
182
|
+
"tier": 2,
|
|
183
|
+
"native_counterpart": "URLSession — upgrade URL to https://",
|
|
184
|
+
"action_required": "Upgrade http:// to https:// or add ATS exception to Info.plist"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"summary": {
|
|
188
|
+
"tier1_count": 3,
|
|
189
|
+
"tier2_count": 2,
|
|
190
|
+
"tier3_count": 1,
|
|
191
|
+
"human_action_required": true
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Field | Type | Notes |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `surface` | string | Short surface name from the tier catalog (e.g. `"WebGL"`, `"Lottie"`, `"REST"`) |
|
|
199
|
+
| `file` | string | Output Swift file path (not input H5 file) |
|
|
200
|
+
| `line` | integer | Line number of the stub or generated call site in the Swift file |
|
|
201
|
+
| `severity` | string | `"critical"` \| `"high"` \| `"medium"` \| `"low"` \| `"none"` |
|
|
202
|
+
| `tier` | integer | 1, 2, or 3 |
|
|
203
|
+
| `native_counterpart` | string | Specific framework/API/library to use |
|
|
204
|
+
| `action_required` | string | Concrete instruction for the human reviewer |
|
|
205
|
+
|
|
206
|
+
The `conversion-report.json` is the primary deliverable for communicating what a
|
|
207
|
+
human must finish. The final run summary (`convergence-summary.json`) must lead
|
|
208
|
+
with `"needs-human": true` and the Tier-3 count when any Tier-3 surfaces are
|
|
209
|
+
present.
|