@r_masseater/vite-plus-adopt 0.11.1 → 0.13.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.
- package/README.md +8 -21
- package/THIRD-PARTY-NOTICES +0 -251
- package/dist/attw.mjs +289 -254
- package/dist/attw.mjs.map +1 -1
- package/dist/cli.mjs +7 -9
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +61 -2
- package/dist/index.mjs +1 -1
- package/dist/{vpa-MRYbih3E.mjs → vpa-jp87uBqF.mjs} +85 -51
- package/dist/vpa-jp87uBqF.mjs.map +1 -0
- package/package.json +26 -57
- package/skills/configure-checks/SKILL.md +5 -13
- package/dist/fsd.d.mts +0 -10
- package/dist/fsd.mjs +0 -1336
- package/dist/fsd.mjs.map +0 -1
- package/dist/index-DyvYt7R0.d.mts +0 -173
- package/dist/parsers/tree-sitter-astro.wasm +0 -0
- package/dist/parsers/tree-sitter-svelte.wasm +0 -0
- package/dist/parsers/tree-sitter-tsx.wasm +0 -0
- package/dist/parsers/tree-sitter-vue.wasm +0 -0
- package/dist/steiger-CbusAzht.mjs +0 -5944
- package/dist/steiger-CbusAzht.mjs.map +0 -1
- package/dist/vpa-MRYbih3E.mjs.map +0 -1
package/dist/attw.mjs
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { t as parseJson } from "./json-QtVKpodH.mjs";
|
|
2
2
|
import { Array as Array$1, Function, MutableRef, Option, Order, Predicate, Record, String as String$1, pipe } from "effect";
|
|
3
3
|
import semver, { major, maxSatisfying, minor, valid, validRange } from "semver";
|
|
4
|
-
import { serverFS } from "typescript/fs";
|
|
5
|
-
import { API, ModuleKind, ModuleResolutionKind, ObjectFlags, SignatureKind, SymbolFlags, TypeFlags, isObjectType } from "typescript/sync";
|
|
6
4
|
import { init, parse } from "cjs-module-lexer";
|
|
7
5
|
import { InternalSymbolName, ModifierFlags, NodeFlags, ScriptKind, ScriptTarget, SyntaxKind, escapeLeadingUnderscores, getNameOfDeclaration } from "typescript/ast";
|
|
6
|
+
import { API, ModuleKind, ModuleResolutionKind, ObjectFlags, SignatureKind, SymbolFlags, TypeFlags, isObjectType } from "typescript/sync";
|
|
8
7
|
import { isArrayBindingPattern, isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBindingElement, isBlock, isCallExpression, isCatchClause, isClassDeclaration, isClassExpression, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isExportSpecifier, isExpression, isExpressionStatement, isForInStatement, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportAttributes, isImportClause, isImportDeclaration, isImportEqualsDeclaration, isImportSpecifier, isImportTypeNode, isInterfaceDeclaration, isJSDoc, isJSDocCallbackTag, isJSDocImportTag, isJSDocTypedefTag, isModuleBlock, isModuleDeclaration, isNamedExports, isNamespaceExport, isNamespaceImport, isNumericLiteral, isObjectBindingPattern, isObjectLiteralExpression, isParameterDeclaration, isParenthesizedExpression, isPrefixUnaryExpression, isPropertyAccessExpression, isPropertyAssignment, isReturnStatement, isShorthandPropertyAssignment, isSourceFile, isStringLiteral, isStringLiteralLikeNode, isTypeAliasDeclaration, isVariableDeclaration, isVariableDeclarationList, isVariableStatement, isVoidExpression } from "typescript/ast/is";
|
|
8
|
+
import { serverFS } from "typescript/fs";
|
|
9
9
|
import { untar } from "@andrewbranch/untar.js";
|
|
10
10
|
import { FlateErrorCode, Gunzip } from "fflate";
|
|
11
11
|
import validatePackgeName from "validate-npm-package-name";
|
|
12
12
|
import * as cjs from "@loaderkit/resolve/cjs";
|
|
13
13
|
import * as esm from "@loaderkit/resolve/esm";
|
|
14
|
+
// src/shared/lib/typescript/binder-symbol-table.ts
|
|
15
|
+
var SymbolTable = class {
|
|
16
|
+
#entries = /* @__PURE__ */ new Map();
|
|
17
|
+
get entries() {
|
|
18
|
+
return this.#entries;
|
|
19
|
+
}
|
|
20
|
+
add = (symbol) => {
|
|
21
|
+
this.#entries.set(symbol.escapedName, symbol);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
14
24
|
// src/shared/lib/typescript/flags.ts
|
|
15
25
|
const DATA_FIRST_ARITY$36 = 2;
|
|
16
26
|
const SET_BIT = 1;
|
|
@@ -25,7 +35,6 @@ const withoutFlags = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => flags -
|
|
|
25
35
|
const combineFlags = (...masks) => Array$1.reduce(masks, 0, withFlags);
|
|
26
36
|
// src/shared/lib/typescript/binder-symbols.ts
|
|
27
37
|
const DATA_FIRST_ARITY$35 = 2;
|
|
28
|
-
const DATA_FIRST_ARITY_3$22 = 3;
|
|
29
38
|
const UNDERSCORE = "_";
|
|
30
39
|
const DOUBLE_UNDERSCORE = "__";
|
|
31
40
|
const TRIPLE_UNDERSCORE = "___";
|
|
@@ -38,11 +47,6 @@ const escapeLeadingUnderscores$1 = (name) => {
|
|
|
38
47
|
if (String$1.startsWith(DOUBLE_UNDERSCORE)(name)) return `${UNDERSCORE}${name}`;
|
|
39
48
|
return name;
|
|
40
49
|
};
|
|
41
|
-
const createSymbol = Function.dual(DATA_FIRST_ARITY$35, (flags, escapedName) => ({
|
|
42
|
-
flags,
|
|
43
|
-
escapedName,
|
|
44
|
-
name: unescapeLeadingUnderscores(escapedName)
|
|
45
|
-
}));
|
|
46
50
|
const isInJsFileNode = (node) => {
|
|
47
51
|
let current = node;
|
|
48
52
|
while (!isSourceFile(current)) current = current.parent;
|
|
@@ -62,49 +66,80 @@ const isAmbientOverride = (existing, node) => isAmbientNode(node) && !isInJsFile
|
|
|
62
66
|
const replacesAssignmentDeclaration = (existing, node) => !isAmbientOverride(existing, node) && isAssignmentDeclarationNode(existing) && !isAssignmentDeclarationNode(node);
|
|
63
67
|
const replacesModuleDeclaration = (existing, node) => existing.kind !== node.kind && isEffectiveModuleDeclaration(existing);
|
|
64
68
|
const replacesValueDeclaration = (existing, node) => replacesAssignmentDeclaration(existing, node) || replacesModuleDeclaration(existing, node);
|
|
65
|
-
const setValueDeclaration = Function.dual(DATA_FIRST_ARITY$35, (symbol, node) => {
|
|
66
|
-
const existing = symbol.valueDeclaration;
|
|
67
|
-
if (Predicate.isUndefined(existing) || replacesValueDeclaration(existing, node)) symbol.valueDeclaration = node;
|
|
68
|
-
});
|
|
69
69
|
const EXPORT_TABLE_FLAGS = combineFlags(SymbolFlags.Class, SymbolFlags.Enum, SymbolFlags.Module, SymbolFlags.Variable);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
const entriesOf = (table) => table.entries;
|
|
71
|
+
var BoundSymbol = class {
|
|
72
|
+
escapedName;
|
|
73
|
+
name;
|
|
74
|
+
#flags;
|
|
75
|
+
#declarations;
|
|
76
|
+
#valueDeclaration;
|
|
77
|
+
#exports = Option.none();
|
|
78
|
+
#parent;
|
|
79
|
+
#exportSymbol;
|
|
80
|
+
constructor(flags, escapedName) {
|
|
81
|
+
this.#flags = flags;
|
|
82
|
+
this.escapedName = escapedName;
|
|
83
|
+
this.name = unescapeLeadingUnderscores(escapedName);
|
|
84
|
+
}
|
|
85
|
+
get flags() {
|
|
86
|
+
return this.#flags;
|
|
87
|
+
}
|
|
88
|
+
get declarations() {
|
|
89
|
+
return this.#declarations;
|
|
90
|
+
}
|
|
91
|
+
get valueDeclaration() {
|
|
92
|
+
return this.#valueDeclaration;
|
|
93
|
+
}
|
|
94
|
+
get exports() {
|
|
95
|
+
return this.#exports.pipe(Option.map(entriesOf), Option.getOrUndefined);
|
|
96
|
+
}
|
|
97
|
+
get parent() {
|
|
98
|
+
return this.#parent;
|
|
99
|
+
}
|
|
100
|
+
get exportSymbol() {
|
|
101
|
+
return this.#exportSymbol;
|
|
102
|
+
}
|
|
103
|
+
get exportTable() {
|
|
104
|
+
return this.#exports;
|
|
105
|
+
}
|
|
106
|
+
openExports = () => {
|
|
107
|
+
this.#exports = Option.orElseSome(this.#exports, () => new SymbolTable());
|
|
108
|
+
};
|
|
109
|
+
setValueDeclaration = (node) => {
|
|
110
|
+
const existing = this.#valueDeclaration;
|
|
111
|
+
if (Predicate.isUndefined(existing) || replacesValueDeclaration(existing, node)) this.#valueDeclaration = node;
|
|
112
|
+
};
|
|
113
|
+
addDeclaration = (node, flags) => {
|
|
114
|
+
this.#flags = withFlags(this.#flags, flags);
|
|
115
|
+
const declarations = this.#declarations ?? [];
|
|
116
|
+
if (!declarations.includes(node)) this.#declarations = [...declarations, node];
|
|
117
|
+
if (hasFlag(flags, EXPORT_TABLE_FLAGS)) this.openExports();
|
|
118
|
+
if (hasFlag(flags, SymbolFlags.Value)) this.setValueDeclaration(node);
|
|
119
|
+
};
|
|
120
|
+
adoptedBy = (parent) => {
|
|
121
|
+
this.#parent ??= parent;
|
|
122
|
+
};
|
|
123
|
+
exportThrough = (symbol) => {
|
|
124
|
+
this.#exportSymbol = symbol;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
92
127
|
const conflicts = (found, declaration) => hasFlag(found.flags, declaration.excludes) && !(hasFlag(declaration.includes, SymbolFlags.Variable) && hasFlag(found.flags, SymbolFlags.Assignment));
|
|
93
128
|
const symbolInTable = (table, name, declaration) => {
|
|
94
|
-
const found = table.get(name);
|
|
129
|
+
const found = table.entries.get(name);
|
|
95
130
|
if (Predicate.isUndefined(found)) {
|
|
96
|
-
const created =
|
|
97
|
-
table.
|
|
131
|
+
const created = new BoundSymbol(0, name);
|
|
132
|
+
table.add(created);
|
|
98
133
|
return created;
|
|
99
134
|
}
|
|
100
|
-
if (conflicts(found, declaration)) return
|
|
135
|
+
if (conflicts(found, declaration)) return new BoundSymbol(0, name);
|
|
101
136
|
return found;
|
|
102
137
|
};
|
|
103
138
|
const exportOf = Function.dual(DATA_FIRST_ARITY$35, (owner, name) => Option.flatMap(Option.fromNullishOr(owner.exports), (table) => Option.fromNullishOr(table.get(name))));
|
|
104
139
|
const declareSymbol = (declaration) => {
|
|
105
|
-
const symbol = Option.getOrElse(Option.zipWith(declaration.table, declaration.name, (table, name) => symbolInTable(table, name, declaration)), () =>
|
|
106
|
-
|
|
107
|
-
if (
|
|
140
|
+
const symbol = Option.getOrElse(Option.zipWith(declaration.table, declaration.name, (table, name) => symbolInTable(table, name, declaration)), () => new BoundSymbol(0, MISSING_NAME));
|
|
141
|
+
symbol.addDeclaration(declaration.node, declaration.includes);
|
|
142
|
+
if (Option.isSome(declaration.parent)) symbol.adoptedBy(declaration.parent.value);
|
|
108
143
|
return symbol;
|
|
109
144
|
};
|
|
110
145
|
// src/shared/lib/typescript/binder-syntax.ts
|
|
@@ -696,9 +731,38 @@ const getVersionPaths = Function.dual(DATA_FIRST_ARITY$29, (info, state) => info
|
|
|
696
731
|
// src/shared/lib/typescript/binder-declarations.ts
|
|
697
732
|
const DATA_FIRST_ARITY$28 = 2;
|
|
698
733
|
const DATA_FIRST_ARITY_3$19 = 3;
|
|
734
|
+
var FileBinding = class {
|
|
735
|
+
file;
|
|
736
|
+
locals = new SymbolTable();
|
|
737
|
+
isJs;
|
|
738
|
+
exportContext;
|
|
739
|
+
strict;
|
|
740
|
+
isExternalModule;
|
|
741
|
+
#symbol;
|
|
742
|
+
#commonJsModuleIndicator;
|
|
743
|
+
constructor(facts) {
|
|
744
|
+
this.file = facts.file;
|
|
745
|
+
this.isJs = facts.isJs;
|
|
746
|
+
this.exportContext = facts.exportContext;
|
|
747
|
+
this.strict = facts.strict;
|
|
748
|
+
this.isExternalModule = facts.isExternalModule;
|
|
749
|
+
}
|
|
750
|
+
get symbol() {
|
|
751
|
+
return this.#symbol;
|
|
752
|
+
}
|
|
753
|
+
get commonJsModuleIndicator() {
|
|
754
|
+
return this.#commonJsModuleIndicator;
|
|
755
|
+
}
|
|
756
|
+
attach = (symbol) => {
|
|
757
|
+
this.#symbol = symbol;
|
|
758
|
+
};
|
|
759
|
+
markCommonJs = (node) => {
|
|
760
|
+
this.#commonJsModuleIndicator = node;
|
|
761
|
+
};
|
|
762
|
+
};
|
|
699
763
|
const DEFAULT_NAME = "default";
|
|
700
764
|
const exportsOf = (owner) => ({
|
|
701
|
-
table: owner.pipe(Option.flatMap((symbol) =>
|
|
765
|
+
table: owner.pipe(Option.flatMap((symbol) => symbol.exportTable)),
|
|
702
766
|
parent: owner
|
|
703
767
|
});
|
|
704
768
|
const fileExports = (binding) => exportsOf(Option.fromNullishOr(binding.symbol));
|
|
@@ -742,7 +806,7 @@ const localExportFlags = (flags) => ({
|
|
|
742
806
|
const declareExportedMember = (binding, node, flags) => {
|
|
743
807
|
if (hasSyntacticModifier(node, ModifierFlags.Default) && Option.isNone(declarationName(node, binding.isJs))) return declareExport(binding, node, flags);
|
|
744
808
|
const local = declareLocal(binding, node, localExportFlags(flags));
|
|
745
|
-
local.
|
|
809
|
+
local.exportThrough(declareExport(binding, node, flags));
|
|
746
810
|
return local;
|
|
747
811
|
};
|
|
748
812
|
const isExportedDeclaration = (binding, node) => !isAmbientModule(node) && (isExportedMember(node) || binding.exportContext);
|
|
@@ -759,6 +823,16 @@ const declareBlockScoped = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node,
|
|
|
759
823
|
if (binding.isExternalModule || Predicate.isNotUndefined(binding.commonJsModuleIndicator)) return declareModuleMember(binding, node, flags);
|
|
760
824
|
return declareLocal(binding, node, flags);
|
|
761
825
|
});
|
|
826
|
+
const ALIAS = {
|
|
827
|
+
includes: SymbolFlags.Alias,
|
|
828
|
+
excludes: SymbolFlags.AliasExcludes
|
|
829
|
+
};
|
|
830
|
+
const inContainer = (flags) => (binding, node, scope) => {
|
|
831
|
+
if (scope.containerIsFile) declareSourceFileMember(binding, node, flags);
|
|
832
|
+
};
|
|
833
|
+
const inBlock = (flags) => (binding, node, scope) => {
|
|
834
|
+
if (scope.blockIsFile) declareBlockScoped(binding, node, flags);
|
|
835
|
+
};
|
|
762
836
|
// src/shared/lib/typescript/binder-cjs.ts
|
|
763
837
|
const DATA_FIRST_ARITY$27 = 2;
|
|
764
838
|
const DATA_FIRST_ARITY_3$18 = 3;
|
|
@@ -775,12 +849,12 @@ const EXPORT_ALIAS$1 = {
|
|
|
775
849
|
excludes: 0
|
|
776
850
|
};
|
|
777
851
|
const createFileSymbol = (binding) => {
|
|
778
|
-
const symbol =
|
|
779
|
-
|
|
780
|
-
binding.symbol
|
|
852
|
+
const symbol = new BoundSymbol(0, `"${String$1.replace(EXTENSION, "")(binding.file.fileName)}"`);
|
|
853
|
+
symbol.addDeclaration(binding.file, SymbolFlags.ValueModule);
|
|
854
|
+
binding.attach(symbol);
|
|
781
855
|
};
|
|
782
856
|
const lookupSymbolForName = Function.dual(DATA_FIRST_ARITY$27, (binding, name) => {
|
|
783
|
-
return Option.fromNullishOr(binding.locals.get(name)).pipe(Option.map((found) => found.exportSymbol ?? found)).pipe(Option.orElse(() => Option.fromNullishOr(binding.symbol).pipe(Option.flatMap((file) => exportOf(file, name)))));
|
|
857
|
+
return Option.fromNullishOr(binding.locals.entries.get(name)).pipe(Option.map((found) => found.exportSymbol ?? found)).pipe(Option.orElse(() => Option.fromNullishOr(binding.symbol).pipe(Option.flatMap((file) => exportOf(file, name)))));
|
|
784
858
|
});
|
|
785
859
|
const lookupIdentifier = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => Option.flatMap(Option.liftPredicate(node, isIdentifier), (identifier) => lookupSymbolForName(binding, escapeLeadingUnderscores$1(identifier.text))));
|
|
786
860
|
const variableInitializer = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => lookupIdentifier(binding, node).pipe(Option.flatMap((symbol) => Option.fromNullishOr(symbol.valueDeclaration)), Option.filter(isVariableDeclaration), Option.flatMap((declaration) => Option.fromNullishOr(declaration.initializer))));
|
|
@@ -802,7 +876,7 @@ const isExportsOrModuleExportsOrAlias = Function.dual(DATA_FIRST_ARITY$27, (bind
|
|
|
802
876
|
const setCommonJsModuleIndicator = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => {
|
|
803
877
|
if (binding.isExternalModule) return false;
|
|
804
878
|
if (Predicate.isUndefined(binding.commonJsModuleIndicator)) {
|
|
805
|
-
binding.
|
|
879
|
+
binding.markCommonJs(node);
|
|
806
880
|
createFileSymbol(binding);
|
|
807
881
|
}
|
|
808
882
|
return true;
|
|
@@ -825,7 +899,7 @@ const forEachIdentifierInEntityName = Function.dual(DATA_FIRST_ARITY$27, (bindin
|
|
|
825
899
|
return walk.action(accessNameOrArgument(node), memberOfAccess(node, parent), parent);
|
|
826
900
|
});
|
|
827
901
|
const markModuleAssignment = (name, symbol) => symbol.pipe(Option.map((found) => {
|
|
828
|
-
|
|
902
|
+
found.addDeclaration(name, MODULE_ASSIGNMENT);
|
|
829
903
|
return found;
|
|
830
904
|
}));
|
|
831
905
|
const exportsPropertyFlags = (node) => {
|
|
@@ -1010,7 +1084,7 @@ const lookupSymbolForPropertyAccess = (binding, node) => {
|
|
|
1010
1084
|
const isAliasSymbol = (symbol) => Option.exists(symbol, (found) => hasFlag(found.flags, SymbolFlags.Alias));
|
|
1011
1085
|
const addNamespaceDeclaration = (binding) => (name, symbol, parent) => {
|
|
1012
1086
|
if (Option.isSome(symbol)) {
|
|
1013
|
-
|
|
1087
|
+
symbol.value.addDeclaration(name, NAMESPACE_FLAGS.includes);
|
|
1014
1088
|
return symbol;
|
|
1015
1089
|
}
|
|
1016
1090
|
return parent.pipe(Option.map((owner) => declare(binding, {
|
|
@@ -1051,7 +1125,7 @@ const expandoMemberFlags = (declaration) => {
|
|
|
1051
1125
|
const bindExpandoMember = (binding, declaration, namespace) => {
|
|
1052
1126
|
const owner = namespace.pipe(Option.filter(isExpandoSymbol));
|
|
1053
1127
|
if (Option.isNone(owner)) return;
|
|
1054
|
-
owner.value.
|
|
1128
|
+
owner.value.openExports();
|
|
1055
1129
|
const flags = expandoMemberFlags(declaration);
|
|
1056
1130
|
declare(binding, {
|
|
1057
1131
|
target: exportsOf(owner),
|
|
@@ -1124,7 +1198,7 @@ const bindModuleExportsAssignment = Function.dual(DATA_FIRST_ARITY_3$16, (bindin
|
|
|
1124
1198
|
const assigned = getRightMostAssignedExpression(node.right);
|
|
1125
1199
|
if (!setCommonJsModuleIndicator(binding, node) || isUnboundModuleExportsValue(binding, assigned, scope) || bindShorthandExports(binding, assigned)) return;
|
|
1126
1200
|
const flags = Option.getOrElse(Option.liftPredicate(MODULE_EXPORTS_ALIAS, () => isAliasableExpression(node.right)), () => MODULE_EXPORTS_VALUE);
|
|
1127
|
-
|
|
1201
|
+
declareExport(binding, node, flags).setValueDeclaration(node);
|
|
1128
1202
|
});
|
|
1129
1203
|
const MODULE_LOCAL = {
|
|
1130
1204
|
includes: combineFlags(SymbolFlags.FunctionScopedVariable, SymbolFlags.ModuleExports),
|
|
@@ -1287,7 +1361,6 @@ const flagPair = (includes, excludes) => ({
|
|
|
1287
1361
|
includes,
|
|
1288
1362
|
excludes
|
|
1289
1363
|
});
|
|
1290
|
-
const ALIAS$1 = flagPair(SymbolFlags.Alias, SymbolFlags.AliasExcludes);
|
|
1291
1364
|
const FUNCTION = flagPair(SymbolFlags.Function, SymbolFlags.FunctionExcludes);
|
|
1292
1365
|
const VALUE_MODULE = flagPair(SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
|
1293
1366
|
const NAMESPACE_MODULE = flagPair(SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
|
@@ -1296,12 +1369,6 @@ const REGULAR_ENUM = flagPair(SymbolFlags.RegularEnum, SymbolFlags.RegularEnumEx
|
|
|
1296
1369
|
const EXPORT_STAR = flagPair(SymbolFlags.ExportStar, 0);
|
|
1297
1370
|
const EXPORT_ALIAS = flagPair(SymbolFlags.Alias, SymbolFlags.All);
|
|
1298
1371
|
const EXPORT_PROPERTY = flagPair(SymbolFlags.Property, SymbolFlags.All);
|
|
1299
|
-
const inContainer = (flags) => (binding, node, scope) => {
|
|
1300
|
-
if (scope.containerIsFile) declareSourceFileMember(binding, node, flags);
|
|
1301
|
-
};
|
|
1302
|
-
const inBlock = (flags) => (binding, node, scope) => {
|
|
1303
|
-
if (scope.blockIsFile) declareBlockScoped(binding, node, flags);
|
|
1304
|
-
};
|
|
1305
1372
|
const bindFunction = (binding, node, scope) => {
|
|
1306
1373
|
if (binding.strict) {
|
|
1307
1374
|
inBlock(FUNCTION)(binding, node, scope);
|
|
@@ -1326,7 +1393,7 @@ const bindModuleDeclaration = (binding, node, scope) => {
|
|
|
1326
1393
|
if (scope.containerIsFile && isModuleDeclaration(node)) declareSourceFileMember(binding, node, moduleFlags(binding, node));
|
|
1327
1394
|
};
|
|
1328
1395
|
const bindImportClause = (binding, node, scope) => {
|
|
1329
|
-
if (isImportClause(node) && Predicate.isNotUndefined(node.name)) inContainer(ALIAS
|
|
1396
|
+
if (isImportClause(node) && Predicate.isNotUndefined(node.name)) inContainer(ALIAS)(binding, node, scope);
|
|
1330
1397
|
};
|
|
1331
1398
|
const hasFileExports = (binding, scope) => scope.containerIsFile && Option.isSome(Option.fromNullishOr(binding.symbol));
|
|
1332
1399
|
const bindExportClause = (binding, node) => {
|
|
@@ -1335,7 +1402,7 @@ const bindExportClause = (binding, node) => {
|
|
|
1335
1402
|
declareExport(binding, node, EXPORT_STAR);
|
|
1336
1403
|
return;
|
|
1337
1404
|
}
|
|
1338
|
-
if (isNamespaceExport(clause)) declareExport(binding, clause, ALIAS
|
|
1405
|
+
if (isNamespaceExport(clause)) declareExport(binding, clause, ALIAS);
|
|
1339
1406
|
};
|
|
1340
1407
|
const bindExportDeclaration = (binding, node, scope) => {
|
|
1341
1408
|
if (hasFileExports(binding, scope) && isExportDeclaration(node)) bindExportClause(binding, node);
|
|
@@ -1344,7 +1411,7 @@ const bindExportAssignment = (binding, node, scope) => {
|
|
|
1344
1411
|
if (!hasFileExports(binding, scope) || !isExportAssignment(node)) return;
|
|
1345
1412
|
const flags = Option.getOrElse(Option.liftPredicate(EXPORT_ALIAS, () => isAliasableExpression(node.expression)), () => EXPORT_PROPERTY);
|
|
1346
1413
|
const symbol = declareExport(binding, node, flags);
|
|
1347
|
-
if (node.isExportEquals) setValueDeclaration(
|
|
1414
|
+
if (node.isExportEquals) symbol.setValueDeclaration(node);
|
|
1348
1415
|
};
|
|
1349
1416
|
const DECLARATION_BINDERS = /* @__PURE__ */ new Map([
|
|
1350
1417
|
[SyntaxKind.FunctionDeclaration, bindFunction],
|
|
@@ -1353,20 +1420,16 @@ const DECLARATION_BINDERS = /* @__PURE__ */ new Map([
|
|
|
1353
1420
|
[SyntaxKind.TypeAliasDeclaration, inBlock(flagPair(SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes))],
|
|
1354
1421
|
[SyntaxKind.EnumDeclaration, bindEnum],
|
|
1355
1422
|
[SyntaxKind.ModuleDeclaration, bindModuleDeclaration],
|
|
1356
|
-
[SyntaxKind.ImportEqualsDeclaration, inContainer(ALIAS
|
|
1357
|
-
[SyntaxKind.NamespaceImport, inContainer(ALIAS
|
|
1358
|
-
[SyntaxKind.ImportSpecifier, inContainer(ALIAS
|
|
1359
|
-
[SyntaxKind.ExportSpecifier, inContainer(ALIAS
|
|
1423
|
+
[SyntaxKind.ImportEqualsDeclaration, inContainer(ALIAS)],
|
|
1424
|
+
[SyntaxKind.NamespaceImport, inContainer(ALIAS)],
|
|
1425
|
+
[SyntaxKind.ImportSpecifier, inContainer(ALIAS)],
|
|
1426
|
+
[SyntaxKind.ExportSpecifier, inContainer(ALIAS)],
|
|
1360
1427
|
[SyntaxKind.ImportClause, bindImportClause],
|
|
1361
1428
|
[SyntaxKind.ExportDeclaration, bindExportDeclaration],
|
|
1362
1429
|
[SyntaxKind.ExportAssignment, bindExportAssignment]
|
|
1363
1430
|
]);
|
|
1364
1431
|
// src/shared/lib/typescript/binder-variables.ts
|
|
1365
1432
|
const DATA_FIRST_ARITY_3$15 = 3;
|
|
1366
|
-
const ALIAS = {
|
|
1367
|
-
includes: SymbolFlags.Alias,
|
|
1368
|
-
excludes: SymbolFlags.AliasExcludes
|
|
1369
|
-
};
|
|
1370
1433
|
const BLOCK_VARIABLE = {
|
|
1371
1434
|
includes: SymbolFlags.BlockScopedVariable,
|
|
1372
1435
|
excludes: SymbolFlags.BlockScopedVariableExcludes
|
|
@@ -1399,14 +1462,10 @@ const possibleDeclarationOf = (node) => {
|
|
|
1399
1462
|
return node.parent.parent;
|
|
1400
1463
|
};
|
|
1401
1464
|
const isRequireAlias = (binding, node) => binding.isJs && isRequireInitialized(possibleDeclarationOf(node)) && !hasJSDocTypeTag(node) && !hasExportModifier(node);
|
|
1402
|
-
const bindRequireAlias = (
|
|
1403
|
-
|
|
1404
|
-
};
|
|
1405
|
-
const bindBlockVariable = (binding, node, scope) => {
|
|
1406
|
-
if (scope.blockIsFile) declareBlockScoped(binding, node, BLOCK_VARIABLE);
|
|
1407
|
-
};
|
|
1465
|
+
const bindRequireAlias = inContainer(ALIAS);
|
|
1466
|
+
const bindBlockVariable = inBlock(BLOCK_VARIABLE);
|
|
1408
1467
|
const bindFunctionVariable = (binding, node, scope) => {
|
|
1409
|
-
if (
|
|
1468
|
+
if (!isParameterBinding(node)) inContainer(FUNCTION_VARIABLE)(binding, node, scope);
|
|
1410
1469
|
};
|
|
1411
1470
|
const variableBinderFor = (binding, node) => {
|
|
1412
1471
|
if (isRequireAlias(binding, node)) return bindRequireAlias;
|
|
@@ -1484,14 +1543,13 @@ const directiveText = (statement) => Option.liftPredicate(statement, isExpressio
|
|
|
1484
1543
|
const hasUseStrictPrologue = (file) => pipe(file.statements, Array$1.map(directiveText), Array$1.takeWhile(Option.isSome), Array$1.some((text) => Option.contains(text, USE_STRICT)));
|
|
1485
1544
|
const createBinding = (file) => {
|
|
1486
1545
|
const isExternalModule = Predicate.isNotUndefined(file.externalModuleIndicator) && file.externalModuleIndicator !== true;
|
|
1487
|
-
return {
|
|
1546
|
+
return new FileBinding({
|
|
1488
1547
|
file,
|
|
1489
|
-
locals: /* @__PURE__ */ new Map(),
|
|
1490
1548
|
isJs: isJsFile(file),
|
|
1491
1549
|
exportContext: file.isDeclarationFile && !hasExportDeclarations(file),
|
|
1492
1550
|
strict: isExternalModule || hasUseStrictPrologue(file),
|
|
1493
1551
|
isExternalModule
|
|
1494
|
-
};
|
|
1552
|
+
});
|
|
1495
1553
|
};
|
|
1496
1554
|
const declareFileSymbol = (binding) => {
|
|
1497
1555
|
if (binding.isExternalModule) {
|
|
@@ -1512,7 +1570,7 @@ const writableValue = (value) => ({
|
|
|
1512
1570
|
const exposeOnSourceFile = (binding) => {
|
|
1513
1571
|
Object.defineProperties(binding.file, {
|
|
1514
1572
|
symbol: writableValue(binding.symbol),
|
|
1515
|
-
locals: writableValue(binding.locals),
|
|
1573
|
+
locals: writableValue(binding.locals.entries),
|
|
1516
1574
|
commonJsModuleIndicator: writableValue(binding.commonJsModuleIndicator)
|
|
1517
1575
|
});
|
|
1518
1576
|
};
|
|
@@ -1616,8 +1674,7 @@ const findExtension = (path, extensions) => Array$1.findFirst(extensions, (exten
|
|
|
1616
1674
|
const hasTSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_TS);
|
|
1617
1675
|
const hasJSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_JS);
|
|
1618
1676
|
const ARBITRARY_DECLARATION = ".d.";
|
|
1619
|
-
const
|
|
1620
|
-
const getDeclarationFileExtension = (fileName) => Array$1.findFirst(SUPPORTED_DECLARATION, (extension) => String$1.endsWith(extension)(fileName)).pipe(Option.orElse(() => getArbitraryDeclarationExtension(fileName)));
|
|
1677
|
+
const getDeclarationFileExtension = (fileName) => Array$1.findFirst(SUPPORTED_DECLARATION, (extension) => String$1.endsWith(extension)(fileName)).pipe(Option.orElse(() => Option.liftPredicate(fileName, (name) => fileExtensionIs(name, Extension.Ts)).pipe(Option.flatMap((name) => String$1.lastIndexOf(ARBITRARY_DECLARATION)(getBaseFileName(name)).pipe(Option.map((index) => String$1.slice(name.length - getBaseFileName(name).length + index)(name)))))));
|
|
1621
1678
|
const isDeclarationFileName = (fileName) => Option.isSome(getDeclarationFileExtension(fileName));
|
|
1622
1679
|
const getAnyExtensionFromPath = (path) => {
|
|
1623
1680
|
const base = getBaseFileName(path);
|
|
@@ -1902,13 +1959,12 @@ const ancestorMatching = (node, judge) => {
|
|
|
1902
1959
|
if (verdict) return node;
|
|
1903
1960
|
return ancestorMatching(Option.fromNullishOr(node.value.parent), judge);
|
|
1904
1961
|
};
|
|
1905
|
-
const findAncestor = (node, judge) => Option.getOrUndefined(ancestorMatching(Option.fromNullishOr(node), judge));
|
|
1906
1962
|
const getNameOfAccessExpression$2 = (node) => {
|
|
1907
1963
|
if (isPropertyAccessExpression(node)) return node.name;
|
|
1908
1964
|
return skipParentheses(node.argumentExpression);
|
|
1909
1965
|
};
|
|
1910
1966
|
const nodeFunctions = {
|
|
1911
|
-
findAncestor,
|
|
1967
|
+
findAncestor: (node, judge) => Option.getOrUndefined(ancestorMatching(Option.fromNullishOr(node), judge)),
|
|
1912
1968
|
forEachChild: (node, visit) => node.forEachChild(visit),
|
|
1913
1969
|
getNameOfAccessExpression: getNameOfAccessExpression$2,
|
|
1914
1970
|
isAccessExpression: toleratingAbsence(isAccessExpression),
|
|
@@ -1955,16 +2011,13 @@ const parsePackageName = (moduleName) => Option.match(packageNameEnd(moduleName)
|
|
|
1955
2011
|
rest: String$1.slice(end + NEXT$1)(moduleName)
|
|
1956
2012
|
})
|
|
1957
2013
|
});
|
|
1958
|
-
const
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
const unmangleScopedPackageName = (
|
|
1965
|
-
if (!String$1.includes(SCOPE_SEPARATOR)(typesPackageName)) return typesPackageName;
|
|
1966
|
-
return `@${String$1.replace(SCOPE_SEPARATOR, "/")(typesPackageName)}`;
|
|
1967
|
-
};
|
|
2014
|
+
const rewrittenWhen = (applies, rewrite) => (name) => Option.match(Option.liftPredicate(name, applies), {
|
|
2015
|
+
onNone: () => name,
|
|
2016
|
+
onSome: rewrite
|
|
2017
|
+
});
|
|
2018
|
+
const isScopedWithSlash = (name) => String$1.startsWith("@")(name) && String$1.includes("/")(name);
|
|
2019
|
+
const mangleScopedPackageName = rewrittenWhen(isScopedWithSlash, (name) => String$1.slice(SCOPE_MARKER_LENGTH)(String$1.replace("/", SCOPE_SEPARATOR)(name)));
|
|
2020
|
+
const unmangleScopedPackageName = rewrittenWhen(String$1.includes(SCOPE_SEPARATOR), (name) => `@${String$1.replace(SCOPE_SEPARATOR, "/")(name)}`);
|
|
1968
2021
|
const getTypesPackageName = (packageName) => `@types/${mangleScopedPackageName(packageName)}`;
|
|
1969
2022
|
const mangleScopedPackageNameWithTrace = Function.dual(DATA_FIRST_ARITY$21, (packageName, state) => {
|
|
1970
2023
|
const mangled = mangleScopedPackageName(packageName);
|
|
@@ -2002,8 +2055,8 @@ const pathFunctions = {
|
|
|
2002
2055
|
pathIsRelative,
|
|
2003
2056
|
unmangleScopedPackageName
|
|
2004
2057
|
};
|
|
2005
|
-
//
|
|
2006
|
-
|
|
2058
|
+
// \0attw-typescript
|
|
2059
|
+
var _attw_typescript_default = {
|
|
2007
2060
|
...fileFunctions,
|
|
2008
2061
|
...nodeFunctions,
|
|
2009
2062
|
...pathFunctions,
|
|
@@ -2038,8 +2091,8 @@ var cjsOnlyExportsDefault_default = defineCheck({
|
|
|
2038
2091
|
if (!implementationFileName) return;
|
|
2039
2092
|
if (resolutionKind === "node10" || resolutionKind === "node16-cjs") return;
|
|
2040
2093
|
const sourceFile = ((_c = context.hosts.findHostForFiles([implementationFileName])) !== null && _c !== void 0 ? _c : context.hosts.bundler).getSourceFile(implementationFileName);
|
|
2041
|
-
if (!sourceFile.externalModuleIndicator && sourceFile.commonJsModuleIndicator && ((_b = (_a = sourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(
|
|
2042
|
-
const decl = sourceFile.symbol.exports.get(
|
|
2094
|
+
if (!sourceFile.externalModuleIndicator && sourceFile.commonJsModuleIndicator && ((_b = (_a = sourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(_attw_typescript_default.InternalSymbolName.Default)) && sourceFile.symbol.exports.has(_attw_typescript_default.escapeLeadingUnderscores("__esModule")) && !sourceFile.symbol.exports.has(_attw_typescript_default.InternalSymbolName.ExportEquals)) {
|
|
2095
|
+
const decl = sourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default).declarations[0];
|
|
2043
2096
|
return {
|
|
2044
2097
|
kind: "CJSOnlyExportsDefault",
|
|
2045
2098
|
fileName: implementationFileName,
|
|
@@ -2199,15 +2252,15 @@ var Package = class Package {
|
|
|
2199
2252
|
return path in __classPrivateFieldGet(this, _Package_files, "f");
|
|
2200
2253
|
}
|
|
2201
2254
|
directoryExists(path) {
|
|
2202
|
-
path =
|
|
2255
|
+
path = _attw_typescript_default.ensureTrailingDirectorySeparator(path);
|
|
2203
2256
|
for (const file in __classPrivateFieldGet(this, _Package_files, "f")) if (file.startsWith(path)) return true;
|
|
2204
2257
|
return false;
|
|
2205
2258
|
}
|
|
2206
2259
|
containsTypes(directory = "/") {
|
|
2207
|
-
return this.listFiles(directory).some(
|
|
2260
|
+
return this.listFiles(directory).some(_attw_typescript_default.hasTSFileExtension);
|
|
2208
2261
|
}
|
|
2209
2262
|
listFiles(directory = "/") {
|
|
2210
|
-
directory =
|
|
2263
|
+
directory = _attw_typescript_default.ensureTrailingDirectorySeparator(directory);
|
|
2211
2264
|
return directory === "/" ? Object.keys(__classPrivateFieldGet(this, _Package_files, "f")) : Object.keys(__classPrivateFieldGet(this, _Package_files, "f")).filter((f) => f.startsWith(directory));
|
|
2212
2265
|
}
|
|
2213
2266
|
mergedWithTypes(typesPackage) {
|
|
@@ -2227,7 +2280,7 @@ async function createPackageFromNpm(packageSpec, { definitelyTyped = true, ...op
|
|
|
2227
2280
|
const parsed = parsePackageSpec(packageSpec);
|
|
2228
2281
|
if (parsed.status === "error") throw new Error(parsed.error);
|
|
2229
2282
|
const packageName = parsed.data.name;
|
|
2230
|
-
const typesPackageName =
|
|
2283
|
+
const typesPackageName = _attw_typescript_default.getTypesPackageName(packageName);
|
|
2231
2284
|
const { tarballUrl, packageVersion } = parsed.data.versionKind === "none" && typeof definitelyTyped === "string" ? await resolveImplementationPackageForTypesPackage(typesPackageName, definitelyTyped, options) : await getNpmTarballUrl([parsed.data], options);
|
|
2232
2285
|
const pkg = await createPackageFromTarballUrl(tarballUrl);
|
|
2233
2286
|
if (!definitelyTyped || pkg.containsTypes()) return pkg;
|
|
@@ -2243,7 +2296,7 @@ async function createPackageFromNpm(packageSpec, { definitelyTyped = true, ...op
|
|
|
2243
2296
|
}
|
|
2244
2297
|
async function resolveImplementationPackageForTypesPackage(typesPackageName, typesPackageVersion, options) {
|
|
2245
2298
|
if (!typesPackageName.startsWith("@types/")) throw new Error(`'resolveImplementationPackageForTypesPackage' expects an @types package name and version`);
|
|
2246
|
-
const packageName =
|
|
2299
|
+
const packageName = _attw_typescript_default.unmangleScopedPackageName(typesPackageName.slice(7));
|
|
2247
2300
|
const version = valid(typesPackageVersion);
|
|
2248
2301
|
if (version) return getNpmTarballUrl([
|
|
2249
2302
|
parsePackageSpec(`${packageName}@${major(version)}.${minor(version)}`).data,
|
|
@@ -2263,7 +2316,7 @@ async function resolveImplementationPackageForTypesPackage(typesPackageName, typ
|
|
|
2263
2316
|
throw new Error(`'resolveImplementationPackageForTypesPackage' expects a valid SemVer version or range`);
|
|
2264
2317
|
}
|
|
2265
2318
|
async function resolveTypesPackageForPackage(packageName, packageVersion, options) {
|
|
2266
|
-
const typesPackageName =
|
|
2319
|
+
const typesPackageName = _attw_typescript_default.getTypesPackageName(packageName);
|
|
2267
2320
|
try {
|
|
2268
2321
|
return await getNpmTarballUrl([
|
|
2269
2322
|
{
|
|
@@ -2360,7 +2413,7 @@ function extractTarball(tarball) {
|
|
|
2360
2413
|
const packageVersion = packageJson.version;
|
|
2361
2414
|
return {
|
|
2362
2415
|
files: data.reduce((acc, file) => {
|
|
2363
|
-
acc[
|
|
2416
|
+
acc[_attw_typescript_default.combinePaths("/node_modules/" + packageName, file.filename.substring(prefix.length))] = file.fileData;
|
|
2364
2417
|
return acc;
|
|
2365
2418
|
}, {}),
|
|
2366
2419
|
packageName,
|
|
@@ -2370,51 +2423,51 @@ function extractTarball(tarball) {
|
|
|
2370
2423
|
// upstream/attw-core/lib/internal/esm/esmBindings.js
|
|
2371
2424
|
function* extractDestructedNames(node) {
|
|
2372
2425
|
switch (node.kind) {
|
|
2373
|
-
case
|
|
2374
|
-
for (const element of node.elements) if (element.kind ===
|
|
2426
|
+
case _attw_typescript_default.SyntaxKind.ArrayBindingPattern:
|
|
2427
|
+
for (const element of node.elements) if (element.kind === _attw_typescript_default.SyntaxKind.BindingElement) yield* extractDestructedNames(element.name);
|
|
2375
2428
|
break;
|
|
2376
|
-
case
|
|
2429
|
+
case _attw_typescript_default.SyntaxKind.Identifier:
|
|
2377
2430
|
yield node.text;
|
|
2378
2431
|
break;
|
|
2379
|
-
case
|
|
2432
|
+
case _attw_typescript_default.SyntaxKind.ObjectBindingPattern: for (const element of node.elements) yield* extractDestructedNames(element.name);
|
|
2380
2433
|
}
|
|
2381
2434
|
}
|
|
2382
2435
|
function getEsmModuleBindings(sourceText) {
|
|
2383
2436
|
const options = {
|
|
2384
|
-
languageVersion:
|
|
2385
|
-
impliedNodeFormat:
|
|
2437
|
+
languageVersion: _attw_typescript_default.ScriptTarget.ESNext,
|
|
2438
|
+
impliedNodeFormat: _attw_typescript_default.ModuleKind.ESNext
|
|
2386
2439
|
};
|
|
2387
|
-
const sourceFile =
|
|
2440
|
+
const sourceFile = _attw_typescript_default.createSourceFile("module.cjs", sourceText, options, false, _attw_typescript_default.ScriptKind.JS);
|
|
2388
2441
|
const exports = [];
|
|
2389
2442
|
const reexports = [];
|
|
2390
2443
|
for (const statement of sourceFile.statements) switch (statement.kind) {
|
|
2391
|
-
case
|
|
2444
|
+
case _attw_typescript_default.SyntaxKind.ExportDeclaration: {
|
|
2392
2445
|
const declaration = statement;
|
|
2393
2446
|
const { exportClause } = declaration;
|
|
2394
2447
|
if (!declaration.isTypeOnly) {
|
|
2395
2448
|
if (exportClause) {
|
|
2396
|
-
if (exportClause.kind ===
|
|
2449
|
+
if (exportClause.kind === _attw_typescript_default.SyntaxKind.NamedExports) {
|
|
2397
2450
|
for (const element of exportClause.elements) if (!element.isTypeOnly) exports.push(element.name.text);
|
|
2398
2451
|
} else exports.push(exportClause.name.text);
|
|
2399
|
-
} else if (declaration.moduleSpecifier &&
|
|
2452
|
+
} else if (declaration.moduleSpecifier && _attw_typescript_default.isStringLiteral(declaration.moduleSpecifier)) reexports.push(declaration.moduleSpecifier.text);
|
|
2400
2453
|
}
|
|
2401
2454
|
break;
|
|
2402
2455
|
}
|
|
2403
|
-
case
|
|
2456
|
+
case _attw_typescript_default.SyntaxKind.ExportAssignment:
|
|
2404
2457
|
if (!statement.isExportEquals) exports.push("default");
|
|
2405
2458
|
break;
|
|
2406
|
-
case
|
|
2407
|
-
case
|
|
2459
|
+
case _attw_typescript_default.SyntaxKind.ClassDeclaration:
|
|
2460
|
+
case _attw_typescript_default.SyntaxKind.FunctionDeclaration: {
|
|
2408
2461
|
const declaration = statement;
|
|
2409
|
-
if (
|
|
2410
|
-
if (
|
|
2462
|
+
if (_attw_typescript_default.hasSyntacticModifier(declaration, _attw_typescript_default.ModifierFlags.Export)) {
|
|
2463
|
+
if (_attw_typescript_default.hasSyntacticModifier(declaration, _attw_typescript_default.ModifierFlags.Default)) exports.push("default");
|
|
2411
2464
|
else if (declaration.name) exports.push(declaration.name.text);
|
|
2412
2465
|
}
|
|
2413
2466
|
break;
|
|
2414
2467
|
}
|
|
2415
|
-
case
|
|
2468
|
+
case _attw_typescript_default.SyntaxKind.VariableStatement: {
|
|
2416
2469
|
const declaration = statement;
|
|
2417
|
-
if (
|
|
2470
|
+
if (_attw_typescript_default.hasSyntacticModifier(declaration, _attw_typescript_default.ModifierFlags.Export)) for (const declarator of declaration.declarationList.declarations) exports.push(...extractDestructedNames(declarator.name));
|
|
2418
2471
|
break;
|
|
2419
2472
|
}
|
|
2420
2473
|
}
|
|
@@ -2487,15 +2540,15 @@ var namedExports_default = defineCheck({
|
|
|
2487
2540
|
];
|
|
2488
2541
|
},
|
|
2489
2542
|
execute: ([implementationFileName, implementationModuleKind, typesFileName, typesModuleKind, resolutionKind], context) => {
|
|
2490
|
-
if (!implementationFileName || !typesFileName || resolutionKind !== "node16-esm" || (typesModuleKind === null || typesModuleKind === void 0 ? void 0 : typesModuleKind.detectedKind) !==
|
|
2543
|
+
if (!implementationFileName || !typesFileName || resolutionKind !== "node16-esm" || (typesModuleKind === null || typesModuleKind === void 0 ? void 0 : typesModuleKind.detectedKind) !== _attw_typescript_default.ModuleKind.CommonJS || (implementationModuleKind === null || implementationModuleKind === void 0 ? void 0 : implementationModuleKind.detectedKind) !== _attw_typescript_default.ModuleKind.CommonJS) return;
|
|
2491
2544
|
const host = context.hosts.findHostForFiles([typesFileName]);
|
|
2492
2545
|
const typesSourceFile = host.getSourceFile(typesFileName);
|
|
2493
|
-
if (typesSourceFile.scriptKind ===
|
|
2546
|
+
if (typesSourceFile.scriptKind === _attw_typescript_default.ScriptKind.JSON || !typesSourceFile.symbol) return;
|
|
2494
2547
|
const typeChecker = host.createAuxiliaryProgram([typesFileName]).getTypeChecker();
|
|
2495
2548
|
const moduleType = typeChecker.getTypeOfSymbol(typeChecker.resolveExternalModuleSymbol(typesSourceFile.symbol));
|
|
2496
2549
|
if (typeChecker.isArrayLikeType(moduleType) || typeChecker.getPropertyOfType(moduleType, "0")) return;
|
|
2497
2550
|
const expectedNames = Array.from(new Set(typeChecker.getExportsAndPropertiesOfModule(typesSourceFile.symbol).filter((symbol) => {
|
|
2498
|
-
return symbol.name !== "prototype" && typeChecker.getSymbolFlags(symbol, true) &
|
|
2551
|
+
return symbol.name !== "prototype" && typeChecker.getSymbolFlags(symbol, true) & _attw_typescript_default.SymbolFlags.Value;
|
|
2499
2552
|
}).map((symbol) => symbol.name)));
|
|
2500
2553
|
let exports;
|
|
2501
2554
|
try {
|
|
@@ -2535,7 +2588,7 @@ var entrypointResolutions_default = defineCheck({
|
|
|
2535
2588
|
entrypoint: subpath,
|
|
2536
2589
|
resolutionKind
|
|
2537
2590
|
});
|
|
2538
|
-
if (resolutionKind === "node16-cjs" && (!entrypoint.implementationResolution && entrypoint.resolution && ((_a = context.programInfo["node16"].moduleKinds[entrypoint.resolution.fileName]) === null || _a === void 0 ? void 0 : _a.detectedKind) ===
|
|
2591
|
+
if (resolutionKind === "node16-cjs" && (!entrypoint.implementationResolution && entrypoint.resolution && ((_a = context.programInfo["node16"].moduleKinds[entrypoint.resolution.fileName]) === null || _a === void 0 ? void 0 : _a.detectedKind) === _attw_typescript_default.ModuleKind.ESNext || entrypoint.implementationResolution && ((_b = context.programInfo["node16"].moduleKinds[entrypoint.implementationResolution.fileName]) === null || _b === void 0 ? void 0 : _b.detectedKind) === _attw_typescript_default.ModuleKind.ESNext)) problems.push({
|
|
2539
2592
|
kind: "CJSResolvesToESM",
|
|
2540
2593
|
entrypoint: subpath,
|
|
2541
2594
|
resolutionKind
|
|
@@ -2562,14 +2615,14 @@ function getEsbuildBabelSwcExports(sourceFile) {
|
|
|
2562
2615
|
for (const statement of sourceFile.statements) {
|
|
2563
2616
|
if (possibleIndex !== -1 && statement.end < possibleIndex) continue;
|
|
2564
2617
|
if (possibleIndex !== -1 && statement.pos > possibleIndex) break;
|
|
2565
|
-
if (
|
|
2618
|
+
if (_attw_typescript_default.isExpressionStatement(statement) && _attw_typescript_default.isCallExpression(statement.expression) && _attw_typescript_default.isIdentifier(statement.expression.expression) && statement.expression.arguments.length === 2 && _attw_typescript_default.isIdentifier(statement.expression.arguments[0]) && _attw_typescript_default.isObjectLiteralExpression(statement.expression.arguments[1])) {
|
|
2566
2619
|
const callTarget = statement.expression.expression;
|
|
2567
|
-
if (callTarget.text === "__export" || callTarget.text === "_export" || isEsbuildExportFunction((_b = (_a = sourceFile.locals) === null || _a === void 0 ? void 0 : _a.get(
|
|
2568
|
-
if (
|
|
2620
|
+
if (callTarget.text === "__export" || callTarget.text === "_export" || isEsbuildExportFunction((_b = (_a = sourceFile.locals) === null || _a === void 0 ? void 0 : _a.get(_attw_typescript_default.escapeLeadingUnderscores(callTarget.text))) === null || _b === void 0 ? void 0 : _b.valueDeclaration)) return statement.expression.arguments[1].properties.flatMap((prop) => {
|
|
2621
|
+
if (_attw_typescript_default.isPropertyAssignment(prop) && (_attw_typescript_default.isIdentifier(prop.name) || _attw_typescript_default.isStringOrNumericLiteralLike(prop.name))) return [{
|
|
2569
2622
|
name: prop.name.text,
|
|
2570
2623
|
node: prop
|
|
2571
2624
|
}];
|
|
2572
|
-
if (
|
|
2625
|
+
if (_attw_typescript_default.isShorthandPropertyAssignment(prop)) return [{
|
|
2573
2626
|
name: prop.name.text,
|
|
2574
2627
|
node: prop
|
|
2575
2628
|
}];
|
|
@@ -2580,7 +2633,7 @@ function getEsbuildBabelSwcExports(sourceFile) {
|
|
|
2580
2633
|
}
|
|
2581
2634
|
function isEsbuildExportFunction(decl) {
|
|
2582
2635
|
if (!decl) return false;
|
|
2583
|
-
return
|
|
2636
|
+
return _attw_typescript_default.isVariableDeclaration(decl) && decl.initializer && _attw_typescript_default.isFunctionExpressionOrArrowFunction(decl.initializer) && _attw_typescript_default.isBlock(decl.initializer.body) && decl.initializer.body.statements.length == 1 && _attw_typescript_default.isForInStatement(decl.initializer.body.statements[0]);
|
|
2584
2637
|
}
|
|
2585
2638
|
function isProbablyMinified(text) {
|
|
2586
2639
|
return minifiedVariableAssignmentPattern.test(text);
|
|
@@ -2588,61 +2641,61 @@ function isProbablyMinified(text) {
|
|
|
2588
2641
|
function getWebpackBootstrapExports(sourceFile) {
|
|
2589
2642
|
var _a;
|
|
2590
2643
|
for (const statement of sourceFile.statements) {
|
|
2591
|
-
if (!
|
|
2644
|
+
if (!_attw_typescript_default.isExpressionStatement(statement) || !_attw_typescript_default.isBinaryExpression(statement.expression)) continue;
|
|
2592
2645
|
const assignment = statement.expression;
|
|
2593
|
-
if (assignment.operatorToken.kind !==
|
|
2594
|
-
const bootstrapCall =
|
|
2595
|
-
if (!
|
|
2596
|
-
const bootstrap =
|
|
2597
|
-
if (!
|
|
2646
|
+
if (assignment.operatorToken.kind !== _attw_typescript_default.SyntaxKind.EqualsToken || !isModuleExports$1(assignment.left)) continue;
|
|
2647
|
+
const bootstrapCall = _attw_typescript_default.skipParentheses(assignment.right);
|
|
2648
|
+
if (!_attw_typescript_default.isCallExpression(bootstrapCall)) continue;
|
|
2649
|
+
const bootstrap = _attw_typescript_default.skipParentheses(bootstrapCall.expression);
|
|
2650
|
+
if (!_attw_typescript_default.isFunctionExpression(bootstrap) || !_attw_typescript_default.isBlock(bootstrap.body) || bootstrapCall.arguments.length !== 1 || !_attw_typescript_default.isArrayLiteralExpression(bootstrapCall.arguments[0])) continue;
|
|
2598
2651
|
const entryModuleId = getWebpackEntryModuleId(bootstrap.body);
|
|
2599
2652
|
if (entryModuleId === void 0) continue;
|
|
2600
2653
|
const entryModule = bootstrapCall.arguments[0].elements[entryModuleId];
|
|
2601
|
-
if (!entryModule || !
|
|
2654
|
+
if (!entryModule || !_attw_typescript_default.isFunctionExpression(entryModule)) continue;
|
|
2602
2655
|
const exportsParameterName = (_a = entryModule.parameters[1]) === null || _a === void 0 ? void 0 : _a.name;
|
|
2603
|
-
if (!exportsParameterName || !
|
|
2656
|
+
if (!exportsParameterName || !_attw_typescript_default.isIdentifier(exportsParameterName)) continue;
|
|
2604
2657
|
const exportsParameterText = exportsParameterName.text;
|
|
2605
2658
|
const exports = [];
|
|
2606
2659
|
visit(entryModule.body);
|
|
2607
2660
|
return exports;
|
|
2608
2661
|
function visit(node) {
|
|
2609
|
-
if (
|
|
2662
|
+
if (_attw_typescript_default.isBinaryExpression(node) && node.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken && _attw_typescript_default.isAccessExpression(node.left) && _attw_typescript_default.isIdentifier(node.left.expression) && node.left.expression.text === exportsParameterText) {
|
|
2610
2663
|
const name = getNameOfAccessExpression$1(node.left);
|
|
2611
2664
|
if (name !== void 0) exports.push({
|
|
2612
2665
|
name,
|
|
2613
2666
|
node
|
|
2614
2667
|
});
|
|
2615
2668
|
}
|
|
2616
|
-
|
|
2669
|
+
_attw_typescript_default.forEachChild(node, visit);
|
|
2617
2670
|
}
|
|
2618
2671
|
}
|
|
2619
2672
|
}
|
|
2620
2673
|
function getWebpackEntryModuleId(body) {
|
|
2621
2674
|
for (const statement of body.statements) {
|
|
2622
|
-
if (!
|
|
2675
|
+
if (!_attw_typescript_default.isReturnStatement(statement) || !statement.expression) continue;
|
|
2623
2676
|
return getWebpackEntryModuleIdFromExpression(statement.expression);
|
|
2624
2677
|
}
|
|
2625
2678
|
}
|
|
2626
2679
|
function getWebpackEntryModuleIdFromExpression(expression) {
|
|
2627
|
-
expression =
|
|
2628
|
-
if (
|
|
2629
|
-
if (
|
|
2680
|
+
expression = _attw_typescript_default.skipParentheses(expression);
|
|
2681
|
+
if (_attw_typescript_default.isCallExpression(expression) && expression.arguments.length === 1) return getNumericValue(expression.arguments[0]);
|
|
2682
|
+
if (_attw_typescript_default.isBinaryExpression(expression) && expression.operatorToken.kind === _attw_typescript_default.SyntaxKind.CommaToken) return getWebpackEntryModuleIdFromExpression(expression.right);
|
|
2630
2683
|
}
|
|
2631
2684
|
function getNumericValue(node) {
|
|
2632
|
-
node =
|
|
2633
|
-
if (
|
|
2634
|
-
if (
|
|
2685
|
+
node = _attw_typescript_default.skipParentheses(node);
|
|
2686
|
+
if (_attw_typescript_default.isNumericLiteral(node)) return Number(node.text);
|
|
2687
|
+
if (_attw_typescript_default.isBinaryExpression(node) && node.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken) return getNumericValue(node.right);
|
|
2635
2688
|
}
|
|
2636
2689
|
function isModuleExports$1(node) {
|
|
2637
|
-
return
|
|
2690
|
+
return _attw_typescript_default.isAccessExpression(node) && _attw_typescript_default.isIdentifier(node.expression) && node.expression.text === "module" && getNameOfAccessExpression$1(node) === "exports";
|
|
2638
2691
|
}
|
|
2639
2692
|
function getNameOfAccessExpression$1(accessExpression) {
|
|
2640
|
-
const node =
|
|
2641
|
-
if (
|
|
2693
|
+
const node = _attw_typescript_default.getNameOfAccessExpression(accessExpression);
|
|
2694
|
+
if (_attw_typescript_default.isIdentifier(node) || _attw_typescript_default.isStringLiteralLike(node)) return node.text;
|
|
2642
2695
|
}
|
|
2643
2696
|
// upstream/attw-core/lib/internal/checks/exportDefaultDisagreement.js
|
|
2644
2697
|
const bindOptions = {
|
|
2645
|
-
target:
|
|
2698
|
+
target: _attw_typescript_default.ScriptTarget.Latest,
|
|
2646
2699
|
allowJs: true,
|
|
2647
2700
|
checkJs: true
|
|
2648
2701
|
};
|
|
@@ -2653,38 +2706,38 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2653
2706
|
const entrypoint = entrypoints[subpath].resolutions[resolutionKind];
|
|
2654
2707
|
const typesFileName = (_a = entrypoint.resolution) === null || _a === void 0 ? void 0 : _a.fileName;
|
|
2655
2708
|
const implementationFileName = (_b = entrypoint.implementationResolution) === null || _b === void 0 ? void 0 : _b.fileName;
|
|
2656
|
-
if (typesFileName && ((_d = (_c = programInfo[getResolutionOption(resolutionKind)].moduleKinds) === null || _c === void 0 ? void 0 : _c[typesFileName]) === null || _d === void 0 ? void 0 : _d.detectedKind) ===
|
|
2709
|
+
if (typesFileName && ((_d = (_c = programInfo[getResolutionOption(resolutionKind)].moduleKinds) === null || _c === void 0 ? void 0 : _c[typesFileName]) === null || _d === void 0 ? void 0 : _d.detectedKind) === _attw_typescript_default.ModuleKind.ESNext || implementationFileName && ((_f = (_e = programInfo[getResolutionOption(resolutionKind)].moduleKinds) === null || _e === void 0 ? void 0 : _e[implementationFileName]) === null || _f === void 0 ? void 0 : _f.detectedKind) === _attw_typescript_default.ModuleKind.ESNext) return [];
|
|
2657
2710
|
return [typesFileName, implementationFileName];
|
|
2658
2711
|
},
|
|
2659
2712
|
execute: ([typesFileName, implementationFileName], context) => {
|
|
2660
2713
|
var _a, _b;
|
|
2661
|
-
if (!typesFileName || !implementationFileName || !
|
|
2714
|
+
if (!typesFileName || !implementationFileName || !_attw_typescript_default.hasTSFileExtension(typesFileName)) return;
|
|
2662
2715
|
const host = context.hosts.findHostForFiles([typesFileName]);
|
|
2663
2716
|
const typesSourceFile = host.getSourceFile(typesFileName);
|
|
2664
|
-
|
|
2717
|
+
_attw_typescript_default.bindSourceFile(typesSourceFile, bindOptions);
|
|
2665
2718
|
if (!((_a = typesSourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports)) return;
|
|
2666
2719
|
const implementationSourceFile = host.getSourceFile(implementationFileName);
|
|
2667
|
-
|
|
2720
|
+
_attw_typescript_default.bindSourceFile(implementationSourceFile, bindOptions);
|
|
2668
2721
|
if (!((_b = implementationSourceFile.symbol) === null || _b === void 0 ? void 0 : _b.exports) || implementationSourceFile.externalModuleIndicator) return;
|
|
2669
|
-
if (typesSourceFile.symbol.exports.has(
|
|
2722
|
+
if (typesSourceFile.symbol.exports.has(_attw_typescript_default.InternalSymbolName.Default) && !getImplHasDefault() && implIsAnalyzable()) return {
|
|
2670
2723
|
kind: "FalseExportDefault",
|
|
2671
2724
|
typesFileName,
|
|
2672
2725
|
implementationFileName
|
|
2673
2726
|
};
|
|
2674
2727
|
if (!getImplHasDefault() || !implIsAnalyzable()) return;
|
|
2675
|
-
if (!typesSourceFile.symbol.exports.has(
|
|
2728
|
+
if (!typesSourceFile.symbol.exports.has(_attw_typescript_default.InternalSymbolName.ExportEquals) && implementationSourceFile.symbol.exports.has(_attw_typescript_default.InternalSymbolName.ExportEquals) && getTypesDefaultSymbol() && (getImplExportEqualsIsExportDefault() && getTypesChecker().typeHasCallOrConstructSignatures(getTypesTypeOfDefault()) || getImplChecker().typeHasCallOrConstructSignatures(getImplTypeOfModuleExports()))) return {
|
|
2676
2729
|
kind: "MissingExportEquals",
|
|
2677
2730
|
typesFileName,
|
|
2678
2731
|
implementationFileName
|
|
2679
2732
|
};
|
|
2680
2733
|
if (!Array.from(typesSourceFile.symbol.exports.values()).some((s) => {
|
|
2681
2734
|
if (s.escapedName === "default") return false;
|
|
2682
|
-
if (s.flags &
|
|
2683
|
-
while (s.flags &
|
|
2735
|
+
if (s.flags & _attw_typescript_default.SymbolFlags.Value) return true;
|
|
2736
|
+
while (s.flags & _attw_typescript_default.SymbolFlags.Alias) {
|
|
2684
2737
|
s = getTypesChecker().getAliasedSymbol(s);
|
|
2685
|
-
if (s.flags &
|
|
2738
|
+
if (s.flags & _attw_typescript_default.SymbolFlags.Value) return true;
|
|
2686
2739
|
}
|
|
2687
|
-
}) && typeIsObjecty(getTypesTypeOfDefault(), getTypesChecker()) && (Array.from(implementationSourceFile.symbol.exports.keys()).some((name) => isNotDefaultOrEsModule(
|
|
2740
|
+
}) && typeIsObjecty(getTypesTypeOfDefault(), getTypesChecker()) && (Array.from(implementationSourceFile.symbol.exports.keys()).some((name) => isNotDefaultOrEsModule(_attw_typescript_default.unescapeLeadingUnderscores(name))) || getImplProbableExports().some(({ name }) => isNotDefaultOrEsModule(name))) && getTypesDefaultSymbol()) return {
|
|
2688
2741
|
kind: "MissingExportEquals",
|
|
2689
2742
|
typesFileName,
|
|
2690
2743
|
implementationFileName
|
|
@@ -2701,7 +2754,7 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2701
2754
|
function getImplHasDefault() {
|
|
2702
2755
|
var _a, _b, _c, _d, _e;
|
|
2703
2756
|
var _f;
|
|
2704
|
-
return (_f = implHasDefault) !== null && _f !== void 0 ? _f : implHasDefault = ((_b = (_a = implementationSourceFile === null || implementationSourceFile === void 0 ? void 0 : implementationSourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(
|
|
2757
|
+
return (_f = implHasDefault) !== null && _f !== void 0 ? _f : implHasDefault = ((_b = (_a = implementationSourceFile === null || implementationSourceFile === void 0 ? void 0 : implementationSourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(_attw_typescript_default.InternalSymbolName.Default)) || ((_c = getImplProbableExports()) === null || _c === void 0 ? void 0 : _c.some((s) => s.name === "default")) || !!((_e = (_d = implementationSourceFile.symbol) === null || _d === void 0 ? void 0 : _d.exports) === null || _e === void 0 ? void 0 : _e.size) && getImplChecker().getExportsAndPropertiesOfModule(implementationSourceFile.symbol).some((s) => s.name === "default");
|
|
2705
2758
|
}
|
|
2706
2759
|
function getTypesChecker() {
|
|
2707
2760
|
var _a;
|
|
@@ -2709,7 +2762,7 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2709
2762
|
}
|
|
2710
2763
|
function getTypesDefaultSymbol() {
|
|
2711
2764
|
var _a, _b;
|
|
2712
|
-
return (_a = typesDefaultSymbol) !== null && _a !== void 0 ? _a : typesDefaultSymbol = (_b = typesSourceFile.symbol.exports.get(
|
|
2765
|
+
return (_a = typesDefaultSymbol) !== null && _a !== void 0 ? _a : typesDefaultSymbol = (_b = typesSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default)) !== null && _b !== void 0 ? _b : getTypesChecker().getExportsAndPropertiesOfModule(typesSourceFile.symbol).find((s) => s.escapedName === "default");
|
|
2713
2766
|
}
|
|
2714
2767
|
function getTypesTypeOfDefault() {
|
|
2715
2768
|
var _a;
|
|
@@ -2719,19 +2772,19 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2719
2772
|
function getImplTypeOfModuleExports() {
|
|
2720
2773
|
if (implTypeOfModuleExports) return implTypeOfModuleExports;
|
|
2721
2774
|
const type = getImplChecker().getTypeOfSymbol(getImplChecker().resolveExternalModuleSymbol(implementationSourceFile.symbol));
|
|
2722
|
-
if (type.flags &
|
|
2775
|
+
if (type.flags & _attw_typescript_default.TypeFlags.Any && getImplExportEqualsIsExportDefault()) return implTypeOfModuleExports = getImplChecker().getTypeOfSymbol(implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default));
|
|
2723
2776
|
return implTypeOfModuleExports = type;
|
|
2724
2777
|
}
|
|
2725
2778
|
function getImplExportEqualsIsExportDefault() {
|
|
2726
2779
|
var _a;
|
|
2727
2780
|
if (implExportEqualsIsExportDefault !== void 0) return implExportEqualsIsExportDefault;
|
|
2728
|
-
const exportEquals = implementationSourceFile.symbol.exports.get(
|
|
2781
|
+
const exportEquals = implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.ExportEquals);
|
|
2729
2782
|
if (!exportEquals) return implExportEqualsIsExportDefault = false;
|
|
2730
|
-
const exportDefault = implementationSourceFile.symbol.exports.get(
|
|
2783
|
+
const exportDefault = implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default);
|
|
2731
2784
|
if (!exportDefault) return implExportEqualsIsExportDefault = false;
|
|
2732
|
-
for (const assignment of [exportEquals.valueDeclaration,
|
|
2785
|
+
for (const assignment of [exportEquals.valueDeclaration, _attw_typescript_default.findAncestor((_a = exportDefault.declarations) === null || _a === void 0 ? void 0 : _a[0], _attw_typescript_default.isBinaryExpression)]) {
|
|
2733
2786
|
let seenModuleExports = false, seenExportsDefault = false;
|
|
2734
|
-
if (assignment &&
|
|
2787
|
+
if (assignment && _attw_typescript_default.isBinaryExpression(assignment) && assignment.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken) {
|
|
2735
2788
|
if (!!forEachAssignmentTarget(assignment, (target) => {
|
|
2736
2789
|
if (!seenExportsDefault && isExportsDefault(target)) seenExportsDefault = true;
|
|
2737
2790
|
else if (!seenModuleExports && isModuleExports(target)) seenModuleExports = true;
|
|
@@ -2743,10 +2796,10 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2743
2796
|
}
|
|
2744
2797
|
function implIsAnalyzable() {
|
|
2745
2798
|
var _a, _b, _c;
|
|
2746
|
-
if (((_b = (_a = implementationSourceFile.symbol.exports.get(
|
|
2799
|
+
if (((_b = (_a = implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.ExportEquals)) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.length) > 1) {
|
|
2747
2800
|
let commonContainer;
|
|
2748
|
-
for (const decl of implementationSourceFile.symbol.exports.get(
|
|
2749
|
-
const container =
|
|
2801
|
+
for (const decl of implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.ExportEquals).declarations) {
|
|
2802
|
+
const container = _attw_typescript_default.findAncestor(decl, (node) => _attw_typescript_default.isFunctionBlock(node) || _attw_typescript_default.isSourceFile(node));
|
|
2750
2803
|
if (commonContainer === void 0) commonContainer = container;
|
|
2751
2804
|
else if (commonContainer !== container) return false;
|
|
2752
2805
|
}
|
|
@@ -2756,31 +2809,31 @@ var exportDefaultDisagreement_default = defineCheck({
|
|
|
2756
2809
|
}
|
|
2757
2810
|
});
|
|
2758
2811
|
function typeIsObjecty(type, checker) {
|
|
2759
|
-
return type.flags &
|
|
2812
|
+
return type.flags & _attw_typescript_default.TypeFlags.Object && !(type.flags & _attw_typescript_default.TypeFlags.Primitive) && !checker.typeHasCallOrConstructSignatures(type);
|
|
2760
2813
|
}
|
|
2761
2814
|
function isModuleExports(target) {
|
|
2762
|
-
return
|
|
2815
|
+
return _attw_typescript_default.isAccessExpression(target) && _attw_typescript_default.isIdentifier(target.expression) && target.expression.text === "module" && getNameOfAccessExpression(target) === "exports" || _attw_typescript_default.isIdentifier(target) && target.text === "exports";
|
|
2763
2816
|
}
|
|
2764
2817
|
function isExportsDefault(target) {
|
|
2765
|
-
return
|
|
2818
|
+
return _attw_typescript_default.isAccessExpression(target) && _attw_typescript_default.isIdentifier(target.expression) && target.expression.text === "exports" && getNameOfAccessExpression(target) === "default" || _attw_typescript_default.isAccessExpression(target) && _attw_typescript_default.isAccessExpression(target.expression) && _attw_typescript_default.isIdentifier(target.expression.expression) && target.expression.expression.text === "module" && getNameOfAccessExpression(target.expression) === "exports" && getNameOfAccessExpression(target) === "default";
|
|
2766
2819
|
}
|
|
2767
2820
|
function isNotDefaultOrEsModule(name) {
|
|
2768
2821
|
return name !== "default" && name !== "__esModule";
|
|
2769
2822
|
}
|
|
2770
2823
|
function forEachAssignmentTarget(assignment, cb) {
|
|
2771
|
-
const target =
|
|
2772
|
-
if (
|
|
2824
|
+
const target = _attw_typescript_default.skipParentheses(assignment.right);
|
|
2825
|
+
if (_attw_typescript_default.isBinaryExpression(target) && target.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken) {
|
|
2773
2826
|
const res = forEachAssignmentTarget(target, cb);
|
|
2774
2827
|
if (res) return res;
|
|
2775
2828
|
} else {
|
|
2776
2829
|
const res = cb(target);
|
|
2777
2830
|
if (res) return res;
|
|
2778
2831
|
}
|
|
2779
|
-
return cb(
|
|
2832
|
+
return cb(_attw_typescript_default.skipParentheses(assignment.left));
|
|
2780
2833
|
}
|
|
2781
2834
|
function getNameOfAccessExpression(accessExpression) {
|
|
2782
|
-
const node =
|
|
2783
|
-
if (
|
|
2835
|
+
const node = _attw_typescript_default.getNameOfAccessExpression(accessExpression);
|
|
2836
|
+
if (_attw_typescript_default.isIdentifier(node) || _attw_typescript_default.isStringLiteralLike(node)) return node.text;
|
|
2784
2837
|
}
|
|
2785
2838
|
// upstream/attw-core/lib/internal/checks/internalResolutionError.js
|
|
2786
2839
|
var internalResolutionError_default = defineCheck({
|
|
@@ -2788,15 +2841,15 @@ var internalResolutionError_default = defineCheck({
|
|
|
2788
2841
|
enumerateFiles: true,
|
|
2789
2842
|
dependencies: ({ resolutionOption, fileName }) => [resolutionOption, fileName],
|
|
2790
2843
|
execute: ([resolutionOption, fileName], context) => {
|
|
2791
|
-
if (!
|
|
2844
|
+
if (!_attw_typescript_default.hasTSFileExtension(fileName)) return;
|
|
2792
2845
|
const host = context.hosts[resolutionOption];
|
|
2793
2846
|
const sourceFile = host.getSourceFile(fileName);
|
|
2794
2847
|
if (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.imports) {
|
|
2795
2848
|
const problems = [];
|
|
2796
2849
|
for (const moduleSpecifier of sourceFile.imports) {
|
|
2797
2850
|
const reference = moduleSpecifier.text;
|
|
2798
|
-
if (reference !== context.pkg.packageName && !reference.startsWith(`${context.pkg.packageName}/`) && reference[0] !== "#" && !
|
|
2799
|
-
const resolutionMode =
|
|
2851
|
+
if (reference !== context.pkg.packageName && !reference.startsWith(`${context.pkg.packageName}/`) && reference[0] !== "#" && !_attw_typescript_default.pathIsRelative(reference)) continue;
|
|
2852
|
+
const resolutionMode = _attw_typescript_default.getModeForUsageLocation(sourceFile, moduleSpecifier, host.getCompilerOptions());
|
|
2800
2853
|
const resolution = host.getResolvedModule(sourceFile, moduleSpecifier.text, resolutionMode);
|
|
2801
2854
|
if (!resolution) throw new Error(`Expected resolution for '${moduleSpecifier.text}' in ${fileName}`);
|
|
2802
2855
|
if (!resolution.resolvedModule) problems.push({
|
|
@@ -2833,14 +2886,14 @@ var checks_default = [
|
|
|
2833
2886
|
},
|
|
2834
2887
|
execute: ([typesFileName, implementationFileName, typesModuleKind, implementationModuleKind]) => {
|
|
2835
2888
|
if (typesFileName && implementationFileName && typesModuleKind && implementationModuleKind) {
|
|
2836
|
-
if (typesModuleKind.detectedKind ===
|
|
2889
|
+
if (typesModuleKind.detectedKind === _attw_typescript_default.ModuleKind.ESNext && implementationModuleKind.detectedKind === _attw_typescript_default.ModuleKind.CommonJS) return {
|
|
2837
2890
|
kind: "FalseESM",
|
|
2838
2891
|
typesFileName,
|
|
2839
2892
|
implementationFileName,
|
|
2840
2893
|
typesModuleKind,
|
|
2841
2894
|
implementationModuleKind
|
|
2842
2895
|
};
|
|
2843
|
-
else if (typesModuleKind.detectedKind ===
|
|
2896
|
+
else if (typesModuleKind.detectedKind === _attw_typescript_default.ModuleKind.CommonJS && implementationModuleKind.detectedKind === _attw_typescript_default.ModuleKind.ESNext) return {
|
|
2844
2897
|
kind: "FalseCJS",
|
|
2845
2898
|
typesFileName,
|
|
2846
2899
|
implementationFileName,
|
|
@@ -2862,9 +2915,9 @@ var checks_default = [
|
|
|
2862
2915
|
},
|
|
2863
2916
|
execute: ([fileName, expectedModuleKind], context) => {
|
|
2864
2917
|
var _a, _b;
|
|
2865
|
-
if (!expectedModuleKind || !
|
|
2918
|
+
if (!expectedModuleKind || !_attw_typescript_default.hasJSFileExtension(fileName)) return;
|
|
2866
2919
|
const sourceFile = ((_a = context.hosts.findHostForFiles([fileName])) !== null && _a !== void 0 ? _a : context.hosts.bundler).getSourceFile(fileName);
|
|
2867
|
-
const syntaxImpliedModuleKind = sourceFile.externalModuleIndicator ?
|
|
2920
|
+
const syntaxImpliedModuleKind = sourceFile.externalModuleIndicator ? _attw_typescript_default.ModuleKind.ESNext : sourceFile.commonJsModuleIndicator ? _attw_typescript_default.ModuleKind.CommonJS : void 0;
|
|
2868
2921
|
if (syntaxImpliedModuleKind !== void 0 && expectedModuleKind.detectedKind !== syntaxImpliedModuleKind) {
|
|
2869
2922
|
const syntax = (_b = sourceFile.externalModuleIndicator) !== null && _b !== void 0 ? _b : sourceFile.commonJsModuleIndicator;
|
|
2870
2923
|
return {
|
|
@@ -3029,7 +3082,7 @@ const assignedIdentifier = (declaration) => {
|
|
|
3029
3082
|
if (isExportAssignment(declaration)) return Option.liftPredicate(declaration.expression, (node) => isIdentifier(node));
|
|
3030
3083
|
return Option.none();
|
|
3031
3084
|
};
|
|
3032
|
-
const localNamed = (identifier) => bindingOf(sourceFileOf(identifier)).pipe(Option.flatMap((binding) => Option.liftPredicate(identifier, (node) => isIdentifier(node)).pipe(Option.flatMap((node) => Option.fromNullishOr(binding.locals.get(escapeLeadingUnderscores$1(node.text)))))));
|
|
3085
|
+
const localNamed = (identifier) => bindingOf(sourceFileOf(identifier)).pipe(Option.flatMap((binding) => Option.liftPredicate(identifier, (node) => isIdentifier(node)).pipe(Option.flatMap((node) => Option.fromNullishOr(binding.locals.entries.get(escapeLeadingUnderscores$1(node.text)))))));
|
|
3033
3086
|
const boundExpandoExports = (moduleSymbol) => Option.fromNullishOr(moduleSymbol.exports).pipe(Option.flatMap((exports) => Option.fromNullishOr(exports.get(EXPORT_EQUALS))), Option.flatMap((exportEquals) => firstDeclaration(exportEquals)), Option.flatMap((declaration) => assignedIdentifier(declaration)), Option.flatMap((identifier) => localNamed(identifier)), Option.flatMap((local) => Option.fromNullishOr(local.exports)), Option.map((members) => pipe([...members.values()], Array$1.filter((member) => hasFlag(member.flags, SymbolFlags.Assignment)))), Option.getOrElse(() => []));
|
|
3034
3087
|
// src/shared/lib/typescript/type-only.ts
|
|
3035
3088
|
const isTypeOnlyImportClause = (node) => isImportClause(node) && node.phaseModifier === SyntaxKind.TypeKeyword;
|
|
@@ -3307,43 +3360,28 @@ const attempt = (kind, extension, usingTsExtension = false) => ({
|
|
|
3307
3360
|
extension,
|
|
3308
3361
|
usingTsExtension
|
|
3309
3362
|
});
|
|
3310
|
-
const
|
|
3311
|
-
const explicit =
|
|
3312
|
-
return [
|
|
3313
|
-
attempt("TypeScript", Extension.Mts, explicit),
|
|
3314
|
-
attempt("Declaration", Extension.Dmts, explicit),
|
|
3315
|
-
attempt("JavaScript", Extension.Mjs)
|
|
3316
|
-
];
|
|
3317
|
-
};
|
|
3318
|
-
const cjsAttempts = (original) => {
|
|
3319
|
-
const explicit = original === Extension.Cts || original === Extension.Dcts;
|
|
3320
|
-
return [
|
|
3321
|
-
attempt("TypeScript", Extension.Cts, explicit),
|
|
3322
|
-
attempt("Declaration", Extension.Dcts, explicit),
|
|
3323
|
-
attempt("JavaScript", Extension.Cjs)
|
|
3324
|
-
];
|
|
3363
|
+
const family = (typed, listed, plain) => (original) => {
|
|
3364
|
+
const explicit = typed.includes(original);
|
|
3365
|
+
return [...pipe(listed, Array$1.map(([kind, extension]) => attempt(kind, extension, explicit))), ...pipe(plain, Array$1.map(([kind, extension]) => attempt(kind, extension)))];
|
|
3325
3366
|
};
|
|
3367
|
+
const esmAttempts = family([Extension.Mts, Extension.Dmts], [["TypeScript", Extension.Mts], ["Declaration", Extension.Dmts]], [["JavaScript", Extension.Mjs]]);
|
|
3368
|
+
const cjsAttempts = family([Extension.Cts, Extension.Dcts], [["TypeScript", Extension.Cts], ["Declaration", Extension.Dcts]], [["JavaScript", Extension.Cjs]]);
|
|
3326
3369
|
const jsonAttempts = () => [attempt("Declaration", ".d.json.ts"), attempt("Json", Extension.Json)];
|
|
3327
|
-
const
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
const defaultAttempts = (
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
attempt("Declaration", Extension.Dts, explicit),
|
|
3343
|
-
attempt("JavaScript", Extension.Js),
|
|
3344
|
-
attempt("JavaScript", Extension.Jsx)
|
|
3345
|
-
];
|
|
3346
|
-
};
|
|
3370
|
+
const TS_FILE = ["TypeScript", Extension.Ts];
|
|
3371
|
+
const TSX_FILE = ["TypeScript", Extension.Tsx];
|
|
3372
|
+
const DTS_FILE = ["Declaration", Extension.Dts];
|
|
3373
|
+
const JS_FILE = ["JavaScript", Extension.Js];
|
|
3374
|
+
const JSX_FILE = ["JavaScript", Extension.Jsx];
|
|
3375
|
+
const jsxAttempts = family([Extension.Tsx], [
|
|
3376
|
+
TSX_FILE,
|
|
3377
|
+
TS_FILE,
|
|
3378
|
+
DTS_FILE
|
|
3379
|
+
], [JSX_FILE, JS_FILE]);
|
|
3380
|
+
const defaultAttempts = family([Extension.Ts, Extension.Dts], [
|
|
3381
|
+
TS_FILE,
|
|
3382
|
+
TSX_FILE,
|
|
3383
|
+
DTS_FILE
|
|
3384
|
+
], [JS_FILE, JSX_FILE]);
|
|
3347
3385
|
const arbitraryAttempts = (candidate, original) => Option.liftPredicate(`${candidate}${original}`, (path) => !isDeclarationFileName(path)).pipe(Option.match({
|
|
3348
3386
|
onNone: () => [],
|
|
3349
3387
|
onSome: () => [attempt("Declaration", `.d${original}.ts`)]
|
|
@@ -4184,16 +4222,18 @@ const fromSelfName = (lookup, features, state) => {
|
|
|
4184
4222
|
if (features.selfName) return loadModuleFromSelfNameReference(lookup, state);
|
|
4185
4223
|
return Option.none();
|
|
4186
4224
|
};
|
|
4187
|
-
const
|
|
4225
|
+
const foundAs = (isExternalLibraryImport) => (resolved) => ({
|
|
4188
4226
|
resolved,
|
|
4189
|
-
isExternalLibraryImport
|
|
4190
|
-
})
|
|
4227
|
+
isExternalLibraryImport
|
|
4228
|
+
});
|
|
4229
|
+
const resolveNonRelative = (lookup, features, state) => {
|
|
4230
|
+
const external = foundAs(true);
|
|
4231
|
+
return fromPackageImports(lookup, features, state).pipe(Option.orElse(() => fromSelfName(lookup, features, state)), Option.orElse(() => resolveFromNodeModulesWithTrace(lookup, state)), Option.map(Option.map(external)));
|
|
4232
|
+
};
|
|
4191
4233
|
const resolveRelative = (lookup, state) => {
|
|
4192
4234
|
const { resolved, insideNodeModules } = loadRelativeModule(lookup, state);
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
isExternalLibraryImport: insideNodeModules
|
|
4196
|
-
})));
|
|
4235
|
+
const found = foundAs(insideNodeModules);
|
|
4236
|
+
return resolved.pipe(Option.map(found));
|
|
4197
4237
|
};
|
|
4198
4238
|
const tryResolve = (extensions, request, state) => {
|
|
4199
4239
|
const lookup = {
|
|
@@ -4310,18 +4350,18 @@ const resolveInDirectory = Function.dual(DATA_FIRST_ARITY$7, (request, context)
|
|
|
4310
4350
|
extensions: extensionsFor(request.options),
|
|
4311
4351
|
conditions: conditionsFor$1(request)
|
|
4312
4352
|
}, context));
|
|
4353
|
+
const cacheKeyOf = (request) => ({
|
|
4354
|
+
name: request.moduleName,
|
|
4355
|
+
mode: request.mode,
|
|
4356
|
+
directory: getDirectoryPath(request.containingFile)
|
|
4357
|
+
});
|
|
4313
4358
|
const resolveUncached = (request, context) => {
|
|
4314
|
-
const
|
|
4359
|
+
const key = cacheKeyOf(request);
|
|
4315
4360
|
traceMessage(context, Messages.explicitResolutionKind, request.options.moduleResolution);
|
|
4316
4361
|
const result = resolveInDirectory({
|
|
4317
4362
|
...request,
|
|
4318
|
-
containingDirectory
|
|
4363
|
+
containingDirectory: key.directory
|
|
4319
4364
|
}, context);
|
|
4320
|
-
const key = {
|
|
4321
|
-
name: request.moduleName,
|
|
4322
|
-
mode: request.mode,
|
|
4323
|
-
directory: containingDirectory
|
|
4324
|
-
};
|
|
4325
4365
|
for (const cache of Option.toArray(context.cache)) {
|
|
4326
4366
|
cache.setForDirectory(key, result);
|
|
4327
4367
|
if (!isExternalModuleNameRelative(request.moduleName)) cache.setForNonRelative(key, result);
|
|
@@ -4340,13 +4380,9 @@ const traceOutcome = (moduleName, result, trace) => {
|
|
|
4340
4380
|
emitTrace(trace, message);
|
|
4341
4381
|
};
|
|
4342
4382
|
const reuseCachedWithTrace = (request, context) => {
|
|
4343
|
-
const
|
|
4344
|
-
return context.cache.pipe(Option.flatMap((cache) => cache.getFromDirectory({
|
|
4345
|
-
|
|
4346
|
-
mode: request.mode,
|
|
4347
|
-
directory
|
|
4348
|
-
})), Option.map((cached) => {
|
|
4349
|
-
traceMessage(context, Messages.resolutionFoundInCache, request.moduleName, directory);
|
|
4383
|
+
const key = cacheKeyOf(request);
|
|
4384
|
+
return context.cache.pipe(Option.flatMap((cache) => cache.getFromDirectory(key)), Option.map((cached) => {
|
|
4385
|
+
traceMessage(context, Messages.resolutionFoundInCache, request.moduleName, key.directory);
|
|
4350
4386
|
return cached;
|
|
4351
4387
|
}));
|
|
4352
4388
|
};
|
|
@@ -4742,7 +4778,7 @@ const createProgram = Function.dual(DATA_FIRST_ARITY$5, (site, rootNames) => {
|
|
|
4742
4778
|
},
|
|
4743
4779
|
resolvedModules: programFiles.resolvedModules,
|
|
4744
4780
|
dispose: () => {
|
|
4745
|
-
for (const created of
|
|
4781
|
+
for (const created of checker.pipe(MutableRef.get, Option.toArray)) created.dispose();
|
|
4746
4782
|
}
|
|
4747
4783
|
};
|
|
4748
4784
|
});
|
|
@@ -5008,8 +5044,7 @@ const impliedFormatOf = (source, fileName) => {
|
|
|
5008
5044
|
if (fileExtensionIsOneOf(path, ESM_EXTENSIONS)) return Option.some("ESNext");
|
|
5009
5045
|
if (fileExtensionIsOneOf(path, CJS_EXTENSIONS)) return Option.some("CommonJS");
|
|
5010
5046
|
if (!shouldLookupPackageJson(source.kind, path)) return Option.none();
|
|
5011
|
-
|
|
5012
|
-
return Option.some(formatOfScope(scope));
|
|
5047
|
+
return cachedScope(source, getDirectoryPath(path)).pipe(formatOfScope, Option.some);
|
|
5013
5048
|
};
|
|
5014
5049
|
const scopeReason = (info) => {
|
|
5015
5050
|
if (Predicate.isTruthy(info.contents.packageJsonContent["type"])) return "type";
|
|
@@ -5272,7 +5307,7 @@ function getEntrypoints(fs, exportsObject, options) {
|
|
|
5272
5307
|
const rootDir = `/node_modules/${fs.packageName}`;
|
|
5273
5308
|
const proxies = getProxyDirectories(rootDir, fs);
|
|
5274
5309
|
if (proxies.length === 0) {
|
|
5275
|
-
if (options === null || options === void 0 ? void 0 : options.entrypointsLegacy) return fs.listFiles().filter((f) => !
|
|
5310
|
+
if (options === null || options === void 0 ? void 0 : options.entrypointsLegacy) return fs.listFiles().filter((f) => !_attw_typescript_default.isDeclarationFileName(f) && extensions.has(f.slice(f.lastIndexOf(".")))).map((f) => "." + f.slice(rootDir.length));
|
|
5276
5311
|
return ["."];
|
|
5277
5312
|
}
|
|
5278
5313
|
return proxies;
|
|
@@ -5319,10 +5354,10 @@ function getProxyDirectories(rootDir, fs) {
|
|
|
5319
5354
|
}
|
|
5320
5355
|
} catch {}
|
|
5321
5356
|
return proxyDirectories.sort((a, b) => {
|
|
5322
|
-
return
|
|
5357
|
+
return _attw_typescript_default.comparePathsCaseInsensitive(a, b);
|
|
5323
5358
|
});
|
|
5324
5359
|
function isInsideVendorDirectory(file) {
|
|
5325
|
-
return !!
|
|
5360
|
+
return !!_attw_typescript_default.forEachAncestorDirectory(file, (dir) => {
|
|
5326
5361
|
if (vendorDirectories.has(dir)) return true;
|
|
5327
5362
|
});
|
|
5328
5363
|
}
|
|
@@ -5361,7 +5396,7 @@ function getEntrypointResolution(packageName, host, resolutionKind, entrypoint)
|
|
|
5361
5396
|
};
|
|
5362
5397
|
const moduleSpecifier = packageName + entrypoint.substring(1);
|
|
5363
5398
|
const importingFileName = resolutionKind === "node16-esm" ? "/index.mts" : "/index.ts";
|
|
5364
|
-
const resolutionMode = resolutionKind === "node16-esm" ?
|
|
5399
|
+
const resolutionMode = resolutionKind === "node16-esm" ? _attw_typescript_default.ModuleKind.ESNext : resolutionKind === "node16-cjs" ? _attw_typescript_default.ModuleKind.CommonJS : void 0;
|
|
5365
5400
|
const resolution = tryResolve();
|
|
5366
5401
|
return {
|
|
5367
5402
|
name: entrypoint,
|
|
@@ -5377,8 +5412,8 @@ function getEntrypointResolution(packageName, host, resolutionKind, entrypoint)
|
|
|
5377
5412
|
if (!fileName) return;
|
|
5378
5413
|
return {
|
|
5379
5414
|
fileName,
|
|
5380
|
-
isJson: resolution.resolvedModule.extension ===
|
|
5381
|
-
isTypeScript:
|
|
5415
|
+
isJson: resolution.resolvedModule.extension === _attw_typescript_default.Extension.Json,
|
|
5416
|
+
isTypeScript: _attw_typescript_default.hasTSFileExtension(resolution.resolvedModule.resolvedFileName),
|
|
5382
5417
|
trace
|
|
5383
5418
|
};
|
|
5384
5419
|
}
|