@glutinum/cli 1.0.0-beta.6 → 1.0.0-beta.8

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.
@@ -9,7 +9,7 @@ import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FS
9
9
  import { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
10
10
  import { class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
11
11
  import { tryPick, map as map_2, last, iterate, toList, tryHead, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
12
- import { PackageContext__ModulePath_Z7E147617, PackageContext__NestedAmbientModuleSegments_32BC514A, PackageContext__IsEntryFile_Z721C83C5, ambientSpecifier, PackageContext__IsExternal_Z721C83C5, PackageContext__TryFindExternalModulePath_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
12
+ import { PackageContext__ModulePath_Z7E147617, PackageContext__NestedAmbientModuleSegments_32BC514A, PackageContext__IsExternalLibFile_Z721C83C5, PackageContext__IsEntryFile_Z721C83C5, ambientSpecifier, PackageContext__IsExternal_Z721C83C5, PackageContext__TryFindExternalModulePath_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
13
13
  import { tail, append, cons, tryHead as tryHead_1, exists as exists_1, tryFind, isEmpty, filter, head, tryItem, mapIndexed, choose, ofArray, contains, collect as collect_1, empty, map as map_1 } from "../../fable_modules/fable-library-js.5.17.2/List.js";
14
14
  import { item as item_1 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
15
15
  import { contains as contains_1, ofSeq } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
@@ -610,73 +610,91 @@ export function readHeritageClauses(reader, heritageClauses) {
610
610
  }
611
611
  }
612
612
 
613
- /**
614
- * Determine if the type is from the ES5 library
615
- *
616
- * This is to detect native utility types usage
617
- */
618
- export function isFromEs5Lib(symbolOpt) {
619
- if (symbolOpt != null) {
620
- const symbol = symbolOpt;
621
- const matchValue = symbol.declarations;
622
- if (matchValue != null) {
623
- const declarations = matchValue;
624
- if ((declarations.length === 0) ? true : Operators_IsNull(item_1(0, declarations).parent)) {
625
- return false;
626
- }
627
- else if (item_1(0, declarations).parent.kind === 308) {
628
- const sourceFile = item_1(0, declarations).parent;
629
- return sourceFile.fileName.endsWith("/lib.es5.d.ts");
630
- }
631
- else {
632
- return false;
633
- }
613
+ function libDeclaration(symbolOpt) {
614
+ let option_3;
615
+ const option_1 = symbolOpt;
616
+ if (option_1 != null) {
617
+ const symbol = option_1;
618
+ option_3 = symbol.declarations;
619
+ }
620
+ else {
621
+ option_3 = undefined;
622
+ }
623
+ if (option_3 != null) {
624
+ const declarations = option_3;
625
+ if ((declarations.length === 0) ? true : Operators_IsNull(item_1(0, declarations).parent)) {
626
+ return undefined;
634
627
  }
635
628
  else {
636
- return contains(symbol.name, ofArray(["Iterable", "IterableIterator"]), {
637
- Equals: (x, y) => (x === y),
638
- GetHashCode: (x) => (stringHash(x) | 0),
639
- });
629
+ return item_1(0, declarations);
640
630
  }
641
631
  }
642
632
  else {
643
- return false;
633
+ return undefined;
644
634
  }
645
635
  }
646
636
 
647
637
  /**
648
- * `PromiseConstructor` of `lib.es2015.promise.d.ts`: a type of the ECMAScript libraries
638
+ * `Omit`, `Partial` and the other utility types are declared at the top of `lib.es5.d.ts`
649
639
  */
650
- export function isFromEsLib(symbolOpt) {
651
- let declarations;
640
+ export function isFromEs5Lib(symbolOpt) {
641
+ let declaration, symbol;
642
+ let matchResult, symbol_1;
652
643
  if (symbolOpt != null) {
653
- const symbol = symbolOpt;
654
- const matchValue = symbol.declarations;
655
- let matchResult, declarations_1;
656
- if (matchValue != null) {
657
- if ((declarations = matchValue, declarations.length > 0)) {
658
- matchResult = 0;
659
- declarations_1 = matchValue;
660
- }
661
- else {
662
- matchResult = 1;
663
- }
644
+ if ((symbol = symbolOpt, symbol.declarations == null)) {
645
+ matchResult = 0;
646
+ symbol_1 = symbolOpt;
664
647
  }
665
648
  else {
666
649
  matchResult = 1;
667
650
  }
668
- switch (matchResult) {
669
- case 0: {
670
- const fileName = normalizePath(item_1(0, declarations_1).getSourceFile().fileName);
671
- return fileName.indexOf("/lib/lib.es") >= 0;
651
+ }
652
+ else {
653
+ matchResult = 1;
654
+ }
655
+ switch (matchResult) {
656
+ case 0:
657
+ return contains(symbol_1.name, ofArray(["Iterable", "IterableIterator"]), {
658
+ Equals: (x, y) => (x === y),
659
+ GetHashCode: (x) => (stringHash(x) | 0),
660
+ });
661
+ default: {
662
+ const matchValue = libDeclaration(symbolOpt);
663
+ let matchResult_1, declaration_1;
664
+ if (matchValue != null) {
665
+ if ((declaration = matchValue, declaration.parent.kind === 308)) {
666
+ matchResult_1 = 0;
667
+ declaration_1 = matchValue;
668
+ }
669
+ else {
670
+ matchResult_1 = 1;
671
+ }
672
+ }
673
+ else {
674
+ matchResult_1 = 1;
675
+ }
676
+ switch (matchResult_1) {
677
+ case 0:
678
+ return declaration_1.parent.fileName.endsWith("/lib.es5.d.ts");
679
+ default:
680
+ return false;
672
681
  }
673
- default:
674
- return false;
675
682
  }
676
683
  }
677
- else {
684
+ }
685
+
686
+ /**
687
+ * `PromiseConstructor` of `lib.es2015.promise.d.ts`: a type of the ECMAScript libraries
688
+ */
689
+ export function isFromEsLib(symbolOpt) {
690
+ const matchValue = libDeclaration(symbolOpt);
691
+ if (matchValue == null) {
678
692
  return false;
679
693
  }
694
+ else {
695
+ const declaration = matchValue;
696
+ return normalizePath(declaration.getSourceFile().fileName).indexOf("/lib/lib.es") >= 0;
697
+ }
680
698
  }
681
699
 
682
700
  export const knownExternalTypeNames = ofSeq(["Date", "Promise", "Array", "ReadonlyArray", "Boolean", "Function", "Error", "RegExp", "Iterable", "IterableIterator", "IteratorObject", "ArrayIterator", "MapIterator", "SetIterator", "StringIterator", "Uint8Array", "Int8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"], {
@@ -699,6 +717,19 @@ export function resolveAlias(checker, symbol) {
699
717
  }
700
718
  }
701
719
 
720
+ /**
721
+ * `type X` beside `export { x as X }` is one symbol flagged both `TypeAlias` and `Alias`
722
+ */
723
+ export function resolveValueAlias(checker, symbol) {
724
+ const matchValue = symbol.flags;
725
+ if ($007CHasSymbolFlags$007C_$007C(788968, matchValue) != null) {
726
+ return symbol;
727
+ }
728
+ else {
729
+ return resolveAlias(checker, symbol);
730
+ }
731
+ }
732
+
702
733
  /**
703
734
  * `Omit<LabelOption, "rotate">` where `interface LabelOption<T = Params>`: `T` is `Params`
704
735
  */
@@ -772,40 +803,58 @@ export function declaredName(symbol) {
772
803
  */
773
804
  export function importedName(checker, symbol) {
774
805
  let target, target_1;
806
+ let isType;
775
807
  const matchValue = symbol.flags;
776
- if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
777
- const matchValue_1 = resolveAlias(checker, symbol);
778
- let matchResult, target_2, target_3;
779
- if (matchValue_1 != null) {
780
- if ((target = matchValue_1, target.name === "default")) {
781
- matchResult = 0;
782
- target_2 = matchValue_1;
783
- }
784
- else if ((target_1 = matchValue_1, (target_1.name !== symbol.name) && (target_1.name !== "export="))) {
785
- matchResult = 1;
786
- target_3 = matchValue_1;
787
- }
788
- else {
789
- matchResult = 2;
790
- }
808
+ isType = ($007CHasSymbolFlags$007C_$007C(788968, matchValue) != null);
809
+ const matchValue_1 = symbol.flags;
810
+ let matchResult;
811
+ if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue_1) != null) {
812
+ if (!isType) {
813
+ matchResult = 0;
791
814
  }
792
815
  else {
793
- matchResult = 2;
794
- }
795
- switch (matchResult) {
796
- case 0:
797
- return declaredName(target_2);
798
- case 1:
799
- return target_3.name;
800
- default:
801
- return undefined;
816
+ matchResult = 1;
802
817
  }
803
818
  }
804
- else if (symbol.name === "default") {
805
- return declaredName(symbol);
806
- }
807
819
  else {
808
- return undefined;
820
+ matchResult = 1;
821
+ }
822
+ switch (matchResult) {
823
+ case 0: {
824
+ const matchValue_2 = resolveAlias(checker, symbol);
825
+ let matchResult_1, target_2, target_3;
826
+ if (matchValue_2 != null) {
827
+ if ((target = matchValue_2, target.name === "default")) {
828
+ matchResult_1 = 0;
829
+ target_2 = matchValue_2;
830
+ }
831
+ else if ((target_1 = matchValue_2, (target_1.name !== symbol.name) && (target_1.name !== "export="))) {
832
+ matchResult_1 = 1;
833
+ target_3 = matchValue_2;
834
+ }
835
+ else {
836
+ matchResult_1 = 2;
837
+ }
838
+ }
839
+ else {
840
+ matchResult_1 = 2;
841
+ }
842
+ switch (matchResult_1) {
843
+ case 0:
844
+ return declaredName(target_2);
845
+ case 1:
846
+ return target_3.name;
847
+ default:
848
+ return undefined;
849
+ }
850
+ }
851
+ default:
852
+ if (symbol.name === "default") {
853
+ return declaredName(symbol);
854
+ }
855
+ else {
856
+ return undefined;
857
+ }
809
858
  }
810
859
  }
811
860
 
@@ -1342,8 +1391,8 @@ export function isGlobalScriptOfPackage(packageContext, sourceFile) {
1342
1391
  }
1343
1392
  else {
1344
1393
  const packageContext_1 = packageContext;
1345
- if (!(ts.isExternalModule(sourceFile)) && (promotedAmbientModule(sourceFile) == null)) {
1346
- return !PackageContext__IsEntryFile_Z721C83C5(packageContext_1, sourceFile.fileName);
1394
+ if ((!(ts.isExternalModule(sourceFile)) && (promotedAmbientModule(sourceFile) == null)) && !PackageContext__IsEntryFile_Z721C83C5(packageContext_1, sourceFile.fileName)) {
1395
+ return !PackageContext__IsExternalLibFile_Z721C83C5(packageContext_1, sourceFile.fileName);
1347
1396
  }
1348
1397
  else {
1349
1398
  return false;
@@ -1682,3 +1731,25 @@ export function isPrivateMember(modifiers, name) {
1682
1731
  }
1683
1732
  }
1684
1733
 
1734
+ /**
1735
+ * The node a reference lands at, the reference itself unless members are read for another declaration
1736
+ */
1737
+ export function landingOf(reader, node) {
1738
+ if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length === 0) {
1739
+ return node;
1740
+ }
1741
+ else {
1742
+ return item_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length - 1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing);
1743
+ }
1744
+ }
1745
+
1746
+ export function isLibraryName(reader, name) {
1747
+ const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
1748
+ if (matchValue == null) {
1749
+ return false;
1750
+ }
1751
+ else {
1752
+ return matchValue.IsLibraryName(name);
1753
+ }
1754
+ }
1755
+