@ng-native/desktop 0.0.0 → 0.24.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 +52 -0
- 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 +277 -0
- package/native/appkit/CMakeLists.txt +130 -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-sheet.h +59 -0
- package/native/appkit/camera-sheet.mm +344 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +134 -0
- package/native/appkit/camera.h +61 -0
- package/native/appkit/camera.mm +496 -0
- package/native/appkit/cg-canvas.h +24 -0
- package/native/appkit/cg-canvas.mm +663 -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 +632 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1228 -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 +1475 -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 +562 -0
- package/native/appkit/svg-view.h +18 -0
- package/native/appkit/svg-view.mm +103 -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/tab-walk.h +31 -0
- package/native/appkit/tab-walk.mm +64 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +81 -0
- package/native/appkit/text-input-field.mm +525 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +485 -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 +10 -0
- package/native/appkit/web-view-component.mm +62 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +401 -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 +151 -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 +121 -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 +222 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +108 -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/dom-web-view.h +53 -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 +134 -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 +163 -0
- package/native/core/include/ngn/safe-areas.h +82 -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/surface-metrics.h +51 -0
- package/native/core/include/ngn/svg.h +434 -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 +134 -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 +137 -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 +359 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +98 -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/dom-web-view.cpp +45 -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 +358 -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 +412 -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 +401 -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 +385 -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 +384 -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 +420 -0
- package/native/core/src/safe-areas.cpp +137 -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 +2190 -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 +139 -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 +175 -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/launch-probe.sh +60 -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 +73 -1
- package/prebuilt.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ashley Hunter
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @ng-native/desktop
|
|
2
|
+
|
|
3
|
+
The macOS desktop host for Angular Native: React Native's C++ core and Hermes, mounting an app's
|
|
4
|
+
views into AppKit, and the `ng-native-desktop` command that builds and launches it. You install the
|
|
5
|
+
package and never import it.
|
|
6
|
+
|
|
7
|
+
Alpha: APIs may change before 1.0.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Most Mac apps start from `npx create-expo-app@latest my-app --template @ng-native/template-desktop`.
|
|
12
|
+
To add macOS to an app you have:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx expo install @ng-native/desktop
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then list `macos` in `expo.platforms`, set `expo.experiments.outOfTreePlatforms` to `true` and add
|
|
19
|
+
`@ng-native/desktop` to `expo.plugins`. [Setup](https://ng-native.com/packages/desktop#setup) has
|
|
20
|
+
the details, and the Nx and Angular CLI generators that do it for you.
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm start # the Expo CLI's dev server, in one terminal
|
|
26
|
+
npx ng-native-desktop run # builds the host the first time, then opens the app
|
|
27
|
+
npx ng-native-desktop package # dist/macos/<name>.app; --format dmg or mas to ship it
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The first run for a React Native version builds the host from source, which needs Xcode 16 or its
|
|
31
|
+
Command Line Tools, CMake and Ninja, unless the package has a prebuilt host for that version and
|
|
32
|
+
the app has no native desktop code of its own: `run` downloads the debug host, with React Native's
|
|
33
|
+
debugger, and `package` the release one.
|
|
34
|
+
|
|
35
|
+
## Docs
|
|
36
|
+
|
|
37
|
+
- [Build for the Mac](https://ng-native.com/guide/desktop), the guide, and
|
|
38
|
+
[what differs](https://ng-native.com/guide/desktop-differences) from iOS and Android
|
|
39
|
+
- [Desktop](https://ng-native.com/packages/desktop): setup, running, packaging, config and native
|
|
40
|
+
code
|
|
41
|
+
- [Views and controls](https://ng-native.com/packages/desktop/views),
|
|
42
|
+
[windows, menus and the Dock](https://ng-native.com/packages/desktop/windows-and-menus) and
|
|
43
|
+
[focus and accessibility](https://ng-native.com/packages/desktop/accessibility)
|
|
44
|
+
- [Expo modules on macOS](https://ng-native.com/packages/desktop/expo-modules)
|
|
45
|
+
- [Debugging and launch settings](https://ng-native.com/packages/desktop/development)
|
|
46
|
+
- [Inside a package](https://ng-native.com/packages/desktop/packaging)
|
|
47
|
+
- [The desktop host](https://github.com/ng-native/ng-native/blob/main/docs/desktop-host.md): the
|
|
48
|
+
source layout and publishing a prebuilt host, for contributors
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/app.plugin.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `"plugins": [["@ng-native/desktop", { ... }]]` in app.json: the options of the macOS build that
|
|
3
|
+
* have no Expo key (document types, capabilities and the deny-list). Expo runs a plugin whenever
|
|
4
|
+
* it reads the config, so a mistake in the options stops `expo start`, `expo export` and
|
|
5
|
+
* `ng-native-desktop` with every problem listed, rather than turning into a capability the app
|
|
6
|
+
* quietly lacks.
|
|
7
|
+
*
|
|
8
|
+
* It changes nothing in the config: the desktop host is not a native project prebuild writes, and
|
|
9
|
+
* `ng-native-desktop` reads these options and the Expo keys it shares with iOS (`bin/app-config.mjs`)
|
|
10
|
+
* when it builds.
|
|
11
|
+
*/
|
|
12
|
+
const { validateDesktopOptions } = require('@ng-native/device/desktop-options');
|
|
13
|
+
|
|
14
|
+
module.exports = function withNgNativeDesktop(config, options) {
|
|
15
|
+
validateDesktopOptions(options);
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the desktop build reads from an app's Expo config. Settings Expo already has a key for come
|
|
3
|
+
* from that key, the same one the iOS build reads: the bundle identifier, the URL schemes, the
|
|
4
|
+
* icon, the version, the updates URL and the usage strings. The `@ng-native/desktop` plugin options
|
|
5
|
+
* hold only what has no Expo key: document types, capabilities and the deny-list.
|
|
6
|
+
*
|
|
7
|
+
* The config plugin (`app.plugin.cjs`) and the `ng-native-desktop` command both read options
|
|
8
|
+
* through here, so an option the plugin accepts is one the command can build.
|
|
9
|
+
*/
|
|
10
|
+
import { macosPermissions, validateDesktopOptions } from '@ng-native/device/desktop-options';
|
|
11
|
+
|
|
12
|
+
/** The name the plugin is listed under in `expo.plugins`. */
|
|
13
|
+
export const PLUGIN_NAME = '@ng-native/desktop';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('@ng-native/device/desktop-options').DesktopOptions} DesktopOptions
|
|
17
|
+
* @typedef {import('@ng-native/device/desktop-options').MacosPermissions} MacosPermissions
|
|
18
|
+
*
|
|
19
|
+
* @typedef {{
|
|
20
|
+
* name?: string,
|
|
21
|
+
* slug?: string,
|
|
22
|
+
* version?: string,
|
|
23
|
+
* scheme?: string | string[],
|
|
24
|
+
* icon?: string,
|
|
25
|
+
* runtimeVersion?: unknown,
|
|
26
|
+
* platforms?: string[],
|
|
27
|
+
* experiments?: { outOfTreePlatforms?: boolean },
|
|
28
|
+
* updates?: {
|
|
29
|
+
* url?: string,
|
|
30
|
+
* enabled?: boolean,
|
|
31
|
+
* codeSigningCertificate?: string,
|
|
32
|
+
* codeSigningMetadata?: { keyid?: string, alg?: string },
|
|
33
|
+
* },
|
|
34
|
+
* ios?: {
|
|
35
|
+
* bundleIdentifier?: string,
|
|
36
|
+
* buildNumber?: string,
|
|
37
|
+
* scheme?: string | string[],
|
|
38
|
+
* icon?: string | { light?: string, dark?: string, tinted?: string },
|
|
39
|
+
* infoPlist?: Record<string, unknown>,
|
|
40
|
+
* usesAppleSignIn?: boolean,
|
|
41
|
+
* entitlements?: Record<string, unknown>,
|
|
42
|
+
* },
|
|
43
|
+
* plugins?: unknown[],
|
|
44
|
+
* }} ExpoConfig
|
|
45
|
+
*
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* name: string,
|
|
48
|
+
* version: string,
|
|
49
|
+
* buildNumber: string,
|
|
50
|
+
* bundleIdentifier: string | null,
|
|
51
|
+
* schemes: string[],
|
|
52
|
+
* icon: string | null,
|
|
53
|
+
* updatesUrl: string | null,
|
|
54
|
+
* updatesCodeSigning: { certificate: string, keyId: string, alg: string } | null,
|
|
55
|
+
* runtimeVersion: string | null,
|
|
56
|
+
* permissions: MacosPermissions,
|
|
57
|
+
* options: DesktopOptions,
|
|
58
|
+
* }} DesktopAppConfig
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The plugin's options as `expo.plugins` lists them, or undefined when the plugin is listed bare
|
|
63
|
+
* or not at all.
|
|
64
|
+
*
|
|
65
|
+
* @param {ExpoConfig} config
|
|
66
|
+
* @returns {unknown}
|
|
67
|
+
*/
|
|
68
|
+
export function pluginOptions(config) {
|
|
69
|
+
for (const entry of config.plugins ?? []) {
|
|
70
|
+
if (Array.isArray(entry) && entry[0] === PLUGIN_NAME) return entry[1];
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The capabilities in the plugin options as the host reads them, from a packaged app's
|
|
77
|
+
* `NGNCapabilities` or the dev command's `--capabilities`: each path's access spelled out. Undefined
|
|
78
|
+
* where the options give none.
|
|
79
|
+
*
|
|
80
|
+
* @param {DesktopOptions} options
|
|
81
|
+
*/
|
|
82
|
+
export function hostCapabilities(options) {
|
|
83
|
+
const capabilities = options.capabilities;
|
|
84
|
+
if (!capabilities) return undefined;
|
|
85
|
+
return {
|
|
86
|
+
spawn: capabilities.spawn?.map((rule) => ({
|
|
87
|
+
program: rule.program,
|
|
88
|
+
args: rule.args ? [...rule.args] : undefined,
|
|
89
|
+
})),
|
|
90
|
+
env: capabilities.env ? [...capabilities.env] : undefined,
|
|
91
|
+
paths: capabilities.paths?.map((entry) => ({
|
|
92
|
+
path: entry.path,
|
|
93
|
+
access: entry.access ?? 'read',
|
|
94
|
+
})),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The desktop build's settings for an app, from its resolved Expo config. Throws, listing every
|
|
100
|
+
* problem, when the plugin options are not valid.
|
|
101
|
+
*
|
|
102
|
+
* - `bundleIdentifier` is `ios.bundleIdentifier`: macOS and iOS share Apple's identifier, and a
|
|
103
|
+
* universal purchase needs them to be the same. Null when the app sets none.
|
|
104
|
+
* - `schemes` are `scheme` and `ios.scheme`, which deep links open the app by.
|
|
105
|
+
* - `icon` is `ios.icon` (an Icon Composer `.icon` folder or an image, its light variant when it
|
|
106
|
+
* has variants), else `icon`.
|
|
107
|
+
* - `updatesUrl` is `updates.url`, the bundle server, unless updates are turned off.
|
|
108
|
+
* - `updatesCodeSigning` is `updates.codeSigningCertificate`, the PEM file's path from the project,
|
|
109
|
+
* with `codeSigningMetadata`'s key id and algorithm, defaulting as expo-updates does to `main`
|
|
110
|
+
* and `rsa-v1_5-sha256`. Null without a certificate, or with updates turned off.
|
|
111
|
+
*
|
|
112
|
+
* @param {ExpoConfig} config
|
|
113
|
+
* @returns {DesktopAppConfig}
|
|
114
|
+
*/
|
|
115
|
+
export function desktopAppConfig(config) {
|
|
116
|
+
const options = validateDesktopOptions(pluginOptions(config));
|
|
117
|
+
const ios = config.ios ?? {};
|
|
118
|
+
const version = config.version ?? '1.0.0';
|
|
119
|
+
return {
|
|
120
|
+
name: config.name ?? config.slug ?? 'ng-native',
|
|
121
|
+
version,
|
|
122
|
+
buildNumber: ios.buildNumber ?? version,
|
|
123
|
+
bundleIdentifier: ios.bundleIdentifier ?? null,
|
|
124
|
+
schemes: schemes(config),
|
|
125
|
+
icon: iosIcon(ios.icon) ?? config.icon ?? null,
|
|
126
|
+
updatesUrl: updatesUrl(config.updates),
|
|
127
|
+
updatesCodeSigning: updatesCodeSigning(config.updates),
|
|
128
|
+
runtimeVersion: typeof config.runtimeVersion === 'string' ? config.runtimeVersion : null,
|
|
129
|
+
permissions: macosPermissions(config),
|
|
130
|
+
options,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param {ExpoConfig} config
|
|
136
|
+
* @returns {string[]}
|
|
137
|
+
*/
|
|
138
|
+
function schemes(config) {
|
|
139
|
+
const all = [config.scheme, config.ios?.scheme].flat();
|
|
140
|
+
/** @param {unknown} scheme @returns {scheme is string} */
|
|
141
|
+
const named = (scheme) => typeof scheme === 'string' && scheme !== '';
|
|
142
|
+
return [...new Set(all.filter(named))];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** @param {NonNullable<ExpoConfig['ios']>['icon']} icon */
|
|
146
|
+
function iosIcon(icon) {
|
|
147
|
+
if (typeof icon === 'string') return icon;
|
|
148
|
+
return icon?.light ?? null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** @param {ExpoConfig['updates']} updates */
|
|
152
|
+
function updatesUrl(updates) {
|
|
153
|
+
return updates?.enabled === false ? null : (updates?.url ?? null);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** @param {ExpoConfig['updates']} updates */
|
|
157
|
+
function updatesCodeSigning(updates) {
|
|
158
|
+
const certificate = updates?.codeSigningCertificate;
|
|
159
|
+
if (updates?.enabled === false || typeof certificate !== 'string' || certificate === '') {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const metadata = updates?.codeSigningMetadata ?? {};
|
|
163
|
+
return {
|
|
164
|
+
certificate,
|
|
165
|
+
keyId: metadata.keyid ?? 'main',
|
|
166
|
+
alg: metadata.alg ?? 'rsa-v1_5-sha256',
|
|
167
|
+
};
|
|
168
|
+
}
|
package/bin/autolink.mjs
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autolinking for the desktop build: which native code the host compiles in, found the way Expo's
|
|
3
|
+
* autolinking finds a library's iOS and Android code.
|
|
4
|
+
*
|
|
5
|
+
* - A library opts in through its `expo-module.config.json`: `macos` among its `platforms`, and a
|
|
6
|
+
* `macos` entry naming the CMake target its desktop code builds and the folder that holds its
|
|
7
|
+
* CMake fragment (`desktop` unless it says otherwise):
|
|
8
|
+
*
|
|
9
|
+
* { "platforms": ["apple", "android", "macos"],
|
|
10
|
+
* "macos": { "cmakeTarget": "haptics_desktop", "cmakeDir": "desktop" } }
|
|
11
|
+
*
|
|
12
|
+
* - The app's own modules are each `modules/<name>/macos/`, beside `ios/` and `android/`, compiled
|
|
13
|
+
* in with nothing to register. The module's `expo-module.config.json` may name its CMake target.
|
|
14
|
+
* - A package in the plugin options' `deny` list stays out, whatever it ships; the packages it
|
|
15
|
+
* depends on are still walked.
|
|
16
|
+
* - A dependency with native code and none for the desktop is listed, so `run` and `package` can
|
|
17
|
+
* say its native modules are absent on macOS.
|
|
18
|
+
*
|
|
19
|
+
* Plain Node with no dependencies, so it runs before anything is built.
|
|
20
|
+
*/
|
|
21
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Packages whose native side is answered another way on macOS, so they are neither linked nor
|
|
26
|
+
* reported: React Native and React themselves, Expo (`expo` and `expo-*` resolve to empty modules
|
|
27
|
+
* there, and the host's own modules answer the services that use them) and this framework.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} name
|
|
30
|
+
*/
|
|
31
|
+
function suppliedOtherwise(name) {
|
|
32
|
+
return (
|
|
33
|
+
name === 'react' ||
|
|
34
|
+
name === 'react-native' ||
|
|
35
|
+
name === 'expo' ||
|
|
36
|
+
name.startsWith('expo-') ||
|
|
37
|
+
name.startsWith('@expo/') ||
|
|
38
|
+
name.startsWith('@ng-native/') ||
|
|
39
|
+
name.startsWith('@react-native/')
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {{ name: string, dir: string, cmakeTarget: string, cmakeDir: string }} DesktopLibrary
|
|
45
|
+
* @typedef {{ name: string, dir: string, cmakeTarget: string | null }} AppModule
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* libraries: DesktopLibrary[],
|
|
48
|
+
* appModules: AppModule[],
|
|
49
|
+
* hostLibraries: { name: string, dir: string }[],
|
|
50
|
+
* withoutDesktop: string[],
|
|
51
|
+
* problems: string[],
|
|
52
|
+
* }} DesktopLinks
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The desktop code an app's build compiles in, and the dependencies with native code that have
|
|
57
|
+
* none. Walks the app's `dependencies` and theirs, as Expo's autolinking does, each package once.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} appDir
|
|
60
|
+
* @param {{ deny?: readonly string[], builtIn?: readonly string[] }} [options] `builtIn` are the
|
|
61
|
+
* libraries the host compiles in itself, which are neither linked nor reported: `hostLibraries`
|
|
62
|
+
* says where each one the walk finds is installed, under a dependency's node_modules too
|
|
63
|
+
* @returns {DesktopLinks}
|
|
64
|
+
*/
|
|
65
|
+
export function desktopLinks(appDir, { deny = [], builtIn = [] } = {}) {
|
|
66
|
+
/** @type {DesktopLinks} */
|
|
67
|
+
const links = {
|
|
68
|
+
libraries: [],
|
|
69
|
+
appModules: appModules(appDir),
|
|
70
|
+
hostLibraries: [],
|
|
71
|
+
withoutDesktop: [],
|
|
72
|
+
problems: [],
|
|
73
|
+
};
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
// Breadth first, so a package nearer the app wins: the app's own version of a library is the
|
|
76
|
+
// one taken, not an older copy nested under a dependency listed before it.
|
|
77
|
+
const queue = [appDir];
|
|
78
|
+
for (let from = queue.shift(); from !== undefined; from = queue.shift()) {
|
|
79
|
+
for (const name of dependencyNames(from)) {
|
|
80
|
+
if (seen.has(name) || suppliedOtherwise(name)) continue;
|
|
81
|
+
seen.add(name);
|
|
82
|
+
const dir = packageDir(from, name);
|
|
83
|
+
if (dir === null) continue;
|
|
84
|
+
// A denied package stays out of the build and the warning, but what it depends on does not.
|
|
85
|
+
if (deny.includes(name)) {
|
|
86
|
+
// Neither linked nor reported.
|
|
87
|
+
} else if (builtIn.includes(name)) links.hostLibraries.push({ name, dir });
|
|
88
|
+
else classify(links, name, dir);
|
|
89
|
+
queue.push(dir);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
links.libraries.sort((a, b) => a.name.localeCompare(b.name));
|
|
93
|
+
links.hostLibraries.sort((a, b) => builtIn.indexOf(a.name) - builtIn.indexOf(b.name));
|
|
94
|
+
links.withoutDesktop.sort();
|
|
95
|
+
return links;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {DesktopLinks} links
|
|
100
|
+
* @param {string} name
|
|
101
|
+
* @param {string} dir
|
|
102
|
+
*/
|
|
103
|
+
function classify(links, name, dir) {
|
|
104
|
+
const config = readJson(path.join(dir, 'expo-module.config.json'));
|
|
105
|
+
const macos = config?.platforms?.includes('macos') ? config.macos : undefined;
|
|
106
|
+
if (macos === undefined) {
|
|
107
|
+
if (hasNativeCode(dir, config)) links.withoutDesktop.push(name);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (typeof macos?.cmakeTarget !== 'string' || macos.cmakeTarget === '') {
|
|
111
|
+
links.problems.push(
|
|
112
|
+
`${name} lists macos in expo-module.config.json without a macos.cmakeTarget, so it is left out.`,
|
|
113
|
+
);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const cmakeDir = path.join(dir, typeof macos.cmakeDir === 'string' ? macos.cmakeDir : 'desktop');
|
|
117
|
+
if (!existsSync(path.join(cmakeDir, 'CMakeLists.txt'))) {
|
|
118
|
+
links.problems.push(
|
|
119
|
+
`${name} names ${path.relative(dir, cmakeDir)}/CMakeLists.txt for macos, which it does not have, so it is left out.`,
|
|
120
|
+
);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
links.libraries.push({ name, dir, cmakeTarget: macos.cmakeTarget, cmakeDir });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The app's own modules: each `modules/<name>/macos/` folder.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} appDir
|
|
130
|
+
* @returns {AppModule[]}
|
|
131
|
+
*/
|
|
132
|
+
function appModules(appDir) {
|
|
133
|
+
const root = path.join(appDir, 'modules');
|
|
134
|
+
if (!isDirectory(root)) return [];
|
|
135
|
+
return readdirSync(root)
|
|
136
|
+
.sort()
|
|
137
|
+
.filter((name) => isDirectory(path.join(root, name, 'macos')))
|
|
138
|
+
.map((name) => {
|
|
139
|
+
const config = readJson(path.join(root, name, 'expo-module.config.json'));
|
|
140
|
+
const target = config?.macos?.cmakeTarget;
|
|
141
|
+
return {
|
|
142
|
+
name,
|
|
143
|
+
dir: path.join(root, name, 'macos'),
|
|
144
|
+
cmakeTarget: typeof target === 'string' && target !== '' ? target : null,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether a package ships native code for a phone: an Expo module for iOS or Android, a React
|
|
151
|
+
* Native codegen spec, a podspec, or an `ios` or `android` folder.
|
|
152
|
+
*
|
|
153
|
+
* @param {string} dir
|
|
154
|
+
* @param {{ platforms?: string[] } | null} config its expo-module.config.json
|
|
155
|
+
*/
|
|
156
|
+
function hasNativeCode(dir, config) {
|
|
157
|
+
if (config?.platforms?.some((platform) => ['apple', 'ios', 'android'].includes(platform))) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (readJson(path.join(dir, 'package.json'))?.codegenConfig) return true;
|
|
161
|
+
if (isDirectory(path.join(dir, 'ios')) || isDirectory(path.join(dir, 'android'))) return true;
|
|
162
|
+
return readdirSync(dir).some((file) => file.endsWith('.podspec'));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @param {string} dir */
|
|
166
|
+
function dependencyNames(dir) {
|
|
167
|
+
return Object.keys(readJson(path.join(dir, 'package.json'))?.dependencies ?? {});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* A package's directory as Node finds it from `from`, or null when it is not installed: the first
|
|
172
|
+
* `node_modules/<name>` up the tree, with symlinks resolved. Looked up directly rather than through
|
|
173
|
+
* `require.resolve('<name>/package.json')`, which throws for a package whose `exports` leave
|
|
174
|
+
* package.json out.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} from
|
|
177
|
+
* @param {string} name
|
|
178
|
+
*/
|
|
179
|
+
function packageDir(from, name) {
|
|
180
|
+
for (let dir = from; ; dir = path.dirname(dir)) {
|
|
181
|
+
if (path.basename(dir) !== 'node_modules') {
|
|
182
|
+
const candidate = path.join(dir, 'node_modules', name);
|
|
183
|
+
if (existsSync(path.join(candidate, 'package.json'))) return realpathSync(candidate);
|
|
184
|
+
}
|
|
185
|
+
if (path.dirname(dir) === dir) return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** @param {string} file @returns {any} */
|
|
190
|
+
function readJson(file) {
|
|
191
|
+
try {
|
|
192
|
+
return JSON.parse(readFileSync(file, 'utf8'));
|
|
193
|
+
} catch {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** @param {string} dir */
|
|
199
|
+
function isDirectory(dir) {
|
|
200
|
+
try {
|
|
201
|
+
return statSync(dir).isDirectory();
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* What `run` and `package` print about the links: a line for each library left out, and one
|
|
209
|
+
* naming the dependencies with no desktop code. Empty when there is nothing to say.
|
|
210
|
+
*
|
|
211
|
+
* @param {DesktopLinks} links
|
|
212
|
+
* @returns {string[]}
|
|
213
|
+
*/
|
|
214
|
+
export function linkWarnings(links) {
|
|
215
|
+
const lines = [...links.problems];
|
|
216
|
+
if (links.withoutDesktop.length > 0) {
|
|
217
|
+
lines.push(
|
|
218
|
+
`No desktop code in ${links.withoutDesktop.join(', ')}: their native modules are absent on ` +
|
|
219
|
+
'macOS. List a package in the deny option of the @ng-native/desktop plugin to keep it out ' +
|
|
220
|
+
'of this check.',
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
return lines;
|
|
224
|
+
}
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `ng-native-desktop` command: builds the desktop host when it needs building and launches it,
|
|
3
|
+
* or packages the app (`package.mjs`).
|
|
4
|
+
*
|
|
5
|
+
* ng-native-desktop run [bundle path or URL] [--module <name>] [--port <port>] [--url <link>] [--universal]
|
|
6
|
+
* ng-native-desktop package [--format app|dmg|mas] [--output <dir>] [--feed-url <url>]
|
|
7
|
+
*
|
|
8
|
+
* The host is built in the per-user cache (see `cacheDir`) from the pinned sources
|
|
9
|
+
* `native/scripts/fetch.sh` fetches, against the app's own `react-native`. With no bundle it loads
|
|
10
|
+
* the app from the dev server `npm start` runs, by URL, so reload and Fast Refresh work. The app's
|
|
11
|
+
* Expo config must list `macos`; the command says how to add it when it does not.
|
|
12
|
+
*/
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { parseArgs } from 'node:util';
|
|
15
|
+
|
|
16
|
+
import { hostCapabilities } from './app-config.mjs';
|
|
17
|
+
import { prepareHost, system, UsageError } from './host.mjs';
|
|
18
|
+
import { PACKAGE_USAGE, packageApp, parsePackage } from './package.mjs';
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
cacheDir,
|
|
22
|
+
checkExpoConfig,
|
|
23
|
+
HOST_LIBRARIES,
|
|
24
|
+
linkFile,
|
|
25
|
+
system,
|
|
26
|
+
UsageError,
|
|
27
|
+
} from './host.mjs';
|
|
28
|
+
|
|
29
|
+
export const USAGE = `Usage: ng-native-desktop run [bundle path or URL] [--module <name>] [--port <port>] [--url <link>]
|
|
30
|
+
[--universal]
|
|
31
|
+
|
|
32
|
+
Builds the macOS desktop host if it needs building, then opens the app in it: from the dev server
|
|
33
|
+
(start it with npm start) unless a bundle path or URL is given.
|
|
34
|
+
|
|
35
|
+
--module <name> the registered app to start (default: main)
|
|
36
|
+
--port <port> the dev server's port (default: 8081)
|
|
37
|
+
--url <link> a link to open the app on, as Linking's initial URL (myapp://settings)
|
|
38
|
+
--universal build for arm64 and x86_64 (default: this Mac's architecture)
|
|
39
|
+
|
|
40
|
+
${PACKAGE_USAGE}`;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The dev server URL of an app's bundle for macOS. The entry is the one Expo's own clients load,
|
|
44
|
+
* which resolves the app's `main` (`/index.bundle` would need an index file at the root).
|
|
45
|
+
*
|
|
46
|
+
* @param {number} port
|
|
47
|
+
*/
|
|
48
|
+
export function devServerBundleUrl(port) {
|
|
49
|
+
return `http://localhost:${port}/.expo/.virtual-metro-entry.bundle?platform=macos&dev=true`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {string[]} argv the arguments after the command name
|
|
54
|
+
* @returns {{ command: 'help' } | { command: 'run', bundle: string | undefined, module: string, port: number, universal: boolean, url?: string } | import('./package.mjs').PackageCommand}
|
|
55
|
+
*/
|
|
56
|
+
export function parseCommand(argv) {
|
|
57
|
+
const [command, ...rest] = argv;
|
|
58
|
+
if (command === undefined || command === 'help' || command === '--help' || command === '-h') {
|
|
59
|
+
return { command: 'help' };
|
|
60
|
+
}
|
|
61
|
+
if (command === 'package') return parsePackage(rest);
|
|
62
|
+
if (command !== 'run') {
|
|
63
|
+
throw new UsageError(`Unknown command "${command}".`);
|
|
64
|
+
}
|
|
65
|
+
const { values, positionals } = parseArgs({
|
|
66
|
+
args: rest,
|
|
67
|
+
allowPositionals: true,
|
|
68
|
+
options: {
|
|
69
|
+
module: { type: 'string', default: 'main' },
|
|
70
|
+
port: { type: 'string', default: '8081' },
|
|
71
|
+
universal: { type: 'boolean', default: false },
|
|
72
|
+
url: { type: 'string' },
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
if (positionals.length > 1) {
|
|
76
|
+
throw new UsageError('run takes at most one bundle path or URL.');
|
|
77
|
+
}
|
|
78
|
+
const port = Number(values.port);
|
|
79
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535) {
|
|
80
|
+
throw new UsageError(`--port takes a port number, not "${values.port}".`);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
command: 'run',
|
|
84
|
+
bundle: positionals[0],
|
|
85
|
+
module: values.module,
|
|
86
|
+
port,
|
|
87
|
+
universal: values.universal,
|
|
88
|
+
...(values.url !== undefined && { url: values.url }),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** @param {string} bundle */
|
|
93
|
+
export function isUrl(bundle) {
|
|
94
|
+
return /^https?:\/\//i.test(bundle);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Builds the host (a no-op when nothing changed) and runs it on the bundle. Returns the host's
|
|
99
|
+
* exit status.
|
|
100
|
+
*
|
|
101
|
+
* @param {{ bundle?: string, module: string, port?: number, universal: boolean, url?: string }} options
|
|
102
|
+
* @param {typeof system} [sys]
|
|
103
|
+
*/
|
|
104
|
+
export async function run(options, sys = system) {
|
|
105
|
+
const { cwd, expo, config, buildDir } = prepareHost(sys, options);
|
|
106
|
+
const appId = config.bundleIdentifier ?? expo.slug ?? config.name;
|
|
107
|
+
// What Processes may run and read, as a packaged app's Info.plist gives it.
|
|
108
|
+
const capabilities = hostCapabilities(config.options);
|
|
109
|
+
return sys.host(path.join(buildDir, 'appkit', 'ngn-macos'), [
|
|
110
|
+
bundleArgument(options, cwd),
|
|
111
|
+
'--module',
|
|
112
|
+
options.module,
|
|
113
|
+
'--title',
|
|
114
|
+
config.name,
|
|
115
|
+
'--app-id',
|
|
116
|
+
appId,
|
|
117
|
+
...(capabilities ? ['--capabilities', JSON.stringify(capabilities)] : []),
|
|
118
|
+
...(options.url ? ['--url', options.url] : []),
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* What the host loads. A URL goes to the host as it is: it loads it from the dev server and stays
|
|
124
|
+
* connected for reload and Fast Refresh.
|
|
125
|
+
*
|
|
126
|
+
* @param {{ bundle?: string, port?: number }} options
|
|
127
|
+
* @param {string} cwd
|
|
128
|
+
*/
|
|
129
|
+
function bundleArgument(options, cwd) {
|
|
130
|
+
if (!options.bundle) return devServerBundleUrl(options.port ?? 8081);
|
|
131
|
+
return isUrl(options.bundle) ? options.bundle : path.resolve(cwd, options.bundle);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param {string[]} argv
|
|
136
|
+
* @param {typeof system} [sys]
|
|
137
|
+
*/
|
|
138
|
+
export async function main(argv, sys = system) {
|
|
139
|
+
try {
|
|
140
|
+
const command = parseCommand(argv);
|
|
141
|
+
if (command.command === 'help') {
|
|
142
|
+
console.log(USAGE);
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
if (command.command === 'package') return await packageApp(command, sys);
|
|
146
|
+
return await run(command, sys);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (
|
|
149
|
+
error instanceof UsageError ||
|
|
150
|
+
(error instanceof Error && 'code' in error && String(error.code).startsWith('ERR_PARSE_ARGS'))
|
|
151
|
+
) {
|
|
152
|
+
console.error(`${error.message}\n\n${USAGE}`);
|
|
153
|
+
return 2;
|
|
154
|
+
}
|
|
155
|
+
console.error(error instanceof Error ? error.message : error);
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
}
|