basalt-core 0.0.0-rc5
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/dist/cli/basalt.d.ts +3 -0
- package/dist/cli/basalt.d.ts.map +1 -0
- package/dist/cli/basalt.js +47 -0
- package/dist/cli/basalt.js.map +1 -0
- package/dist/cli/bundle-cli.d.ts +12 -0
- package/dist/cli/bundle-cli.d.ts.map +1 -0
- package/dist/cli/bundle-cli.js +124 -0
- package/dist/cli/bundle-cli.js.map +1 -0
- package/dist/cli/bundleWithAssets.d.ts +79 -0
- package/dist/cli/bundleWithAssets.d.ts.map +1 -0
- package/dist/cli/bundleWithAssets.js +198 -0
- package/dist/cli/bundleWithAssets.js.map +1 -0
- package/dist/cli/desktop.d.ts +339 -0
- package/dist/cli/desktop.d.ts.map +1 -0
- package/dist/cli/desktop.js +1029 -0
- package/dist/cli/desktop.js.map +1 -0
- package/dist/cli/doctor.d.ts +31 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +283 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts +77 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +442 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/metro.d.ts +49 -0
- package/dist/cli/metro.d.ts.map +1 -0
- package/dist/cli/metro.js +148 -0
- package/dist/cli/metro.js.map +1 -0
- package/dist/cli/packageApp.d.ts +102 -0
- package/dist/cli/packageApp.d.ts.map +1 -0
- package/dist/cli/packageApp.js +319 -0
- package/dist/cli/packageApp.js.map +1 -0
- package/dist/cli/steps.d.ts +34 -0
- package/dist/cli/steps.d.ts.map +1 -0
- package/dist/cli/steps.js +53 -0
- package/dist/cli/steps.js.map +1 -0
- package/dist/metro-config.d.ts +168 -0
- package/dist/metro-config.d.ts.map +1 -0
- package/dist/metro-config.js +671 -0
- package/dist/metro-config.js.map +1 -0
- package/dist/react-native.config.d.ts +7 -0
- package/dist/react-native.config.d.ts.map +1 -0
- package/dist/react-native.config.js +80 -0
- package/dist/react-native.config.js.map +1 -0
- package/dist/src/DragSource.d.ts +52 -0
- package/dist/src/DragSource.d.ts.map +1 -0
- package/dist/src/DragSource.js +97 -0
- package/dist/src/DragSource.js.map +1 -0
- package/dist/src/DropTarget.d.ts +58 -0
- package/dist/src/DropTarget.d.ts.map +1 -0
- package/dist/src/DropTarget.js +131 -0
- package/dist/src/DropTarget.js.map +1 -0
- package/dist/src/KeyHandler.d.ts +57 -0
- package/dist/src/KeyHandler.d.ts.map +1 -0
- package/dist/src/KeyHandler.js +48 -0
- package/dist/src/KeyHandler.js.map +1 -0
- package/dist/src/Menu.d.ts +72 -0
- package/dist/src/Menu.d.ts.map +1 -0
- package/dist/src/Menu.js +179 -0
- package/dist/src/Menu.js.map +1 -0
- package/dist/src/TitleBar.d.ts +75 -0
- package/dist/src/TitleBar.d.ts.map +1 -0
- package/dist/src/TitleBar.js +236 -0
- package/dist/src/TitleBar.js.map +1 -0
- package/dist/src/Window.d.ts +87 -0
- package/dist/src/Window.d.ts.map +1 -0
- package/dist/src/Window.js +248 -0
- package/dist/src/Window.js.map +1 -0
- package/dist/src/closeRequest.d.ts +55 -0
- package/dist/src/closeRequest.d.ts.map +1 -0
- package/dist/src/closeRequest.js +134 -0
- package/dist/src/closeRequest.js.map +1 -0
- package/dist/src/index.d.ts +45 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +92 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/overrides/Alert.d.ts +69 -0
- package/dist/src/overrides/Alert.d.ts.map +1 -0
- package/dist/src/overrides/Alert.js +112 -0
- package/dist/src/overrides/Alert.js.map +1 -0
- package/dist/src/overrides/BaseViewConfig.d.ts +28 -0
- package/dist/src/overrides/BaseViewConfig.d.ts.map +1 -0
- package/dist/src/overrides/BaseViewConfig.js +72 -0
- package/dist/src/overrides/BaseViewConfig.js.map +1 -0
- package/dist/src/overrides/Platform.linux.d.ts +10 -0
- package/dist/src/overrides/Platform.linux.d.ts.map +1 -0
- package/dist/src/overrides/Platform.linux.js +15 -0
- package/dist/src/overrides/Platform.linux.js.map +1 -0
- package/dist/src/overrides/Platform.macos.d.ts +10 -0
- package/dist/src/overrides/Platform.macos.d.ts.map +1 -0
- package/dist/src/overrides/Platform.macos.js +15 -0
- package/dist/src/overrides/Platform.macos.js.map +1 -0
- package/dist/src/overrides/Platform.windows.d.ts +10 -0
- package/dist/src/overrides/Platform.windows.d.ts.map +1 -0
- package/dist/src/overrides/Platform.windows.js +15 -0
- package/dist/src/overrides/Platform.windows.js.map +1 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts +24 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts.map +1 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.js +30 -0
- package/dist/src/overrides/ReactDevToolsSettingsManager.js.map +1 -0
- package/dist/src/overrides/RefreshControl.d.ts +52 -0
- package/dist/src/overrides/RefreshControl.d.ts.map +1 -0
- package/dist/src/overrides/RefreshControl.js +92 -0
- package/dist/src/overrides/RefreshControl.js.map +1 -0
- package/dist/src/overrides/ScrollView.d.ts +39 -0
- package/dist/src/overrides/ScrollView.d.ts.map +1 -0
- package/dist/src/overrides/ScrollView.js +59 -0
- package/dist/src/overrides/ScrollView.js.map +1 -0
- package/dist/src/overrides/Share.d.ts +96 -0
- package/dist/src/overrides/Share.d.ts.map +1 -0
- package/dist/src/overrides/Share.js +97 -0
- package/dist/src/overrides/Share.js.map +1 -0
- package/dist/src/overrides/TextInput.d.ts +81 -0
- package/dist/src/overrides/TextInput.d.ts.map +1 -0
- package/dist/src/overrides/TextInput.js +213 -0
- package/dist/src/overrides/TextInput.js.map +1 -0
- package/dist/src/overrides/View.d.ts +36 -0
- package/dist/src/overrides/View.d.ts.map +1 -0
- package/dist/src/overrides/View.js +99 -0
- package/dist/src/overrides/View.js.map +1 -0
- package/dist/src/overrides/createPlatform.d.ts +32 -0
- package/dist/src/overrides/createPlatform.d.ts.map +1 -0
- package/dist/src/overrides/createPlatform.js +84 -0
- package/dist/src/overrides/createPlatform.js.map +1 -0
- package/dist/src/overrides/setUpDeveloperTools.d.ts +28 -0
- package/dist/src/overrides/setUpDeveloperTools.d.ts.map +1 -0
- package/dist/src/overrides/setUpDeveloperTools.js +84 -0
- package/dist/src/overrides/setUpDeveloperTools.js.map +1 -0
- package/dist/src/overrides/setUpXHR.d.ts +46 -0
- package/dist/src/overrides/setUpXHR.d.ts.map +1 -0
- package/dist/src/overrides/setUpXHR.js +236 -0
- package/dist/src/overrides/setUpXHR.js.map +1 -0
- package/dist/src/quitRequest.d.ts +55 -0
- package/dist/src/quitRequest.d.ts.map +1 -0
- package/dist/src/quitRequest.js +121 -0
- package/dist/src/quitRequest.js.map +1 -0
- package/dist/src/resourcePath.d.ts +18 -0
- package/dist/src/resourcePath.d.ts.map +1 -0
- package/dist/src/resourcePath.js +31 -0
- package/dist/src/resourcePath.js.map +1 -0
- package/dist/src/responseBody.d.ts +76 -0
- package/dist/src/responseBody.d.ts.map +1 -0
- package/dist/src/responseBody.js +94 -0
- package/dist/src/responseBody.js.map +1 -0
- package/dist/src/responseHeaders.d.ts +40 -0
- package/dist/src/responseHeaders.d.ts.map +1 -0
- package/dist/src/responseHeaders.js +75 -0
- package/dist/src/responseHeaders.js.map +1 -0
- package/dist/src/titleBarState.d.ts +43 -0
- package/dist/src/titleBarState.d.ts.map +1 -0
- package/dist/src/titleBarState.js +77 -0
- package/dist/src/titleBarState.js.map +1 -0
- package/dist/src/useContextMenu.d.ts +113 -0
- package/dist/src/useContextMenu.d.ts.map +1 -0
- package/dist/src/useContextMenu.js +109 -0
- package/dist/src/useContextMenu.js.map +1 -0
- package/dist/src/useDialog.d.ts +98 -0
- package/dist/src/useDialog.d.ts.map +1 -0
- package/dist/src/useDialog.js +112 -0
- package/dist/src/useDialog.js.map +1 -0
- package/dist/src/useDisplays.d.ts +70 -0
- package/dist/src/useDisplays.d.ts.map +1 -0
- package/dist/src/useDisplays.js +118 -0
- package/dist/src/useDisplays.js.map +1 -0
- package/dist/src/useHandledKeys.d.ts +38 -0
- package/dist/src/useHandledKeys.d.ts.map +1 -0
- package/dist/src/useHandledKeys.js +70 -0
- package/dist/src/useHandledKeys.js.map +1 -0
- package/dist/src/useWindow.d.ts +140 -0
- package/dist/src/useWindow.d.ts.map +1 -0
- package/dist/src/useWindow.js +233 -0
- package/dist/src/useWindow.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/native/CMakeLists.txt +355 -0
- package/native/bootstrap.sh +613 -0
- package/native/cmake/CompilerFlags.cmake +49 -0
- package/native/cmake/Expo.cmake +125 -0
- package/native/cmake/ReactNativeCore.cmake +612 -0
- package/native/cmake/Reanimated.cmake +108 -0
- package/native/cmake/Skia.cmake +379 -0
- package/native/cmake/ThirdParty.cmake +290 -0
- package/native/cmake/Worklets.cmake +67 -0
- package/native/cmake/codegen/CMakeLists.txt +32 -0
- package/native/core/AppIdentity.cpp +85 -0
- package/native/core/AppIdentity.h +59 -0
- package/native/core/AppPaths.cpp +96 -0
- package/native/core/AppPaths.h +53 -0
- package/native/core/AppearanceModule.cpp +60 -0
- package/native/core/AppearanceModule.h +40 -0
- package/native/core/Backface.h +59 -0
- package/native/core/BlobModule.cpp +283 -0
- package/native/core/BlobModule.h +76 -0
- package/native/core/BlobRegistry.cpp +75 -0
- package/native/core/BlobRegistry.h +44 -0
- package/native/core/ColorScheme.cpp +105 -0
- package/native/core/ColorScheme.h +59 -0
- package/native/core/ComponentRegistry.h +30 -0
- package/native/core/ControlMetrics.h +37 -0
- package/native/core/CoreModules.cpp +592 -0
- package/native/core/CoreModules.h +308 -0
- package/native/core/DebuggingOverlay.cpp +106 -0
- package/native/core/DebuggingOverlay.h +65 -0
- package/native/core/DesktopControls.cpp +232 -0
- package/native/core/DesktopControls.h +170 -0
- package/native/core/DevBundle.cpp +108 -0
- package/native/core/DevBundle.h +69 -0
- package/native/core/DevMenu.cpp +99 -0
- package/native/core/DevMenu.h +75 -0
- package/native/core/DialogModule.cpp +150 -0
- package/native/core/DialogModule.h +51 -0
- package/native/core/DragAndDrop.cpp +45 -0
- package/native/core/DragAndDrop.h +225 -0
- package/native/core/ExpoImageComponent.cpp +79 -0
- package/native/core/ExpoImageComponent.h +80 -0
- package/native/core/ExpoModules.cpp +415 -0
- package/native/core/ExpoModules.h +115 -0
- package/native/core/ExpoRuntime.cpp +366 -0
- package/native/core/ExpoRuntime.h +42 -0
- package/native/core/FocusRing.h +36 -0
- package/native/core/FontRegistry.h +51 -0
- package/native/core/GestureHandlerModule.cpp +136 -0
- package/native/core/GestureHandlerModule.h +71 -0
- package/native/core/Gestures.cpp +533 -0
- package/native/core/Gestures.h +145 -0
- package/native/core/HoverTracker.cpp +69 -0
- package/native/core/HoverTracker.h +109 -0
- package/native/core/HttpClient.cpp +282 -0
- package/native/core/ImageBytes.cpp +205 -0
- package/native/core/ImageBytes.h +29 -0
- package/native/core/ImageCache.cpp +51 -0
- package/native/core/ImageCache.h +89 -0
- package/native/core/JsRuntimeAccess.cpp +70 -0
- package/native/core/JsRuntimeAccess.h +60 -0
- package/native/core/JsiPromise.h +51 -0
- package/native/core/KeyEvents.cpp +116 -0
- package/native/core/KeyEvents.h +144 -0
- package/native/core/LogBoxSurface.cpp +46 -0
- package/native/core/LogBoxSurface.h +68 -0
- package/native/core/MenuModel.h +117 -0
- package/native/core/MenuModule.cpp +209 -0
- package/native/core/MenuModule.h +66 -0
- package/native/core/MountingWalk.h +524 -0
- package/native/core/PackageModules.cpp.in +25 -0
- package/native/core/PackageModules.h +50 -0
- package/native/core/PlatformConstantsModule.cpp +63 -0
- package/native/core/PlatformConstantsModule.h +64 -0
- package/native/core/PlatformServices.h +213 -0
- package/native/core/PointerButtons.h +63 -0
- package/native/core/PullToRefresh.cpp +57 -0
- package/native/core/PullToRefresh.h +73 -0
- package/native/core/ReanimatedCompat.h +47 -0
- package/native/core/ReanimatedModule.cpp +203 -0
- package/native/core/ReanimatedModule.h +55 -0
- package/native/core/ScrollAnimation.cpp +59 -0
- package/native/core/ScrollAnimation.h +70 -0
- package/native/core/ScrollBounds.cpp +26 -0
- package/native/core/ScrollBounds.h +68 -0
- package/native/core/ScrollIndicator.cpp +50 -0
- package/native/core/ScrollIndicator.h +69 -0
- package/native/core/ScrollMomentum.cpp +71 -0
- package/native/core/ScrollMomentum.h +73 -0
- package/native/core/ScrollSnap.cpp +123 -0
- package/native/core/ScrollSnap.h +80 -0
- package/native/core/ShareFallback.cpp +101 -0
- package/native/core/ShareFallback.h +45 -0
- package/native/core/SkiaPictureViewComponent.cpp +11 -0
- package/native/core/SkiaPictureViewComponent.h +47 -0
- package/native/core/SourceCodeModule.cpp +55 -0
- package/native/core/SourceCodeModule.h +53 -0
- package/native/core/StatusBarModule.cpp +23 -0
- package/native/core/StatusBarModule.h +42 -0
- package/native/core/TestDialog.cpp +148 -0
- package/native/core/TestDialog.h +96 -0
- package/native/core/TestKeys.cpp +78 -0
- package/native/core/TestKeys.h +50 -0
- package/native/core/TestQuitFile.cpp +33 -0
- package/native/core/TestQuitFile.h +60 -0
- package/native/core/TestSettle.h +192 -0
- package/native/core/TitleBarRegions.h +31 -0
- package/native/core/TurboModuleProxy.cpp +51 -0
- package/native/core/TurboModuleProxy.h +46 -0
- package/native/core/UIManagerAccess.cpp +43 -0
- package/native/core/UIManagerAccess.h +43 -0
- package/native/core/WindowBoundsCache.cpp +319 -0
- package/native/core/WindowControl.h +235 -0
- package/native/core/WindowHost.h +158 -0
- package/native/core/WindowMethods.cpp +167 -0
- package/native/core/WindowMethods.h +84 -0
- package/native/core/WindowsModule.cpp +448 -0
- package/native/core/WindowsModule.h +133 -0
- package/native/core/WorkletsModule.cpp +199 -0
- package/native/core/WorkletsModule.h +57 -0
- package/native/core/portability_probe.cpp +210 -0
- package/native/tests/EventRecorder.h +124 -0
- package/native/tests/TestHarness.cpp +109 -0
- package/native/tests/TestHarness.h +89 -0
- package/native/tests/TreeDump.h +49 -0
- package/native/tests/test_app_identity.cpp +114 -0
- package/native/tests/test_app_paths.cpp +48 -0
- package/native/tests/test_appearance.cpp +107 -0
- package/native/tests/test_backface.cpp +79 -0
- package/native/tests/test_blobs.cpp +157 -0
- package/native/tests/test_controls.cpp +185 -0
- package/native/tests/test_devbundle.cpp +103 -0
- package/native/tests/test_drag_and_drop.cpp +143 -0
- package/native/tests/test_gestures.cpp +331 -0
- package/native/tests/test_hover.cpp +92 -0
- package/native/tests/test_image_cache.cpp +109 -0
- package/native/tests/test_js_runtime_access.cpp +137 -0
- package/native/tests/test_key_events.cpp +235 -0
- package/native/tests/test_momentum.cpp +138 -0
- package/native/tests/test_quit_file.cpp +104 -0
- package/native/tests/test_scroll_animation.cpp +120 -0
- package/native/tests/test_scroll_bounds.cpp +66 -0
- package/native/tests/test_scroll_indicator.cpp +149 -0
- package/native/tests/test_scroll_snap.cpp +112 -0
- package/native/tests/test_settle.cpp +115 -0
- package/native/tests/test_share.cpp +75 -0
- package/native/tests/test_sourcecode.cpp +62 -0
- package/native/tests/test_window_close.cpp +119 -0
- package/native/tests/test_window_limits.cpp +123 -0
- package/package.json +43 -0
- package/react-native.config.js +86 -0
- package/supported-versions.json +66 -0
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* `npx basalt-core init`, which adds a desktop to an app that exists.
|
|
5
|
+
*
|
|
6
|
+
* It does not create an app. `create-expo-app` does that, and the division is
|
|
7
|
+
* the same one `run-linux` already assumes: this platform is something you add
|
|
8
|
+
* to a React Native app, not a way to start one.
|
|
9
|
+
*
|
|
10
|
+
* ## Why a bin rather than a CLI command
|
|
11
|
+
*
|
|
12
|
+
* The run commands are React Native CLI commands, registered from the host
|
|
13
|
+
* packages, because the CLI has to be able to find them. This one cannot be:
|
|
14
|
+
* before it runs, the package is not a dependency yet, so there is no config
|
|
15
|
+
* for the CLI to read. `npx basalt-core init` works from nothing, which
|
|
16
|
+
* is the point -- one command, in an app that has never heard of this platform.
|
|
17
|
+
*
|
|
18
|
+
* ## Idempotent, and refusing beats half-configuring
|
|
19
|
+
*
|
|
20
|
+
* Every step reports one of three things: it was already right, it was changed,
|
|
21
|
+
* or it could not be done and why. Running twice is safe and says so. An app
|
|
22
|
+
* this cannot recognise is refused before anything is written, because a
|
|
23
|
+
* half-configured app fails later and further from the cause than one that was
|
|
24
|
+
* turned away -- and the failure it produces names a Metro or Babel internal
|
|
25
|
+
* rather than the step that was skipped.
|
|
26
|
+
*
|
|
27
|
+
* @format
|
|
28
|
+
*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
+
}) : function(o, v) {
|
|
43
|
+
o["default"] = v;
|
|
44
|
+
});
|
|
45
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
46
|
+
var ownKeys = function(o) {
|
|
47
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48
|
+
var ar = [];
|
|
49
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
58
|
+
__setModuleDefault(result, mod);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.HOST_PACKAGES = exports.DEV_DEPENDENCIES = void 0;
|
|
64
|
+
exports.desktopsFor = desktopsFor;
|
|
65
|
+
exports.init = init;
|
|
66
|
+
exports.main = main;
|
|
67
|
+
const fs = __importStar(require("node:fs"));
|
|
68
|
+
const path = __importStar(require("node:path"));
|
|
69
|
+
const steps_1 = require("./steps");
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
71
|
+
const { DESKTOP_PLATFORMS } = require('../metro-config');
|
|
72
|
+
// The dev dependencies an app needs to bundle for a desktop. Both are React
|
|
73
|
+
// Native's own: the Metro config this platform wraps, and the CLI that carries
|
|
74
|
+
// the run commands. An Expo app has neither, because `expo` is its CLI.
|
|
75
|
+
exports.DEV_DEPENDENCIES = [
|
|
76
|
+
'@react-native/metro-config',
|
|
77
|
+
'@react-native-community/cli',
|
|
78
|
+
];
|
|
79
|
+
const PACKAGE_NAME = 'basalt-core';
|
|
80
|
+
/**
|
|
81
|
+
* The host packages, one per desktop, and all three by default.
|
|
82
|
+
*
|
|
83
|
+
* Each carries its own `run-<desktop>` command -- React Native's CLI reads a
|
|
84
|
+
* `react-native.config.js` out of every dependency, and the commands live
|
|
85
|
+
* beside the host they need rather than in core, so an app with only the
|
|
86
|
+
* AppKit package never sees a command it could not have used. Which means an
|
|
87
|
+
* app that installed core alone has no desktop commands at all, and `init`'s
|
|
88
|
+
* own closing line tells the person to run one.
|
|
89
|
+
*
|
|
90
|
+
* All three rather than the one this machine runs, because `package.json` is
|
|
91
|
+
* committed: which desktops an app builds for is a property of the project and
|
|
92
|
+
* not of whoever set it up. Narrowing by the current platform would configure
|
|
93
|
+
* an app on a Mac that failed on a contributor's Linux box, reporting an
|
|
94
|
+
* unrecognised command -- which reads as a broken install rather than as a
|
|
95
|
+
* decision somebody made.
|
|
96
|
+
*
|
|
97
|
+
* The cost of the other two is source that is never compiled: the build only
|
|
98
|
+
* configures the host for the platform it is running on. An app that wants
|
|
99
|
+
* fewer says so in app.json; see DESKTOPS_KEY.
|
|
100
|
+
*/
|
|
101
|
+
exports.HOST_PACKAGES = {
|
|
102
|
+
linux: 'basalt-gtk',
|
|
103
|
+
macos: 'basalt-appkit',
|
|
104
|
+
windows: 'basalt-win32',
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Where an app narrows that list: `"basalt": {"desktops": ["macos"]}`.
|
|
108
|
+
*
|
|
109
|
+
* app.json rather than package.json, and under the `basalt` key that is
|
|
110
|
+
* already this platform's escape hatch there -- `cli/packageApp.ts` reads
|
|
111
|
+
* `basalt.identifier` and `basalt.scheme` from the same place.
|
|
112
|
+
*
|
|
113
|
+
* Not Expo's own `platforms` field: a bare React Native app does not have one,
|
|
114
|
+
* and it is Expo's to define rather than this platform's to borrow.
|
|
115
|
+
*/
|
|
116
|
+
const DESKTOPS_KEY = 'desktops';
|
|
117
|
+
/**
|
|
118
|
+
* Reads a JSON file, or returns null when it is absent or unparseable.
|
|
119
|
+
*
|
|
120
|
+
* Unparseable and absent are deliberately the same answer here: both mean "this
|
|
121
|
+
* is not something to edit", and the caller says so with the path.
|
|
122
|
+
*/
|
|
123
|
+
function readJson(file) {
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Is this a React Native app at all?
|
|
133
|
+
*
|
|
134
|
+
* `react-native` in any dependency field, or `expo` -- an Expo app has React
|
|
135
|
+
* Native transitively and may not name it. Anything else is refused.
|
|
136
|
+
*/
|
|
137
|
+
function describeProject(root) {
|
|
138
|
+
const manifest = path.join(root, 'package.json');
|
|
139
|
+
if (!fs.existsSync(manifest)) {
|
|
140
|
+
return { ok: false, reason: `no package.json in ${root}` };
|
|
141
|
+
}
|
|
142
|
+
const json = readJson(manifest);
|
|
143
|
+
if (json == null) {
|
|
144
|
+
return { ok: false, reason: `${manifest} is not readable JSON` };
|
|
145
|
+
}
|
|
146
|
+
const all = {
|
|
147
|
+
...(json.dependencies || {}),
|
|
148
|
+
...(json.devDependencies || {}),
|
|
149
|
+
...(json.peerDependencies || {}),
|
|
150
|
+
};
|
|
151
|
+
if (all['react-native'] == null && all.expo == null) {
|
|
152
|
+
return {
|
|
153
|
+
ok: false,
|
|
154
|
+
reason: `${manifest} lists neither react-native nor expo. This adds a desktop ` +
|
|
155
|
+
'to an app that exists; create one with `npx create-expo-app` first.',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return { ok: true, manifest, json, expo: all.expo != null };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The Metro config to edit, or null with the reason.
|
|
162
|
+
*
|
|
163
|
+
* Only the two filenames Metro itself looks for. A project using
|
|
164
|
+
* `metro.config.ts` is a real case and not one this writes into blindly: the
|
|
165
|
+
* wrapper is a require() call, and a TypeScript config may be doing something
|
|
166
|
+
* this cannot preserve.
|
|
167
|
+
*/
|
|
168
|
+
function findMetroConfig(root) {
|
|
169
|
+
for (const name of ['metro.config.js', 'metro.config.cjs']) {
|
|
170
|
+
const file = path.join(root, name);
|
|
171
|
+
if (fs.existsSync(file)) {
|
|
172
|
+
return { file };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
for (const name of ['metro.config.ts', 'metro.config.mjs']) {
|
|
176
|
+
if (fs.existsSync(path.join(root, name))) {
|
|
177
|
+
return {
|
|
178
|
+
file: null,
|
|
179
|
+
reason: `found ${name}, which this cannot edit safely. Add ` +
|
|
180
|
+
`\`withDesktopPlatforms\` from \`${PACKAGE_NAME}/metro-config\` by hand.`,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Absent rather than unreadable, which the caller writes one for.
|
|
185
|
+
return { file: null, reason: 'no metro.config.js', missing: true };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The desktops this app builds for: every one, unless app.json narrows it.
|
|
189
|
+
*
|
|
190
|
+
* An unknown name is refused rather than ignored. A typo -- "mac", "win" --
|
|
191
|
+
* would otherwise quietly install one package fewer and fail much later, at
|
|
192
|
+
* the command that is missing, which is the failure this whole step exists to
|
|
193
|
+
* prevent.
|
|
194
|
+
*/
|
|
195
|
+
function desktopsFor(root) {
|
|
196
|
+
const all = Object.keys(exports.HOST_PACKAGES);
|
|
197
|
+
const appJson = readJson(path.join(root, 'app.json'));
|
|
198
|
+
const named = appJson?.basalt?.[DESKTOPS_KEY];
|
|
199
|
+
if (named == null) {
|
|
200
|
+
return { desktops: all };
|
|
201
|
+
}
|
|
202
|
+
if (!Array.isArray(named) || named.some(entry => typeof entry !== 'string')) {
|
|
203
|
+
return {
|
|
204
|
+
desktops: all,
|
|
205
|
+
reason: `app.json's "basalt.${DESKTOPS_KEY}" is not a list of names; using all of them`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const unknown = named.filter(entry => !(entry in exports.HOST_PACKAGES));
|
|
209
|
+
if (unknown.length > 0) {
|
|
210
|
+
return {
|
|
211
|
+
desktops: all,
|
|
212
|
+
reason: `app.json's "basalt.${DESKTOPS_KEY}" names ${unknown.join(', ')}, which ` +
|
|
213
|
+
`${unknown.length === 1 ? 'is not a desktop' : 'are not desktops'} this ` +
|
|
214
|
+
`platform has. Expected any of ${all.join(', ')}; using all of them`,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return { desktops: named };
|
|
218
|
+
}
|
|
219
|
+
/** Adds this package, the host packages, and the two dev dependencies. */
|
|
220
|
+
function addDependencies(project, version, desktops, write) {
|
|
221
|
+
const json = project.json;
|
|
222
|
+
const changes = [];
|
|
223
|
+
json.dependencies = json.dependencies || {};
|
|
224
|
+
if (json.dependencies[PACKAGE_NAME] == null) {
|
|
225
|
+
json.dependencies[PACKAGE_NAME] = version;
|
|
226
|
+
changes.push(PACKAGE_NAME);
|
|
227
|
+
}
|
|
228
|
+
// The same version as core: they share a C++ ABI with the host, and
|
|
229
|
+
// docs/DECISIONS.md says they version together until that stops being true.
|
|
230
|
+
for (const desktop of desktops) {
|
|
231
|
+
const host = exports.HOST_PACKAGES[desktop];
|
|
232
|
+
if (host != null && json.dependencies[host] == null) {
|
|
233
|
+
json.dependencies[host] = version;
|
|
234
|
+
changes.push(host);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
json.devDependencies = json.devDependencies || {};
|
|
238
|
+
for (const name of exports.DEV_DEPENDENCIES) {
|
|
239
|
+
// Not if it is already a dependency of any kind: an app that has it in
|
|
240
|
+
// `dependencies` made that choice, and moving it is not this command's
|
|
241
|
+
// business.
|
|
242
|
+
const present = json.devDependencies[name] != null || (json.dependencies || {})[name] != null;
|
|
243
|
+
if (!present) {
|
|
244
|
+
json.devDependencies[name] = '*';
|
|
245
|
+
changes.push(name);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (changes.length === 0) {
|
|
249
|
+
return (0, steps_1.step)(steps_1.DONE, 'dependencies are already present');
|
|
250
|
+
}
|
|
251
|
+
// Phrased for what actually happened. `doctor` runs this same function with
|
|
252
|
+
// writing off, and a report that said "added" when nothing was added would
|
|
253
|
+
// be the one thing a read-only command must never do.
|
|
254
|
+
return write
|
|
255
|
+
? (0, steps_1.step)(steps_1.CHANGED, `added ${changes.join(', ')} -- run your package manager to install`)
|
|
256
|
+
: (0, steps_1.step)(steps_1.CHANGED, `would add ${changes.join(', ')}`);
|
|
257
|
+
}
|
|
258
|
+
/** Adds a script per desktop, leaving any the app already defined alone. */
|
|
259
|
+
function addScripts(project, write) {
|
|
260
|
+
const json = project.json;
|
|
261
|
+
json.scripts = json.scripts || {};
|
|
262
|
+
const added = [];
|
|
263
|
+
for (const platform of DESKTOP_PLATFORMS) {
|
|
264
|
+
const name = platform;
|
|
265
|
+
if (json.scripts[name] == null) {
|
|
266
|
+
json.scripts[name] = `react-native run-${platform}`;
|
|
267
|
+
added.push(name);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (added.length === 0) {
|
|
271
|
+
return (0, steps_1.step)(steps_1.DONE, 'scripts are already present');
|
|
272
|
+
}
|
|
273
|
+
return (0, steps_1.step)(steps_1.CHANGED, write ? `added scripts: ${added.join(', ')}` : `would add scripts: ${added.join(', ')}`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Writes a Metro config for an app that has none.
|
|
277
|
+
*
|
|
278
|
+
* A stock `create-expo-app --template blank` has no `metro.config.js` at all:
|
|
279
|
+
* Expo's default is implicit, and an app only grows the file when it has
|
|
280
|
+
* something to say. That is the common case rather than an edge one, and
|
|
281
|
+
* blocking on it left the command reporting by hand the single step it exists
|
|
282
|
+
* to do -- which is what `release.yml` had been working around with a heredoc
|
|
283
|
+
* of exactly these three lines.
|
|
284
|
+
*
|
|
285
|
+
* Which default to start from is the app's own: `expo/metro-config` reads
|
|
286
|
+
* app.json and the Expo plugins, and a bare React Native app has neither.
|
|
287
|
+
*/
|
|
288
|
+
function writeMetroConfig(root, expo) {
|
|
289
|
+
const file = path.join(root, 'metro.config.js');
|
|
290
|
+
const defaults = expo ? 'expo/metro-config' : '@react-native/metro-config';
|
|
291
|
+
const contents = `const {getDefaultConfig} = require('${defaults}');\n` +
|
|
292
|
+
`const {withDesktopPlatforms} = require('${PACKAGE_NAME}/metro-config');\n` +
|
|
293
|
+
'\n' +
|
|
294
|
+
'module.exports = withDesktopPlatforms(getDefaultConfig(__dirname));\n';
|
|
295
|
+
fs.writeFileSync(file, contents);
|
|
296
|
+
return (0, steps_1.step)(steps_1.CHANGED, `wrote metro.config.js, on ${defaults}`);
|
|
297
|
+
}
|
|
298
|
+
/** Whether the app's Metro config is already wrapped, changing nothing. */
|
|
299
|
+
function inspectMetroConfig(file) {
|
|
300
|
+
const name = path.basename(file);
|
|
301
|
+
const before = fs.readFileSync(file, 'utf8');
|
|
302
|
+
if (before.includes('withDesktopPlatforms')) {
|
|
303
|
+
return (0, steps_1.step)(steps_1.DONE, `${name} already wraps the config`);
|
|
304
|
+
}
|
|
305
|
+
if (!/^module\.exports\s*=\s*([\s\S]+?);$/m.test(before)) {
|
|
306
|
+
return (0, steps_1.step)(steps_1.BLOCKED, `could not find a \`module.exports =\` in ${name}. Wrap its export in ` +
|
|
307
|
+
'`withDesktopPlatforms(...)` by hand.');
|
|
308
|
+
}
|
|
309
|
+
return (0, steps_1.step)(steps_1.CHANGED, `${name} would be wrapped in withDesktopPlatforms`);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Wraps the app's Metro config, preserving what is there.
|
|
313
|
+
*
|
|
314
|
+
* Textual rather than by parsing: a Metro config is a small file people edit,
|
|
315
|
+
* and rewriting it through an AST would reformat the whole thing to change one
|
|
316
|
+
* line. What that costs is certainty, so anything not recognised is refused
|
|
317
|
+
* rather than guessed at.
|
|
318
|
+
*/
|
|
319
|
+
function wrapMetroConfig(file) {
|
|
320
|
+
const before = fs.readFileSync(file, 'utf8');
|
|
321
|
+
if (before.includes('withDesktopPlatforms')) {
|
|
322
|
+
return (0, steps_1.step)(steps_1.DONE, `${path.basename(file)} already wraps the config`);
|
|
323
|
+
}
|
|
324
|
+
const requireLine = `const {withDesktopPlatforms} = require('${PACKAGE_NAME}/metro-config');\n`;
|
|
325
|
+
// `module.exports = <something>;` on one line, which is what both the Expo
|
|
326
|
+
// and the bare template produce.
|
|
327
|
+
// Non-greedy up to the semicolon, and deliberately not swallowing what
|
|
328
|
+
// follows it: `\s*$` would eat the file's trailing newline, and a command
|
|
329
|
+
// that reformats the end of a file it was asked to edit one line of is a
|
|
330
|
+
// command people stop trusting.
|
|
331
|
+
const assignment = /^module\.exports\s*=\s*([\s\S]+?);$/m;
|
|
332
|
+
const match = before.match(assignment);
|
|
333
|
+
if (match == null) {
|
|
334
|
+
return (0, steps_1.step)(steps_1.BLOCKED, `could not find a \`module.exports =\` in ${path.basename(file)}. Wrap ` +
|
|
335
|
+
'its export in `withDesktopPlatforms(...)` by hand.');
|
|
336
|
+
}
|
|
337
|
+
const wrapped = before.replace(assignment, `module.exports = withDesktopPlatforms(${match[1].trim()});`);
|
|
338
|
+
// After the last require at the top, so the file still reads top to bottom.
|
|
339
|
+
const requires = [...wrapped.matchAll(/^(?:const|let|var)\s.*require\(.*\);\s*$/gm)];
|
|
340
|
+
const after = requires.length > 0
|
|
341
|
+
? wrapped.slice(0, requires[requires.length - 1].index + requires[requires.length - 1][0].length) +
|
|
342
|
+
'\n' +
|
|
343
|
+
requireLine +
|
|
344
|
+
wrapped.slice(requires[requires.length - 1].index + requires[requires.length - 1][0].length)
|
|
345
|
+
: requireLine + wrapped;
|
|
346
|
+
fs.writeFileSync(file, after);
|
|
347
|
+
return (0, steps_1.step)(steps_1.CHANGED, `wrapped ${path.basename(file)} in withDesktopPlatforms`);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* This package's own version, for the dependency `init` adds.
|
|
351
|
+
*
|
|
352
|
+
* Found by walking up rather than by a fixed number of `..`: this file runs
|
|
353
|
+
* from `dist/cli/` once built and from `cli/` in a checkout, so any hardcoded
|
|
354
|
+
* depth is wrong in one of the two -- which is exactly the bug that shipped the
|
|
355
|
+
* first time, as a dependency pinned to `*`.
|
|
356
|
+
*/
|
|
357
|
+
function ownVersion() {
|
|
358
|
+
let dir = __dirname;
|
|
359
|
+
for (let up = 0; up < 5; up++) {
|
|
360
|
+
const candidate = path.join(dir, 'package.json');
|
|
361
|
+
const json = readJson(candidate);
|
|
362
|
+
if (json?.name === PACKAGE_NAME) {
|
|
363
|
+
return json.version != null ? `^${json.version}` : '*';
|
|
364
|
+
}
|
|
365
|
+
const parent = path.dirname(dir);
|
|
366
|
+
if (parent === dir) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
dir = parent;
|
|
370
|
+
}
|
|
371
|
+
return '*';
|
|
372
|
+
}
|
|
373
|
+
function init(root = process.cwd(), { write = true } = {}) {
|
|
374
|
+
const project = describeProject(root);
|
|
375
|
+
if (!project.ok) {
|
|
376
|
+
return { ok: false, reason: project.reason, steps: [] };
|
|
377
|
+
}
|
|
378
|
+
const metro = findMetroConfig(root);
|
|
379
|
+
const steps = [];
|
|
380
|
+
const { desktops, reason } = desktopsFor(root);
|
|
381
|
+
if (reason != null) {
|
|
382
|
+
// Reported rather than refused: the app is configurable, and what is wrong
|
|
383
|
+
// is one field. Refusing would leave it configured for nothing.
|
|
384
|
+
steps.push(['desktops', (0, steps_1.step)(steps_1.BLOCKED, reason)]);
|
|
385
|
+
}
|
|
386
|
+
steps.push(['dependencies', addDependencies(project, ownVersion(), desktops, write)]);
|
|
387
|
+
steps.push(['scripts', addScripts(project, write)]);
|
|
388
|
+
if (metro.file == null && metro.missing) {
|
|
389
|
+
// No config at all, which is what a stock Expo app looks like: write one
|
|
390
|
+
// rather than refuse. A config that exists and cannot be edited is a
|
|
391
|
+
// different case and still refused below.
|
|
392
|
+
steps.push([
|
|
393
|
+
'metro config',
|
|
394
|
+
write ? writeMetroConfig(root, project.expo) : (0, steps_1.step)(steps_1.CHANGED, 'would write metro.config.js'),
|
|
395
|
+
]);
|
|
396
|
+
}
|
|
397
|
+
else if (metro.file == null) {
|
|
398
|
+
steps.push(['metro config', (0, steps_1.step)(steps_1.BLOCKED, metro.reason ?? 'no metro config')]);
|
|
399
|
+
}
|
|
400
|
+
else if (write) {
|
|
401
|
+
steps.push(['metro config', wrapMetroConfig(metro.file)]);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// The read-only form, which this branch did not have: with writing off it
|
|
405
|
+
// pushed no step at all, so `doctor` would have said nothing about the one
|
|
406
|
+
// file most likely to be wrong.
|
|
407
|
+
steps.push(['metro config', inspectMetroConfig(metro.file)]);
|
|
408
|
+
}
|
|
409
|
+
if (write) {
|
|
410
|
+
// Two spaces and a trailing newline, which is what npm itself writes, so an
|
|
411
|
+
// app's package.json does not churn in the next unrelated diff.
|
|
412
|
+
fs.writeFileSync(project.manifest, `${JSON.stringify(project.json, null, 2)}\n`);
|
|
413
|
+
}
|
|
414
|
+
return { ok: true, steps };
|
|
415
|
+
}
|
|
416
|
+
function main(argv) {
|
|
417
|
+
// `npx basalt-core init` is how the README and the proposal both
|
|
418
|
+
// spell this, and it is how react-native-windows and react-native-macos
|
|
419
|
+
// spell theirs -- so `init` is the verb, not the directory to configure.
|
|
420
|
+
// Without this the command resolved ./init, found no package.json there,
|
|
421
|
+
// and refused to configure the app it was standing in.
|
|
422
|
+
const args = argv[0] === 'init' ? argv.slice(1) : argv;
|
|
423
|
+
const root = args[0] != null && !args[0].startsWith('-') ? path.resolve(args[0]) : process.cwd();
|
|
424
|
+
const result = init(root);
|
|
425
|
+
if (!result.ok) {
|
|
426
|
+
process.stderr.write(`basalt-core init: ${result.reason}\n`);
|
|
427
|
+
return 1;
|
|
428
|
+
}
|
|
429
|
+
const { changed, blocked } = (0, steps_1.report)(result.steps, line => process.stdout.write(`${line}\n`));
|
|
430
|
+
if (blocked > 0) {
|
|
431
|
+
process.stdout.write('\nSome steps need doing by hand; see above.\n');
|
|
432
|
+
return 1;
|
|
433
|
+
}
|
|
434
|
+
process.stdout.write(changed === 0
|
|
435
|
+
? '\nAlready configured. Nothing to do.\n'
|
|
436
|
+
: '\nInstall dependencies, then `npm run linux` (or macos, or windows).\n');
|
|
437
|
+
return 0;
|
|
438
|
+
}
|
|
439
|
+
if (require.main === module) {
|
|
440
|
+
process.exitCode = main(process.argv.slice(2));
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init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AC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAEjG,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;QAC7D,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,IAAA,cAAM,EAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;IAE3F,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,OAAO,KAAK,CAAC;QACX,CAAC,CAAC,wCAAwC;QAC1C,CAAC,CAAC,wEAAwE,CAC7E,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starting Metro, or noticing that it is already running.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately not a Metro API call. `run-android` and `run-ios` both shell out
|
|
5
|
+
* to `react-native start` in a detached process for the same reason: the
|
|
6
|
+
* packager outlives the run command, and an app is normally launched several
|
|
7
|
+
* times against one Metro.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
import type { ChildProcess } from 'node:child_process';
|
|
12
|
+
/**
|
|
13
|
+
* What React Native's CLI hands a command. Only the two fields this file uses:
|
|
14
|
+
* the rest of the context is large, changes between versions, and typing what
|
|
15
|
+
* is not read would be claiming more than is known.
|
|
16
|
+
*/
|
|
17
|
+
export type MetroContext = {
|
|
18
|
+
root: string;
|
|
19
|
+
reactNativePath: string;
|
|
20
|
+
};
|
|
21
|
+
export type StartedMetro = {
|
|
22
|
+
child: ChildProcess;
|
|
23
|
+
logPath: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Whether something is already listening.
|
|
27
|
+
*
|
|
28
|
+
* Only that something is listening, not that it is Metro: a port in use by
|
|
29
|
+
* anything else is a problem the developer has to see, and starting a second
|
|
30
|
+
* Metro on top of it would hide it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isPortTaken(port: number, host?: string): Promise<boolean>;
|
|
33
|
+
export declare function waitForPort(port: number, timeoutMs: number): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Starts Metro and returns once it is listening.
|
|
36
|
+
*
|
|
37
|
+
* Detached and unref'd, so quitting the app does not kill the packager and the
|
|
38
|
+
* next `run-linux` reuses it.
|
|
39
|
+
*
|
|
40
|
+
* Its output goes to a file rather than to this terminal, which looks like the
|
|
41
|
+
* unfriendly choice and is not. A detached child that inherits stdout holds the
|
|
42
|
+
* pipe open after this command exits, so anything reading `run-linux`'s output
|
|
43
|
+
* waits forever for a packager that is meant to outlive it. This repository's
|
|
44
|
+
* own CI hit the same shape and its workflow carries the same warning. The path
|
|
45
|
+
* is printed, and `--no-packager` with a packager of your own is the answer if
|
|
46
|
+
* you want it on screen.
|
|
47
|
+
*/
|
|
48
|
+
export declare function startMetro(context: MetroContext, port: number): Promise<StartedMetro>;
|
|
49
|
+
//# sourceMappingURL=metro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../cli/metro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAMrD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAY9E;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASnF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CA+C3F"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Starting Metro, or noticing that it is already running.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately not a Metro API call. `run-android` and `run-ios` both shell out
|
|
6
|
+
* to `react-native start` in a detached process for the same reason: the
|
|
7
|
+
* packager outlives the run command, and an app is normally launched several
|
|
8
|
+
* times against one Metro.
|
|
9
|
+
*
|
|
10
|
+
* @format
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.isPortTaken = isPortTaken;
|
|
47
|
+
exports.waitForPort = waitForPort;
|
|
48
|
+
exports.startMetro = startMetro;
|
|
49
|
+
const node_child_process_1 = require("node:child_process");
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const net = __importStar(require("node:net"));
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
53
|
+
/**
|
|
54
|
+
* Whether something is already listening.
|
|
55
|
+
*
|
|
56
|
+
* Only that something is listening, not that it is Metro: a port in use by
|
|
57
|
+
* anything else is a problem the developer has to see, and starting a second
|
|
58
|
+
* Metro on top of it would hide it.
|
|
59
|
+
*/
|
|
60
|
+
function isPortTaken(port, host = 'localhost') {
|
|
61
|
+
return new Promise(resolve => {
|
|
62
|
+
const socket = net.connect({ port, host });
|
|
63
|
+
const done = (taken) => {
|
|
64
|
+
socket.destroy();
|
|
65
|
+
resolve(taken);
|
|
66
|
+
};
|
|
67
|
+
socket.setTimeout(1500);
|
|
68
|
+
socket.once('connect', () => done(true));
|
|
69
|
+
socket.once('timeout', () => done(false));
|
|
70
|
+
socket.once('error', () => done(false));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function waitForPort(port, timeoutMs) {
|
|
74
|
+
const deadline = Date.now() + timeoutMs;
|
|
75
|
+
while (Date.now() < deadline) {
|
|
76
|
+
if (await isPortTaken(port)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Starts Metro and returns once it is listening.
|
|
85
|
+
*
|
|
86
|
+
* Detached and unref'd, so quitting the app does not kill the packager and the
|
|
87
|
+
* next `run-linux` reuses it.
|
|
88
|
+
*
|
|
89
|
+
* Its output goes to a file rather than to this terminal, which looks like the
|
|
90
|
+
* unfriendly choice and is not. A detached child that inherits stdout holds the
|
|
91
|
+
* pipe open after this command exits, so anything reading `run-linux`'s output
|
|
92
|
+
* waits forever for a packager that is meant to outlive it. This repository's
|
|
93
|
+
* own CI hit the same shape and its workflow carries the same warning. The path
|
|
94
|
+
* is printed, and `--no-packager` with a packager of your own is the answer if
|
|
95
|
+
* you want it on screen.
|
|
96
|
+
*/
|
|
97
|
+
async function startMetro(context, port) {
|
|
98
|
+
const cli = path.join(context.reactNativePath, 'cli.js');
|
|
99
|
+
const logDir = path.join(context.root, '.basalt');
|
|
100
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
101
|
+
const logPath = path.join(logDir, 'metro.log');
|
|
102
|
+
const log = fs.openSync(logPath, 'a');
|
|
103
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [cli, 'start', '--port', String(port)], {
|
|
104
|
+
cwd: context.root,
|
|
105
|
+
detached: true,
|
|
106
|
+
stdio: ['ignore', log, log],
|
|
107
|
+
});
|
|
108
|
+
child.unref();
|
|
109
|
+
fs.closeSync(log);
|
|
110
|
+
const exited = new Promise(resolve => {
|
|
111
|
+
child.once('exit', (code, signal) => resolve({ code, signal }));
|
|
112
|
+
child.once('error', (error) => resolve({ error }));
|
|
113
|
+
});
|
|
114
|
+
const outcome = await Promise.race([
|
|
115
|
+
waitForPort(port, 90000).then(listening => ({ listening })),
|
|
116
|
+
exited.then(exit => ({ exit })),
|
|
117
|
+
]);
|
|
118
|
+
if (outcome.exit) {
|
|
119
|
+
const { code, signal, error } = outcome.exit;
|
|
120
|
+
const how = error
|
|
121
|
+
? `could not be started (${error.message})`
|
|
122
|
+
: `exited before listening (${signal ?? `code ${code}`})`;
|
|
123
|
+
throw new Error(`Metro ${how}. The end of ${logPath}:\n\n${tail(logPath, 12)}`);
|
|
124
|
+
}
|
|
125
|
+
if (!outcome.listening) {
|
|
126
|
+
throw new Error(`Metro did not start listening on port ${port}; see ${logPath}`);
|
|
127
|
+
}
|
|
128
|
+
return { child, logPath };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The last lines of a file, without terminal colour codes, for an error
|
|
132
|
+
* message. Empty when it cannot be read: the message is still worth showing.
|
|
133
|
+
*/
|
|
134
|
+
function tail(file, lines) {
|
|
135
|
+
try {
|
|
136
|
+
return fs
|
|
137
|
+
.readFileSync(file, 'utf8')
|
|
138
|
+
.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '')
|
|
139
|
+
.trimEnd()
|
|
140
|
+
.split(/\r?\n/)
|
|
141
|
+
.slice(-lines)
|
|
142
|
+
.join('\n');
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
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