@bake-native/core 0.0.0 → 0.1.0-rc.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/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.txt +548 -0
- package/bake-prelude.js +189 -0
- package/batch-contract.json +21 -0
- package/batch-wire.js +674 -0
- package/close-watcher.js +137 -0
- package/compat.json +64 -0
- package/controls.css +108 -0
- package/determinism.js +175 -0
- package/devtools.d.ts +13 -0
- package/devtools.js +73 -0
- package/dialogs.js +59 -0
- package/direct-style.js +105 -0
- package/direct-table.js +261 -0
- package/dist/bake.mjs +2211 -0
- package/dist/build-BrSFpaK1.mjs +1 -0
- package/dist/build-tools-Dxyl6XAf.mjs +80 -0
- package/dist/build-vAPG2xQv.mjs +5516 -0
- package/dist/client-Cm7o6dQd.mjs +17544 -0
- package/dist/compiler.mjs +4 -0
- package/dist/config-B1W8gfZY.mjs +12 -0
- package/dist/dev-xZblYmDc.mjs +990 -0
- package/dist/direct-report-Bdda-k_Y.mjs +153 -0
- package/dist/direct-report-Du44nNWl.mjs +1 -0
- package/dist/index.d.mts +176 -0
- package/dist/index.mjs +1 -0
- package/dist/intl-ROnAp2qO.mjs +75 -0
- package/dist/jiti-stub-CKcaShwE.mjs +5 -0
- package/dist/native-views-BQ8TtbQj.mjs +8046 -0
- package/dist/octane/package.json +5 -0
- package/dist/package-D2aYD6A4.mjs +2789 -0
- package/dist/react/package.json +13 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-BtyJGAQB.mjs +6632 -0
- package/dist/scope-8W2aIuQ9.mjs +262 -0
- package/dist/screens/BakeNativeScreen.native.ts +9 -0
- package/dist/screens/package.json +5 -0
- package/dom-exception.js +31 -0
- package/element-api.js +158 -0
- package/first-screen.js +30 -0
- package/fonts/Geist-Italic-Variable.ttf +0 -0
- package/fonts/Geist-Variable.ttf +0 -0
- package/fonts/GeistMono-Italic-Variable.ttf +0 -0
- package/fonts/GeistMono-Variable.ttf +0 -0
- package/fonts/OFL.txt +93 -0
- package/fonts/README.md +27 -0
- package/fonts/geist-italic.css +8 -0
- package/fonts/geist-mono-italic.css +8 -0
- package/fonts/geist-mono.css +8 -0
- package/fonts/geist.css +8 -0
- package/header-icons.json +53 -0
- package/host-runtime.js +521 -0
- package/image-props.js +17 -0
- package/index.d.ts +8 -0
- package/index.js +7 -0
- package/licenses/Apache-2.0.txt +73 -0
- package/locale-entry.d.ts +1 -0
- package/locale-entry.js +1 -0
- package/locale.d.ts +28 -0
- package/locale.js +124 -0
- package/markup-support.js +87 -0
- package/media-element.js +115 -0
- package/native-args-entry.js +2 -0
- package/native-args.d.ts +7 -0
- package/native-args.js +155 -0
- package/native-entry.js +1 -0
- package/native-globals.d.ts +166 -0
- package/native-scenarios.d.ts +17 -0
- package/native-scenarios.js +46 -0
- package/native-support.json +366 -0
- package/native.d.ts +52 -0
- package/native.js +237 -0
- package/package.json +143 -4
- package/page-elements.js +123 -0
- package/runtime-provides.json +412 -0
- package/safe-area.d.ts +1 -0
- package/safe-area.js +44 -0
- package/swift-ui/modifiers.js +176 -0
- package/tab-icons.js +62 -0
- package/templates/create/tabs/AGENTS.md +22 -0
- package/templates/create/tabs/README.md +43 -0
- package/templates/create/tabs/_gitignore +13 -0
- package/templates/create/tabs/android/app/build.gradle.kts +79 -0
- package/templates/create/tabs/android/app/src/main/AndroidManifest.xml +39 -0
- package/templates/create/tabs/android/app/src/main/kotlin/MainActivity.kt +35 -0
- package/templates/create/tabs/android/app/src/main/res/values/themes.xml +8 -0
- package/templates/create/tabs/android/build.gradle.kts +5 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.properties +9 -0
- package/templates/create/tabs/android/gradle.properties +3 -0
- package/templates/create/tabs/android/gradlew +248 -0
- package/templates/create/tabs/android/settings.gradle.kts +47 -0
- package/templates/create/tabs/bake.config.ts +10 -0
- package/templates/create/tabs/ios/App/App.swift +30 -0
- package/templates/create/tabs/ios/build.sh +23 -0
- package/templates/create/tabs/ios/project.yml +57 -0
- package/templates/create/tabs/macos/Package.swift +24 -0
- package/templates/create/tabs/macos/Sources/__SWIFT_NAME__/App.swift +146 -0
- package/templates/create/tabs/macos/build.sh +4 -0
- package/templates/create/tabs/package.json +23 -0
- package/templates/create/tabs/pnpm-workspace.yaml +6 -0
- package/templates/create/tabs/src/App.tsrx +92 -0
- package/templates/create/tabs/src/App.tsx +67 -0
- package/templates/create/tabs/src/styles.css +32 -0
- package/templates/create/tabs/tsconfig.json +5 -0
- package/templates/create/tabs/windows/Cargo.toml +29 -0
- package/templates/create/tabs/windows/build.rs +9 -0
- package/templates/create/tabs/windows/src/main.rs +52 -0
- package/templates/create/tabs/windows/src/shell.rs +316 -0
- package/templates/module/__NAME__.kt +20 -0
- package/templates/module/__NAME__.native.ts +24 -0
- package/templates/module/__NAME__.swift +25 -0
- package/templates/module/__NAME__.web.ts +13 -0
- package/templates/module/__NAME__Test.kt +26 -0
- package/templates/module/__NAME__Tests.swift +25 -0
- package/templates/module/__SNAKE__.rs +43 -0
- package/text.d.ts +20 -0
- package/text.js +100 -0
- package/transform-entry.js +1 -0
- package/transform.d.ts +15 -0
- package/transform.js +98 -0
- package/tsconfig.native.json +16 -0
- package/ui/scope.js +103 -0
- package/ui/swift.js +106 -0
- package/ui/ui.css +272 -0
- package/view-ref-writer.js +268 -0
- package/view-ref.d.ts +26 -0
- package/view-ref.js +85 -0
- package/views/Video.native.ts +68 -0
- package/views/generated/VideoViewAndroid.h +68 -0
- package/views/generated/VideoViewJSI.h +94 -0
- package/views/generated/VideoViewSpec.kt +113 -0
- package/views/generated/apple/VideoViewJSI/VideoViewJSIApple.cpp +40 -0
- package/views/generated/apple/VideoViewJSI/include/VideoViewJSIApple.h +28 -0
- package/views/generated/apple/VideoViewSpec/VideoViewInterop.swift +39 -0
- package/views/generated/apple/VideoViewSpec/VideoViewSpec.swift +186 -0
- package/views/generated/video_view_spec.rs +189 -0
- package/views.d.ts +24 -0
- package/views.js +45 -0
- package/virtual-window.js +35 -0
- package/visibility.js +75 -0
- package/web-crypto.js +84 -0
- package/web-fetch.js +1071 -0
- package/README.md +0 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "The SF Symbol names a Header item (`systemImage`) may use, one table for every target. iOS and macOS draw the SF Symbol itself; the web (and Android) draws `path`, Material Icons geometry (24x24 SVG path); Windows draws `segoe`, a Segoe Fluent Icons code point. Any other name is a build error on targets without SF Symbols (web, android, windows; fail-closed). Read by navigation.tsrx (web), fail-closed.mjs (the build check) and bake-host-windows (header.rs).",
|
|
3
|
+
"icons": {
|
|
4
|
+
"plus": { "path": "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z", "segoe": "E710" },
|
|
5
|
+
"plus.circle": { "path": "M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z", "segoe": "E710" },
|
|
6
|
+
"plus.circle.fill": { "path": "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z", "segoe": "E710" },
|
|
7
|
+
"star": { "path": "M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z", "segoe": "E734" },
|
|
8
|
+
"star.fill": { "path": "M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z", "segoe": "E735" },
|
|
9
|
+
"heart": { "path": "M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z", "segoe": "EB51" },
|
|
10
|
+
"heart.fill": { "path": "M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z", "segoe": "EB52" },
|
|
11
|
+
"gearshape": { "path": "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z", "segoe": "E713" },
|
|
12
|
+
"gearshape.fill": { "path": "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z", "segoe": "E713" },
|
|
13
|
+
"magnifyingglass": { "path": "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z", "segoe": "E721" },
|
|
14
|
+
"square.and.arrow.up": { "path": "M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z", "segoe": "E72D" },
|
|
15
|
+
"trash": { "path": "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM8 9h8v10H8V9zm7.5-5l-1-1h-5l-1 1H5v2h14V4z", "segoe": "E74D" },
|
|
16
|
+
"trash.fill": { "path": "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", "segoe": "E74D" },
|
|
17
|
+
"pencil": { "path": "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", "segoe": "E70F" },
|
|
18
|
+
"square.and.pencil": { "path": "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", "segoe": "E70F" },
|
|
19
|
+
"ellipsis": { "path": "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z", "segoe": "E712" },
|
|
20
|
+
"ellipsis.circle": { "path": "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z", "segoe": "E712" },
|
|
21
|
+
"xmark": { "path": "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z", "segoe": "E711" },
|
|
22
|
+
"checkmark": { "path": "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z", "segoe": "E73E" },
|
|
23
|
+
"chevron.backward": { "path": "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z", "segoe": "E72B" },
|
|
24
|
+
"chevron.left": { "path": "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z", "segoe": "E72B" },
|
|
25
|
+
"chevron.right": { "path": "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z", "segoe": "E72A" },
|
|
26
|
+
"arrow.left": { "path": "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z", "segoe": "E72B" },
|
|
27
|
+
"arrow.right": { "path": "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z", "segoe": "E72A" },
|
|
28
|
+
"arrow.clockwise": { "path": "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z", "segoe": "E72C" },
|
|
29
|
+
"line.3.horizontal": { "path": "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z", "segoe": "E700" },
|
|
30
|
+
"line.3.horizontal.decrease": { "path": "M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z", "segoe": "E71C" },
|
|
31
|
+
"slider.horizontal.3": { "path": "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z", "segoe": "E9E9" },
|
|
32
|
+
"list.bullet": { "path": "M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z", "segoe": "E8FD" },
|
|
33
|
+
"bell": { "path": "M16 17H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6zm2-1v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-6 6c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2z", "segoe": "EA8F" },
|
|
34
|
+
"bell.fill": { "path": "M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z", "segoe": "EA8F" },
|
|
35
|
+
"person": { "path": "M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z", "segoe": "E77B" },
|
|
36
|
+
"person.fill": { "path": "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z", "segoe": "E77B" },
|
|
37
|
+
"person.crop.circle": { "path": "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6zm0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20z", "segoe": "E77B" },
|
|
38
|
+
"info.circle": { "path": "M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z", "segoe": "E946" },
|
|
39
|
+
"bookmark": { "path": "M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z", "segoe": "E8A4" },
|
|
40
|
+
"bookmark.fill": { "path": "M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z", "segoe": "E8A4" },
|
|
41
|
+
"folder": { "path": "M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z", "segoe": "E8B7" },
|
|
42
|
+
"folder.fill": { "path": "M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z", "segoe": "E8B7" },
|
|
43
|
+
"house": { "path": "M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z", "segoe": "E80F" },
|
|
44
|
+
"house.fill": { "path": "M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z", "segoe": "E80F" },
|
|
45
|
+
"paperplane": { "path": "M4.01 6.03l7.51 3.22-7.52-1 .01-2.22m7.5 8.72L4 17.97v-2.22l7.51-1M2.01 3L2 10l15 2-15 2 .01 7L23 12 2.01 3z", "segoe": "E724" },
|
|
46
|
+
"paperplane.fill": { "path": "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z", "segoe": "E724" },
|
|
47
|
+
"envelope": { "path": "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z", "segoe": "E715" },
|
|
48
|
+
"envelope.fill": { "path": "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z", "segoe": "E715" },
|
|
49
|
+
"calendar": { "path": "M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z", "segoe": "E787" },
|
|
50
|
+
"bag": { "path": "M19 6h-2c0-2.76-2.24-5-5-5S7 3.24 7 6H5c-1.1 0-1.99.9-1.99 2L3 20c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-3c1.66 0 3 1.34 3 3H9c0-1.66 1.34-3 3-3zm0 10c-2.76 0-5-2.24-5-5h2c0 1.66 1.34 3 3 3s3-1.34 3-3h2c0 2.76-2.24 5-5 5z", "segoe": "E719" },
|
|
51
|
+
"bag.fill": { "path": "M19 6h-2c0-2.76-2.24-5-5-5S7 3.24 7 6H5c-1.1 0-1.99.9-1.99 2L3 20c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-3c1.66 0 3 1.34 3 3H9c0-1.66 1.34-3 3-3zm0 10c-2.76 0-5-2.24-5-5h2c0 1.66 1.34 3 3 3s3-1.34 3-3h2c0 2.76-2.24 5-5 5z", "segoe": "E719" }
|
|
52
|
+
}
|
|
53
|
+
}
|
package/host-runtime.js
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// Runs inside Hermes. Bridges a renderer root to the native host:
|
|
2
|
+
// JS -> native: __host.post('batch' | 'timer' | 'error', json) (drained by Swift after each call)
|
|
3
|
+
// native -> JS: __bakeDispatch(listenerId, payload), __bakeDispatchEvent(event) (one DOM
|
|
4
|
+
// event along its capture / bubble path), __bakeTimer(id), __bakeHostEvent(name, payload),
|
|
5
|
+
// __bakeNet(id, event) (fetch answers, web-fetch.js)
|
|
6
|
+
// installed by the host before this runs: globalThis.native.<Module>.<fn> (JSI functions),
|
|
7
|
+
// __bakeInitialProps (root component props), __bakeEmit(name, payload) (JS -> host events),
|
|
8
|
+
// __bakeReportError({kind, message, stack, code}) (debug cores only: the red error overlay)
|
|
9
|
+
import { createBatchWriter } from './batch-wire.js';
|
|
10
|
+
import { isTransformOnlyUpdate, isTransformValue } from './transform.js';
|
|
11
|
+
import { installDeterminism } from './determinism.js';
|
|
12
|
+
import { installWebFetch } from './web-fetch.js';
|
|
13
|
+
import { installWebCrypto } from './web-crypto.js';
|
|
14
|
+
import { installDialogs } from './dialogs.js';
|
|
15
|
+
import { installVisibility } from './visibility.js';
|
|
16
|
+
import { installElementApi } from './element-api.js';
|
|
17
|
+
import { installMediaElement } from './media-element.js';
|
|
18
|
+
import { installPageElements } from './page-elements.js';
|
|
19
|
+
import { installCloseWatcher } from './close-watcher.js';
|
|
20
|
+
import { nativeViewRefs } from './view-ref-writer.js';
|
|
21
|
+
import { bakeProps, installBakeTraps, takePropReads, throwIfRead } from './first-screen.js';
|
|
22
|
+
|
|
23
|
+
// The Rust host installs this function before loading the bundle. Swift and the baker
|
|
24
|
+
// keep using the JSON transport until they move to the Rust runtime.
|
|
25
|
+
const sendBinary = globalThis.__bakeBatch;
|
|
26
|
+
const post = globalThis.__bakePost ?? __host.post;
|
|
27
|
+
// Real time (the injected clock may be driven) for the per-batch encode-time sample.
|
|
28
|
+
const wallNow = globalThis.__bakeWallNow;
|
|
29
|
+
|
|
30
|
+
// Scoped <style> blocks: the compiler emits registerUniversalStyles(moduleId, [{id, css}])
|
|
31
|
+
// at module evaluation, so sheets reach the host before the first commit.
|
|
32
|
+
export function sendStyles(moduleId, sheets) {
|
|
33
|
+
post('styles', JSON.stringify({ moduleId, sheets }));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// --- errors: a debug core installs __bakeReportError and shows what reaches it on the
|
|
37
|
+
// host's red error overlay (`bake inspect errors`). Render / commit errors no boundary claims go
|
|
38
|
+
// there through the root's onUncaughtError, unhandled promise rejections through Hermes'
|
|
39
|
+
// rejection tracker. Errors that escape a host entry (timers, events) the core sees itself.
|
|
40
|
+
// A release core installs nothing: no handler, no tracker, behavior as before.
|
|
41
|
+
const reportError = globalThis.__bakeReportError;
|
|
42
|
+
const report =
|
|
43
|
+
reportError &&
|
|
44
|
+
((kind, e) => reportError({ kind, message: String(e?.message ?? e), stack: String(e?.stack ?? ''), code: e?.code ?? null }));
|
|
45
|
+
if (report)
|
|
46
|
+
globalThis.HermesInternal?.enablePromiseRejectionTracker?.({
|
|
47
|
+
allRejections: true,
|
|
48
|
+
onUnhandled: (_id, e) => report('unhandledRejection', e),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// --- timers (Hermes has no setTimeout; the runtime's core thread schedules them on the root's
|
|
52
|
+
// injected clock and calls back: setTimeout / setInterval / rAF never cross the main thread.
|
|
53
|
+
// Timers due in the same frame commit once; a driven clock moves only when a test says so) ---
|
|
54
|
+
let nextTimer = 1;
|
|
55
|
+
const timers = new Map();
|
|
56
|
+
function schedule(fn, ms, args, repeat, frame = false) {
|
|
57
|
+
if (typeof fn !== 'function') throw new TypeError('Timer callback must be a function');
|
|
58
|
+
const id = nextTimer++;
|
|
59
|
+
ms = Math.max(0, Number(ms) || 0);
|
|
60
|
+
timers.set(id, { fn, args, ms, repeat, frame });
|
|
61
|
+
post('timer', JSON.stringify({ id, ms, frame }));
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
64
|
+
function cancel(id) {
|
|
65
|
+
if (timers.delete(id) && sendBinary) post('cancelTimer', JSON.stringify(id));
|
|
66
|
+
}
|
|
67
|
+
globalThis.setTimeout = (fn, ms, ...args) => schedule(fn, ms, args, false);
|
|
68
|
+
globalThis.setInterval = (fn, ms, ...args) => schedule(fn, ms, args, true);
|
|
69
|
+
globalThis.clearTimeout = globalThis.clearInterval = cancel;
|
|
70
|
+
globalThis.__bakeTimer = (id, time) => {
|
|
71
|
+
const t = timers.get(id);
|
|
72
|
+
if (!t) return;
|
|
73
|
+
if (t.repeat) post('timer', JSON.stringify({ id, ms: t.ms }));
|
|
74
|
+
else timers.delete(id);
|
|
75
|
+
if (t.frame) t.fn(time);
|
|
76
|
+
else t.fn(...t.args);
|
|
77
|
+
};
|
|
78
|
+
if (sendBinary) {
|
|
79
|
+
globalThis.requestAnimationFrame = (fn) => schedule(fn, 0, [], false, true);
|
|
80
|
+
globalThis.cancelAnimationFrame = cancel;
|
|
81
|
+
// Date.now / new Date / performance.now on the injected clock; with a driven clock a fixed
|
|
82
|
+
// start, Math.random seed, locale and time zone (determinism.js).
|
|
83
|
+
installDeterminism(globalThis, globalThis.__bakeNow, globalThis.__bakeDeterminism);
|
|
84
|
+
// performance.mark(name): also a marker on the host's perf monitor (a screen, a route change),
|
|
85
|
+
// sent as a log line the host takes out of the console ("\u0001bake:mark <name>").
|
|
86
|
+
const perf = (globalThis.performance ??= {});
|
|
87
|
+
const mark = perf.mark;
|
|
88
|
+
perf.mark = (name, options) => {
|
|
89
|
+
console.log('\u0001bake:mark ' + String(name));
|
|
90
|
+
return typeof mark === 'function' ? mark.call(perf, name, options) : undefined;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// fetch, Request / Response / Headers, AbortController, URL, Blob, ...: one script for
|
|
94
|
+
// every native target; requests go to the core thread (mock routes, then the platform
|
|
95
|
+
// transport) and answers come back through __bakeNet. The baker (no __bakeBatch) has no network:
|
|
96
|
+
// fetch rejects there.
|
|
97
|
+
// Bundled only when the app names one of these globals (bake build, __BAKE_WEB_FETCH__).
|
|
98
|
+
if (__BAKE_WEB_FETCH__) installWebFetch(globalThis, sendBinary ? post : null);
|
|
99
|
+
// CloseWatcher: Android's back, Escape and other close requests (close-watcher.js); the core keeps
|
|
100
|
+
// the stack and asks a watcher through __bakeDispatch(-1, {type: 'closerequest', id}).
|
|
101
|
+
const closeRequest = installCloseWatcher(globalThis, sendBinary ? post : null);
|
|
102
|
+
// crypto.getRandomValues / randomUUID from the OS CSPRNG (web-crypto.js, the core's
|
|
103
|
+
// __bakeRandomWords). Installed before the app module runs, so the bake's traps (installed at
|
|
104
|
+
// mount) see it. Bundled only when the app names `crypto` (bake build, __BAKE_WEB_CRYPTO__).
|
|
105
|
+
if (__BAKE_WEB_CRYPTO__) installWebCrypto(globalThis);
|
|
106
|
+
// alert() / confirm() as the platform's system dialog, returning a Promise (dialogs.js, the
|
|
107
|
+
// built-in native.BakeDialogs). Bundled only when the app names one (bake build, __BAKE_DIALOGS__).
|
|
108
|
+
if (__BAKE_DIALOGS__) installDialogs(globalThis);
|
|
109
|
+
|
|
110
|
+
// --- host events (root.send(name, payload) in Swift); `host.on` in @bake-native/octane subscribes ---
|
|
111
|
+
const hostListeners = (globalThis.__bakeHostListeners ??= new Map());
|
|
112
|
+
globalThis.__bakeHostEvent = (name, payload) => {
|
|
113
|
+
const set = hostListeners.get(name);
|
|
114
|
+
if (set) for (const fn of [...set]) fn(payload);
|
|
115
|
+
return true;
|
|
116
|
+
};
|
|
117
|
+
// document.visibilityState / hidden / visibilitychange from the host's __bakeVisibility events
|
|
118
|
+
// (visibility.js). Bundled only when the app names one (bake build, __BAKE_VISIBILITY__).
|
|
119
|
+
if (__BAKE_VISIBILITY__) installVisibility(globalThis, hostListeners);
|
|
120
|
+
|
|
121
|
+
// Renderer batches cross as OCB2: a typed, varint-encoded stream generated from
|
|
122
|
+
// native/rust/schema/batch.oschema. Strings and template programs are defined once per VM and
|
|
123
|
+
// referenced by index afterwards, so the writer lives as long as this module (and the VM).
|
|
124
|
+
// `__bakeBatchJson` (the runtime's BAKE_BATCH_JSON=1) selects the debug encoding: JSON text.
|
|
125
|
+
const debugJson = globalThis.__bakeBatchJson === true;
|
|
126
|
+
// `__bakeBatchVerify` (BAKE_BATCH_VERIFY=1): each batch also goes as JSON text and the runtime
|
|
127
|
+
// checks that the binary one decodes to it.
|
|
128
|
+
const verify = globalThis.__bakeBatchVerify === true;
|
|
129
|
+
// Transform-only updates (an animation loop moving views): Octane's update classifier sees every
|
|
130
|
+
// update's props before and after; one whose only change is the inline `style.transform` is sent
|
|
131
|
+
// as `set-transform` (batch.oschema), the new transform alone (its numbers when it is an
|
|
132
|
+
// `@bake-native/octane` value). Not in the decode-equality checks (`verify`, golden), which
|
|
133
|
+
// compare each command with its JSON. Entries live until the next encode (a Map is cheaper than a
|
|
134
|
+
// WeakMap per update in Hermes); a batch Octane holds past another encode is sent as plain updates.
|
|
135
|
+
const transformOnly = new Map(); // next props -> its new transform
|
|
136
|
+
const setTransform = { op: 'set-transform', id: 0, transform: '' };
|
|
137
|
+
let lowerTransforms = !verify;
|
|
138
|
+
const writer = sendBinary && !debugJson
|
|
139
|
+
? createBatchWriter({
|
|
140
|
+
'set-transform'(c) {
|
|
141
|
+
if (!lowerTransforms) return undefined;
|
|
142
|
+
const t = transformOnly.get(c.props);
|
|
143
|
+
if (t === undefined) return undefined;
|
|
144
|
+
setTransform.id = c.id;
|
|
145
|
+
setTransform.transform = t;
|
|
146
|
+
return setTransform;
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
: null;
|
|
150
|
+
|
|
151
|
+
// --- phase timings (BAKE_PHASE_TIMINGS=1 builds only, tools/perf/phases.mjs): per batch, the time
|
|
152
|
+
// from the JS entry (dispatch, timer, host event) or the previous batch to this batch's encode,
|
|
153
|
+
// i.e. event handler + Octane render + diff, logged as "\u0001bake:phase render <ms>" after the
|
|
154
|
+
// batch is sent. `phaseAt` is that entry's start on the wall clock.
|
|
155
|
+
let phaseAt = 0;
|
|
156
|
+
function timeEntries() {
|
|
157
|
+
for (const name of ['__bakeDispatch', '__bakeDispatchEvent', '__bakeTimer', '__bakeHostEvent']) {
|
|
158
|
+
const f = globalThis[name];
|
|
159
|
+
if (typeof f === 'function') globalThis[name] = function (...args) { phaseAt = wallNow(); return f.apply(this, args); };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// --- `View` refs: the writer (view-ref-writer.js) only in bundles that call setTransform or
|
|
164
|
+
// setOpacity (`bake build`: __BAKE_VIEW_REF__, fail-closed.mjs usesViewRef). view-ref.js finds it here.
|
|
165
|
+
const viewRefs = __BAKE_VIEW_REF__ ? (globalThis.__bakeViewRefs = nativeViewRefs(globalThis)) : null;
|
|
166
|
+
|
|
167
|
+
// --- driver: every accepted commit becomes one batch for the native host ---
|
|
168
|
+
const EVENT_ALIASES = { press: 'click', doubleclick: 'dblclick' };
|
|
169
|
+
const driver = {
|
|
170
|
+
id: 'native',
|
|
171
|
+
updates: {
|
|
172
|
+
// `changed` (patches/octane@0.27.1.patch): `next` is `previous` with only `next[changed.name]`
|
|
173
|
+
// replaced, a style object a signal binding built that differs from the previous one only in
|
|
174
|
+
// `changed.keys`; then a transform-only update needs no walk over the props.
|
|
175
|
+
// `onlyTransform` (React, which compares the props once in commitUpdate): whether `next` is
|
|
176
|
+
// `previous` with only `style.transform` replaced, between style objects with the same keys.
|
|
177
|
+
classify(_type, previous, next, changed, onlyTransform) {
|
|
178
|
+
// `View` refs (view-ref.js): an update that declares a written view's transform or opacity
|
|
179
|
+
// anew is the later write.
|
|
180
|
+
if (__BAKE_VIEW_REF__) viewRefs.classify(previous, next, changed);
|
|
181
|
+
if (writer === null) return 'update';
|
|
182
|
+
if (onlyTransform !== undefined) {
|
|
183
|
+
if (onlyTransform && isTransformValue(next.style.transform)) transformOnly.set(next, next.style.transform);
|
|
184
|
+
} else if (changed !== undefined && changed.name === 'style') {
|
|
185
|
+
if (changed.keys.length === 1 && changed.keys[0] === 'transform' && isTransformValue(next.style.transform)) {
|
|
186
|
+
transformOnly.set(next, next.style.transform);
|
|
187
|
+
}
|
|
188
|
+
} else if (isTransformOnlyUpdate(previous, next)) {
|
|
189
|
+
transformOnly.set(next, next.style.transform);
|
|
190
|
+
}
|
|
191
|
+
return 'update';
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
events: {
|
|
195
|
+
classify(name) {
|
|
196
|
+
if (!/^on[A-Z]/.test(name)) return null;
|
|
197
|
+
const type = name.slice(2).toLowerCase();
|
|
198
|
+
return { type: EVENT_ALIASES[type] ?? type, priority: 'discrete' };
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
// Encoded when applied, not when prepared: Octane may hold a prepared batch (suspended) and
|
|
202
|
+
// abort it after later batches were sent, and the stream's definitions must follow the order
|
|
203
|
+
// batches reach the core.
|
|
204
|
+
prepareBatch(_container, batch) {
|
|
205
|
+
return {
|
|
206
|
+
apply() {
|
|
207
|
+
// Destroyed nodes: their handles and addEventListener listeners go (ids are not reused).
|
|
208
|
+
if (elements.size !== 0) {
|
|
209
|
+
for (const c of batch.commands) {
|
|
210
|
+
if (c.op === 'destroy' && elements.has(c.id)) {
|
|
211
|
+
elements.delete(c.id);
|
|
212
|
+
if (__BAKE_ELEMENT_API__) refListeners.delete(c.id);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
mediaApi?.track(batch.commands);
|
|
217
|
+
if (__BAKE_VIEW_REF__) viewRefs.commit(batch.commands);
|
|
218
|
+
if (typeof batch.version === 'number') lastBatchVersion = batch.version;
|
|
219
|
+
const t0 = wallNow ? wallNow() : 0;
|
|
220
|
+
// Tests: the same batch in the debug encoding, for the decode-equality check.
|
|
221
|
+
const golden = globalThis.__bakeBatchGolden;
|
|
222
|
+
lowerTransforms = !verify && !golden;
|
|
223
|
+
let payload;
|
|
224
|
+
try {
|
|
225
|
+
payload = writer ? writer.encode(batch) : JSON.stringify(batch);
|
|
226
|
+
} finally {
|
|
227
|
+
transformOnly.clear();
|
|
228
|
+
}
|
|
229
|
+
const encodeMs = wallNow ? wallNow() - t0 : 0;
|
|
230
|
+
if (golden) golden(payload, JSON.stringify(batch));
|
|
231
|
+
if (!sendBinary) post('batch', payload);
|
|
232
|
+
else if (verify && writer) sendBinary(payload, encodeMs, JSON.stringify(batch));
|
|
233
|
+
else sendBinary(payload, encodeMs);
|
|
234
|
+
if (__BAKE_PHASE_TIMINGS__ && wallNow && phaseAt !== 0) {
|
|
235
|
+
console.log('\u0001bake:phase render ' + (t0 - phaseAt));
|
|
236
|
+
phaseAt = wallNow();
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
abort() {},
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
// Refs get the same element handle as event targets (`event.target === ref.current`).
|
|
243
|
+
getPublicInstance(_container, id) {
|
|
244
|
+
return element(id);
|
|
245
|
+
},
|
|
246
|
+
// A node with a handle (a ref, an event's target) may have listeners, pointer capture, media
|
|
247
|
+
// state or direct writes behind it, which go only when the node is destroyed: a renderer that
|
|
248
|
+
// reuses native views for other elements leaves such a node alone.
|
|
249
|
+
hasPublicInstance(id) {
|
|
250
|
+
return elements.has(id);
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// --- document.documentElement / document.body (page-elements.js): their writes go to the core as
|
|
255
|
+
// `update`s of their reserved ids (batch.oschema).
|
|
256
|
+
const PAGE_IDS = [0xfffffff0, 0xfffffff1];
|
|
257
|
+
let lastBatchVersion = 0;
|
|
258
|
+
/** Sends the page elements' props (`page-elements.js`), as `update`s of their reserved ids. */
|
|
259
|
+
function sendPage(elements) {
|
|
260
|
+
const commands = elements.map((el) => ({ op: 'update', id: PAGE_IDS[el.__index], props: el.__props() }));
|
|
261
|
+
// The renderer's last batch version (the core keeps the last one it saw; page batches repeat it).
|
|
262
|
+
const batch = { renderer: 'native', version: lastBatchVersion, commands };
|
|
263
|
+
const payload = writer ? writer.encode(batch) : JSON.stringify(batch);
|
|
264
|
+
if (!sendBinary) post('batch', payload);
|
|
265
|
+
else sendBinary(payload, 0);
|
|
266
|
+
}
|
|
267
|
+
// Only in bundles that name document.documentElement or document.body (`bake build`:
|
|
268
|
+
// __BAKE_PAGE_ELEMENTS__, fail-closed.mjs usesPageElements): the rest pay nothing for it.
|
|
269
|
+
if (__BAKE_PAGE_ELEMENTS__) installPageElements(globalThis, sendPage);
|
|
270
|
+
|
|
271
|
+
// --- element handles: the element APIs (element-api.js) only in bundles that use them.
|
|
272
|
+
const elementApi = __BAKE_ELEMENT_API__ ? installElementApi(globalThis, (id) => element(id)) : null;
|
|
273
|
+
const refListeners = elementApi ? elementApi.refListeners : new Map();
|
|
274
|
+
const runRefListeners = elementApi ? elementApi.runRefListeners : () => {};
|
|
275
|
+
// --- <video> handles: the media element's members (media-element.js) only in bundles that
|
|
276
|
+
// render <video>, on top of the element APIs' prototype when the bundle has those too.
|
|
277
|
+
const mediaApi = __BAKE_MEDIA__
|
|
278
|
+
? installMediaElement(elementApi ? elementApi.proto : null, (id, proto) => {
|
|
279
|
+
const el = elements.get(id);
|
|
280
|
+
if (el && Object.getPrototypeOf(el) !== proto) Object.setPrototypeOf(el, proto);
|
|
281
|
+
})
|
|
282
|
+
: null;
|
|
283
|
+
|
|
284
|
+
// --- DOM events with propagation ---
|
|
285
|
+
// The core sends one event with its listeners in dispatch order: [listener, nodeId, phase]
|
|
286
|
+
// (1 capture, 2 at target, 3 bubble). One event object goes to all of them, as in the DOM:
|
|
287
|
+
// stopPropagation() ends the path after the current element, stopImmediatePropagation() at
|
|
288
|
+
// once, preventDefault() cancels the core's default action (Tab navigation). Elements are
|
|
289
|
+
// handles: {id, setPointerCapture, releasePointerCapture, hasPointerCapture}. The outcome goes
|
|
290
|
+
// back as an `eventDone` post before this returns.
|
|
291
|
+
const elements = new Map();
|
|
292
|
+
const captured = new Map(); // pointerId -> node id (what JS asked for; the core decides)
|
|
293
|
+
let pendingCaptures = null;
|
|
294
|
+
function element(id) {
|
|
295
|
+
if (id == null) return null;
|
|
296
|
+
let el = elements.get(id);
|
|
297
|
+
if (!el) {
|
|
298
|
+
const proto = mediaApi?.isVideo(id) ? mediaApi.proto : elementApi?.proto;
|
|
299
|
+
el = Object.assign(proto ? Object.create(proto) : {}, {
|
|
300
|
+
id,
|
|
301
|
+
nodeType: 1,
|
|
302
|
+
setPointerCapture(pointerId) {
|
|
303
|
+
captured.set(pointerId, id);
|
|
304
|
+
(pendingCaptures ??= []).push([id, pointerId, 1]);
|
|
305
|
+
},
|
|
306
|
+
releasePointerCapture(pointerId) {
|
|
307
|
+
if (captured.get(pointerId) === id) captured.delete(pointerId);
|
|
308
|
+
(pendingCaptures ??= []).push([id, pointerId, 0]);
|
|
309
|
+
},
|
|
310
|
+
hasPointerCapture(pointerId) {
|
|
311
|
+
return captured.get(pointerId) === id;
|
|
312
|
+
},
|
|
313
|
+
}, __BAKE_POPOVER__ ? popoverMembers(id) : null);
|
|
314
|
+
elements.set(id, el);
|
|
315
|
+
}
|
|
316
|
+
return el;
|
|
317
|
+
}
|
|
318
|
+
// The Popover API: the core keeps the top layer and fires `toggle` (bake_core::popover). The
|
|
319
|
+
// state changes once this JS turn ends (after the commit it is in). `source` (an element
|
|
320
|
+
// handle): a press on it is inside the popover (light dismiss). Only in bundles that name a
|
|
321
|
+
// member (`bake build`: __BAKE_POPOVER__, fail-closed.mjs usesPopover).
|
|
322
|
+
function popoverMembers(id) {
|
|
323
|
+
return {
|
|
324
|
+
showPopover(options) {
|
|
325
|
+
popover(id, 'show', undefined, options?.source?.id);
|
|
326
|
+
},
|
|
327
|
+
hidePopover() {
|
|
328
|
+
popover(id, 'hide');
|
|
329
|
+
},
|
|
330
|
+
togglePopover(options) {
|
|
331
|
+
const force = typeof options === 'boolean' ? options : options?.force;
|
|
332
|
+
popover(id, 'toggle', typeof force === 'boolean' ? force : undefined, options?.source?.id);
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function popover(id, op, force, source) {
|
|
337
|
+
if (!sendBinary) return;
|
|
338
|
+
const msg = { id, op };
|
|
339
|
+
if (force !== undefined) msg.force = force;
|
|
340
|
+
if (source != null) msg.source = source;
|
|
341
|
+
post('popover', JSON.stringify(msg));
|
|
342
|
+
}
|
|
343
|
+
function dispatchDomEvent(root, message, isInactiveListenerError) {
|
|
344
|
+
const { token, type, target, related, payload, deliveries } = message;
|
|
345
|
+
if (type === 'lostpointercapture' || type === 'pointerup' || type === 'pointercancel') {
|
|
346
|
+
if (captured.get(payload.pointerId) === target || type !== 'lostpointercapture') captured.delete(payload.pointerId);
|
|
347
|
+
} else if (type === 'gotpointercapture') {
|
|
348
|
+
captured.set(payload.pointerId, target);
|
|
349
|
+
}
|
|
350
|
+
let stopped = false;
|
|
351
|
+
let immediate = false;
|
|
352
|
+
let prevented = false;
|
|
353
|
+
const eventTarget = element(target);
|
|
354
|
+
if (eventTarget && typeof payload.target?.value === 'string') eventTarget.value = payload.target.value;
|
|
355
|
+
const event = Object.assign({}, payload, {
|
|
356
|
+
type,
|
|
357
|
+
target: eventTarget,
|
|
358
|
+
currentTarget: null,
|
|
359
|
+
relatedTarget: element(related),
|
|
360
|
+
eventPhase: 0,
|
|
361
|
+
get defaultPrevented() {
|
|
362
|
+
return prevented;
|
|
363
|
+
},
|
|
364
|
+
preventDefault() {
|
|
365
|
+
if (payload.cancelable) prevented = true;
|
|
366
|
+
},
|
|
367
|
+
stopPropagation() {
|
|
368
|
+
stopped = true;
|
|
369
|
+
},
|
|
370
|
+
stopImmediatePropagation() {
|
|
371
|
+
stopped = true;
|
|
372
|
+
immediate = true;
|
|
373
|
+
event.__immediate = true;
|
|
374
|
+
},
|
|
375
|
+
persist() {},
|
|
376
|
+
nativeEvent: null,
|
|
377
|
+
});
|
|
378
|
+
event.nativeEvent = event;
|
|
379
|
+
pendingCaptures = null;
|
|
380
|
+
let error = null;
|
|
381
|
+
function dispatch() {
|
|
382
|
+
let current = null;
|
|
383
|
+
let refsAtTarget = false;
|
|
384
|
+
for (let i = 0; i < deliveries.length; i++) {
|
|
385
|
+
const delivery = deliveries[i];
|
|
386
|
+
const listener = delivery[0];
|
|
387
|
+
const node = delivery[1];
|
|
388
|
+
const phase = delivery[2];
|
|
389
|
+
if (immediate || (stopped && node !== current)) break;
|
|
390
|
+
current = node;
|
|
391
|
+
event.currentTarget = element(node);
|
|
392
|
+
event.eventPhase = phase;
|
|
393
|
+
try {
|
|
394
|
+
// 0: only addEventListener listeners of this element.
|
|
395
|
+
if (listener !== 0) root.dispatchEvent(listener, event);
|
|
396
|
+
if (__BAKE_ELEMENT_API__ && refListeners.has(node)) {
|
|
397
|
+
if (phase === 1) runRefListeners(node, type + 'capture', event);
|
|
398
|
+
else if (phase === 3) runRefListeners(node, type, event);
|
|
399
|
+
else if (!refsAtTarget) {
|
|
400
|
+
// At the target both phases run, capture first, once per event.
|
|
401
|
+
refsAtTarget = true;
|
|
402
|
+
runRefListeners(node, type + 'capture', event);
|
|
403
|
+
if (!immediate) runRefListeners(node, type, event);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
} catch (e) {
|
|
407
|
+
// A listener an earlier one unmounted no longer runs (the DOM's removed listener).
|
|
408
|
+
if (!isInactiveListenerError?.(e)) error ??= e;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
if (root.eventScope) root.eventScope('discrete', dispatch);
|
|
414
|
+
else dispatch();
|
|
415
|
+
} finally {
|
|
416
|
+
event.currentTarget = null;
|
|
417
|
+
event.eventPhase = 0;
|
|
418
|
+
post('eventDone', JSON.stringify({ token, prevented, captures: pendingCaptures ?? [] }));
|
|
419
|
+
pendingCaptures = null;
|
|
420
|
+
}
|
|
421
|
+
if (error) throw error;
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** The adapter supplies render, prepare and dispatchEvent. The host owns the first commit and wire protocol. */
|
|
426
|
+
export function mountNative(App, adapter) {
|
|
427
|
+
const root = adapter.createRoot(driver, {
|
|
428
|
+
scheduleMicrotask: (cb) => queueMicrotask(cb),
|
|
429
|
+
onUncaughtError: report && ((e) => report('render', e)),
|
|
430
|
+
});
|
|
431
|
+
if (root.runInput) {
|
|
432
|
+
for (const name of ['__bakeHostEvent', '__bakeTimer']) {
|
|
433
|
+
const dispatch = globalThis[name];
|
|
434
|
+
globalThis[name] = (...args) => root.runInput(() => dispatch(...args));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// A target-only event (input, change, scroll, submit, media, ...) goes to the one listener of
|
|
438
|
+
// the element it happened on, so that element is the currentTarget while the listener runs, as
|
|
439
|
+
// in the DOM, and null once dispatch is over. The core sends the element's fields as `target`.
|
|
440
|
+
globalThis.__bakeDispatch = (listener, payload) => {
|
|
441
|
+
// A close request for a CloseWatcher (bake_core::close_watch::CLOSE_WATCHER_LISTENER): a
|
|
442
|
+
// discrete user event, as a click.
|
|
443
|
+
if (listener === -1) {
|
|
444
|
+
if (root.eventScope) root.eventScope('discrete', () => closeRequest(payload.id));
|
|
445
|
+
else closeRequest(payload.id);
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
payload = (mediaApi ? mediaApi.event(payload, element) : payload) ?? {};
|
|
449
|
+
const at = payload.currentTarget ?? payload.target;
|
|
450
|
+
const own = at != null && typeof at === 'object';
|
|
451
|
+
if (own) payload.currentTarget = at;
|
|
452
|
+
try {
|
|
453
|
+
if (listener !== 0) root.dispatchEvent(listener, payload);
|
|
454
|
+
} finally {
|
|
455
|
+
if (own) payload.currentTarget = null;
|
|
456
|
+
}
|
|
457
|
+
// A target-only event an element handle listens to: `__bakeNode` names it.
|
|
458
|
+
const node = __BAKE_ELEMENT_API__ ? payload.__bakeNode : null;
|
|
459
|
+
if (__BAKE_ELEMENT_API__ && node != null && refListeners.has(node)) {
|
|
460
|
+
// These events do not bubble here, and their default action (a click's) already ran.
|
|
461
|
+
const target = element(node);
|
|
462
|
+
if (payload.type === 'change') Object.assign(target, payload.target);
|
|
463
|
+
const event = Object.assign({}, payload, {
|
|
464
|
+
target, currentTarget: target, eventPhase: 2, defaultPrevented: false,
|
|
465
|
+
preventDefault() { if (payload.cancelable) event.defaultPrevented = true; },
|
|
466
|
+
stopPropagation() {},
|
|
467
|
+
stopImmediatePropagation() { event.__immediate = true; },
|
|
468
|
+
});
|
|
469
|
+
delete event.__bakeNode;
|
|
470
|
+
try {
|
|
471
|
+
// At the target both phases run, capture first.
|
|
472
|
+
runRefListeners(node, payload.type + 'capture', event);
|
|
473
|
+
if (!event.__immediate) runRefListeners(node, payload.type, event);
|
|
474
|
+
} finally {
|
|
475
|
+
event.currentTarget = null;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return true;
|
|
479
|
+
};
|
|
480
|
+
globalThis.__bakeDispatchEvent = (event) => dispatchDomEvent(root, event, adapter.isInactiveListenerError);
|
|
481
|
+
globalThis.__bakeRoot = root;
|
|
482
|
+
if (__BAKE_PHASE_TIMINGS__ && wallNow) timeEntries();
|
|
483
|
+
// The first render is the baked one (docs/design/first-screen-locales.md): no props (the root
|
|
484
|
+
// component's parameter defaults), and while baking, a read of time, randomness, Intl, props
|
|
485
|
+
// or a native member throws (first-screen.js). The host's props follow right after the first
|
|
486
|
+
// commit, as an update.
|
|
487
|
+
const props = globalThis.__bakeInitialProps ?? {};
|
|
488
|
+
const restore = globalThis.__bakeBaking ? installBakeTraps() : null;
|
|
489
|
+
// bake-frame, and bake build's layout preview of an app it bakes (`__bakeBakePreview`, without the
|
|
490
|
+
// traps): the render is recorded before its refs and effects are committed, which need the
|
|
491
|
+
// live host. Nothing after the first render runs in a bake.
|
|
492
|
+
const prepared = !!restore || globalThis.__bakeBakePreview === true;
|
|
493
|
+
// An app bake.config.ts leaves unbaked (bake: false) has no first screen to match: its first
|
|
494
|
+
// render gets the host's props.
|
|
495
|
+
const excluded = typeof __BAKE_FRAME_EXCLUDED__ !== 'undefined' && __BAKE_FRAME_EXCLUDED__;
|
|
496
|
+
try {
|
|
497
|
+
const first = excluded ? props : restore ? bakeProps(adapter.reservedRootProps) : {};
|
|
498
|
+
if (prepared) {
|
|
499
|
+
const attempt = root.prepare(App, first);
|
|
500
|
+
if (attempt.status === 'prepared') post('batch', JSON.stringify(attempt.batch));
|
|
501
|
+
} else {
|
|
502
|
+
root.render(App, first);
|
|
503
|
+
}
|
|
504
|
+
// While baking: the props the root read (bake build checks them against its parameter
|
|
505
|
+
// defaults), then every value the first render read that a baked first screen cannot know,
|
|
506
|
+
// at once (first-screen.js).
|
|
507
|
+
if (restore) {
|
|
508
|
+
post('firstScreenProps', JSON.stringify(takePropReads()));
|
|
509
|
+
throwIfRead();
|
|
510
|
+
}
|
|
511
|
+
} catch (e) {
|
|
512
|
+
// A render that broke on a stand-in value fails with the reads that caused it.
|
|
513
|
+
if (restore && e?.name !== 'FirstScreenReads') throwIfRead();
|
|
514
|
+
// The first render throws out of the bundle's evaluation; reported as a render error first.
|
|
515
|
+
report?.('render', e);
|
|
516
|
+
throw e;
|
|
517
|
+
} finally {
|
|
518
|
+
restore?.();
|
|
519
|
+
}
|
|
520
|
+
if (!excluded && !prepared && Object.keys(props).length) setTimeout(() => root.render(App, props), 0);
|
|
521
|
+
}
|
package/image-props.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const objectFit = { cover: 'cover', contain: 'contain', stretch: 'fill', center: 'scale-down' };
|
|
2
|
+
|
|
3
|
+
export function imageFit(mode) {
|
|
4
|
+
if (mode == null) return objectFit.cover;
|
|
5
|
+
if (!Object.hasOwn(objectFit, mode)) {
|
|
6
|
+
throw new Error('Unsupported Image resizeMode. Use cover, contain, stretch or center.');
|
|
7
|
+
}
|
|
8
|
+
return objectFit[mode];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function imageSource(source) {
|
|
12
|
+
if (source == null) return undefined;
|
|
13
|
+
if (typeof source === 'string' && source.trim()) return source;
|
|
14
|
+
if (typeof source === 'object' && Object.hasOwn(source, 'uri')
|
|
15
|
+
&& Object.keys(source).length === 1 && typeof source.uri === 'string' && source.uri.trim()) return source.uri;
|
|
16
|
+
throw new Error('Image source must be an imported image or a single { uri } object. Import local images at the top of the file.');
|
|
17
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './dist/index.mjs';
|
|
2
|
+
export * from './native.js';
|
|
3
|
+
export * from './native-args.js';
|
|
4
|
+
export * from './text.js';
|
|
5
|
+
export * from './locale-entry.js';
|
|
6
|
+
export * from './transform.js';
|
|
7
|
+
export type { ViewRef } from './view-ref.js';
|
|
8
|
+
export * from './views.js';
|
package/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { defineConfig } from './dist/index.mjs';
|
|
2
|
+
export { native, hasNative, host, registerWebModule } from './native-entry.js';
|
|
3
|
+
export { webSpec } from './native-args-entry.js';
|
|
4
|
+
export { createMeasureContext, installMeasureOnlyCanvas, measureText } from './text.js';
|
|
5
|
+
export { dir, locale, setLocale } from './locale-entry.js';
|
|
6
|
+
export { Transform, transform } from './transform-entry.js';
|
|
7
|
+
export { viewCommand } from './views.js';
|