@ng-native/desktop 0.0.0-stage → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +51 -2
- package/app.plugin.cjs +17 -0
- package/bin/app-config.mjs +168 -0
- package/bin/autolink.mjs +224 -0
- package/bin/cli.mjs +158 -0
- package/bin/host.mjs +427 -0
- package/bin/ng-native-desktop.mjs +4 -0
- package/bin/package.mjs +971 -0
- package/bin/plist.mjs +68 -0
- package/bin/prebuilt.mjs +328 -0
- package/bin/toolchain.mjs +192 -0
- package/native/CMakeLists.txt +276 -0
- package/native/appkit/CMakeLists.txt +109 -0
- package/native/appkit/address-search.h +26 -0
- package/native/appkit/address-search.mm +277 -0
- package/native/appkit/animation-frames.h +14 -0
- package/native/appkit/animation-frames.mm +106 -0
- package/native/appkit/app-info.h +12 -0
- package/native/appkit/app-info.mm +98 -0
- package/native/appkit/app-updater.mm +128 -0
- package/native/appkit/app-windows.h +81 -0
- package/native/appkit/app-windows.mm +318 -0
- package/native/appkit/appkit-backend.h +73 -0
- package/native/appkit/appkit-backend.mm +276 -0
- package/native/appkit/apple-authentication.h +19 -0
- package/native/appkit/apple-authentication.mm +248 -0
- package/native/appkit/apple-button-view.h +10 -0
- package/native/appkit/apple-button-view.mm +37 -0
- package/native/appkit/apple-id-button.h +16 -0
- package/native/appkit/apple-id-button.mm +50 -0
- package/native/appkit/audio.h +16 -0
- package/native/appkit/audio.mm +275 -0
- package/native/appkit/battery.h +13 -0
- package/native/appkit/battery.mm +92 -0
- package/native/appkit/bookmarks.h +17 -0
- package/native/appkit/bookmarks.mm +145 -0
- package/native/appkit/calendar.h +25 -0
- package/native/appkit/calendar.mm +660 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +130 -0
- package/native/appkit/camera.h +39 -0
- package/native/appkit/camera.mm +362 -0
- package/native/appkit/cg-canvas.h +17 -0
- package/native/appkit/cg-canvas.mm +518 -0
- package/native/appkit/component-view.h +17 -0
- package/native/appkit/crypto.h +19 -0
- package/native/appkit/crypto.mm +78 -0
- package/native/appkit/desktop-expo.h +29 -0
- package/native/appkit/desktop-expo.mm +385 -0
- package/native/appkit/expo-image-drawing.h +46 -0
- package/native/appkit/expo-image-drawing.mm +131 -0
- package/native/appkit/expo-image-view.h +15 -0
- package/native/appkit/expo-image-view.mm +182 -0
- package/native/appkit/expo-ui-renderer.h +68 -0
- package/native/appkit/expo-ui-renderer.mm +101 -0
- package/native/appkit/expo-ui-view.h +26 -0
- package/native/appkit/expo-ui-view.mm +134 -0
- package/native/appkit/expo-ui.swift +1284 -0
- package/native/appkit/file-system.h +16 -0
- package/native/appkit/file-system.mm +140 -0
- package/native/appkit/fonts.h +12 -0
- package/native/appkit/fonts.mm +48 -0
- package/native/appkit/geocoder.h +19 -0
- package/native/appkit/geocoder.mm +101 -0
- package/native/appkit/glass-effect.h +22 -0
- package/native/appkit/glass-effect.mm +63 -0
- package/native/appkit/glass-view.h +8 -0
- package/native/appkit/glass-view.mm +65 -0
- package/native/appkit/header-toolbar.h +60 -0
- package/native/appkit/header-toolbar.mm +629 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1200 -0
- package/native/appkit/image-manipulator.h +14 -0
- package/native/appkit/image-manipulator.mm +191 -0
- package/native/appkit/image-request.h +22 -0
- package/native/appkit/image-request.mm +62 -0
- package/native/appkit/image-view.h +8 -0
- package/native/appkit/image-view.mm +142 -0
- package/native/appkit/input-replay.h +25 -0
- package/native/appkit/input-replay.mm +418 -0
- package/native/appkit/language-model.h +14 -0
- package/native/appkit/language-model.mm +99 -0
- package/native/appkit/language-model.swift +472 -0
- package/native/appkit/local-authentication.h +15 -0
- package/native/appkit/local-authentication.mm +133 -0
- package/native/appkit/location.h +16 -0
- package/native/appkit/location.mm +214 -0
- package/native/appkit/main.mm +1515 -0
- package/native/appkit/map-view.h +15 -0
- package/native/appkit/map-view.mm +109 -0
- package/native/appkit/maps.h +35 -0
- package/native/appkit/maps.mm +343 -0
- package/native/appkit/menu-bar.h +22 -0
- package/native/appkit/menu-bar.mm +208 -0
- package/native/appkit/modal-focus.h +16 -0
- package/native/appkit/modal-focus.mm +26 -0
- package/native/appkit/modal-host-view.h +79 -0
- package/native/appkit/modal-host-view.mm +442 -0
- package/native/appkit/native-controls.h +22 -0
- package/native/appkit/native-controls.mm +431 -0
- package/native/appkit/network-state.h +12 -0
- package/native/appkit/network-state.mm +64 -0
- package/native/appkit/network.h +14 -0
- package/native/appkit/network.mm +396 -0
- package/native/appkit/notifications.h +19 -0
- package/native/appkit/notifications.mm +309 -0
- package/native/appkit/photo-library.h +33 -0
- package/native/appkit/photo-library.mm +548 -0
- package/native/appkit/pointer-buttons.h +32 -0
- package/native/appkit/presentation-label.h +15 -0
- package/native/appkit/presentation-label.mm +12 -0
- package/native/appkit/presented-screen.h +19 -0
- package/native/appkit/presented-screen.mm +181 -0
- package/native/appkit/printing.h +42 -0
- package/native/appkit/printing.mm +393 -0
- package/native/appkit/push.h +19 -0
- package/native/appkit/push.mm +81 -0
- package/native/appkit/red-box.h +26 -0
- package/native/appkit/red-box.mm +387 -0
- package/native/appkit/screen-capture.h +21 -0
- package/native/appkit/screen-capture.mm +92 -0
- package/native/appkit/scroll-view.h +13 -0
- package/native/appkit/scroll-view.mm +251 -0
- package/native/appkit/scrollers.h +25 -0
- package/native/appkit/scrollers.mm +43 -0
- package/native/appkit/search-field.h +34 -0
- package/native/appkit/search-field.mm +291 -0
- package/native/appkit/search-toolbar-item.h +19 -0
- package/native/appkit/search-toolbar-item.mm +269 -0
- package/native/appkit/share-picker.h +34 -0
- package/native/appkit/share-picker.mm +121 -0
- package/native/appkit/split-view.h +77 -0
- package/native/appkit/split-view.mm +1206 -0
- package/native/appkit/store-review.h +13 -0
- package/native/appkit/store-review.mm +28 -0
- package/native/appkit/surface-view.h +45 -0
- package/native/appkit/surface-view.mm +558 -0
- package/native/appkit/svg-view.h +17 -0
- package/native/appkit/svg-view.mm +57 -0
- package/native/appkit/symbol-drawing.h +24 -0
- package/native/appkit/symbol-drawing.mm +117 -0
- package/native/appkit/symbol-view.h +8 -0
- package/native/appkit/symbol-view.mm +33 -0
- package/native/appkit/system-access.h +34 -0
- package/native/appkit/system-access.mm +210 -0
- package/native/appkit/system.h +24 -0
- package/native/appkit/system.mm +403 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +76 -0
- package/native/appkit/text-input-field.mm +444 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +477 -0
- package/native/appkit/text-recognition.h +13 -0
- package/native/appkit/text-recognition.mm +102 -0
- package/native/appkit/tracking.h +13 -0
- package/native/appkit/tracking.mm +51 -0
- package/native/appkit/tray-and-dock.h +45 -0
- package/native/appkit/tray-and-dock.mm +130 -0
- package/native/appkit/undo.h +23 -0
- package/native/appkit/undo.mm +125 -0
- package/native/appkit/updates.h +17 -0
- package/native/appkit/updates.mm +71 -0
- package/native/appkit/video-view.h +10 -0
- package/native/appkit/video-view.mm +42 -0
- package/native/appkit/video.h +38 -0
- package/native/appkit/video.mm +404 -0
- package/native/appkit/web-browser.h +12 -0
- package/native/appkit/web-browser.mm +97 -0
- package/native/appkit/web-view-component.h +9 -0
- package/native/appkit/web-view-component.mm +56 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +394 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
- package/native/cmake/libraries/react-native-worklets.cmake +46 -0
- package/native/cmake/libraries.cmake +109 -0
- package/native/cmake/linked-modules.cmake +112 -0
- package/native/cmake/react-native.cmake +175 -0
- package/native/cmake/runtime-dependencies.cmake +34 -0
- package/native/cmake/swift.cmake +43 -0
- package/native/cmake/third-party.cmake +74 -0
- package/native/core/include/ngn/absent-views.h +27 -0
- package/native/core/include/ngn/accessibility.h +140 -0
- package/native/core/include/ngn/address-search.h +69 -0
- package/native/core/include/ngn/animation-frames.h +39 -0
- package/native/core/include/ngn/app-info.h +52 -0
- package/native/core/include/ngn/app-menus.h +146 -0
- package/native/core/include/ngn/app-windows.h +181 -0
- package/native/core/include/ngn/apple-authentication.h +116 -0
- package/native/core/include/ngn/asset.h +28 -0
- package/native/core/include/ngn/audio.h +125 -0
- package/native/core/include/ngn/back-swipe.h +112 -0
- package/native/core/include/ngn/battery.h +48 -0
- package/native/core/include/ngn/bytes.h +59 -0
- package/native/core/include/ngn/calendar.h +180 -0
- package/native/core/include/ngn/camera.h +128 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +105 -0
- package/native/core/include/ngn/crypto.h +38 -0
- package/native/core/include/ngn/default-menu.h +91 -0
- package/native/core/include/ngn/desktop-expo.h +193 -0
- package/native/core/include/ngn/desktop-modal.h +109 -0
- package/native/core/include/ngn/desktop-props.h +75 -0
- package/native/core/include/ngn/desktop-view-props.h +110 -0
- package/native/core/include/ngn/dev-server.h +33 -0
- package/native/core/include/ngn/download.h +24 -0
- package/native/core/include/ngn/expo-image.h +192 -0
- package/native/core/include/ngn/expo-ui.h +133 -0
- package/native/core/include/ngn/file-system.h +274 -0
- package/native/core/include/ngn/focus-order.h +63 -0
- package/native/core/include/ngn/fonts.h +64 -0
- package/native/core/include/ngn/gestures.h +305 -0
- package/native/core/include/ngn/glass.h +67 -0
- package/native/core/include/ngn/header-bar.h +112 -0
- package/native/core/include/ngn/host-state.h +243 -0
- package/native/core/include/ngn/image-manipulator.h +70 -0
- package/native/core/include/ngn/input-dispatcher.h +211 -0
- package/native/core/include/ngn/input-script.h +56 -0
- package/native/core/include/ngn/input.h +112 -0
- package/native/core/include/ngn/key-value-store.h +41 -0
- package/native/core/include/ngn/language-model.h +69 -0
- package/native/core/include/ngn/launch-frame.h +47 -0
- package/native/core/include/ngn/launch-settings.h +98 -0
- package/native/core/include/ngn/layout-animations.h +24 -0
- package/native/core/include/ngn/library-components.h +13 -0
- package/native/core/include/ngn/library-glue.h +53 -0
- package/native/core/include/ngn/live-regions.h +54 -0
- package/native/core/include/ngn/local-authentication.h +74 -0
- package/native/core/include/ngn/location.h +89 -0
- package/native/core/include/ngn/maps.h +226 -0
- package/native/core/include/ngn/module-registry.h +51 -0
- package/native/core/include/ngn/mounting-backend.h +96 -0
- package/native/core/include/ngn/mounting-manager.h +155 -0
- package/native/core/include/ngn/native-controls.h +161 -0
- package/native/core/include/ngn/native-module.h +109 -0
- package/native/core/include/ngn/network-state.h +44 -0
- package/native/core/include/ngn/network.h +100 -0
- package/native/core/include/ngn/notifications.h +185 -0
- package/native/core/include/ngn/photo-library.h +130 -0
- package/native/core/include/ngn/printing.h +69 -0
- package/native/core/include/ngn/processes.h +114 -0
- package/native/core/include/ngn/red-box.h +119 -0
- package/native/core/include/ngn/reload-thread.h +258 -0
- package/native/core/include/ngn/runtime.h +161 -0
- package/native/core/include/ngn/safe-areas.h +77 -0
- package/native/core/include/ngn/screen-capture.h +35 -0
- package/native/core/include/ngn/screen-presentation.h +85 -0
- package/native/core/include/ngn/screen-stacks.h +80 -0
- package/native/core/include/ngn/scrollers.h +106 -0
- package/native/core/include/ngn/sharing.h +39 -0
- package/native/core/include/ngn/spawn-rules.h +78 -0
- package/native/core/include/ngn/splash-screen.h +41 -0
- package/native/core/include/ngn/split-view.h +270 -0
- package/native/core/include/ngn/sqlite.h +38 -0
- package/native/core/include/ngn/store-review.h +26 -0
- package/native/core/include/ngn/surface-book.h +101 -0
- package/native/core/include/ngn/svg.h +393 -0
- package/native/core/include/ngn/symbol.h +90 -0
- package/native/core/include/ngn/system.h +102 -0
- package/native/core/include/ngn/tabs-host.h +171 -0
- package/native/core/include/ngn/text-input.h +125 -0
- package/native/core/include/ngn/text-measurer.h +38 -0
- package/native/core/include/ngn/text-recognition.h +55 -0
- package/native/core/include/ngn/tracking.h +34 -0
- package/native/core/include/ngn/tray-and-dock.h +107 -0
- package/native/core/include/ngn/undo.h +37 -0
- package/native/core/include/ngn/updates.h +253 -0
- package/native/core/include/ngn/video.h +126 -0
- package/native/core/include/ngn/view-box.h +126 -0
- package/native/core/include/ngn/view-transform.h +26 -0
- package/native/core/include/ngn/view-tree.h +85 -0
- package/native/core/include/ngn/web-browser.h +45 -0
- package/native/core/include/ngn/web-view.h +133 -0
- package/native/core/include/ngn/worklet-host.h +98 -0
- package/native/core/src/absent-views.cpp +41 -0
- package/native/core/src/accessibility.cpp +374 -0
- package/native/core/src/animation-frames.cpp +49 -0
- package/native/core/src/app-menus.cpp +352 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +91 -0
- package/native/core/src/bytes.cpp +158 -0
- package/native/core/src/control-sizes.cpp +232 -0
- package/native/core/src/default-menu.cpp +96 -0
- package/native/core/src/desktop-modal.cpp +162 -0
- package/native/core/src/desktop-view-props.cpp +80 -0
- package/native/core/src/dev-server-helper.cpp +152 -0
- package/native/core/src/dev-server.cpp +103 -0
- package/native/core/src/download.cpp +53 -0
- package/native/core/src/expo-image.cpp +548 -0
- package/native/core/src/expo-ui.cpp +203 -0
- package/native/core/src/focus-order.cpp +441 -0
- package/native/core/src/gestures.cpp +1806 -0
- package/native/core/src/glass.cpp +49 -0
- package/native/core/src/header-bar.cpp +104 -0
- package/native/core/src/host-services.cpp +50 -0
- package/native/core/src/host-state.cpp +61 -0
- package/native/core/src/input-dispatcher.cpp +727 -0
- package/native/core/src/input-script.cpp +123 -0
- package/native/core/src/key-value-store.cpp +169 -0
- package/native/core/src/launch-settings.cpp +148 -0
- package/native/core/src/layout-animations.cpp +62 -0
- package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
- package/native/core/src/libraries/react-native-worklets.cpp +192 -0
- package/native/core/src/libraries/rnscreens.cpp +125 -0
- package/native/core/src/libraries/rnsvg.cpp +345 -0
- package/native/core/src/libraries/safeareacontext.cpp +70 -0
- package/native/core/src/libraries/worklets-idle-frames.js +70 -0
- package/native/core/src/library-glue.cpp +35 -0
- package/native/core/src/live-regions.cpp +122 -0
- package/native/core/src/module-registry.cpp +50 -0
- package/native/core/src/modules/accessibility-manager.cpp +98 -0
- package/native/core/src/modules/address-search.cpp +219 -0
- package/native/core/src/modules/alert-manager.cpp +140 -0
- package/native/core/src/modules/app-info.cpp +74 -0
- package/native/core/src/modules/app-modules.cpp +405 -0
- package/native/core/src/modules/apple-authentication.cpp +188 -0
- package/native/core/src/modules/asset.cpp +111 -0
- package/native/core/src/modules/async-storage.cpp +192 -0
- package/native/core/src/modules/audio.cpp +541 -0
- package/native/core/src/modules/battery.cpp +88 -0
- package/native/core/src/modules/calendar.cpp +457 -0
- package/native/core/src/modules/camera.cpp +221 -0
- package/native/core/src/modules/core-modules.cpp +62 -0
- package/native/core/src/modules/crypto.cpp +117 -0
- package/native/core/src/modules/desktop-expo.cpp +527 -0
- package/native/core/src/modules/file-system.cpp +941 -0
- package/native/core/src/modules/fonts.cpp +163 -0
- package/native/core/src/modules/image-loader.cpp +105 -0
- package/native/core/src/modules/image-manipulator.cpp +305 -0
- package/native/core/src/modules/language-model.cpp +195 -0
- package/native/core/src/modules/local-authentication.cpp +140 -0
- package/native/core/src/modules/location.cpp +186 -0
- package/native/core/src/modules/maps.cpp +500 -0
- package/native/core/src/modules/network-state.cpp +72 -0
- package/native/core/src/modules/networking.cpp +387 -0
- package/native/core/src/modules/notifications.cpp +549 -0
- package/native/core/src/modules/photo-library.cpp +371 -0
- package/native/core/src/modules/printing.cpp +201 -0
- package/native/core/src/modules/screen-capture.cpp +71 -0
- package/native/core/src/modules/sharing.cpp +59 -0
- package/native/core/src/modules/splash-screen.cpp +70 -0
- package/native/core/src/modules/sqlite.cpp +421 -0
- package/native/core/src/modules/store-review.cpp +23 -0
- package/native/core/src/modules/text-recognition.cpp +107 -0
- package/native/core/src/modules/tracking.cpp +46 -0
- package/native/core/src/modules/undo.cpp +59 -0
- package/native/core/src/modules/video.cpp +366 -0
- package/native/core/src/modules/web-browser.cpp +100 -0
- package/native/core/src/modules/web-socket.cpp +266 -0
- package/native/core/src/mounting-manager.cpp +380 -0
- package/native/core/src/native-controls.cpp +129 -0
- package/native/core/src/native-module.cpp +250 -0
- package/native/core/src/network.cpp +219 -0
- package/native/core/src/posix-launcher.cpp +366 -0
- package/native/core/src/processes.cpp +324 -0
- package/native/core/src/red-box-errors.js +83 -0
- package/native/core/src/red-box.cpp +306 -0
- package/native/core/src/runtime.cpp +422 -0
- package/native/core/src/safe-areas.cpp +130 -0
- package/native/core/src/screen-presentation.cpp +61 -0
- package/native/core/src/screen-stacks.cpp +254 -0
- package/native/core/src/scrollers.cpp +181 -0
- package/native/core/src/spawn-rules.cpp +292 -0
- package/native/core/src/split-view.cpp +343 -0
- package/native/core/src/svg.cpp +1883 -0
- package/native/core/src/symbol.cpp +94 -0
- package/native/core/src/tabs-host.cpp +234 -0
- package/native/core/src/text-input.cpp +126 -0
- package/native/core/src/text-layout-manager.cpp +63 -0
- package/native/core/src/tray-and-dock.cpp +154 -0
- package/native/core/src/updates.cpp +965 -0
- package/native/core/src/view-box.cpp +788 -0
- package/native/core/src/view-transform.cpp +45 -0
- package/native/core/src/view-tree.cpp +234 -0
- package/native/core/src/web-view.cpp +143 -0
- package/native/core/src/worklet-host.cpp +10 -0
- package/native/scripts/build-hermes.sh +44 -0
- package/native/scripts/build.sh +171 -0
- package/native/scripts/cache-dir.sh +18 -0
- package/native/scripts/codegen-library.sh +193 -0
- package/native/scripts/compiler-launcher.sh +17 -0
- package/native/scripts/fetch.sh +174 -0
- package/native/scripts/hermes-built.sh +10 -0
- package/native/scripts/host-dir.sh +16 -0
- package/native/scripts/macos-target.sh +8 -0
- package/native/scripts/make-prebuilt.mjs +360 -0
- package/native/scripts/prebuilt-host-cache.mjs +158 -0
- package/native/shim/openssl/sha.h +22 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
- package/package.json +70 -3
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Builds the prebuilt desktop host for one React Native version and flavour and packs it for a
|
|
4
|
+
* release.
|
|
5
|
+
*
|
|
6
|
+
* make-prebuilt.mjs <app> <out> [--flavour debug|release] [--version <v>] [--base-url <url>]
|
|
7
|
+
* [--manifest <prebuilt.json>] [--host-cache <dir>] [--reuse <prebuilt.json>]
|
|
8
|
+
* [--reuse-only] [--build-dir <dir>]
|
|
9
|
+
* make-prebuilt.mjs <app> --print-key [--flavour debug|release]
|
|
10
|
+
*
|
|
11
|
+
* - <app>: the app whose react-native and host libraries (react-native-screens,
|
|
12
|
+
* react-native-safe-area-context) the host is built against: the desktop template.
|
|
13
|
+
* - <out>: where the archive and `prebuilt-host-<flavour>.json`, its manifest entry, go. Runs into
|
|
14
|
+
* the same folder take turns there (publishPrebuilt), so the two always come from the same build.
|
|
15
|
+
* - --flavour: `release` (the default), the universal Release build a packaged app ships
|
|
16
|
+
* (`build.sh --universal --release`), or `debug`, the universal dev build `run` uses
|
|
17
|
+
* (`build.sh --universal --no-tests`), which carries React Native's debugger.
|
|
18
|
+
* - --version: the release the archive is named for (default: this package's version), for a
|
|
19
|
+
* release whose version is not yet in package.json.
|
|
20
|
+
* - --base-url: where the release serves the archive, an absolute http or https URL with no query
|
|
21
|
+
* or fragment; the archive's URL is this and its name. Needed with --manifest, since the CLI
|
|
22
|
+
* downloads from the URL as it is.
|
|
23
|
+
* - --manifest: a `prebuilt.json` to write the entry into, in place of the one for the same React
|
|
24
|
+
* Native version and flavour.
|
|
25
|
+
* - --host-cache: a folder keeping the built host between runs (prebuilt-host-cache.mjs). When it
|
|
26
|
+
* holds a host built from the same inputs (the host's native sources and build scripts, React
|
|
27
|
+
* Native's and each compiled-in library's version, the flavour, the compiler and the SDK), that
|
|
28
|
+
* host is stripped, signed and packed with no build; otherwise the host is built and the folder
|
|
29
|
+
* replaced with it. An inputs key that cannot be computed builds without the cache.
|
|
30
|
+
* - --reuse: a `prebuilt.json` of an earlier release. When its entry for this React Native version
|
|
31
|
+
* and flavour records the same inputs key, its archive is downloaded, checked against the entry's
|
|
32
|
+
* SHA-256 and published again under this release's name, byte for byte. A different key, a failed
|
|
33
|
+
* download or a checksum that does not match falls back to --host-cache or a build.
|
|
34
|
+
* - --reuse-only: with --reuse, stop there when the archive cannot be reused, exiting with 3 and
|
|
35
|
+
* writing nothing, so a caller can prepare a build's caches before it builds.
|
|
36
|
+
* - --build-dir: build here, a folder that must be missing or empty, instead of a fresh temp folder:
|
|
37
|
+
* a fixed path lets a compiler cache such as ccache hit from one run to the next.
|
|
38
|
+
* - --print-key: print the inputs key --host-cache checks against, and nothing else.
|
|
39
|
+
*
|
|
40
|
+
* The host has no app's linked code and is built from scratch in a directory of its own, so no other
|
|
41
|
+
* build can replace it before it is archived. `ngn-macos` and `hermesc` have their local symbols
|
|
42
|
+
* stripped and are signed with the hardened runtime, ad hoc (`codesign --sign -`) unless `NGN_SIGN_IDENTITY` names an identity: an
|
|
43
|
+
* app re-signs the host when it packages, so the release needs no Developer ID. Nothing is uploaded.
|
|
44
|
+
*/
|
|
45
|
+
import { spawnSync } from 'node:child_process';
|
|
46
|
+
import { createHash } from 'node:crypto';
|
|
47
|
+
import {
|
|
48
|
+
cpSync,
|
|
49
|
+
existsSync,
|
|
50
|
+
mkdirSync,
|
|
51
|
+
mkdtempSync,
|
|
52
|
+
readdirSync,
|
|
53
|
+
readFileSync,
|
|
54
|
+
rmSync,
|
|
55
|
+
writeFileSync,
|
|
56
|
+
} from 'node:fs';
|
|
57
|
+
import { createRequire } from 'node:module';
|
|
58
|
+
import { tmpdir } from 'node:os';
|
|
59
|
+
import path from 'node:path';
|
|
60
|
+
import { fileURLToPath } from 'node:url';
|
|
61
|
+
import { parseArgs } from 'node:util';
|
|
62
|
+
|
|
63
|
+
import { HOST_LIBRARIES, packageDir } from '../../bin/host.mjs';
|
|
64
|
+
import {
|
|
65
|
+
FLAVOURS,
|
|
66
|
+
flavourOf,
|
|
67
|
+
prebuiltName,
|
|
68
|
+
publishPrebuilt,
|
|
69
|
+
readManifest,
|
|
70
|
+
signPrebuiltFiles,
|
|
71
|
+
} from '../../bin/prebuilt.mjs';
|
|
72
|
+
import {
|
|
73
|
+
HOST_FILES,
|
|
74
|
+
hostInputsKey,
|
|
75
|
+
readHostCache,
|
|
76
|
+
treeDigests,
|
|
77
|
+
writeHostCache,
|
|
78
|
+
} from './prebuilt-host-cache.mjs';
|
|
79
|
+
|
|
80
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
81
|
+
|
|
82
|
+
/** @param {string} command @param {string[]} args @param {import('node:child_process').SpawnSyncOptions} [options] */
|
|
83
|
+
function run(command, args, options = {}) {
|
|
84
|
+
const result = spawnSync(command, args, { stdio: 'inherit', encoding: 'utf8', ...options });
|
|
85
|
+
if (result.error) throw result.error;
|
|
86
|
+
if (result.status !== 0)
|
|
87
|
+
throw new Error(`${command} ${args.join(' ')} failed (${result.status}).`);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { values, positionals } = parseArgs({
|
|
92
|
+
allowPositionals: true,
|
|
93
|
+
options: {
|
|
94
|
+
flavour: { type: 'string', default: 'release' },
|
|
95
|
+
version: { type: 'string' },
|
|
96
|
+
'base-url': { type: 'string' },
|
|
97
|
+
manifest: { type: 'string' },
|
|
98
|
+
'host-cache': { type: 'string' },
|
|
99
|
+
'build-dir': { type: 'string' },
|
|
100
|
+
reuse: { type: 'string' },
|
|
101
|
+
'reuse-only': { type: 'boolean', default: false },
|
|
102
|
+
'print-key': { type: 'boolean', default: false },
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const [appArg, outArg] = positionals;
|
|
106
|
+
const printKey = values['print-key'];
|
|
107
|
+
if (!appArg || (!outArg && !printKey)) {
|
|
108
|
+
console.error(
|
|
109
|
+
'Usage: make-prebuilt.mjs <app> <out> [--flavour debug|release] [--version <v>] [--base-url <url>] [--manifest <prebuilt.json>] [--host-cache <dir>] [--reuse <prebuilt.json> [--reuse-only]] [--build-dir <dir>]\n make-prebuilt.mjs <app> --print-key [--flavour debug|release]',
|
|
110
|
+
);
|
|
111
|
+
process.exit(2);
|
|
112
|
+
}
|
|
113
|
+
if (values['reuse-only'] && !values.reuse) {
|
|
114
|
+
console.error('--reuse-only needs --reuse, the prebuilt.json whose archive to reuse.');
|
|
115
|
+
process.exit(2);
|
|
116
|
+
}
|
|
117
|
+
const flavour = /** @type {import('../../bin/prebuilt.mjs').Flavour} */ (values.flavour);
|
|
118
|
+
if (!FLAVOURS.includes(flavour)) {
|
|
119
|
+
console.error(`--flavour takes debug or release, not "${values.flavour}".`);
|
|
120
|
+
process.exit(2);
|
|
121
|
+
}
|
|
122
|
+
const baseUrl = values['base-url'];
|
|
123
|
+
if (values.manifest !== undefined || baseUrl !== undefined) {
|
|
124
|
+
/** @type {URL | null} */
|
|
125
|
+
let parsed = null;
|
|
126
|
+
try {
|
|
127
|
+
parsed = new URL(baseUrl ?? '');
|
|
128
|
+
} catch {}
|
|
129
|
+
// A query or a fragment would end up holding the archive's name.
|
|
130
|
+
if (!parsed || !['http:', 'https:'].includes(parsed.protocol) || /[?#]/.test(baseUrl ?? '')) {
|
|
131
|
+
console.error(
|
|
132
|
+
baseUrl === undefined
|
|
133
|
+
? '--manifest needs --base-url, the absolute URL the release serves the archive from.'
|
|
134
|
+
: `--base-url takes the absolute http or https URL the release serves the archive from, with no query or fragment, not "${baseUrl}".`,
|
|
135
|
+
);
|
|
136
|
+
process.exit(2);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const buildDirArg = values['build-dir'] && path.resolve(values['build-dir']);
|
|
140
|
+
if (buildDirArg && existsSync(buildDirArg) && readdirSync(buildDirArg).length > 0) {
|
|
141
|
+
// The host is always built from scratch: an earlier build's files could end up in it.
|
|
142
|
+
console.error(`--build-dir takes a missing or empty folder, and ${buildDirArg} is not empty.`);
|
|
143
|
+
process.exit(2);
|
|
144
|
+
}
|
|
145
|
+
const app = path.resolve(appArg);
|
|
146
|
+
const out = path.resolve(outArg ?? '.');
|
|
147
|
+
const require = createRequire(path.join(app, 'package.json'));
|
|
148
|
+
/** @param {string} name */
|
|
149
|
+
const installed = (name) => {
|
|
150
|
+
try {
|
|
151
|
+
return path.dirname(require.resolve(`${name}/package.json`));
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** @param {string} dir */
|
|
157
|
+
const versionOf = (dir) =>
|
|
158
|
+
String(JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8')).version);
|
|
159
|
+
|
|
160
|
+
const reactNativeDir = installed('react-native');
|
|
161
|
+
if (!reactNativeDir) throw new Error(`react-native is not installed in ${app}.`);
|
|
162
|
+
const reactNative = versionOf(reactNativeDir);
|
|
163
|
+
const libraries = Object.fromEntries(
|
|
164
|
+
HOST_LIBRARIES.flatMap((name) => {
|
|
165
|
+
const dir = installed(name);
|
|
166
|
+
return dir ? [[name, dir]] : [];
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const libraryVersions = Object.fromEntries(
|
|
171
|
+
Object.entries(libraries).map(([lib, dir]) => [lib, versionOf(dir)]),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
/** @param {string} command @param {string[]} args */
|
|
175
|
+
const capture = (command, args) =>
|
|
176
|
+
run(command, args, { stdio: ['ignore', 'pipe', 'inherit'] }).stdout.trim();
|
|
177
|
+
|
|
178
|
+
/** The key of everything the host is built from (prebuilt-host-cache.mjs hostInputsKey). */
|
|
179
|
+
function inputsKey() {
|
|
180
|
+
const desktop = path.resolve(here, '..', '..');
|
|
181
|
+
return hostInputsKey({
|
|
182
|
+
flavour,
|
|
183
|
+
reactNative,
|
|
184
|
+
libraries: libraryVersions,
|
|
185
|
+
// The native sources and every build script, and the list of libraries compiled in.
|
|
186
|
+
sources: [
|
|
187
|
+
path.join(desktop, 'native'),
|
|
188
|
+
path.join(desktop, 'bin', 'host.mjs'),
|
|
189
|
+
path.join(desktop, 'bin', 'prebuilt.mjs'),
|
|
190
|
+
].flatMap((root) => treeDigests(desktop, root)),
|
|
191
|
+
toolchain: [
|
|
192
|
+
capture('xcrun', ['clang', '--version']),
|
|
193
|
+
capture('xcrun', ['--show-sdk-version']),
|
|
194
|
+
].join('\n'),
|
|
195
|
+
// A reused archive is signed: another identity is another archive.
|
|
196
|
+
signing: process.env['NGN_SIGN_IDENTITY'] || '-',
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (printKey) {
|
|
201
|
+
console.log(inputsKey());
|
|
202
|
+
process.exit(0);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const hostCache = values['host-cache'] && path.resolve(values['host-cache']);
|
|
206
|
+
const reuse = values.reuse && path.resolve(values.reuse);
|
|
207
|
+
/** @type {string | null} */
|
|
208
|
+
let key = null;
|
|
209
|
+
if (hostCache || reuse) {
|
|
210
|
+
try {
|
|
211
|
+
key = inputsKey();
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error(
|
|
214
|
+
`make-prebuilt: no inputs key (${/** @type {Error} */ (error).message}); building from scratch.`,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Downloads into `packed` the archive `manifestFile` names for this React Native version and
|
|
221
|
+
* flavour, when its entry was built from `key` and the download has the entry's SHA-256. Returns
|
|
222
|
+
* why not otherwise, having written nothing.
|
|
223
|
+
*
|
|
224
|
+
* @param {string} manifestFile
|
|
225
|
+
* @param {string} inputs
|
|
226
|
+
* @param {string} packed
|
|
227
|
+
*/
|
|
228
|
+
async function reuseArchive(manifestFile, inputs, packed) {
|
|
229
|
+
try {
|
|
230
|
+
const entry = readManifest(readFileSync(manifestFile, 'utf8')).hosts.find(
|
|
231
|
+
(each) => each.reactNative === reactNative && flavourOf(each) === flavour,
|
|
232
|
+
);
|
|
233
|
+
if (!entry) return `${manifestFile} has no ${flavour} host for React Native ${reactNative}`;
|
|
234
|
+
if (entry.inputs !== inputs)
|
|
235
|
+
return `the ${flavour} host in ${manifestFile} was built from other inputs`;
|
|
236
|
+
const response = await fetch(entry.url, { signal: AbortSignal.timeout(600_000) });
|
|
237
|
+
if (!response.ok) return `${entry.url} answered ${response.status}`;
|
|
238
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
239
|
+
if (createHash('sha256').update(bytes).digest('hex') !== entry.sha256) {
|
|
240
|
+
return `${entry.url} does not match the SHA-256 in ${manifestFile}`;
|
|
241
|
+
}
|
|
242
|
+
writeFileSync(packed, bytes);
|
|
243
|
+
return null;
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return `the host in ${manifestFile} could not be reused: ${/** @type {Error} */ (error).message}`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const desktopVersion = values.version ?? versionOf(packageDir);
|
|
250
|
+
const name = prebuiltName(desktopVersion, reactNative, flavour);
|
|
251
|
+
mkdirSync(out, { recursive: true });
|
|
252
|
+
// Packed at a name of its own in <out>, and moved into place with its entry by publishPrebuilt.
|
|
253
|
+
const packed = path.join(out, `.${name}.${process.pid}.partial`);
|
|
254
|
+
const staging = mkdtempSync(path.join(tmpdir(), 'ngn-prebuilt-'));
|
|
255
|
+
try {
|
|
256
|
+
const appkit = path.join(staging, 'appkit');
|
|
257
|
+
let reused = false;
|
|
258
|
+
if (reuse && key) {
|
|
259
|
+
const why = await reuseArchive(reuse, key, packed);
|
|
260
|
+
if (why === null) {
|
|
261
|
+
// Unpacked only to be checked below like a host packed here.
|
|
262
|
+
run('tar', ['-xzf', packed, '-C', staging]);
|
|
263
|
+
reused = true;
|
|
264
|
+
console.error(
|
|
265
|
+
`make-prebuilt: reusing the host ${reuse} names, built from these inputs (${key}).`,
|
|
266
|
+
);
|
|
267
|
+
} else {
|
|
268
|
+
console.error(`make-prebuilt: ${why}; not reusing it.`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (!reused && values['reuse-only']) {
|
|
272
|
+
// Nothing was written to <out>, and process.exit skips the finally below.
|
|
273
|
+
rmSync(staging, { recursive: true, force: true });
|
|
274
|
+
console.error('make-prebuilt: --reuse-only: nothing to reuse, so nothing is built.');
|
|
275
|
+
process.exit(3);
|
|
276
|
+
}
|
|
277
|
+
/** @type {string | null} */
|
|
278
|
+
let built = null;
|
|
279
|
+
if (!reused) {
|
|
280
|
+
/** @type {string | null} */
|
|
281
|
+
let source = null;
|
|
282
|
+
if (hostCache && key) {
|
|
283
|
+
const cached = readHostCache(hostCache, key);
|
|
284
|
+
if (cached.appkit) {
|
|
285
|
+
source = cached.appkit;
|
|
286
|
+
console.error(
|
|
287
|
+
`make-prebuilt: packing the host built from these inputs (${key}) in ${hostCache}.`,
|
|
288
|
+
);
|
|
289
|
+
} else {
|
|
290
|
+
console.error(`make-prebuilt: ${cached.reason}; building the host.`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (source === null) {
|
|
294
|
+
const buildRoot = buildDirArg ?? path.join(staging, 'build');
|
|
295
|
+
const build = run(
|
|
296
|
+
path.join(here, 'build.sh'),
|
|
297
|
+
[
|
|
298
|
+
reactNativeDir,
|
|
299
|
+
'--universal',
|
|
300
|
+
// The debug host is the dev build an app's `run` makes, with React Native's debugger.
|
|
301
|
+
flavour === 'release' ? '--release' : '--no-tests',
|
|
302
|
+
// Stripped before it is packed, so debug info would only slow the build.
|
|
303
|
+
...(flavour === 'release' ? [] : ['--no-debug-info']),
|
|
304
|
+
...Object.values(libraries).flatMap((dir) => ['--library', dir]),
|
|
305
|
+
'--build-dir',
|
|
306
|
+
buildRoot,
|
|
307
|
+
],
|
|
308
|
+
{ stdio: ['inherit', 'pipe', 'inherit'], env: { ...process.env, NGN_DESKTOP_LINK: '' } },
|
|
309
|
+
);
|
|
310
|
+
source = built = path.join(build.stdout.trim().split('\n').pop() ?? '', 'appkit');
|
|
311
|
+
}
|
|
312
|
+
mkdirSync(appkit, { recursive: true });
|
|
313
|
+
for (const file of HOST_FILES) {
|
|
314
|
+
cpSync(path.join(source, file), path.join(appkit, file), {
|
|
315
|
+
recursive: true,
|
|
316
|
+
verbatimSymlinks: true,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
signPrebuiltFiles(
|
|
320
|
+
run,
|
|
321
|
+
['ngn-macos', 'hermesc'].map((file) => path.join(appkit, file)),
|
|
322
|
+
process.env,
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
for (const file of HOST_FILES) {
|
|
326
|
+
if (!existsSync(path.join(appkit, file))) throw new Error(`The host has no ${file}.`);
|
|
327
|
+
}
|
|
328
|
+
const archs = run('lipo', ['-archs', path.join(appkit, 'ngn-macos')], {
|
|
329
|
+
stdio: ['inherit', 'pipe', 'inherit'],
|
|
330
|
+
}).stdout.trim();
|
|
331
|
+
if (archs.split(' ').sort().join(' ') !== 'arm64 x86_64') {
|
|
332
|
+
throw new Error(`ngn-macos is built for ${archs}, not arm64 and x86_64.`);
|
|
333
|
+
}
|
|
334
|
+
// Kept as the build left it, unstripped and unsigned, for the next run with the same inputs.
|
|
335
|
+
if (built && hostCache && key) writeHostCache(hostCache, key, built);
|
|
336
|
+
|
|
337
|
+
// Owner and group dropped, so the archive does not carry the build machine's.
|
|
338
|
+
if (!reused) run('tar', ['-czf', packed, '--uid', '0', '--gid', '0', '-C', staging, 'appkit']);
|
|
339
|
+
const sha256 = createHash('sha256').update(readFileSync(packed)).digest('hex');
|
|
340
|
+
const host = {
|
|
341
|
+
reactNative,
|
|
342
|
+
flavour,
|
|
343
|
+
url: `${(baseUrl ?? '').replace(/\/$/, '')}/${name}`,
|
|
344
|
+
sha256,
|
|
345
|
+
libraries: libraryVersions,
|
|
346
|
+
// What the next release compares with to reuse this archive (--reuse).
|
|
347
|
+
...(key ? { inputs: key } : {}),
|
|
348
|
+
};
|
|
349
|
+
publishPrebuilt({
|
|
350
|
+
out,
|
|
351
|
+
archive: packed,
|
|
352
|
+
name,
|
|
353
|
+
host,
|
|
354
|
+
manifest: values.manifest && path.resolve(values.manifest),
|
|
355
|
+
});
|
|
356
|
+
console.log(`${path.join(out, name)}\n${JSON.stringify(host, null, 2)}`);
|
|
357
|
+
} finally {
|
|
358
|
+
rmSync(packed, { force: true });
|
|
359
|
+
rmSync(staging, { recursive: true, force: true });
|
|
360
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A built prebuilt host kept between release runs (make-prebuilt.mjs --host-cache), so a release
|
|
3
|
+
* whose host inputs did not change packs the host it already built instead of building it again.
|
|
4
|
+
*
|
|
5
|
+
* The cache holds the build's `appkit/` files as the build left them, before they are stripped and
|
|
6
|
+
* signed, and a `host.json` naming the inputs key they were built from and each file's digest. A
|
|
7
|
+
* cache is used only when its key is the one computed now and every file still has its digest;
|
|
8
|
+
* anything else builds from scratch.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
11
|
+
import {
|
|
12
|
+
cpSync,
|
|
13
|
+
existsSync,
|
|
14
|
+
lstatSync,
|
|
15
|
+
readdirSync,
|
|
16
|
+
readFileSync,
|
|
17
|
+
readlinkSync,
|
|
18
|
+
rmSync,
|
|
19
|
+
writeFileSync,
|
|
20
|
+
} from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
|
|
23
|
+
/** What the cache holds, under `appkit/`: the files make-prebuilt.mjs archives. */
|
|
24
|
+
export const HOST_FILES = ['ngn-macos', 'hermesc', 'Sparkle.framework'];
|
|
25
|
+
|
|
26
|
+
/** Bumped when the cache's layout or what the key covers changes, so older caches miss. */
|
|
27
|
+
const SCHEMA = 1;
|
|
28
|
+
|
|
29
|
+
/** @param {string | Buffer} data */
|
|
30
|
+
const sha256 = (data) => createHash('sha256').update(data).digest('hex');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Each file under `root` (a file or a directory), by its path relative to `base`, with the SHA-256
|
|
34
|
+
* of its contents, or `link:<target>` for a symbolic link, which is never followed. Sorted.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} base
|
|
37
|
+
* @param {string} root
|
|
38
|
+
* @returns {[string, string][]}
|
|
39
|
+
*/
|
|
40
|
+
export function treeDigests(base, root) {
|
|
41
|
+
/** @type {[string, string][]} */
|
|
42
|
+
const out = [];
|
|
43
|
+
/** @param {string} file */
|
|
44
|
+
const walk = (file) => {
|
|
45
|
+
const stat = lstatSync(file);
|
|
46
|
+
const rel = path.relative(base, file).split(path.sep).join('/');
|
|
47
|
+
if (stat.isSymbolicLink()) out.push([rel, `link:${readlinkSync(file)}`]);
|
|
48
|
+
else if (stat.isDirectory()) for (const name of readdirSync(file)) walk(path.join(file, name));
|
|
49
|
+
else if (stat.isFile()) out.push([rel, sha256(readFileSync(file))]);
|
|
50
|
+
else throw new Error(`${file} is neither a file, a directory nor a link.`);
|
|
51
|
+
};
|
|
52
|
+
walk(root);
|
|
53
|
+
return out.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The key of everything a prebuilt host is built from. Any change to one of these is a host that
|
|
58
|
+
* may differ, and builds again.
|
|
59
|
+
*
|
|
60
|
+
* @param {{
|
|
61
|
+
* flavour: string,
|
|
62
|
+
* reactNative: string,
|
|
63
|
+
* libraries: Record<string, string>,
|
|
64
|
+
* sources: [string, string][],
|
|
65
|
+
* toolchain: string,
|
|
66
|
+
* signing: string,
|
|
67
|
+
* }} inputs `libraries`: each compiled-in library's version. `sources`: the digests
|
|
68
|
+
* (treeDigests) of the host's native sources and build scripts. `toolchain`: the compiler and SDK.
|
|
69
|
+
* `signing`: the identity the archive is signed with, `-` for ad hoc.
|
|
70
|
+
*/
|
|
71
|
+
export function hostInputsKey({ flavour, reactNative, libraries, sources, toolchain, signing }) {
|
|
72
|
+
const sortedLibraries = Object.fromEntries(
|
|
73
|
+
Object.entries(libraries).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),
|
|
74
|
+
);
|
|
75
|
+
return sha256(
|
|
76
|
+
JSON.stringify({
|
|
77
|
+
schema: SCHEMA,
|
|
78
|
+
flavour,
|
|
79
|
+
reactNative,
|
|
80
|
+
libraries: sortedLibraries,
|
|
81
|
+
sources,
|
|
82
|
+
toolchain,
|
|
83
|
+
signing,
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The cached host's `appkit` folder when `dir` holds a host built from `key` whose files are all as
|
|
90
|
+
* they were saved, else null with why: a cache that is missing, from other inputs, short of a file
|
|
91
|
+
* or changed in any byte is never used.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} dir
|
|
94
|
+
* @param {string} key
|
|
95
|
+
* @returns {{ appkit: string, reason?: undefined } | { appkit: null, reason: string }}
|
|
96
|
+
*/
|
|
97
|
+
export function readHostCache(dir, key) {
|
|
98
|
+
const record = path.join(dir, 'host.json');
|
|
99
|
+
if (!existsSync(record)) return { appkit: null, reason: `no built host in ${dir}` };
|
|
100
|
+
/** @type {{ schema?: number, key?: string, files?: [string, string][] }} */
|
|
101
|
+
let saved;
|
|
102
|
+
try {
|
|
103
|
+
saved = JSON.parse(readFileSync(record, 'utf8'));
|
|
104
|
+
} catch (error) {
|
|
105
|
+
return {
|
|
106
|
+
appkit: null,
|
|
107
|
+
reason: `${record} is unreadable: ${/** @type {Error} */ (error).message}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (saved === null || typeof saved !== 'object' || Array.isArray(saved)) {
|
|
111
|
+
return { appkit: null, reason: `${record} is not a host record` };
|
|
112
|
+
}
|
|
113
|
+
if (saved.schema !== SCHEMA || saved.key !== key) {
|
|
114
|
+
return { appkit: null, reason: `the host in ${dir} was built from other inputs` };
|
|
115
|
+
}
|
|
116
|
+
const appkit = path.join(dir, 'appkit');
|
|
117
|
+
try {
|
|
118
|
+
for (const name of HOST_FILES) {
|
|
119
|
+
if (!existsSync(path.join(appkit, name))) {
|
|
120
|
+
return { appkit: null, reason: `the host in ${dir} has no ${name}` };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const now = JSON.stringify(treeDigests(appkit, appkit));
|
|
124
|
+
if (now !== JSON.stringify(saved.files)) {
|
|
125
|
+
return { appkit: null, reason: `the host in ${dir} is not as it was saved` };
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return {
|
|
129
|
+
appkit: null,
|
|
130
|
+
reason: `the host in ${dir} is unreadable: ${/** @type {Error} */ (error).message}`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { appkit };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Replaces `dir` with the host files in `appkit` (a build's, before stripping and signing) and the
|
|
138
|
+
* record naming `key`. The record goes in last, so a copy cut short is never read as a host.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} dir
|
|
141
|
+
* @param {string} key
|
|
142
|
+
* @param {string} appkit
|
|
143
|
+
*/
|
|
144
|
+
export function writeHostCache(dir, key, appkit) {
|
|
145
|
+
rmSync(dir, { recursive: true, force: true });
|
|
146
|
+
const target = path.join(dir, 'appkit');
|
|
147
|
+
for (const name of HOST_FILES) {
|
|
148
|
+
cpSync(path.join(appkit, name), path.join(target, name), {
|
|
149
|
+
recursive: true,
|
|
150
|
+
verbatimSymlinks: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const files = treeDigests(target, target);
|
|
154
|
+
writeFileSync(
|
|
155
|
+
path.join(dir, 'host.json'),
|
|
156
|
+
`${JSON.stringify({ schema: SCHEMA, key, files }, null, 2)}\n`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The part of OpenSSL's <openssl/sha.h> React Native's DevServerHelper calls, over the system's
|
|
2
|
+
// SHA-256 (CommonCrypto on Apple platforms). See cmake/runtime-dependencies.cmake.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#if defined(__APPLE__)
|
|
6
|
+
#include <CommonCrypto/CommonDigest.h>
|
|
7
|
+
|
|
8
|
+
#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
|
|
9
|
+
using SHA256_CTX = CC_SHA256_CTX;
|
|
10
|
+
|
|
11
|
+
inline int SHA256_Init(SHA256_CTX *context) {
|
|
12
|
+
return CC_SHA256_Init(context);
|
|
13
|
+
}
|
|
14
|
+
inline int SHA256_Update(SHA256_CTX *context, const void *data, size_t length) {
|
|
15
|
+
return CC_SHA256_Update(context, data, static_cast<CC_LONG>(length));
|
|
16
|
+
}
|
|
17
|
+
inline int SHA256_Final(unsigned char *digest, SHA256_CTX *context) {
|
|
18
|
+
return CC_SHA256_Final(digest, context);
|
|
19
|
+
}
|
|
20
|
+
#else
|
|
21
|
+
#error "No SHA-256 shim for this OS yet: the desktop host's runtime builds on macOS only."
|
|
22
|
+
#endif
|
package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// React Native's cxx platform's view traits, with the desktop props (ngn/desktop-props.h): a view
|
|
2
|
+
// that asks for a cursor, takes focus or listens for a desktop element event keeps its children
|
|
3
|
+
// under it, as React Native keeps a view with `cursor` or a pointer listener, and so do a live
|
|
4
|
+
// region and a view with a role or a label. Without it Fabric
|
|
5
|
+
// flattens the view, mounting its children under an ancestor, and the hit test, the cursor and
|
|
6
|
+
// Tab order never see it. cmake/react-native.cmake puts this directory before React Native's own.
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
10
|
+
#include <react/renderer/core/ShadowNodeTraits.h>
|
|
11
|
+
|
|
12
|
+
#include "ngn/desktop-props.h"
|
|
13
|
+
|
|
14
|
+
namespace facebook::react::HostPlatformViewTraitsInitializer {
|
|
15
|
+
|
|
16
|
+
inline bool formsStackingContext(const ViewProps &props) {
|
|
17
|
+
// A live region reads its text from the views under it (ngn/live-regions.h), and an
|
|
18
|
+
// accessibility element is read with the text inside it (ngn/accessibility.h).
|
|
19
|
+
if (props.accessibilityLiveRegion != AccessibilityLiveRegion::None || props.role != Role::None ||
|
|
20
|
+
!props.accessibilityRole.empty() || !props.accessibilityLabel.empty()) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const auto *desktop = dynamic_cast<const ngn::HasDesktopProps *>(&props);
|
|
24
|
+
return desktop != nullptr && ngn::formsStackingContext(desktop->desktop);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
inline bool formsView(const ViewProps & /*props*/) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
inline bool isKeyboardFocusable(const ViewProps &props) {
|
|
32
|
+
const auto *desktop = dynamic_cast<const ngn::HasDesktopProps *>(&props);
|
|
33
|
+
return desktop != nullptr &&
|
|
34
|
+
(desktop->desktop.focusable.value_or(false) || desktop->desktop.tabIndex.value_or(-1) >= 0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
} // namespace facebook::react::HostPlatformViewTraitsInitializer
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/desktop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"description": "The macOS desktop host for Angular Native: React Native's C++ core and Hermes, mounting into AppKit views, and the ng-native-desktop command that builds and launches it.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"react-native",
|
|
8
|
+
"angular-native",
|
|
9
|
+
"macos",
|
|
10
|
+
"desktop",
|
|
11
|
+
"appkit",
|
|
12
|
+
"fabric"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"ng-native-desktop": "./bin/ng-native-desktop.mjs"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@ng-native/device": "0.23.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react-native": "~0.88.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"react-native": {
|
|
26
|
+
"optional": true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.29.7",
|
|
31
|
+
"react-native-worklets": "0.13.0",
|
|
32
|
+
"typescript": "~6.0.3"
|
|
33
|
+
},
|
|
34
|
+
"nx": {
|
|
35
|
+
"projectType": "library",
|
|
36
|
+
"tags": [
|
|
37
|
+
"scope:desktop",
|
|
38
|
+
"layer:host"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"homepage": "https://ng-native.com/packages/desktop",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/ng-native/ng-native/issues"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/ng-native/ng-native.git",
|
|
49
|
+
"directory": "packages/desktop"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"app.plugin.cjs",
|
|
53
|
+
"prebuilt.json",
|
|
54
|
+
"bin/*.mjs",
|
|
55
|
+
"native/CMakeLists.txt",
|
|
56
|
+
"native/cmake",
|
|
57
|
+
"native/scripts",
|
|
58
|
+
"native/shim",
|
|
59
|
+
"native/core/include",
|
|
60
|
+
"native/core/src",
|
|
61
|
+
"native/appkit",
|
|
62
|
+
"!native/appkit/tests"
|
|
63
|
+
],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
69
|
+
"test": "node --test \"bin/*.test.ts\"",
|
|
70
|
+
"test:native": "native/scripts/build.sh --backend none --test",
|
|
71
|
+
"build:host": "native/scripts/build.sh"
|
|
72
|
+
}
|
|
6
73
|
}
|
package/prebuilt.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"hosts": [
|
|
4
|
+
{
|
|
5
|
+
"reactNative": "0.88.0",
|
|
6
|
+
"flavour": "debug",
|
|
7
|
+
"url": "https://github.com/ng-native/ng-native/releases/download/vminor/ng-native-desktop-host-minor-rn-0.88.0-macos-universal-debug.tar.gz",
|
|
8
|
+
"sha256": "f69b8e99c19f739f6a8f0039fe92a99a2e3dca7b2523f95541e6943c13678d46",
|
|
9
|
+
"libraries": {
|
|
10
|
+
"react-native-screens": "4.30.0",
|
|
11
|
+
"react-native-safe-area-context": "5.10.1",
|
|
12
|
+
"react-native-svg": "15.16.0",
|
|
13
|
+
"react-native-worklets": "0.13.0",
|
|
14
|
+
"react-native-reanimated": "4.7.1"
|
|
15
|
+
},
|
|
16
|
+
"inputs": "af0e12481a719f97c4ba92eee9317c1207084d2cb6f4eb6affada352019e3f32"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"reactNative": "0.88.0",
|
|
20
|
+
"flavour": "release",
|
|
21
|
+
"url": "https://github.com/ng-native/ng-native/releases/download/vminor/ng-native-desktop-host-minor-rn-0.88.0-macos-universal.tar.gz",
|
|
22
|
+
"sha256": "d4058d91c399452762deef93ea87586e3511c22d249ea9853819ae16ebca7f33",
|
|
23
|
+
"libraries": {
|
|
24
|
+
"react-native-screens": "4.30.0",
|
|
25
|
+
"react-native-safe-area-context": "5.10.1",
|
|
26
|
+
"react-native-svg": "15.16.0",
|
|
27
|
+
"react-native-worklets": "0.13.0",
|
|
28
|
+
"react-native-reanimated": "4.7.1"
|
|
29
|
+
},
|
|
30
|
+
"inputs": "2521d55a05418e1d949972e0263e34ebd502ef69694a58bf8d45428b4c0d080b"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|