@glutinum/cli 0.14.0 → 1.0.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 (182) hide show
  1. package/dist/Glutinum.Converter/FsharpAST.js +38 -4
  2. package/dist/Glutinum.Converter/Generate.js +15 -7
  3. package/dist/Glutinum.Converter/GlueAST.js +45 -36
  4. package/dist/Glutinum.Converter/Hosting.js +918 -0
  5. package/dist/Glutinum.Converter/Merge.js +218 -82
  6. package/dist/Glutinum.Converter/Packages.js +44 -8
  7. package/dist/Glutinum.Converter/Printer.js +77 -49
  8. package/dist/Glutinum.Converter/Read.js +8 -8
  9. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
  10. package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
  11. package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
  12. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
  13. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
  14. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
  15. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
  16. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
  17. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
  18. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
  19. package/dist/Glutinum.Converter/Reader/Node.js +20 -20
  20. package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
  21. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  22. package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
  23. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
  24. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
  25. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
  26. package/dist/Glutinum.Converter/Reader/Types.js +6 -6
  27. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
  28. package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
  29. package/dist/Glutinum.Converter/Transform.js +2057 -700
  30. package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
  31. package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
  32. package/dist/Glutinum.Converter/Utils/String.js +2 -2
  33. package/dist/Program.js +38 -26
  34. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  35. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  36. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  37. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  38. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  39. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  40. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  73. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  76. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  84. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  85. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  86. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  87. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  88. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  89. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  90. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  91. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  92. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  93. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  94. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  95. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  96. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  97. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  98. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  99. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  100. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  101. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  102. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  103. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  104. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  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.5.17.2/Array.js +1348 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  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.5.17.2/Date.js +834 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  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.5.17.2/Decimal.js +238 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  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.CompilerServices.js +27 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  144. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  145. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  146. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  147. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  148. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  149. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  150. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  151. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  152. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  153. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  154. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  155. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  156. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  157. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  158. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  159. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  160. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  161. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  162. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  163. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  164. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  165. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  166. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  167. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  168. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  169. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  170. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  171. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  172. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  173. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  174. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  175. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  176. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  177. package/package.json +2 -2
  178. package/dist/Glutinum.Converter/TypeScript.js +0 -12
  179. package/src/Glutinum.Converter/js/bootstrap.js +0 -123
  180. package/src/Glutinum.Converter/js/host.js +0 -144
  181. package/src/Glutinum.Converter/js/npm.js +0 -137
  182. package/src/Glutinum.Converter/js/resolve.js +0 -402
package/dist/Program.js CHANGED
@@ -1,11 +1,12 @@
1
1
 
2
2
  import { success, info, error, log } from "./Glutinum.Converter/Log.js";
3
- import { generateBindingFile, generatePackagesFromDisk } from "./Glutinum.Converter/Generate.js";
4
- import { length, exists, filter, contains, cons, singleton, append, reverse, ofArray, tail as tail_5, head, isEmpty, empty } from "./fable_modules/fable-library-js.5.17.2/List.js";
3
+ import { generateBindingFileWith, generatePackagesFromDisk } from "./Glutinum.Converter/Generate.js";
4
+ import { length, exists, filter, contains, cons, ofArray, singleton, append, reverse, tail as tail_5, head, isEmpty, empty } from "./fable_modules/fable-library-js.5.17.2/List.js";
5
+ import { defaultArg } from "./fable_modules/fable-library-js.5.17.2/Option.js";
6
+ import { join, concat, split } from "./fable_modules/fable-library-js.5.17.2/String.js";
5
7
  import { item, equalsWith } from "./fable_modules/fable-library-js.5.17.2/Array.js";
6
8
  import { stringHash, defaultOf } from "./fable_modules/fable-library-js.5.17.2/Util.js";
7
9
  import { defaultOptions, GenerateOptions } from "./Glutinum.Converter/Packages.js";
8
- import { join, concat } from "./fable_modules/fable-library-js.5.17.2/String.js";
9
10
  import * as path from "path";
10
11
  import * as fs from "fs";
11
12
 
