@magnusopera/fscript 0.87.2 → 0.90.0

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 (101) hide show
  1. package/README.md +15 -0
  2. package/dist/FScript.Language/Ast.js +2 -2
  3. package/dist/FScript.Language/BuiltinFunctions.js +81 -69
  4. package/dist/FScript.Language/BuiltinSignatures.js +9 -8
  5. package/dist/FScript.Language/BuiltinTypes.js +1 -1
  6. package/dist/FScript.Language/Error.js +2 -2
  7. package/dist/FScript.Language/Eval.js +176 -127
  8. package/dist/FScript.Language/Execution.js +8 -7
  9. package/dist/FScript.Language/ExportSignatures.js +5 -5
  10. package/dist/FScript.Language/HostInterop.js +41 -11
  11. package/dist/FScript.Language/IncludeResolver.js +15 -19
  12. package/dist/FScript.Language/Interactive.js +9 -9
  13. package/dist/FScript.Language/Lexer.js +39 -39
  14. package/dist/FScript.Language/Parser.js +17 -17
  15. package/dist/FScript.Language/Pretty.js +5 -5
  16. package/dist/FScript.Language/Span.js +2 -2
  17. package/dist/FScript.Language/SupportCollections.js +2871 -0
  18. package/dist/FScript.Language/SupportLibrary.js +1998 -0
  19. package/dist/FScript.Language/TaskFunctions.js +51 -7
  20. package/dist/FScript.Language/TaskSharingAnalysis.js +310 -129
  21. package/dist/FScript.Language/Token.js +2 -2
  22. package/dist/FScript.Language/TypeInfer.js +21 -25
  23. package/dist/FScript.Language/Types.js +9 -9
  24. package/dist/FScript.Language/Value.js +11 -8
  25. package/dist/Library.js +54 -28
  26. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Array.js +325 -198
  27. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BigInt.js +18 -6
  28. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CHANGELOG.md +64 -1
  29. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Date.js +1 -1
  30. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Decimal.js +33 -47
  31. package/dist/fable_modules/fable-library-js.5.27.0/Double.js +78 -0
  32. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.js +7 -1
  33. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Global.js +1 -1
  34. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Int32.js +10 -1
  35. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/List.js +230 -157
  36. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Long.js +7 -2
  37. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Map.js +46 -39
  38. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableMap.js +76 -96
  39. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableSet.js +58 -80
  40. package/dist/fable_modules/fable-library-js.5.27.0/NumberStyles.js +56 -0
  41. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Numeric.js +72 -4
  42. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Random.js +26 -17
  43. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Range.js +4 -3
  44. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Reflection.js +7 -1
  45. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/RegExp.js +3 -2
  46. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq.js +149 -70
  47. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq2.js +4 -8
  48. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Set.js +66 -59
  49. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/String.js +160 -39
  50. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Collections.Generic.js +3 -2
  51. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Text.js +10 -10
  52. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.js +5 -5
  53. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnly.js +1 -1
  54. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Types.js +28 -10
  55. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Util.js +151 -54
  56. package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/package.json +1 -1
  57. package/dist/fable_modules/project_cracked.json +1 -1
  58. package/package.json +1 -1
  59. package/dist/fable_modules/fable-library-js.5.24.0/Double.js +0 -53
  60. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Async.js +0 -0
  61. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/AsyncBuilder.js +0 -0
  62. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BitConverter.js +0 -0
  63. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Boolean.js +0 -0
  64. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Char.js +0 -0
  65. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Choice.js +0 -0
  66. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CollectionUtil.js +0 -0
  67. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/ConditionalWeakTable.js +0 -0
  68. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOffset.js +0 -0
  69. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnly.js +0 -0
  70. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnlyTemporal.js +0 -0
  71. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeFormat.js +0 -0
  72. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeOffsetTemporal.js +0 -0
  73. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeTemporal.js +0 -0
  74. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Directory.js +0 -0
  75. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Encoding.js +0 -0
  76. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Environment.js +0 -0
  77. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Event.js +0 -0
  78. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Collections.js +0 -0
  79. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.CompilerServices.js +0 -0
  80. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/File.js +0 -0
  81. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Guid.js +0 -0
  82. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MailboxProcessor.js +0 -0
  83. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MapUtil.js +0 -0
  84. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Native.js +0 -0
  85. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Observable.js +0 -0
  86. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Option.js +0 -0
  87. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Path.js +0 -0
  88. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/README.md +0 -0
  89. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Result.js +0 -0
  90. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Stopwatch.js +0 -0
  91. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Task.js +0 -0
  92. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TaskBuilder.js +0 -0
  93. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnlyTemporal.js +0 -0
  94. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpan.js +0 -0
  95. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpanTemporal.js +0 -0
  96. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Timer.js +0 -0
  97. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Unicode.13.0.0.js +0 -0
  98. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Uri.js +0 -0
  99. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/big.d.ts +0 -0
  100. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/lib/big.js +0 -0
  101. /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/quotation.js +0 -0
@@ -1,6 +1,6 @@
1
1
 
