@magnusopera/fscript 0.92.2 → 0.92.4

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.
@@ -1,15 +1,15 @@
1
1
 
2
2
  import { printf, toText, getCharAtIndex, isNullOrWhiteSpace, concat, endsWith, substring, split, join, trimEnd, startsWith, replace, isNullOrEmpty, compare } from "../fable_modules/fable-library-js.5.27.0/String.js";
3
3
  import { exists, choose, collect, append, map, ofArray, fold as fold_1, singleton, empty, tail as tail_2, cons, head as head_1, isEmpty, reverse } from "../fable_modules/fable-library-js.5.27.0/List.js";
4
- import { fold } from "../fable_modules/fable-library-js.5.27.0/Array.js";
4
+ import { addRangeInPlace, fold } from "../fable_modules/fable-library-js.5.27.0/Array.js";
5
5
  import { ParseException, ParseError } from "./Error.js";
6
6
  import { isLetterOrDigit, isLetter } from "../fable_modules/fable-library-js.5.27.0/Char.js";
7
7
  import { map as map_1, toList as toList_1, fold as fold_2, forAll } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
8
8
  import { union, toList, ofList, FSharpSet__Contains, empty as empty_1, add } from "../fable_modules/fable-library-js.5.27.0/Set.js";
9
- import { curry4, defaultOf, disposeSafe, getEnumerator, Exception, curry2, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
10
- import { ofSeq, empty as empty_2, add as add_1, FSharpMap__ContainsKey, FSharpMap__get_Item } from "../fable_modules/fable-library-js.5.27.0/Map.js";
9
+ import { compare as compare_1, curry4, defaultOf, disposeSafe, getEnumerator, Exception, curry2, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
10
+ import { toSeq, ofSeq, empty as empty_2, add as add_1, FSharpMap__ContainsKey, FSharpMap__get_Item } from "../fable_modules/fable-library-js.5.27.0/Map.js";
11
11
  import { Stmt, TypeDef, InterpolatedPart, MapEntry, Param, Expr, Pattern, TypeRef } from "./Ast.js";
12
- import { parseProgramWithSourceName } from "./Parser.js";
12
+ import { parseProgramWithRecordFieldLabels, parseProgramWithSourceName } from "./Parser.js";
13
13
  import { FSharpRef } from "../fable_modules/fable-library-js.5.27.0/Types.js";
14
14
  import { Span, Position } from "./Span.js";
15
15
  import { addToSet, tryGetValue } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
@@ -779,7 +779,7 @@ export function parseProgramFromFile(rootDirectory, entryFile) {
779
779
  throw new ParseException(new ParseError("File-backed imports are not supported in Fable builds; use resolver-backed source imports", new Span(p, p)));
780
780
  }
781
781
 
782
- function parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entrySource, resolveImportedSource) {
782
+ function parseProgramFromSourceWithIncludesCore(parseSource, rootDirectory, entryFile, entrySource, resolveImportedSource) {
783
783
  const rootDirectoryWithSeparator = normalizeDirectoryPath(rootDirectory);
784
784
  const fileSpan = (path) => {
785
785
  const p = new Position(path, 1, 1);
@@ -808,7 +808,7 @@ function parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entryS
808
808
  if (!isMainFile) {
809
809
  addToSet(sandboxedPath, emittedFiles);
810
810
  }
811
- const program = parseProgramWithSourceName(sandboxedPath, pathsEqual(sandboxedPath, entrySandboxedPath) ? entrySource : ((resolveImportedSource == null) ? (() => {
811
+ const program = parseSource(sandboxedPath, pathsEqual(sandboxedPath, entrySandboxedPath) ? entrySource : ((resolveImportedSource == null) ? (() => {
812
812
  throw new ParseException(new ParseError(concat("Imported file \'", sandboxedPath, "\' could not be resolved; Fable hosts must provide a resolver"), fileSpan(sandboxedPath)));
813
813
  })() : ((matchValue_1 = resolveImportedSource(sandboxedPath), (matchValue_1 == null) ? (() => {
814
814
  throw new ParseException(new ParseError(concat("Imported file \'", sandboxedPath, "\' could not be resolved"), fileSpan(sandboxedPath)));
@@ -836,17 +836,28 @@ function parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entryS
836
836
  }
837
837
 
838
838
  export function parseProgramFromSourceWithIncludes(rootDirectory, entryFile, entrySource) {
839
- return parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entrySource, undefined)[0];
839
+ return parseProgramFromSourceWithIncludesCore(parseProgramWithSourceName, rootDirectory, entryFile, entrySource, undefined)[0];
840
840
  }
841
841
 
842
842
  export function parseProgramFromSourceWithIncludesResolver(rootDirectory, entryFile, entrySource, resolveImportedSource) {
843
- return parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entrySource, resolveImportedSource)[0];
843
+ return parseProgramFromSourceWithIncludesCore(parseProgramWithSourceName, rootDirectory, entryFile, entrySource, resolveImportedSource)[0];
844
844
  }
845
845
 
846
846
  /**
847
847
  * Includes source-module identities for tools which need to display original aliases.
848
848
  */
849
849
  export function parseProgramFromSourceWithIncludesResolverAndMetadata(rootDirectory, entryFile, entrySource, resolveImportedSource) {
850
- return parseProgramFromSourceWithIncludesCore(rootDirectory, entryFile, entrySource, resolveImportedSource);
850
+ return parseProgramFromSourceWithIncludesCore(parseProgramWithSourceName, rootDirectory, entryFile, entrySource, resolveImportedSource);
851
+ }
852
+
853
+ export function parseProgramFromSourceWithIncludesAndRecordFieldLabels(rootDirectory, entryFile, entrySource) {
854
+ const labels = [];
855
+ return [parseProgramFromSourceWithIncludesCore((sourceName, source) => {
856
+ const patternInput = parseProgramWithRecordFieldLabels(sourceName, source);
857
+ addRangeInPlace(toSeq(patternInput[1]), labels);
858
+ return patternInput[0];
859
+ }, rootDirectory, entryFile, entrySource, undefined)[0], ofSeq(labels, {
860
+ Compare: (x, y) => (compare_1(x, y) | 0),
861
+ })];
851
862
  }
852
863