create-disposabl-app 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -22
- package/dist/templates/default/apps/desktop/.oxfmtrc.json +5 -0
- package/dist/templates/default/apps/desktop/.oxlintrc.json +6 -0
- package/dist/templates/default/apps/desktop/README.md +58 -0
- package/dist/templates/default/apps/desktop/forge.config.mts +90 -0
- package/dist/templates/default/apps/desktop/index.html +12 -0
- package/dist/templates/default/apps/desktop/package.json +55 -1
- package/dist/templates/default/apps/desktop/src/declarations.d.ts +2 -0
- package/dist/templates/default/apps/desktop/src/index.css +8 -0
- package/dist/templates/default/apps/desktop/src/main.ts +58 -0
- package/dist/templates/default/apps/desktop/src/preload.ts +3 -0
- package/dist/templates/default/apps/desktop/src/renderer.ts +19 -0
- package/dist/templates/default/apps/desktop/tsconfig.json +14 -0
- package/dist/templates/default/apps/desktop/vite.main.config.mts +4 -0
- package/dist/templates/default/apps/desktop/vite.preload.config.mts +4 -0
- package/dist/templates/default/apps/desktop/vite.renderer.config.mts +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/agent-device/SKILL.md +22 -0
- package/dist/templates/default/apps/mobile/.agents/skills/android-emulator/SKILL.md +32 -0
- package/dist/templates/default/apps/mobile/.agents/skills/dogfood/SKILL.md +27 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/SKILL.md +176 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/app-store-metadata.md +497 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/ios-app-store.md +376 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/native-ios.md +167 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/play-store.md +244 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/testflight.md +62 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-app-stores/references/workflows.md +120 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-hosting/SKILL.md +431 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-hosting/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/SKILL.md +46 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/references/metrics.md +98 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/references/queries.md +444 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/references/setup.md +529 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-observe/references/third-party.md +136 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/SKILL.md +237 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/references/controllers.md +139 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/references/logs-and-crashes.md +101 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/references/run-your-app.md +256 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-simulator/references/troubleshooting.md +56 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update/SKILL.md +146 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update-insights/SKILL.md +238 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update-insights/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-update-insights/references/update-insights-schema.md +69 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-workflows/SKILL.md +99 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-workflows/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-workflows/scripts/fetch.js +109 -0
- package/dist/templates/default/apps/mobile/.agents/skills/eas-workflows/scripts/package.json +6 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-animation/LICENSE +21 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-animation/RECIPES.md +385 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-animation/SKILL.md +274 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-animation/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-app-clip/SKILL.md +290 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-app-clip/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-app-clip/references/native-module.md +96 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/SKILL.md +69 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/brownfield-integrated.md +551 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/brownfield-isolated.md +449 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/comparison.md +63 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/feature-integration.md +163 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/troubleshooting.md +88 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-brownfield/references/version-compatibility.md +40 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-data-fetching/SKILL.md +478 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-data-fetching/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-data-fetching/references/expo-router-loaders.md +341 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-data-fetching/references/offline-and-cancellation.md +68 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-design-system/SKILL.md +376 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-design-system/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-design-system/references/audit.md +190 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-design-system/references/native-slop.md +74 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-dev-client/SKILL.md +184 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-dev-client/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-dom/SKILL.md +425 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-dom/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-examples/SKILL.md +106 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-examples/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-examples/references/catalog.md +105 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/SKILL.md +124 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/references/compatibility.md +130 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/references/example.md +212 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/references/migration-map.md +457 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/SKILL.md +151 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/config-plugin.md +90 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/create-expo-module.md +206 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/lifecycle.md +127 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/module-config.md +48 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/native-module.md +286 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-module/references/native-view.md +171 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/SKILL.md +201 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/controls.md +231 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/gradients.md +106 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/icons.md +232 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/media.md +193 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/storage.md +121 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/visual-effects.md +198 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-native-ui/references/webgpu-three.md +605 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-overview/SKILL.md +120 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-overview/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-overview/references/launch-without-dev-menu.md +24 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-project-structure/SKILL.md +114 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-project-structure/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/SKILL.md +240 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/form-sheet.md +253 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/route-structure.md +229 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/search.md +248 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/tabs.md +433 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/toolbar-and-headers.md +284 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-router/references/zoom-transitions.md +158 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/SKILL.md +314 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/agents/visual-grader.md +52 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/references/design-rubric.md +45 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/references/runtime-matrix.md +34 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/check-static.sh +64 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/clean-fixture.sh +56 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/generate_viewer.py +450 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/latest-sdk.sh +46 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/make-fixture.sh +95 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/make-workspace.sh +31 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/snapshot-android.sh +284 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/snapshot-ios.sh +132 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-skill-eval/scripts/snapshot-web.sh +61 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/SKILL.md +101 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/references/drop-in-replacements.md +27 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/references/jetpack-compose.md +73 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/references/swift-ui.md +73 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/references/universal.md +104 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-ui/scripts/list-components.js +193 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/SKILL.md +150 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/expo-av-to-audio.md +132 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/expo-av-to-video.md +160 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/native-tabs.md +124 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/new-architecture.md +79 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/react-19.md +79 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/react-compiler.md +59 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-upgrade/references/react-navigation-to-expo-router.md +61 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/SKILL.md +91 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/references/false-friends.md +119 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/references/native-patterns.md +39 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/references/run-as-goal.md +48 -0
- package/dist/templates/default/apps/mobile/.agents/skills/expo-web-to-native/references/verify-on-device.md +45 -0
- package/dist/templates/default/apps/mobile/.agents/skills/ios-simulator/SKILL.md +32 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/POWER.md +172 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/SKILL.md +238 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/agents/openai.yaml +4 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-analyze-app.md +208 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-analyze-js.md +264 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-barrel-exports.md +250 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-code-splitting.md +255 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-hermes-mmap.md +167 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-library-size.md +164 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-native-assets.md +208 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-r8-android.md +231 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/bundle-tree-shaking.md +215 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/bundle-treemap-source-map-explorer.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/controlled-textinput-pingpong.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/devtools-flamegraph.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/emerge-xray-ios.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/expo-atlas-treemap.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/flashlight-flatlist-vs-flashlist.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/fps-drop-graph.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/memory-heap-snapshot.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/tti-warm-start-diagram.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/view-hierarchy-flattening.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/xcode-instruments-templates.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/images/xcode-thread-view.png +0 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-animations-reanimated.md +273 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-atomic-state.md +190 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-bottomsheet.md +339 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-concurrent-react.md +238 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-lists-flatlist-flashlist.md +223 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-measure-fps.md +178 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-memory-leaks.md +168 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-profile-react.md +138 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-react-compiler.md +261 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/js-uncontrolled-components.md +219 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-android-16kb-alignment.md +114 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-measure-tti.md +221 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-memory-leaks.md +206 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-memory-patterns.md +240 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-platform-setup.md +112 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-profiling.md +140 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-sdks-over-polyfills.md +192 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-threading-model.md +230 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-turbo-modules.md +210 -0
- package/dist/templates/default/apps/mobile/.agents/skills/react-native-best-practices/references/native-view-flattening.md +180 -0
- package/dist/templates/default/apps/mobile/AGENTS.md +41 -0
- package/dist/templates/default/apps/mobile/app.json +38 -0
- package/dist/templates/default/apps/mobile/assets/expo.icon/Assets/expo-symbol 2.svg +3 -0
- package/dist/templates/default/apps/mobile/assets/expo.icon/Assets/grid.png +0 -0
- package/dist/templates/default/apps/mobile/assets/expo.icon/icon.json +40 -0
- package/dist/templates/default/apps/mobile/assets/images/android-icon-background.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/android-icon-foreground.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/android-icon-monochrome.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/icon.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/splash-icon.png +0 -0
- package/dist/templates/default/apps/mobile/eslint.config.js +10 -0
- package/dist/templates/default/apps/mobile/package.json +43 -1
- package/dist/templates/default/apps/mobile/skills-lock.json +185 -0
- package/dist/templates/default/apps/mobile/src/app/_layout.tsx +5 -0
- package/dist/templates/default/apps/mobile/src/app/index.tsx +17 -0
- package/dist/templates/default/apps/mobile/tsconfig.json +20 -0
- package/dist/templates/default/apps/web/.agents/skills/frontend-design/SKILL.md +71 -0
- package/dist/templates/default/apps/web/.agents/skills/web-design-guidelines/SKILL.md +39 -0
- package/dist/templates/default/apps/web/.env.example +3 -0
- package/dist/templates/default/apps/web/components.json +23 -0
- package/dist/templates/default/apps/web/eslint.config.ts +21 -0
- package/dist/templates/default/apps/web/package.json +39 -1
- package/dist/templates/default/apps/web/public/disposabl-logo.svg +8 -0
- package/dist/templates/default/apps/web/public/favicon.ico +0 -0
- package/dist/templates/default/apps/web/public/manifest.json +25 -0
- package/dist/templates/default/apps/web/skills-lock.json +17 -0
- package/dist/templates/default/apps/web/src/index.css +92 -0
- package/dist/templates/default/apps/web/src/routeTree.gen.ts +282 -0
- package/dist/templates/default/apps/web/src/router/__root.tsx +63 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +9 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/$id.tsx +27 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/index.tsx +33 -0
- package/dist/templates/default/apps/web/src/router/index.tsx +15 -0
- package/dist/templates/default/apps/web/src/router.tsx +20 -0
- package/dist/templates/default/apps/web/tsconfig.json +33 -0
- package/dist/templates/default/apps/web/tsr.config.json +6 -0
- package/dist/templates/default/apps/web/vite.config.ts +67 -0
- package/dist/templates/default/bun.lock +3932 -0
- package/dist/templates/default/bunfig.toml +5 -0
- package/dist/templates/default/disposabl.json +5 -0
- package/dist/templates/default/gitignore +9 -1
- package/dist/templates/default/package.json +29 -4
- package/dist/templates/default/packages/backend/.agents/skills/convex/SKILL.md +69 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-add/SKILL.md +26 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-advisor/SKILL.md +32 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-agent/SKILL.md +25 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-auth/SKILL.md +29 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-authz/SKILL.md +36 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-backup/SKILL.md +33 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-billing/SKILL.md +69 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-cost/SKILL.md +29 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/SKILL.md +325 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/agents/openai.yaml +14 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/assets/icon.svg +3 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/references/advanced-patterns.md +146 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/references/hybrid-components.md +38 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/references/local-components.md +39 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-create-component/references/packaged-components.md +54 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-crons/SKILL.md +23 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-deploy-guard/SKILL.md +29 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-design/SKILL.md +30 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-docs/SKILL.md +31 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-domains/SKILL.md +26 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-env/SKILL.md +24 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-expert/SKILL.md +38 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-explain-app/SKILL.md +29 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-improve-convex-plugin/SKILL.md +24 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-insights/SKILL.md +32 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-launch-readiness/SKILL.md +35 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-migrate/SKILL.md +23 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-migrate-rehearse/SKILL.md +31 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-monitor/SKILL.md +22 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-optimize/SKILL.md +26 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-quickstart/SKILL.md +29 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-quickstart/agents/openai.yaml +14 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-quickstart/assets/icon.svg +4 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-reviewer/SKILL.md +26 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-seed/SKILL.md +23 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-self-heal/SKILL.md +38 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-sentinel/SKILL.md +25 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-suggest/SKILL.md +27 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-test/SKILL.md +23 -0
- package/dist/templates/default/packages/backend/.agents/skills/convex-verify/SKILL.md +34 -0
- package/dist/templates/default/packages/backend/.prettierignore +4 -0
- package/dist/templates/default/packages/backend/AGENTS.md +18 -0
- package/dist/templates/default/packages/backend/CLAUDE.md +13 -0
- package/dist/templates/default/packages/backend/README.md +25 -0
- package/dist/templates/default/packages/backend/convex/_generated/ai/ai-files.state.json +6 -0
- package/dist/templates/default/packages/backend/convex/_generated/ai/guidelines.md +286 -0
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +66 -0
- package/dist/templates/default/packages/backend/convex/_generated/api.js +23 -0
- package/dist/templates/default/packages/backend/convex/_generated/dataModel.d.ts +60 -0
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +164 -0
- package/dist/templates/default/packages/backend/convex/_generated/server.js +101 -0
- package/dist/templates/default/packages/backend/convex/auth.config.ts +14 -0
- package/dist/templates/default/packages/backend/convex/auth.ts +15 -0
- package/dist/templates/default/packages/backend/convex/convex.config.ts +30 -0
- package/dist/templates/default/packages/backend/convex/http.ts +5 -0
- package/dist/templates/default/packages/backend/convex/mcp.ts +8 -0
- package/dist/templates/default/packages/backend/convex/schema.ts +10 -0
- package/dist/templates/default/packages/backend/convex/todos/index.ts +26 -0
- package/dist/templates/default/packages/backend/convex/todos/internal.ts +43 -0
- package/dist/templates/default/packages/backend/convex/tsconfig.json +27 -0
- package/dist/templates/default/packages/backend/convex/users.ts +20 -0
- package/dist/templates/default/packages/backend/eslint.config.mjs +62 -0
- package/dist/templates/default/packages/backend/package.json +36 -0
- package/dist/templates/default/packages/backend/skills-lock.json +203 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/accordion.tsx +77 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert-dialog.tsx +185 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert.tsx +75 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/aspect-ratio.tsx +22 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/attachment.tsx +207 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/avatar.tsx +106 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/badge.tsx +51 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/breadcrumb.tsx +121 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/bubble.tsx +127 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/button-group.tsx +87 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/button.tsx +57 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/calendar.tsx +241 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/card.tsx +102 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/carousel.tsx +239 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/chart.tsx +368 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/checkbox.tsx +27 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/code-block.tsx +243 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/collapsible.tsx +19 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/combobox.tsx +300 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/command.tsx +194 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/context-menu.tsx +271 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dialog.tsx +156 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/direction.tsx +4 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/drawer.tsx +224 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dropdown-menu.tsx +269 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/empty.tsx +103 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/field.tsx +236 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/hover-card.tsx +50 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-group.tsx +158 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-otp.tsx +83 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input.tsx +19 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/item.tsx +201 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/kbd.tsx +26 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/label.tsx +19 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/marker.tsx +70 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/menubar.tsx +284 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message-scroller.tsx +128 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message.tsx +91 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/native-select.tsx +64 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/navigation-menu.tsx +170 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/pagination.tsx +133 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/popover.tsx +87 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/progress.tsx +82 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/questionnaire.tsx +330 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/radio-group.tsx +35 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/resizable.tsx +49 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/scroll-area.tsx +51 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/select.tsx +201 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/separator.tsx +22 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sheet.tsx +132 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sidebar.tsx +723 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/skeleton.tsx +13 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/slider.tsx +51 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/spinner.tsx +16 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/switch.tsx +31 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/table.tsx +113 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tabs.tsx +81 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/textarea.tsx +17 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toast.tsx +229 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle-group.tsx +87 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle.tsx +42 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tooltip.tsx +65 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/trace.tsx +161 -0
- package/dist/templates/default/packages/disposabl-kit/client/hooks/use-mobile.ts +21 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/prerender.ts +89 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/return-to.ts +12 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/utils.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +114 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +120 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/_authenticated/route.tsx +38 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +137 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +30 -0
- package/dist/templates/default/packages/disposabl-kit/client/styles/globals.css +60 -0
- package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +32 -0
- package/dist/templates/default/packages/disposabl-kit/components.json +23 -0
- package/dist/templates/default/packages/disposabl-kit/eslint.config.js +21 -0
- package/dist/templates/default/packages/disposabl-kit/package.json +60 -0
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +86 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +40 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/platforms.ts +20 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/static-routes.ts +56 -0
- package/dist/templates/default/packages/disposabl-kit/tsconfig.json +17 -0
- package/dist/templates/default/patches/@convex-dev%2Fauth@2.0.0-beta.0.patch +310 -0
- package/dist/templates/default/patches/@convex-dev%2Fstatic-hosting@0.2.1.patch +187 -0
- package/dist/templates/default/tsconfig.json +9 -0
- package/dist/templates/default/turbo.json +51 -0
- package/package.json +1 -2
package/dist/templates/default/apps/mobile/.agents/skills/expo-migrate-module/references/example.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Worked Example: Full Module Migration
|
|
2
|
+
|
|
3
|
+
This walks a single small module from the 1.0 DSL through mixed mode to a fully migrated 2.0 form. Every per-member rule lives in `migration-map.md`; this shows how they compose and how mixed mode is an intermediate state, not a failure.
|
|
4
|
+
|
|
5
|
+
The module below is representative: a name, a sync function, two async functions (one that suspends, one that blocks), a settable property, a constant, an event with observing hooks, and a record.
|
|
6
|
+
|
|
7
|
+
## Starting point: 1.0 DSL
|
|
8
|
+
|
|
9
|
+
```swift
|
|
10
|
+
import ExpoModulesCore
|
|
11
|
+
|
|
12
|
+
@Record
|
|
13
|
+
struct DownloadOptions {
|
|
14
|
+
var url: URL // required
|
|
15
|
+
var retries: Int = 3 // omittable, default 3
|
|
16
|
+
var label: String? // omittable and nullable
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public final class DownloaderModule: Module {
|
|
20
|
+
private var volume: Double = 1
|
|
21
|
+
|
|
22
|
+
public func definition() -> ModuleDefinition {
|
|
23
|
+
Name("Downloader")
|
|
24
|
+
|
|
25
|
+
Events("onProgress")
|
|
26
|
+
|
|
27
|
+
OnStartObserving {
|
|
28
|
+
self.beginProgressUpdates()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
OnStopObserving {
|
|
32
|
+
self.stopProgressUpdates()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Constant("buildInfo") { computeBuildInfo() }
|
|
36
|
+
|
|
37
|
+
Function("clamp") { (value: Double) -> Double in
|
|
38
|
+
return min(max(value, 0), 1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Property("volume") { self.volume }
|
|
42
|
+
.set { self.volume = $0 }
|
|
43
|
+
|
|
44
|
+
AsyncFunction("download") { (options: DownloadOptions) -> String in
|
|
45
|
+
return try await self.performDownload(options)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
AsyncFunction("clearCache") {
|
|
49
|
+
try FileManager.default.removeItem(at: self.cacheDirectory)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private func report(percent: Double) {
|
|
54
|
+
sendEvent("onProgress", ["percent": percent])
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The observable contract to preserve:
|
|
60
|
+
|
|
61
|
+
| Member | JS name | Contract |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| Module | `Downloader` | `requireNativeModule("Downloader")` |
|
|
64
|
+
| `clamp` | `clamp` | sync, 1 arg, returns number |
|
|
65
|
+
| `volume` | `volume` | read/write number |
|
|
66
|
+
| `buildInfo` | `buildInfo` | read-only constant |
|
|
67
|
+
| `download` | `download` | async, 1 record arg, returns string |
|
|
68
|
+
| `clearCache` | `clearCache` | async, no args, blocking work runs off the JS thread |
|
|
69
|
+
| `onProgress` | `onProgress` | event, payload `{ percent }` |
|
|
70
|
+
| observing hooks | n/a | progress updates start/stop with the listener count |
|
|
71
|
+
| `DownloadOptions` | n/a | `url` required; `retries` default 3; `label` nullable |
|
|
72
|
+
|
|
73
|
+
## Intermediate: mixed mode
|
|
74
|
+
|
|
75
|
+
Suppose the checked-out core supports everything used above: `@ExpoModule`, `@JS` functions/properties/constants, async `@JavaScriptActor`, `@Record`, default async `@Event`, and the module lifecycle hooks. One member is still blocked, by semantics rather than support: `clearCache` has a body that blocks and never suspends, and a 1.0 `AsyncFunction` runs it on a background queue automatically, while a 2.0 async member starts on the JS actor. Migrating it as-is would move blocking I/O onto the JS thread, so it stays in the DSL.
|
|
76
|
+
|
|
77
|
+
The record migrates first because it is a pure data type and the function that consumes it depends on it. Its shape is already correct, so migration is just verifying each field decodes: `url`, `retries`, `label` all map cleanly, so `@Record` stays as-is (it was already using the macro here).
|
|
78
|
+
|
|
79
|
+
```swift
|
|
80
|
+
import ExpoModulesCore
|
|
81
|
+
|
|
82
|
+
@Record
|
|
83
|
+
struct DownloadOptions {
|
|
84
|
+
var url: URL
|
|
85
|
+
var retries: Int = 3
|
|
86
|
+
var label: String?
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ExpoModule("Downloader")
|
|
90
|
+
public final class DownloaderModule: Module {
|
|
91
|
+
// Explicit wire name: default @Event would strip "on" and emit "progress".
|
|
92
|
+
@Event("onProgress")
|
|
93
|
+
var onProgress: (ProgressEvent) -> Void
|
|
94
|
+
|
|
95
|
+
@JS("clamp")
|
|
96
|
+
func clamp(value: Double) -> Double {
|
|
97
|
+
return min(max(value, 0), 1)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Stored var -> JS getter + setter, matching the 1.0 get/set pair.
|
|
101
|
+
@JS
|
|
102
|
+
var volume: Double = 1
|
|
103
|
+
|
|
104
|
+
// A let is a natural constant: read-only from JS.
|
|
105
|
+
@JS
|
|
106
|
+
let buildInfo = computeBuildInfo()
|
|
107
|
+
|
|
108
|
+
@JS
|
|
109
|
+
func download(options: DownloadOptions) async throws -> String {
|
|
110
|
+
return try await performDownload(options)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// override: the hooks are inherited from the Module base class.
|
|
114
|
+
override func didStartListening(event: String) {
|
|
115
|
+
beginProgressUpdates()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
override func didStopListening(event: String) {
|
|
119
|
+
stopProgressUpdates()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Kept on the DSL: the body blocks without suspending, and a 2.0 async
|
|
123
|
+
// member would start it on the JS actor instead of a background queue.
|
|
124
|
+
public func definition() -> ModuleDefinition {
|
|
125
|
+
AsyncFunction("clearCache") {
|
|
126
|
+
try FileManager.default.removeItem(at: self.cacheDirectory)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private func report(percent: Double) {
|
|
131
|
+
onProgress(ProgressEvent(percent: percent))
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Record
|
|
136
|
+
struct ProgressEvent {
|
|
137
|
+
var percent: Double
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Notes on the choices, each traceable to `migration-map.md`:
|
|
142
|
+
|
|
143
|
+
- `Name("Downloader")` moved into `@ExpoModule("Downloader")`; the custom name is carried explicitly, never dropped.
|
|
144
|
+
- `@Event("onProgress")` uses the explicit wire name to avoid the `on`-stripping default; the untyped dictionary became a typed `ProgressEvent`.
|
|
145
|
+
- The duplicate `private var volume` field was removed once `@JS var volume` became the single source of truth. Watch for this: a 1.0 backing field plus a migrated `@JS var` of the same name is a double-declaration.
|
|
146
|
+
- `Constant("buildInfo")` became `@JS let buildInfo`. Evaluation moves from the lazy 1.0 closure to module initialization, acceptable here because `computeBuildInfo()` is cheap; an expensive value would keep lazy storage behind a getter-only computed `@JS var`.
|
|
147
|
+
- `OnStartObserving`/`OnStopObserving` became the `didStartListening(event:)`/`didStopListening(event:)` hooks, with `override` because the class inherits `Module`. The 1.0 hooks were module-wide, so the event argument is ignored.
|
|
148
|
+
- `definition()` remains but now holds only the queue-sensitive `clearCache`. It is not deleted because it is non-empty.
|
|
149
|
+
|
|
150
|
+
## Fully migrated (after explicitly moving the blocking work off the JS actor)
|
|
151
|
+
|
|
152
|
+
The DSL entry for `clearCache` was the semantics-preserving default. To finish the migration, replace the implicit background queue with an explicit hop so the blocking work still never runs on the JS thread, then delete the empty `definition()`.
|
|
153
|
+
|
|
154
|
+
```swift
|
|
155
|
+
import ExpoModulesCore
|
|
156
|
+
|
|
157
|
+
@Record
|
|
158
|
+
struct DownloadOptions {
|
|
159
|
+
var url: URL
|
|
160
|
+
var retries: Int = 3
|
|
161
|
+
var label: String?
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Record
|
|
165
|
+
struct ProgressEvent {
|
|
166
|
+
var percent: Double
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@ExpoModule("Downloader")
|
|
170
|
+
public final class DownloaderModule: Module {
|
|
171
|
+
@Event("onProgress")
|
|
172
|
+
var onProgress: (ProgressEvent) -> Void
|
|
173
|
+
|
|
174
|
+
@JS("clamp")
|
|
175
|
+
func clamp(value: Double) -> Double {
|
|
176
|
+
return min(max(value, 0), 1)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
@JS
|
|
180
|
+
var volume: Double = 1
|
|
181
|
+
|
|
182
|
+
@JS
|
|
183
|
+
let buildInfo = computeBuildInfo()
|
|
184
|
+
|
|
185
|
+
@JS
|
|
186
|
+
func download(options: DownloadOptions) async throws -> String {
|
|
187
|
+
return try await performDownload(options)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@JS
|
|
191
|
+
func clearCache() async throws {
|
|
192
|
+
// Explicit hop: the body blocks, so it must not run on the JS actor.
|
|
193
|
+
try await Task.detached {
|
|
194
|
+
try FileManager.default.removeItem(at: self.cacheDirectory)
|
|
195
|
+
}.value
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
override func didStartListening(event: String) {
|
|
199
|
+
beginProgressUpdates()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override func didStopListening(event: String) {
|
|
203
|
+
stopProgressUpdates()
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private func report(percent: Double) {
|
|
207
|
+
onProgress(ProgressEvent(percent: percent))
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`definition()` is gone only because it was empty and `@ExpoModule("Downloader")` preserves the resolved name. If any member had stayed blocked or unverified, the mixed-mode form above is the correct place to stop, not a broken end state.
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# 1.0 to 2.0 Migration Map
|
|
2
|
+
|
|
3
|
+
Use this reference while editing. Preserve behavior first; macro adoption is secondary.
|
|
4
|
+
|
|
5
|
+
## Module and naming
|
|
6
|
+
|
|
7
|
+
Convert the module class and remove `Name(...)` only when the paired core reads the macro-synthesized name:
|
|
8
|
+
|
|
9
|
+
```swift
|
|
10
|
+
// 1.0
|
|
11
|
+
public final class CameraModule: Module {
|
|
12
|
+
public func definition() -> ModuleDefinition {
|
|
13
|
+
Name("Camera")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 2.0
|
|
18
|
+
@ExpoModule("Camera")
|
|
19
|
+
public final class CameraModule: Module {}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Always carry a custom 1.0 name into `@ExpoModule("...")`. A stale `Name(...)` can override or conflict with the 2.0 name depending on the core revision. In mixed mode, remove `Name(...)` only after verifying that the module still resolves under its expected JS name.
|
|
23
|
+
|
|
24
|
+
## Functions
|
|
25
|
+
|
|
26
|
+
Move a DSL closure into a real method and use `@JS("wireName")` when the Swift method name is different:
|
|
27
|
+
|
|
28
|
+
```swift
|
|
29
|
+
// 1.0
|
|
30
|
+
Function("sum") { (a: Double, b: Double) -> Double in
|
|
31
|
+
return a + b
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 2.0
|
|
35
|
+
@JS("sum")
|
|
36
|
+
func add(a: Double, b: Double) -> Double {
|
|
37
|
+
return a + b
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Preserve:
|
|
42
|
+
|
|
43
|
+
- the JS name
|
|
44
|
+
- positional arity
|
|
45
|
+
- optional arguments and Swift defaults
|
|
46
|
+
- thrown errors and return type
|
|
47
|
+
- whether the result is synchronous or a Promise
|
|
48
|
+
|
|
49
|
+
Do not migrate functions that resolve to the same JS name unless the checked-out macro has overload grouping and collision diagnostics. Older 2.0 implementations install one property per declaration, so the last overload silently wins.
|
|
50
|
+
|
|
51
|
+
Reject or keep in DSL any unsupported signature such as variadics, `inout`, unresolved generics, or closure parameters without verified callback support. A `Promise` parameter is also unsupported; refactor it as described under Async functions.
|
|
52
|
+
|
|
53
|
+
### Async functions
|
|
54
|
+
|
|
55
|
+
A `Promise` parameter is not supported in a `@JS` signature; 2.0 drops the trailing-`Promise` argument entirely. A Promise-returning function has three shapes in 2.0. Pick by how the underlying work produces its result.
|
|
56
|
+
|
|
57
|
+
**1. Standard `async` method.** The common case. Swift `async` maps to a JS Promise:
|
|
58
|
+
|
|
59
|
+
```swift
|
|
60
|
+
// 1.0
|
|
61
|
+
AsyncFunction("load") { (url: URL) -> String in
|
|
62
|
+
return try loadSynchronously(url)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 2.0
|
|
66
|
+
@JS
|
|
67
|
+
func load(url: URL) async throws -> String {
|
|
68
|
+
return try await loadResource(url)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**2. Checked continuation.** When the result arrives through a delegate or completion handler that fires once, wrap it with `withCheckedThrowingContinuation` (or `withCheckedContinuation` for non-throwing callbacks, or an `AsyncStream` for repeated values). This is the usual refactor for a 1.0 `AsyncFunction` that took a trailing `Promise` instance:
|
|
73
|
+
|
|
74
|
+
```swift
|
|
75
|
+
// 1.0
|
|
76
|
+
AsyncFunction("start") { (promise: Promise) in
|
|
77
|
+
scanner.start(
|
|
78
|
+
onSuccess: { result in promise.resolve(result) },
|
|
79
|
+
onFailure: { error in promise.reject(error) }
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 2.0
|
|
84
|
+
@JS
|
|
85
|
+
func start() async throws -> ScanResult {
|
|
86
|
+
return try await withCheckedThrowingContinuation { continuation in
|
|
87
|
+
scanner.start(
|
|
88
|
+
onSuccess: { result in continuation.resume(returning: result) },
|
|
89
|
+
onFailure: { error in continuation.resume(throwing: error) }
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Resume the continuation exactly once on every path. If the callback API cannot guarantee that, or the refactor is otherwise unsafe, keep the function on the DSL instead of forcing it.
|
|
96
|
+
|
|
97
|
+
**3. Synchronous method returning a `Task`.** The `Task` encodes to a promise that settles with its result. Use it when the work is naturally a `Task`, or when a promise is needed as a value nested inside another encoded result rather than as the function's own return:
|
|
98
|
+
|
|
99
|
+
```swift
|
|
100
|
+
// 2.0
|
|
101
|
+
@JS
|
|
102
|
+
func download(url: URL) -> Task<DownloadResult, any Error> {
|
|
103
|
+
return Task {
|
|
104
|
+
try await self.downloader.download(url)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This shape requires the `JavaScriptEncodable` conformance for `Task` in the checked-out core (encode-only; a JS promise does not decode back into a `Task`). Verify it exists before using this shape; prefer shape 1 or 2 when it is absent.
|
|
110
|
+
|
|
111
|
+
#### Threading: the architectural difference
|
|
112
|
+
|
|
113
|
+
This is the highest-risk part of an async migration, because the code compiles and the JS signature is unchanged while the work moves onto a different thread.
|
|
114
|
+
|
|
115
|
+
The two versions schedule async work from opposite starting points:
|
|
116
|
+
|
|
117
|
+
| | 1.0 `AsyncFunction` | 2.0 `async` `@JS` |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| Where the body starts | off the JS thread, from the first statement | on the JS thread |
|
|
120
|
+
| When it leaves the JS thread | never runs there | at the first real suspension point |
|
|
121
|
+
| A body with no `await` | still runs off the JS thread | runs entirely on the JS thread |
|
|
122
|
+
|
|
123
|
+
A 2.0 async member is `@JavaScriptActor`-isolated and stays on the JS thread until it actually suspends. So the dangerous case is a function marked `async` whose body never awaits anything, or awaits only after doing substantial work. In 1.0 that body was off the JS thread from the start; migrated verbatim to 2.0, it now blocks the JS thread for its full duration. Nothing in the JS contract reveals this: the function still returns a promise.
|
|
124
|
+
|
|
125
|
+
Audit every `AsyncFunction` you migrate for what the body does before its first `await`:
|
|
126
|
+
|
|
127
|
+
- No `await` at all, or synchronous work ahead of the first `await`: the work is on the JS thread. Treat it as a regression unless the body is trivial.
|
|
128
|
+
- Blocking I/O, file or database access, image or crypto work, or an unbounded loop: never leave this on the JS actor.
|
|
129
|
+
- `.runOnQueue(...)` in 1.0: the queue was the contract. See the continuation pattern below.
|
|
130
|
+
|
|
131
|
+
To restore the 1.0 behavior, use the `@JS` macro's `.concurrent` option (macros plugin `0.10.0`):
|
|
132
|
+
|
|
133
|
+
```swift
|
|
134
|
+
// Body runs off the JS thread, like a 1.0 AsyncFunction.
|
|
135
|
+
@JS(.concurrent)
|
|
136
|
+
func process(input: String) async throws -> String {
|
|
137
|
+
return try self.processor.process(input)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// The option is variadic, so it combines with an explicit JS name.
|
|
141
|
+
@JS("doWork", .concurrent)
|
|
142
|
+
func performWork() async throws {}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Only the body moves. Arguments are still decoded on the JS thread and the result is still encoded back on it, so `.concurrent` changes execution, not the JS contract. This makes it the preferred fix for a migrated function that relied on 1.0 background execution: the intent is explicit and the body stays as written.
|
|
146
|
+
|
|
147
|
+
Two constraints:
|
|
148
|
+
|
|
149
|
+
- `.concurrent` is valid only on an `async` function. On anything else it is diagnosed on the `@JS` attribute.
|
|
150
|
+
- You must still write `async` yourself. The macro cannot add it, but the diagnostic for a synchronous function carries a fix-it that inserts it.
|
|
151
|
+
|
|
152
|
+
**Check availability first.** The plugin side shipped in `0.10.0`, but this also needs a `JSOptions` type and a second `@JS` overload in core, because the options-only spelling cannot reuse the unlabeled JS-name slot. Core has lagged the plugin on every 2.0 feature so far, and where it still declares `@JS(_ jsName: String? = nil)` alone, `@JS(.concurrent)` does not compile. Read the checked-out declaration:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
grep -rn 'public macro JS' <expo-modules-core>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If it takes only a name, use the explicit patterns below instead.
|
|
159
|
+
|
|
160
|
+
For a queue-pinned function, or when `.concurrent` is unavailable, prefer restructuring the work onto the Swift Concurrency model (structured concurrency, an actor, or a detached task for blocking work). When that is not feasible because the queue itself is the contract, for example a library that must be called from one serial queue, convert to an `async` method that dispatches to that queue inside a checked continuation:
|
|
161
|
+
|
|
162
|
+
```swift
|
|
163
|
+
// 1.0
|
|
164
|
+
AsyncFunction("process") { (input: String) -> String in
|
|
165
|
+
return try self.processor.process(input)
|
|
166
|
+
}
|
|
167
|
+
.runOnQueue(processingQueue)
|
|
168
|
+
|
|
169
|
+
// 2.0
|
|
170
|
+
@JS
|
|
171
|
+
func process(input: String) async throws -> String {
|
|
172
|
+
return try await withCheckedThrowingContinuation { continuation in
|
|
173
|
+
processingQueue.async {
|
|
174
|
+
do {
|
|
175
|
+
continuation.resume(returning: try self.processor.process(input))
|
|
176
|
+
} catch {
|
|
177
|
+
continuation.resume(throwing: error)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Properties and constants
|
|
185
|
+
|
|
186
|
+
Map a getter to a getter-only `@JS var`; map a getter/setter pair to a settable stored or computed `@JS var`:
|
|
187
|
+
|
|
188
|
+
```swift
|
|
189
|
+
// 1.0
|
|
190
|
+
Property("volume") { self.volume }
|
|
191
|
+
.set { self.volume = $0 }
|
|
192
|
+
|
|
193
|
+
// 2.0
|
|
194
|
+
@JS
|
|
195
|
+
var volume: Double = 1
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Access control does not define JS mutability. Verify whether the declaration is syntactically settable; a stored `var` normally produces a JS setter.
|
|
199
|
+
|
|
200
|
+
Map a 1.0 `Constant` to a `@JS let`; a `let` property is a natural constant and produces a read-only JS property:
|
|
201
|
+
|
|
202
|
+
```swift
|
|
203
|
+
// 1.0
|
|
204
|
+
Constant("apiVersion") { 3 }
|
|
205
|
+
|
|
206
|
+
// 2.0
|
|
207
|
+
@JS
|
|
208
|
+
let apiVersion = 3
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Evaluation timing shifts: a 1.0 `Constant` closure runs lazily, while a `let` initializes with the module instance. When the value is expensive and must stay deferred, keep private lazy storage and expose a getter-only computed property (a `var` with a `{ }` getter body and no storage of its own), not a stored `lazy var`:
|
|
212
|
+
|
|
213
|
+
```swift
|
|
214
|
+
private lazy var cachedInfo = computeInfo()
|
|
215
|
+
|
|
216
|
+
@JS
|
|
217
|
+
var info: Info { // computed: recomputes nothing, just returns the cached value
|
|
218
|
+
return cachedInfo
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Do not expose a cached value as a settable `lazy @JS var`.
|
|
223
|
+
|
|
224
|
+
## Events
|
|
225
|
+
|
|
226
|
+
Replace `Events(...)` plus `sendEvent(...)` with a typed function property:
|
|
227
|
+
|
|
228
|
+
```swift
|
|
229
|
+
@Record
|
|
230
|
+
struct ProgressEvent {
|
|
231
|
+
var percent: Double
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Explicit string preserves the old wire name.
|
|
235
|
+
@Event("onProgress")
|
|
236
|
+
var onProgress: (ProgressEvent) -> Void
|
|
237
|
+
|
|
238
|
+
func report(percent: Double) {
|
|
239
|
+
onProgress(ProgressEvent(percent: percent))
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The default `@Event` wire name strips a leading `on` and decapitalizes the remainder: Swift `onProgress` emits `progress`. 1.0 modules commonly expose `onProgress`. During migration, pass the original wire name explicitly unless an intentional JS breaking change was approved.
|
|
244
|
+
|
|
245
|
+
Use `() -> Void` for no-payload events. For payloads, create or reuse a `JavaScriptEncodable` type instead of preserving an untyped dictionary. Migrate `OnStartObserving` and `OnStopObserving` to the `didStartListening(event:)`/`didStopListening(event:)` lifecycle hooks (see Views and lifecycle).
|
|
246
|
+
|
|
247
|
+
Default `@Event` dispatch schedules onto the JS thread and is callable from other isolation contexts. Do not use `sync: true` unless core provides the matching `emitSync` overloads.
|
|
248
|
+
|
|
249
|
+
## Shared objects
|
|
250
|
+
|
|
251
|
+
Move instance behavior from a `Class(...)` block onto the `SharedObject` subclass:
|
|
252
|
+
|
|
253
|
+
```swift
|
|
254
|
+
// 2.0
|
|
255
|
+
@SharedObject
|
|
256
|
+
final class Download: SharedObject {
|
|
257
|
+
@JS
|
|
258
|
+
init(url: URL) {
|
|
259
|
+
self.url = url
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@JS
|
|
263
|
+
func pause() {}
|
|
264
|
+
|
|
265
|
+
@JS
|
|
266
|
+
var progress: Double { currentProgress }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@ExpoModule(classes: [Download.self])
|
|
270
|
+
final class DownloadModule: Module {}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Drop the leading owner argument used by instance DSL closures; use `self` in the real instance method. Preserve constructor arity and JS member names.
|
|
274
|
+
|
|
275
|
+
Migrate only when the checked-out core supplies the shared-object decoration and construction hooks. Never create both a 1.0 `Class(...)` entry and a 2.0 registration for the same class without confirming that core intentionally merges them.
|
|
276
|
+
|
|
277
|
+
Static members belong to shared objects, not modules: a module is exported to JS as an instance, so Swift `static` members on a `Module` class are not useful there. Keep module-level values as instance `@JS` members.
|
|
278
|
+
|
|
279
|
+
#### Static members
|
|
280
|
+
|
|
281
|
+
A static member installs on the JS class object itself, so JS reaches it as `Download.supportedSchemes()`, not through an instance. The 1.0 DSL has dedicated components for this: `StaticFunction` and `StaticAsyncFunction`. Unlike `Function`, they do not receive the instance as their first argument. There is no static *property* component in 1.0, so a static value was exposed as a `StaticFunction` returning it.
|
|
282
|
+
|
|
283
|
+
```swift
|
|
284
|
+
// 1.0
|
|
285
|
+
Class(Download.self) {
|
|
286
|
+
Constructor { (url: URL) in Download(url: url) }
|
|
287
|
+
|
|
288
|
+
// Instance function: receives the owner as its first argument.
|
|
289
|
+
Function("pause") { (download: Download) in
|
|
290
|
+
download.pause()
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Static: no owner argument, callable as Download.supportedSchemes()
|
|
294
|
+
StaticFunction("supportedSchemes") { () -> [String] in
|
|
295
|
+
Download.supportedSchemes
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```swift
|
|
301
|
+
// 2.0
|
|
302
|
+
@SharedObject
|
|
303
|
+
final class Download: SharedObject {
|
|
304
|
+
@JS
|
|
305
|
+
init(url: URL) { self.url = url }
|
|
306
|
+
|
|
307
|
+
@JS
|
|
308
|
+
func pause() {}
|
|
309
|
+
|
|
310
|
+
@JS
|
|
311
|
+
static func supportedSchemes() -> [String] {
|
|
312
|
+
return Self.schemes
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
`StaticFunction` and `StaticAsyncFunction` both collapse into a `static` (or `class`) Swift declaration, with `async` carrying the distinction, exactly as `Function`/`AsyncFunction` do for instance members. Because 1.0 had no static property component, a `StaticFunction` that only returns a stored value can become a `@JS static var` in 2.0. That changes the JS contract from a call to a property access, so do it only when the user asks; a syntax migration keeps it a function.
|
|
318
|
+
|
|
319
|
+
What decides whether any of this works is the binding path: instance members bind onto the class prototype, while `static`/`class` members bind onto the constructor object through a separate, `constructor:`-labeled decoration hook. The two are independent capabilities.
|
|
320
|
+
|
|
321
|
+
**Support status.** The macros plugin has emitted the `constructor:` binding since `0.7.0`, but core shipped the `prototype:` overload well ahead of it. Where only `prototype:` is declared, a `@JS static` member expands and then fails to link. Verify before migrating any static member:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
grep -rn '_decorateSharedObject' <expo-modules-core>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
If only the `prototype:` overload is declared, keep every `StaticFunction`/`StaticAsyncFunction` entry in the 1.0 `Class(...)` block. Mixed mode is the expected outcome here: migrate the constructor and instance members, leave the static entries on the DSL, and say in the handoff that static members stayed behind because the installed core does not bind them yet.
|
|
328
|
+
|
|
329
|
+
Static functions and static properties travel this same path, so neither is available ahead of the other. When the hook is present, confirm it by calling the member on the JS class rather than on an instance; an instance-side test passes whether or not static binding works.
|
|
330
|
+
|
|
331
|
+
## Records
|
|
332
|
+
|
|
333
|
+
Attach `@Record`, remove field wrappers, and encode requiredness in the declaration:
|
|
334
|
+
|
|
335
|
+
```swift
|
|
336
|
+
@Record
|
|
337
|
+
struct Options {
|
|
338
|
+
var source: URL // required
|
|
339
|
+
var retries: Int = 3 // omittable; default applies
|
|
340
|
+
var label: String? // omittable and nullable
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Rules:
|
|
345
|
+
|
|
346
|
+
- non-optional with no default: required
|
|
347
|
+
- any property with a default: omittable
|
|
348
|
+
- optional type: omittable and nullable
|
|
349
|
+
|
|
350
|
+
Preserve the 1.0 contract exactly. For example, migrate `@Field var source: URL? = nil` to `var source: URL?`, not to `var source: URL`, unless the user approved a breaking change.
|
|
351
|
+
|
|
352
|
+
Every stored property is part of the 2.0 record surface. If the old type contains stored bookkeeping that was not a 1.0 field, move it out of the record or leave the type on 1.0; there is no field opt-out. Verify that each field supports the required `JavaScriptDecodable`/`JavaScriptEncodable` direction.
|
|
353
|
+
|
|
354
|
+
## Unions
|
|
355
|
+
|
|
356
|
+
`@Union` (macros plugin `0.10.0`) is the typed, N-case alternative to 1.0's `Either` types. It applies to a non-generic `enum` whose every case carries exactly one associated value:
|
|
357
|
+
|
|
358
|
+
```swift
|
|
359
|
+
// 1.0: JS `string | SourceOptions`, unwrapped by probing each side.
|
|
360
|
+
@JS
|
|
361
|
+
func load(_ source: Either<String, SourceOptions>) throws {
|
|
362
|
+
if let text: String = source.get() {
|
|
363
|
+
load(url: URL(string: text))
|
|
364
|
+
} else if let options: SourceOptions = source.get() {
|
|
365
|
+
load(url: options.url, headers: options.headers)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
```swift
|
|
371
|
+
// 2.0: the same JS type, as a named enum.
|
|
372
|
+
@Union
|
|
373
|
+
enum Source {
|
|
374
|
+
case text(String)
|
|
375
|
+
case options(SourceOptions) // a @Record
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
@JS
|
|
379
|
+
func load(_ source: Source) throws {
|
|
380
|
+
switch source { // exhaustive; each payload keeps its static type
|
|
381
|
+
case .text(let text):
|
|
382
|
+
load(url: URL(string: text))
|
|
383
|
+
case .options(let options):
|
|
384
|
+
load(url: options.url, headers: options.headers)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
The JS-visible type is unchanged: case order defines the accepted alternatives, so `Either<String, SourceOptions>` maps to cases in that same order. Decoding tries each case's payload in declaration order and the first match wins, which matters for overlapping types (`Int`/`Double`, `URL`/`String`): keep the 1.0 `Either` order, since reordering silently changes which case a given JS value lands in.
|
|
390
|
+
|
|
391
|
+
Besides `switch`, a value unwraps by payload type without naming the case, which is the closest analogue to 1.0's `get()`:
|
|
392
|
+
|
|
393
|
+
```swift
|
|
394
|
+
let text = try source.as(String.self) // throws on a mismatch
|
|
395
|
+
let options = try? source.as(SourceOptions.self) // SourceOptions?
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
A type the union does not carry is a compile error, not a runtime `nil`. A mismatch on a held value throws, where 1.0's `get()` returned `nil`, so a migrated probe chain must become a `switch` or a `try?`.
|
|
399
|
+
|
|
400
|
+
Constraints, each a compile error: a generic enum, no cases, a case with no payload or more than one, a default value on the payload, and two cases with the identical payload spelling.
|
|
401
|
+
|
|
402
|
+
**Check availability first.** The plugin side shipped in `0.10.0`, but this also needs the `Union` macro declaration and the `UnionCaseMismatch` exception in core:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
grep -rn 'public macro Union\|UnionCaseMismatch' <expo-modules-core>
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Keep `Either` types on the 1.0 DSL until both exist in the target. Treat adopting `@Union` as an API-shape change to raise with the user rather than a mechanical step: it renames nothing in JS, but it does restructure Swift call sites.
|
|
409
|
+
|
|
410
|
+
## Views and lifecycle
|
|
411
|
+
|
|
412
|
+
Views are not covered by 2.0 yet. Keep UIKit `View`, `Prop`, view `Events`, and `OnViewDidUpdateProps` DSL entries on 1.0. Macro declarations or expansion tests alone do not prove the runtime update path exists.
|
|
413
|
+
|
|
414
|
+
The planned shape is a class marked `@ExpoView` whose props and event callbacks are declared once in a typed `@ViewProps` struct, instead of split between the native view and a hand-written JS prop type. Until that lands complete, a module with views migrates its non-view members and keeps the view on the DSL. That is a normal mixed-mode result, not a failed migration.
|
|
415
|
+
|
|
416
|
+
Module lifecycle is core-owned rather than macro-generated. The DSL components map to hook methods with no-op defaults:
|
|
417
|
+
|
|
418
|
+
| 1.0 | 2.0 |
|
|
419
|
+
| --- | --- |
|
|
420
|
+
| `OnCreate` | `didCreate()` |
|
|
421
|
+
| `OnDestroy` | `willDestroy()` |
|
|
422
|
+
| `OnStartObserving` | `didStartListening(event:)` |
|
|
423
|
+
| `OnStopObserving` | `didStopListening(event:)` |
|
|
424
|
+
|
|
425
|
+
Rules:
|
|
426
|
+
|
|
427
|
+
- Use the `override` keyword when the class inherits `Module`/`BaseModule`; define the hooks directly (no `override`) when the conformance comes only from `@ExpoModule`. Hooks added only in a subclass of a macro module are not called; keep them on the class that declares the conformance.
|
|
428
|
+
- The listening hooks receive the event name. A module-wide 1.0 `OnStartObserving` ignores the argument; a per-event `OnStartObserving("name")` becomes a comparison on it.
|
|
429
|
+
- `didCreate()` runs after the module is registered, slightly later than 1.0 `OnCreate`, which fires before registration; `willDestroy()` runs at holder teardown. Verify nothing depends on the earlier timing before migrating `OnCreate`.
|
|
430
|
+
- DSL lifecycle components can remain during an incremental migration and each fires exactly once, but do not implement a DSL component and its hook for the same behavior, or the work runs twice.
|
|
431
|
+
|
|
432
|
+
There is no 2.0 replacement for every lifecycle component; for example, retain app-context teardown handling when no matching hook exists.
|
|
433
|
+
|
|
434
|
+
## Mixed mode
|
|
435
|
+
|
|
436
|
+
`@ExpoModule` may coexist with a non-empty `definition()` when the paired core supports merging the two surfaces. Keep only unsupported entries in the DSL and avoid duplicate names across macro and DSL registrations.
|
|
437
|
+
|
|
438
|
+
Before deleting `definition()`, verify that it contains no:
|
|
439
|
+
|
|
440
|
+
- views or view events
|
|
441
|
+
- lifecycle or app-context listeners
|
|
442
|
+
- queue-pinned functions
|
|
443
|
+
- `StaticFunction`/`StaticAsyncFunction` entries, unless core declares the `constructor:` decoration hook
|
|
444
|
+
|
|
445
|
+
## Contract checklist
|
|
446
|
+
|
|
447
|
+
For every migrated member compare before and after:
|
|
448
|
+
|
|
449
|
+
| Concern | Must remain stable |
|
|
450
|
+
| --- | --- |
|
|
451
|
+
| Module | registration name and `requireNativeModule` key |
|
|
452
|
+
| Function | JS name, accepted arity, omitted/default behavior, sync/Promise result |
|
|
453
|
+
| Property | JS name, read/write behavior, evaluation/caching |
|
|
454
|
+
| Event | listener string, payload shape, timing |
|
|
455
|
+
| Record | field names, requiredness, nullability, defaults |
|
|
456
|
+
| Shared object | constructor shape, prototype vs constructor placement, identity |
|
|
457
|
+
| Execution | JS actor, main actor, background queue, ordering |
|