crankscript 0.17.0 → 0.18.0-beta.1

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 (284) hide show
  1. package/CHANGELOG.md +11 -5
  2. package/assets/ImportMap/ImportMap.js +26 -65
  3. package/assets/ImportMap/ImportMap.js.map +1 -1
  4. package/assets/ImportMap/index.js +3 -6
  5. package/assets/ImportMap/index.js.map +1 -1
  6. package/assets/beforeEmit/getBeforeEmit.js +11 -16
  7. package/assets/beforeEmit/getBeforeEmit.js.map +1 -1
  8. package/assets/beforeEmit/index.js +3 -6
  9. package/assets/beforeEmit/index.js.map +1 -1
  10. package/assets/beforeEmit/withAutomaticImportWarning.js +4 -11
  11. package/assets/beforeEmit/withAutomaticImportWarning.js.map +1 -1
  12. package/assets/index.js +18 -28
  13. package/assets/index.js.map +1 -1
  14. package/assets/transformCallExpression/getTransformCallExpression.js +66 -18
  15. package/assets/transformCallExpression/getTransformCallExpression.js.map +1 -1
  16. package/assets/transformCallExpression/index.js +3 -6
  17. package/assets/transformCallExpression/index.js.map +1 -1
  18. package/assets/transformClassDeclaration/createClasCall.js +11 -24
  19. package/assets/transformClassDeclaration/createClasCall.js.map +1 -1
  20. package/assets/transformClassDeclaration/getExportedClassDeclarationStatements.js +14 -15
  21. package/assets/transformClassDeclaration/getExportedClassDeclarationStatements.js.map +1 -1
  22. package/assets/transformClassDeclaration/getTransformClassDeclaration.js +47 -43
  23. package/assets/transformClassDeclaration/getTransformClassDeclaration.js.map +1 -1
  24. package/assets/transformClassDeclaration/index.js +3 -6
  25. package/assets/transformClassDeclaration/index.js.map +1 -1
  26. package/assets/transformClassDeclaration/transformConstructor.js +44 -56
  27. package/assets/transformClassDeclaration/transformConstructor.js.map +1 -1
  28. package/assets/transformClassDeclaration/transformMethodDeclaration.js +12 -20
  29. package/assets/transformClassDeclaration/transformMethodDeclaration.js.map +1 -1
  30. package/assets/transformClassDeclaration/transformPropertyName.js +14 -19
  31. package/assets/transformClassDeclaration/transformPropertyName.js.map +1 -1
  32. package/assets/transformExportDeclaration/getTransformExportDeclaration.d.ts +6 -0
  33. package/assets/transformExportDeclaration/getTransformExportDeclaration.js +52 -0
  34. package/assets/transformExportDeclaration/getTransformExportDeclaration.js.map +1 -0
  35. package/assets/transformNewExpression/index.js +3 -6
  36. package/assets/transformNewExpression/index.js.map +1 -1
  37. package/assets/transformNewExpression/isBuiltinNewExpression.js +11 -15
  38. package/assets/transformNewExpression/isBuiltinNewExpression.js.map +1 -1
  39. package/assets/transformNewExpression/transformNewExpression.js +12 -23
  40. package/assets/transformNewExpression/transformNewExpression.js.map +1 -1
  41. package/assets/transformPropertyAccessExpression/a.js +24 -0
  42. package/assets/transformPropertyAccessExpression/a.js.map +1 -0
  43. package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js +6 -13
  44. package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js.map +1 -1
  45. package/assets/transformPropertyAccessExpression/index.js +3 -6
  46. package/assets/transformPropertyAccessExpression/index.js.map +1 -1
  47. package/assets/transformSuperExpression/index.js +3 -6
  48. package/assets/transformSuperExpression/index.js.map +1 -1
  49. package/assets/transformSuperExpression/transformSuperExpression.js +8 -16
  50. package/assets/transformSuperExpression/transformSuperExpression.js.map +1 -1
  51. package/assets/types.js +1 -4
  52. package/assets/types.js.map +1 -1
  53. package/package.json +8 -5
  54. package/src/commands/CompileCommand/CompileCommand.d.ts +1 -1
  55. package/src/commands/CompileCommand/CompileCommand.js +3 -10
  56. package/src/commands/CompileCommand/CompileCommand.js.map +1 -1
  57. package/src/commands/CompileCommand/components/Compile.d.ts +1 -1
  58. package/src/commands/CompileCommand/components/Compile.js +3 -7
  59. package/src/commands/CompileCommand/components/Compile.js.map +1 -1
  60. package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.d.ts +1 -1
  61. package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.js +1 -2
  62. package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.js.map +1 -1
  63. package/src/commands/CompileCommand/hooks/task/compile.d.ts +5 -2
  64. package/src/commands/CompileCommand/hooks/task/compile.js +10 -9
  65. package/src/commands/CompileCommand/hooks/task/compile.js.map +1 -1
  66. package/src/commands/CompileCommand/hooks/useCompileTasks.d.ts +5 -2
  67. package/src/commands/CompileCommand/hooks/useCompileTasks.js +33 -30
  68. package/src/commands/CompileCommand/hooks/useCompileTasks.js.map +1 -1
  69. package/src/commands/CompileCommand/index.js +0 -1
  70. package/src/commands/CompileCommand/index.js.map +1 -1
  71. package/src/commands/DoctorCommand.js +5 -12
  72. package/src/commands/DoctorCommand.js.map +1 -1
  73. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +2 -2
  74. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +30 -30
  75. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js.map +1 -1
  76. package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +1 -1
  77. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +14 -15
  78. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js.map +1 -1
  79. package/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js +5 -10
  80. package/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js.map +1 -1
  81. package/src/commands/EnvironmentAwareCommand/index.js +0 -1
  82. package/src/commands/EnvironmentAwareCommand/index.js.map +1 -1
  83. package/src/commands/GenerateTypes/GenerateTypesCommand.js +14 -21
  84. package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -1
  85. package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +1 -1
  86. package/src/commands/GenerateTypes/components/GenerateTypes.js +11 -15
  87. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
  88. package/src/commands/GenerateTypes/constants.js +0 -1
  89. package/src/commands/GenerateTypes/constants.js.map +1 -1
  90. package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +1 -1
  91. package/src/commands/GenerateTypes/fn/getApiDefinitions.js +12 -14
  92. package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -1
  93. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.d.ts +1 -1
  94. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +38 -30
  95. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -1
  96. package/src/commands/GenerateTypes/fn/getFunctionTypeOverride.js +5 -4
  97. package/src/commands/GenerateTypes/fn/getFunctionTypeOverride.js.map +1 -1
  98. package/src/commands/GenerateTypes/fn/getHtmlForVersion.js +6 -9
  99. package/src/commands/GenerateTypes/fn/getHtmlForVersion.js.map +1 -1
  100. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +13 -10
  101. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
  102. package/src/commands/GenerateTypes/hooks/useFetchHtml.js +10 -12
  103. package/src/commands/GenerateTypes/hooks/useFetchHtml.js.map +1 -1
  104. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +23 -29
  105. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -1
  106. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.d.ts +2 -2
  107. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +44 -75
  108. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
  109. package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +1 -1
  110. package/src/commands/GenerateTypes/hooks/useGetVersion.js +19 -19
  111. package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
  112. package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +1 -1
  113. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +10 -12
  114. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
  115. package/src/commands/GenerateTypes/index.js +0 -1
  116. package/src/commands/GenerateTypes/index.js.map +1 -1
  117. package/src/commands/GenerateTypes/types.d.ts +1 -1
  118. package/src/commands/GenerateTypes/types.js +1 -2
  119. package/src/commands/GenerateTypes/types.js.map +1 -1
  120. package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +2 -2
  121. package/src/commands/GenerateTypes/utils/createTypeProvider.js +63 -85
  122. package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
  123. package/src/commands/GenerateTypes/utils/functionTypeOverrides.d.ts +1 -1
  124. package/src/commands/GenerateTypes/utils/functionTypeOverrides.js +6 -7
  125. package/src/commands/GenerateTypes/utils/functionTypeOverrides.js.map +1 -1
  126. package/src/commands/NewCommand/NewCommand.js +9 -17
  127. package/src/commands/NewCommand/NewCommand.js.map +1 -1
  128. package/src/commands/NewCommand/components/New.d.ts +1 -1
  129. package/src/commands/NewCommand/components/New.js +19 -25
  130. package/src/commands/NewCommand/components/New.js.map +1 -1
  131. package/src/commands/NewLibCommand/NewLibCommand.js +9 -17
  132. package/src/commands/NewLibCommand/NewLibCommand.js.map +1 -1
  133. package/src/commands/NewLibCommand/components/NewLib.d.ts +1 -1
  134. package/src/commands/NewLibCommand/components/NewLib.js +19 -25
  135. package/src/commands/NewLibCommand/components/NewLib.js.map +1 -1
  136. package/src/commands/NewLibCommand/index.js +0 -1
  137. package/src/commands/NewLibCommand/index.js.map +1 -1
  138. package/src/commands/RenderableCommand.d.ts +1 -1
  139. package/src/commands/RenderableCommand.js +5 -3
  140. package/src/commands/RenderableCommand.js.map +1 -1
  141. package/src/commands/SimulatorCommand/SimulatorCommand.d.ts +1 -1
  142. package/src/commands/SimulatorCommand/SimulatorCommand.js +23 -38
  143. package/src/commands/SimulatorCommand/SimulatorCommand.js.map +1 -1
  144. package/src/commands/SimulatorCommand/components/Simulator.d.ts +3 -2
  145. package/src/commands/SimulatorCommand/components/Simulator.js +19 -17
  146. package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
  147. package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.d.ts +1 -1
  148. package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.js +15 -22
  149. package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.js.map +1 -1
  150. package/src/commands/SimulatorCommand/fn/createTemporaryFolderPathFromEntryFile.js +8 -6
  151. package/src/commands/SimulatorCommand/fn/createTemporaryFolderPathFromEntryFile.js.map +1 -1
  152. package/src/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.d.ts +1 -1
  153. package/src/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js +1 -2
  154. package/src/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js.map +1 -1
  155. package/src/commands/SimulatorCommand/hooks/useFileWatcher.js +10 -10
  156. package/src/commands/SimulatorCommand/hooks/useFileWatcher.js.map +1 -1
  157. package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.d.ts +6 -2
  158. package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.js +52 -50
  159. package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.js.map +1 -1
  160. package/src/commands/SimulatorCommand/index.js +0 -1
  161. package/src/commands/SimulatorCommand/index.js.map +1 -1
  162. package/src/commands/TestCommand/TestCommand.d.ts +12 -0
  163. package/src/commands/TestCommand/TestCommand.js +32 -0
  164. package/src/commands/TestCommand/TestCommand.js.map +1 -0
  165. package/src/commands/TestCommand/components/Test.d.ts +9 -0
  166. package/src/commands/TestCommand/components/Test.js +73 -0
  167. package/src/commands/TestCommand/components/Test.js.map +1 -0
  168. package/src/commands/TestCommand/components/TestLine.d.ts +10 -0
  169. package/src/commands/TestCommand/components/TestLine.js +11 -0
  170. package/src/commands/TestCommand/components/TestLine.js.map +1 -0
  171. package/src/commands/TestCommand/components/TestResult.d.ts +8 -0
  172. package/src/commands/TestCommand/components/TestResult.js +21 -0
  173. package/src/commands/TestCommand/components/TestResult.js.map +1 -0
  174. package/src/commands/TestCommand/components/TestSuite.d.ts +8 -0
  175. package/src/commands/TestCommand/components/TestSuite.js +60 -0
  176. package/src/commands/TestCommand/components/TestSuite.js.map +1 -0
  177. package/src/commands/TestCommand/components/TestSummary.d.ts +7 -0
  178. package/src/commands/TestCommand/components/TestSummary.js +9 -0
  179. package/src/commands/TestCommand/components/TestSummary.js.map +1 -0
  180. package/src/commands/TestCommand/hooks/useTestFiles.d.ts +3 -0
  181. package/src/commands/TestCommand/hooks/useTestFiles.js +8 -0
  182. package/src/commands/TestCommand/hooks/useTestFiles.js.map +1 -0
  183. package/src/commands/TestCommand/hooks/useTestServer.d.ts +5 -0
  184. package/src/commands/TestCommand/hooks/useTestServer.js +26 -0
  185. package/src/commands/TestCommand/hooks/useTestServer.js.map +1 -0
  186. package/src/commands/TestCommand/hooks/useTestTasks.d.ts +14 -0
  187. package/src/commands/TestCommand/hooks/useTestTasks.js +61 -0
  188. package/src/commands/TestCommand/hooks/useTestTasks.js.map +1 -0
  189. package/src/commands/TestCommand/index.d.ts +1 -0
  190. package/src/commands/TestCommand/index.js +2 -0
  191. package/src/commands/TestCommand/index.js.map +1 -0
  192. package/src/commands/TestCommand/server/TestServer.d.ts +72 -0
  193. package/src/commands/TestCommand/server/TestServer.js +249 -0
  194. package/src/commands/TestCommand/server/TestServer.js.map +1 -0
  195. package/src/commands/TestCommand/types.d.ts +4 -0
  196. package/src/commands/TestCommand/types.js +6 -0
  197. package/src/commands/TestCommand/types.js.map +1 -0
  198. package/src/commands/TestCommand/utils/formatTestError.d.ts +1 -0
  199. package/src/commands/TestCommand/utils/formatTestError.js +7 -0
  200. package/src/commands/TestCommand/utils/formatTestError.js.map +1 -0
  201. package/src/commands/TranspileCommand/TranspileCommand.d.ts +1 -0
  202. package/src/commands/TranspileCommand/TranspileCommand.js +23 -28
  203. package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
  204. package/src/commands/TranspileCommand/components/Transpile.d.ts +4 -3
  205. package/src/commands/TranspileCommand/components/Transpile.js +4 -7
  206. package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
  207. package/src/commands/TranspileCommand/fn/getErrorMessage.d.ts +1 -1
  208. package/src/commands/TranspileCommand/fn/getErrorMessage.js +5 -6
  209. package/src/commands/TranspileCommand/fn/getErrorMessage.js.map +1 -1
  210. package/src/commands/TranspileCommand/fn/transpile.d.ts +4 -3
  211. package/src/commands/TranspileCommand/fn/transpile.js +21 -24
  212. package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
  213. package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +1 -1
  214. package/src/commands/TranspileCommand/fn/validateEntryPoint.js +2 -3
  215. package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -1
  216. package/src/commands/TranspileCommand/fn/validateExitPoint.d.ts +1 -1
  217. package/src/commands/TranspileCommand/fn/validateExitPoint.js +6 -6
  218. package/src/commands/TranspileCommand/fn/validateExitPoint.js.map +1 -1
  219. package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +6 -5
  220. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +35 -33
  221. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
  222. package/src/commands/TranspileCommand/index.js +0 -1
  223. package/src/commands/TranspileCommand/index.js.map +1 -1
  224. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js +1 -2
  225. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js.map +1 -1
  226. package/src/commands/TranspileCommand/model/ValidatedExitPoint.js +1 -2
  227. package/src/commands/TranspileCommand/model/ValidatedExitPoint.js.map +1 -1
  228. package/src/commands/TranspileCommand/types.js +1 -2
  229. package/src/commands/TranspileCommand/types.js.map +1 -1
  230. package/src/components/CheckList/CheckList.d.ts +3 -2
  231. package/src/components/CheckList/CheckList.js +14 -21
  232. package/src/components/CheckList/CheckList.js.map +1 -1
  233. package/src/components/CheckList/Item.d.ts +3 -2
  234. package/src/components/CheckList/Item.js +47 -44
  235. package/src/components/CheckList/Item.js.map +1 -1
  236. package/src/components/CheckList/index.js +0 -1
  237. package/src/components/CheckList/index.js.map +1 -1
  238. package/src/components/ErrorBoundary.d.ts +14 -0
  239. package/src/components/ErrorBoundary.js +7 -13
  240. package/src/components/ErrorBoundary.js.map +1 -1
  241. package/src/components/Spinner.d.ts +1 -1
  242. package/src/components/Spinner.js +13 -18
  243. package/src/components/Spinner.js.map +1 -1
  244. package/src/constants.js +1 -6
  245. package/src/constants.js.map +1 -1
  246. package/src/environment/createEnvironment.d.ts +1 -1
  247. package/src/environment/createEnvironment.js +13 -16
  248. package/src/environment/createEnvironment.js.map +1 -1
  249. package/src/environment/dto/Environment.d.ts +1 -1
  250. package/src/environment/dto/Environment.js +1 -2
  251. package/src/environment/dto/Environment.js.map +1 -1
  252. package/src/environment/error/EnvironmentError.js +0 -1
  253. package/src/environment/error/EnvironmentError.js.map +1 -1
  254. package/src/environment/path/dto/PlaydateSdkPath.js +3 -4
  255. package/src/environment/path/dto/PlaydateSdkPath.js.map +1 -1
  256. package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js +1 -2
  257. package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js.map +1 -1
  258. package/src/environment/path/getPlaydateSdkPath.js +5 -3
  259. package/src/environment/path/getPlaydateSdkPath.js.map +1 -1
  260. package/src/index.js +7 -5
  261. package/src/index.js.map +1 -1
  262. package/src/types.d.ts +3 -3
  263. package/src/types.js +4 -5
  264. package/src/types.js.map +1 -1
  265. package/src/utils/appendExeOnWindows.js +1 -2
  266. package/src/utils/appendExeOnWindows.js.map +1 -1
  267. package/src/utils/dirname.js +0 -1
  268. package/src/utils/dirname.js.map +1 -1
  269. package/src/utils/platform.js +0 -1
  270. package/src/utils/platform.js.map +1 -1
  271. package/src/commands/TranspileCommand/fn/_tests/test-abstract/src/index.js +0 -4
  272. package/src/commands/TranspileCommand/fn/_tests/test-abstract/src/index.js.map +0 -1
  273. package/src/commands/TranspileCommand/fn/_tests/test-automatic-imports/src/index.js +0 -3
  274. package/src/commands/TranspileCommand/fn/_tests/test-automatic-imports/src/index.js.map +0 -1
  275. package/src/commands/TranspileCommand/fn/_tests/test-builtins/src/index.js +0 -4
  276. package/src/commands/TranspileCommand/fn/_tests/test-builtins/src/index.js.map +0 -1
  277. package/src/commands/TranspileCommand/fn/_tests/test-default-parameters/src/index.js +0 -17
  278. package/src/commands/TranspileCommand/fn/_tests/test-default-parameters/src/index.js.map +0 -1
  279. package/src/commands/TranspileCommand/fn/_tests/test-implicit-constructor/src/index.js +0 -10
  280. package/src/commands/TranspileCommand/fn/_tests/test-implicit-constructor/src/index.js.map +0 -1
  281. package/src/commands/TranspileCommand/fn/_tests/test-static/src/index.js +0 -18
  282. package/src/commands/TranspileCommand/fn/_tests/test-static/src/index.js.map +0 -1
  283. package/src/commands/TranspileCommand/fn/_tests/test-super/src/index.js +0 -24
  284. package/src/commands/TranspileCommand/fn/_tests/test-super/src/index.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { StatusMessage } from '@inkjs/ui';
