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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vince Vella
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basalt.d.ts","sourceRoot":"","sources":["../../cli/basalt.ts"],"names":[],"mappings":";AAyBA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAqB3C"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// `npx basalt-core <verb>`.
|
|
4
|
+
//
|
|
5
|
+
// Two verbs, and the same shape react-native-windows and react-native-macos
|
|
6
|
+
// use: a bin named for the platform, taking the thing to do. `init` was the
|
|
7
|
+
// first and was the bin itself, which is why it had to learn that `init` is a
|
|
8
|
+
// word and not a directory.
|
|
9
|
+
//
|
|
10
|
+
// Not a React Native CLI command, for the reason init.ts gives: before this
|
|
11
|
+
// runs, the package is not a dependency yet and the CLI has no config to read.
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.main = main;
|
|
14
|
+
const init_1 = require("./init");
|
|
15
|
+
const doctor_1 = require("./doctor");
|
|
16
|
+
const VERBS = {
|
|
17
|
+
init: init_1.main,
|
|
18
|
+
doctor: doctor_1.main,
|
|
19
|
+
};
|
|
20
|
+
const USAGE = `basalt-core <command> [directory]
|
|
21
|
+
|
|
22
|
+
init configure an app to build for the desktop
|
|
23
|
+
doctor report what a build needs, changing nothing
|
|
24
|
+
`;
|
|
25
|
+
function main(argv) {
|
|
26
|
+
const verb = argv[0];
|
|
27
|
+
if (verb === '--help' || verb === '-h' || verb == null) {
|
|
28
|
+
process.stdout.write(USAGE);
|
|
29
|
+
// No verb is a question, not a mistake, and a question was answered.
|
|
30
|
+
return verb == null ? 1 : 0;
|
|
31
|
+
}
|
|
32
|
+
const run = VERBS[verb];
|
|
33
|
+
if (run == null) {
|
|
34
|
+
// A path where a verb was expected is the old spelling of this command,
|
|
35
|
+
// when `init` was the bin. Saying so beats "unknown command ./my-app".
|
|
36
|
+
process.stderr.write(`basalt-core: no such command ${JSON.stringify(verb)}\n\n${USAGE}`);
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
// The verb is passed through: each main() already skips its own name, so
|
|
40
|
+
// that `node dist/cli/init.js init` keeps working for anything that calls
|
|
41
|
+
// the file directly.
|
|
42
|
+
return run(argv);
|
|
43
|
+
}
|
|
44
|
+
if (require.main === module) {
|
|
45
|
+
process.exitCode = main(process.argv.slice(2));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=basalt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basalt.js","sourceRoot":"","sources":["../../cli/basalt.ts"],"names":[],"mappings":";;AACA,4BAA4B;AAC5B,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;;AAgB/E,oBAqBC;AAnCD,iCAAwC;AACxC,qCAA4C;AAE5C,MAAM,KAAK,GAAyD;IAClE,IAAI,EAAE,WAAQ;IACd,MAAM,EAAE,aAAU;CACnB,CAAC;AAEF,MAAM,KAAK,GAAG;;;;CAIb,CAAC;AAEF,SAAgB,IAAI,CAAC,IAAc;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAErB,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,qEAAqE;QACrE,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,wEAAwE;QACxE,uEAAuE;QACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;QACzF,OAAO,CAAC,CAAC;IACX,CAAC;IAED,yEAAyE;IACzE,0EAA0E;IAC1E,qBAAqB;IACrB,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;AACnB,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,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `basalt-bundle`, for apps that cannot use React Native's CLI.
|
|
4
|
+
*
|
|
5
|
+
* An Expo app has `expo` as its CLI, which does not know this platform, and
|
|
6
|
+
* Metro's own `build` emits no assets. This is the missing command: one bundle,
|
|
7
|
+
* its assets beside it, ready for the host to load.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=bundle-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-cli.d.ts","sourceRoot":"","sources":["../../cli/bundle-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* `basalt-bundle`, for apps that cannot use React Native's CLI.
|
|
5
|
+
*
|
|
6
|
+
* An Expo app has `expo` as its CLI, which does not know this platform, and
|
|
7
|
+
* Metro's own `build` emits no assets. This is the missing command: one bundle,
|
|
8
|
+
* its assets beside it, ready for the host to load.
|
|
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
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const bundleWithAssets_1 = require("./bundleWithAssets");
|
|
48
|
+
function parse(argv) {
|
|
49
|
+
const options = {
|
|
50
|
+
projectRoot: process.cwd(),
|
|
51
|
+
entryFile: 'index.js',
|
|
52
|
+
platform: 'linux',
|
|
53
|
+
dev: false,
|
|
54
|
+
};
|
|
55
|
+
for (let i = 0; i < argv.length; i++) {
|
|
56
|
+
const next = () => argv[++i];
|
|
57
|
+
switch (argv[i]) {
|
|
58
|
+
case '--project-root':
|
|
59
|
+
options.projectRoot = path.resolve(next());
|
|
60
|
+
break;
|
|
61
|
+
case '--entry-file':
|
|
62
|
+
options.entryFile = next();
|
|
63
|
+
break;
|
|
64
|
+
case '--bundle-output':
|
|
65
|
+
options.bundleOutput = path.resolve(next());
|
|
66
|
+
break;
|
|
67
|
+
case '--assets-dest':
|
|
68
|
+
options.assetsDest = path.resolve(next());
|
|
69
|
+
break;
|
|
70
|
+
case '--platform':
|
|
71
|
+
options.platform = next();
|
|
72
|
+
break;
|
|
73
|
+
case '--config':
|
|
74
|
+
options.configPath = path.resolve(next());
|
|
75
|
+
break;
|
|
76
|
+
case '--dev':
|
|
77
|
+
options.dev = next() !== 'false';
|
|
78
|
+
break;
|
|
79
|
+
case '--minify':
|
|
80
|
+
options.minify = next() !== 'false';
|
|
81
|
+
break;
|
|
82
|
+
case '-h':
|
|
83
|
+
case '--help':
|
|
84
|
+
options.help = true;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`unknown option ${argv[i]}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return options;
|
|
91
|
+
}
|
|
92
|
+
const USAGE = `
|
|
93
|
+
basalt-bundle --bundle-output <path> [options]
|
|
94
|
+
|
|
95
|
+
--entry-file <path> default index.js
|
|
96
|
+
--bundle-output <path> required
|
|
97
|
+
--assets-dest <dir> default: beside the bundle, which is where React
|
|
98
|
+
Native looks for assets at runtime
|
|
99
|
+
--project-root <dir> default: the working directory
|
|
100
|
+
--config <path> a metro.config.js, if not the project's own
|
|
101
|
+
--dev true|false default false
|
|
102
|
+
--minify true|false default: the opposite of --dev
|
|
103
|
+
`;
|
|
104
|
+
async function main() {
|
|
105
|
+
const options = parse(process.argv.slice(2));
|
|
106
|
+
if (options.help || options.bundleOutput == null) {
|
|
107
|
+
console.log(USAGE.trim());
|
|
108
|
+
process.exitCode = options.help ? 0 : 1;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// Narrowed by the guard above: `bundleOutput` is what makes the options a
|
|
112
|
+
// complete request rather than a partial one.
|
|
113
|
+
const request = options;
|
|
114
|
+
const result = await (0, bundleWithAssets_1.bundleWithAssets)(request);
|
|
115
|
+
console.log(`wrote ${path.relative(request.projectRoot, request.bundleOutput)} ` +
|
|
116
|
+
`and ${result.files} asset file${result.files === 1 ? '' : 's'} ` +
|
|
117
|
+
`from ${result.assets} asset${result.assets === 1 ? '' : 's'}` +
|
|
118
|
+
(result.expoConfig ? ', with app.config.json' : ''));
|
|
119
|
+
}
|
|
120
|
+
main().catch((error) => {
|
|
121
|
+
console.error(`error: ${error.message}`);
|
|
122
|
+
process.exitCode = 1;
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=bundle-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-cli.js","sourceRoot":"","sources":["../../cli/bundle-cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundling for linux, assets included.
|
|
3
|
+
*
|
|
4
|
+
* React Native's own CLI does this and takes `--assets-dest`, so a React Native
|
|
5
|
+
* app is served by `run-linux`. An Expo app is not: its CLI is `expo`, which
|
|
6
|
+
* does not know this platform, and Metro's own `build` command has no asset
|
|
7
|
+
* option at all. Without one, `require('./logo.png')` resolves to a path beside
|
|
8
|
+
* the bundle that nothing ever wrote.
|
|
9
|
+
*
|
|
10
|
+
* So this is the same two steps React Native's CLI performs internally: build
|
|
11
|
+
* the bundle, then ask Metro which assets the build referenced and copy each
|
|
12
|
+
* one where resolution will look for it.
|
|
13
|
+
*
|
|
14
|
+
* @format
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* One asset, as Metro's `Server.getAssets` reports it. `scales` and `files` are
|
|
18
|
+
* parallel: one file per scale.
|
|
19
|
+
*/
|
|
20
|
+
export type MetroAsset = {
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
httpServerLocation: string;
|
|
24
|
+
scales: number[];
|
|
25
|
+
files: string[];
|
|
26
|
+
};
|
|
27
|
+
export type BundleOptions = {
|
|
28
|
+
projectRoot: string;
|
|
29
|
+
entryFile: string;
|
|
30
|
+
bundleOutput: string;
|
|
31
|
+
assetsDest?: string;
|
|
32
|
+
platform?: string;
|
|
33
|
+
dev?: boolean;
|
|
34
|
+
minify?: boolean;
|
|
35
|
+
configPath?: string;
|
|
36
|
+
};
|
|
37
|
+
export type BundleResult = {
|
|
38
|
+
assets: number;
|
|
39
|
+
files: number;
|
|
40
|
+
assetsDest: string;
|
|
41
|
+
expoConfig: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Where one asset file belongs, relative to the assets directory.
|
|
45
|
+
*
|
|
46
|
+
* This has to agree exactly with what React Native computes at runtime in
|
|
47
|
+
* `AssetSourceResolver.scaledAssetPath`, or assets land somewhere resolution
|
|
48
|
+
* does not look and the failure is a missing file with no explanation. The
|
|
49
|
+
* `../` replacement is React Native's: an asset can sit outside the project
|
|
50
|
+
* root, and its path must not escape the assets directory.
|
|
51
|
+
*/
|
|
52
|
+
export declare function destinationFor(asset: MetroAsset, scale: number): string;
|
|
53
|
+
/**
|
|
54
|
+
* Writes the app's resolved Expo config beside the bundle, as `app.config.json`.
|
|
55
|
+
*
|
|
56
|
+
* This is what `Constants.expoConfig` is, and expo-linking reads it to find the
|
|
57
|
+
* app's URI scheme. iOS and Android embed it into the app during the native
|
|
58
|
+
* build, from a script expo-constants contributes; this platform's hosts are
|
|
59
|
+
* generic binaries with no build step of their own, so bundling is the moment
|
|
60
|
+
* that has both the project and a place to put the answer.
|
|
61
|
+
*
|
|
62
|
+
* `isPublicConfig` is Expo's own flag for "this will be readable by anything
|
|
63
|
+
* that can read the app", and drops the keys that are not meant to be --
|
|
64
|
+
* `hooks`, and EAS credentials under `extra`. Embedding the private config
|
|
65
|
+
* would be a change in what an app ships, made silently by a bundler.
|
|
66
|
+
*
|
|
67
|
+
* Returns false when the project is not an Expo app, which is not a failure:
|
|
68
|
+
* `expo/config` is simply not there to resolve.
|
|
69
|
+
*/
|
|
70
|
+
export declare function writeExpoAppConfig(projectRoot: string, bundleOutput: string): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Builds `entryFile` to `bundleOutput`, and writes its assets beside it.
|
|
73
|
+
*
|
|
74
|
+
* Beside it by default, and that default is not arbitrary: React Native
|
|
75
|
+
* resolves an asset relative to the script's own location, so anywhere else is
|
|
76
|
+
* wrong unless the script is somewhere else too.
|
|
77
|
+
*/
|
|
78
|
+
export declare function bundleWithAssets({ projectRoot, entryFile, bundleOutput, assetsDest, platform, dev, minify, configPath, }: BundleOptions): Promise<BundleResult>;
|
|
79
|
+
//# sourceMappingURL=bundleWithAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleWithAssets.d.ts","sourceRoot":"","sources":["../../cli/bundleWithAssets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAkEF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvE;AAoBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CAyBlB;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAkB,EAClB,GAAW,EACX,MAAa,EACb,UAAU,GACX,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAkCvC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bundling for linux, assets included.
|
|
4
|
+
*
|
|
5
|
+
* React Native's own CLI does this and takes `--assets-dest`, so a React Native
|
|
6
|
+
* app is served by `run-linux`. An Expo app is not: its CLI is `expo`, which
|
|
7
|
+
* does not know this platform, and Metro's own `build` command has no asset
|
|
8
|
+
* option at all. Without one, `require('./logo.png')` resolves to a path beside
|
|
9
|
+
* the bundle that nothing ever wrote.
|
|
10
|
+
*
|
|
11
|
+
* So this is the same two steps React Native's CLI performs internally: build
|
|
12
|
+
* the bundle, then ask Metro which assets the build referenced and copy each
|
|
13
|
+
* one where resolution will look for it.
|
|
14
|
+
*
|
|
15
|
+
* @format
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.destinationFor = destinationFor;
|
|
52
|
+
exports.writeExpoAppConfig = writeExpoAppConfig;
|
|
53
|
+
exports.bundleWithAssets = bundleWithAssets;
|
|
54
|
+
const fs = __importStar(require("node:fs"));
|
|
55
|
+
const path = __importStar(require("node:path"));
|
|
56
|
+
const node_module_1 = require("node:module");
|
|
57
|
+
/**
|
|
58
|
+
* Metro, and the pieces of it that have no public export.
|
|
59
|
+
*
|
|
60
|
+
* `metro/private/*` is how Metro's own package.json exposes its internals, and
|
|
61
|
+
* `Server.getAssets` is what React Native's CLI uses for exactly this. Resolved
|
|
62
|
+
* from the project rather than from here, so an app gets the Metro it installed
|
|
63
|
+
* and not a second copy.
|
|
64
|
+
*/
|
|
65
|
+
function loadMetro(projectRoot) {
|
|
66
|
+
const resolvers = [(0, node_module_1.createRequire)(path.join(projectRoot, 'package.json'))];
|
|
67
|
+
// Then from React Native's own location. An installed app has Metro hoisted
|
|
68
|
+
// into its node_modules and the first resolver finds it; a checkout, a
|
|
69
|
+
// workspace or a linked package may not, and Metro is always beside React
|
|
70
|
+
// Native. Looked up second rather than first so an app that pins its own
|
|
71
|
+
// Metro gets the one it pinned.
|
|
72
|
+
try {
|
|
73
|
+
resolvers.push((0, node_module_1.createRequire)(resolvers[0].resolve('react-native/package.json')));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// No react-native from the project. The error below will be the useful one.
|
|
77
|
+
}
|
|
78
|
+
for (const resolve of resolvers) {
|
|
79
|
+
try {
|
|
80
|
+
const metro = resolve('metro');
|
|
81
|
+
const serverModule = resolve('metro/private/Server');
|
|
82
|
+
return { metro, Server: serverModule.default ?? serverModule };
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Try the next one.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`could not find Metro from ${projectRoot} or from its react-native. ` +
|
|
89
|
+
'Bundling needs it; it is normally installed with react-native.');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Where one asset file belongs, relative to the assets directory.
|
|
93
|
+
*
|
|
94
|
+
* This has to agree exactly with what React Native computes at runtime in
|
|
95
|
+
* `AssetSourceResolver.scaledAssetPath`, or assets land somewhere resolution
|
|
96
|
+
* does not look and the failure is a missing file with no explanation. The
|
|
97
|
+
* `../` replacement is React Native's: an asset can sit outside the project
|
|
98
|
+
* root, and its path must not escape the assets directory.
|
|
99
|
+
*/
|
|
100
|
+
function destinationFor(asset, scale) {
|
|
101
|
+
const suffix = scale === 1 ? '' : `@${scale}x`;
|
|
102
|
+
const name = `${asset.name}${suffix}.${asset.type}`;
|
|
103
|
+
return path.join(asset.httpServerLocation.replace(/^\//, '').replace(/\.\.\//g, '_'), name);
|
|
104
|
+
}
|
|
105
|
+
async function copyAssets(assets, assetsDest) {
|
|
106
|
+
let copied = 0;
|
|
107
|
+
for (const asset of assets) {
|
|
108
|
+
// `scales` and `files` are parallel arrays: one file per scale.
|
|
109
|
+
for (let index = 0; index < asset.scales.length; index++) {
|
|
110
|
+
const source = asset.files[index];
|
|
111
|
+
if (source == null) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const destination = path.join(assetsDest, destinationFor(asset, asset.scales[index]));
|
|
115
|
+
await fs.promises.mkdir(path.dirname(destination), { recursive: true });
|
|
116
|
+
await fs.promises.copyFile(source, destination);
|
|
117
|
+
copied++;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return copied;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Writes the app's resolved Expo config beside the bundle, as `app.config.json`.
|
|
124
|
+
*
|
|
125
|
+
* This is what `Constants.expoConfig` is, and expo-linking reads it to find the
|
|
126
|
+
* app's URI scheme. iOS and Android embed it into the app during the native
|
|
127
|
+
* build, from a script expo-constants contributes; this platform's hosts are
|
|
128
|
+
* generic binaries with no build step of their own, so bundling is the moment
|
|
129
|
+
* that has both the project and a place to put the answer.
|
|
130
|
+
*
|
|
131
|
+
* `isPublicConfig` is Expo's own flag for "this will be readable by anything
|
|
132
|
+
* that can read the app", and drops the keys that are not meant to be --
|
|
133
|
+
* `hooks`, and EAS credentials under `extra`. Embedding the private config
|
|
134
|
+
* would be a change in what an app ships, made silently by a bundler.
|
|
135
|
+
*
|
|
136
|
+
* Returns false when the project is not an Expo app, which is not a failure:
|
|
137
|
+
* `expo/config` is simply not there to resolve.
|
|
138
|
+
*/
|
|
139
|
+
async function writeExpoAppConfig(projectRoot, bundleOutput) {
|
|
140
|
+
let getConfig;
|
|
141
|
+
try {
|
|
142
|
+
getConfig = (0, node_module_1.createRequire)(path.join(projectRoot, 'package.json'))('expo/config')
|
|
143
|
+
.getConfig;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
// Past this point the project *is* an Expo app, so a failure is a real one
|
|
149
|
+
// and silence would leave Constants.expoConfig mysteriously null.
|
|
150
|
+
const { exp } = getConfig(projectRoot, {
|
|
151
|
+
skipSDKVersionRequirement: true,
|
|
152
|
+
isPublicConfig: true,
|
|
153
|
+
});
|
|
154
|
+
const destination = path.join(path.dirname(bundleOutput), 'app.config.json');
|
|
155
|
+
await fs.promises.writeFile(destination, JSON.stringify(exp, null, 2));
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Builds `entryFile` to `bundleOutput`, and writes its assets beside it.
|
|
160
|
+
*
|
|
161
|
+
* Beside it by default, and that default is not arbitrary: React Native
|
|
162
|
+
* resolves an asset relative to the script's own location, so anywhere else is
|
|
163
|
+
* wrong unless the script is somewhere else too.
|
|
164
|
+
*/
|
|
165
|
+
async function bundleWithAssets({ projectRoot, entryFile, bundleOutput, assetsDest, platform = 'linux', dev = false, minify = !dev, configPath, }) {
|
|
166
|
+
const { metro, Server } = loadMetro(projectRoot);
|
|
167
|
+
const config = await metro.loadConfig({ cwd: projectRoot, config: configPath });
|
|
168
|
+
const destination = assetsDest ?? path.dirname(bundleOutput);
|
|
169
|
+
await fs.promises.mkdir(path.dirname(bundleOutput), { recursive: true });
|
|
170
|
+
await metro.runBuild(config, {
|
|
171
|
+
entry: entryFile,
|
|
172
|
+
out: bundleOutput,
|
|
173
|
+
platform,
|
|
174
|
+
dev,
|
|
175
|
+
minify,
|
|
176
|
+
});
|
|
177
|
+
// A second Metro over the same config. Wasteful-looking and not: the build
|
|
178
|
+
// above discards the graph, and this is the only public-ish way to ask which
|
|
179
|
+
// assets it contained.
|
|
180
|
+
const server = new Server(config);
|
|
181
|
+
try {
|
|
182
|
+
const assets = await server.getAssets({
|
|
183
|
+
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
184
|
+
entryFile,
|
|
185
|
+
platform,
|
|
186
|
+
dev,
|
|
187
|
+
minify,
|
|
188
|
+
bundleType: 'todo',
|
|
189
|
+
});
|
|
190
|
+
const copied = await copyAssets(assets, destination);
|
|
191
|
+
const expoConfig = await writeExpoAppConfig(projectRoot, bundleOutput);
|
|
192
|
+
return { assets: assets.length, files: copied, assetsDest: destination, expoConfig };
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
server.end();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=bundleWithAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleWithAssets.js","sourceRoot":"","sources":["../../cli/bundleWithAssets.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GH,wCAIC;AAqCD,gDA4BC;AASD,4CA2CC;AApOD,4CAA8B;AAC9B,gDAAkC;AAClC,6CAA0C;AA0D1C;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,WAAmB;IACpC,MAAM,SAAS,GAAG,CAAC,IAAA,2BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAE1E,4EAA4E;IAC5E,uEAAuE;IACvE,0EAA0E;IAC1E,yEAAyE;IACzE,gCAAgC;IAChC,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,IAAA,2BAAa,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;IAAC,MAAM,CAAC;QACP,4EAA4E;IAC9E,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAC/B,MAAM,YAAY,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;YACrD,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,IAAI,YAAY,EAAC,CAAC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB;QACtB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,6BAA6B,WAAW,6BAA6B;QACnE,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