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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useQuitRequest()` -- being asked before the application terminates.
|
|
3
|
+
*
|
|
4
|
+
* The same mechanism as `useCloseRequest()`, one level up, and it exists
|
|
5
|
+
* because the window half is not enough: an app can guard every window it
|
|
6
|
+
* owns and still lose the person's work to Cmd-Q. macOS routes quitting
|
|
7
|
+
* through `applicationShouldTerminate:` and asks no window whether it minds;
|
|
8
|
+
* a session ending on Linux or Windows does the same.
|
|
9
|
+
*
|
|
10
|
+
* ## Why a registration rather than a returned `false`
|
|
11
|
+
*
|
|
12
|
+
* Identical to the window case, and see src/closeRequest.ts for the long
|
|
13
|
+
* version: the handler is JavaScript on another thread and the system wants a
|
|
14
|
+
* synchronous yes or no, so the decision has to exist before the attempt.
|
|
15
|
+
* Registering is what makes it exist -- the host then refuses the quit and
|
|
16
|
+
* reports it, and the app quits itself when it is ready.
|
|
17
|
+
*
|
|
18
|
+
* ## One handler, not one per window
|
|
19
|
+
*
|
|
20
|
+
* Quitting is one event no matter how many windows are open, so this is not
|
|
21
|
+
* addressed to a window and the handler takes no id. An app that registers
|
|
22
|
+
* from two components gets asked twice and can quit twice, which is
|
|
23
|
+
* harmless -- the second `quit()` arrives at a process that is already
|
|
24
|
+
* going -- but is not the intended shape. Register it once, near the top.
|
|
25
|
+
*
|
|
26
|
+
* ## What each desktop means by "quit"
|
|
27
|
+
*
|
|
28
|
+
* On macOS this is Cmd-Q, the Quit menu item, and logging out. On Windows and
|
|
29
|
+
* Linux there is no application-level quit gesture to intercept -- an app ends
|
|
30
|
+
* when its last window closes, which is a window close and `useCloseRequest`'s
|
|
31
|
+
* business -- so what this catches there is the session ending: logout,
|
|
32
|
+
* shutdown, reboot.
|
|
33
|
+
*
|
|
34
|
+
* @format
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* What the handler is given: call it to let the quit through. It stops
|
|
38
|
+
* intercepting first, so the quit it then asks for is not refused by the
|
|
39
|
+
* registration that produced the question.
|
|
40
|
+
*/
|
|
41
|
+
export type AllowQuit = () => void;
|
|
42
|
+
export type QuitRequestHandler = (quit: AllowQuit) => void;
|
|
43
|
+
/** Whether this platform can be asked at all. */
|
|
44
|
+
export declare const isSupported: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Ask to be asked before the application quits.
|
|
47
|
+
*
|
|
48
|
+
* Pass null to stop asking. The handler is read through a ref, so an app that
|
|
49
|
+
* passes a new closure every render does not re-register -- what re-runs the
|
|
50
|
+
* effect is whether there is a handler at all, plus `deps`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useQuitRequest(handler: QuitRequestHandler | null | undefined, deps?: ReadonlyArray<unknown>): void;
|
|
53
|
+
/** Ends the application, asking nobody. */
|
|
54
|
+
export declare function quit(): void;
|
|
55
|
+
//# sourceMappingURL=quitRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quitRequest.d.ts","sourceRoot":"","sources":["../../src/quitRequest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAMH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;AAEnC,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;AAY3D,iDAAiD;AACjD,eAAO,MAAM,WAAW,SAAuC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,EAC9C,IAAI,GAAE,aAAa,CAAC,OAAO,CAAM,GAChC,IAAI,CAgCN;AAED,2CAA2C;AAC3C,wBAAgB,IAAI,IAAI,IAAI,CAE3B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `useQuitRequest()` -- being asked before the application terminates.
|
|
4
|
+
*
|
|
5
|
+
* The same mechanism as `useCloseRequest()`, one level up, and it exists
|
|
6
|
+
* because the window half is not enough: an app can guard every window it
|
|
7
|
+
* owns and still lose the person's work to Cmd-Q. macOS routes quitting
|
|
8
|
+
* through `applicationShouldTerminate:` and asks no window whether it minds;
|
|
9
|
+
* a session ending on Linux or Windows does the same.
|
|
10
|
+
*
|
|
11
|
+
* ## Why a registration rather than a returned `false`
|
|
12
|
+
*
|
|
13
|
+
* Identical to the window case, and see src/closeRequest.ts for the long
|
|
14
|
+
* version: the handler is JavaScript on another thread and the system wants a
|
|
15
|
+
* synchronous yes or no, so the decision has to exist before the attempt.
|
|
16
|
+
* Registering is what makes it exist -- the host then refuses the quit and
|
|
17
|
+
* reports it, and the app quits itself when it is ready.
|
|
18
|
+
*
|
|
19
|
+
* ## One handler, not one per window
|
|
20
|
+
*
|
|
21
|
+
* Quitting is one event no matter how many windows are open, so this is not
|
|
22
|
+
* addressed to a window and the handler takes no id. An app that registers
|
|
23
|
+
* from two components gets asked twice and can quit twice, which is
|
|
24
|
+
* harmless -- the second `quit()` arrives at a process that is already
|
|
25
|
+
* going -- but is not the intended shape. Register it once, near the top.
|
|
26
|
+
*
|
|
27
|
+
* ## What each desktop means by "quit"
|
|
28
|
+
*
|
|
29
|
+
* On macOS this is Cmd-Q, the Quit menu item, and logging out. On Windows and
|
|
30
|
+
* Linux there is no application-level quit gesture to intercept -- an app ends
|
|
31
|
+
* when its last window closes, which is a window close and `useCloseRequest`'s
|
|
32
|
+
* business -- so what this catches there is the session ending: logout,
|
|
33
|
+
* shutdown, reboot.
|
|
34
|
+
*
|
|
35
|
+
* @format
|
|
36
|
+
*/
|
|
37
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === undefined) k2 = k;
|
|
39
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
40
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
41
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
42
|
+
}
|
|
43
|
+
Object.defineProperty(o, k2, desc);
|
|
44
|
+
}) : (function(o, m, k, k2) {
|
|
45
|
+
if (k2 === undefined) k2 = k;
|
|
46
|
+
o[k2] = m[k];
|
|
47
|
+
}));
|
|
48
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
49
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
50
|
+
}) : function(o, v) {
|
|
51
|
+
o["default"] = v;
|
|
52
|
+
});
|
|
53
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
54
|
+
var ownKeys = function(o) {
|
|
55
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
56
|
+
var ar = [];
|
|
57
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
58
|
+
return ar;
|
|
59
|
+
};
|
|
60
|
+
return ownKeys(o);
|
|
61
|
+
};
|
|
62
|
+
return function (mod) {
|
|
63
|
+
if (mod && mod.__esModule) return mod;
|
|
64
|
+
var result = {};
|
|
65
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
66
|
+
__setModuleDefault(result, mod);
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
})();
|
|
70
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
|
+
exports.isSupported = void 0;
|
|
72
|
+
exports.useQuitRequest = useQuitRequest;
|
|
73
|
+
exports.quit = quit;
|
|
74
|
+
const React = __importStar(require("react"));
|
|
75
|
+
const react_native_1 = require("react-native");
|
|
76
|
+
const NativeWindows = react_native_1.TurboModuleRegistry.get('BasaltWindows');
|
|
77
|
+
// Must match kQuitRequestedEvent in native/core/WindowsModule.h.
|
|
78
|
+
const QUIT_REQUESTED_EVENT = 'basaltQuitRequested';
|
|
79
|
+
/** Whether this platform can be asked at all. */
|
|
80
|
+
exports.isSupported = NativeWindows?.interceptQuit != null;
|
|
81
|
+
/**
|
|
82
|
+
* Ask to be asked before the application quits.
|
|
83
|
+
*
|
|
84
|
+
* Pass null to stop asking. The handler is read through a ref, so an app that
|
|
85
|
+
* passes a new closure every render does not re-register -- what re-runs the
|
|
86
|
+
* effect is whether there is a handler at all, plus `deps`.
|
|
87
|
+
*/
|
|
88
|
+
function useQuitRequest(handler, deps = []) {
|
|
89
|
+
const handlerRef = React.useRef(handler);
|
|
90
|
+
handlerRef.current = handler;
|
|
91
|
+
const wanted = handler != null;
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
if (!exports.isSupported || !wanted) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// `isSupported` above is what proves these are here; it is computed at
|
|
97
|
+
// module scope from the same optional call, which the compiler cannot
|
|
98
|
+
// follow.
|
|
99
|
+
NativeWindows.interceptQuit(true);
|
|
100
|
+
const subscription = react_native_1.DeviceEventEmitter.addListener(QUIT_REQUESTED_EVENT, () => {
|
|
101
|
+
handlerRef.current?.(() => {
|
|
102
|
+
NativeWindows.interceptQuit(false);
|
|
103
|
+
NativeWindows.quit?.();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return () => {
|
|
107
|
+
// Stop intercepting on the way out, for the reason the window half
|
|
108
|
+
// does: an app that stopped listening and went on refusing every quit
|
|
109
|
+
// would be a process that cannot be quit at all, which is worse than
|
|
110
|
+
// the bug this prevents.
|
|
111
|
+
NativeWindows.interceptQuit(false);
|
|
112
|
+
subscription.remove();
|
|
113
|
+
};
|
|
114
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
115
|
+
}, [wanted, ...deps]);
|
|
116
|
+
}
|
|
117
|
+
/** Ends the application, asking nobody. */
|
|
118
|
+
function quit() {
|
|
119
|
+
NativeWindows?.quit?.();
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=quitRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quitRequest.js","sourceRoot":"","sources":["../../src/quitRequest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCH,wCAmCC;AAGD,oBAEC;AAzED,6CAA+B;AAE/B,+CAAqE;AAgBrE,MAAM,aAAa,GAAG,kCAAmB,CAAC,GAAG,CAAsB,eAAe,CAAC,CAAC;AAEpF,iEAAiE;AACjE,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEnD,iDAAiD;AACpC,QAAA,WAAW,GAAG,aAAa,EAAE,aAAa,IAAI,IAAI,CAAC;AAEhE;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,OAA8C,EAC9C,OAA+B,EAAE;IAEjC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,MAAM,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC;IAE/B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,mBAAW,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,uEAAuE;QACvE,sEAAsE;QACtE,UAAU;QACV,aAAc,CAAC,aAAc,CAAC,IAAI,CAAC,CAAC;QAEpC,MAAM,YAAY,GAAG,iCAAkB,CAAC,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE;YAC7E,UAAU,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE;gBACxB,aAAc,CAAC,aAAc,CAAC,KAAK,CAAC,CAAC;gBACrC,aAAc,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,mEAAmE;YACnE,sEAAsE;YACtE,qEAAqE;YACrE,yBAAyB;YACzB,aAAc,CAAC,aAAc,CAAC,KAAK,CAAC,CAAC;YACrC,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,2CAA2C;AAC3C,SAAgB,IAAI;IAClB,aAAa,EAAE,IAAI,EAAE,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the files the build put beside this application are.
|
|
3
|
+
*
|
|
4
|
+
* `Foo.app/Contents/Resources` on macOS, and beside the executable on Linux and
|
|
5
|
+
* Windows, which have no separate resources directory. A development run, where
|
|
6
|
+
* the host starts out of a build directory, answers that directory.
|
|
7
|
+
*
|
|
8
|
+
* Here rather than worked out by each app: this project's packager is what
|
|
9
|
+
* decides the layout, so an app deriving it would be an app that has to know
|
|
10
|
+
* the shape of a bundle it did not build. See native/core/AppPaths.h.
|
|
11
|
+
*
|
|
12
|
+
* Empty when the running executable's path cannot be determined, which no
|
|
13
|
+
* supported desktop does.
|
|
14
|
+
*
|
|
15
|
+
* @format
|
|
16
|
+
*/
|
|
17
|
+
export declare function resourcePath(): string;
|
|
18
|
+
//# sourceMappingURL=resourcePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePath.d.ts","sourceRoot":"","sources":["../../src/resourcePath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,wBAAgB,YAAY,IAAI,MAAM,CAOrC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Where the files the build put beside this application are.
|
|
4
|
+
*
|
|
5
|
+
* `Foo.app/Contents/Resources` on macOS, and beside the executable on Linux and
|
|
6
|
+
* Windows, which have no separate resources directory. A development run, where
|
|
7
|
+
* the host starts out of a build directory, answers that directory.
|
|
8
|
+
*
|
|
9
|
+
* Here rather than worked out by each app: this project's packager is what
|
|
10
|
+
* decides the layout, so an app deriving it would be an app that has to know
|
|
11
|
+
* the shape of a bundle it did not build. See native/core/AppPaths.h.
|
|
12
|
+
*
|
|
13
|
+
* Empty when the running executable's path cannot be determined, which no
|
|
14
|
+
* supported desktop does.
|
|
15
|
+
*
|
|
16
|
+
* @format
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.resourcePath = resourcePath;
|
|
20
|
+
const react_native_1 = require("react-native");
|
|
21
|
+
const NativeApp = react_native_1.TurboModuleRegistry.get('BasaltApp');
|
|
22
|
+
let cached = null;
|
|
23
|
+
function resourcePath() {
|
|
24
|
+
// Cached because it cannot change while the process runs, and an app reading
|
|
25
|
+
// it per file would otherwise cross the bridge each time.
|
|
26
|
+
if (cached == null) {
|
|
27
|
+
cached = NativeApp?.getResourcePath() ?? '';
|
|
28
|
+
}
|
|
29
|
+
return cached;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=resourcePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePath.js","sourceRoot":"","sources":["../../src/resourcePath.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAaH,oCAOC;AAlBD,+CAAiD;AAOjD,MAAM,SAAS,GAAG,kCAAmB,CAAC,GAAG,CAAkB,WAAW,CAAC,CAAC;AAExE,IAAI,MAAM,GAAkB,IAAI,CAAC;AAEjC,SAAgB,YAAY;IAC1B,6EAA6E;IAC7E,0DAA0D;IAC1D,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,GAAG,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the platform actually delivered for a `blob` response, and how to make a
|
|
3
|
+
* Blob out of it.
|
|
4
|
+
*
|
|
5
|
+
* `src/overrides/setUpXHR.ts` asks for `arraybuffer` when JavaScript asked for
|
|
6
|
+
* `blob`, because React Native's XHR turns that into a native request for
|
|
7
|
+
* `base64` -- and base64 is the only response encoding ReactCxxPlatform has that
|
|
8
|
+
* can carry arbitrary bytes through a JavaScript string intact.
|
|
9
|
+
*
|
|
10
|
+
* **Except that it only encodes on some versions.** `encodeResponseBody` is a
|
|
11
|
+
* fix that landed in ReactCxxPlatform's NetworkingModule after 0.86; before it,
|
|
12
|
+
* `didReceiveNetworkData` passes the body through whatever was asked for. And
|
|
13
|
+
* ReactCxxPlatform is fetched at the app's exact React Native version -- see
|
|
14
|
+
* native/bootstrap.sh for why one vendored copy cannot serve several -- so both
|
|
15
|
+
* behaviours are live at once across supported versions, and neither the app nor
|
|
16
|
+
* this package chooses which.
|
|
17
|
+
*
|
|
18
|
+
* Handing a raw body to `BlobModule.createFromParts` as `base64` is what the
|
|
19
|
+
* failure looked like: the decoder skips the characters that are not in the
|
|
20
|
+
* alphabet and returns whatever the rest happens to mean, so a 98-byte JSON body
|
|
21
|
+
* became one byte, or none. `fetch(...).json()` then failed with "JSON Parse
|
|
22
|
+
* error: Unexpected character: v" -- a complaint about a byte that appears
|
|
23
|
+
* nowhere in the response, which is a long way from the cause. Found in kino,
|
|
24
|
+
* where every call to its daemon failed this way.
|
|
25
|
+
*
|
|
26
|
+
* So the delivered string is examined rather than assumed.
|
|
27
|
+
*
|
|
28
|
+
* **One observation settles it.** Whether the platform encodes is a property of
|
|
29
|
+
* the build, not of a response, so it is learned rather than re-decided. A body
|
|
30
|
+
* that *cannot* be base64 -- one containing a character outside the alphabet, or
|
|
31
|
+
* a length that is not a multiple of four -- proves the platform does not
|
|
32
|
+
* encode, and that verdict holds for every response afterwards. A platform that
|
|
33
|
+
* does encode never produces such a body, so the verdict can only ever be
|
|
34
|
+
* reached correctly.
|
|
35
|
+
*
|
|
36
|
+
* **Content-Length settles it outright, when there is one.** The delivered
|
|
37
|
+
* string is either the body or its base64, and those have different lengths, so
|
|
38
|
+
* a byte count from the server picks one. That is exact and needs nothing
|
|
39
|
+
* learned. It is not always available -- a chunked response has no
|
|
40
|
+
* Content-Length, and kino's daemon sends every response chunked -- which is why
|
|
41
|
+
* it is a shortcut rather than the whole answer.
|
|
42
|
+
*
|
|
43
|
+
* **The window where it can still be wrong, stated.** With no Content-Length and
|
|
44
|
+
* nothing yet learned, a body that looks like canonical base64 is taken as
|
|
45
|
+
* base64. Most bodies are decisive: any JSON object or array contains `{`, `"`
|
|
46
|
+
* or `,`. A few are not -- `null`, `true` and `1234` are all four characters
|
|
47
|
+
* from the alphabet -- so a non-encoding platform whose *first* blob response is
|
|
48
|
+
* chunked *and* one of those is read wrongly, once.
|
|
49
|
+
*
|
|
50
|
+
/** One part for `BlobModule.createFromParts`, with the size the Blob should claim. */
|
|
51
|
+
export interface ResponseBlobPart {
|
|
52
|
+
part: {
|
|
53
|
+
data: string;
|
|
54
|
+
type: 'base64' | 'string';
|
|
55
|
+
};
|
|
56
|
+
size: number;
|
|
57
|
+
/** False when the platform did not encode, which the caller reports once. */
|
|
58
|
+
encoded: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Canonical base64: four-character groups from the alphabet, with at most two
|
|
62
|
+
* `=` and only at the end.
|
|
63
|
+
*/
|
|
64
|
+
export declare function looksLikeBase64(value: string): boolean;
|
|
65
|
+
/** The number of bytes `value` is as UTF-8, which is what a Blob's size means. */
|
|
66
|
+
export declare function utf8Length(value: string): number;
|
|
67
|
+
/** The decoded length of canonical base64, from its length and padding alone. */
|
|
68
|
+
export declare function base64Length(encoded: string): number;
|
|
69
|
+
/**
|
|
70
|
+
* A reader that remembers what it has learned about this platform.
|
|
71
|
+
*
|
|
72
|
+
* One per process in the override; a factory rather than module state so that a
|
|
73
|
+
* test can start from not knowing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createResponseBodyReader(): (delivered: string, contentLength?: number | null) => ResponseBlobPart;
|
|
76
|
+
//# sourceMappingURL=responseBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseBody.d.ts","sourceRoot":"","sources":["../../src/responseBody.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sFAiDsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAA;KAAC,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKtD;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBhD;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,CAC1C,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,gBAAgB,CA8CpB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.looksLikeBase64 = looksLikeBase64;
|
|
4
|
+
exports.utf8Length = utf8Length;
|
|
5
|
+
exports.base64Length = base64Length;
|
|
6
|
+
exports.createResponseBodyReader = createResponseBodyReader;
|
|
7
|
+
/**
|
|
8
|
+
* Canonical base64: four-character groups from the alphabet, with at most two
|
|
9
|
+
* `=` and only at the end.
|
|
10
|
+
*/
|
|
11
|
+
function looksLikeBase64(value) {
|
|
12
|
+
if (value.length === 0 || value.length % 4 !== 0) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return /^[A-Za-z0-9+/]+={0,2}$/.test(value);
|
|
16
|
+
}
|
|
17
|
+
/** The number of bytes `value` is as UTF-8, which is what a Blob's size means. */
|
|
18
|
+
function utf8Length(value) {
|
|
19
|
+
let bytes = 0;
|
|
20
|
+
for (let i = 0; i < value.length; i++) {
|
|
21
|
+
const code = value.charCodeAt(i);
|
|
22
|
+
if (code < 0x80) {
|
|
23
|
+
bytes += 1;
|
|
24
|
+
}
|
|
25
|
+
else if (code < 0x800) {
|
|
26
|
+
bytes += 2;
|
|
27
|
+
}
|
|
28
|
+
else if (code >= 0xd800 && code <= 0xdbff) {
|
|
29
|
+
// A surrogate pair is one character of four bytes; skip its low half.
|
|
30
|
+
bytes += 4;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
bytes += 3;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return bytes;
|
|
38
|
+
}
|
|
39
|
+
/** The decoded length of canonical base64, from its length and padding alone. */
|
|
40
|
+
function base64Length(encoded) {
|
|
41
|
+
const padding = encoded.endsWith('==') ? 2 : encoded.endsWith('=') ? 1 : 0;
|
|
42
|
+
return Math.max(0, (encoded.length / 4) * 3 - padding);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A reader that remembers what it has learned about this platform.
|
|
46
|
+
*
|
|
47
|
+
* One per process in the override; a factory rather than module state so that a
|
|
48
|
+
* test can start from not knowing.
|
|
49
|
+
*/
|
|
50
|
+
function createResponseBodyReader() {
|
|
51
|
+
// null while nothing decisive has been seen.
|
|
52
|
+
let platformEncodes = null;
|
|
53
|
+
return function read(delivered, contentLength) {
|
|
54
|
+
const couldBeBase64 = looksLikeBase64(delivered);
|
|
55
|
+
if (!couldBeBase64 && delivered.length > 0) {
|
|
56
|
+
// Decisive: a platform that encodes could not have produced this.
|
|
57
|
+
platformEncodes = false;
|
|
58
|
+
}
|
|
59
|
+
// A byte count from the server, where there is one, decides it outright --
|
|
60
|
+
// and teaches the same lesson for the responses that arrive without one.
|
|
61
|
+
//
|
|
62
|
+
// Never from an empty body: base64 of no bytes is the empty string, so the
|
|
63
|
+
// two possibilities are identical and there is nothing to learn. Worth
|
|
64
|
+
// stating because `looksLikeBase64('')` is false, which would otherwise read
|
|
65
|
+
// as "this platform does not encode".
|
|
66
|
+
if (typeof contentLength === 'number' && contentLength >= 0 && delivered.length > 0) {
|
|
67
|
+
const rawFits = utf8Length(delivered) === contentLength;
|
|
68
|
+
const base64Fits = couldBeBase64 && base64Length(delivered) === contentLength;
|
|
69
|
+
// Only when exactly one fits. An empty body fits both, and says nothing.
|
|
70
|
+
if (rawFits !== base64Fits) {
|
|
71
|
+
platformEncodes = base64Fits;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Unknown counts as encoding, because on a platform that does, every body
|
|
75
|
+
// looks like base64 and nothing decisive ever arrives.
|
|
76
|
+
const asBase64 = couldBeBase64 && platformEncodes !== false;
|
|
77
|
+
if (asBase64) {
|
|
78
|
+
return {
|
|
79
|
+
part: { data: delivered, type: 'base64' },
|
|
80
|
+
size: base64Length(delivered),
|
|
81
|
+
encoded: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// The body itself. Correct for a text body, which is what almost every
|
|
85
|
+
// `fetch(...).json()` is; a binary body was already damaged before it
|
|
86
|
+
// reached here, because it crossed into JavaScript as a string.
|
|
87
|
+
return {
|
|
88
|
+
part: { data: delivered, type: 'string' },
|
|
89
|
+
size: utf8Length(delivered),
|
|
90
|
+
encoded: false,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=responseBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseBody.js","sourceRoot":"","sources":["../../src/responseBody.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The response headers, in the shape React Native's XMLHttpRequest expects.
|
|
3
|
+
*
|
|
4
|
+
* ReactCxxPlatform's NetworkingModule holds them as
|
|
5
|
+
* `std::vector<std::pair<std::string, std::string>>` and bridges that straight
|
|
6
|
+
* to JavaScript, which makes an array of two-element arrays:
|
|
7
|
+
*
|
|
8
|
+
* [["Content-Type", "application/json"], ["Content-Length", "580"]]
|
|
9
|
+
*
|
|
10
|
+
* React Native's XHR expects an object. `setResponseHeaders` does
|
|
11
|
+
* `Object.keys(headers)` to build its lower-cased lookup, so an array gives it
|
|
12
|
+
* the keys "0", "1", "2" and values that are arrays. Nothing throws: the headers
|
|
13
|
+
* are all there, correctly, and every lookup misses.
|
|
14
|
+
*
|
|
15
|
+
* What that looked like: `getResponseHeader('content-type')` null on a response
|
|
16
|
+
* that plainly had one, `fetch(...).headers.get(...)` null for everything, and
|
|
17
|
+
* `getAllResponseHeaders()` returning lines like `0: Server,BaseHTTP/0.6`. So a
|
|
18
|
+
* `Response` carried no content type, which is also why a Blob built from one
|
|
19
|
+
* had `type: ''`.
|
|
20
|
+
*
|
|
21
|
+
* Converted here rather than reported, because nothing about it is ambiguous and
|
|
22
|
+
* no app can act on it.
|
|
23
|
+
*
|
|
24
|
+
* **Duplicates are joined with ", "**, which is what the XHR specification says
|
|
25
|
+
* `getResponseHeader` returns for a header that appeared more than once, and
|
|
26
|
+
* what iOS and Android already hand over -- they build the object natively. The
|
|
27
|
+
* one header this is wrong for is `Set-Cookie`, which may not be joined; it is
|
|
28
|
+
* also the one header XHR refuses to return at all, so nothing here can reach
|
|
29
|
+
* it either way.
|
|
30
|
+
*/
|
|
31
|
+
export type DeliveredHeaders = ReadonlyArray<readonly [string, string]> | Record<string, string>;
|
|
32
|
+
/** True for the array-of-pairs shape ReactCxxPlatform sends. */
|
|
33
|
+
export declare function isHeaderPairs(value: unknown): value is ReadonlyArray<readonly [string, string]>;
|
|
34
|
+
/**
|
|
35
|
+
* An object of header names to values. Anything already an object is passed
|
|
36
|
+
* through untouched, so a ReactCxxPlatform that starts sending one needs no
|
|
37
|
+
* change here.
|
|
38
|
+
*/
|
|
39
|
+
export declare function headersToObject(delivered: unknown): Record<string, string> | null;
|
|
40
|
+
//# sourceMappingURL=responseHeaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseHeaders.d.ts","sourceRoot":"","sources":["../../src/responseHeaders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjG,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAgCjF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The response headers, in the shape React Native's XMLHttpRequest expects.
|
|
4
|
+
*
|
|
5
|
+
* ReactCxxPlatform's NetworkingModule holds them as
|
|
6
|
+
* `std::vector<std::pair<std::string, std::string>>` and bridges that straight
|
|
7
|
+
* to JavaScript, which makes an array of two-element arrays:
|
|
8
|
+
*
|
|
9
|
+
* [["Content-Type", "application/json"], ["Content-Length", "580"]]
|
|
10
|
+
*
|
|
11
|
+
* React Native's XHR expects an object. `setResponseHeaders` does
|
|
12
|
+
* `Object.keys(headers)` to build its lower-cased lookup, so an array gives it
|
|
13
|
+
* the keys "0", "1", "2" and values that are arrays. Nothing throws: the headers
|
|
14
|
+
* are all there, correctly, and every lookup misses.
|
|
15
|
+
*
|
|
16
|
+
* What that looked like: `getResponseHeader('content-type')` null on a response
|
|
17
|
+
* that plainly had one, `fetch(...).headers.get(...)` null for everything, and
|
|
18
|
+
* `getAllResponseHeaders()` returning lines like `0: Server,BaseHTTP/0.6`. So a
|
|
19
|
+
* `Response` carried no content type, which is also why a Blob built from one
|
|
20
|
+
* had `type: ''`.
|
|
21
|
+
*
|
|
22
|
+
* Converted here rather than reported, because nothing about it is ambiguous and
|
|
23
|
+
* no app can act on it.
|
|
24
|
+
*
|
|
25
|
+
* **Duplicates are joined with ", "**, which is what the XHR specification says
|
|
26
|
+
* `getResponseHeader` returns for a header that appeared more than once, and
|
|
27
|
+
* what iOS and Android already hand over -- they build the object natively. The
|
|
28
|
+
* one header this is wrong for is `Set-Cookie`, which may not be joined; it is
|
|
29
|
+
* also the one header XHR refuses to return at all, so nothing here can reach
|
|
30
|
+
* it either way.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.isHeaderPairs = isHeaderPairs;
|
|
34
|
+
exports.headersToObject = headersToObject;
|
|
35
|
+
/** True for the array-of-pairs shape ReactCxxPlatform sends. */
|
|
36
|
+
function isHeaderPairs(value) {
|
|
37
|
+
return Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An object of header names to values. Anything already an object is passed
|
|
41
|
+
* through untouched, so a ReactCxxPlatform that starts sending one needs no
|
|
42
|
+
* change here.
|
|
43
|
+
*/
|
|
44
|
+
function headersToObject(delivered) {
|
|
45
|
+
if (delivered == null) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!isHeaderPairs(delivered)) {
|
|
49
|
+
return delivered;
|
|
50
|
+
}
|
|
51
|
+
const headers = {};
|
|
52
|
+
for (const pair of delivered) {
|
|
53
|
+
// Defensive about the pair rather than the array: this is parsing something
|
|
54
|
+
// that crossed a bridge, and a malformed entry should be skipped rather than
|
|
55
|
+
// become the string "undefined".
|
|
56
|
+
if (!Array.isArray(pair) || pair.length < 2) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const [name, value] = pair;
|
|
60
|
+
if (typeof name !== 'string' || typeof value !== 'string') {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Case-insensitively the same header, so that a server sending `Vary` and
|
|
64
|
+
// `vary` produces one entry rather than two that shadow each other.
|
|
65
|
+
const existing = Object.keys(headers).find(key => key.toLowerCase() === name.toLowerCase());
|
|
66
|
+
if (existing === undefined) {
|
|
67
|
+
headers[name] = value;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
headers[existing] = `${headers[existing]}, ${value}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return headers;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=responseHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseHeaders.js","sourceRoot":"","sources":["../../src/responseHeaders.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAKH,sCAEC;AAOD,0CAgCC;AA1CD,gEAAgE;AAChE,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,SAAkB;IAChD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,SAAmC,CAAC;IAC7C,CAAC;IAED,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,4EAA4E;QAC5E,6EAA6E;QAC7E,iCAAiC;QACjC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC1D,SAAS;QACX,CAAC;QACD,0EAA0E;QAC1E,oEAAoE;QACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CACxC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAChD,CAAC;QACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;QACvD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The title bar requests currently mounted, and what they add up to.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from TitleBar.tsx, with no React Native in it, so that it can be
|
|
5
|
+
* tested with nothing but Node -- this is the part with rules in it.
|
|
6
|
+
*
|
|
7
|
+
* Several screens may each ask for something, as they do of <StatusBar>, and
|
|
8
|
+
* the most recently mounted request wins. But key by key: a screen that only
|
|
9
|
+
* sets a title does not reset the colour an app shell underneath it set, and
|
|
10
|
+
* when it unmounts the shell's title comes back.
|
|
11
|
+
*
|
|
12
|
+
* @format
|
|
13
|
+
*/
|
|
14
|
+
export declare const TITLE_BAR_KEYS: readonly ["title", "style", "backgroundColor", "textColor", "borderColor"];
|
|
15
|
+
export type TitleBarKey = (typeof TITLE_BAR_KEYS)[number];
|
|
16
|
+
/** The system's title bar, or none and the app draws its own. */
|
|
17
|
+
export type TitleBarStyle = 'native' | 'hidden';
|
|
18
|
+
/**
|
|
19
|
+
* A colour as React Native accepts one -- a string, or the number
|
|
20
|
+
* `processColor` produces. Deliberately not React Native's `ColorValue`: this
|
|
21
|
+
* file has no React Native in it, which is what lets it be tested under plain
|
|
22
|
+
* Node.
|
|
23
|
+
*/
|
|
24
|
+
export type TitleBarColor = string | number | null;
|
|
25
|
+
export type TitleBarOptions = {
|
|
26
|
+
title?: string | null;
|
|
27
|
+
style?: TitleBarStyle;
|
|
28
|
+
backgroundColor?: TitleBarColor;
|
|
29
|
+
textColor?: TitleBarColor;
|
|
30
|
+
borderColor?: TitleBarColor;
|
|
31
|
+
};
|
|
32
|
+
/** What a stack of requests resolves to: the same keys, none of them required. */
|
|
33
|
+
export type TitleBarRequest = TitleBarOptions;
|
|
34
|
+
export type TitleBarStack = {
|
|
35
|
+
push(options?: TitleBarOptions | null): number;
|
|
36
|
+
update(id: number, options?: TitleBarOptions | null): void;
|
|
37
|
+
remove(id: number): void;
|
|
38
|
+
resolve(): TitleBarRequest;
|
|
39
|
+
readonly size: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function createTitleBarStack(): TitleBarStack;
|
|
42
|
+
export declare function sameRequest(a?: TitleBarRequest | null, b?: TitleBarRequest | null): boolean;
|
|
43
|
+
//# sourceMappingURL=titleBarState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"titleBarState.d.ts","sourceRoot":"","sources":["../../src/titleBarState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,cAAc,4EAMjB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;IAC3D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,IAAI,eAAe,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAeF,wBAAgB,mBAAmB,IAAI,aAAa,CAsCnD;AAID,wBAAgB,WAAW,CACzB,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,EAC1B,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,GACzB,OAAO,CAET"}
|