2
3
  import { Option } from 'clipanion';
3
4
  import { Text } from 'ink';
@@ -7,43 +8,42 @@ import { RenderableCommand } from '../../commands/RenderableCommand.js';
7
8
  import { createEnvironment } from '../../environment/createEnvironment.js';
8
9
  import { CrankScriptProvider } from './contexts/CrankScriptContext.js';
9
10
  export class EnvironmentAwareCommand extends RenderableCommand {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.verbose = Option.Boolean('-vvv,--verbose', false, {
14
+ description: 'Enable verbose logging',
15
+ });
16
+ }
10
17
  render() {
11
18
  if (!this.environment) {
12
19
  throw new Error('Environment is not set');
13
20
  }
14
21
  return this.renderWithEnvironment(this.environment);
15
22
  }
16
- async execute() {
17
- const environmentHealth = createEnvironment();
18
- if (!environmentHealth.isHealthy) {
19
- this.renderElement(/*#__PURE__*/ React.createElement(HealthReport, {
20
- environment: environmentHealth
21
- }));
22
- return;
23
- }
24
- this.environment = environmentHealth.environment;
25
- try {
26
- const toRender = this.render();
27
- this.renderElement(/*#__PURE__*/ React.createElement(CrankScriptProvider, {
28
- verbose: this.verbose
29
- }, toRender));
30
- } catch (error) {
31
- this.renderElement(/*#__PURE__*/ React.createElement(StatusMessage, {
32
- variant: "error"
33
- }, /*#__PURE__*/ React.createElement(Text, {
34
- color: "red"
35
- }, error instanceof Error ? error.message : 'An unknown error occurred', this.verbose && error instanceof Error && error.stack && /*#__PURE__*/ React.createElement(Text, {
36
- color: "red"
37
- }, error.stack))));
38
- process.exit(1);
39
- }
40
- }
41
- constructor(...args){
42
- super(...args);
43
- this.verbose = Option.Boolean('-vvv,--verbose', false, {
44
- description: 'Enable verbose logging'
23
+ execute() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const environmentHealth = createEnvironment();
26
+ if (!environmentHealth.isHealthy) {
27
+ this.renderElement(React.createElement(HealthReport, { environment: environmentHealth }));
28
+ return;
29
+ }
30
+ this.environment = environmentHealth.environment;
31
+ try {
32
+ const toRender = this.render();
33
+ this.renderElement(React.createElement(CrankScriptProvider, { verbose: this.verbose }, toRender));
34
+ }
35
+ catch (error) {
36
+ this.renderElement(React.createElement(StatusMessage, { variant: "error" },
37
+ React.createElement(Text, { color: "red" },
38
+ error instanceof Error
39
+ ? error.message
40
+ : 'An unknown error occurred',
41
+ this.verbose &&
42
+ error instanceof Error &&
43
+ error.stack && (React.createElement(Text, { color: "red" }, error.stack)))));
44
+ process.exit(1);
45
+ }
45
46
  });
46
47
  }
