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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// How big a window may be: the clamp, which is portable.
|
|
2
|
+
//
|
|
3
|
+
// Worth a unit test rather than only an end-to-end one, because the end-to-end
|
|
4
|
+
// half cannot run everywhere. Enforcing a limit needs a window manager to
|
|
5
|
+
// enforce it, and CI runs the Linux host under Xvfb, which has none -- so the
|
|
6
|
+
// scenario there asserts what the platform *says* it does and stops. This is
|
|
7
|
+
// the arithmetic underneath, and it runs on any machine.
|
|
8
|
+
//
|
|
9
|
+
// The clamp exists at all because the toolkits disagree. AppKit's `setFrame:`
|
|
10
|
+
// clamps a programmatic resize down to the maximum and not up to the minimum,
|
|
11
|
+
// so a window asked to be 300x200 under a minimum of 500x400 went to 300x200 --
|
|
12
|
+
// smaller than anything a person dragging its corner could have made it.
|
|
13
|
+
|
|
14
|
+
#include "TestHarness.h"
|
|
15
|
+
|
|
16
|
+
#include "WindowControl.h"
|
|
17
|
+
|
|
18
|
+
#include <sstream>
|
|
19
|
+
|
|
20
|
+
namespace {
|
|
21
|
+
|
|
22
|
+
// Back to no limits at all, which is the state every other test assumes.
|
|
23
|
+
struct NoLimits {
|
|
24
|
+
~NoLimits() {
|
|
25
|
+
basalt::setWindowMinimumSize(0, 0);
|
|
26
|
+
basalt::setWindowMaximumSize(0, 0);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
TEST(limits_nothing_is_clamped_by_default) {
|
|
31
|
+
const NoLimits reset;
|
|
32
|
+
double width = 123.0;
|
|
33
|
+
double height = 45.0;
|
|
34
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
35
|
+
EXPECT_EQ(width, 123.0);
|
|
36
|
+
EXPECT_EQ(height, 45.0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
TEST(limits_a_minimum_raises_a_smaller_request) {
|
|
40
|
+
const NoLimits reset;
|
|
41
|
+
basalt::setWindowMinimumSize(500, 400);
|
|
42
|
+
double width = 300.0;
|
|
43
|
+
double height = 200.0;
|
|
44
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
45
|
+
|
|
46
|
+
// Only where the platform says it does this. A desktop that reports
|
|
47
|
+
// `minimumSize: false` must not quietly enforce one here: the whole value of
|
|
48
|
+
// answering the question is that the answer can be trusted.
|
|
49
|
+
if (basalt::windowCapabilities().minimumSize) {
|
|
50
|
+
EXPECT_EQ(width, 500.0);
|
|
51
|
+
EXPECT_EQ(height, 400.0);
|
|
52
|
+
} else {
|
|
53
|
+
EXPECT_EQ(width, 300.0);
|
|
54
|
+
EXPECT_EQ(height, 200.0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
TEST(limits_a_maximum_lowers_a_larger_request) {
|
|
59
|
+
const NoLimits reset;
|
|
60
|
+
basalt::setWindowMaximumSize(800, 600);
|
|
61
|
+
double width = 1400.0;
|
|
62
|
+
double height = 1100.0;
|
|
63
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
64
|
+
|
|
65
|
+
if (basalt::windowCapabilities().maximumSize) {
|
|
66
|
+
EXPECT_EQ(width, 800.0);
|
|
67
|
+
EXPECT_EQ(height, 600.0);
|
|
68
|
+
} else {
|
|
69
|
+
// GTK4 removed `gtk_window_set_geometry_hints` and Wayland has no protocol
|
|
70
|
+
// for a maximum, so Linux reports false and is left alone. Enforcing one
|
|
71
|
+
// for a programmatic resize and not for a dragged corner would be a limit
|
|
72
|
+
// that half exists.
|
|
73
|
+
EXPECT_EQ(width, 1400.0);
|
|
74
|
+
EXPECT_EQ(height, 1100.0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
TEST(limits_a_request_already_inside_them_is_untouched) {
|
|
79
|
+
const NoLimits reset;
|
|
80
|
+
basalt::setWindowMinimumSize(400, 300);
|
|
81
|
+
basalt::setWindowMaximumSize(1000, 800);
|
|
82
|
+
double width = 700.0;
|
|
83
|
+
double height = 500.0;
|
|
84
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
85
|
+
EXPECT_EQ(width, 700.0);
|
|
86
|
+
EXPECT_EQ(height, 500.0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
TEST(limits_zero_clears_one_rather_than_pinning_a_window_to_nothing) {
|
|
90
|
+
const NoLimits reset;
|
|
91
|
+
basalt::setWindowMinimumSize(500, 400);
|
|
92
|
+
basalt::setWindowMinimumSize(0, 0);
|
|
93
|
+
double width = 100.0;
|
|
94
|
+
double height = 80.0;
|
|
95
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
96
|
+
EXPECT_EQ(width, 100.0);
|
|
97
|
+
EXPECT_EQ(height, 80.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
TEST(limits_a_negative_is_the_same_as_clearing) {
|
|
101
|
+
// An app clearing a constraint is more likely to pass 0 than -1, and neither
|
|
102
|
+
// should be a window that cannot be narrower than minus one pixel.
|
|
103
|
+
const NoLimits reset;
|
|
104
|
+
basalt::setWindowMinimumSize(-1, -1);
|
|
105
|
+
const basalt::WindowSizeLimits limits = basalt::windowSizeLimits();
|
|
106
|
+
EXPECT_EQ(limits.minWidth, 0.0);
|
|
107
|
+
EXPECT_EQ(limits.minHeight, 0.0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
TEST(limits_one_dimension_can_be_limited_without_the_other) {
|
|
111
|
+
const NoLimits reset;
|
|
112
|
+
basalt::setWindowMinimumSize(500, 0);
|
|
113
|
+
double width = 300.0;
|
|
114
|
+
double height = 10.0;
|
|
115
|
+
basalt::constrainToWindowSizeLimits(width, height);
|
|
116
|
+
if (basalt::windowCapabilities().minimumSize) {
|
|
117
|
+
EXPECT_EQ(width, 500.0);
|
|
118
|
+
}
|
|
119
|
+
// Never raised: a limit of zero is no limit, not a limit of zero.
|
|
120
|
+
EXPECT_EQ(height, 10.0);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
} // namespace
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "basalt-core",
|
|
3
|
+
"version": "0.0.0-rc5",
|
|
4
|
+
"description": "React Native on the desktop, over React Native's own C++ core rather than a fork. The shared half: the platform module, the Metro configuration that resolves it, the bundler, and the C++ that is not about a toolkit.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/vincentvella/basalt-core.git",
|
|
9
|
+
"directory": "packages/basalt-core"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/src/index.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/src/index.js",
|
|
14
|
+
"./metro-config": "./dist/metro-config.js",
|
|
15
|
+
"./cli/bundleWithAssets": "./dist/cli/bundleWithAssets.js",
|
|
16
|
+
"./cli/desktop": "./dist/cli/desktop.js",
|
|
17
|
+
"./cli/metro": "./dist/cli/metro.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"native",
|
|
23
|
+
"metro-config.js",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"supported-versions.json"
|
|
26
|
+
],
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "*",
|
|
29
|
+
"react-native": "*"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@babel/runtime": "^7.25.0"
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"basalt": "dist/cli/basalt.js",
|
|
36
|
+
"basalt-bundle": "dist/cli/bundle-cli.js"
|
|
37
|
+
},
|
|
38
|
+
"types": "dist/src/index.d.ts",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "../../scripts/build_ts.sh",
|
|
41
|
+
"prepack": "../../scripts/build_ts.sh"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What React Native's CLI reads out of this package.
|
|
3
|
+
*
|
|
4
|
+
* An entry per platform, without which the CLI does not believe these are
|
|
5
|
+
* platforms and `react-native bundle --platform macos` is rejected before Metro
|
|
6
|
+
* sees it.
|
|
7
|
+
*
|
|
8
|
+
* Commands are not here. `run-linux` needs a GTK host to run, so it belongs to
|
|
9
|
+
* basalt-gtk -- the CLI reads a react-native.config.js out of every
|
|
10
|
+
* dependency, so an app that has only the AppKit package never sees a command it
|
|
11
|
+
* could not have used.
|
|
12
|
+
*
|
|
13
|
+
* `projectConfig` returning null for a project with no native directory is how
|
|
14
|
+
* the CLI is told "this project does not target that platform", and is what
|
|
15
|
+
* keeps the command out of the way in an app that only builds for iOS. Today
|
|
16
|
+
* every project targets all three, because there is no per-project native code
|
|
17
|
+
* to look for yet; when there is, this is where the check goes.
|
|
18
|
+
*
|
|
19
|
+
* @format
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// Checked, not compiled.
|
|
23
|
+
//
|
|
24
|
+
// This file stays JavaScript on purpose, and it is the only one in the package
|
|
25
|
+
// that does. React Native's CLI reads it from `node_modules/<package>/` by
|
|
26
|
+
// path convention rather than through `exports`, so it has to be loadable as
|
|
27
|
+
// CommonJS at exactly this path -- and what it exports is a data structure,
|
|
28
|
+
// which is the one shape types buy nothing to write and everything to check.
|
|
29
|
+
// `@ts-check` gives the checking without putting a tool this project does not
|
|
30
|
+
// control behind a build step.
|
|
31
|
+
// @ts-check
|
|
32
|
+
'use strict';
|
|
33
|
+
|
|
34
|
+
/** @typedef {{projectConfig: () => object, dependencyConfig: () => null}} PlatformEntry */
|
|
35
|
+
|
|
36
|
+
// `./dist/metro-config`, not `./metro-config`: that file is TypeScript now and
|
|
37
|
+
// this one is not compiled, so the sibling it used to sit beside is no longer
|
|
38
|
+
// there. This is the file React Native's CLI loads from the package root, so
|
|
39
|
+
// it must resolve with nothing but Node.
|
|
40
|
+
// Required from `dist` at runtime, typed from the source.
|
|
41
|
+
//
|
|
42
|
+
// They are the same module. Splitting them this way is what stops checking
|
|
43
|
+
// this file from depending on the output of the very compilation that checks
|
|
44
|
+
// it -- `./dist/metro-config.d.ts` does not exist yet on a clean build, and a
|
|
45
|
+
// config file that only type-checks on the second run is a trap.
|
|
46
|
+
//
|
|
47
|
+
// The path is built rather than written so that TypeScript does not try to
|
|
48
|
+
// resolve it; the cast beside it says what it is.
|
|
49
|
+
const metroConfig = /** @type {typeof import('./metro-config')} */ (
|
|
50
|
+
require(`${__dirname}/dist/metro-config`)
|
|
51
|
+
);
|
|
52
|
+
const DESKTOP_PLATFORMS = metroConfig.DESKTOP_PLATFORMS;
|
|
53
|
+
|
|
54
|
+
// The same entry for each. They differ in their view layer and in nothing the
|
|
55
|
+
// CLI can see, which is the whole argument of this project restated as four
|
|
56
|
+
// lines of configuration.
|
|
57
|
+
//
|
|
58
|
+
// Deliberately no `npmPackageName`, which is the one field that looks obviously
|
|
59
|
+
// right and is wrong here.
|
|
60
|
+
//
|
|
61
|
+
// Setting it tells the CLI this is an *out-of-tree platform* in the
|
|
62
|
+
// react-native-macos and react-native-windows sense: a fork. It then installs
|
|
63
|
+
// `reactNativePlatformResolver`, which rewrites every `react-native/...` import
|
|
64
|
+
// to `basalt-core/...` when bundling, and requires this package to
|
|
65
|
+
// export `./setup-env`. Both are correct for a fork that vendors React Native's
|
|
66
|
+
// JavaScript. This package vendors none of it -- it redirects nine of React
|
|
67
|
+
// Native's own shims to their existing `.android.js` siblings and overrides two
|
|
68
|
+
// files -- so the rewrite sends every import into a package that does not
|
|
69
|
+
// contain it.
|
|
70
|
+
//
|
|
71
|
+
// Without the field these are still platforms the CLI accepts, and resolution
|
|
72
|
+
// stays with `withDesktopPlatforms` in metro-config.js, which is where the
|
|
73
|
+
// actual policy lives.
|
|
74
|
+
/** @type {Record<string, PlatformEntry>} */
|
|
75
|
+
const platforms = {};
|
|
76
|
+
for (const name of DESKTOP_PLATFORMS) {
|
|
77
|
+
platforms[name] = {
|
|
78
|
+
projectConfig: () => ({}),
|
|
79
|
+
// No autolinking: nothing here has native code to link yet, and claiming
|
|
80
|
+
// otherwise would make the CLI generate references to files that do not
|
|
81
|
+
// exist.
|
|
82
|
+
dependencyConfig: () => null,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = {platforms};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": [
|
|
3
|
+
"Which React Native this platform supports, and which Hermes to build for it.",
|
|
4
|
+
"",
|
|
5
|
+
"A pinned triple: basalt-core, React Native, and Hermes are chosen and",
|
|
6
|
+
"tested together, the way react-native-windows pins its own Hermes NuGet",
|
|
7
|
+
"version and one exact React Native in peerDependencies. The alternative --",
|
|
8
|
+
"deriving Hermes from whatever React Native an app happens to have -- was tried",
|
|
9
|
+
"and abandoned: React Native 0.81's Hermes wants a jsi header newer React",
|
|
10
|
+
"Native does not ship and names its build target differently, so following the",
|
|
11
|
+
"app leads three compile errors deep into a version nobody claimed to support.",
|
|
12
|
+
"",
|
|
13
|
+
"Hermes is pinned here rather than read from React Native because this platform",
|
|
14
|
+
"builds it from source. Windows, macOS, iOS and Android all consume a prebuilt",
|
|
15
|
+
"Hermes; Meta publishes one for each of them and none for Linux. That single",
|
|
16
|
+
"difference is where every version problem here comes from.",
|
|
17
|
+
"",
|
|
18
|
+
"To add a version: add an entry, bootstrap against it, and run both suites.",
|
|
19
|
+
"Untested is not supported -- saying so is the point of this file."
|
|
20
|
+
],
|
|
21
|
+
"supported": [
|
|
22
|
+
{
|
|
23
|
+
"reactNative": "0.86",
|
|
24
|
+
"hermes": "250829098.0.0-stable",
|
|
25
|
+
"hermesTarget": "hermesvm",
|
|
26
|
+
"verified": "0.86.3",
|
|
27
|
+
"notes": "The React Native a current Expo app installs, which is why it is supported.",
|
|
28
|
+
"limitations": [
|
|
29
|
+
"No Fast Refresh. ReactHost::destroyReactInstance sets reactInstanceData_->mountingManager to null on teardown, so a reload recreates the instance without a mounting manager and the host collapses. Reproduced, root-caused, and fixed upstream in 0.87 by deleting those three lines. Four of five end-to-end scenarios pass; the fifth is this."
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"reactNative": "0.87",
|
|
34
|
+
"hermes": "250829098.0.0-stable",
|
|
35
|
+
"verified": "0.87.1",
|
|
36
|
+
"notes": "60/60 unit and 5/5 end-to-end, macOS and CI. What CI pins.",
|
|
37
|
+
"hermesTarget": "hermesvm"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"development": {
|
|
41
|
+
"reactNative": "1000.0.0",
|
|
42
|
+
"hermes": "250829098.0.0-stable",
|
|
43
|
+
"notes": "React Native main, which calls itself 1000.0.0. Where development happens; the weekly drift job tracks it.",
|
|
44
|
+
"hermesTarget": "hermesvm"
|
|
45
|
+
},
|
|
46
|
+
"known-unsupported": [
|
|
47
|
+
{
|
|
48
|
+
"reactNative": "0.83 - 0.85",
|
|
49
|
+
"why": "Never built or tested. Nothing suggests they would not work; nothing has checked."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"reactNative": "0.82 and older",
|
|
53
|
+
"why": "Attempted for 0.81.6 and stopped deliberately. Six differences, of which the last three are structural.",
|
|
54
|
+
"what-it-would-take": [
|
|
55
|
+
"~~RN$TurboInterop set before the bundle evaluates, or no native module resolves at all.~~ Done: core/TurboModuleProxy.h installs globalThis.__turboModuleProxy as an alias for nativeModuleProxy[name], so TurboModuleRegistry's first question succeeds and the gated fallback is never reached. Verified against 0.81's own JavaScript -- kino's unmodified bundle reaches Running \"main\" with no flag prepended.",
|
|
56
|
+
"Its Hermes builds `libhermes` rather than `hermesvm`, and React Native links `hermes-engine::libhermes`. Both handled already.",
|
|
57
|
+
"Its codegen has no -f flag, writes core artifacts inside the package, and exits non-zero after printing Done. Handled already.",
|
|
58
|
+
"Our own sources need version guards: TextAlignment has no Start or End, TextMeasureCacheKey has no pointScaleFactor, BaseTouch has no timeStamp. The first two are done.",
|
|
59
|
+
"GtkAnimationChoreographer has to be compiled out: there is no react/renderer/animationbackend, only react/renderer/animations.",
|
|
60
|
+
"ReactHost takes eleven parameters rather than twelve, takes TurboModuleManagerDelegates rather than TurboModuleProviders, and has no choreographer parameter. A second host construction path.",
|
|
61
|
+
"There is no websocket client. 0.81 ships IWebSocketClient with no implementation behind it, so no packager connection, no Fast Refresh, and no websockets for the app. Writing one is the largest piece."
|
|
62
|
+
],
|
|
63
|
+
"verdict": "A permanent second code path through the host, for the version that would also be the most degraded. Three of the six are now handled, and the three that remain are the structural ones: ReactHost's constructor, the missing websocket client, and the choreographer. Worth doing only for a specific app that needs it, and kino would still stop at Expo afterwards."
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|