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,102 @@
1
+ /**
2
+ * Turning a host binary into the thing each desktop calls an application.
3
+ *
4
+ * `--build` produces an executable, and an executable is not an application on
5
+ * any of these three. What it costs to stay a bare binary is not cosmetic:
6
+ *
7
+ * macOS `UNUserNotificationCenter` does not merely fail for a process with
8
+ * no bundle identifier -- it raises `bundleProxyForCurrentProcess is
9
+ * nil` and terminates. So notifications are unreachable, and so are
10
+ * the Dock icon, the menu bar name, file associations and a
11
+ * registered URL scheme, all of which live in the same `Info.plist`.
12
+ *
13
+ * Linux Notifications work without one, because the D-Bus service takes
14
+ * the name in the call. What a `.desktop` file adds is identity: the
15
+ * app's icon beside its notifications, its name in the switcher, and
16
+ * `x-scheme-handler/` so a link opens it.
17
+ *
18
+ * Windows A toast needs an AppUserModelID and a Start Menu shortcut carrying
19
+ * it. Both are done by the host itself rather than from here -- a
20
+ * `.lnk` with that property set means `IPropertyStore`, which is
21
+ * COM, and doing it in C++ at startup is simpler than doing it in
22
+ * PowerShell from Node. See win32/Win32Packaging.h.
23
+ *
24
+ * So this file is macOS and Linux, and Windows is a no-op that says why.
25
+ *
26
+ * ## The macOS bundle is not only for release
27
+ *
28
+ * `NSBundle.mainBundle` comes from where the executable *is*, not from how it
29
+ * was launched. An executable at `Foo.app/Contents/MacOS/Foo` is bundled even
30
+ * when run straight from a shell -- so packaging on every run, including a
31
+ * development one, is what makes `Notification` behave the same in both. The
32
+ * copy is skipped when the binary has not changed, which is what keeps that
33
+ * from costing forty megabytes a run.
34
+ */
35
+ /** The three desktops this can package for. */
36
+ export type PackagePlatform = 'linux' | 'macos' | 'windows';
37
+ /**
38
+ * What an app calls itself, gathered from whatever it already declares --
39
+ * `app.json`, `package.json`, or an Expo config. Never invented beyond the
40
+ * documented fallbacks.
41
+ */
42
+ export type AppConfig = {
43
+ name: string;
44
+ slug: string;
45
+ /** Reverse-DNS, which is what macOS and notifications need. */
46
+ identifier: string;
47
+ /** Custom URL schemes the app registers. */
48
+ schemes: string[];
49
+ version: string;
50
+ };
51
+ export type PackageRequest = {
52
+ platform: PackagePlatform;
53
+ hostBinary: string;
54
+ outputDir: string;
55
+ projectRoot: string;
56
+ bundlePath?: string;
57
+ };
58
+ /**
59
+ * What was produced.
60
+ *
61
+ * `launchPath` is the thing to run, which is not always the host binary: on
62
+ * macOS it is the executable *inside* the bundle, because that is what makes
63
+ * `NSBundle.mainBundle` the bundle.
64
+ */
65
+ export type PackageResult = {
66
+ launchPath: string;
67
+ config: AppConfig;
68
+ /** Where the identity file went, or null when there was no bundle to sit beside. */
69
+ identityPath: string | null;
70
+ /** macOS only: the `.app` that was built. */
71
+ appPath?: string;
72
+ /** Linux only: the `.desktop` entry that was written. */
73
+ desktopPath?: string;
74
+ };
75
+ /**
76
+ * What an app calls itself, from whichever of the three places says so.
77
+ *
78
+ * Expo's config wins where there is one, because an Expo app's `app.json` is
79
+ * read through `expo/config` and may be a function; `app.json` is the plain
80
+ * React Native answer; `package.json` is the last resort so that this never
81
+ * fails outright.
82
+ */
83
+ export declare function readAppConfig(projectRoot: string): AppConfig;
84
+ export declare function infoPlist(config: AppConfig, executableName: string): string;
85
+ /**
86
+ * Packages `hostBinary` for `platform`, into `outputDir`.
87
+ *
88
+ * Returns `{launchPath, ...}`: what to run. On Linux and Windows that is the
89
+ * binary it was given, because neither makes the application out of where the
90
+ * executable sits; on macOS it is the copy inside the bundle.
91
+ */
92
+ /**
93
+ * Writes what the app calls itself beside the bundle, for the host to read.
94
+ *
95
+ * Beside the bundle rather than beside the executable, because the executable
96
+ * is shared by every app on the machine; and written rather than passed as an
97
+ * argument, because a Start Menu shortcut clicked in a month carries no
98
+ * environment. See native/core/AppIdentity.h.
99
+ */
100
+ export declare function writeIdentity(bundlePath: string | undefined, config: AppConfig): string | null;
101
+ export declare function packageApp({ platform, hostBinary, outputDir, projectRoot, bundlePath, }: PackageRequest): PackageResult;
102
+ //# sourceMappingURL=packageApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageApp.d.ts","sourceRoot":"","sources":["../../cli/packageApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAQH,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,oFAAoF;IACpF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgCF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAsD5D;AAUD,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAgD3E;AAwGD;;;;;;GAMG;AACH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,SAAS,GAChB,MAAM,GAAG,IAAI,CAoBf;AAED,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,GACX,EAAE,cAAc,GAAG,aAAa,CAehC"}
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ /**
3
+ * Turning a host binary into the thing each desktop calls an application.
4
+ *
5
+ * `--build` produces an executable, and an executable is not an application on
6
+ * any of these three. What it costs to stay a bare binary is not cosmetic:
7
+ *
8
+ * macOS `UNUserNotificationCenter` does not merely fail for a process with
9
+ * no bundle identifier -- it raises `bundleProxyForCurrentProcess is
10
+ * nil` and terminates. So notifications are unreachable, and so are
11
+ * the Dock icon, the menu bar name, file associations and a
12
+ * registered URL scheme, all of which live in the same `Info.plist`.
13
+ *
14
+ * Linux Notifications work without one, because the D-Bus service takes
15
+ * the name in the call. What a `.desktop` file adds is identity: the
16
+ * app's icon beside its notifications, its name in the switcher, and
17
+ * `x-scheme-handler/` so a link opens it.
18
+ *
19
+ * Windows A toast needs an AppUserModelID and a Start Menu shortcut carrying
20
+ * it. Both are done by the host itself rather than from here -- a
21
+ * `.lnk` with that property set means `IPropertyStore`, which is
22
+ * COM, and doing it in C++ at startup is simpler than doing it in
23
+ * PowerShell from Node. See win32/Win32Packaging.h.
24
+ *
25
+ * So this file is macOS and Linux, and Windows is a no-op that says why.
26
+ *
27
+ * ## The macOS bundle is not only for release
28
+ *
29
+ * `NSBundle.mainBundle` comes from where the executable *is*, not from how it
30
+ * was launched. An executable at `Foo.app/Contents/MacOS/Foo` is bundled even
31
+ * when run straight from a shell -- so packaging on every run, including a
32
+ * development one, is what makes `Notification` behave the same in both. The
33
+ * copy is skipped when the binary has not changed, which is what keeps that
34
+ * from costing forty megabytes a run.
35
+ */
36
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
37
+ if (k2 === undefined) k2 = k;
38
+ var desc = Object.getOwnPropertyDescriptor(m, k);
39
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
40
+ desc = { enumerable: true, get: function() { return m[k]; } };
41
+ }
42
+ Object.defineProperty(o, k2, desc);
43
+ }) : (function(o, m, k, k2) {
44
+ if (k2 === undefined) k2 = k;
45
+ o[k2] = m[k];
46
+ }));
47
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
48
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
49
+ }) : function(o, v) {
50
+ o["default"] = v;
51
+ });
52
+ var __importStar = (this && this.__importStar) || (function () {
53
+ var ownKeys = function(o) {
54
+ ownKeys = Object.getOwnPropertyNames || function (o) {
55
+ var ar = [];
56
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
+ return ar;
58
+ };
59
+ return ownKeys(o);
60
+ };
61
+ return function (mod) {
62
+ if (mod && mod.__esModule) return mod;
63
+ var result = {};
64
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
+ __setModuleDefault(result, mod);
66
+ return result;
67
+ };
68
+ })();
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.readAppConfig = readAppConfig;
71
+ exports.infoPlist = infoPlist;
72
+ exports.writeIdentity = writeIdentity;
73
+ exports.packageApp = packageApp;
74
+ const fs = __importStar(require("node:fs"));
75
+ const path = __importStar(require("node:path"));
76
+ const node_child_process_1 = require("node:child_process");
77
+ const node_module_1 = require("node:module");
78
+ /**
79
+ * What an app calls itself, from whichever of the three places says so.
80
+ *
81
+ * Expo's config wins where there is one, because an Expo app's `app.json` is
82
+ * read through `expo/config` and may be a function; `app.json` is the plain
83
+ * React Native answer; `package.json` is the last resort so that this never
84
+ * fails outright.
85
+ */
86
+ function readAppConfig(projectRoot) {
87
+ let exp = null;
88
+ try {
89
+ const { getConfig } = (0, node_module_1.createRequire)(path.join(projectRoot, 'package.json'))('expo/config');
90
+ exp = getConfig(projectRoot, {
91
+ skipSDKVersionRequirement: true,
92
+ isPublicConfig: true,
93
+ }).exp;
94
+ }
95
+ catch {
96
+ // Not an Expo app. Not a failure: the two files below say the same things.
97
+ }
98
+ const readJson = (file) => {
99
+ try {
100
+ return JSON.parse(fs.readFileSync(path.join(projectRoot, file), 'utf8'));
101
+ }
102
+ catch {
103
+ return {};
104
+ }
105
+ };
106
+ const appJson = readJson('app.json');
107
+ const packageJson = readJson('package.json');
108
+ const name = exp?.name ?? appJson.displayName ?? appJson.name ?? packageJson.name ?? 'App';
109
+ const slug = exp?.slug ?? appJson.name ?? packageJson.name ?? 'app';
110
+ // A reverse-DNS identifier, from whatever the app already declares for a
111
+ // phone. Inventing one is the last resort and is deliberately visible in the
112
+ // string, because an app that ships with `com.basalt.<slug>` should be able
113
+ // to tell that nobody chose it.
114
+ const identifier = appJson.basalt?.identifier ??
115
+ exp?.ios?.bundleIdentifier ??
116
+ exp?.android?.package ??
117
+ `com.basalt.${String(slug).replace(/[^A-Za-z0-9-]/g, '-').toLowerCase()}`;
118
+ // `expo.scheme` is a string or a list of them. Everything downstream wants a
119
+ // list, so it becomes one here.
120
+ const scheme = exp?.scheme ?? appJson.basalt?.scheme ?? null;
121
+ const schemes = scheme == null ? [] : Array.isArray(scheme) ? scheme : [scheme];
122
+ return {
123
+ name,
124
+ slug,
125
+ identifier,
126
+ schemes,
127
+ version: exp?.version ?? appJson.version ?? packageJson.version ?? '1.0.0',
128
+ };
129
+ }
130
+ /** XML text, escaped. A plist is XML and an app called `Ben & Co` is legal. */
131
+ function xml(text) {
132
+ return String(text)
133
+ .replace(/&/g, '&amp;')
134
+ .replace(/</g, '&lt;')
135
+ .replace(/>/g, '&gt;');
136
+ }
137
+ function infoPlist(config, executableName) {
138
+ const urlTypes = config.schemes.length === 0
139
+ ? ''
140
+ : `
141
+ <key>CFBundleURLTypes</key>
142
+ <array>
143
+ <dict>
144
+ <key>CFBundleURLName</key>
145
+ <string>${xml(config.identifier)}</string>
146
+ <key>CFBundleURLSchemes</key>
147
+ <array>
148
+ ${config.schemes.map(s => ` <string>${xml(s)}</string>`).join('\n')}
149
+ </array>
150
+ </dict>
151
+ </array>`;
152
+ return `<?xml version="1.0" encoding="UTF-8"?>
153
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
154
+ <plist version="1.0">
155
+ <dict>
156
+ <key>CFBundleDevelopmentRegion</key>
157
+ <string>en</string>
158
+ <key>CFBundleExecutable</key>
159
+ <string>${xml(executableName)}</string>
160
+ <key>CFBundleIdentifier</key>
161
+ <string>${xml(config.identifier)}</string>
162
+ <key>CFBundleInfoDictionaryVersion</key>
163
+ <string>6.0</string>
164
+ <key>CFBundleName</key>
165
+ <string>${xml(config.name)}</string>
166
+ <key>CFBundleDisplayName</key>
167
+ <string>${xml(config.name)}</string>
168
+ <key>CFBundlePackageType</key>
169
+ <string>APPL</string>
170
+ <key>CFBundleShortVersionString</key>
171
+ <string>${xml(config.version)}</string>
172
+ <key>CFBundleVersion</key>
173
+ <string>${xml(config.version)}</string>
174
+ <key>LSMinimumSystemVersion</key>
175
+ <string>11.0</string>
176
+ <key>NSHighResolutionCapable</key>
177
+ <true/>
178
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
179
+ <true/>${urlTypes}
180
+ </dict>
181
+ </plist>
182
+ `;
183
+ }
184
+ /** Whether `source` is newer than `destination`, or the destination is absent. */
185
+ function isStale(source, destination) {
186
+ try {
187
+ return fs.statSync(source).mtimeMs > fs.statSync(destination).mtimeMs;
188
+ }
189
+ catch {
190
+ return true;
191
+ }
192
+ }
193
+ /**
194
+ * Builds `<name>.app` around the host binary and returns the executable inside
195
+ * it -- which is what should be launched, because that is what makes
196
+ * `NSBundle.mainBundle` the bundle.
197
+ */
198
+ function packageMacos(hostBinary, outputDir, config) {
199
+ const appDir = path.join(outputDir, `${config.name}.app`);
200
+ const macosDir = path.join(appDir, 'Contents', 'MacOS');
201
+ const resourcesDir = path.join(appDir, 'Contents', 'Resources');
202
+ fs.mkdirSync(macosDir, { recursive: true });
203
+ fs.mkdirSync(resourcesDir, { recursive: true });
204
+ // The executable keeps the host's name rather than the app's. It is what
205
+ // shows in `ps` and in a crash report, and "basalt_appkit" there is more
206
+ // useful than the app's name, which is already on the bundle.
207
+ const executableName = path.basename(hostBinary);
208
+ const executable = path.join(macosDir, executableName);
209
+ const signed = isStale(hostBinary, executable);
210
+ if (signed) {
211
+ fs.copyFileSync(hostBinary, executable);
212
+ fs.chmodSync(executable, 0o755);
213
+ }
214
+ const plistPath = path.join(appDir, 'Contents', 'Info.plist');
215
+ const plist = infoPlist(config, executableName);
216
+ const plistChanged = !fs.existsSync(plistPath) || fs.readFileSync(plistPath, 'utf8') !== plist;
217
+ if (plistChanged) {
218
+ fs.writeFileSync(plistPath, plist);
219
+ }
220
+ // Launch Services caches a bundle's plist aggressively, and an app whose
221
+ // identifier changed under it keeps the old one until something touches the
222
+ // directory. Touching it is cheap and the alternative is a stale identity
223
+ // that looks like a bug in the plist.
224
+ fs.utimesSync(appDir, new Date(), new Date());
225
+ // Signed ad hoc, and this is not optional.
226
+ //
227
+ // An unsigned bundle has an identifier and still cannot notify: macOS
228
+ // answers `requestAuthorization` with UNErrorDomain error 1, "notifications
229
+ // are not allowed", because the identity it would attach the permission to
230
+ // is not stable. `--sign -` is the ad-hoc identity, needs no developer
231
+ // account and no keychain, and is enough -- found by the notification
232
+ // arriving the moment it was applied and not before.
233
+ //
234
+ // Only when something changed, because signing walks the whole binary and
235
+ // the host is tens of megabytes.
236
+ if (signed || plistChanged) {
237
+ const result = (0, node_child_process_1.spawnSync)('codesign', ['--force', '--sign', '-', appDir], { encoding: 'utf8' });
238
+ if (result.status !== 0) {
239
+ // Not fatal. Everything except notifications works unsigned, and a build
240
+ // that stopped here would be worse than one that says what is missing.
241
+ console.warn('==> could not sign the app bundle; notifications will be refused by macOS\n' +
242
+ ` ${(result.stderr ?? result.error?.message ?? '').trim()}`);
243
+ }
244
+ }
245
+ return { launchPath: executable, appPath: appDir };
246
+ }
247
+ /**
248
+ * Writes a `.desktop` file for the app and returns where it went.
249
+ *
250
+ * Not installed, only written. Putting a file into
251
+ * `~/.local/share/applications` is a change to the user's session that a build
252
+ * command should not make on its own; the caller prints the one-line copy that
253
+ * does it.
254
+ */
255
+ function packageLinux(hostBinary, outputDir, config) {
256
+ const fileName = `${config.identifier}.desktop`;
257
+ const destination = path.join(outputDir, fileName);
258
+ const mime = config.schemes.map(s => `x-scheme-handler/${s};`).join('');
259
+ const entry = `[Desktop Entry]\n` +
260
+ `Type=Application\n` +
261
+ `Name=${config.name}\n` +
262
+ `Exec=${hostBinary} %U\n` +
263
+ `Icon=${config.identifier}\n` +
264
+ `Terminal=false\n` +
265
+ `Categories=Utility;\n` +
266
+ `StartupNotify=true\n` +
267
+ // The window's own application id, which is what lets the desktop match a
268
+ // running window to this file -- and so what puts the right name and icon
269
+ // on its notifications.
270
+ `StartupWMClass=${config.identifier}\n` +
271
+ (mime === '' ? '' : `MimeType=${mime}\n`);
272
+ fs.writeFileSync(destination, entry);
273
+ return { launchPath: hostBinary, desktopPath: destination };
274
+ }
275
+ /**
276
+ * Packages `hostBinary` for `platform`, into `outputDir`.
277
+ *
278
+ * Returns `{launchPath, ...}`: what to run. On Linux and Windows that is the
279
+ * binary it was given, because neither makes the application out of where the
280
+ * executable sits; on macOS it is the copy inside the bundle.
281
+ */
282
+ /**
283
+ * Writes what the app calls itself beside the bundle, for the host to read.
284
+ *
285
+ * Beside the bundle rather than beside the executable, because the executable
286
+ * is shared by every app on the machine; and written rather than passed as an
287
+ * argument, because a Start Menu shortcut clicked in a month carries no
288
+ * environment. See native/core/AppIdentity.h.
289
+ */
290
+ function writeIdentity(bundlePath, config) {
291
+ if (bundlePath == null) {
292
+ return null;
293
+ }
294
+ const destination = path.join(path.dirname(bundlePath), 'app.identity.json');
295
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
296
+ fs.writeFileSync(destination, JSON.stringify({
297
+ name: config.name,
298
+ identifier: config.identifier,
299
+ schemes: config.schemes,
300
+ version: config.version,
301
+ }, null, 2));
302
+ return destination;
303
+ }
304
+ function packageApp({ platform, hostBinary, outputDir, projectRoot, bundlePath, }) {
305
+ const config = readAppConfig(projectRoot);
306
+ fs.mkdirSync(outputDir, { recursive: true });
307
+ const identityPath = writeIdentity(bundlePath, config);
308
+ if (platform === 'macos') {
309
+ return { config, identityPath, ...packageMacos(hostBinary, outputDir, config) };
310
+ }
311
+ if (platform === 'linux') {
312
+ return { config, identityPath, ...packageLinux(hostBinary, outputDir, config) };
313
+ }
314
+ // Windows does its own, in the host: a Start Menu shortcut carrying an
315
+ // AppUserModelID needs IPropertyStore, and doing that in C++ at startup beats
316
+ // doing it in PowerShell from here. See win32/Win32Packaging.h.
317
+ return { config, identityPath, launchPath: hostBinary };
318
+ }
319
+ //# sourceMappingURL=packageApp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageApp.js","sourceRoot":"","sources":["../../cli/packageApp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FH,sCAsDC;AAUD,8BAgDC;AAuHD,sCAuBC;AAED,gCAqBC;AA5WD,4CAA8B;AAC9B,gDAAkC;AAClC,2DAA6C;AAC7C,6CAA0C;AA4E1C;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,WAAmB;IAC/C,IAAI,GAAG,GAAsB,IAAI,CAAC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OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Already right, changed by this run, needs a person, or could not be asked.
3
+ *
4
+ * `unchecked` is the one that earns its place. Whether GTK's headers are
5
+ * installed is not a question a Mac can answer, and reporting it as passing
6
+ * would make the command worse than not running it -- while reporting it as
7
+ * needing a person would send somebody to install GTK on a Mac. It is neither
8
+ * a failure nor a success, so it is counted as neither.
9
+ */
10
+ export type StepState = 'done' | 'changed' | 'blocked' | 'unchecked';
11
+ export type Step = {
12
+ state: StepState;
13
+ message: string;
14
+ };
15
+ export declare const DONE: StepState;
16
+ export declare const CHANGED: StepState;
17
+ export declare const BLOCKED: StepState;
18
+ export declare const UNCHECKED: StepState;
19
+ export declare function step(state: StepState, message: string): Step;
20
+ /** A step and the name it is reported under. */
21
+ export type NamedStep = [string, Step];
22
+ /**
23
+ * Prints the steps and answers with the exit code.
24
+ *
25
+ * `=` already right, `+` this run changed it, `!` somebody has to, `?` could
26
+ * not be asked from here. One character rather than a word so that a column of
27
+ * them reads at a glance, which is the whole reason for reporting steps
28
+ * instead of just failing.
29
+ */
30
+ export declare function report(steps: readonly NamedStep[], out: (line: string) => void): {
31
+ changed: number;
32
+ blocked: number;
33
+ };
34
+ //# sourceMappingURL=steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../cli/steps.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAErE,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,SAAkB,CAAC;AACtC,eAAO,MAAM,OAAO,EAAE,SAAqB,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,SAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,SAAuB,CAAC;AAEhD,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,gDAAgD;AAChD,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEvC;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC1B;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAmBpC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ // What a command checked, and how it says so.
3
+ //
4
+ // `init` and `doctor` are the same checks with writing on and off, so they
5
+ // report the same way: a list of named steps, each already right, changed, or
6
+ // needing a person. The summary is written once at the end rather than printed
7
+ // as it goes, because a run that refuses halfway should not have narrated four
8
+ // successes first.
9
+ //
10
+ // This is shared rather than duplicated for the reason the two commands exist
11
+ // separately at all: `doctor` is `init` with its hands behind its back, plus
12
+ // the checks that have no fix. If they drifted into reporting differently, the
13
+ // second would stop being a straight answer about the first.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UNCHECKED = exports.BLOCKED = exports.CHANGED = exports.DONE = void 0;
16
+ exports.step = step;
17
+ exports.report = report;
18
+ exports.DONE = 'done';
19
+ exports.CHANGED = 'changed';
20
+ exports.BLOCKED = 'blocked';
21
+ exports.UNCHECKED = 'unchecked';
22
+ function step(state, message) {
23
+ return { state, message };
24
+ }
25
+ /**
26
+ * Prints the steps and answers with the exit code.
27
+ *
28
+ * `=` already right, `+` this run changed it, `!` somebody has to, `?` could
29
+ * not be asked from here. One character rather than a word so that a column of
30
+ * them reads at a glance, which is the whole reason for reporting steps
31
+ * instead of just failing.
32
+ */
33
+ function report(steps, out) {
34
+ let changed = 0;
35
+ let blocked = 0;
36
+ const width = steps.reduce((longest, [name]) => Math.max(longest, name.length), 0);
37
+ for (const [name, outcome] of steps) {
38
+ const mark = outcome.state === exports.DONE
39
+ ? '='
40
+ : outcome.state === exports.CHANGED
41
+ ? '+'
42
+ : outcome.state === exports.UNCHECKED
43
+ ? '?'
44
+ : '!';
45
+ out(` ${mark} ${name.padEnd(width)} ${outcome.message}`);
46
+ if (outcome.state === exports.CHANGED)
47
+ changed++;
48
+ if (outcome.state === exports.BLOCKED)
49
+ blocked++;
50
+ }
51
+ return { changed, blocked };
52
+ }
53
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.js","sourceRoot":"","sources":["../../cli/steps.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,mBAAmB;AACnB,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,6DAA6D;;;AAuB7D,oBAEC;AAaD,wBAsBC;AA1CY,QAAA,IAAI,GAAc,MAAM,CAAC;AACzB,QAAA,OAAO,GAAc,SAAS,CAAC;AAC/B,QAAA,OAAO,GAAc,SAAS,CAAC;AAC/B,QAAA,SAAS,GAAc,WAAW,CAAC;AAEhD,SAAgB,IAAI,CAAC,KAAgB,EAAE,OAAe;IACpD,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC;AAC1B,CAAC;AAKD;;;;;;;GAOG;AACH,SAAgB,MAAM,CACpB,KAA2B,EAC3B,GAA2B;IAE3B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,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