47
48
  }
48
-
49
49
  //# sourceMappingURL=EnvironmentAwareCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.tsx"],"sourcesContent":["import { StatusMessage } from '@inkjs/ui';\nimport { Option } from 'clipanion';\nimport { Text } from 'ink';\nimport React, { JSX } from 'react';\nimport { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { createEnvironment } from '@/cli/environment/createEnvironment.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { CrankScriptProvider } from './contexts/CrankScriptContext.js';\n\nexport abstract class EnvironmentAwareCommand extends RenderableCommand {\n private environment: Environment | undefined;\n\n protected abstract renderWithEnvironment(\n environment: Environment,\n ): JSX.Element;\n\n verbose = Option.Boolean('-vvv,--verbose', false, {\n description: 'Enable verbose logging',\n });\n\n override render() {\n if (!this.environment) {\n throw new Error('Environment is not set');\n }\n\n return this.renderWithEnvironment(this.environment);\n }\n\n override async execute() {\n const environmentHealth = createEnvironment();\n\n if (!environmentHealth.isHealthy) {\n this.renderElement(\n <HealthReport environment={environmentHealth} />,\n );\n\n return;\n }\n\n this.environment = environmentHealth.environment;\n\n try {\n const toRender = this.render();\n this.renderElement(\n <CrankScriptProvider verbose={this.verbose}>\n {toRender}\n </CrankScriptProvider>,\n );\n } catch (error) {\n this.renderElement(\n <StatusMessage variant=\"error\">\n <Text color=\"red\">\n {error instanceof Error\n ? error.message\n : 'An unknown error occurred'}\n {this.verbose &&\n error instanceof Error &&\n error.stack && (\n <Text color=\"red\">{error.stack}</Text>\n )}\n </Text>\n </StatusMessage>,\n );\n\n process.exit(1);\n }\n }\n}\n"],"names":["StatusMessage","Option","Text","React","HealthReport","RenderableCommand","createEnvironment","CrankScriptProvider","EnvironmentAwareCommand","render","environment","Error","renderWithEnvironment","execute","environmentHealth","isHealthy","renderElement","toRender","verbose","error","variant","color","message","stack","process","exit","Boolean","description"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY;AAC1C,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,WAAoB,QAAQ;AACnC,SAASC,YAAY,QAAQ,oEAAoE;AACjG,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,iBAAiB,QAAQ,yCAAyC;AAE3E,SAASC,mBAAmB,QAAQ,mCAAmC;AAEvE,OAAO,MAAeC,gCAAgCH;IAWzCI,SAAS;QACd,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE;YACnB,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAO,IAAI,CAACC,qBAAqB,CAAC,IAAI,CAACF,WAAW;IACtD;IAEA,MAAeG,UAAU;QACrB,MAAMC,oBAAoBR;QAE1B,IAAI,CAACQ,kBAAkBC,SAAS,EAAE;YAC9B,IAAI,CAACC,aAAa,eACd,oBAACZ;gBAAaM,aAAaI;;YAG/B;QACJ;QAEA,IAAI,CAACJ,WAAW,GAAGI,kBAAkBJ,WAAW;QAEhD,IAAI;YACA,MAAMO,WAAW,IAAI,CAACR,MAAM;YAC5B,IAAI,CAACO,aAAa,eACd,oBAACT;gBAAoBW,SAAS,IAAI,CAACA,OAAO;eACrCD;QAGb,EAAE,OAAOE,OAAO;YACZ,IAAI,CAACH,aAAa,eACd,oBAAChB;gBAAcoB,SAAQ;6BACnB,oBAAClB;gBAAKmB,OAAM;eACPF,iBAAiBR,QACZQ,MAAMG,OAAO,GACb,6BACL,IAAI,CAACJ,OAAO,IACTC,iBAAiBR,SACjBQ,MAAMI,KAAK,kBACP,oBAACrB;gBAAKmB,OAAM;eAAOF,MAAMI,KAAK;YAMlDC,QAAQC,IAAI,CAAC;QACjB;IACJ;;;aAlDAP,UAAUjB,OAAOyB,OAAO,CAAC,kBAAkB,OAAO;YAC9CC,aAAa;QACjB;;AAiDJ"}
