@glutinum/cli 0.13.0 → 0.14.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 (319) hide show
  1. package/README.md +19 -1
  2. package/dist/Glutinum.Converter/Abbreviations.js +246 -0
  3. package/dist/Glutinum.Converter/FsharpAST.js +87 -28
  4. package/dist/Glutinum.Converter/Generate.js +55 -8
  5. package/dist/Glutinum.Converter/GlueAST.js +333 -34
  6. package/dist/Glutinum.Converter/Log.js +7 -8
  7. package/dist/Glutinum.Converter/Merge.js +683 -31
  8. package/dist/Glutinum.Converter/Packages.js +308 -0
  9. package/dist/Glutinum.Converter/Printer.js +323 -186
  10. package/dist/Glutinum.Converter/Read.js +279 -6
  11. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +13 -7
  12. package/dist/Glutinum.Converter/Reader/Declaration.js +102 -17
  13. package/dist/Glutinum.Converter/Reader/Documentation.js +168 -73
  14. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +7 -51
  15. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +64 -15
  16. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +165 -0
  17. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -5
  18. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +122 -4
  19. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +83 -7
  20. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +8 -8
  21. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +11 -9
  22. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +3 -2
  23. package/dist/Glutinum.Converter/Reader/Node.js +24 -10
  24. package/dist/Glutinum.Converter/Reader/Parameters.js +110 -7
  25. package/dist/Glutinum.Converter/Reader/Report.js +31 -12
  26. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +4 -3
  27. package/dist/Glutinum.Converter/Reader/TypeNode.js +1524 -253
  28. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +75 -20
  29. package/dist/Glutinum.Converter/Reader/TypeParameters.js +8 -5
  30. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +184 -50
  31. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +32 -13
  32. package/dist/Glutinum.Converter/Reader/Types.js +180 -0
  33. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +99 -43
  34. package/dist/Glutinum.Converter/Reader/Utils.js +1143 -55
  35. package/dist/Glutinum.Converter/Reader/VariableStatement.js +59 -14
  36. package/dist/Glutinum.Converter/Transform.js +8292 -1119
  37. package/dist/Glutinum.Converter/TypeScript.Extensions.js +3 -3
  38. package/dist/Glutinum.Converter/TypeScript.js +3 -3
  39. package/dist/Glutinum.Converter/Utils/Keywords.js +6 -6
  40. package/dist/Glutinum.Converter/Utils/List.js +3 -3
  41. package/dist/Glutinum.Converter/Utils/Naming.js +61 -12
  42. package/dist/Glutinum.Converter/Utils/String.js +7 -3
  43. package/dist/Program.js +230 -72
  44. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  45. package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/AsyncIterable.fs.js +29 -29
  46. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  47. package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/Promise.fs +842 -766
  48. package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/Promise.fs.js +26 -12
  49. package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/PromiseImpl.fs +31 -31
  50. package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/PromiseImpl.fs.js +5 -5
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  53. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AssemblyInfo.fs +4 -4
  54. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Async.fs +89 -9
  55. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Async.fs.js +13 -12
  56. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOption.fs +50 -4
  57. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionCE.fs +30 -39
  58. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionCE.fs.js +10 -10
  59. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResult.fs +52 -8
  60. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultCE.fs +26 -42
  61. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultCE.fs.js +3 -3
  62. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOption.fs +17 -5
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  64. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionCE.fs +31 -33
  65. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionCE.fs.js +3 -3
  66. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidation.fs +1 -6
  67. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationCE.fs +10 -18
  68. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationCE.fs.js +3 -3
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  70. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/List.fs +68 -10
  71. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/List.fs.js +47 -41
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  73. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Option.fs +133 -2
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  76. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/OptionOp.fs +3 -3
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  84. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Result.fs +87 -0
  85. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Result.fs.js +8 -8
  86. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultCE.fs +8 -23
  87. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultCE.fs.js +5 -5
  88. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOption.fs +1 -1
  89. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOption.fs.js +10 -10
  90. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionCE.fs +7 -18
  91. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionCE.fs.js +3 -3
  92. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  93. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  94. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Validation.fs +0 -5
  95. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationCE.fs +7 -13
  96. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationCE.fs.js +3 -3
  97. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValueOption.fs +1 -4
  98. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  99. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  100. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  101. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +3 -3
  102. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  103. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1 → FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0}/FsToolkit.ErrorHandling.AssemblyInfo.fs +4 -4
  104. package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +4 -4
  105. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  106. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Array.js +192 -86
  107. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Async.js +58 -53
  108. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/AsyncBuilder.js +29 -8
  109. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/BigInt.js +71 -46
  110. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/BitConverter.js +2 -2
  111. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Boolean.js +4 -3
  112. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  113. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Char.js +64 -31
  114. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Choice.js +2 -2
  115. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  117. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Date.js +197 -112
  118. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/DateOffset.js +46 -62
  119. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/DateOnly.js +6 -6
  120. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  124. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Decimal.js +39 -13
  125. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  126. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Double.js +10 -3
  127. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Encoding.js +20 -8
  128. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  129. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Event.js +10 -1
  130. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  134. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Guid.js +33 -12
  135. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Int32.js +17 -17
  136. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/List.js +170 -106
  137. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  138. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MailboxProcessor.js +13 -6
  139. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Map.js +65 -61
  140. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MapUtil.js +22 -4
  141. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MutableMap.js +28 -16
  142. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MutableSet.js +7 -7
  143. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  144. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Numeric.js +44 -3
  145. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Observable.js +5 -3
  146. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Option.js +11 -20
  147. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  148. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Random.js +22 -20
  149. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Range.js +12 -12
  150. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Reflection.js +50 -22
  151. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/RegExp.js +68 -30
  152. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Result.js +6 -6
  153. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Seq.js +229 -104
  154. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Seq2.js +1 -1
  155. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Set.js +153 -113
  156. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/String.js +238 -50
  157. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/System.Collections.Generic.js +30 -14
  158. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/System.Text.js +69 -31
  159. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  160. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  161. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  162. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/TimeOnly.js +6 -6
  163. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  164. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/TimeSpan.js +18 -15
  165. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  166. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Types.js +14 -24
  167. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Uri.js +44 -21
  168. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Util.js +49 -12
  169. package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/lib/big.js +14 -11
  170. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  171. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  172. package/package.json +4 -4
  173. package/src/Glutinum.Converter/js/bootstrap.js +109 -2
  174. package/src/Glutinum.Converter/js/host.js +144 -0
  175. package/src/Glutinum.Converter/js/npm.js +137 -0
  176. package/src/Glutinum.Converter/js/resolve.js +402 -0
  177. package/dist/Glutinum.Converter/FsharpAST.js.map +0 -1
  178. package/dist/Glutinum.Converter/Generate.js.map +0 -1
  179. package/dist/Glutinum.Converter/GlueAST.js.map +0 -1
  180. package/dist/Glutinum.Converter/Log.js.map +0 -1
  181. package/dist/Glutinum.Converter/Merge.js.map +0 -1
  182. package/dist/Glutinum.Converter/Printer.js.map +0 -1
  183. package/dist/Glutinum.Converter/Read.js.map +0 -1
  184. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +0 -1
  185. package/dist/Glutinum.Converter/Reader/Declaration.js.map +0 -1
  186. package/dist/Glutinum.Converter/Reader/Documentation.js.map +0 -1
  187. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +0 -1
  188. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +0 -1
  189. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +0 -1
  190. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +0 -1
  191. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +0 -1
  192. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js.map +0 -1
  193. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +0 -1
  194. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +0 -1
  195. package/dist/Glutinum.Converter/Reader/Node.js.map +0 -1
  196. package/dist/Glutinum.Converter/Reader/Parameters.js.map +0 -1
  197. package/dist/Glutinum.Converter/Reader/Report.js.map +0 -1
  198. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +0 -1
  199. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +0 -1
  200. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +0 -1
  201. package/dist/Glutinum.Converter/Reader/TypeParameters.js.map +0 -1
  202. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js.map +0 -1
  203. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +0 -1
  204. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +0 -1
  205. package/dist/Glutinum.Converter/Reader/Utils.js.map +0 -1
  206. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +0 -1
  207. package/dist/Glutinum.Converter/Transform.js.map +0 -1
  208. package/dist/Glutinum.Converter/TypeScript.Extensions.js.map +0 -1
  209. package/dist/Glutinum.Converter/TypeScript.js.map +0 -1
  210. package/dist/Glutinum.Converter/Utils/Keywords.js.map +0 -1
  211. package/dist/Glutinum.Converter/Utils/List.js.map +0 -1
  212. package/dist/Glutinum.Converter/Utils/Naming.js.map +0 -1
  213. package/dist/Glutinum.Converter/Utils/String.js.map +0 -1
  214. package/dist/Program.js.map +0 -1
  215. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs +0 -57
  216. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js.map +0 -1
  217. package/dist/fable_modules/Fable.Promise.3.2.0/Fable.Promise.fableproj +0 -20
  218. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js.map +0 -1
  219. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js.map +0 -1
  220. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js.map +0 -1
  221. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js.map +0 -1
  222. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js.map +0 -1
  223. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js +0 -26
  224. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js.map +0 -1
  225. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js.map +0 -1
  226. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js.map +0 -1
  227. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/FsToolkit.ErrorHandling.fableproj +0 -51
  228. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js.map +0 -1
  229. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs +0 -186
  230. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js +0 -18
  231. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js.map +0 -1
  232. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js.map +0 -1
  233. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js.map +0 -1
  234. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js.map +0 -1
  235. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js.map +0 -1
  236. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs +0 -19
  237. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js +0 -31
  238. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js.map +0 -1
  239. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs +0 -22
  240. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js +0 -18
  241. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js.map +0 -1
  242. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js.map +0 -1
  243. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOptionCE.fs +0 -165
  244. package/dist/fable_modules/fable-library-js.4.14.0/Array.d.ts +0 -123
  245. package/dist/fable_modules/fable-library-js.4.14.0/Async.d.ts +0 -32
  246. package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.d.ts +0 -59
  247. package/dist/fable_modules/fable-library-js.4.14.0/BigInt.d.ts +0 -115
  248. package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.d.ts +0 -27
  249. package/dist/fable_modules/fable-library-js.4.14.0/Boolean.d.ts +0 -3
  250. package/dist/fable_modules/fable-library-js.4.14.0/CHANGELOG.md +0 -37
  251. package/dist/fable_modules/fable-library-js.4.14.0/Char.d.ts +0 -65
  252. package/dist/fable_modules/fable-library-js.4.14.0/Choice.d.ts +0 -121
  253. package/dist/fable_modules/fable-library-js.4.14.0/Date.d.ts +0 -70
  254. package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.d.ts +0 -63
  255. package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.d.ts +0 -18
  256. package/dist/fable_modules/fable-library-js.4.14.0/Decimal.d.ts +0 -45
  257. package/dist/fable_modules/fable-library-js.4.14.0/Double.d.ts +0 -11
  258. package/dist/fable_modules/fable-library-js.4.14.0/Encoding.d.ts +0 -12
  259. package/dist/fable_modules/fable-library-js.4.14.0/Event.d.ts +0 -31
  260. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.d.ts +0 -7
  261. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.js +0 -27
  262. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.d.ts +0 -12
  263. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.d.ts +0 -17
  264. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.js +0 -69
  265. package/dist/fable_modules/fable-library-js.4.14.0/Global.d.ts +0 -24
  266. package/dist/fable_modules/fable-library-js.4.14.0/Global.js +0 -8
  267. package/dist/fable_modules/fable-library-js.4.14.0/Guid.d.ts +0 -10
  268. package/dist/fable_modules/fable-library-js.4.14.0/Int32.d.ts +0 -28
  269. package/dist/fable_modules/fable-library-js.4.14.0/List.d.ts +0 -143
  270. package/dist/fable_modules/fable-library-js.4.14.0/Long.d.ts +0 -3
  271. package/dist/fable_modules/fable-library-js.4.14.0/Long.js +0 -46
  272. package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.d.ts +0 -25
  273. package/dist/fable_modules/fable-library-js.4.14.0/Map.d.ts +0 -178
  274. package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.d.ts +0 -10
  275. package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.d.ts +0 -52
  276. package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.d.ts +0 -39
  277. package/dist/fable_modules/fable-library-js.4.14.0/Native.d.ts +0 -2
  278. package/dist/fable_modules/fable-library-js.4.14.0/Native.js +0 -8
  279. package/dist/fable_modules/fable-library-js.4.14.0/Numeric.d.ts +0 -19
  280. package/dist/fable_modules/fable-library-js.4.14.0/Observable.d.ts +0 -32
  281. package/dist/fable_modules/fable-library-js.4.14.0/Option.d.ts +0 -28
  282. package/dist/fable_modules/fable-library-js.4.14.0/Random.d.ts +0 -37
  283. package/dist/fable_modules/fable-library-js.4.14.0/Range.d.ts +0 -12
  284. package/dist/fable_modules/fable-library-js.4.14.0/Reflection.d.ts +0 -119
  285. package/dist/fable_modules/fable-library-js.4.14.0/RegExp.d.ts +0 -10
  286. package/dist/fable_modules/fable-library-js.4.14.0/Result.d.ts +0 -37
  287. package/dist/fable_modules/fable-library-js.4.14.0/Seq.d.ts +0 -165
  288. package/dist/fable_modules/fable-library-js.4.14.0/Seq2.d.ts +0 -18
  289. package/dist/fable_modules/fable-library-js.4.14.0/Set.d.ts +0 -190
  290. package/dist/fable_modules/fable-library-js.4.14.0/String.d.ts +0 -50
  291. package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.d.ts +0 -79
  292. package/dist/fable_modules/fable-library-js.4.14.0/System.Text.d.ts +0 -38
  293. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.d.ts +0 -5
  294. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.js +0 -5
  295. package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.d.ts +0 -15
  296. package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.d.ts +0 -34
  297. package/dist/fable_modules/fable-library-js.4.14.0/Timer.d.ts +0 -19
  298. package/dist/fable_modules/fable-library-js.4.14.0/Types.d.ts +0 -58
  299. package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.d.ts +0 -2
  300. package/dist/fable_modules/fable-library-js.4.14.0/Uri.d.ts +0 -29
  301. package/dist/fable_modules/fable-library-js.4.14.0/Util.d.ts +0 -207
  302. package/dist/fable_modules/fable-library-js.4.14.0/lib/big.d.ts +0 -5
  303. package/dist/fable_modules/fable-library-js.4.14.0/package.json +0 -24
  304. package/dist/fable_modules/project_cracked.json +0 -1
  305. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionOp.fs +0 -0
  306. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOp.fs +0 -0
  307. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionOp.fs +0 -0
  308. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationOp.fs +0 -0
  309. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOp.fs +0 -0
  310. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionOp.fs +0 -0
  311. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationOp.fs +0 -0
  312. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -0
  313. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
  314. /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -0
  315. /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/FSharp.Core.CompilerServices.js +0 -0
  316. /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/README.md +0 -0
  317. /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Timer.js +0 -0
  318. /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Unicode.13.0.0.js +0 -0
  319. /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/big.d.ts +0 -0