2
- import { Record, Union } from "../fable_modules/fable-library-js.5.24.0/Types.js";
3
- import { record_type, union_type, bool_type, float64_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.24.0/Reflection.js";
2
+ import { Record, Union } from "../fable_modules/fable-library-js.5.27.0/Types.js";
3
+ import { record_type, union_type, bool_type, float64_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
4
4
  import { Span_$reflection } from "./Span.js";
5
5
 
6
6
  export class TokenKind extends Union {
@@ -1,25 +1,25 @@
1
1
 
2
2
  import { Span_$reflection, Span, Position } from "./Span.js";
3
- import { find, toSeq, containsKey, iterate as iterate_2, FSharpMap__Add, values as values_4, FSharpMap__get_Keys, keys, toList, FSharpMap__get_Item, FSharpMap__get_Count, forAll, FSharpMap__ContainsKey, filter, ofList, exists as exists_1, add, fold as fold_1, remove, map, FSharpMap__TryFind, tryFind, isEmpty, empty } from "../fable_modules/fable-library-js.5.24.0/Map.js";
4
- import { defaultOf, safeHash, curry2, curry3, uncurry2, arrayHash, equalArrays, compare, disposeSafe, getEnumerator, Exception, stringHash, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.24.0/Util.js";
3
+ import { find, toSeq, containsKey, iterate as iterate_2, FSharpMap__Add, values as values_4, FSharpMap__get_Keys, keys, toList, FSharpMap__get_Item, FSharpMap__get_Count, forAll, FSharpMap__ContainsKey, filter, ofList, exists as exists_1, add, fold as fold_1, remove, map, FSharpMap__TryFind, tryFind, isEmpty, empty } from "../fable_modules/fable-library-js.5.27.0/Map.js";
4
+ import { defaultOf, safeHash, curry2, curry3, uncurry2, arrayHash, equalArrays, compare, disposeSafe, getEnumerator, Exception, stringHash, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
5
5
  import { PurityContractsModule_empty, Types_generalize, Types_freshNumeric, PurityContracts_$reflection, Scheme_$reflection, Type_$reflection, Types_freshVar, Types_typeToString, Scheme, Type as Type_1 } from "./Types.js";
6
- import { exactlyOne, replicate, map2, sortBy, mapIndexed, tryFind as tryFind_1, indexed, collect, unzip, append, reverse, iterate, tryFindIndex, choose, tail as tail_6, cons, head as head_4, isEmpty as isEmpty_1, empty as empty_2, ofArray, singleton, zip, length, exists, fold, map as map_1 } from "../fable_modules/fable-library-js.5.24.0/List.js";
7
- import { toList as toList_2, ofSeq, contains, add as add_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.24.0/Set.js";
6
+ import { exactlyOne, replicate, map2, sortBy, mapIndexed, tryFind as tryFind_1, indexed, collect, unzip, append, reverse, iterate, tryFindIndex, choose, tail as tail_6, cons, head as head_4, isEmpty as isEmpty_1, empty as empty_2, ofArray, singleton, zip, length, exists, fold, map as map_1 } from "../fable_modules/fable-library-js.5.27.0/List.js";
7
+ import { toList as toList_2, ofSeq, contains, add as add_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.27.0/Set.js";
8
8
  import { EvalException, TypeException, TypeError$ } from "./Error.js";
9
- import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.24.0/String.js";
10
- import { orElse, value as value_42, toArray, flatten, defaultArg } from "../fable_modules/fable-library-js.5.24.0/Option.js";
11
- import { FSharpRef, Union, Record } from "../fable_modules/fable-library-js.5.24.0/Types.js";
9
+ import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.27.0/String.js";
10
+ import { orElse, value as value_42, toArray, flatten, defaultArg } from "../fable_modules/fable-library-js.5.27.0/Option.js";
11
+ import { FSharpRef, Union, Record } from "../fable_modules/fable-library-js.5.27.0/Types.js";
12
12
  import { Attribute, Expr, Ast_spanOfPattern, Ast_spanOfExpr, Attribute_$reflection, BackendImport_$reflection, Pattern_$reflection, TypeDef_$reflection, Expr_$reflection } from "./Ast.js";
13
- import { array_type, class_type, tuple_type, list_type, bool_type, float64_type, int64_type, option_type, union_type, int32_type, string_type, record_type } from "../fable_modules/fable-library-js.5.24.0/Reflection.js";
14
- import { exists as exists_2, forAll as forAll_1, tryPick, tryFind as tryFind_2, foldBack, iterate as iterate_1, filter as filter_1, map as map_2, toList as toList_1 } from "../fable_modules/fable-library-js.5.24.0/Seq.js";
15
- import { last as last_2, setItem, item as item_22 } from "../fable_modules/fable-library-js.5.24.0/Array.js";
16
- import { distinct } from "../fable_modules/fable-library-js.5.24.0/Seq2.js";
13
+ import { array_type, class_type, tuple_type, list_type, bool_type, float64_type, int64_type, option_type, union_type, int32_type, string_type, record_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
14
+ import { exists as exists_2, forAll as forAll_1, tryPick, tryFind as tryFind_2, foldBack, iterate as iterate_1, filter as filter_1, map as map_2, toList as toList_1 } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
15
+ import { last as last_2, setItem, item as item_22 } from "../fable_modules/fable-library-js.5.27.0/Array.js";
16
+ import { distinct } from "../fable_modules/fable-library-js.5.27.0/Seq2.js";
17
17
  import { builtinReservedNames, builtinSchemes } from "./BuiltinSignatures.js";
18
18
  import { ofExterns, typeDefinitions } from "./HostInterop.js";
19
19
  import { typeDefs as typeDefs_2 } from "./BuiltinTypes.js";
20
- import { Dictionary } from "../fable_modules/fable-library-js.5.24.0/MutableMap.js";
21
- import { rangeDouble } from "../fable_modules/fable-library-js.5.24.0/Range.js";
22
- import { tryGetValue, getItemFromDict, addToDict } from "../fable_modules/fable-library-js.5.24.0/MapUtil.js";
20
+ import { Dictionary } from "../fable_modules/fable-library-js.5.27.0/MutableMap.js";
21
+ import { rangeDouble } from "../fable_modules/fable-library-js.5.27.0/Range.js";
22
+ import { tryGetValue, getItemFromDict, addToDict } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
23
23
 
24
24
  const unknownSpan = new Span(new Position(undefined, 0, 0), new Position(undefined, 0, 0));
25
25
 
@@ -2911,9 +2911,9 @@ function inferExprRaw(telemetry, typeDefs, constructors, env, expr) {
2911
2911
  while (enumerator_4["System.Collections.IEnumerator.MoveNext"]()) {
2912
2912
  const item = enumerator_4["System.Collections.Generic.IEnumerator`1.get_Current"]();
2913
2913
  const patternInput_24 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_2, env), item);
2914
- const s1_11 = patternInput_24[0];
2915
- const s2_8 = unify(typeDefs, applyType(s1_11, tv_5), patternInput_24[1], expr.fields[1]);
2916
- sAcc_2 = compose(s2_8, compose(s1_11, sAcc_2));
2914
+ const itemSubst = compose(patternInput_24[0], sAcc_2);
2915
+ const s2_8 = unify(typeDefs, applyType(itemSubst, tv_5), applyType(itemSubst, patternInput_24[1]), expr.fields[1]);
2916
+ sAcc_2 = compose(s2_8, itemSubst);
2917
2917
  }
2918
2918
  }
2919
2919
  finally {
@@ -4839,10 +4839,8 @@ export function inferResolvedProgramWithRegistration(registration, program) {
4839
4839
  while (enumerator_15["System.Collections.IEnumerator.MoveNext"]()) {
4840
4840
  const reference = enumerator_15["System.Collections.Generic.IEnumerator`1.get_Current"]();
4841
4841
  let matchValue_3;
4842
- let outArg = defaultOf();
4843
- matchValue_3 = [tryGetValue(referenceOccurrences, reference.Span, new FSharpRef(() => outArg, (v) => {
4844
- outArg = v;
4845
- })), outArg];
4842
+ const cell = new FSharpRef(defaultOf());
4843
+ matchValue_3 = [tryGetValue(referenceOccurrences, reference.Span, cell), cell.contents];
4846
4844
  if (matchValue_3[0]) {
4847
4845
  void (matchValue_3[1].push(reference));
4848
4846
  }
@@ -5068,10 +5066,8 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5068
5066
  const span_23 = Ast_spanOfExpr(expression_7);
5069
5067
  const expectedName = (expression_7.tag === 2) ? expression_7.fields[0] : ((expression_7.tag === 29) ? expression_7.fields[0] : ((expression_7.tag === 28) ? expression_7.fields[0] : ((expression_7.tag === 21) ? ((expression_7.fields[0].tag === 2) ? concat(expression_7.fields[0].fields[0], ".", expression_7.fields[1]) : undefined) : undefined)));
5070
5068
  let matchValue_4;
5071
- let outArg_1 = defaultOf();
5072
- matchValue_4 = [tryGetValue(referenceOccurrences, span_23, new FSharpRef(() => outArg_1, (v_1) => {
5073
- outArg_1 = v_1;
5074
- })), outArg_1];
5069
+ const cell_1 = new FSharpRef(defaultOf());
5070
+ matchValue_4 = [tryGetValue(referenceOccurrences, span_23, cell_1), cell_1.contents];
5075
5071
  if (matchValue_4[0]) {
5076
5072
  const occurrences_1 = matchValue_4[1];
5077
5073
  let index_1 = 0;
@@ -1,12 +1,12 @@
1
1
 
2
- import { Record, Union } from "../fable_modules/fable-library-js.5.24.0/Types.js";
3
- import { record_type, union_type, bool_type, int32_type, option_type, class_type, string_type, list_type } from "../fable_modules/fable-library-js.5.24.0/Reflection.js";
4
- import { toList, isEmpty, ofList, difference, singleton, add, union, empty } from "../fable_modules/fable-library-js.5.24.0/Set.js";
5
- import { Exception, comparePrimitives } from "../fable_modules/fable-library-js.5.24.0/Util.js";
6
- import { empty as empty_1, fold, map } from "../fable_modules/fable-library-js.5.24.0/List.js";
7
- import { fold as fold_1, map as map_1 } from "../fable_modules/fable-library-js.5.24.0/Seq.js";
8
- import { toList as toList_1, values } from "../fable_modules/fable-library-js.5.24.0/Map.js";
9
- import { join, printf, toText } from "../fable_modules/fable-library-js.5.24.0/String.js";
2
+ import { Record, Union } from "../fable_modules/fable-library-js.5.27.0/Types.js";
3
+ import { record_type, union_type, bool_type, int32_type, option_type, class_type, string_type, list_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
4
+ import { toList, isEmpty, ofList, difference, singleton, add, union, empty } from "../fable_modules/fable-library-js.5.27.0/Set.js";
5
+ import { Exception, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
6
+ import { empty as empty_1, fold, map } from "../fable_modules/fable-library-js.5.27.0/List.js";
7
+ import { fold as fold_1, map as map_1 } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
8
+ import { toList as toList_1, values } from "../fable_modules/fable-library-js.5.27.0/Map.js";
9
+ import { join, printf, toText } from "../fable_modules/fable-library-js.5.27.0/String.js";
10
10
 
11
11
  export class Type extends Union {
12
12
  constructor(tag, fields) {
@@ -322,7 +322,7 @@ export function Types_typeToString(t) {
322
322
  return "numeric";
323
323
  case 15: {
324
324
  const v = t_1.fields[0] | 0;
325
- const letter = String.fromCharCode((~~"a".charCodeAt(0) + (v % 26)) & 0xFFFF);
325
+ const letter = String.fromCharCode(~~(~~"a".charCodeAt(0) + (v % 26)) & 0xFFFF);
326
326
  const suffix = ~~(v / 26) | 0;
327
327
  if (suffix === 0) {
328
328
  return toText(printf("\'%c"))(letter);
@@ -1,6 +1,6 @@
1
1
 
2
- import { Record, FSharpRef, Union } from "../fable_modules/fable-library-js.5.24.0/Types.js";
3
- import { int32_type, lambda_type, unit_type, obj_type, record_type, option_type, class_type, list_type, float64_type, union_type, bool_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.24.0/Reflection.js";
2
+ import { Record, FSharpRef, Union } from "../fable_modules/fable-library-js.5.27.0/Types.js";
3
+ import { enum_type, int32_type, lambda_type, unit_type, obj_type, record_type, option_type, class_type, list_type, float64_type, union_type, bool_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
4
4
  import { HostUnionDescriptor_$reflection, Scheme_$reflection, HostTypeDescriptor_$reflection, Type_$reflection } from "./Types.js";
5
5
  import { Expr_$reflection } from "./Ast.js";
6
6
  import { EvalError$_$reflection } from "./Error.js";
@@ -76,7 +76,7 @@ export function TaskHandle_$reflection() {
76
76
  }
77
77
 
78
78
  export class ExternalCallContext extends Record {
79
- constructor(Session, IsActive, Apply, SpawnTask, AwaitTask, CheckRuntime, SetExitCode) {
79
+ constructor(Session, IsActive, Apply, SpawnTask, AwaitTask, CheckRuntime, SetExitCode, CheckPermissions) {
80
80
  super();
81
81
  this.Session = Session;
82
82
  this.IsActive = IsActive;
@@ -85,16 +85,18 @@ export class ExternalCallContext extends Record {
85
85
  this.AwaitTask = AwaitTask;
86
86
  this.CheckRuntime = CheckRuntime;
87
87
  this.SetExitCode = SetExitCode;
88
+ this.CheckPermissions = CheckPermissions;
88
89
  }
89
90
  }
90
91
 
91
92
  export function ExternalCallContext_$reflection() {
92
- return record_type("FScript.Language.ExternalCallContext", [], ExternalCallContext, () => [["Session", obj_type], ["IsActive", lambda_type(unit_type, bool_type)], ["Apply", lambda_type(Value_$reflection(), lambda_type(Value_$reflection(), Value_$reflection()))], ["SpawnTask", lambda_type(Value_$reflection(), Value_$reflection())], ["AwaitTask", lambda_type(Value_$reflection(), Value_$reflection())], ["CheckRuntime", lambda_type(unit_type, unit_type)], ["SetExitCode", lambda_type(int32_type, unit_type)]]);
93
+ return record_type("FScript.Language.ExternalCallContext", [], ExternalCallContext, () => [["Session", obj_type], ["IsActive", lambda_type(unit_type, bool_type)], ["Apply", lambda_type(Value_$reflection(), lambda_type(Value_$reflection(), Value_$reflection()))], ["SpawnTask", lambda_type(Value_$reflection(), Value_$reflection())], ["AwaitTask", lambda_type(Value_$reflection(), Value_$reflection())], ["CheckRuntime", lambda_type(unit_type, unit_type)], ["SetExitCode", lambda_type(int32_type, unit_type)], ["CheckPermissions", lambda_type(enum_type("FScript.Language.HostPermissions", int32_type, [["None", 0], ["Interactive", 1], ["Threading", 2], ["IO", 4], ["Native", 8], ["All", 15]]), unit_type)]]);
93
94
  }
94
95
 
95
96
  export class ExternalFunction extends Record {
96
- constructor(Name, Scheme, Impl, Arity) {
97
+ constructor(RequiredPermissions, Name, Scheme, Impl, Arity) {
97
98
  super();
99
+ this.RequiredPermissions = RequiredPermissions;
98
100
  this.Name = Name;
99
101
  this.Scheme = Scheme;
100
102
  this.Impl = Impl;
@@ -103,12 +105,13 @@ export class ExternalFunction extends Record {
103
105
  }
104
106
 
105
107
  export function ExternalFunction_$reflection() {
106
- return record_type("FScript.Language.ExternalFunction", [], ExternalFunction, () => [["Name", string_type], ["Scheme", Scheme_$reflection()], ["Impl", lambda_type(ExternalCallContext_$reflection(), lambda_type(list_type(Value_$reflection()), Value_$reflection()))], ["Arity", int32_type]]);
108
+ return record_type("FScript.Language.ExternalFunction", [], ExternalFunction, () => [["RequiredPermissions", enum_type("FScript.Language.HostPermissions", int32_type, [["None", 0], ["Interactive", 1], ["Threading", 2], ["IO", 4], ["Native", 8], ["All", 15]])], ["Name", string_type], ["Scheme", Scheme_$reflection()], ["Impl", lambda_type(ExternalCallContext_$reflection(), lambda_type(list_type(Value_$reflection()), Value_$reflection()))], ["Arity", int32_type]]);
107
109
  }
108
110
 
109
111
  export class ExtensionRegistration extends Record {
110
- constructor(Types, Unions, Functions) {
112
+ constructor(Permissions, Types, Unions, Functions) {
111
113
  super();
114
+ this.Permissions = Permissions;
112
115
  this.Types = Types;
113
116
  this.Unions = Unions;
114
117
  this.Functions = Functions;
@@ -116,6 +119,6 @@ export class ExtensionRegistration extends Record {
116
119
  }
117
120
 
118
121
  export function ExtensionRegistration_$reflection() {
119
- return record_type("FScript.Language.ExtensionRegistration", [], ExtensionRegistration, () => [["Types", list_type(HostTypeDescriptor_$reflection())], ["Unions", list_type(HostUnionDescriptor_$reflection())], ["Functions", list_type(ExternalFunction_$reflection())]]);
122
+ return record_type("FScript.Language.ExtensionRegistration", [], ExtensionRegistration, () => [["Permissions", enum_type("FScript.Language.HostPermissions", int32_type, [["None", 0], ["Interactive", 1], ["Threading", 2], ["IO", 4], ["Native", 8], ["All", 15]])], ["Types", list_type(HostTypeDescriptor_$reflection())], ["Unions", list_type(HostUnionDescriptor_$reflection())], ["Functions", list_type(ExternalFunction_$reflection())]]);
120
123
  }
121
124
 
package/dist/Library.js CHANGED
@@ -1,26 +1,26 @@
1
1
 
2
- import { Record } from "./fable_modules/fable-library-js.5.24.0/Types.js";
3
- import { option_type, obj_type, class_type, record_type, list_type, string_type } from "./fable_modules/fable-library-js.5.24.0/Reflection.js";
2
+ import { Record } from "./fable_modules/fable-library-js.5.27.0/Types.js";
3
+ import { option_type, obj_type, class_type, record_type, list_type, string_type } from "./fable_modules/fable-library-js.5.27.0/Reflection.js";
4
4
  import { Stmt_$reflection } from "./FScript.Language/Ast.js";
5
5
  import { ExtensionRegistration, ExternalFunction, MapKey, Value, ExternalCallContext_$reflection, Value_$reflection, ExtensionRegistration_$reflection } from "./FScript.Language/Value.js";
6
6
  import { inferProgramWithRegistration, TypedStmt_$reflection } from "./FScript.Language/TypeInfer.js";
7
7
  import { HostUnionDescriptor, HostTypeDescriptor, Scheme, Type, Types_ftvType, Types_typeToString, Type_$reflection } from "./FScript.Language/Types.js";
8
8
  import { submit as submit_1, createWithRegistration, Session_$reflection } from "./FScript.Language/Interactive.js";
9
- import { foldBack, find, tryFind as tryFind_1, choose, filter, sort, exists, singleton, collect, append, iterate as iterate_1, tail, head, isEmpty as isEmpty_1, fold, zip, iterateIndexed, empty, ofArray, length, map, toArray } from "./fable_modules/fable-library-js.5.24.0/List.js";
10
- import { flatten, defaultArg, value as value_15, some } from "./fable_modules/fable-library-js.5.24.0/Option.js";
11
- import { stringHash, disposeSafe, getEnumerator, curry2, compare, comparePrimitives, Exception } from "./fable_modules/fable-library-js.5.24.0/Util.js";
12
- import { isNullOrWhiteSpace, concat } from "./fable_modules/fable-library-js.5.24.0/String.js";
9
+ import { foldBack, find, tryFind as tryFind_1, choose, filter, sort, exists, singleton, collect, append, iterate as iterate_1, tail, head, isEmpty as isEmpty_1, fold as fold_1, zip, iterateIndexed, empty, ofArray, length, map, toArray } from "./fable_modules/fable-library-js.5.27.0/List.js";
10
+ import { flatten, defaultArg, value as value_15, some } from "./fable_modules/fable-library-js.5.27.0/Option.js";
11
+ import { stringHash, disposeSafe, getEnumerator, curry2, compare, comparePrimitives, Exception } from "./fable_modules/fable-library-js.5.27.0/Util.js";
12
+ import { isNullOrWhiteSpace, concat } from "./fable_modules/fable-library-js.5.27.0/String.js";
13
13
  import { EvalError$, EvalException, TypeException, ParseException } from "./FScript.Language/Error.js";
14
- import { toInt32_unchecked, fromFloat64, toInt64_unchecked } from "./fable_modules/fable-library-js.5.24.0/BigInt.js";
15
- import { parse as parse_1 } from "./fable_modules/fable-library-js.5.24.0/Long.js";
16
- import { parse as parse_2 } from "./fable_modules/fable-library-js.5.24.0/Int32.js";
17
- import { FSharpMap__get_Count, FSharpMap__get_Keys, empty as empty_3, FSharpMap__get_Item, FSharpMap__TryFind, FSharpMap__ContainsKey, tryFind, iterate, ofList, toList } from "./fable_modules/fable-library-js.5.24.0/Map.js";
18
- import { map as map_1, item } from "./fable_modules/fable-library-js.5.24.0/Array.js";
19
- import { ofSeq, ofList as ofList_1, isSubset, FSharpSet__Add, FSharpSet__Contains, empty as empty_1, isEmpty } from "./fable_modules/fable-library-js.5.24.0/Set.js";
20
- import { $007CRecordFields$007C_$007C, create, empty as empty_2, typeDefinitions, validateCall } from "./FScript.Language/HostInterop.js";
14
+ import { toInt32_unchecked, fromFloat64, toInt64_unchecked } from "./fable_modules/fable-library-js.5.27.0/BigInt.js";
15
+ import { parse as parse_1 } from "./fable_modules/fable-library-js.5.27.0/Long.js";
16
+ import { parse as parse_2 } from "./fable_modules/fable-library-js.5.27.0/Int32.js";
17
+ import { FSharpMap__get_Count, FSharpMap__get_Keys, empty as empty_3, FSharpMap__get_Item, FSharpMap__TryFind, FSharpMap__ContainsKey, tryFind, iterate, ofList, toList } from "./fable_modules/fable-library-js.5.27.0/Map.js";
18
+ import { map as map_1, fold, item as item_1 } from "./fable_modules/fable-library-js.5.27.0/Array.js";
19
+ import { ofSeq, ofList as ofList_1, isSubset, FSharpSet__Add, FSharpSet__Contains, empty as empty_1, isEmpty } from "./fable_modules/fable-library-js.5.27.0/Set.js";
20
+ import { $007CRecordFields$007C_$007C, create, permitted, empty as empty_2, typeDefinitions, validateCall } from "./FScript.Language/HostInterop.js";
21
21
  import { parseProgramFromSourceWithIncludesResolver } from "./FScript.Language/IncludeResolver.js";
22
- import { invokeValue, evalProgramWithRegistration, evalProgramWithRegistrationState } from "./FScript.Language/Eval.js";
23
- import { List_distinct } from "./fable_modules/fable-library-js.5.24.0/Seq2.js";
22
+ import { invokeValueWithPermissionsAndExitCode, evalProgramWithRegistration, evalProgramWithRegistrationState } from "./FScript.Language/Eval.js";
23
+ import { List_distinct } from "./fable_modules/fable-library-js.5.27.0/Seq2.js";
24
24
  import { valueToString } from "./FScript.Language/Pretty.js";
25
25
  import { Span, Position } from "./FScript.Language/Span.js";
26
26
 
@@ -697,14 +697,14 @@ function tagSignature(definitions_mut, expected_mut, value_mut, tagged_mut) {
697
697
  case 2: {
698
698
  const tags = tagged["values"];
699
699
  iterateIndexed((i, v_1) => {
700
- tagSignature(definitions, t_2, v_1, item(i, tags));
700
+ tagSignature(definitions, t_2, v_1, item_1(i, tags));
701
701
  }, values);
702
702
  break;
703
703
  }
704
704
  case 3: {
705
705
  const tags_1 = tagged["values"];
706
706
  iterateIndexed((i_1, tupledArg) => {
707
- tagSignature(definitions, tupledArg[0], tupledArg[1], item(i_1, tags_1));
707
+ tagSignature(definitions, tupledArg[0], tupledArg[1], item_1(i_1, tags_1));
708
708
  }, zip(ts, values_1));
709
709
  break;
710
710
  }
@@ -738,7 +738,7 @@ function tagSignature(definitions_mut, expected_mut, value_mut, tagged_mut) {
738
738
  case 8: {
739
739
  const tags_2 = tagged["entries"];
740
740
  iterateIndexed((i_2, tupledArg_1) => {
741
- tagSignature(definitions, t_6, tupledArg_1[1], item(i_2, tags_2)["value"]);
741
+ tagSignature(definitions, t_6, tupledArg_1[1], item_1(i_2, tags_2)["value"]);
742
742
  }, toList(values_2));
743
743
  break;
744
744
  }
@@ -750,6 +750,29 @@ function tagSignature(definitions_mut, expected_mut, value_mut, tagged_mut) {
750
750
  }
751
751
  }
752
752
 
753
+ function permissionsFromJs(value) {
754
+ if (typeof value === 'undefined' || value === null) {
755
+ return 0;
756
+ }
757
+ else if (!(Array.isArray(value))) {
758
+ throw new Exception("permissions must be an array of capability names");
759
+ }
760
+ else {
761
+ return fold((permissions, item) => {
762
+ let name;
763
+ if ((typeof item) === "string") {
764
+ name = item;
765
+ }
766
+ else {
767
+ throw new Exception("permissions must contain capability names");
768
+ }
769
+ return permissions | ((name === "None") ? 0 : ((name === "Interactive") ? 1 : ((name === "Threading") ? 2 : ((name === "IO") ? 4 : ((name === "Native") ? 8 : (() => {
770
+ throw new Exception(concat("Unknown host permission: ", name));
771
+ })())))));
772
+ }, 0, value);
773
+ }
774
+ }
775
+
753
776
  function buildExternal(definitions, definition) {
754
777
  return withStructuredErrors(() => {
755
778
  const name = getRequiredProperty("name", definition);
@@ -759,7 +782,7 @@ function buildExternal(definitions, definition) {
759
782
  if ((typeof invoke_1) !== "function") {
760
783
  throw new Exception("invoke must be a JavaScript function");
761
784
  }
762
- return new ExternalFunction(name, scheme, (context, args) => {
785
+ return new ExternalFunction(permissionsFromJs(definition["requiredPermissions"]), name, scheme, (context, args) => {
763
786
  const check = () => {
764
787
  if (!context.IsActive()) {
765
788
  throw new Exception("Expired invocation context");
@@ -845,7 +868,7 @@ function buildExternal(definitions, definition) {
845
868
  }
846
869
  else if (isEmpty(Types_ftvType(signature))) {
847
870
  const signature_2 = signature;
848
- result = validateCall(definitions, signature_2, arguments$_1, () => fold(context.Apply, fnValue, arguments$_1));
871
+ result = validateCall(definitions, signature_2, arguments$_1, () => fold_1(context.Apply, fnValue, arguments$_1));
849
872
  }
850
873
  else {
851
874
  throw new Exception("Callback invocation requires a closed function type; use HostFunctions.create");
@@ -1139,7 +1162,7 @@ function validateRegistration(registration_1) {
1139
1162
  finally {
1140
1163
  disposeSafe(enumerator_2);
1141
1164
  }
1142
- return new ExtensionRegistration(registration_1.Types, registration_1.Unions, map((fn_1) => {
1165
+ return new ExtensionRegistration(registration_1.Permissions, registration_1.Types, registration_1.Unions, map((fn_1) => {
1143
1166
  const definition = externDefinitions.get(fn_1);
1144
1167
  if (typeof definition === 'undefined' || definition === null) {
1145
1168
  return fn_1;
@@ -1165,7 +1188,7 @@ function registrationOverride(fallback, value) {
1165
1188
  return fallback;
1166
1189
  }
1167
1190
  else if (Array.isArray(value)) {
1168
- return validateRegistration(new ExtensionRegistration(fallback.Types, fallback.Unions, externsFromArray(value)));
1191
+ return validateRegistration(new ExtensionRegistration(fallback.Permissions, fallback.Types, fallback.Unions, externsFromArray(value)));
1169
1192
  }
1170
1193
  else {
1171
1194
  return registrationFromHandle(value);
@@ -1173,11 +1196,12 @@ function registrationOverride(fallback, value) {
1173
1196
  }
1174
1197
 
1175
1198
  function registrationFromOptions(options) {
1176
- let option_1;
1199
+ let option_1, option_4;
1177
1200
  let registration_1;
1178
1201
  const matchValue = tryGetProperty("registration", options);
1179
1202
  registration_1 = ((matchValue == null) ? empty_2 : registrationFromHandle(value_15(matchValue)));
1180
- return validateRegistration(new ExtensionRegistration(registration_1.Types, registration_1.Unions, append(registration_1.Functions, defaultArg((option_1 = tryGetProperty("externs", options), (option_1 != null) ? externsFromArray(value_15(option_1)) : undefined), empty()))));
1203
+ const functions = defaultArg((option_1 = tryGetProperty("externs", options), (option_1 != null) ? externsFromArray(value_15(option_1)) : undefined), empty());
1204
+ return permitted(validateRegistration(new ExtensionRegistration(defaultArg((option_4 = tryGetProperty("permissions", options), (option_4 != null) ? permissionsFromJs(value_15(option_4)) : undefined), registration_1.Permissions), registration_1.Types, registration_1.Unions, append(registration_1.Functions, functions))));
1181
1205
  }
1182
1206
 
1183
1207
  function optionString(name, fallback, options) {
@@ -1466,7 +1490,7 @@ export function invoke(loaded, name, args) {
1466
1490
  }
1467
1491
  const fnValue = FSharpMap__get_Item(loaded_1.exportedFunctions, name);
1468
1492
  const values = (typeof args === 'undefined' || args === null) ? empty() : map(valueFromJs, ofArray(args));
1469
- return valueToTagged(validateCall(loaded_1.typeDefs, FSharpMap__get_Item(loaded_1.exportedFunctionTypes, name), values, () => invokeValue(loaded_1.typeDefs, fnValue, values)));
1493
+ return valueToTagged(validateCall(loaded_1.typeDefs, FSharpMap__get_Item(loaded_1.exportedFunctionTypes, name), values, () => invokeValueWithPermissionsAndExitCode(loaded_1.registration.Permissions, loaded_1.typeDefs, fnValue, values).Value));
1470
1494
  });
1471
1495
  }
1472
1496
 
@@ -1515,6 +1539,7 @@ export function extern(definition) {
1515
1539
  arity: fn.Arity,
1516
1540
  scheme: fn.Scheme,
1517
1541
  invoke: getRequiredProperty("invoke", definition),
1542
+ requiredPermissions: definition["requiredPermissions"],
1518
1543
  };
1519
1544
  copied = (Object.freeze(_value));
1520
1545
  externDefinitions.set(fn, copied);
@@ -1553,7 +1578,7 @@ function describeType(definition) {
1553
1578
  else {
1554
1579
  constructible = false;
1555
1580
  }
1556
- typeDefinitions(new ExtensionRegistration(singleton(new HostTypeDescriptor(name, fields_1, !constructible)), empty_2.Unions, empty_2.Functions), empty());
1581
+ typeDefinitions(new ExtensionRegistration(empty_2.Permissions, singleton(new HostTypeDescriptor(name, fields_1, !constructible)), empty_2.Unions, empty_2.Functions), empty());
1557
1582
  const _value_1 = {
1558
1583
  name: name,
1559
1584
  fields: (_value = propertiesObject(map((tupledArg) => [tupledArg[0], tupledArg[1]], toList(fields_1))), (() => { const visit = v => { if (v && typeof v === 'object' && !Object.isFrozen(v)) { for (const key of Object.keys(v)) visit(v[key]); Object.freeze(v); } }; visit(_value); return _value; })()),
@@ -1568,7 +1593,7 @@ function describeUnion(definition) {
1568
1593
  let copied;
1569
1594
  const _value = propertiesObject(ofArray(map_1((k) => [k, cases[k]], Object.keys(cases))));
1570
1595
  copied = (Object.freeze(_value));
1571
- typeDefinitions(new ExtensionRegistration(empty_2.Types, singleton(new HostUnionDescriptor(name, ofList(map((k_1) => {
1596
+ typeDefinitions(new ExtensionRegistration(empty_2.Permissions, empty_2.Types, singleton(new HostUnionDescriptor(name, ofList(map((k_1) => {
1572
1597
  const t = copied[k_1];
1573
1598
  return [k_1, (typeof t === 'undefined' || t === null) ? undefined : t];
1574
1599
  }, ofArray(Object.keys(copied))), {
@@ -1591,7 +1616,7 @@ export function registration(definition) {
1591
1616
  let option_1;
1592
1617
  return ofArray(defaultArg((option_1 = tryGetProperty(name, definition), (option_1 != null) ? value_15(option_1) : undefined), []));
1593
1618
  };
1594
- const value_6 = validateRegistration(new ExtensionRegistration(map((d) => {
1619
+ const value_6 = validateRegistration(new ExtensionRegistration(0, map((d) => {
1595
1620
  const d_1 = describeType(d);
1596
1621
  return new HostTypeDescriptor(d_1["name"], fieldTypes(d_1["fields"]), !(d_1["scriptConstructible"]));
1597
1622
  }, entries("types")), map((d_2) => {
@@ -1737,6 +1762,7 @@ export const HostFunctions = (() => {
1737
1762
  arity: length(parameters),
1738
1763
  scheme: new Scheme(empty(), signature),
1739
1764
  invoke: getRequiredProperty("invoke", definition),
1765
+ requiredPermissions: definition["requiredPermissions"],
1740
1766
  });
1741
1767
  }),
1742
1768
  };