1
+ {"version":3,"file":"EnvironmentAwareCommand.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mEAAmE,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,MAAM,OAAgB,uBAAwB,SAAQ,iBAAiB;IAAvE;;QAOI,YAAO,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,EAAE;YAC9C,WAAW,EAAE,wBAAwB;SACxC,CAAC,CAAC;IAiDP,CAAC;IA/CY,MAAM;QACX,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IAEc,OAAO;;YAClB,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;YAE9C,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,aAAa,CACd,oBAAC,YAAY,IAAC,WAAW,EAAE,iBAAiB,GAAI,CACnD,CAAC;gBAEF,OAAO;YACX,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC;YAEjD,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC/B,IAAI,CAAC,aAAa,CACd,oBAAC,mBAAmB,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,IACrC,QAAQ,CACS,CACzB,CAAC;YACN,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,CAAC,aAAa,CACd,oBAAC,aAAa,IAAC,OAAO,EAAC,OAAO;oBAC1B,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK;wBACZ,KAAK,YAAY,KAAK;4BACnB,CAAC,CAAC,KAAK,CAAC,OAAO;4BACf,CAAC,CAAC,2BAA2B;wBAChC,IAAI,CAAC,OAAO;4BACT,KAAK,YAAY,KAAK;4BACtB,KAAK,CAAC,KAAK,IAAI,CACX,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,IAAE,KAAK,CAAC,KAAK,CAAQ,CACzC,CACF,CACK,CACnB,CAAC;gBAEF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;QACL,CAAC;KAAA;CACJ"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { EnvironmentHealthResult } from '../../../types.js';
2
+ import { type EnvironmentHealthResult } from '../../../types.js';
3
3
  interface Props {
4
4
  environment: EnvironmentHealthResult;
5
5
  }
@@ -1,41 +1,40 @@
1
1
  import { StatusMessage } from '@inkjs/ui';
2
2
  import { Text } from 'ink';
3
3
  import React from 'react';
4
- import { HealthCheckStatusType } from '../../../types.js';
4
+ import { HealthCheckStatusType, } from '../../../types.js';
5
5
  const SuccessMessages = {
6
6
  sdkPathKnown: {
7
7
  [HealthCheckStatusType.Unknown]: 'SDK path status unknown',
8
- [HealthCheckStatusType.Healthy]: (sdkPath)=>`SDK path found ("${sdkPath.path}")`,
9
- [HealthCheckStatusType.Unhealthy]: 'SDK path not found'
10
- }
8
+ [HealthCheckStatusType.Healthy]: (sdkPath) => `SDK path found ("${sdkPath.path}")`,
9
+ [HealthCheckStatusType.Unhealthy]: 'SDK path not found',
10
+ },
11
11
  };
12
12
  const ColorMap = {
13
13
  [HealthCheckStatusType.Healthy]: 'green',
14
14
  [HealthCheckStatusType.Unhealthy]: 'red',
15
- [HealthCheckStatusType.Unknown]: 'gray'
15
+ [HealthCheckStatusType.Unknown]: 'gray',
16
16
  };