@@ -56,17 +57,16 @@ function generate(options, inputs) {
56
57
  case 0:
57
58
  return generatePackagesFromDisk(options, empty());
58
59
  case 1:
59
- return generateBindingFile(input_1);
60
+ return generateBindingFileWith(defaultArg(options.ModuleName, "Glutinum"), input_1);
60
61
  default:
61
62
  return generatePackagesFromDisk(options, inputs_1);
62
63
  }
63
64
  }
64
65
 
65
- (function (argv) {
66
- const argv_1 = ofArray(argv);
66
+ function run(argv) {
67
67
  let matchResult;
68
- if (!isEmpty(argv_1)) {
69
- switch (head(argv_1)) {
68
+ if (!isEmpty(argv)) {
69
+ switch (head(argv)) {
70
70
  case "-h":
71
71
  case "--help":
72
72
  case "help": {
@@ -74,7 +74,7 @@ function generate(options, inputs) {
74
74
  break;
75
75
  }
76
76
  case "--version": {
77
- if (isEmpty(tail_5(argv_1))) {
77
+ if (isEmpty(tail_5(argv))) {
78
78
  matchResult = 1;
79
79
  }
80
80
  else {
@@ -100,7 +100,7 @@ function generate(options, inputs) {
100
100
  }
101
101
  default: {
102
102
  let patternInput;
103
- const matchValue = reverse(argv_1);
103
+ const matchValue = reverse(argv);
104
104
  let matchResult_1, inputs, outFile;
105
105
  if (!isEmpty(matchValue)) {
106
106
  if (!isEmpty(tail_5(matchValue))) {
@@ -126,7 +126,7 @@ function generate(options, inputs) {
126
126
  break;
127
127
  }
128
128
  default:
129
- patternInput = [argv_1, undefined];
129
+ patternInput = [argv, undefined];
130
130
  }
131
131
  const outFile_1 = patternInput[1];
132
132
  const takeOptions = (args_mut, options_mut, rest_mut) => {
@@ -194,7 +194,7 @@ function generate(options, inputs) {
194
194
  switch (matchResult_2) {
195
195
  case 0: {
196
196
  args_mut = tail;
197
- options_mut = (new GenerateOptions(options.ExternalPackages, append(options.Externals, singleton((matchValue_1 = value.split("="), (!equalsWith((x, y) => (x === y), matchValue_1, defaultOf()) && (matchValue_1.length === 2)) ? [item(0, matchValue_1), item(1, matchValue_1)] : [value, undefined]))), options.ModuleName, options.Include, options.NoLib));
197
+ options_mut = (new GenerateOptions(options.ExternalPackages, append(options.Externals, singleton((matchValue_1 = split(value, ["="], undefined, 0), (!equalsWith((x, y) => (x === y), matchValue_1, defaultOf()) && (matchValue_1.length === 2)) ? [item(0, matchValue_1), item(1, matchValue_1)] : [value, undefined]))), options.ModuleName, options.Include, options.NoLib));
198
198
  rest_mut = rest;
199
199
  continue takeOptions;
200
200
  }
@@ -212,7 +212,7 @@ function generate(options, inputs) {
212
212
  }
213
213
  case 3: {
214
214
  args_mut = tail_3;
215
- options_mut = (new GenerateOptions(options.ExternalPackages, options.Externals, options.ModuleName, append(options.Include, ofArray(value_2.split(","))), options.NoLib));
215
+ options_mut = (new GenerateOptions(options.ExternalPackages, options.Externals, options.ModuleName, append(options.Include, ofArray(split(value_2, [","], undefined, 0))), options.NoLib));
216
216
  rest_mut = rest;
217
217
  continue takeOptions;
218
218
  }
@@ -256,23 +256,35 @@ function generate(options, inputs) {
256
256
  }
257
257
  else {
258
258
  info(concat("Generating binding file for ", join(", ", inputs_3)));
259
- const res = generate(options_2, inputs_3);
260
- if (outFile_1 == null) {
261
- process.stdout.write(res);
259
+ try {
260
+ const res = generate(options_2, inputs_3);
261
+ if (outFile_1 == null) {
262
+ process.stdout.write(res);
263
+ }
264
+ else {
265
+ const outFile_2 = outFile_1;
266
+ const outFileDir = path.dirname(outFile_2);
267
+ fs.mkdirSync(outFileDir, {
268
+ recursive: true,
269
+ });
270
+ fs.writeFileSync(outFile_2, res);
271
+ info(concat("Bindings written to: ", path.join(process.cwd(), outFile_2)));
272
+ }
273
+ success("Success!");
274
+ return 0;
262
275
  }
263
- else {
264
- const outFile_2 = outFile_1;
265
- const outFileDir = path.dirname(outFile_2);
266
- fs.mkdirSync(outFileDir, {
267
- recursive: true,
268
- });
269
- fs.writeFileSync(outFile_2, res);
270
- info(concat("Bindings written to: ", path.join(process.cwd(), outFile_2)));
276
+ catch (ex) {
277
+ error(ex.message);
278
+ return 1;
271
279
  }
272
- success("Success!");
273
- return 0;
274
280
  }
275
281
  }
276
282
  }
283
+ }
284
+
285
+ (function (argv) {
286
+ const exitCode = run(ofArray(argv)) | 0;
287
+ process.exitCode = exitCode;
288
+ return exitCode | 0;
277
289
  })(typeof process === 'object' ? process.argv.slice(2) : []);
278
290
 
@@ -0,0 +1,89 @@
1
+ [<RequireQualifiedAccess>]
2
+ module AsyncIterable
3
+
4
+ open Fable.Core
5
+ open Fable.Core.JsInterop
6
+
7
+ [<Emit("""{
8
+ [Symbol.asyncIterator]() {
9
+ return {
10
+ next: $0,
11
+ return: $1
12
+ }
13
+ }
14
+ }""")>]
15
+ let private createAsyncIterator
16
+ (onNext: unit -> JS.Promise<obj>)
17
+ (onCancel: unit -> obj)
18
+ : JS.AsyncIterable<'T>
19
+ =
20
+ jsNative
21
+
22
+ /// Creates AsyncIterable. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of#specifications
23
+ let create (onNext: unit -> JS.Promise<'T option>) : JS.AsyncIterable<'T> =
24
+ createAsyncIterator
25
+ (fun () ->
26
+ onNext ()
27
+ |> Promise.map (
28
+ function
29
+ | Some value ->
30
+ createObj
31
+ [
32
+ "value" ==> value
33
+ "done" ==> false
34
+ ]
35
+ | None -> createObj [ "done" ==> true ]
36
+ )
37
+ )
38
+ (fun () -> createObj [ "done" ==> true ])
39
+
40
+ /// Creates AsyncIterable with a cleaning function for cancellation (JS caller invokes `break` or `return` during iteration)
41
+ let createCancellable
42
+ (onCancel: unit -> unit)
43
+ (onNext: unit -> JS.Promise<'T option>)
44
+ : JS.AsyncIterable<'T>
45
+ =
46
+ createAsyncIterator
47
+ (fun () ->
48
+ onNext ()
49
+ |> Promise.map (
50
+ function
51
+ | Some value ->
52
+ createObj
53
+ [
54
+ "value" ==> value
55
+ "done" ==> false
56
+ ]
57
+ | None -> createObj [ "done" ==> true ]
58
+ )
59
+ )
60
+ (fun () ->
61
+ onCancel ()
62
+ createObj [ "done" ==> true ]
63
+ )
64
+
65
+ type CancellationToken() =
66
+ member this.Cancel() : unit = raise !!this
67
+
68
+ /// Iterates AsyncIterable. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
69
+ let iter
70
+ (action: CancellationToken -> 'T -> unit)
71
+ (iterable: JS.AsyncIterable<'T>)
72
+ : JS.Promise<unit>
73
+ =
74
+ let token = CancellationToken()
75
+
76
+ emitJsExpr
77
+ (action, iterable, token)
78
+ """(async () => {
79
+ for await (const value of $1) {
80
+ try {
81
+ $0($2, value)
82
+ } catch (err) {
83
+ if (err instanceof $2.constructor) {
84
+ break;
85
+ }
86
+ throw(err);
87
+ }
88
+ }
89
+ })()"""
@@ -0,0 +1,105 @@
1
+
2
+ import { value as value_1 } from "../fable-library-js.5.17.2/Option.js";
3
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
4
+
5
+ /**
6
+ * Creates AsyncIterable. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of#specifications
7
+ */
8
+ export function create(onNext) {
9
+ return {
10
+ [Symbol.asyncIterator]() {
11
+ return {
12
+ next: (() => {
13
+ const pr = onNext();
14
+ return pr.then((_arg) => {
15
+ if (_arg == null) {
16
+ return {
17
+ done: true,
18
+ };
19
+ }
20
+ else {
21
+ return {
22
+ value: value_1(_arg),
23
+ done: false,
24
+ };
25
+ }
26
+ });
27
+ }),
28
+ return: (() => ({
29
+ done: true,
30
+ }))
31
+ }
32
+ }
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Creates AsyncIterable with a cleaning function for cancellation (JS caller invokes `break` or `return` during iteration)
38
+ */
39
+ export function createCancellable(onCancel, onNext) {
40
+ return {
41
+ [Symbol.asyncIterator]() {
42
+ return {
43
+ next: (() => {
44
+ const pr = onNext();
45
+ return pr.then((_arg) => {
46
+ if (_arg == null) {
47
+ return {
48
+ done: true,
49
+ };
50
+ }
51
+ else {
52
+ return {
53
+ value: value_1(_arg),
54
+ done: false,
55
+ };
56
+ }
57
+ });
58
+ }),
59
+ return: (() => {
60
+ onCancel();
61
+ return {
62
+ done: true,
63
+ };
64
+ })
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ export class CancellationToken {
71
+ constructor() {
72
+ }
73
+ }
74
+
75
+ export function CancellationToken_$reflection() {
76
+ return class_type("AsyncIterable.CancellationToken", undefined, CancellationToken);
77
+ }
78
+
79
+ export function CancellationToken_$ctor() {
80
+ return new CancellationToken();
81
+ }
82
+
83
+ export function CancellationToken__Cancel(this$) {
84
+ throw this$;
85
+ }
86
+
87
+ /**
88
+ * Iterates AsyncIterable. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
89
+ */
90
+ export function iter(action, iterable) {
91
+ const token = CancellationToken_$ctor();
92
+ return (async () => {
93
+ for await (const value of iterable) {
94
+ try {
95
+ action(token, value)
96
+ } catch (err) {
97
+ if (err instanceof token.constructor) {
98
+ break;
99
+ }
100
+ throw(err);
101
+ }
102
+ }
103
+ })();
104
+ }
105
+
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project Sdk="Microsoft.NET.Sdk">
3
+ <PropertyGroup>
4
+ <TargetFramework>netstandard2.0</TargetFramework>
5
+ <FablePackageType>library</FablePackageType>
6
+ <ChangelogFile>$(MSBuildThisFileDirectory)../CHANGELOG.md</ChangelogFile>
7
+ </PropertyGroup>
8
+ <ItemGroup>
9
+ <Compile Include="Promise.fs" />
10
+ <Compile Include="PromiseImpl.fs" />
11
+ <Compile Include="AsyncIterable.fs" />
12
+ </ItemGroup>
13
+ <ItemGroup>
14
+ <PackageReference Include="Fable.Core" Version="5.2.0" />
15
+ <PackageReference Include="EasyBuild.PackageReleaseNotes.Tasks" Version="2.1.0">
16
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17
+ <PrivateAssets>all</PrivateAssets>
18
+ </PackageReference>
19
+ <PackageReference Include="Fable.Package.SDK" Version="1.4.0">
20
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21
+ <PrivateAssets>all</PrivateAssets>
22
+ </PackageReference>
23
+ <PackageReference Update="FSharp.Core" Version="4.7.2" />
24
+ </ItemGroup>
25
+ </Project>