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.
Files changed (325) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cli/basalt.d.ts +3 -0
  3. package/dist/cli/basalt.d.ts.map +1 -0
  4. package/dist/cli/basalt.js +47 -0
  5. package/dist/cli/basalt.js.map +1 -0
  6. package/dist/cli/bundle-cli.d.ts +12 -0
  7. package/dist/cli/bundle-cli.d.ts.map +1 -0
  8. package/dist/cli/bundle-cli.js +124 -0
  9. package/dist/cli/bundle-cli.js.map +1 -0
  10. package/dist/cli/bundleWithAssets.d.ts +79 -0
  11. package/dist/cli/bundleWithAssets.d.ts.map +1 -0
  12. package/dist/cli/bundleWithAssets.js +198 -0
  13. package/dist/cli/bundleWithAssets.js.map +1 -0
  14. package/dist/cli/desktop.d.ts +339 -0
  15. package/dist/cli/desktop.d.ts.map +1 -0
  16. package/dist/cli/desktop.js +1029 -0
  17. package/dist/cli/desktop.js.map +1 -0
  18. package/dist/cli/doctor.d.ts +31 -0
  19. package/dist/cli/doctor.d.ts.map +1 -0
  20. package/dist/cli/doctor.js +283 -0
  21. package/dist/cli/doctor.js.map +1 -0
  22. package/dist/cli/init.d.ts +77 -0
  23. package/dist/cli/init.d.ts.map +1 -0
  24. package/dist/cli/init.js +442 -0
  25. package/dist/cli/init.js.map +1 -0
  26. package/dist/cli/metro.d.ts +49 -0
  27. package/dist/cli/metro.d.ts.map +1 -0
  28. package/dist/cli/metro.js +148 -0
  29. package/dist/cli/metro.js.map +1 -0
  30. package/dist/cli/packageApp.d.ts +102 -0
  31. package/dist/cli/packageApp.d.ts.map +1 -0
  32. package/dist/cli/packageApp.js +319 -0
  33. package/dist/cli/packageApp.js.map +1 -0
  34. package/dist/cli/steps.d.ts +34 -0
  35. package/dist/cli/steps.d.ts.map +1 -0
  36. package/dist/cli/steps.js +53 -0
  37. package/dist/cli/steps.js.map +1 -0
  38. package/dist/metro-config.d.ts +168 -0
  39. package/dist/metro-config.d.ts.map +1 -0
  40. package/dist/metro-config.js +671 -0
  41. package/dist/metro-config.js.map +1 -0
  42. package/dist/react-native.config.d.ts +7 -0
  43. package/dist/react-native.config.d.ts.map +1 -0
  44. package/dist/react-native.config.js +80 -0
  45. package/dist/react-native.config.js.map +1 -0
  46. package/dist/src/DragSource.d.ts +52 -0
  47. package/dist/src/DragSource.d.ts.map +1 -0
  48. package/dist/src/DragSource.js +97 -0
  49. package/dist/src/DragSource.js.map +1 -0
  50. package/dist/src/DropTarget.d.ts +58 -0
  51. package/dist/src/DropTarget.d.ts.map +1 -0
  52. package/dist/src/DropTarget.js +131 -0
  53. package/dist/src/DropTarget.js.map +1 -0
  54. package/dist/src/KeyHandler.d.ts +57 -0
  55. package/dist/src/KeyHandler.d.ts.map +1 -0
  56. package/dist/src/KeyHandler.js +48 -0
  57. package/dist/src/KeyHandler.js.map +1 -0
  58. package/dist/src/Menu.d.ts +72 -0
  59. package/dist/src/Menu.d.ts.map +1 -0
  60. package/dist/src/Menu.js +179 -0
  61. package/dist/src/Menu.js.map +1 -0
  62. package/dist/src/TitleBar.d.ts +75 -0
  63. package/dist/src/TitleBar.d.ts.map +1 -0
  64. package/dist/src/TitleBar.js +236 -0
  65. package/dist/src/TitleBar.js.map +1 -0
  66. package/dist/src/Window.d.ts +87 -0
  67. package/dist/src/Window.d.ts.map +1 -0
  68. package/dist/src/Window.js +248 -0
  69. package/dist/src/Window.js.map +1 -0
  70. package/dist/src/closeRequest.d.ts +55 -0
  71. package/dist/src/closeRequest.d.ts.map +1 -0
  72. package/dist/src/closeRequest.js +134 -0
  73. package/dist/src/closeRequest.js.map +1 -0
  74. package/dist/src/index.d.ts +45 -0
  75. package/dist/src/index.d.ts.map +1 -0
  76. package/dist/src/index.js +92 -0
  77. package/dist/src/index.js.map +1 -0
  78. package/dist/src/overrides/Alert.d.ts +69 -0
  79. package/dist/src/overrides/Alert.d.ts.map +1 -0
  80. package/dist/src/overrides/Alert.js +112 -0
  81. package/dist/src/overrides/Alert.js.map +1 -0
  82. package/dist/src/overrides/BaseViewConfig.d.ts +28 -0
  83. package/dist/src/overrides/BaseViewConfig.d.ts.map +1 -0
  84. package/dist/src/overrides/BaseViewConfig.js +72 -0
  85. package/dist/src/overrides/BaseViewConfig.js.map +1 -0
  86. package/dist/src/overrides/Platform.linux.d.ts +10 -0
  87. package/dist/src/overrides/Platform.linux.d.ts.map +1 -0
  88. package/dist/src/overrides/Platform.linux.js +15 -0
  89. package/dist/src/overrides/Platform.linux.js.map +1 -0
  90. package/dist/src/overrides/Platform.macos.d.ts +10 -0
  91. package/dist/src/overrides/Platform.macos.d.ts.map +1 -0
  92. package/dist/src/overrides/Platform.macos.js +15 -0
  93. package/dist/src/overrides/Platform.macos.js.map +1 -0
  94. package/dist/src/overrides/Platform.windows.d.ts +10 -0
  95. package/dist/src/overrides/Platform.windows.d.ts.map +1 -0
  96. package/dist/src/overrides/Platform.windows.js +15 -0
  97. package/dist/src/overrides/Platform.windows.js.map +1 -0
  98. package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts +24 -0
  99. package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts.map +1 -0
  100. package/dist/src/overrides/ReactDevToolsSettingsManager.js +30 -0
  101. package/dist/src/overrides/ReactDevToolsSettingsManager.js.map +1 -0
  102. package/dist/src/overrides/RefreshControl.d.ts +52 -0
  103. package/dist/src/overrides/RefreshControl.d.ts.map +1 -0
  104. package/dist/src/overrides/RefreshControl.js +92 -0
  105. package/dist/src/overrides/RefreshControl.js.map +1 -0
  106. package/dist/src/overrides/ScrollView.d.ts +39 -0
  107. package/dist/src/overrides/ScrollView.d.ts.map +1 -0
  108. package/dist/src/overrides/ScrollView.js +59 -0
  109. package/dist/src/overrides/ScrollView.js.map +1 -0
  110. package/dist/src/overrides/Share.d.ts +96 -0
  111. package/dist/src/overrides/Share.d.ts.map +1 -0
  112. package/dist/src/overrides/Share.js +97 -0
  113. package/dist/src/overrides/Share.js.map +1 -0
  114. package/dist/src/overrides/TextInput.d.ts +81 -0
  115. package/dist/src/overrides/TextInput.d.ts.map +1 -0
  116. package/dist/src/overrides/TextInput.js +213 -0
  117. package/dist/src/overrides/TextInput.js.map +1 -0
  118. package/dist/src/overrides/View.d.ts +36 -0
  119. package/dist/src/overrides/View.d.ts.map +1 -0
  120. package/dist/src/overrides/View.js +99 -0
  121. package/dist/src/overrides/View.js.map +1 -0
  122. package/dist/src/overrides/createPlatform.d.ts +32 -0
  123. package/dist/src/overrides/createPlatform.d.ts.map +1 -0
  124. package/dist/src/overrides/createPlatform.js +84 -0
  125. package/dist/src/overrides/createPlatform.js.map +1 -0
  126. package/dist/src/overrides/setUpDeveloperTools.d.ts +28 -0
  127. package/dist/src/overrides/setUpDeveloperTools.d.ts.map +1 -0
  128. package/dist/src/overrides/setUpDeveloperTools.js +84 -0
  129. package/dist/src/overrides/setUpDeveloperTools.js.map +1 -0
  130. package/dist/src/overrides/setUpXHR.d.ts +46 -0
  131. package/dist/src/overrides/setUpXHR.d.ts.map +1 -0
  132. package/dist/src/overrides/setUpXHR.js +236 -0
  133. package/dist/src/overrides/setUpXHR.js.map +1 -0
  134. package/dist/src/quitRequest.d.ts +55 -0
  135. package/dist/src/quitRequest.d.ts.map +1 -0
  136. package/dist/src/quitRequest.js +121 -0
  137. package/dist/src/quitRequest.js.map +1 -0
  138. package/dist/src/resourcePath.d.ts +18 -0
  139. package/dist/src/resourcePath.d.ts.map +1 -0
  140. package/dist/src/resourcePath.js +31 -0
  141. package/dist/src/resourcePath.js.map +1 -0
  142. package/dist/src/responseBody.d.ts +76 -0
  143. package/dist/src/responseBody.d.ts.map +1 -0
  144. package/dist/src/responseBody.js +94 -0
  145. package/dist/src/responseBody.js.map +1 -0
  146. package/dist/src/responseHeaders.d.ts +40 -0
  147. package/dist/src/responseHeaders.d.ts.map +1 -0
  148. package/dist/src/responseHeaders.js +75 -0
  149. package/dist/src/responseHeaders.js.map +1 -0
  150. package/dist/src/titleBarState.d.ts +43 -0
  151. package/dist/src/titleBarState.d.ts.map +1 -0
  152. package/dist/src/titleBarState.js +77 -0
  153. package/dist/src/titleBarState.js.map +1 -0
  154. package/dist/src/useContextMenu.d.ts +113 -0
  155. package/dist/src/useContextMenu.d.ts.map +1 -0
  156. package/dist/src/useContextMenu.js +109 -0
  157. package/dist/src/useContextMenu.js.map +1 -0
  158. package/dist/src/useDialog.d.ts +98 -0
  159. package/dist/src/useDialog.d.ts.map +1 -0
  160. package/dist/src/useDialog.js +112 -0
  161. package/dist/src/useDialog.js.map +1 -0
  162. package/dist/src/useDisplays.d.ts +70 -0
  163. package/dist/src/useDisplays.d.ts.map +1 -0
  164. package/dist/src/useDisplays.js +118 -0
  165. package/dist/src/useDisplays.js.map +1 -0
  166. package/dist/src/useHandledKeys.d.ts +38 -0
  167. package/dist/src/useHandledKeys.d.ts.map +1 -0
  168. package/dist/src/useHandledKeys.js +70 -0
  169. package/dist/src/useHandledKeys.js.map +1 -0
  170. package/dist/src/useWindow.d.ts +140 -0
  171. package/dist/src/useWindow.d.ts.map +1 -0
  172. package/dist/src/useWindow.js +233 -0
  173. package/dist/src/useWindow.js.map +1 -0
  174. package/dist/tsconfig.tsbuildinfo +1 -0
  175. package/native/CMakeLists.txt +355 -0
  176. package/native/bootstrap.sh +613 -0
  177. package/native/cmake/CompilerFlags.cmake +49 -0
  178. package/native/cmake/Expo.cmake +125 -0
  179. package/native/cmake/ReactNativeCore.cmake +612 -0
  180. package/native/cmake/Reanimated.cmake +108 -0
  181. package/native/cmake/Skia.cmake +379 -0
  182. package/native/cmake/ThirdParty.cmake +290 -0
  183. package/native/cmake/Worklets.cmake +67 -0
  184. package/native/cmake/codegen/CMakeLists.txt +32 -0
  185. package/native/core/AppIdentity.cpp +85 -0
  186. package/native/core/AppIdentity.h +59 -0
  187. package/native/core/AppPaths.cpp +96 -0
  188. package/native/core/AppPaths.h +53 -0
  189. package/native/core/AppearanceModule.cpp +60 -0
  190. package/native/core/AppearanceModule.h +40 -0
  191. package/native/core/Backface.h +59 -0
  192. package/native/core/BlobModule.cpp +283 -0
  193. package/native/core/BlobModule.h +76 -0
  194. package/native/core/BlobRegistry.cpp +75 -0
  195. package/native/core/BlobRegistry.h +44 -0
  196. package/native/core/ColorScheme.cpp +105 -0
  197. package/native/core/ColorScheme.h +59 -0
  198. package/native/core/ComponentRegistry.h +30 -0
  199. package/native/core/ControlMetrics.h +37 -0
  200. package/native/core/CoreModules.cpp +592 -0
  201. package/native/core/CoreModules.h +308 -0
  202. package/native/core/DebuggingOverlay.cpp +106 -0
  203. package/native/core/DebuggingOverlay.h +65 -0
  204. package/native/core/DesktopControls.cpp +232 -0
  205. package/native/core/DesktopControls.h +170 -0
  206. package/native/core/DevBundle.cpp +108 -0
  207. package/native/core/DevBundle.h +69 -0
  208. package/native/core/DevMenu.cpp +99 -0
  209. package/native/core/DevMenu.h +75 -0
  210. package/native/core/DialogModule.cpp +150 -0
  211. package/native/core/DialogModule.h +51 -0
  212. package/native/core/DragAndDrop.cpp +45 -0
  213. package/native/core/DragAndDrop.h +225 -0
  214. package/native/core/ExpoImageComponent.cpp +79 -0
  215. package/native/core/ExpoImageComponent.h +80 -0
  216. package/native/core/ExpoModules.cpp +415 -0
  217. package/native/core/ExpoModules.h +115 -0
  218. package/native/core/ExpoRuntime.cpp +366 -0
  219. package/native/core/ExpoRuntime.h +42 -0
  220. package/native/core/FocusRing.h +36 -0
  221. package/native/core/FontRegistry.h +51 -0
  222. package/native/core/GestureHandlerModule.cpp +136 -0
  223. package/native/core/GestureHandlerModule.h +71 -0
  224. package/native/core/Gestures.cpp +533 -0
  225. package/native/core/Gestures.h +145 -0
  226. package/native/core/HoverTracker.cpp +69 -0
  227. package/native/core/HoverTracker.h +109 -0
  228. package/native/core/HttpClient.cpp +282 -0
  229. package/native/core/ImageBytes.cpp +205 -0
  230. package/native/core/ImageBytes.h +29 -0
  231. package/native/core/ImageCache.cpp +51 -0
  232. package/native/core/ImageCache.h +89 -0
  233. package/native/core/JsRuntimeAccess.cpp +70 -0
  234. package/native/core/JsRuntimeAccess.h +60 -0
  235. package/native/core/JsiPromise.h +51 -0
  236. package/native/core/KeyEvents.cpp +116 -0
  237. package/native/core/KeyEvents.h +144 -0
  238. package/native/core/LogBoxSurface.cpp +46 -0
  239. package/native/core/LogBoxSurface.h +68 -0
  240. package/native/core/MenuModel.h +117 -0
  241. package/native/core/MenuModule.cpp +209 -0
  242. package/native/core/MenuModule.h +66 -0
  243. package/native/core/MountingWalk.h +524 -0
  244. package/native/core/PackageModules.cpp.in +25 -0
  245. package/native/core/PackageModules.h +50 -0
  246. package/native/core/PlatformConstantsModule.cpp +63 -0
  247. package/native/core/PlatformConstantsModule.h +64 -0
  248. package/native/core/PlatformServices.h +213 -0
  249. package/native/core/PointerButtons.h +63 -0
  250. package/native/core/PullToRefresh.cpp +57 -0
  251. package/native/core/PullToRefresh.h +73 -0
  252. package/native/core/ReanimatedCompat.h +47 -0
  253. package/native/core/ReanimatedModule.cpp +203 -0
  254. package/native/core/ReanimatedModule.h +55 -0
  255. package/native/core/ScrollAnimation.cpp +59 -0
  256. package/native/core/ScrollAnimation.h +70 -0
  257. package/native/core/ScrollBounds.cpp +26 -0
  258. package/native/core/ScrollBounds.h +68 -0
  259. package/native/core/ScrollIndicator.cpp +50 -0
  260. package/native/core/ScrollIndicator.h +69 -0
  261. package/native/core/ScrollMomentum.cpp +71 -0
  262. package/native/core/ScrollMomentum.h +73 -0
  263. package/native/core/ScrollSnap.cpp +123 -0
  264. package/native/core/ScrollSnap.h +80 -0
  265. package/native/core/ShareFallback.cpp +101 -0
  266. package/native/core/ShareFallback.h +45 -0
  267. package/native/core/SkiaPictureViewComponent.cpp +11 -0
  268. package/native/core/SkiaPictureViewComponent.h +47 -0
  269. package/native/core/SourceCodeModule.cpp +55 -0
  270. package/native/core/SourceCodeModule.h +53 -0
  271. package/native/core/StatusBarModule.cpp +23 -0
  272. package/native/core/StatusBarModule.h +42 -0
  273. package/native/core/TestDialog.cpp +148 -0
  274. package/native/core/TestDialog.h +96 -0
  275. package/native/core/TestKeys.cpp +78 -0
  276. package/native/core/TestKeys.h +50 -0
  277. package/native/core/TestQuitFile.cpp +33 -0
  278. package/native/core/TestQuitFile.h +60 -0
  279. package/native/core/TestSettle.h +192 -0
  280. package/native/core/TitleBarRegions.h +31 -0
  281. package/native/core/TurboModuleProxy.cpp +51 -0
  282. package/native/core/TurboModuleProxy.h +46 -0
  283. package/native/core/UIManagerAccess.cpp +43 -0
  284. package/native/core/UIManagerAccess.h +43 -0
  285. package/native/core/WindowBoundsCache.cpp +319 -0
  286. package/native/core/WindowControl.h +235 -0
  287. package/native/core/WindowHost.h +158 -0
  288. package/native/core/WindowMethods.cpp +167 -0
  289. package/native/core/WindowMethods.h +84 -0
  290. package/native/core/WindowsModule.cpp +448 -0
  291. package/native/core/WindowsModule.h +133 -0
  292. package/native/core/WorkletsModule.cpp +199 -0
  293. package/native/core/WorkletsModule.h +57 -0
  294. package/native/core/portability_probe.cpp +210 -0
  295. package/native/tests/EventRecorder.h +124 -0
  296. package/native/tests/TestHarness.cpp +109 -0
  297. package/native/tests/TestHarness.h +89 -0
  298. package/native/tests/TreeDump.h +49 -0
  299. package/native/tests/test_app_identity.cpp +114 -0
  300. package/native/tests/test_app_paths.cpp +48 -0
  301. package/native/tests/test_appearance.cpp +107 -0
  302. package/native/tests/test_backface.cpp +79 -0
  303. package/native/tests/test_blobs.cpp +157 -0
  304. package/native/tests/test_controls.cpp +185 -0
  305. package/native/tests/test_devbundle.cpp +103 -0
  306. package/native/tests/test_drag_and_drop.cpp +143 -0
  307. package/native/tests/test_gestures.cpp +331 -0
  308. package/native/tests/test_hover.cpp +92 -0
  309. package/native/tests/test_image_cache.cpp +109 -0
  310. package/native/tests/test_js_runtime_access.cpp +137 -0
  311. package/native/tests/test_key_events.cpp +235 -0
  312. package/native/tests/test_momentum.cpp +138 -0
  313. package/native/tests/test_quit_file.cpp +104 -0
  314. package/native/tests/test_scroll_animation.cpp +120 -0
  315. package/native/tests/test_scroll_bounds.cpp +66 -0
  316. package/native/tests/test_scroll_indicator.cpp +149 -0
  317. package/native/tests/test_scroll_snap.cpp +112 -0
  318. package/native/tests/test_settle.cpp +115 -0
  319. package/native/tests/test_share.cpp +75 -0
  320. package/native/tests/test_sourcecode.cpp +62 -0
  321. package/native/tests/test_window_close.cpp +119 -0
  322. package/native/tests/test_window_limits.cpp +123 -0
  323. package/package.json +43 -0
  324. package/react-native.config.js +86 -0
  325. package/supported-versions.json +66 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `ScrollView`, for a desktop React Native platform.