17
- export const HealthReport = ({ environment })=>{
17
+ export const HealthReport = ({ environment }) => {
18
18
  const { health } = environment;
19
- return Object.keys(health).map((eachKey)=>{
19
+ return Object.keys(health).map((eachKey) => {
20
20
  const healthKey = eachKey;
21
21
  const keyHealth = health[healthKey];
22
22
  let variant = 'info';
23
23
  let message = SuccessMessages[healthKey][HealthCheckStatusType.Unknown];
24
24
  if (health[healthKey].healthStatus === HealthCheckStatusType.Unhealthy) {
25
- message = SuccessMessages[healthKey][HealthCheckStatusType.Unhealthy];
25
+ message =
26
+ SuccessMessages[healthKey][HealthCheckStatusType.Unhealthy];
26
27
  variant = 'error';
27
28
  }
28
29
  if (health[healthKey].healthStatus === HealthCheckStatusType.Healthy) {
29
30
  message = SuccessMessages[healthKey][HealthCheckStatusType.Healthy](health[healthKey].argument);
30
31
  variant = 'success';
31
32
  }
32
- return /*#__PURE__*/ React.createElement(StatusMessage, {
33
- key: healthKey,
34
- variant: variant
35
- }, /*#__PURE__*/ React.createElement(Text, {
36
- color: ColorMap[keyHealth.healthStatus]
37
- }, keyHealth.healthStatus === HealthCheckStatusType.Unhealthy && ' ', message));
33
+ return (React.createElement(StatusMessage, { key: healthKey, variant: variant },
34
+ React.createElement(Text, { color: ColorMap[keyHealth.healthStatus] },
35
+ keyHealth.healthStatus ===
36
+ HealthCheckStatusType.Unhealthy && ' ',
37
+ message)));
38
38
  });
39
39
  };
40
-
41
40
  //# sourceMappingURL=HealthReport.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/components/HealthReport.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text, TextProps } from 'ink';\nimport React from 'react';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\nimport {\n EnvironmentHealth,\n EnvironmentHealthResult,\n HealthCheckStatusType,\n} from '@/cli/types.js';\n\ninterface Props {\n environment: EnvironmentHealthResult;\n}\n\nconst SuccessMessages = {\n sdkPathKnown: {\n [HealthCheckStatusType.Unknown]: 'SDK path status unknown',\n [HealthCheckStatusType.Healthy]: (sdkPath: PlaydateSdkPath) =>\n `SDK path found (\"${sdkPath.path}\")`,\n [HealthCheckStatusType.Unhealthy]: 'SDK path not found',\n },\n} as const;\n\nconst ColorMap = {\n [HealthCheckStatusType.Healthy]: 'green',\n [HealthCheckStatusType.Unhealthy]: 'red',\n [HealthCheckStatusType.Unknown]: 'gray',\n} satisfies {\n [key in HealthCheckStatusType]: TextProps['color'];\n};\n\nexport const HealthReport = ({ environment }: Props) => {\n const { health } = environment;\n return Object.keys(health).map(eachKey => {\n const healthKey = eachKey as keyof EnvironmentHealth;\n const keyHealth = health[healthKey];\n\n let variant: StatusMessageProps['variant'] = 'info';\n let message: string =\n SuccessMessages[healthKey][HealthCheckStatusType.Unknown];\n\n if (\n health[healthKey].healthStatus === HealthCheckStatusType.Unhealthy\n ) {\n message =\n SuccessMessages[healthKey][HealthCheckStatusType.Unhealthy];\n variant = 'error';\n }\n\n if (health[healthKey].healthStatus === HealthCheckStatusType.Healthy) {\n message = SuccessMessages[healthKey][HealthCheckStatusType.Healthy](\n health[healthKey].argument,\n );\n variant = 'success';\n }\n\n return (\n <StatusMessage key={healthKey} variant={variant}>\n <Text color={ColorMap[keyHealth.healthStatus]}>\n {keyHealth.healthStatus ===\n HealthCheckStatusType.Unhealthy && ' '}\n {message}\n </Text>\n </StatusMessage>\n );\n });\n};\n"],"names":["StatusMessage","Text","React","HealthCheckStatusType","SuccessMessages","sdkPathKnown","Unknown","Healthy","sdkPath","path","Unhealthy","ColorMap","HealthReport","environment","health","Object","keys","map","eachKey","healthKey","keyHealth","variant","message","healthStatus","argument","key","color"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAA4B,YAAY;AAC9D,SAASC,IAAI,QAAmB,MAAM;AACtC,OAAOC,WAAW,QAAQ;AAE1B,SAGIC,qBAAqB,QAClB,iBAAiB;AAMxB,MAAMC,kBAAkB;IACpBC,cAAc;QACV,CAACF,sBAAsBG,OAAO,CAAC,EAAE;QACjC,CAACH,sBAAsBI,OAAO,CAAC,EAAE,CAACC,UAC9B,CAAC,iBAAiB,EAAEA,QAAQC,IAAI,CAAC,EAAE,CAAC;QACxC,CAACN,sBAAsBO,SAAS,CAAC,EAAE;IACvC;AACJ;AAEA,MAAMC,WAAW;IACb,CAACR,sBAAsBI,OAAO,CAAC,EAAE;IACjC,CAACJ,sBAAsBO,SAAS,CAAC,EAAE;IACnC,CAACP,sBAAsBG,OAAO,CAAC,EAAE;AACrC;AAIA,OAAO,MAAMM,eAAe,CAAC,EAAEC,WAAW,EAAS;IAC/C,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAOE,OAAOC,IAAI,CAACF,QAAQG,GAAG,CAACC,CAAAA;QAC3B,MAAMC,YAAYD;QAClB,MAAME,YAAYN,MAAM,CAACK,UAAU;QAEnC,IAAIE,UAAyC;QAC7C,IAAIC,UACAlB,eAAe,CAACe,UAAU,CAAChB,sBAAsBG,OAAO,CAAC;QAE7D,IACIQ,MAAM,CAACK,UAAU,CAACI,YAAY,KAAKpB,sBAAsBO,SAAS,EACpE;YACEY,UACIlB,eAAe,CAACe,UAAU,CAAChB,sBAAsBO,SAAS,CAAC;YAC/DW,UAAU;QACd;QAEA,IAAIP,MAAM,CAACK,UAAU,CAACI,YAAY,KAAKpB,sBAAsBI,OAAO,EAAE;YAClEe,UAAUlB,eAAe,CAACe,UAAU,CAAChB,sBAAsBI,OAAO,CAAC,CAC/DO,MAAM,CAACK,UAAU,CAACK,QAAQ;YAE9BH,UAAU;QACd;QAEA,qBACI,oBAACrB;YAAcyB,KAAKN;YAAWE,SAASA;yBACpC,oBAACpB;YAAKyB,OAAOf,QAAQ,CAACS,UAAUG,YAAY,CAAC;WACxCH,UAAUG,YAAY,KACnBpB,sBAAsBO,SAAS,IAAI,KACtCY;IAIjB;AACJ,EAAE"}
1
+ {"version":3,"file":"HealthReport.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/components/HealthReport.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2B,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAGH,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,eAAe,GAAG;IACpB,YAAY,EAAE;QACV,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,yBAAyB;QAC1D,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC,OAAwB,EAAE,EAAE,CAC1D,oBAAoB,OAAO,CAAC,IAAI,IAAI;QACxC,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,oBAAoB;KAC1D;CACK,CAAC;AAEX,MAAM,QAAQ,GAAG;IACb,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,OAAO;IACxC,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,KAAK;IACxC,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM;CAG1C,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,WAAW,EAAS,EAAE,EAAE;IACnD,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACvC,MAAM,SAAS,GAAG,OAAkC,CAAC;QACrD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAEpC,IAAI,OAAO,GAAkC,MAAM,CAAC;QACpD,IAAI,OAAO,GACP,eAAe,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAE9D,IACI,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,KAAK,qBAAqB,CAAC,SAAS,EACpE,CAAC;YACC,OAAO;gBACH,eAAe,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;YAChE,OAAO,GAAG,OAAO,CAAC;QACtB,CAAC;QAED,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,KAAK,qBAAqB,CAAC,OAAO,EAAE,CAAC;YACnE,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAC/D,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAC7B,CAAC;YACF,OAAO,GAAG,SAAS,CAAC;QACxB,CAAC;QAED,OAAO,CACH,oBAAC,aAAa,IAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO;YAC3C,oBAAC,IAAI,IAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC;gBACxC,SAAS,CAAC,YAAY;oBACnB,qBAAqB,CAAC,SAAS,IAAI,GAAG;gBACzC,OAAO,CACL,CACK,CACnB,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -1,20 +1,15 @@
1
1
  import React, { createContext, useContext } from 'react';
2
- export const CrankScriptContext = /*#__PURE__*/ createContext({
3
- verbose: false
2
+ export const CrankScriptContext = createContext({
3
+ verbose: false,
4
4
  });
5
- export const CrankScriptProvider = ({ children, verbose })=>{
6
- return /*#__PURE__*/ React.createElement(CrankScriptContext.Provider, {
7
- value: {
8
- verbose
9
- }
10
- }, children);
5
+ export const CrankScriptProvider = ({ children, verbose, }) => {
6
+ return (React.createElement(CrankScriptContext.Provider, { value: { verbose } }, children));
11
7
  };
12
- export const useCrankScriptContext = ()=>{
8
+ export const useCrankScriptContext = () => {
13
9
  const context = useContext(CrankScriptContext);
14
10
  if (!context) {
15
11
  throw new Error('CrankScriptContext not found');
16
12
  }
17
13
  return context;
18
14
  };
19
-
20
15
  //# sourceMappingURL=CrankScriptContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\n\ntype CrankScriptContextType = {\n verbose: boolean;\n};\n\nexport const CrankScriptContext = createContext<CrankScriptContextType>({\n verbose: false,\n});\n\nexport const CrankScriptProvider = ({\n children,\n verbose,\n}: {\n children: React.ReactNode;\n verbose: boolean;\n}) => {\n return (\n <CrankScriptContext.Provider value={{ verbose }}>\n {children}\n </CrankScriptContext.Provider>\n );\n};\n\nexport const useCrankScriptContext = () => {\n const context = useContext(CrankScriptContext);\n\n if (!context) {\n throw new Error('CrankScriptContext not found');\n }\n\n return context;\n};\n"],"names":["React","createContext","useContext","CrankScriptContext","verbose","CrankScriptProvider","children","Provider","value","useCrankScriptContext","context","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAMzD,OAAO,MAAMC,mCAAqBF,cAAsC;IACpEG,SAAS;AACb,GAAG;AAEH,OAAO,MAAMC,sBAAsB,CAAC,EAChCC,QAAQ,EACRF,OAAO,EAIV;IACG,qBACI,oBAACD,mBAAmBI,QAAQ;QAACC,OAAO;YAAEJ;QAAQ;OACzCE;AAGb,EAAE;AAEF,OAAO,MAAMG,wBAAwB;IACjC,MAAMC,UAAUR,WAAWC;IAE3B,IAAI,CAACO,SAAS;QACV,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX,EAAE"}
1
+ {"version":3,"file":"CrankScriptContext.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAyB;IACpE,OAAO,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,QAAQ,EACR,OAAO,GAIV,EAAE,EAAE;IACD,OAAO,CACH,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAC1C,QAAQ,CACiB,CACjC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export * from './EnvironmentAwareCommand.js';
2
-
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/index.ts"],"sourcesContent":["export * from './EnvironmentAwareCommand.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,+BAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -7,39 +7,32 @@ import { RenderableCommand } from '../../commands/RenderableCommand.js';
7
7
  import { PlaydateSdkVersionIdentifier } from '../../types.js';
8
8
  import { GenerateTypes } from './components/GenerateTypes.js';
9
9
  export class GenerateTypesCommand extends RenderableCommand {
10
- render() {
11
- const output = this.output.endsWith('.d.ts') ? this.output : join(this.output, 'playdate.d.ts');
12
- return /*#__PURE__*/ React.createElement(GenerateTypes, {
13
- output: output,
14
- version: this.version,
15
- overwriteJson: this.overwriteJson
16
- });
17
- }
18
- constructor(...args){
19
- super(...args);
10
+ constructor() {
11
+ super(...arguments);
20
12
  this.output = Option.String('-o,--output', process.cwd(), {
21
13
  description: `Where to generate the playdate.d.ts file. Defaults to the current working directory ("${process.cwd()}")`,
22
- validator: t.isString()
14
+ validator: t.isString(),
23
15
  });
24
16
  this.overwriteJson = Option.Boolean('-j,--overwrite-json', false, {
25
- description: 'Overwrite the JSON data file with the new data'
17
+ description: 'Overwrite the JSON data file with the new data',
26
18
  });
27
19
  this.version = Option.String({
28
20
  name: 'version',
29
21
  validator: t.isOneOf([
30
22
  t.isLiteral(PlaydateSdkVersionIdentifier.Latest),
31
- t.matchesRegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/)
32
- ])
23
+ t.matchesRegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/),
24
+ ]),
33
25
  });
34
26
  }
27
+ render() {
28
+ const output = this.output.endsWith('.d.ts')
29
+ ? this.output
30
+ : join(this.output, 'playdate.d.ts');
31
+ return (React.createElement(GenerateTypes, { output: output, version: this.version, overwriteJson: this.overwriteJson }));
32
+ }
35
33
  }
36
- GenerateTypesCommand.paths = [
37
- [
38
- 'generate-types'
39
- ]
40
- ];
34
+ GenerateTypesCommand.paths = [['generate-types']];
41
35
  GenerateTypesCommand.usage = Command.Usage({
42
- description: 'Generate types from the Playdate SDK documentation'
36
+ description: 'Generate types from the Playdate SDK documentation',
43
37
  });
44
-
45
38
  //# sourceMappingURL=GenerateTypesCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"sourcesContent":["import { join } from 'node:path';\nimport * as process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { AnyStrictValidator } from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { PlaydateSdkVersionIdentifier } from '@/cli/types.js';\nimport { GenerateTypes } from './components/GenerateTypes.js';\n\nexport class GenerateTypesCommand extends RenderableCommand {\n static override paths = [['generate-types']];\n static override usage = Command.Usage({\n description: 'Generate types from the Playdate SDK documentation',\n });\n\n output = Option.String('-o,--output', process.cwd(), {\n description: `Where to generate the playdate.d.ts file. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n });\n\n overwriteJson = Option.Boolean('-j,--overwrite-json', false, {\n description: 'Overwrite the JSON data file with the new data',\n });\n\n version = Option.String({\n name: 'version',\n validator: t.isOneOf([\n t.isLiteral(PlaydateSdkVersionIdentifier.Latest),\n t.matchesRegExp(/^[0-9]+\\.[0-9]+\\.[0-9]+$/) as AnyStrictValidator,\n ]),\n });\n\n override render() {\n const output = this.output.endsWith('.d.ts')\n ? this.output\n : join(this.output, 'playdate.d.ts');\n\n return (\n <GenerateTypes\n output={output}\n version={this.version}\n overwriteJson={this.overwriteJson}\n />\n );\n }\n}\n"],"names":["join","process","Command","Option","React","t","RenderableCommand","PlaydateSdkVersionIdentifier","GenerateTypes","GenerateTypesCommand","render","output","endsWith","version","overwriteJson","String","cwd","description","validator","isString","Boolean","name","isOneOf","isLiteral","Latest","matchesRegExp","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,YAAYC,aAAa,eAAe;AACxC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAE9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,4BAA4B,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,OAAO,MAAMC,6BAA6BH;IAuB7BI,SAAS;QACd,MAAMC,SAAS,IAAI,CAACA,MAAM,CAACC,QAAQ,CAAC,WAC9B,IAAI,CAACD,MAAM,GACXX,KAAK,IAAI,CAACW,MAAM,EAAE;QAExB,qBACI,oBAACH;YACGG,QAAQA;YACRE,SAAS,IAAI,CAACA,OAAO;YACrBC,eAAe,IAAI,CAACA,aAAa;;IAG7C;;;aA7BAH,SAASR,OAAOY,MAAM,CAAC,eAAed,QAAQe,GAAG,IAAI;YACjDC,aAAa,CAAC,sFAAsF,EAAEhB,QAAQe,GAAG,GAAG,EAAE,CAAC;YACvHE,WAAWb,EAAEc,QAAQ;QACzB;aAEAL,gBAAgBX,OAAOiB,OAAO,CAAC,uBAAuB,OAAO;YACzDH,aAAa;QACjB;aAEAJ,UAAUV,OAAOY,MAAM,CAAC;YACpBM,MAAM;YACNH,WAAWb,EAAEiB,OAAO,CAAC;gBACjBjB,EAAEkB,SAAS,CAAChB,6BAA6BiB,MAAM;gBAC/CnB,EAAEoB,aAAa,CAAC;aACnB;QACL;;AAeJ;AApCahB,qBACOiB,QAAQ;IAAC;QAAC;KAAiB;CAAC;AADnCjB,qBAEOkB,QAAQzB,QAAQ0B,KAAK,CAAC;IAClCX,aAAa;AACjB"}
1
+ {"version":3,"file":"GenerateTypesCommand.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IAA3D;;QAMI,WAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE;YACjD,WAAW,EAAE,yFAAyF,OAAO,CAAC,GAAG,EAAE,IAAI;YACvH,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE;SAC1B,CAAC,CAAC;QAEH,kBAAa,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,EAAE;YACzD,WAAW,EAAE,gDAAgD;SAChE,CAAC,CAAC;QAEH,YAAO,GAAG,MAAM,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;gBACjB,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,MAAM,CAAC;gBAChD,CAAC,CAAC,aAAa,CAAC,0BAA0B,CAAuB;aACpE,CAAC;SACL,CAAC,CAAC;IAeP,CAAC;IAbY,MAAM;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;YACxC,CAAC,CAAC,IAAI,CAAC,MAAM;YACb,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAEzC,OAAO,CACH,oBAAC,aAAa,IACV,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,aAAa,EAAE,IAAI,CAAC,aAAa,GACnC,CACL,CAAC;IACN,CAAC;;AAlCe,0BAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,AAAvB,CAAwB;AAC7B,0BAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAClC,WAAW,EAAE,oDAAoD;CACpE,CAAC,AAFmB,CAElB"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { PlaydateSdkVersion } from '../../../types.js';
2
+ import type { PlaydateSdkVersion } from '../../../types.js';
3
3
  interface Props {
4
4
  output: string;
5
5
  version: PlaydateSdkVersion;
@@ -5,36 +5,32 @@ import { useGenerateTypeFile } from '../../../commands/GenerateTypes/hooks/useGe
5
5
  import { useGetVersion } from '../../../commands/GenerateTypes/hooks/useGetVersion.js';
6
6
  import { useParseDocumentation } from '../../../commands/GenerateTypes/hooks/useParseDocumentation.js';
7
7
  import { CheckList } from '../../../components/CheckList/index.js';
8
- export const GenerateTypes = ({ output, version, overwriteJson })=>{
8
+ export const GenerateTypes = ({ output, version, overwriteJson }) => {
9
9
  const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);
10
10
  const { html, fetchHtml } = useFetchHtml(fetchedVersion);
11
11
  const { definitions, parseDocumentation } = useParseDocumentation(html, version);
12
12
  const { generateTypeFile } = useGenerateTypeFile(output, definitions, typeProvider);
13
13
  const { formatTypeFile } = useFormatTypeFile(output);
14
- const items = useMemo(()=>{
14
+ const items = useMemo(() => {
15
15
  return [
16
16
  getVersion,
17
17
  fetchHtml,
18
18
  parseDocumentation,
19
19
  generateTypeFile,
20
- formatTypeFile
20
+ formatTypeFile,
21
21
  ];
22
22
  }, [
23
- fetchedVersion,
24
- html,
25
- definitions,
26
- typeProvider,
27
- formatTypeFile
23
+ formatTypeFile,
24
+ getVersion,
25
+ parseDocumentation,
26
+ generateTypeFile,
27
+ fetchHtml,
28
28
  ]);
29
- return /*#__PURE__*/ React.createElement(CheckList, {
30
- items: items,
31
- onFinish: ()=>{
29
+ return (React.createElement(CheckList, { items: items, onFinish: () => {
32
30
  if (overwriteJson) {
33
- typeProvider == null ? void 0 : typeProvider.save();
31
+ typeProvider === null || typeProvider === void 0 ? void 0 : typeProvider.save();
34
32
  }
35
33
  process.exit();
36
- }
37
- });
34
+ } }));
38
35
  };
39
-
40
36
  //# sourceMappingURL=GenerateTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';\nimport { useFormatTypeFile } from '@/cli/commands/GenerateTypes/hooks/useFormatTypeFile.js';\nimport { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';\nimport { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';\nimport { useParseDocumentation } from '@/cli/commands/GenerateTypes/hooks/useParseDocumentation.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, PlaydateSdkVersion } from '@/cli/types.js';\n\ninterface Props {\n output: string;\n version: PlaydateSdkVersion;\n overwriteJson: boolean;\n}\n\nexport const GenerateTypes = ({ output, version, overwriteJson }: Props) => {\n const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { definitions, parseDocumentation } = useParseDocumentation(\n html,\n version,\n );\n const { generateTypeFile } = useGenerateTypeFile(\n output,\n definitions,\n typeProvider,\n );\n const { formatTypeFile } = useFormatTypeFile(output);\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n parseDocumentation,\n generateTypeFile,\n formatTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html, definitions, typeProvider, formatTypeFile]);\n\n return (\n <CheckList\n items={items}\n onFinish={() => {\n if (overwriteJson) {\n typeProvider?.save();\n }\n\n process.exit();\n }}\n />\n );\n};\n"],"names":["React","useMemo","useFetchHtml","useFormatTypeFile","useGenerateTypeFile","useGetVersion","useParseDocumentation","CheckList","GenerateTypes","output","version","overwriteJson","typeProvider","fetchedVersion","getVersion","html","fetchHtml","definitions","parseDocumentation","generateTypeFile","formatTypeFile","items","onFinish","save","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,QAAQ,qDAAqD;AAClF,SAASC,iBAAiB,QAAQ,0DAA0D;AAC5F,SAASC,mBAAmB,QAAQ,4DAA4D;AAChG,SAASC,aAAa,QAAQ,sDAAsD;AACpF,SAASC,qBAAqB,QAAQ,8DAA8D;AACpG,SAASC,SAAS,QAAQ,sCAAsC;AAShE,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAS;IACnE,MAAM,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGT,cAAcK;IACnE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGd,aAAaW;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGZ,sBACxCS,MACAL;IAEJ,MAAM,EAAES,gBAAgB,EAAE,GAAGf,oBACzBK,QACAQ,aACAL;IAEJ,MAAM,EAAEQ,cAAc,EAAE,GAAGjB,kBAAkBM;IAE7C,MAAMY,QAAQpB,QAAQ;QAClB,OAAO;YACHa;YACAE;YACAE;YACAC;YACAC;SACH;IACL,GAAG;QAACP;QAAgBE;QAAME;QAAaL;QAAcQ;KAAe;IAEpE,qBACI,oBAACb;QACGc,OAAOA;QACPC,UAAU;YACN,IAAIX,eAAe;gBACfC,gCAAAA,aAAcW,IAAI;YACtB;YAEAC,QAAQC,IAAI;QAChB;;AAGZ,EAAE"}
1
+ {"version":3,"file":"GenerateTypes.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAShE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAS,EAAE,EAAE;IACvE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5E,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;IACzD,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,qBAAqB,CAC7D,IAAI,EACJ,OAAO,CACV,CAAC;IACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,CAC5C,MAAM,EACN,WAAW,EACX,YAAY,CACf,CAAC;IACF,MAAM,EAAE,cAAc,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAErD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACvB,OAAO;YACH,UAAU;YACV,SAAS;YACT,kBAAkB;YAClB,gBAAgB;YAChB,cAAc;SACW,CAAC;IAClC,CAAC,EAAE;QACC,cAAc;QACd,UAAU;QACV,kBAAkB;QAClB,gBAAgB;QAChB,SAAS;KACZ,CAAC,CAAC;IAEH,OAAO,CACH,oBAAC,SAAS,IACN,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,GAAG,EAAE;YACX,IAAI,aAAa,EAAE,CAAC;gBAChB,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,EAAE,CAAC;YACzB,CAAC;YAED,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,GACH,CACL,CAAC;AACN,CAAC,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export const PlaydateSdkUrl = 'https://sdk.play.date/';
2
-
3
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/constants.ts"],"sourcesContent":["export const PlaydateSdkUrl = 'https://sdk.play.date/';\n"],"names":["PlaydateSdkUrl"],"rangeMappings":"","mappings":"AAAA,OAAO,MAAMA,iBAAiB,yBAAyB"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/commands/GenerateTypes/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC"}
@@ -1,2 +1,2 @@
1
- import { ApiDefinitions, FunctionDescription, PropertyDescription, FunctionTypeOverrideMap } from '../../../types.js';
1
+ import type { ApiDefinitions, FunctionDescription, FunctionTypeOverrideMap, PropertyDescription } from '../../../types.js';
2
2
  export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[], functionTypeOverride: FunctionTypeOverrideMap) => ApiDefinitions;
@@ -1,39 +1,37 @@
1
- export const getApiDefinitions = (functions, properties, functionTypeOverride)=>{
1
+ export const getApiDefinitions = (functions, properties, functionTypeOverride) => {
2
2
  const global = {
3
3
  functions: [],
4
4
  methods: [],
5
5
  properties: [],
6
- namespaces: {}
6
+ namespaces: {},
7
7
  };
8
- const getOrCreateNamespace = (path, root)=>{
9
- return path.reduce((currentNamespace, ns)=>{
8
+ const getOrCreateNamespace = (path, root) => {
9
+ return path.reduce((currentNamespace, ns) => {
10
10
  if (!currentNamespace.namespaces[ns]) {
11
11
  currentNamespace.namespaces[ns] = {
12
12
  functions: [],
13
13
  methods: [],
14
14
  properties: [],
15
- namespaces: {}
15
+ namespaces: {},
16
16
  };
17
17
  }
18
18
  return currentNamespace.namespaces[ns];
19
19
  }, root);
20
20
  };
21
- functions.forEach((func)=>{
22
- var _functionTypeOverride_func_signature;
21
+ functions.forEach((func) => {
22
+ var _a;
23
23
  const targetNamespace = getOrCreateNamespace(func.namespaces, global);
24
- if (func.hasSelf || ((_functionTypeOverride_func_signature = functionTypeOverride[func.signature]) == null ? void 0 : _functionTypeOverride_func_signature.isMethod)) {
24
+ if (func.hasSelf || ((_a = functionTypeOverride[func.signature]) === null || _a === void 0 ? void 0 : _a.isMethod)) {
25
25
  targetNamespace.methods.push(func);
26
- } else {
26
+ }
27
+ else {
27
28
  targetNamespace.functions.push(func);
28
29
  }
29
30
  });
30
- properties.forEach((prop)=>{
31
+ properties.forEach((prop) => {
31
32
  const targetNamespace = getOrCreateNamespace(prop.namespaces, global);
32
33
  targetNamespace.properties.push(prop);
33
34
  });
34
- return {
35
- global
36
- };
35
+ return { global };
37
36
  };
38
-
39
37
  //# sourceMappingURL=getApiDefinitions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n ApiObject,\n PropertyDescription,\n FunctionTypeOverrideMap,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[],\n functionTypeOverride: FunctionTypeOverrideMap,\n): ApiDefinitions => {\n const global: ApiObject = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n\n const getOrCreateNamespace = (\n path: string[],\n root: ApiObject,\n ): ApiObject => {\n return path.reduce((currentNamespace, ns) => {\n if (!currentNamespace.namespaces[ns]) {\n currentNamespace.namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n }\n return currentNamespace.namespaces[ns];\n }, root);\n };\n\n functions.forEach(func => {\n const targetNamespace = getOrCreateNamespace(func.namespaces, global);\n if (func.hasSelf || functionTypeOverride[func.signature]?.isMethod) {\n targetNamespace.methods.push(func);\n } else {\n targetNamespace.functions.push(func);\n }\n });\n\n properties.forEach(prop => {\n const targetNamespace = getOrCreateNamespace(prop.namespaces, global);\n targetNamespace.properties.push(prop);\n });\n\n return { global };\n};\n"],"names":["getApiDefinitions","functions","properties","functionTypeOverride","global","methods","namespaces","getOrCreateNamespace","path","root","reduce","currentNamespace","ns","forEach","func","targetNamespace","hasSelf","signature","isMethod","push","prop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA,OAAO,MAAMA,oBAAoB,CAC7BC,WACAC,YACAC;IAEA,MAAMC,SAAoB;QACtBH,WAAW,EAAE;QACbI,SAAS,EAAE;QACXH,YAAY,EAAE;QACdI,YAAY,CAAC;IACjB;IAEA,MAAMC,uBAAuB,CACzBC,MACAC;QAEA,OAAOD,KAAKE,MAAM,CAAC,CAACC,kBAAkBC;YAClC,IAAI,CAACD,iBAAiBL,UAAU,CAACM,GAAG,EAAE;gBAClCD,iBAAiBL,UAAU,CAACM,GAAG,GAAG;oBAC9BX,WAAW,EAAE;oBACbI,SAAS,EAAE;oBACXH,YAAY,EAAE;oBACdI,YAAY,CAAC;gBACjB;YACJ;YACA,OAAOK,iBAAiBL,UAAU,CAACM,GAAG;QAC1C,GAAGH;IACP;IAEAR,UAAUY,OAAO,CAACC,CAAAA;YAEMX;QADpB,MAAMY,kBAAkBR,qBAAqBO,KAAKR,UAAU,EAAEF;QAC9D,IAAIU,KAAKE,OAAO,MAAIb,uCAAAA,oBAAoB,CAACW,KAAKG,SAAS,CAAC,qBAApCd,qCAAsCe,QAAQ,GAAE;YAChEH,gBAAgBV,OAAO,CAACc,IAAI,CAACL;QACjC,OAAO;YACHC,gBAAgBd,SAAS,CAACkB,IAAI,CAACL;QACnC;IACJ;IAEAZ,WAAWW,OAAO,CAACO,CAAAA;QACf,MAAML,kBAAkBR,qBAAqBa,KAAKd,UAAU,EAAEF;QAC9DW,gBAAgBb,UAAU,CAACiB,IAAI,CAACC;IACpC;IAEA,OAAO;QAAEhB;IAAO;AACpB,EAAE"}
1
+ {"version":3,"file":"getApiDefinitions.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,SAAgC,EAChC,UAAiC,EACjC,oBAA6C,EAC/B,EAAE;IAChB,MAAM,MAAM,GAAc;QACtB,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;KACjB,CAAC;IAEF,MAAM,oBAAoB,GAAG,CACzB,IAAc,EACd,IAAe,EACN,EAAE;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE;YACxC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;gBACnC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG;oBAC9B,SAAS,EAAE,EAAE;oBACb,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,EAAE;oBACd,UAAU,EAAE,EAAE;iBACjB,CAAC;YACN,CAAC;YACD,OAAO,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC3C,CAAC,EAAE,IAAI,CAAC,CAAC;IACb,CAAC,CAAC;IAEF,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;QACvB,MAAM,eAAe,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,IAAI,CAAC,OAAO,KAAI,MAAA,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,QAAQ,CAAA,EAAE,CAAC;YACjE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACJ,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,eAAe,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACtE,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,CAAC;AACtB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FunctionDescription, PropertyDescription } from '../../../types.js';
1
+ import type { FunctionDescription, PropertyDescription } from '../../../types.js';
2
2
  export declare const getDescriptionsFromHtml: (html: string, version: string) => {
3
3
  functions: FunctionDescription[];
4
4
  properties: PropertyDescription[];
@@ -1,49 +1,59 @@
1
- import { _ as _extends } from "@swc/helpers/_/_extends";
2
1
  import { load } from 'cheerio';
3
2
  import Turndown from 'turndown';
4
3
  import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
5
4
  import { parseFunctionSignature } from '../../../commands/GenerateTypes/fn/parseFunctionSignature.js';
6
- const extractFunctionCalls = (input)=>{
5
+ const extractFunctionCalls = (input) => {
7
6
  const functionCallRegex = /([a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*(?::[a-zA-Z_]\w*)?)\s*(\([^)]*\))?/g;
8
7
  const matches = [];
9
- let match;
10
- while((match = functionCallRegex.exec(input)) !== null){
8
+ let match = functionCallRegex.exec(input);
9
+ while (match !== null) {
11
10
  matches.push(match[0].trim());
11
+ match = functionCallRegex.exec(input);
12
12
  }
13
13
  return matches;
14
14
  };
15
- const normalizeSignature = (signature)=>{
15
+ const normalizeSignature = (signature) => {
16
16
  const closingParenIndex = signature.indexOf(')');
17
- return closingParenIndex !== -1 ? signature.slice(0, closingParenIndex + 1) : signature;
17
+ return closingParenIndex !== -1
18
+ ? signature.slice(0, closingParenIndex + 1)
19
+ : signature;
18
20
  };
19
- export const getDescriptionsFromHtml = (html, version)=>{
21
+ export const getDescriptionsFromHtml = (html, version) => {
22
+ var _a, _b;
20
23
  const $ = load(html);
21
24
  const functionSignatures = $('[id^="m-"], [id^="f-"], [id^="c-"], [id^="v-"]').toArray();
22
25
  const functions = [];
23
26
  const properties = [];
24
27
  const visitedSignatures = [];
25
28
  const turndown = new Turndown();
26
- for (const element of functionSignatures){
27
- var _$_attr;
28
- const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
29
+ for (const element of functionSignatures) {
30
+ const id = (_a = $(element).attr('id')) !== null && _a !== void 0 ? _a : '';
29
31
  const isProperty = id.startsWith('v-');
30
32
  const titleText = $(element).find('> .title').text();
31
- if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\[/.test(titleText) || /^-[a-zA-Z]/.test(titleText) || /[+*/]/.test(titleText) || titleText.indexOf(' - ') !== -1 || titleText.indexOf(' .. ') !== -1) {
33
+ if (titleText.indexOf('#') !== -1 ||
34
+ /[a-zA-Z]\[/.test(titleText) ||
35
+ /^-[a-zA-Z]/.test(titleText) ||
36
+ /[+*/]/.test(titleText) ||
37
+ titleText.indexOf(' - ') !== -1 ||
38
+ titleText.indexOf(' .. ') !== -1) {
32
39
  continue;
33
40
  }
34
- const titles = isProperty ? titleText.split(' ') : extractFunctionCalls(titleText);
35
- var _$_find_html;
36
- let docsString = ((_$_find_html = $(element).find('.content').html()) != null ? _$_find_html : '').trim();
41
+ const titles = isProperty
42
+ ? titleText.split(' ')
43
+ : extractFunctionCalls(titleText);
44
+ let docsString = ((_b = $(element).find('.content').html()) !== null && _b !== void 0 ? _b : '').trim();
37
45
  if (docsString.startsWith('<div class="paragraph">')) {
38
46
  docsString = docsString.slice('<div class="paragraph">'.length);
39
47
  }
40
48
  if (docsString.endsWith('</div>')) {
41
49
  docsString = docsString.slice(0, docsString.length - '</div>'.length);
42
50
  }
43
- docsString = docsString.replace(/<a href="#/g, '<a href="' + PlaydateSdkUrl + version + '#');
51
+ docsString = docsString.replace(/<a href="#/g, `<a href="${PlaydateSdkUrl}${version}#`);
44
52
  docsString = turndown.turndown(docsString);
45
- const baseDocs = id ? `${docsString}\n\n[Read more](${PlaydateSdkUrl}${version}#${id})` : docsString;
46
- for (const title of titles){
53
+ const baseDocs = id
54
+ ? `${docsString}\n\n[Read more](${PlaydateSdkUrl}${version}#${id})`
55
+ : docsString;
56
+ for (const title of titles) {
47
57
  const signature = normalizeSignature(title);
48
58
  if (visitedSignatures.includes(signature)) {
49
59
  continue;
@@ -54,25 +64,23 @@ export const getDescriptionsFromHtml = (html, version)=>{
54
64
  name: title.split('.').slice(-1)[0],
55
65
  namespaces: signature.split('.').slice(0, -1),
56
66
  signature,
57
- docs: baseDocs
67
+ docs: baseDocs,
58
68
  });
59
- } else {
69
+ }
70
+ else {
60
71
  try {
61
72
  const description = parseFunctionSignature(signature);
62
- const docs = description.hasSelf ? baseDocs : `${baseDocs}\n\n@noSelf`;
63
- functions.push(_extends({}, description, {
64
- docs
65
- }));
66
- } catch (e) {
67
- // Ignore
73
+ const docs = description.hasSelf
74
+ ? baseDocs
75
+ : `${baseDocs}\n\n@noSelf`;
76
+ functions.push(Object.assign(Object.assign({}, description), { docs }));
77
+ }
78
+ catch (_error) {
79
+ // Ignore
68
80
  }
69
81
  }
70
82
  }
71
83
  }
72
- return {
73
- functions,
74
- properties
75
- };
84
+ return { functions, properties };
76
85
  };
77
-
78
86
  //# sourceMappingURL=getDescriptionsFromHtml.js.map