@jhm1909/ag-kit 0.1.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/.agent/ARCHITECTURE.md +189 -0
- package/.agent/known-registries.json +181 -0
- package/.agent/mcp_config.json +19 -0
- package/.agent/rules/clean-code.md +107 -0
- package/.agent/rules/documents.md +177 -0
- package/.agent/rules/git-workflow.md +68 -0
- package/.agent/rules/nano-banana.md +46 -0
- package/.agent/rules/research.md +35 -0
- package/.agent/rules/skill-loading.md +100 -0
- package/.agent/rules/skill-suggestion.md +47 -0
- package/.agent/rules/testing.md +52 -0
- package/.agent/rules/workflow-advisor.md +108 -0
- package/.agent/rules/workflow-skill-convention.md +127 -0
- package/.agent/skills/ai-engineer/SKILL.md +824 -0
- package/.agent/skills/ai-engineer/references/agentic-patterns.md +329 -0
- package/.agent/skills/ai-engineer/references/evaluation.md +493 -0
- package/.agent/skills/ai-engineer/references/llm.md +490 -0
- package/.agent/skills/ai-engineer/references/rag-advanced.md +444 -0
- package/.agent/skills/ai-engineer/references/serving-optimization.md +531 -0
- package/.agent/skills/ai-engineer/vector-db/README.md +137 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +41 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/backend-developer/SKILL.md +763 -0
- package/.agent/skills/backend-developer/references/general-patterns.md +65 -0
- package/.agent/skills/backend-developer/references/go-echo.md +68 -0
- package/.agent/skills/backend-developer/references/go-gin.md +76 -0
- package/.agent/skills/backend-developer/references/java-springboot.md +83 -0
- package/.agent/skills/backend-developer/references/node-express.md +64 -0
- package/.agent/skills/backend-developer/references/node-nestjs.md +69 -0
- package/.agent/skills/backend-developer/references/python-django.md +67 -0
- package/.agent/skills/backend-developer/references/python-fastapi.md +80 -0
- package/.agent/skills/blockchain-engineer/SKILL.md +975 -0
- package/.agent/skills/blockchain-engineer/references/deployment.md +28 -0
- package/.agent/skills/blockchain-engineer/references/evm.md +14 -0
- package/.agent/skills/blockchain-engineer/references/mechanisms.md +32 -0
- package/.agent/skills/blockchain-engineer/references/solidity.md +32 -0
- package/.agent/skills/business-analysis/SKILL.md +85 -0
- package/.agent/skills/business-analysis/references/best-practices/diagrams.md +141 -0
- package/.agent/skills/business-analysis/references/domains/ai-agent.md +94 -0
- package/.agent/skills/business-analysis/references/domains/blockchain-dapp.md +86 -0
- package/.agent/skills/business-analysis/references/domains/ecommerce.md +77 -0
- package/.agent/skills/business-analysis/references/domains/education.md +42 -0
- package/.agent/skills/business-analysis/references/domains/fintech.md +44 -0
- package/.agent/skills/business-analysis/references/domains/fnb.md +82 -0
- package/.agent/skills/business-analysis/references/domains/healthtech.md +44 -0
- package/.agent/skills/business-analysis/references/domains/internal-tools.md +38 -0
- package/.agent/skills/business-analysis/references/domains/marketplace.md +52 -0
- package/.agent/skills/business-analysis/references/domains/saas.md +36 -0
- package/.agent/skills/business-analysis/references/workflows/collaboration.md +41 -0
- package/.agent/skills/business-analysis/scripts/verify_mermaid.py +86 -0
- package/.agent/skills/business-analysis/templates/brd.md +46 -0
- package/.agent/skills/business-analysis/templates/change-request.md +41 -0
- package/.agent/skills/business-analysis/templates/prd-functional.md +38 -0
- package/.agent/skills/business-analysis/templates/use-case.md +40 -0
- package/.agent/skills/business-analysis/templates/user-story-detailed.md +36 -0
- package/.agent/skills/code-review/SKILL.md +113 -0
- package/.agent/skills/code-review/references/code-review-reception.md +209 -0
- package/.agent/skills/code-review/references/differential_review.md +59 -0
- package/.agent/skills/code-review/references/requesting-code-review.md +105 -0
- package/.agent/skills/code-review/references/spec_compliance.md +43 -0
- package/.agent/skills/code-review/references/verification-before-completion.md +139 -0
- package/.agent/skills/context-engineering/SKILL.md +68 -0
- package/.agent/skills/context-engineering/references/context-compression.md +84 -0
- package/.agent/skills/context-engineering/references/context-degradation.md +93 -0
- package/.agent/skills/context-engineering/references/context-fundamentals.md +75 -0
- package/.agent/skills/context-engineering/references/context-optimization.md +82 -0
- package/.agent/skills/context-engineering/references/evaluation.md +89 -0
- package/.agent/skills/context-engineering/references/memory-systems.md +88 -0
- package/.agent/skills/context-engineering/references/multi-agent-patterns.md +90 -0
- package/.agent/skills/context-engineering/references/project-development.md +97 -0
- package/.agent/skills/context-engineering/references/tool-design.md +86 -0
- package/.agent/skills/debugging/SKILL.md +60 -0
- package/.agent/skills/debugging/references/defense-in-depth.md +130 -0
- package/.agent/skills/debugging/references/root-cause-tracing.md +177 -0
- package/.agent/skills/debugging/references/systematic-debugging.md +295 -0
- package/.agent/skills/debugging/references/verification-before-completion.md +142 -0
- package/.agent/skills/designer/SKILL.md +159 -0
- package/.agent/skills/designer/concepts/apple-glass.md +48 -0
- package/.agent/skills/designer/concepts/aurora-gradients.md +26 -0
- package/.agent/skills/designer/concepts/bento-grids.md +14 -0
- package/.agent/skills/designer/concepts/claymorphism.md +27 -0
- package/.agent/skills/designer/concepts/neo-brutalism.md +32 -0
- package/.agent/skills/designer/data/app-interface.csv +31 -0
- package/.agent/skills/designer/data/charts.csv +26 -0
- package/.agent/skills/designer/data/colors.csv +162 -0
- package/.agent/skills/designer/data/design.csv +1776 -0
- package/.agent/skills/designer/data/icons.csv +106 -0
- package/.agent/skills/designer/data/landing.csv +35 -0
- package/.agent/skills/designer/data/products.csv +162 -0
- package/.agent/skills/designer/data/react-performance.csv +45 -0
- package/.agent/skills/designer/data/styles.csv +85 -0
- package/.agent/skills/designer/data/typography.csv +74 -0
- package/.agent/skills/designer/data/ui-reasoning.csv +162 -0
- package/.agent/skills/designer/data/ux-guidelines.csv +100 -0
- package/.agent/skills/designer/references/accessibility.md +172 -0
- package/.agent/skills/designer/references/branding.md +88 -0
- package/.agent/skills/designer/references/color-theory.md +139 -0
- package/.agent/skills/designer/references/creation.md +118 -0
- package/.agent/skills/designer/references/design-systems.md +219 -0
- package/.agent/skills/designer/references/frontend_design_aesthetics.md +57 -0
- package/.agent/skills/designer/references/layout.md +200 -0
- package/.agent/skills/designer/references/motion.md +92 -0
- package/.agent/skills/designer/references/review.md +100 -0
- package/.agent/skills/designer/references/trends.md +209 -0
- package/.agent/skills/designer/references/typography.md +190 -0
- package/.agent/skills/designer/scripts/remove_background.py +135 -0
- package/.agent/skills/designer/scripts/ui-search/__pycache__/core.cpython-314.pyc +0 -0
- package/.agent/skills/designer/scripts/ui-search/__pycache__/design_system.cpython-314.pyc +0 -0
- package/.agent/skills/designer/scripts/ui-search/core.py +217 -0
- package/.agent/skills/designer/scripts/ui-search/design_system.py +1067 -0
- package/.agent/skills/designer/scripts/ui-search/search.py +114 -0
- package/.agent/skills/designer/templates/design-motion-spec.md +30 -0
- package/.agent/skills/devops-engineer/SKILL.md +90 -0
- package/.agent/skills/devops-engineer/docker-compose/README.md +47 -0
- package/.agent/skills/devops-engineer/references/ci-cd-pipelines.md +76 -0
- package/.agent/skills/devops-engineer/references/cloud-providers.md +57 -0
- package/.agent/skills/devops-engineer/references/codebase-normalization.md +104 -0
- package/.agent/skills/devops-engineer/references/container-orchestration.md +69 -0
- package/.agent/skills/devops-engineer/references/iac-tools.md +63 -0
- package/.agent/skills/devops-engineer/references/observability-security.md +45 -0
- package/.agent/skills/devops-engineer/references/vercel-supabase.md +17 -0
- package/.agent/skills/devops-engineer/templates/release-notes.md +8 -0
- package/.agent/skills/frontend-developer/SKILL.md +125 -0
- package/.agent/skills/frontend-developer/react-nextjs/README.md +90 -0
- package/.agent/skills/frontend-developer/references/angular.md +52 -0
- package/.agent/skills/frontend-developer/references/composition_patterns.md +60 -0
- package/.agent/skills/frontend-developer/references/core-performance.md +68 -0
- package/.agent/skills/frontend-developer/references/modern-signals.md +43 -0
- package/.agent/skills/frontend-developer/references/react_performance_rules.md +55 -0
- package/.agent/skills/frontend-developer/references/vue-nuxt.md +55 -0
- package/.agent/skills/frontend-developer/scripts/validate_compliance.py +65 -0
- package/.agent/skills/frontend-developer/threejs/README.md +89 -0
- package/.agent/skills/frontend-developer/threejs/animation.md +552 -0
- package/.agent/skills/frontend-developer/threejs/fundamentals.md +488 -0
- package/.agent/skills/frontend-developer/threejs/geometry.md +548 -0
- package/.agent/skills/frontend-developer/threejs/interaction.md +660 -0
- package/.agent/skills/frontend-developer/threejs/lighting.md +481 -0
- package/.agent/skills/frontend-developer/threejs/loaders.md +623 -0
- package/.agent/skills/frontend-developer/threejs/materials.md +520 -0
- package/.agent/skills/frontend-developer/threejs/postprocessing.md +602 -0
- package/.agent/skills/frontend-developer/threejs/router.json +181 -0
- package/.agent/skills/frontend-developer/threejs/shaders.md +642 -0
- package/.agent/skills/frontend-developer/threejs/textures.md +628 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/lead-architect/SKILL.md +85 -0
- package/.agent/skills/lead-architect/references/application-architecture.md +70 -0
- package/.agent/skills/lead-architect/references/infrastructure.md +51 -0
- package/.agent/skills/lead-architect/references/process.md +42 -0
- package/.agent/skills/lead-architect/references/system-architecture.md +62 -0
- package/.agent/skills/lead-architect/references/web-fullstack.md +82 -0
- package/.agent/skills/lead-architect/templates/adr.md +62 -0
- package/.agent/skills/lead-architect/templates/rfc.md +46 -0
- package/.agent/skills/lead-architect/templates/sdd.md +62 -0
- package/.agent/skills/lead-architect/templates/technical-spec.md +61 -0
- package/.agent/skills/marketer/SKILL.md +66 -0
- package/.agent/skills/marketer/remotion-best-practices/SKILL.md +58 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/3d.md +86 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/animations.md +29 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/assets.md +78 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/audio.md +172 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/calculate-metadata.md +104 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/can-decode.md +75 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/charts.md +58 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/compositions.md +146 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/display-captions.md +126 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/extract-frames.md +229 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/fonts.md +152 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/get-video-duration.md +58 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/gifs.md +138 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/images.md +130 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/import-srt-captions.md +67 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/lottie.md +68 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/measuring-text.md +143 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/sequencing.md +106 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/tailwind.md +11 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/text-animations.md +20 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/timing.md +179 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/transcribe-captions.md +19 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/transitions.md +122 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/trimming.md +53 -0
- package/.agent/skills/marketer/remotion-best-practices/rules/videos.md +171 -0
- package/.agent/skills/mcp-builder/SKILL.md +76 -0
- package/.agent/skills/mcp-builder/references/evaluation.md +602 -0
- package/.agent/skills/mcp-builder/references/mcp_best_practices.md +249 -0
- package/.agent/skills/mcp-builder/references/node_mcp_server.md +970 -0
- package/.agent/skills/mcp-builder/references/python_mcp_server.md +719 -0
- package/.agent/skills/mobile-developer/SKILL.md +83 -0
- package/.agent/skills/mobile-developer/api-routes/SKILL.md +389 -0
- package/.agent/skills/mobile-developer/building-ui/SKILL.md +335 -0
- package/.agent/skills/mobile-developer/building-ui/references/animations.md +220 -0
- package/.agent/skills/mobile-developer/building-ui/references/controls.md +270 -0
- package/.agent/skills/mobile-developer/building-ui/references/form-sheet.md +227 -0
- package/.agent/skills/mobile-developer/building-ui/references/gradients.md +106 -0
- package/.agent/skills/mobile-developer/building-ui/references/icons.md +213 -0
- package/.agent/skills/mobile-developer/building-ui/references/media.md +198 -0
- package/.agent/skills/mobile-developer/building-ui/references/route-structure.md +229 -0
- package/.agent/skills/mobile-developer/building-ui/references/search.md +248 -0
- package/.agent/skills/mobile-developer/building-ui/references/storage.md +121 -0
- package/.agent/skills/mobile-developer/building-ui/references/tabs.md +368 -0
- package/.agent/skills/mobile-developer/building-ui/references/visual-effects.md +197 -0
- package/.agent/skills/mobile-developer/building-ui/references/webgpu-three.md +605 -0
- package/.agent/skills/mobile-developer/cicd-workflows/SKILL.md +107 -0
- package/.agent/skills/mobile-developer/cicd-workflows/scripts/fetch.js +109 -0
- package/.agent/skills/mobile-developer/cicd-workflows/scripts/package.json +11 -0
- package/.agent/skills/mobile-developer/cicd-workflows/scripts/validate.js +84 -0
- package/.agent/skills/mobile-developer/data-fetching/SKILL.md +508 -0
- package/.agent/skills/mobile-developer/deployment/SKILL.md +207 -0
- package/.agent/skills/mobile-developer/deployment/references/app-store-metadata.md +479 -0
- package/.agent/skills/mobile-developer/deployment/references/ios-app-store.md +355 -0
- package/.agent/skills/mobile-developer/deployment/references/play-store.md +246 -0
- package/.agent/skills/mobile-developer/deployment/references/testflight.md +58 -0
- package/.agent/skills/mobile-developer/deployment/references/workflows.md +200 -0
- package/.agent/skills/mobile-developer/dev-client/SKILL.md +181 -0
- package/.agent/skills/mobile-developer/tailwind-setup/SKILL.md +501 -0
- package/.agent/skills/mobile-developer/upgrading-expo/SKILL.md +116 -0
- package/.agent/skills/mobile-developer/upgrading-expo/references/new-architecture.md +79 -0
- package/.agent/skills/mobile-developer/upgrading-expo/references/react-19.md +79 -0
- package/.agent/skills/mobile-developer/upgrading-expo/references/react-compiler.md +59 -0
- package/.agent/skills/mobile-developer/use-dom/SKILL.md +434 -0
- package/.agent/skills/modern-python/SKILL.md +122 -0
- package/.agent/skills/project-manager/SKILL.md +110 -0
- package/.agent/skills/project-manager/references/ba-collaboration.md +62 -0
- package/.agent/skills/project-manager/references/discovery_process.md +52 -0
- package/.agent/skills/project-manager/references/jobs_to_be_done.md +51 -0
- package/.agent/skills/project-manager/references/prd_development.md +52 -0
- package/.agent/skills/project-manager/references/rules-guide.md +55 -0
- package/.agent/skills/project-manager/references/skill-creation.md +98 -0
- package/.agent/skills/project-manager/references/strategic-frameworks.md +62 -0
- package/.agent/skills/project-manager/references/task-decomposition.md +194 -0
- package/.agent/skills/project-manager/references/workflows-guide.md +44 -0
- package/.agent/skills/project-manager/router.json +160 -0
- package/.agent/skills/project-manager/scripts/compare_skill.py +177 -0
- package/.agent/skills/project-manager/scripts/encoding_utils.py +36 -0
- package/.agent/skills/project-manager/scripts/init_skill.py +190 -0
- package/.agent/skills/project-manager/scripts/quick_validate.py +123 -0
- package/.agent/skills/project-manager/templates/pm-strategy-one-pager.md +6 -0
- package/.agent/skills/project-manager/templates/prd-strategic.md +38 -0
- package/.agent/skills/project-manager/templates/skill-questionnaire.md +118 -0
- package/.agent/skills/project-manager/templates/user-story-simple.md +14 -0
- package/.agent/skills/prompt-engineer/SKILL.md +319 -0
- package/.agent/skills/prompt-engineer/skill-creator/README.md +47 -0
- package/.agent/skills/qa-tester/SKILL.md +142 -0
- package/.agent/skills/qa-tester/assets/README.md +8 -0
- package/.agent/skills/qa-tester/references/accessibility_testing.md +35 -0
- package/.agent/skills/qa-tester/references/agent_browser.md +38 -0
- package/.agent/skills/qa-tester/references/automation/api_testing.md +23 -0
- package/.agent/skills/qa-tester/references/automation/best_practices.md +14 -0
- package/.agent/skills/qa-tester/references/automation/jest_vitest.md +26 -0
- package/.agent/skills/qa-tester/references/automation/playwright.md +30 -0
- package/.agent/skills/qa-tester/references/e2e_testing.md +46 -0
- package/.agent/skills/qa-tester/references/integration_testing.md +39 -0
- package/.agent/skills/qa-tester/references/performance_testing.md +44 -0
- package/.agent/skills/qa-tester/references/property_based_testing.md +44 -0
- package/.agent/skills/qa-tester/references/security_audit.md +53 -0
- package/.agent/skills/qa-tester/references/security_testing.md +30 -0
- package/.agent/skills/qa-tester/references/sharp_edges.md +49 -0
- package/.agent/skills/qa-tester/references/static_analysis.md +52 -0
- package/.agent/skills/qa-tester/references/supply_chain_audit.md +54 -0
- package/.agent/skills/qa-tester/references/test_case_standards.md +96 -0
- package/.agent/skills/qa-tester/references/test_report_template.md +32 -0
- package/.agent/skills/qa-tester/references/unit_testing.md +50 -0
- package/.agent/skills/qa-tester/references/visual_testing.md +32 -0
- package/.agent/skills/qa-tester/templates/uat-plan.md +34 -0
- package/.agent/skills/research-first/SKILL.md +118 -0
- package/.agent/skills-manifest.json +264 -0
- package/.agent/workflows/absorb.md +176 -0
- package/.agent/workflows/bootstrap.md +91 -0
- package/.agent/workflows/brainstorm.md +168 -0
- package/.agent/workflows/break-tasks.md +77 -0
- package/.agent/workflows/commit.md +349 -0
- package/.agent/workflows/custom-behavior.md +64 -0
- package/.agent/workflows/debug.md +65 -0
- package/.agent/workflows/development.md +49 -0
- package/.agent/workflows/documentation.md +221 -0
- package/.agent/workflows/gen-tests.md +53 -0
- package/.agent/workflows/guide.md +196 -0
- package/.agent/workflows/implement-feature.md +182 -0
- package/.agent/workflows/install-skill.md +193 -0
- package/.agent/workflows/qa.md +54 -0
- package/.agent/workflows/ui-ux-design.md +108 -0
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/cli/index.js +345 -0
- package/cli/migrate-skills.js +113 -0
- package/cli/verify.js +291 -0
- package/package.json +49 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# React 19
|
|
2
|
+
|
|
3
|
+
React 19 is included in Expo SDK 54. This release simplifies several common patterns.
|
|
4
|
+
|
|
5
|
+
## Context Changes
|
|
6
|
+
|
|
7
|
+
### useContext → use
|
|
8
|
+
|
|
9
|
+
The `use` hook replaces `useContext`:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// Before (React 18)
|
|
13
|
+
import { useContext } from "react";
|
|
14
|
+
const value = useContext(MyContext);
|
|
15
|
+
|
|
16
|
+
// After (React 19)
|
|
17
|
+
import { use } from "react";
|
|
18
|
+
const value = use(MyContext);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- The `use` hook can also read promises, enabling Suspense-based data fetching.
|
|
22
|
+
- `use` can be called conditionally, this simplifies components that consume multiple contexts.
|
|
23
|
+
|
|
24
|
+
### Context.Provider → Context
|
|
25
|
+
|
|
26
|
+
Context providers no longer need the `.Provider` suffix:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
// Before (React 18)
|
|
30
|
+
<ThemeContext.Provider value={theme}>
|
|
31
|
+
{children}
|
|
32
|
+
</ThemeContext.Provider>
|
|
33
|
+
|
|
34
|
+
// After (React 19)
|
|
35
|
+
<ThemeContext value={theme}>
|
|
36
|
+
{children}
|
|
37
|
+
</ThemeContext>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## ref as a Prop
|
|
41
|
+
|
|
42
|
+
### Removing forwardRef
|
|
43
|
+
|
|
44
|
+
Components can now receive `ref` as a regular prop. `forwardRef` is no longer needed:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// Before (React 18)
|
|
48
|
+
import { forwardRef } from "react";
|
|
49
|
+
|
|
50
|
+
const Input = forwardRef<TextInput, Props>((props, ref) => {
|
|
51
|
+
return <TextInput ref={ref} {...props} />;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// After (React 19)
|
|
55
|
+
function Input({ ref, ...props }: Props & { ref?: React.Ref<TextInput> }) {
|
|
56
|
+
return <TextInput ref={ref} {...props} />;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Migration Steps
|
|
61
|
+
|
|
62
|
+
1. Remove `forwardRef` wrapper
|
|
63
|
+
2. Add `ref` to the props destructuring
|
|
64
|
+
3. Update the type to include `ref?: React.Ref<T>`
|
|
65
|
+
|
|
66
|
+
## Other React 19 Features
|
|
67
|
+
|
|
68
|
+
- **Actions** — Functions that handle async transitions
|
|
69
|
+
- **useOptimistic** — Optimistic UI updates
|
|
70
|
+
- **useFormStatus** — Form submission state (web)
|
|
71
|
+
- **Document Metadata** — Native `<title>` and `<meta>` support (web)
|
|
72
|
+
|
|
73
|
+
## Cleanup Checklist
|
|
74
|
+
|
|
75
|
+
When upgrading to SDK 54:
|
|
76
|
+
|
|
77
|
+
- [ ] Replace `useContext` with `use`
|
|
78
|
+
- [ ] Remove `.Provider` from Context components
|
|
79
|
+
- [ ] Remove `forwardRef` wrappers, use `ref` prop instead
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# React Compiler
|
|
2
|
+
|
|
3
|
+
React Compiler is stable in Expo SDK 54 and later. It automatically memoizes components and hooks, eliminating the need for manual `useMemo`, `useCallback`, and `React.memo`.
|
|
4
|
+
|
|
5
|
+
## Enabling React Compiler
|
|
6
|
+
|
|
7
|
+
Add to `app.json`:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"expo": {
|
|
12
|
+
"experiments": {
|
|
13
|
+
"reactCompiler": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What React Compiler Does
|
|
20
|
+
|
|
21
|
+
- Automatically memoizes components and values
|
|
22
|
+
- Eliminates unnecessary re-renders
|
|
23
|
+
- Removes the need for manual `useMemo` and `useCallback`
|
|
24
|
+
- Works with existing code without modifications
|
|
25
|
+
|
|
26
|
+
## Cleanup After Enabling
|
|
27
|
+
|
|
28
|
+
Once React Compiler is enabled, you can remove manual memoization:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
// Before (manual memoization)
|
|
32
|
+
const memoizedValue = useMemo(() => computeExpensive(a, b), [a, b]);
|
|
33
|
+
const memoizedCallback = useCallback(() => doSomething(a), [a]);
|
|
34
|
+
const MemoizedComponent = React.memo(MyComponent);
|
|
35
|
+
|
|
36
|
+
// After (React Compiler handles it)
|
|
37
|
+
const value = computeExpensive(a, b);
|
|
38
|
+
const callback = () => doSomething(a);
|
|
39
|
+
// Just use MyComponent directly
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- Expo SDK 54 or later
|
|
45
|
+
- New Architecture enabled (default in SDK 54+)
|
|
46
|
+
|
|
47
|
+
## Verifying It's Working
|
|
48
|
+
|
|
49
|
+
React Compiler runs at build time. Check the Metro bundler output for compilation messages. You can also use React DevTools to verify components are being optimized.
|
|
50
|
+
|
|
51
|
+
## Troubleshooting
|
|
52
|
+
|
|
53
|
+
If you encounter issues:
|
|
54
|
+
|
|
55
|
+
1. Ensure New Architecture is enabled
|
|
56
|
+
2. Clear Metro cache: `npx expo start --clear`
|
|
57
|
+
3. Check for incompatible patterns in your code (rare)
|
|
58
|
+
|
|
59
|
+
React Compiler is designed to work with idiomatic React code. If it can't safely optimize a component, it skips that component without breaking your app.
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: use-dom
|
|
3
|
+
description: >
|
|
4
|
+
Use Expo DOM components to run web code in a webview on native and as-is on web. Migrate web code to native incrementally.
|
|
5
|
+
license: MIT
|
|
6
|
+
compatibility: Claude Code, Cursor, Gemini CLI, GitHub Copilot
|
|
7
|
+
metadata:
|
|
8
|
+
author: jhm1909
|
|
9
|
+
version: "2.0.0"
|
|
10
|
+
domain: mobile
|
|
11
|
+
estimated_tokens: 5000
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Use DOM
|
|
15
|
+
|
|
16
|
+
## Knowledge Graph
|
|
17
|
+
|
|
18
|
+
- **extends**: [[mobile-developer]]
|
|
19
|
+
- **requires**: [[frontend-developer]]
|
|
20
|
+
- **suggests**: [[building-ui]]
|
|
21
|
+
- **conflicts**: []
|
|
22
|
+
- **enhances": []
|
|
23
|
+
- **moc": [[mobile-development-moc]]
|
|
24
|
+
|
|
25
|
+
## What are DOM Components?
|
|
26
|
+
|
|
27
|
+
DOM components allow web code to run verbatim in a webview on native platforms while rendering as-is on web. This enables using web-only libraries like `recharts`, `react-syntax-highlighter`, or any React web library in your Expo app without modification.
|
|
28
|
+
|
|
29
|
+
## When to Use DOM Components
|
|
30
|
+
|
|
31
|
+
Use DOM components when you need:
|
|
32
|
+
|
|
33
|
+
- **Web-only libraries** — Charts (recharts, chart.js), syntax highlighters, rich text editors, or any library that depends on DOM APIs
|
|
34
|
+
- **Migrating web code** — Bring existing React web components to native without rewriting
|
|
35
|
+
- **Complex HTML/CSS layouts** — When CSS features aren't available in React Native
|
|
36
|
+
- **iframes or embeds** — Embedding external content that requires a browser context
|
|
37
|
+
- **Canvas or WebGL** — Web graphics APIs not available natively
|
|
38
|
+
|
|
39
|
+
## When NOT to Use DOM Components
|
|
40
|
+
|
|
41
|
+
Avoid DOM components when:
|
|
42
|
+
|
|
43
|
+
- **Native performance is critical** — Webviews add overhead
|
|
44
|
+
- **Simple UI** — React Native components are more efficient for basic layouts
|
|
45
|
+
- **Deep native integration** — Use local modules instead for native APIs
|
|
46
|
+
- **Layout routes** — `_layout` files cannot be DOM components
|
|
47
|
+
|
|
48
|
+
## Basic DOM Component
|
|
49
|
+
|
|
50
|
+
Create a new file with the `'use dom';` directive at the top:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
// components/WebChart.tsx
|
|
54
|
+
"use dom";
|
|
55
|
+
|
|
56
|
+
export default function WebChart({
|
|
57
|
+
data,
|
|
58
|
+
}: {
|
|
59
|
+
data: number[];
|
|
60
|
+
dom: import("expo/dom").DOMProps;
|
|
61
|
+
}) {
|
|
62
|
+
return (
|
|
63
|
+
<div style={{ padding: 20 }}>
|
|
64
|
+
<h2>Chart Data</h2>
|
|
65
|
+
<ul>
|
|
66
|
+
{data.map((value, i) => (
|
|
67
|
+
<li key={i}>{value}</li>
|
|
68
|
+
))}
|
|
69
|
+
</ul>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Rules for DOM Components
|
|
76
|
+
|
|
77
|
+
1. **Must have `'use dom';` directive** at the top of the file
|
|
78
|
+
2. **Single default export** — One React component per file
|
|
79
|
+
3. **Own file** — Cannot be defined inline or combined with native components
|
|
80
|
+
4. **Serializable props only** — Strings, numbers, booleans, arrays, plain objects
|
|
81
|
+
5. **Include CSS in the component file** — DOM components run in isolated context
|
|
82
|
+
|
|
83
|
+
## The `dom` Prop
|
|
84
|
+
|
|
85
|
+
Every DOM component receives a special `dom` prop for webview configuration. Always type it in your props:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
"use dom";
|
|
89
|
+
|
|
90
|
+
interface Props {
|
|
91
|
+
content: string;
|
|
92
|
+
dom: import("expo/dom").DOMProps;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default function MyComponent({ content }: Props) {
|
|
96
|
+
return <div>{content}</div>;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Common `dom` Prop Options
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
// Disable body scrolling
|
|
104
|
+
<DOMComponent dom={{ scrollEnabled: false }} />
|
|
105
|
+
|
|
106
|
+
// Flow under the notch (disable safe area insets)
|
|
107
|
+
<DOMComponent dom={{ contentInsetAdjustmentBehavior: "never" }} />
|
|
108
|
+
|
|
109
|
+
// Control size manually
|
|
110
|
+
<DOMComponent dom={{ style: { width: 300, height: 400 } }} />
|
|
111
|
+
|
|
112
|
+
// Combine options
|
|
113
|
+
<DOMComponent
|
|
114
|
+
dom={{
|
|
115
|
+
scrollEnabled: false,
|
|
116
|
+
contentInsetAdjustmentBehavior: "never",
|
|
117
|
+
style: { width: '100%', height: 500 }
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Exposing Native Actions to the Webview
|
|
123
|
+
|
|
124
|
+
Pass async functions as props to expose native functionality to the DOM component:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
// app/index.tsx (native)
|
|
128
|
+
import { Alert } from "react-native";
|
|
129
|
+
import DOMComponent from "@/components/dom-component";
|
|
130
|
+
|
|
131
|
+
export default function Screen() {
|
|
132
|
+
return (
|
|
133
|
+
<DOMComponent
|
|
134
|
+
showAlert={async (message: string) => {
|
|
135
|
+
Alert.alert("From Web", message);
|
|
136
|
+
}}
|
|
137
|
+
saveData={async (data: { name: string; value: number }) => {
|
|
138
|
+
// Save to native storage, database, etc.
|
|
139
|
+
console.log("Saving:", data);
|
|
140
|
+
return { success: true };
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
// components/dom-component.tsx
|
|
149
|
+
"use dom";
|
|
150
|
+
|
|
151
|
+
interface Props {
|
|
152
|
+
showAlert: (message: string) => Promise<void>;
|
|
153
|
+
saveData: (data: {
|
|
154
|
+
name: string;
|
|
155
|
+
value: number;
|
|
156
|
+
}) => Promise<{ success: boolean }>;
|
|
157
|
+
dom?: import("expo/dom").DOMProps;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default function DOMComponent({ showAlert, saveData }: Props) {
|
|
161
|
+
const handleClick = async () => {
|
|
162
|
+
await showAlert("Hello from the webview!");
|
|
163
|
+
const result = await saveData({ name: "test", value: 42 });
|
|
164
|
+
console.log("Save result:", result);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return <button onClick={handleClick}>Trigger Native Action</button>;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Using Web Libraries
|
|
172
|
+
|
|
173
|
+
DOM components can use any web library:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
// components/syntax-highlight.tsx
|
|
177
|
+
"use dom";
|
|
178
|
+
|
|
179
|
+
import SyntaxHighlighter from "react-syntax-highlighter";
|
|
180
|
+
import { docco } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
|
181
|
+
|
|
182
|
+
interface Props {
|
|
183
|
+
code: string;
|
|
184
|
+
language: string;
|
|
185
|
+
dom?: import("expo/dom").DOMProps;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export default function SyntaxHighlight({ code, language }: Props) {
|
|
189
|
+
return (
|
|
190
|
+
<SyntaxHighlighter language={language} style={docco}>
|
|
191
|
+
{code}
|
|
192
|
+
</SyntaxHighlighter>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
// components/chart.tsx
|
|
199
|
+
"use dom";
|
|
200
|
+
|
|
201
|
+
import {
|
|
202
|
+
LineChart,
|
|
203
|
+
Line,
|
|
204
|
+
XAxis,
|
|
205
|
+
YAxis,
|
|
206
|
+
CartesianGrid,
|
|
207
|
+
Tooltip,
|
|
208
|
+
} from "recharts";
|
|
209
|
+
|
|
210
|
+
interface Props {
|
|
211
|
+
data: Array<{ name: string; value: number }>;
|
|
212
|
+
dom: import("expo/dom").DOMProps;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export default function Chart({ data }: Props) {
|
|
216
|
+
return (
|
|
217
|
+
<LineChart width={400} height={300} data={data}>
|
|
218
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
219
|
+
<XAxis dataKey="name" />
|
|
220
|
+
<YAxis />
|
|
221
|
+
<Tooltip />
|
|
222
|
+
<Line type="monotone" dataKey="value" stroke="#8884d8" />
|
|
223
|
+
</LineChart>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## CSS in DOM Components
|
|
229
|
+
|
|
230
|
+
CSS imports must be in the DOM component file since they run in isolated context:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
// components/styled-component.tsx
|
|
234
|
+
"use dom";
|
|
235
|
+
|
|
236
|
+
import "@/styles.css"; // CSS file in same directory
|
|
237
|
+
|
|
238
|
+
export default function StyledComponent({
|
|
239
|
+
dom,
|
|
240
|
+
}: {
|
|
241
|
+
dom: import("expo/dom").DOMProps;
|
|
242
|
+
}) {
|
|
243
|
+
return (
|
|
244
|
+
<div className="container">
|
|
245
|
+
<h1 className="title">Styled Content</h1>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Or use inline styles / CSS-in-JS:
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
"use dom";
|
|
255
|
+
|
|
256
|
+
const styles = {
|
|
257
|
+
container: {
|
|
258
|
+
padding: 20,
|
|
259
|
+
backgroundColor: "#f0f0f0",
|
|
260
|
+
},
|
|
261
|
+
title: {
|
|
262
|
+
fontSize: 24,
|
|
263
|
+
color: "#333",
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export default function StyledComponent({
|
|
268
|
+
dom,
|
|
269
|
+
}: {
|
|
270
|
+
dom: import("expo/dom").DOMProps;
|
|
271
|
+
}) {
|
|
272
|
+
return (
|
|
273
|
+
<div style={styles.container}>
|
|
274
|
+
<h1 style={styles.title}>Styled Content</h1>
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Expo Router in DOM Components
|
|
281
|
+
|
|
282
|
+
The expo-router `<Link />` component and router API work inside DOM components:
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
"use dom";
|
|
286
|
+
|
|
287
|
+
import { Link, useRouter } from "expo-router";
|
|
288
|
+
|
|
289
|
+
export default function Navigation({
|
|
290
|
+
dom,
|
|
291
|
+
}: {
|
|
292
|
+
dom: import("expo/dom").DOMProps;
|
|
293
|
+
}) {
|
|
294
|
+
const router = useRouter();
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<nav>
|
|
298
|
+
<Link href="/about">About</Link>
|
|
299
|
+
<button onClick={() => router.push("/settings")}>Settings</button>
|
|
300
|
+
</nav>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Router APIs That Require Props
|
|
306
|
+
|
|
307
|
+
These hooks don't work directly in DOM components because they need synchronous access to native routing state:
|
|
308
|
+
|
|
309
|
+
- `useLocalSearchParams()`
|
|
310
|
+
- `useGlobalSearchParams()`
|
|
311
|
+
- `usePathname()`
|
|
312
|
+
- `useSegments()`
|
|
313
|
+
- `useRootNavigation()`
|
|
314
|
+
- `useRootNavigationState()`
|
|
315
|
+
|
|
316
|
+
**Solution:** Read these values in the native parent and pass as props:
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
// app/[id].tsx (native)
|
|
320
|
+
import { useLocalSearchParams, usePathname } from "expo-router";
|
|
321
|
+
import DOMComponent from "@/components/dom-component";
|
|
322
|
+
|
|
323
|
+
export default function Screen() {
|
|
324
|
+
const { id } = useLocalSearchParams();
|
|
325
|
+
const pathname = usePathname();
|
|
326
|
+
|
|
327
|
+
return <DOMComponent id={id as string} pathname={pathname} />;
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
```tsx
|
|
332
|
+
// components/dom-component.tsx
|
|
333
|
+
"use dom";
|
|
334
|
+
|
|
335
|
+
interface Props {
|
|
336
|
+
id: string;
|
|
337
|
+
pathname: string;
|
|
338
|
+
dom?: import("expo/dom").DOMProps;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export default function DOMComponent({ id, pathname }: Props) {
|
|
342
|
+
return (
|
|
343
|
+
<div>
|
|
344
|
+
<p>Current ID: {id}</p>
|
|
345
|
+
<p>Current Path: {pathname}</p>
|
|
346
|
+
</div>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Detecting DOM Environment
|
|
352
|
+
|
|
353
|
+
Check if code is running in a DOM component:
|
|
354
|
+
|
|
355
|
+
```tsx
|
|
356
|
+
"use dom";
|
|
357
|
+
|
|
358
|
+
import { IS_DOM } from "expo/dom";
|
|
359
|
+
|
|
360
|
+
export default function Component({
|
|
361
|
+
dom,
|
|
362
|
+
}: {
|
|
363
|
+
dom?: import("expo/dom").DOMProps;
|
|
364
|
+
}) {
|
|
365
|
+
return <div>{IS_DOM ? "Running in DOM component" : "Running natively"}</div>;
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## Assets
|
|
370
|
+
|
|
371
|
+
Prefer requiring assets instead of using the public directory:
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
"use dom";
|
|
375
|
+
|
|
376
|
+
// Good - bundled with the component
|
|
377
|
+
const logo = require("../assets/logo.png");
|
|
378
|
+
|
|
379
|
+
export default function Component({
|
|
380
|
+
dom,
|
|
381
|
+
}: {
|
|
382
|
+
dom: import("expo/dom").DOMProps;
|
|
383
|
+
}) {
|
|
384
|
+
return <img src={logo} alt="Logo" />;
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## Usage from Native Components
|
|
389
|
+
|
|
390
|
+
Import and use DOM components like regular components:
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
// app/index.tsx
|
|
394
|
+
import { View, Text } from "react-native";
|
|
395
|
+
import WebChart from "@/components/web-chart";
|
|
396
|
+
import CodeBlock from "@/components/code-block";
|
|
397
|
+
|
|
398
|
+
export default function HomeScreen() {
|
|
399
|
+
return (
|
|
400
|
+
<View style={{ flex: 1 }}>
|
|
401
|
+
<Text>Native content above</Text>
|
|
402
|
+
|
|
403
|
+
<WebChart data={[10, 20, 30, 40, 50]} dom={{ style: { height: 300 } }} />
|
|
404
|
+
|
|
405
|
+
<CodeBlock
|
|
406
|
+
code="const x = 1;"
|
|
407
|
+
language="javascript"
|
|
408
|
+
dom={{ scrollEnabled: true }}
|
|
409
|
+
/>
|
|
410
|
+
|
|
411
|
+
<Text>Native content below</Text>
|
|
412
|
+
</View>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Platform Behavior
|
|
418
|
+
|
|
419
|
+
| Platform | Behavior |
|
|
420
|
+
| -------- | ----------------------------------- |
|
|
421
|
+
| iOS | Rendered in WKWebView |
|
|
422
|
+
| Android | Rendered in WebView |
|
|
423
|
+
| Web | Rendered as-is (no webview wrapper) |
|
|
424
|
+
|
|
425
|
+
On web, the `dom` prop is ignored since no webview is needed.
|
|
426
|
+
|
|
427
|
+
## Tips
|
|
428
|
+
|
|
429
|
+
- DOM components hot reload during development
|
|
430
|
+
- Keep DOM components focused — don't put entire screens in webviews
|
|
431
|
+
- Use native components for navigation chrome, DOM components for specialized content
|
|
432
|
+
- Test on all platforms — web rendering may differ slightly from native webviews
|
|
433
|
+
- Large DOM components may impact performance — profile if needed
|
|
434
|
+
- The webview has its own JavaScript context — cannot directly share state with native
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: modern-python
|
|
3
|
+
description: >
|
|
4
|
+
Configures Python projects with modern tooling (uv, ruff, ty, pytest).
|
|
5
|
+
Use when creating projects, writing scripts, or migrating from pip/Poetry/mypy/black.
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
author: Trail of Bits (adapted)
|
|
9
|
+
version: "1.0.0"
|
|
10
|
+
domain: python
|
|
11
|
+
source: trailofbits/skills/modern-python
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Modern Python
|
|
15
|
+
|
|
16
|
+
Guide for modern Python tooling and best practices.
|
|
17
|
+
|
|
18
|
+
## Knowledge Graph
|
|
19
|
+
|
|
20
|
+
- **extends**: [[backend-developer]]
|
|
21
|
+
- **requires**: []
|
|
22
|
+
- **suggests**: [[qa-tester]], [[devops-engineer]]
|
|
23
|
+
- **conflicts**: []
|
|
24
|
+
- **moc**: [[python-development-moc]]
|
|
25
|
+
|
|
26
|
+
## Core Toolchain
|
|
27
|
+
|
|
28
|
+
| Tool | Purpose | Replaces |
|
|
29
|
+
|------|---------|----------|
|
|
30
|
+
| **uv** | Package/dependency management | pip, virtualenv, pipx, pyenv |
|
|
31
|
+
| **ruff** | Linting AND formatting | flake8, black, isort |
|
|
32
|
+
| **ty** | Type checking | mypy, pyright |
|
|
33
|
+
| **pytest** | Testing with coverage | unittest |
|
|
34
|
+
|
|
35
|
+
## Anti-Patterns
|
|
36
|
+
|
|
37
|
+
| Avoid | Use Instead |
|
|
38
|
+
|-------|-------------|
|
|
39
|
+
| `pip install` | `uv add` + `uv sync` |
|
|
40
|
+
| requirements.txt | PEP 723 (scripts) or pyproject.toml (projects) |
|
|
41
|
+
| Poetry | uv (faster, simpler) |
|
|
42
|
+
| mypy / pyright | ty (faster, Astral team) |
|
|
43
|
+
| `[project.optional-dependencies]` for dev | `[dependency-groups]` (PEP 735) |
|
|
44
|
+
| Manual venv activation | `uv run <cmd>` |
|
|
45
|
+
|
|
46
|
+
## Decision Tree
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
What are you doing?
|
|
50
|
+
│
|
|
51
|
+
├─ Single-file script with deps?
|
|
52
|
+
│ └─ PEP 723 inline metadata
|
|
53
|
+
│
|
|
54
|
+
├─ New multi-file project?
|
|
55
|
+
│ └─ uv init → uv add → uv run
|
|
56
|
+
│
|
|
57
|
+
├─ New reusable package?
|
|
58
|
+
│ └─ uv init --package → full pyproject.toml
|
|
59
|
+
│
|
|
60
|
+
└─ Migrating existing project?
|
|
61
|
+
└─ uv init --bare → uv add from existing deps
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv init myproject && cd myproject
|
|
68
|
+
uv add requests rich
|
|
69
|
+
uv add --group dev pytest ruff ty
|
|
70
|
+
uv run python src/myproject/main.py
|
|
71
|
+
uv run pytest
|
|
72
|
+
uv run ruff check .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## pyproject.toml Template
|
|
76
|
+
|
|
77
|
+
```toml
|
|
78
|
+
[project]
|
|
79
|
+
name = "myproject"
|
|
80
|
+
version = "0.1.0"
|
|
81
|
+
requires-python = ">=3.11"
|
|
82
|
+
|
|
83
|
+
[dependency-groups]
|
|
84
|
+
dev = [{include-group = "lint"}, {include-group = "test"}]
|
|
85
|
+
lint = ["ruff", "ty"]
|
|
86
|
+
test = ["pytest", "pytest-cov"]
|
|
87
|
+
|
|
88
|
+
[tool.ruff]
|
|
89
|
+
line-length = 100
|
|
90
|
+
target-version = "py311"
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint]
|
|
93
|
+
select = ["ALL"]
|
|
94
|
+
ignore = ["D", "COM812", "ISC001"]
|
|
95
|
+
|
|
96
|
+
[tool.pytest]
|
|
97
|
+
addopts = ["--cov=myproject", "--cov-fail-under=80"]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Key Commands
|
|
101
|
+
|
|
102
|
+
| Command | Description |
|
|
103
|
+
|---------|-------------|
|
|
104
|
+
| `uv add <pkg>` | Add dependency |
|
|
105
|
+
| `uv add --group dev <pkg>` | Add dev dependency |
|
|
106
|
+
| `uv sync --all-groups` | Install all |
|
|
107
|
+
| `uv run <cmd>` | Run in venv |
|
|
108
|
+
| `uv run --with <pkg> <cmd>` | Run with temp dep |
|
|
109
|
+
| `uv build` | Build package |
|
|
110
|
+
|
|
111
|
+
## Checklist
|
|
112
|
+
|
|
113
|
+
- [ ] Use `src/` layout
|
|
114
|
+
- [ ] `requires-python = ">=3.11"`
|
|
115
|
+
- [ ] ruff with `select = ["ALL"]`
|
|
116
|
+
- [ ] ty for type checking
|
|
117
|
+
- [ ] Test coverage ≥ 80%
|
|
118
|
+
- [ ] `uv.lock` in version control
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
*Modern Python setup | Trail of Bits methodology*
|