@@ -1,20 +1,12 @@
1
- import { OperationCanceledError, Trampoline } from "./AsyncBuilder.js";
1
+ import { OperationCanceledException, Trampoline } from "./AsyncBuilder.js";
2
2
  import { CancellationToken } from "./AsyncBuilder.js";
3
- import { protectedCont } from "./AsyncBuilder.js";
4
- import { protectedBind } from "./AsyncBuilder.js";
5
- import { protectedReturn } from "./AsyncBuilder.js";
3
+ import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.js";
6
4
  import { Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.js";
7
- import { TimeoutException } from "./SystemException.js";
8
- // Implemented just for type references
9
- export class Async {
10
- }
5
+ import { TimeoutException_$ctor } from "./System.js";
6
+ import { Exception } from "./Util.js";
11
7
  function emptyContinuation(_x) {
12
8
  // NOP
13
9
  }
14
- // see AsyncBuilder.Delay
15
- function delay(generator) {
16
- return protectedCont((ctx) => generator()(ctx));
17
- }
18
10
  // MakeAsync: body:(AsyncActivation<'T> -> AsyncReturn) -> Async<'T>
19
11
  export function makeAsync(body) {
20
12
  return body;
@@ -49,36 +41,54 @@ export function isCancellationRequested(token) {
49
41
  }
50
42
  export function throwIfCancellationRequested(token) {
51
43
  if (token != null && token.isCancelled) {
52
- throw new Error("Operation is cancelled");
44
+ throw new Exception("Operation is cancelled");
53
45
  }
54
46
  }
55
- function throwAfter(millisecondsDueTime) {
47
+ export function startChild(computation, ms) {
48
+ return protectedCont((ctx) => {
49
+ // Share the parent's cancellation token so cancelling the parent
50
+ // cancels the child, like .NET Async.StartChild
51
+ const promise = startAsPromise(computation, ctx.cancelToken);
52
+ let promiseToRun = promise;
53
+ if (ms) {
54
+ // Race the computation against a timeout: whichever settles first wins.
55
+ promiseToRun = new Promise((resolve, reject) => {
56
+ const timeoutId = setTimeout(() => reject(TimeoutException_$ctor()), ms);
57
+ promise.then(value => { clearTimeout(timeoutId); resolve(value); }, error => { clearTimeout(timeoutId); reject(error); });
58
+ });
59
+ }
60
+ // Prevent an unhandled rejection when the child is cancelled or fails
61
+ // while nobody awaits it (in F# an unobserved child's cancellation or
62
+ // failure is simply not propagated). awaitPromise attaches its own
63
+ // handlers to the same promise, so awaiting still observes the result.
64
+ promiseToRun.catch(emptyContinuation);
65
+ // JS Promises are hot, computation has already started
66
+ // but we delay returning the result
67
+ protectedReturn(awaitPromise(promiseToRun))(ctx);
68
+ });
69
+ }
70
+ export function awaitPromise(p) {
71
+ return fromContinuations((conts) => p.then(conts[0]).catch((err) => (err instanceof OperationCanceledException
72
+ ? conts[2] : conts[1])(err)));
73
+ }
74
+ export function awaitEvent(event, cancelAction) {
56
75
  return protectedCont((ctx) => {
57
76
  let tokenId;
58
- const timeoutId = setTimeout(() => {
77
+ const handler = ((_sender, arg) => {
59
78
  ctx.cancelToken.removeListener(tokenId);
60
- ctx.onError(new TimeoutException());
61
- }, millisecondsDueTime);
79
+ event.RemoveHandler(handler);
80
+ ctx.onSuccess(arg);
81
+ });
62
82
  tokenId = ctx.cancelToken.addListener(() => {
63
- clearTimeout(timeoutId);
64
- ctx.onCancel(new OperationCanceledError());
83
+ event.RemoveHandler(handler);
84
+ if (cancelAction != null) {
85
+ cancelAction();
86
+ }
87
+ ctx.onCancel(new OperationCanceledException());
65
88
  });
89
+ event.AddHandler(handler);
66
90
  });
67
91
  }
68
- export function startChild(computation, ms) {
69
- if (ms) {
70
- const computationWithTimeout = protectedBind(parallel2(computation, throwAfter(ms)), xs => protectedReturn(xs[0]));
71
- return startChild(computationWithTimeout);
72
- }
73
- const promise = startAsPromise(computation);
74
- // JS Promises are hot, computation has already started
75
- // but we delay returning the result
76
- return protectedCont((ctx) => protectedReturn(awaitPromise(promise))(ctx));
77
- }
78
- export function awaitPromise(p) {
79
- return fromContinuations((conts) => p.then(conts[0]).catch((err) => (err instanceof OperationCanceledError
80
- ? conts[2] : conts[1])(err)));
81
- }
82
92
  export function cancellationToken() {
83
93
  return protectedCont((ctx) => ctx.onSuccess(ctx.cancelToken));
84
94
  }
@@ -101,20 +111,19 @@ export function ignore(computation) {
101
111
  return protectedBind(computation, (_x) => protectedReturn(void 0));
102
112
  }
103
113
  export function parallel(computations) {
104
- return delay(() => awaitPromise(Promise.all(Array.from(computations, (w) => startAsPromise(w)))));
105
- }
106
- function parallel2(a, b) {
107
- return delay(() => awaitPromise(Promise.all([startAsPromise(a), startAsPromise(b)])));
114
+ // Children share the parent's cancellation token, like .NET Async.Parallel
115
+ return protectedCont((ctx) => awaitPromise(Promise.all(Array.from(computations, (w) => startAsPromise(w, ctx.cancelToken))))(ctx));
108
116
  }
109
117
  export function sequential(computations) {
110
- function _sequential(computations) {
118
+ function _sequential(computations, cancelToken) {
111
119
  let pr = Promise.resolve([]);
112
120
  for (const c of computations) {
113
- pr = pr.then(results => startAsPromise(c).then(r => results.concat([r])));
121
+ pr = pr.then(results => startAsPromise(c, cancelToken).then(r => results.concat([r])));
114
122
  }
115
123
  return pr;
116
124
  }
117
- return delay(() => awaitPromise(_sequential(computations)));
125
+ // Children share the parent's cancellation token, like .NET Async.Sequential
126
+ return protectedCont((ctx) => awaitPromise(_sequential(computations, ctx.cancelToken))(ctx));
118
127
  }
119
128
  export function sleep(millisecondsDueTime) {
120
129
  return protectedCont((ctx) => {
@@ -125,29 +134,26 @@ export function sleep(millisecondsDueTime) {
125
134
  }, millisecondsDueTime);
126
135
  tokenId = ctx.cancelToken.addListener(() => {
127
136
  clearTimeout(timeoutId);
128
- ctx.onCancel(new OperationCanceledError());
137
+ ctx.onCancel(new OperationCanceledException());
129
138
  });
130
139
  });
131
140
  }
132
- export function runSynchronously() {
133
- throw new Error("Asynchronous code cannot be run synchronously in JS");
134
- }
135
141
  export function start(computation, cancellationToken) {
136
- return startWithContinuations(computation, cancellationToken);
142
+ return startWithContinuations(computation, emptyContinuation, function (err) { throw err; }, emptyContinuation, cancellationToken);
137
143
  }
138
144
  export function startImmediate(computation, cancellationToken) {
139
145
  return start(computation, cancellationToken);
140
146
  }
141
147
  export function startWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, cancelToken) {
142
- if (typeof continuation !== "function") {
143
- cancelToken = continuation;
144
- continuation = undefined;
145
- }
146
148
  const trampoline = new Trampoline();
149
+ // Mark the computation completed as soon as a terminal continuation is entered
150
+ // so protectedCont lets exceptions from continuation code propagate instead of
151
+ // routing them to onError (see Trampoline.completed).
152
+ const done = (cont) => (x) => { trampoline.completed = true; return cont(x); };
147
153
  computation({
148
- onSuccess: continuation ? continuation : emptyContinuation,
149
- onError: exceptionContinuation ? exceptionContinuation : emptyContinuation,
150
- onCancel: cancellationContinuation ? cancellationContinuation : emptyContinuation,
154
+ onSuccess: done(continuation ? continuation : emptyContinuation),
155
+ onError: done(exceptionContinuation),
156
+ onCancel: done(cancellationContinuation),
151
157
  cancelToken: cancelToken ? cancelToken : defaultCancellationToken,
152
158
  trampoline,
153
159
  });
@@ -155,4 +161,3 @@ export function startWithContinuations(computation, continuation, exceptionConti
155
161
  export function startAsPromise(computation, cancellationToken) {
156
162
  return new Promise((resolve, reject) => startWithContinuations(computation, resolve, reject, reject, cancellationToken ? cancellationToken : defaultCancellationToken));
157
163
  }
158
- export default Async;
@@ -1,4 +1,4 @@
1
- import { ensureErrorOrException } from './Types.js';
1
+ import { Exception, ensureErrorOrException } from "./Util.js";
2
2
  export class CancellationToken {
3
3
  constructor(cancelled = false) {
4
4
  this._id = 0;
@@ -35,10 +35,10 @@ export class CancellationToken {
35
35
  // https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtokensource.dispose?view=net-6.0
36
36
  }
37
37
  }
38
- export class OperationCanceledError extends Error {
39
- constructor() {
40
- super("The operation was canceled");
41
- Object.setPrototypeOf(this, OperationCanceledError.prototype);
38
+ export class OperationCanceledException extends Exception {
39
+ constructor(msg) {
40
+ super(msg ?? "The operation was canceled");
41
+ // Object.setPrototypeOf(this, OperationCanceledException.prototype);
42
42
  }
43
43
  }
44
44
  export class Trampoline {
@@ -47,6 +47,7 @@ export class Trampoline {
47
47
  }
48
48
  constructor() {
49
49
  this.callCount = 0;
50
+ this.completed = false;
50
51
  }
51
52
  incrementAndCheck() {
52
53
  return this.callCount++ > Trampoline.maxTrampolineCallCount;
@@ -59,7 +60,7 @@ export class Trampoline {
59
60
  export function protectedCont(f) {
60
61
  return (ctx) => {
61
62
  if (ctx.cancelToken.isCancelled) {
62
- ctx.onCancel(new OperationCanceledError());
63
+ ctx.onCancel(new OperationCanceledException());
63
64
  }
64
65
  else if (ctx.trampoline.incrementAndCheck()) {
65
66
  ctx.trampoline.hijack(() => {
@@ -67,6 +68,9 @@ export function protectedCont(f) {
67
68
  f(ctx);
68
69
  }
69
70
  catch (err) {
71
+ if (ctx.trampoline.completed) {
72
+ throw err;
73
+ }
70
74
  ctx.onError(ensureErrorOrException(err));
71
75
  }
72
76
  });
@@ -76,6 +80,13 @@ export function protectedCont(f) {
76
80
  f(ctx);
77
81
  }
78
82
  catch (err) {
83
+ // Once a terminal continuation has run the computation is complete, so
84
+ // an exception from user continuation code must propagate rather than be
85
+ // routed to onError (which would resolve the computation a second time,
86
+ // e.g. a succeeded try/with body re-entering its with handler).
87
+ if (ctx.trampoline.completed) {
88
+ throw err;
89
+ }
79
90
  ctx.onError(ensureErrorOrException(err));
80
91
  }
81
92
  }
@@ -85,12 +96,18 @@ export function protectedBind(computation, binder) {
85
96
  return protectedCont((ctx) => {
86
97
  computation({
87
98
  onSuccess: (x) => {
99
+ // Only guard the binder evaluation itself: the resulting computation
100
+ // is protected on its own, and re-catching what it throws would
101
+ // route continuation exceptions back into onError (double-resolve).
102
+ let bound;
88
103
  try {
89
- binder(x)(ctx);
104
+ bound = binder(x);
90
105
  }
91
106
  catch (err) {
92
107
  ctx.onError(ensureErrorOrException(err));
108
+ return;
93
109
  }
110
+ bound(ctx);
94
111
  },
95
112
  onError: ctx.onError,
96
113
  onCancel: ctx.onCancel,
@@ -155,12 +172,16 @@ export class AsyncBuilder {
155
172
  cancelToken: ctx.cancelToken,
156
173
  trampoline: ctx.trampoline,
157
174
  onError: (ex) => {
175
+ // See protectedBind: only guard the handler evaluation itself.
176
+ let handled;
158
177
  try {
159
- catchHandler(ex)(ctx);
178
+ handled = catchHandler(ex);
160
179
  }
161
180
  catch (err) {
162
181
  ctx.onError(ensureErrorOrException(err));
182
+ return;
163
183
  }
184
+ handled(ctx);
164
185
  },
165
186
  });
166
187
  });
@@ -1,5 +1,5 @@
1
1
  import { fromParts, truncate } from "./Decimal.js";
2
- import { bigintHash } from "./Util.js";
2
+ import { Exception, bigintHash } from "./Util.js";
3
3
  const isBigEndian = false;
4
4
  BigInt.prototype.toJSON = function () {
5
5
  return `${this.toString()}`;
@@ -95,26 +95,53 @@ export function fromByteArray(bytes) {
95
95
  export function toByteArray(value) {
96
96
  return toSignedBytes(value, isBigEndian);
97
97
  }
98
- export function toInt8(x) { return Number(BigInt.asIntN(8, x)); }
99
- export function toUInt8(x) { return Number(BigInt.asUintN(8, x)); }
100
- export function toInt16(x) { return Number(BigInt.asIntN(16, x)); }
101
- export function toUInt16(x) { return Number(BigInt.asUintN(16, x)); }
102
- export function toInt32(x) { return Number(BigInt.asIntN(32, x)); }
103
- export function toUInt32(x) { return Number(BigInt.asUintN(32, x)); }
104
- export function toInt64(x) { return BigInt.asIntN(64, x); }
105
- export function toUInt64(x) { return BigInt.asUintN(64, x); }
106
- export function toInt128(x) { return BigInt.asIntN(128, x); }
107
- export function toUInt128(x) { return BigInt.asUintN(128, x); }
108
- export function toNativeInt(x) { return BigInt.asIntN(64, x); }
109
- export function toUNativeInt(x) { return BigInt.asUintN(64, x); }
98
+ export function toIntN_unchecked(bits, x, signed) {
99
+ return signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
100
+ }
101
+ export function toIntN(bits, x, signed) {
102
+ const truncated = signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
103
+ if (truncated !== x) {
104
+ const s = signed ? "a signed" : "an unsigned";
105
+ throw new Exception(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
106
+ }
107
+ return truncated;
108
+ }
109
+ export function toInt8(x) { return Number(toIntN(8, x, true)); }
110
+ export function toUInt8(x) { return Number(toIntN(8, x, false)); }
111
+ export function toInt16(x) { return Number(toIntN(16, x, true)); }
112
+ export function toUInt16(x) { return Number(toIntN(16, x, false)); }
113
+ export function toInt32(x) { return Number(toIntN(32, x, true)); }
114
+ export function toUInt32(x) { return Number(toIntN(32, x, false)); }
115
+ export function toInt64(x) { return toIntN(64, x, true); }
116
+ export function toUInt64(x) { return toIntN(64, x, false); }
117
+ export function toInt128(x) { return toIntN(128, x, true); }
118
+ export function toUInt128(x) { return toIntN(128, x, false); }
119
+ export function toNativeInt(x) { return toIntN(64, x, true); }
120
+ export function toUNativeInt(x) { return toIntN(64, x, false); }
121
+ export function toInt8_unchecked(x) { return Number(toIntN_unchecked(8, x, true)); }
122
+ export function toUInt8_unchecked(x) { return Number(toIntN_unchecked(8, x, false)); }
123
+ export function toInt16_unchecked(x) { return Number(toIntN_unchecked(16, x, true)); }
124
+ export function toUInt16_unchecked(x) { return Number(toIntN_unchecked(16, x, false)); }
125
+ export function toInt32_unchecked(x) { return Number(toIntN_unchecked(32, x, true)); }
126
+ export function toUInt32_unchecked(x) { return Number(toIntN_unchecked(32, x, false)); }
127
+ export function toInt64_unchecked(x) { return toIntN_unchecked(64, x, true); }
128
+ export function toUInt64_unchecked(x) { return toIntN_unchecked(64, x, false); }
129
+ export function toInt128_unchecked(x) { return toIntN_unchecked(128, x, true); }
130
+ export function toUInt128_unchecked(x) { return toIntN_unchecked(128, x, false); }
131
+ export function toNativeInt_unchecked(x) { return toIntN_unchecked(64, x, true); }
132
+ export function toUNativeInt_unchecked(x) { return toIntN_unchecked(64, x, false); }
110
133
  export function toFloat16(x) { return Number(x); }
111
134
  export function toFloat32(x) { return Number(x); }
112
135
  export function toFloat64(x) { return Number(x); }
113
136
  export function toDecimal(x) {
114
- const low = Number(BigInt.asUintN(32, x));
115
- const mid = Number(BigInt.asUintN(32, x >> 32n));
116
- const high = Number(BigInt.asUintN(32, x >> 64n));
117
137
  const isNegative = x < zero;
138
+ const bits = abs(x);
139
+ if ((bits >> 96n) !== zero) {
140
+ throw new Exception("Value was either too large or too small for a Decimal.");
141
+ }
142
+ const low = Number(BigInt.asUintN(32, bits));
143
+ const mid = Number(BigInt.asUintN(32, bits >> 32n));
144
+ const high = Number(BigInt.asUintN(32, bits >> 64n));
118
145
  const scale = 0;
119
146
  return fromParts(low, mid, high, isNegative, scale);
120
147
  }
@@ -154,6 +181,8 @@ export function divRem(x, y, out) {
154
181
  }
155
182
  }
156
183
  export function greatestCommonDivisor(x, y) {
184
+ x = abs(x);
185
+ y = abs(y);
157
186
  while (y > zero) {
158
187
  const q = x / y;
159
188
  const r = x - q * y;
@@ -162,8 +191,16 @@ export function greatestCommonDivisor(x, y) {
162
191
  }
163
192
  return x;
164
193
  }
194
+ // Number of bits in the binary representation of x (x must be positive)
195
+ function bitLength(x) {
196
+ const hex = x.toString(16);
197
+ return (hex.length - 1) * 4 + (32 - Math.clz32(fromHexCode(hex.charCodeAt(0))));
198
+ }
165
199
  export function getBitLength(x) {
166
- return fromFloat64(x === zero ? 1 : log2(abs(x)) + 1);
200
+ if (x < zero) {
201
+ x = -x - one; // two's complement bit length excluding the sign bit
202
+ }
203
+ return x === zero ? zero : BigInt(bitLength(x));
167
204
  }
168
205
  export function log2(x) {
169
206
  const n = Number(x);
@@ -195,7 +232,10 @@ export function log(x, base) {
195
232
  return log2(x) / Math.log2(base);
196
233
  }
197
234
  export function ilog2(x) {
198
- return BigInt(log2(x));
235
+ if (x < zero) {
236
+ throw new Exception("Value must be non-negative.");
237
+ }
238
+ return x === zero ? zero : BigInt(bitLength(x) - 1);
199
239
  }
200
240
  // export function copySign
201
241
  // export function createChecked
@@ -224,39 +264,24 @@ function fromHexCode(code) {
224
264
  }
225
265
  function toSignedBytes(x, isBigEndian) {
226
266
  const isNeg = x < 0n;
227
- if (isNeg) {
228
- const len = log2(-x);
229
- const bits = len + (8 - len % 8);
230
- const pow2 = (1n << BigInt(bits));
231
- x = x + pow2; // two's complement
232
- }
233
- const hex = x.toString(16);
234
- const len = hex.length;
235
- const odd = len % 2;
236
- const first = hex.charCodeAt(0);
237
- const isLow = 48 <= first && first <= 55; // 0..7
238
- const start = (isNeg && isLow) || (!isNeg && !isLow) ? 1 : 0;
239
- const bytes = new Uint8Array(start + (len + odd) / 2);
240
- const inc = isBigEndian ? 1 : -1;
241
- let pos = isBigEndian ? 0 : bytes.length - 1;
242
- if (start > 0) {
243
- bytes[pos] = isNeg ? 255 : 0;
244
- pos += inc;
245
- }
246
- if (odd > 0) {
247
- bytes[pos] = fromHexCode(first);
248
- pos += inc;
267
+ const sentinel = isNeg ? -1n : 0n;
268
+ const bytes = []; // little-endian
269
+ do {
270
+ bytes.push(Number(BigInt.asUintN(8, x)));
271
+ x = x >> 8n;
272
+ } while (x !== sentinel);
273
+ // extra byte if the top byte's sign bit would misrepresent the sign
274
+ if (isNeg !== (bytes[bytes.length - 1] > 127)) {
275
+ bytes.push(isNeg ? 255 : 0);
249
276
  }
250
- for (let i = odd; i < len; i += 2, pos += inc) {
251
- const a = fromHexCode(hex.charCodeAt(i));
252
- const b = fromHexCode(hex.charCodeAt(i + 1));
253
- bytes[pos] = (a << 4) | b;
277
+ if (isBigEndian) {
278
+ bytes.reverse();
254
279
  }
255
- return bytes;
280
+ return new Uint8Array(bytes);
256
281
  }
257
282
  function fromSignedBytes(bytes, isBigEndian) {
258
283
  if (bytes == null) {
259
- throw new Error("bytes is null");
284
+ throw new Exception("bytes is null");
260
285
  }
261
286
  const len = bytes.length;
262
287
  const first = isBigEndian ? 0 : len - 1;
@@ -77,7 +77,7 @@ export function doubleToInt64Bits(value) {
77
77
  export function toBoolean(bytes, offset) {
78
78
  const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
79
79
  const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
80
- return view.getUint8(offset) === 1 ? true : false;
80
+ return view.getUint8(offset) !== 0;
81
81
  }
82
82
  export function toChar(bytes, offset) {
83
83
  const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
@@ -134,5 +134,5 @@ export function toString(bytes, offset, count) {
134
134
  else if (offset != null) {
135
135
  buffer = buffer.subarray(offset);
136
136
  }
137
- return Array.from(buffer).map((b) => ("0" + b.toString(16)).slice(-2)).join("-");
137
+ return Array.from(buffer).map((b) => ("0" + b.toString(16)).slice(-2).toUpperCase()).join("-");
138
138
  }
@@ -1,10 +1,11 @@
1
1
  import { FSharpRef } from "./Types.js";
2
+ import { Exception } from "./Util.js";
2
3
  export function tryParse(str, defValue) {
3
- if (str.match(/^\s*true\s*$/i)) {
4
+ if (str != null && str.match(/^\s*true\s*$/i)) {
4
5
  defValue.contents = true;
5
6
  return true;
6
7
  }
7
- else if (str.match(/^\s*false\s*$/i)) {
8
+ else if (str != null && str.match(/^\s*false\s*$/i)) {
8
9
  defValue.contents = false;
9
10
  return true;
10
11
  }
@@ -16,6 +17,6 @@ export function parse(str) {
16
17
  return defValue.contents;
17
18
  }
18
19
  else {
19
- throw new Error(`String '${str}' was not recognized as a valid Boolean.`);
20
+ throw new Exception(`String '${str}' was not recognized as a valid Boolean.`);
20
21
  }
21
22
  }