3
+ *
4
+ * Unlike the other four overrides beside this one, this is not a rewrite: it is
5
+ * React Native's own `ScrollView`, with the one line that drops `refreshControl`
6
+ * on the floor put back.
7
+ *
8
+ * `ScrollView.render` handles the prop in two branches -- iOS puts the control
9
+ * inside the scroll view, Android wraps the scroll view in one -- and has no
10
+ * `else`. Bundle for `linux`, `macos` or `windows` and neither branch is taken,
11
+ * so `<ScrollView refreshControl={...}>` renders the list and silently no
12
+ * refresh control: no warning, no error, nothing on screen, and a
13
+ * `<RefreshControl>` that is never mounted and so can never fire `onRefresh`.
14
+ *
15
+ * A wrapper rather than a copy. `ScrollView.js` is two thousand lines and every
16
+ * one of them would have to be re-copied at each React Native upgrade; the part
17
+ * that is wrong here is a single decision about where one child goes, and the
18
+ * iOS arrangement -- the control as a child of the scroll view -- is the one
19
+ * this platform implements. So the control is passed through as an ordinary
20
+ * first child and everything else is React Native's.
21
+ *
22
+ * Importing the module this file replaces resolves to the original rather than
23
+ * looping: `metro-config.js` skips the override when the request comes from the
24
+ * override itself. That guard was written for exactly this case.
25
+ *
26
+ * @format
27
+ */
28
+ import * as React from 'react';
29
+ type BasaltScrollViewProps = {
30
+ refreshControl?: React.ReactElement | null;
31
+ children?: React.ReactNode;
32
+ [key: string]: unknown;
33
+ };
34
+ declare function BasaltScrollView({ refreshControl, children, ...props }: BasaltScrollViewProps): React.ReactElement;
35
+ declare namespace BasaltScrollView {
36
+ var displayName: string;
37
+ }
38
+ export default BasaltScrollView;
39
+ //# sourceMappingURL=ScrollView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../src/overrides/ScrollView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,qBAAqB,GAAG;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAG3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,iBAAS,gBAAgB,CAAC,EACxB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAa5C;kBAjBQ,gBAAgB;;;AAmCzB,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `ScrollView`, for a desktop React Native platform.
3
+ *
4
+ * Unlike the other four overrides beside this one, this is not a rewrite: it is
5
+ * React Native's own `ScrollView`, with the one line that drops `refreshControl`
6
+ * on the floor put back.
7
+ *
8
+ * `ScrollView.render` handles the prop in two branches -- iOS puts the control
9
+ * inside the scroll view, Android wraps the scroll view in one -- and has no
10
+ * `else`. Bundle for `linux`, `macos` or `windows` and neither branch is taken,
11
+ * so `<ScrollView refreshControl={...}>` renders the list and silently no
12
+ * refresh control: no warning, no error, nothing on screen, and a
13
+ * `<RefreshControl>` that is never mounted and so can never fire `onRefresh`.
14
+ *
15
+ * A wrapper rather than a copy. `ScrollView.js` is two thousand lines and every
16
+ * one of them would have to be re-copied at each React Native upgrade; the part
17
+ * that is wrong here is a single decision about where one child goes, and the
18
+ * iOS arrangement -- the control as a child of the scroll view -- is the one
19
+ * this platform implements. So the control is passed through as an ordinary
20
+ * first child and everything else is React Native's.
21
+ *
22
+ * Importing the module this file replaces resolves to the original rather than
23
+ * looping: `metro-config.js` skips the override when the request comes from the
24
+ * override itself. That guard was written for exactly this case.
25
+ *
26
+ * @format
27
+ */
28
+ 'use strict';
29
+ var __importDefault = (this && this.__importDefault) || function (mod) {
30
+ return (mod && mod.__esModule) ? mod : { "default": mod };
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ const jsx_runtime_1 = require("react/jsx-runtime");
34
+ const ScrollView_1 = __importDefault(require("basalt-core/upstream/Libraries/Components/ScrollView/ScrollView"));
35
+ function BasaltScrollView({ refreshControl, children, ...props }) {
36
+ if (refreshControl == null) {
37
+ return (0, jsx_runtime_1.jsx)(ScrollView_1.default, { ...props, children: children });
38
+ }
39
+ // First, so it takes the row at the top of the content: on a phone the
40
+ // spinner lives in the rubber band above the list, and a desktop scroll view
41
+ // has none. See the header of RefreshControl.js beside this file.
42
+ return ((0, jsx_runtime_1.jsxs)(ScrollView_1.default, { ...props, children: [refreshControl, children] }));
43
+ }
44
+ BasaltScrollView.displayName = 'ScrollView';
45
+ // `ScrollView.Context` is read by VirtualizedList and by `ScrollView`'s own
46
+ // children, and the statics are part of the public export. Copied rather than
47
+ // re-declared so that anything React Native adds to them arrives here too.
48
+ // Indexed by a string on both sides: these are React Native's statics, whose
49
+ // names are not known here and whose shapes it publishes no types for.
50
+ const statics = BasaltScrollView;
51
+ const upstreamStatics = ScrollView_1.default;
52
+ for (const key of Object.keys(upstreamStatics)) {
53
+ if (statics[key] === undefined) {
54
+ statics[key] = upstreamStatics[key];
55
+ }
56
+ }
57
+ statics.Context = upstreamStatics.Context;
58
+ exports.default = BasaltScrollView;
59
+ //# sourceMappingURL=ScrollView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollView.js","sourceRoot":"","sources":["../../../src/overrides/ScrollView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,YAAY,CAAC;;;;;;AAEb,iHAAyF;AAWzF,SAAS,gBAAgB,CAAC,EACxB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACc;IACtB,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,uBAAC,oBAAU,OAAK,KAAK,YAAG,QAAQ,GAAc,CAAC;IACxD,CAAC;IACD,uEAAuE;IACvE,6EAA6E;IAC7E,kEAAkE;IAClE,OAAO,CACL,wBAAC,oBAAU,OAAK,KAAK,aAClB,cAAc,EACd,QAAQ,IACE,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,WAAW,GAAG,YAAY,CAAC;AAE5C,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,uEAAuE;AACvE,MAAM,OAAO,GAAG,gBAAsD,CAAC;AACvE,MAAM,eAAe,GAAG,oBAAgD,CAAC;AACzE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;IAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;AAE1C,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `Share`, for a platform React Native's own copy does not have a branch for.
3
+ *
4
+ * Not a shim and not a subset: this is a rewrite, for the same reason
5
+ * TextInput.js is one. React Native's `Share.share()` branches on `Platform.OS`
6
+ * being exactly `android` or `ios` and ends with
7
+ *
8
+ * return Promise.reject(new Error('Unsupported platform'));
9
+ *
10
+ * so on a desktop the native module was never reached, and implementing one
11
+ * changed nothing at all. A third branch upstream would be the tidier fix and
12
+ * is not ours to make; until then the file is replaced, and the replacement is
13
+ * deliberately close to the original so a diff against it stays short.
14
+ *
15
+ * ## Which of the two shapes this follows
16
+ *
17
+ * Android's. React Native has two: a promise-returning `ShareModule.share`, and
18
+ * an iOS callback pair on `ActionSheetManager`. The first is the one whose
19
+ * signature matches what `Share.share()` returns, so the desktop module is
20
+ * shaped like it -- see core/CoreModules.h.
21
+ *
22
+ * It takes one thing more than Android's does: `url`. React Native marks that
23
+ * as iOS-only, and a desktop has no reason to refuse it -- a link with a
24
+ * sentence about it is what most calls to Share are, and dropping either half
25
+ * would be dropping half of what the app asked for.
26
+ *
27
+ * ## What the platforms do with it
28
+ *
29
+ * macOS shows `NSSharingServicePicker`, which is the real thing. Linux and
30
+ * Windows show a small picker built from a clipboard and a mail client, because
31
+ * Linux has no share service at all and Windows' needs WinRT interop that is
32
+ * not written yet. See native/core/ShareFallback.h, which argues for that being
33
+ * the honest answer rather than a rejection.
34
+ *
35
+ * @format
36
+ */
37
+ /** One or the other must be there, which is what the union says. */
38
+ export type ShareContent = {
39
+ title?: string;
40
+ url: string;
41
+ message?: string;
42
+ } | {
43
+ title?: string;
44
+ url?: string;
45
+ message: string;
46
+ };
47
+ export type ShareOptions = {
48
+ dialogTitle?: string;
49
+ /** iOS's, accepted and ignored, so code written for it runs unchanged. */
50
+ excludedActivityTypes?: Array<string>;
51
+ tintColor?: string;
52
+ subject?: string;
53
+ anchor?: number;
54
+ };
55
+ export type ShareAction = {
56
+ action: 'sharedAction' | 'dismissedAction';
57
+ /** Null here for the same reason it is null on Android. */
58
+ activityType?: string | null;
59
+ };
60
+ declare class Share {
61
+ /**
62
+ * Open a dialog to share text content.
63
+ *
64
+ * Returns a Promise which will be invoked with an object containing `action`.
65
+ * If the user dismissed the dialog, the Promise will still be resolved with
66
+ * action being `Share.dismissedAction` and all the other keys being undefined.
67
+ *
68
+ * **Content:**
69
+ *
70
+ * - `message` - A message to share.
71
+ * - `url` - A URL to share.
72
+ * - `title` - Title of the message, and the subject of an email if the share
73
+ * goes that way.
74
+ *
75
+ * At least one of `url` or `message` is required.
76
+ *
77
+ * **Options:**
78
+ *
79
+ * - `dialogTitle` - Title of the share dialog, where one is drawn rather than
80
+ * supplied by the system.
81
+ *
82
+ * `excludedActivityTypes`, `tintColor`, `subject` and `anchor` are iOS's and
83
+ * are accepted and ignored, so that code written for iOS runs unchanged.
84
+ */
85
+ static share(content: ShareContent, options?: ShareOptions): Promise<ShareAction>;
86
+ /**
87
+ * The content was successfully shared.
88
+ */
89
+ static sharedAction: 'sharedAction';
90
+ /**
91
+ * The dialog was dismissed.
92
+ */
93
+ static dismissedAction: 'dismissedAction';
94
+ }
95
+ export default Share;
96
+ //# sourceMappingURL=Share.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Share.d.ts","sourceRoot":"","sources":["../../../src/overrides/Share.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,oEAAoE;AACpE,MAAM,MAAM,YAAY,GACpB;IACE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,qBAAqB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAAC;IAC3C,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,cAAM,KAAK;IACT;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuCrF;;OAEG;IACH,MAAM,CAAC,YAAY,EAAE,cAAc,CAAkB;IAErD;;OAEG;IACH,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAqB;CAC/D;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * `Share`, for a platform React Native's own copy does not have a branch for.
3
+ *
4
+ * Not a shim and not a subset: this is a rewrite, for the same reason
5
+ * TextInput.js is one. React Native's `Share.share()` branches on `Platform.OS`
6
+ * being exactly `android` or `ios` and ends with
7
+ *
8
+ * return Promise.reject(new Error('Unsupported platform'));
9
+ *
10
+ * so on a desktop the native module was never reached, and implementing one
11
+ * changed nothing at all. A third branch upstream would be the tidier fix and
12
+ * is not ours to make; until then the file is replaced, and the replacement is
13
+ * deliberately close to the original so a diff against it stays short.
14
+ *
15
+ * ## Which of the two shapes this follows
16
+ *
17
+ * Android's. React Native has two: a promise-returning `ShareModule.share`, and
18
+ * an iOS callback pair on `ActionSheetManager`. The first is the one whose
19
+ * signature matches what `Share.share()` returns, so the desktop module is
20
+ * shaped like it -- see core/CoreModules.h.
21
+ *
22
+ * It takes one thing more than Android's does: `url`. React Native marks that
23
+ * as iOS-only, and a desktop has no reason to refuse it -- a link with a
24
+ * sentence about it is what most calls to Share are, and dropping either half
25
+ * would be dropping half of what the app asked for.
26
+ *
27
+ * ## What the platforms do with it
28
+ *
29
+ * macOS shows `NSSharingServicePicker`, which is the real thing. Linux and
30
+ * Windows show a small picker built from a clipboard and a mail client, because
31
+ * Linux has no share service at all and Windows' needs WinRT interop that is
32
+ * not written yet. See native/core/ShareFallback.h, which argues for that being
33
+ * the honest answer rather than a rejection.
34
+ *
35
+ * @format
36
+ */
37
+ 'use strict';
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ const NativeShareModule_1 = __importDefault(require("basalt-core/upstream/Libraries/Share/NativeShareModule"));
43
+ const invariant = require('invariant');
44
+ class Share {
45
+ /**
46
+ * Open a dialog to share text content.
47
+ *
48
+ * Returns a Promise which will be invoked with an object containing `action`.
49
+ * If the user dismissed the dialog, the Promise will still be resolved with
50
+ * action being `Share.dismissedAction` and all the other keys being undefined.
51
+ *
52
+ * **Content:**
53
+ *
54
+ * - `message` - A message to share.
55
+ * - `url` - A URL to share.
56
+ * - `title` - Title of the message, and the subject of an email if the share
57
+ * goes that way.
58
+ *
59
+ * At least one of `url` or `message` is required.
60
+ *
61
+ * **Options:**
62
+ *
63
+ * - `dialogTitle` - Title of the share dialog, where one is drawn rather than
64
+ * supplied by the system.
65
+ *
66
+ * `excludedActivityTypes`, `tintColor`, `subject` and `anchor` are iOS's and
67
+ * are accepted and ignored, so that code written for iOS runs unchanged.
68
+ */
69
+ static share(content, options = {}) {
70
+ invariant(typeof content === 'object' && content !== null, 'Content to share must be a valid object');
71
+ invariant(typeof content.url === 'string' || typeof content.message === 'string', 'At least one of URL or message is required');
72
+ invariant(typeof options === 'object' && options !== null, 'Options must be a valid object');
73
+ invariant(content.title == null || typeof content.title === 'string', 'Invalid title: title should be a string.');
74
+ invariant(NativeShareModule_1.default, 'ShareModule should be registered on this platform.');
75
+ return NativeShareModule_1.default.share({
76
+ title: content.title,
77
+ message: typeof content.message === 'string' ? content.message : undefined,
78
+ url: typeof content.url === 'string' ? content.url : undefined,
79
+ }, options.dialogTitle).then((result) => ({
80
+ // iOS's, and null here for the same reason it is null on Android: the
81
+ // platform reports whether something was shared and not which service
82
+ // took it.
83
+ activityType: null,
84
+ ...result,
85
+ }));
86
+ }
87
+ /**
88
+ * The content was successfully shared.
89
+ */
90
+ static sharedAction = 'sharedAction';
91
+ /**
92
+ * The dialog was dismissed.
93
+ */
94
+ static dismissedAction = 'dismissedAction';
95
+ }
96
+ exports.default = Share;
97
+ //# sourceMappingURL=Share.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Share.js","sourceRoot":"","sources":["../../../src/overrides/Share.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,YAAY,CAAC;;;;;AAEb,+GAAuF;AAEvF,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AA8BvC,MAAM,KAAK;IACT;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,KAAK,CAAC,OAAqB,EAAE,UAAwB,EAAE;QAC5D,SAAS,CACP,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAC/C,yCAAyC,CAC1C,CAAC;QACF,SAAS,CACP,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EACtE,4CAA4C,CAC7C,CAAC;QACF,SAAS,CACP,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAC/C,gCAAgC,CACjC,CAAC;QACF,SAAS,CACP,OAAO,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAC1D,0CAA0C,CAC3C,CAAC;QACF,SAAS,CACP,2BAAiB,EACjB,oDAAoD,CACrD,CAAC;QAEF,OAAO,2BAAiB,CAAC,KAAK,CAC5B;YACE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EACL,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YACnE,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;SAC/D,EACD,OAAO,CAAC,WAAW,CACpB,CAAC,IAAI,CAAC,CAAC,MAAgC,EAAE,EAAE,CAAC,CAAC;YAC5C,sEAAsE;YACtE,sEAAsE;YACtE,WAAW;YACX,YAAY,EAAE,IAAI;YAClB,GAAG,MAAM;SACV,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,GAAmB,cAAc,CAAC;IAErD;;OAEG;IACH,MAAM,CAAC,eAAe,GAAsB,iBAAiB,CAAC;;AAGhE,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * `<TextInput>`, for every desktop platform here.
3
+ *
4
+ * React Native's own `TextInput.js` cannot be used here. Its body is
5
+ *
6
+ * if (Platform.OS === 'android') { ... }
7
+ * else if (Platform.OS === 'ios') { ... }
8
+ *
9
+ * and on any other platform neither branch runs, so the component it goes on to
10
+ * render is undefined and React reports an invalid element type. There is no
11
+ * third branch to add without forking fifteen hundred lines of iOS and Android
12
+ * behaviour that would then drift from upstream in silence.
13
+ *
14
+ * So this is a smaller implementation, and honestly a subset. It renders the
15
+ * same native component the iOS path renders, `RCTSinglelineTextInputView`,
16
+ * which ReactCommon rewrites to the component named `TextInput`, whose shadow
17
+ * node is React Native's own iOS one and whose measurement runs through
18
+ * whichever text layout manager the platform installs -- Pango on Linux, Core
19
+ * Text on macOS and DirectWrite on Windows, all three of which mount it. What
20
+ * it does not carry is the years of platform-specific behaviour in the real
21
+ * file: no `InputAccessoryView`, no shared `TextInputState` focus registry, no
22
+ * autofill, no `rejectResponderTermination`, no multiline.
23
+ *
24
+ * `selection` and `onSelectionChange` do work, and need nothing here: both
25
+ * reach the native component through `...rest`, and what was missing was the
26
+ * native half on either side of them.
27
+ *
28
+ * `docs/BACKLOG.md` tracks what is missing. The seam is here when it is time.
29
+ *
30
+ * @format
31
+ */
32
+ import * as React from 'react';
33
+ /**
34
+ * React Native's text fields are controlled: JavaScript owns the value and
35
+ * every keystroke round-trips through a re-render. `mostRecentEventCount` is
36
+ * how the native side tells a stale prop from a current one. Without it a fast
37
+ * typist outruns the render loop and watches characters reorder themselves.
38
+ */
39
+ /**
40
+ * The props this file reads. Everything else is forwarded untouched, which is
41
+ * what the index signature says -- React Native's `TextInputProps` is large,
42
+ * exported as no usable type, and this is a rewrite of its component rather
43
+ * than a re-declaration of its surface.
44
+ */
45
+ export type BasaltTextInputProps = {
46
+ value?: string;
47
+ defaultValue?: string;
48
+ onChange?: (event: TextInputChangeEvent) => void;
49
+ onChangeText?: (text: string) => void;
50
+ onFocus?: (event: unknown) => void;
51
+ onBlur?: (event: unknown) => void;
52
+ editable?: boolean;
53
+ style?: unknown;
54
+ [key: string]: unknown;
55
+ };
56
+ /** What the native component reports on every edit. */
57
+ type TextInputChangeEvent = {
58
+ nativeEvent: {
59
+ text: string;
60
+ eventCount: number;
61
+ target?: number;
62
+ };
63
+ };
64
+ /** The handle a caller gets, which is this and not the host instance. */
65
+ export type BasaltTextInputHandle = {
66
+ focus: () => void;
67
+ blur: () => void;
68
+ clear: () => void;
69
+ setSelection: (start: number, end: number) => void;
70
+ isFocused: () => boolean;
71
+ /**
72
+ * React Native's own field instances carry this and upstream's guards read
73
+ * it. Optional, because the handle this file builds does not.
74
+ */
75
+ currentProps?: {
76
+ editable?: boolean;
77
+ };
78
+ };
79
+ declare const ForwardedTextInput: React.ForwardRefExoticComponent<Omit<BasaltTextInputProps, "ref"> & React.RefAttributes<BasaltTextInputHandle>>;
80
+ export default ForwardedTextInput;
81
+ //# sourceMappingURL=TextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/overrides/TextInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B;;;;;GAKG;AACH;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACjD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,uDAAuD;AACvD,KAAK,oBAAoB,GAAG;IAC1B,WAAW,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CAClE,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;CACrC,CAAC;AAmJF,QAAA,MAAM,kBAAkB,iHAA8B,CAAC;AA0DvD,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * `<TextInput>`, for every desktop platform here.
3
+ *
4
+ * React Native's own `TextInput.js` cannot be used here. Its body is
5
+ *
6
+ * if (Platform.OS === 'android') { ... }
7
+ * else if (Platform.OS === 'ios') { ... }
8
+ *
9
+ * and on any other platform neither branch runs, so the component it goes on to
10
+ * render is undefined and React reports an invalid element type. There is no
11
+ * third branch to add without forking fifteen hundred lines of iOS and Android
12
+ * behaviour that would then drift from upstream in silence.
13
+ *
14
+ * So this is a smaller implementation, and honestly a subset. It renders the
15
+ * same native component the iOS path renders, `RCTSinglelineTextInputView`,
16
+ * which ReactCommon rewrites to the component named `TextInput`, whose shadow
17
+ * node is React Native's own iOS one and whose measurement runs through
18
+ * whichever text layout manager the platform installs -- Pango on Linux, Core
19
+ * Text on macOS and DirectWrite on Windows, all three of which mount it. What
20
+ * it does not carry is the years of platform-specific behaviour in the real
21
+ * file: no `InputAccessoryView`, no shared `TextInputState` focus registry, no
22
+ * autofill, no `rejectResponderTermination`, no multiline.
23
+ *
24
+ * `selection` and `onSelectionChange` do work, and need nothing here: both
25
+ * reach the native component through `...rest`, and what was missing was the
26
+ * native half on either side of them.
27
+ *
28
+ * `docs/BACKLOG.md` tracks what is missing. The seam is here when it is time.
29
+ *
30
+ * @format
31
+ */
32
+ 'use strict';
33
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
34
+ if (k2 === undefined) k2 = k;
35
+ var desc = Object.getOwnPropertyDescriptor(m, k);
36
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
37
+ desc = { enumerable: true, get: function() { return m[k]; } };
38
+ }
39
+ Object.defineProperty(o, k2, desc);
40
+ }) : (function(o, m, k, k2) {
41
+ if (k2 === undefined) k2 = k;
42
+ o[k2] = m[k];
43
+ }));
44
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
45
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
46
+ }) : function(o, v) {
47
+ o["default"] = v;
48
+ });
49
+ var __importStar = (this && this.__importStar) || (function () {
50
+ var ownKeys = function(o) {
51
+ ownKeys = Object.getOwnPropertyNames || function (o) {
52
+ var ar = [];
53
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
54
+ return ar;
55
+ };
56
+ return ownKeys(o);
57
+ };
58
+ return function (mod) {
59
+ if (mod && mod.__esModule) return mod;
60
+ var result = {};
61
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
62
+ __setModuleDefault(result, mod);
63
+ return result;
64
+ };
65
+ })();
66
+ var __importDefault = (this && this.__importDefault) || function (mod) {
67
+ return (mod && mod.__esModule) ? mod : { "default": mod };
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ const jsx_runtime_1 = require("react/jsx-runtime");
71
+ const React = __importStar(require("react"));
72
+ const react_1 = require("react");
73
+ const RCTSingelineTextInputNativeComponent_1 = __importStar(require("basalt-core/upstream/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent"));
74
+ const TextInputState_1 = __importDefault(require("basalt-core/upstream/Libraries/Components/TextInput/TextInputState"));
75
+ const StyleSheet_1 = __importDefault(require("basalt-core/upstream/Libraries/StyleSheet/StyleSheet"));
76
+ function TextInput({ value, defaultValue, onChange, onChangeText, onFocus, onBlur, editable, style, ...rest }, forwardedRef) {
77
+ const inputRef = (0, react_1.useRef)(null);
78
+ const [mostRecentEventCount, setMostRecentEventCount] = (0, react_1.useState)(0);
79
+ const focused = (0, react_1.useRef)(false);
80
+ // Built as one object rather than inline, because the registry has to hold
81
+ // the *same* thing callers do. `useImperativeHandle` means the ref a caller
82
+ // gets is this handle and not the host instance, so registering the host
83
+ // instance would make `isTextInput(ref)` answer false about a field that is
84
+ // very much one -- which is exactly what it did first time round.
85
+ const handle = (0, react_1.useMemo)(() => ({
86
+ focus() {
87
+ if (inputRef.current != null) {
88
+ RCTSingelineTextInputNativeComponent_1.Commands.focus(inputRef.current);
89
+ }
90
+ },
91
+ blur() {
92
+ if (inputRef.current != null) {
93
+ RCTSingelineTextInputNativeComponent_1.Commands.blur(inputRef.current);
94
+ }
95
+ },
96
+ clear() {
97
+ if (inputRef.current != null) {
98
+ RCTSingelineTextInputNativeComponent_1.Commands.setTextAndSelection(inputRef.current, mostRecentEventCount, '', 0, 0);
99
+ }
100
+ onChangeText?.('');
101
+ },
102
+ setSelection(start, end) {
103
+ if (inputRef.current != null) {
104
+ RCTSingelineTextInputNativeComponent_1.Commands.setTextAndSelection(inputRef.current, mostRecentEventCount, null, start, end);
105
+ }
106
+ },
107
+ isFocused() {
108
+ return focused.current;
109
+ },
110
+ }), [mostRecentEventCount, onChangeText]);
111
+ (0, react_1.useImperativeHandle)(forwardedRef, () => handle, [handle]);
112
+ // The shared registry, which is what makes `TextInput.State` and
113
+ // `dismissKeyboard`-shaped code work: a field has to be in `inputs` before
114
+ // anything can ask whether it is one, and has to leave when it unmounts or
115
+ // the set grows for the life of the app.
116
+ (0, react_1.useEffect)(() => {
117
+ TextInputState_1.default.registerInput(handle);
118
+ return () => {
119
+ TextInputState_1.default.unregisterInput(handle);
120
+ // A field that unmounts while focused would otherwise leave the registry
121
+ // pointing at something React has thrown away, and
122
+ // `currentlyFocusedInput()` would answer with it.
123
+ if (TextInputState_1.default.currentlyFocusedInput() === handle) {
124
+ TextInputState_1.default.blurInput(handle);
125
+ }
126
+ };
127
+ }, [handle]);
128
+ const handleChange = (0, react_1.useCallback)((event) => {
129
+ const { text, eventCount } = event.nativeEvent;
130
+ setMostRecentEventCount(eventCount);
131
+ onChange?.(event);
132
+ onChangeText?.(text);
133
+ }, [onChange, onChangeText]);
134
+ const handleFocus = (0, react_1.useCallback)((event) => {
135
+ focused.current = true;
136
+ // The platform is the authority on what has focus, so the registry is
137
+ // told here rather than by whoever called focus() -- a click into a field
138
+ // never goes through that path at all.
139
+ TextInputState_1.default.focusInput(handle);
140
+ onFocus?.(event);
141
+ }, [handle, onFocus]);
142
+ const handleBlur = (0, react_1.useCallback)((event) => {
143
+ focused.current = false;
144
+ TextInputState_1.default.blurInput(handle);
145
+ onBlur?.(event);
146
+ }, [handle, onBlur]);
147
+ return ((0, jsx_runtime_1.jsx)(RCTSingelineTextInputNativeComponent_1.default, { ...rest, ref: inputRef, style: [styles.input, style],
148
+ // `text` rather than `value`: the iOS view config calls it that, and this
149
+ // renders the iOS component. An uncontrolled field is given its default
150
+ // once and then left alone, which is what passing undefined does.
151
+ text: value != null ? value : defaultValue, editable: editable !== false, mostRecentEventCount: mostRecentEventCount, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur }));
152
+ }
153
+ const styles = StyleSheet_1.default.create({
154
+ input: {
155
+ // Yoga decides the size, and a field measured from empty text is a couple
156
+ // of pixels tall -- invisible, unclickable, and indistinguishable from the
157
+ // component being broken. Any explicit height in `style` overrides this.
158
+ minHeight: 36,
159
+ },
160
+ });
161
+ const ForwardedTextInput = React.forwardRef(TextInput);
162
+ /**
163
+ * `TextInput.State`, which is React Native's own registry with two methods
164
+ * replaced.
165
+ *
166
+ * `focusTextInput` and `blurTextInput` upstream are
167
+ *
168
+ * if (Platform.OS === 'ios') { iOSTextInputCommands.focus(ref); }
169
+ * else if (Platform.OS === 'android') { ... }
170
+ *
171
+ * -- the same missing third branch that makes TextInput.js itself unusable
172
+ * here. On these platforms they would update the registry and then focus
173
+ * nothing, which is worse than not existing: `currentlyFocusedInput()` would
174
+ * name a field that does not have focus.
175
+ *
176
+ * So the rest of the module is taken as it is, and these two dispatch the
177
+ * commands the component already uses. Wrapped rather than forked, because the
178
+ * other nine functions are the registry itself and have no platform in them.
179
+ */
180
+ const State = {
181
+ ...TextInputState_1.default,
182
+ focusTextInput(textField) {
183
+ if (textField == null) {
184
+ return;
185
+ }
186
+ // Upstream's guards, which are not incidental: focusing what is already
187
+ // focused would emit a second onFocus, and a disabled field must refuse.
188
+ if (TextInputState_1.default.currentlyFocusedInput() === textField ||
189
+ textField.currentProps?.editable === false) {
190
+ return;
191
+ }
192
+ TextInputState_1.default.focusInput(textField);
193
+ // The handle's own method, which dispatches the command against the host
194
+ // instance it closed over. `Commands.focus` cannot be called with the
195
+ // handle, and the handle is what the registry holds.
196
+ textField.focus?.();
197
+ },
198
+ blurTextInput(textField) {
199
+ if (textField == null) {
200
+ return;
201
+ }
202
+ if (TextInputState_1.default.currentlyFocusedInput() !== textField) {
203
+ return;
204
+ }
205
+ TextInputState_1.default.blurInput(textField);
206
+ textField.blur?.();
207
+ },
208
+ };
209
+ // The statics React Native's TextInput carries. Assigned through an indexed
210
+ // cast because a forwardRef component's type has no room for them.
211
+ ForwardedTextInput.State = State;
212
+ exports.default = ForwardedTextInput;
213
+ //# sourceMappingURL=TextInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/overrides/TextInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,6CAA+B;AAC/B,iCAOe;AACf,iKAEkG;AAClG,wHAAgG;AAChG,sGAA8E;AA6C9E,SAAS,SAAS,CAChB,EACE,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACc,EACvB,YAA8C;IAE9C,MAAM,QAAQ,GAAG,IAAA,cAAM,EACrB,IAAI,CACL,CAAC;IACF,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAG9B,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,kEAAkE;IAClE,MAAM,MAAM,GAAG,IAAA,eAAO,EACpB,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;YACH,IAAI,QAAQ,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;gBAC7B,+CAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAA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D,CAAC,KAAK,GAAG,KAAK,CAAC;AAEzE,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * React Native's `View`, plus the keyboard props react-native-macos has.
3
+ *
4
+ * `keyDownEvents`, `onKeyDown` and `focusable` are how an app written against
5
+ * react-native-macos declares a keyboard shortcut, and an app that has them is
6
+ * an app this platform was supposed to be able to replace. Without them the
7
+ * props are dropped in JavaScript, silently -- no error, no warning, and every
8
+ * binding in the app simply never fires, which is exactly how it was found.
9
+ *
10
+ * `<KeyHandler>` already did this under names of this project's own. Those names
11
+ * are better -- a component that takes `keys` cannot be spread onto a view that
12
+ * does nothing with it -- and they are no use to an app that is not being
13
+ * rewritten. Both work now, through one implementation: see useHandledKeys.ts.
14
+ *
15
+ * **Two components, not one branch.** A view without `keyDownEvents` renders
16
+ * React Native's own with no hooks added, because hooks cannot be conditional
17
+ * and three of them on every view in an app is not a cost to impose for a prop
18
+ * almost nothing uses. The consequence is that a view which *gains* the prop
19
+ * changes component type and remounts, which is the right trade for a prop that
20
+ * is either on a view for its lifetime or not on it at all.
21
+ *
22
+ * The callback is handed `{nativeEvent}`, which is react-native-macos's shape
23
+ * and what an app already written for it expects -- not the bare object
24
+ * `<KeyHandler>` passes. Different names, different shapes; both are contracts
25
+ * and neither gets to change the other.
26
+ *
27
+ * @format
28
+ */
29
+ import * as React from 'react';
30
+ type Props = any;
31
+ declare function BasaltView(props: Props): React.ReactElement;
32
+ declare namespace BasaltView {
33
+ var displayName: string;
34
+ }
35
+ export default BasaltView;
36
+ //# sourceMappingURL=View.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../../../src/overrides/View.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,KAAK,KAAK,GAAG,GAAG,CAAC;AAgCjB,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAQpD;kBARQ,UAAU;;;AAYnB,eAAe,UAAU,CAAC"}