@r_masseater/vite-plus-adopt 0.12.0 → 0.14.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/dist/attw.mjs CHANGED
@@ -11,6 +11,16 @@ 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 MEMBER_TABLE_FLAGS = combineFlags(SymbolFlags.Class, SymbolFlags.Interface, SymbolFlags.TypeLiteral, SymbolFlags.ObjectLiteral);
71
- const recordDeclaration = (symbol, node) => {
72
- const declarations = symbol.declarations ?? [];
73
- if (!declarations.includes(node)) declarations.push(node);
74
- symbol.declarations = declarations;
75
- };
76
- const DECLARATION_EFFECTS = [
77
- [EXPORT_TABLE_FLAGS, (symbol) => {
78
- symbol.exports ??= /* @__PURE__ */ new Map();
79
- }],
80
- [MEMBER_TABLE_FLAGS, (symbol) => {
81
- symbol.members ??= /* @__PURE__ */ new Map();
82
- }],
83
- [SymbolFlags.Value, (symbol, node) => {
84
- setValueDeclaration(symbol, node);
85
- }]
86
- ];
87
- const addDeclarationToSymbol = Function.dual(DATA_FIRST_ARITY_3$22, (symbol, node, flags) => {
88
- symbol.flags = withFlags(symbol.flags, flags);
89
- recordDeclaration(symbol, node);
90
- for (const [required, apply] of DECLARATION_EFFECTS) if (hasFlag(flags, required)) apply(symbol, node);
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 = createSymbol(0, name);
97
- table.set(name, created);
131
+ const created = new BoundSymbol(0, name);
132
+ table.add(created);
98
133
  return created;
99
134
  }
100
- if (conflicts(found, declaration)) return createSymbol(0, name);
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)), () => createSymbol(0, MISSING_NAME));
106
- addDeclarationToSymbol(symbol, declaration.node, declaration.includes);
107
- if (Predicate.isUndefined(symbol.parent) && Option.isSome(declaration.parent)) symbol.parent = declaration.parent.value;
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) => Option.fromNullishOr(symbol.exports))),
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.exportSymbol = declareExport(binding, node, flags);
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 = createSymbol(0, `"${String$1.replace(EXTENSION, "")(binding.file.fileName)}"`);
779
- addDeclarationToSymbol(symbol, binding.file, SymbolFlags.ValueModule);
780
- binding.symbol = 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.commonJsModuleIndicator = node;
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
- addDeclarationToSymbol(found, name, MODULE_ASSIGNMENT);
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
- addDeclarationToSymbol(symbol.value, name, NAMESPACE_FLAGS.includes);
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.exports ??= /* @__PURE__ */ new Map();
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
- setValueDeclaration(declareExport(binding, node, flags), node);
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$1)(binding, node, scope);
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$1);
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(symbol, node);
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$1)],
1357
- [SyntaxKind.NamespaceImport, inContainer(ALIAS$1)],
1358
- [SyntaxKind.ImportSpecifier, inContainer(ALIAS$1)],
1359
- [SyntaxKind.ExportSpecifier, inContainer(ALIAS$1)],
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 = (binding, node, scope) => {
1403
- if (scope.containerIsFile) declareSourceFileMember(binding, node, ALIAS);
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 (scope.containerIsFile && !isParameterBinding(node)) declareSourceFileMember(binding, node, FUNCTION_VARIABLE);
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 getArbitraryDeclarationExtension = (fileName) => 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)))));
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);
@@ -1878,10 +1935,11 @@ const MODULE_NAMES = /* @__PURE__ */ new Map([
1878
1935
  const SCRIPT_KINDS = new Set(Record.values(ScriptKind));
1879
1936
  const resolutionNameOf = (kind) => Option.fromNullishOr(kind).pipe(Option.flatMapNullishOr((value) => RESOLUTION_NAMES.get(value)), Option.getOrElse(() => "Node10"));
1880
1937
  const moduleNameOf = (kind) => Option.fromNullishOr(kind).pipe(Option.flatMapNullishOr((value) => MODULE_NAMES.get(value)), Option.getOrElse(() => "CommonJS"));
1881
- const getModeForUsageLocation = (sourceFile, usage, options) => Option.getOrUndefined(getModeForUsageLocation$1(sourceFile, usage, {
1938
+ const modeOptionsOf = (options) => ({
1882
1939
  moduleResolution: resolutionNameOf(options.moduleResolution),
1883
1940
  module: moduleNameOf(options.module)
1884
- }).pipe(Option.map((mode) => modeToNumber(mode))));
1941
+ });
1942
+ const getModeForUsageLocation = (sourceFile, usage, options) => Option.getOrUndefined(getModeForUsageLocation$1(sourceFile, usage, modeOptionsOf(options)).pipe(Option.map((mode) => modeToNumber(mode))));
1885
1943
  const isScriptKind = (value) => Predicate.isNumber(value) && SCRIPT_KINDS.has(value);
1886
1944
  const createSourceFile = (fileName, text, ...parseArguments) => parseSourceFile(getNormalizedAbsolutePath(fileName, ROOT), text, Option.liftPredicate(parseArguments[SCRIPT_KIND_AFTER_TEXT], isScriptKind));
1887
1945
  const fileFunctions = {
@@ -1901,13 +1959,12 @@ const ancestorMatching = (node, judge) => {
1901
1959
  if (verdict) return node;
1902
1960
  return ancestorMatching(Option.fromNullishOr(node.value.parent), judge);
1903
1961
  };
1904
- const findAncestor = (node, judge) => Option.getOrUndefined(ancestorMatching(Option.fromNullishOr(node), judge));
1905
1962
  const getNameOfAccessExpression$2 = (node) => {
1906
1963
  if (isPropertyAccessExpression(node)) return node.name;
1907
1964
  return skipParentheses(node.argumentExpression);
1908
1965
  };
1909
1966
  const nodeFunctions = {
1910
- findAncestor,
1967
+ findAncestor: (node, judge) => Option.getOrUndefined(ancestorMatching(Option.fromNullishOr(node), judge)),
1911
1968
  forEachChild: (node, visit) => node.forEachChild(visit),
1912
1969
  getNameOfAccessExpression: getNameOfAccessExpression$2,
1913
1970
  isAccessExpression: toleratingAbsence(isAccessExpression),
@@ -1954,16 +2011,13 @@ const parsePackageName = (moduleName) => Option.match(packageNameEnd(moduleName)
1954
2011
  rest: String$1.slice(end + NEXT$1)(moduleName)
1955
2012
  })
1956
2013
  });
1957
- const mangleScopedPackageName = (packageName) => {
1958
- if (!String$1.startsWith("@")(packageName)) return packageName;
1959
- const replaced = String$1.replace("/", SCOPE_SEPARATOR)(packageName);
1960
- if (replaced === packageName) return packageName;
1961
- return String$1.slice(SCOPE_MARKER_LENGTH)(replaced);
1962
- };
1963
- const unmangleScopedPackageName = (typesPackageName) => {
1964
- if (!String$1.includes(SCOPE_SEPARATOR)(typesPackageName)) return typesPackageName;
1965
- return `@${String$1.replace(SCOPE_SEPARATOR, "/")(typesPackageName)}`;
1966
- };
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)}`);
1967
2021
  const getTypesPackageName = (packageName) => `@types/${mangleScopedPackageName(packageName)}`;
1968
2022
  const mangleScopedPackageNameWithTrace = Function.dual(DATA_FIRST_ARITY$21, (packageName, state) => {
1969
2023
  const mangled = mangleScopedPackageName(packageName);
@@ -2001,8 +2055,8 @@ const pathFunctions = {
2001
2055
  pathIsRelative,
2002
2056
  unmangleScopedPackageName
2003
2057
  };
2004
- // src/shared/lib/typescript/index.ts
2005
- const ts = {
2058
+ // \0attw-typescript
2059
+ var _attw_typescript_default = {
2006
2060
  ...fileFunctions,
2007
2061
  ...nodeFunctions,
2008
2062
  ...pathFunctions,
@@ -2037,8 +2091,8 @@ var cjsOnlyExportsDefault_default = defineCheck({
2037
2091
  if (!implementationFileName) return;
2038
2092
  if (resolutionKind === "node10" || resolutionKind === "node16-cjs") return;
2039
2093
  const sourceFile = ((_c = context.hosts.findHostForFiles([implementationFileName])) !== null && _c !== void 0 ? _c : context.hosts.bundler).getSourceFile(implementationFileName);
2040
- 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(ts.InternalSymbolName.Default)) && sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores("__esModule")) && !sourceFile.symbol.exports.has(ts.InternalSymbolName.ExportEquals)) {
2041
- const decl = sourceFile.symbol.exports.get(ts.InternalSymbolName.Default).declarations[0];
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];
2042
2096
  return {
2043
2097
  kind: "CJSOnlyExportsDefault",
2044
2098
  fileName: implementationFileName,
@@ -2198,15 +2252,15 @@ var Package = class Package {
2198
2252
  return path in __classPrivateFieldGet(this, _Package_files, "f");
2199
2253
  }
2200
2254
  directoryExists(path) {
2201
- path = ts.ensureTrailingDirectorySeparator(path);
2255
+ path = _attw_typescript_default.ensureTrailingDirectorySeparator(path);
2202
2256
  for (const file in __classPrivateFieldGet(this, _Package_files, "f")) if (file.startsWith(path)) return true;
2203
2257
  return false;
2204
2258
  }
2205
2259
  containsTypes(directory = "/") {
2206
- return this.listFiles(directory).some(ts.hasTSFileExtension);
2260
+ return this.listFiles(directory).some(_attw_typescript_default.hasTSFileExtension);
2207
2261
  }
2208
2262
  listFiles(directory = "/") {
2209
- directory = ts.ensureTrailingDirectorySeparator(directory);
2263
+ directory = _attw_typescript_default.ensureTrailingDirectorySeparator(directory);
2210
2264
  return directory === "/" ? Object.keys(__classPrivateFieldGet(this, _Package_files, "f")) : Object.keys(__classPrivateFieldGet(this, _Package_files, "f")).filter((f) => f.startsWith(directory));
2211
2265
  }
2212
2266
  mergedWithTypes(typesPackage) {
@@ -2226,7 +2280,7 @@ async function createPackageFromNpm(packageSpec, { definitelyTyped = true, ...op
2226
2280
  const parsed = parsePackageSpec(packageSpec);
2227
2281
  if (parsed.status === "error") throw new Error(parsed.error);
2228
2282
  const packageName = parsed.data.name;
2229
- const typesPackageName = ts.getTypesPackageName(packageName);
2283
+ const typesPackageName = _attw_typescript_default.getTypesPackageName(packageName);
2230
2284
  const { tarballUrl, packageVersion } = parsed.data.versionKind === "none" && typeof definitelyTyped === "string" ? await resolveImplementationPackageForTypesPackage(typesPackageName, definitelyTyped, options) : await getNpmTarballUrl([parsed.data], options);
2231
2285
  const pkg = await createPackageFromTarballUrl(tarballUrl);
2232
2286
  if (!definitelyTyped || pkg.containsTypes()) return pkg;
@@ -2242,7 +2296,7 @@ async function createPackageFromNpm(packageSpec, { definitelyTyped = true, ...op
2242
2296
  }
2243
2297
  async function resolveImplementationPackageForTypesPackage(typesPackageName, typesPackageVersion, options) {
2244
2298
  if (!typesPackageName.startsWith("@types/")) throw new Error(`'resolveImplementationPackageForTypesPackage' expects an @types package name and version`);
2245
- const packageName = ts.unmangleScopedPackageName(typesPackageName.slice(7));
2299
+ const packageName = _attw_typescript_default.unmangleScopedPackageName(typesPackageName.slice(7));
2246
2300
  const version = valid(typesPackageVersion);
2247
2301
  if (version) return getNpmTarballUrl([
2248
2302
  parsePackageSpec(`${packageName}@${major(version)}.${minor(version)}`).data,
@@ -2262,7 +2316,7 @@ async function resolveImplementationPackageForTypesPackage(typesPackageName, typ
2262
2316
  throw new Error(`'resolveImplementationPackageForTypesPackage' expects a valid SemVer version or range`);
2263
2317
  }
2264
2318
  async function resolveTypesPackageForPackage(packageName, packageVersion, options) {
2265
- const typesPackageName = ts.getTypesPackageName(packageName);
2319
+ const typesPackageName = _attw_typescript_default.getTypesPackageName(packageName);
2266
2320
  try {
2267
2321
  return await getNpmTarballUrl([
2268
2322
  {
@@ -2359,7 +2413,7 @@ function extractTarball(tarball) {
2359
2413
  const packageVersion = packageJson.version;
2360
2414
  return {
2361
2415
  files: data.reduce((acc, file) => {
2362
- acc[ts.combinePaths("/node_modules/" + packageName, file.filename.substring(prefix.length))] = file.fileData;
2416
+ acc[_attw_typescript_default.combinePaths("/node_modules/" + packageName, file.filename.substring(prefix.length))] = file.fileData;
2363
2417
  return acc;
2364
2418
  }, {}),
2365
2419
  packageName,
@@ -2369,51 +2423,51 @@ function extractTarball(tarball) {
2369
2423
  // upstream/attw-core/lib/internal/esm/esmBindings.js
2370
2424
  function* extractDestructedNames(node) {
2371
2425
  switch (node.kind) {
2372
- case ts.SyntaxKind.ArrayBindingPattern:
2373
- for (const element of node.elements) if (element.kind === ts.SyntaxKind.BindingElement) yield* extractDestructedNames(element.name);
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);
2374
2428
  break;
2375
- case ts.SyntaxKind.Identifier:
2429
+ case _attw_typescript_default.SyntaxKind.Identifier:
2376
2430
  yield node.text;
2377
2431
  break;
2378
- case ts.SyntaxKind.ObjectBindingPattern: for (const element of node.elements) yield* extractDestructedNames(element.name);
2432
+ case _attw_typescript_default.SyntaxKind.ObjectBindingPattern: for (const element of node.elements) yield* extractDestructedNames(element.name);
2379
2433
  }
2380
2434
  }
2381
2435
  function getEsmModuleBindings(sourceText) {
2382
2436
  const options = {
2383
- languageVersion: ts.ScriptTarget.ESNext,
2384
- impliedNodeFormat: ts.ModuleKind.ESNext
2437
+ languageVersion: _attw_typescript_default.ScriptTarget.ESNext,
2438
+ impliedNodeFormat: _attw_typescript_default.ModuleKind.ESNext
2385
2439
  };
2386
- const sourceFile = ts.createSourceFile("module.cjs", sourceText, options, false, ts.ScriptKind.JS);
2440
+ const sourceFile = _attw_typescript_default.createSourceFile("module.cjs", sourceText, options, false, _attw_typescript_default.ScriptKind.JS);
2387
2441
  const exports = [];
2388
2442
  const reexports = [];
2389
2443
  for (const statement of sourceFile.statements) switch (statement.kind) {
2390
- case ts.SyntaxKind.ExportDeclaration: {
2444
+ case _attw_typescript_default.SyntaxKind.ExportDeclaration: {
2391
2445
  const declaration = statement;
2392
2446
  const { exportClause } = declaration;
2393
2447
  if (!declaration.isTypeOnly) {
2394
2448
  if (exportClause) {
2395
- if (exportClause.kind === ts.SyntaxKind.NamedExports) {
2449
+ if (exportClause.kind === _attw_typescript_default.SyntaxKind.NamedExports) {
2396
2450
  for (const element of exportClause.elements) if (!element.isTypeOnly) exports.push(element.name.text);
2397
2451
  } else exports.push(exportClause.name.text);
2398
- } else if (declaration.moduleSpecifier && ts.isStringLiteral(declaration.moduleSpecifier)) reexports.push(declaration.moduleSpecifier.text);
2452
+ } else if (declaration.moduleSpecifier && _attw_typescript_default.isStringLiteral(declaration.moduleSpecifier)) reexports.push(declaration.moduleSpecifier.text);
2399
2453
  }
2400
2454
  break;
2401
2455
  }
2402
- case ts.SyntaxKind.ExportAssignment:
2456
+ case _attw_typescript_default.SyntaxKind.ExportAssignment:
2403
2457
  if (!statement.isExportEquals) exports.push("default");
2404
2458
  break;
2405
- case ts.SyntaxKind.ClassDeclaration:
2406
- case ts.SyntaxKind.FunctionDeclaration: {
2459
+ case _attw_typescript_default.SyntaxKind.ClassDeclaration:
2460
+ case _attw_typescript_default.SyntaxKind.FunctionDeclaration: {
2407
2461
  const declaration = statement;
2408
- if (ts.hasSyntacticModifier(declaration, ts.ModifierFlags.Export)) {
2409
- if (ts.hasSyntacticModifier(declaration, ts.ModifierFlags.Default)) exports.push("default");
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");
2410
2464
  else if (declaration.name) exports.push(declaration.name.text);
2411
2465
  }
2412
2466
  break;
2413
2467
  }
2414
- case ts.SyntaxKind.VariableStatement: {
2468
+ case _attw_typescript_default.SyntaxKind.VariableStatement: {
2415
2469
  const declaration = statement;
2416
- if (ts.hasSyntacticModifier(declaration, ts.ModifierFlags.Export)) for (const declarator of declaration.declarationList.declarations) exports.push(...extractDestructedNames(declarator.name));
2470
+ if (_attw_typescript_default.hasSyntacticModifier(declaration, _attw_typescript_default.ModifierFlags.Export)) for (const declarator of declaration.declarationList.declarations) exports.push(...extractDestructedNames(declarator.name));
2417
2471
  break;
2418
2472
  }
2419
2473
  }
@@ -2486,15 +2540,15 @@ var namedExports_default = defineCheck({
2486
2540
  ];
2487
2541
  },
2488
2542
  execute: ([implementationFileName, implementationModuleKind, typesFileName, typesModuleKind, resolutionKind], context) => {
2489
- if (!implementationFileName || !typesFileName || resolutionKind !== "node16-esm" || (typesModuleKind === null || typesModuleKind === void 0 ? void 0 : typesModuleKind.detectedKind) !== ts.ModuleKind.CommonJS || (implementationModuleKind === null || implementationModuleKind === void 0 ? void 0 : implementationModuleKind.detectedKind) !== ts.ModuleKind.CommonJS) return;
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;
2490
2544
  const host = context.hosts.findHostForFiles([typesFileName]);
2491
2545
  const typesSourceFile = host.getSourceFile(typesFileName);
2492
- if (typesSourceFile.scriptKind === ts.ScriptKind.JSON || !typesSourceFile.symbol) return;
2546
+ if (typesSourceFile.scriptKind === _attw_typescript_default.ScriptKind.JSON || !typesSourceFile.symbol) return;
2493
2547
  const typeChecker = host.createAuxiliaryProgram([typesFileName]).getTypeChecker();
2494
2548
  const moduleType = typeChecker.getTypeOfSymbol(typeChecker.resolveExternalModuleSymbol(typesSourceFile.symbol));
2495
2549
  if (typeChecker.isArrayLikeType(moduleType) || typeChecker.getPropertyOfType(moduleType, "0")) return;
2496
2550
  const expectedNames = Array.from(new Set(typeChecker.getExportsAndPropertiesOfModule(typesSourceFile.symbol).filter((symbol) => {
2497
- return symbol.name !== "prototype" && typeChecker.getSymbolFlags(symbol, true) & ts.SymbolFlags.Value;
2551
+ return symbol.name !== "prototype" && typeChecker.getSymbolFlags(symbol, true) & _attw_typescript_default.SymbolFlags.Value;
2498
2552
  }).map((symbol) => symbol.name)));
2499
2553
  let exports;
2500
2554
  try {
@@ -2534,7 +2588,7 @@ var entrypointResolutions_default = defineCheck({
2534
2588
  entrypoint: subpath,
2535
2589
  resolutionKind
2536
2590
  });
2537
- if (resolutionKind === "node16-cjs" && (!entrypoint.implementationResolution && entrypoint.resolution && ((_a = context.programInfo["node16"].moduleKinds[entrypoint.resolution.fileName]) === null || _a === void 0 ? void 0 : _a.detectedKind) === ts.ModuleKind.ESNext || entrypoint.implementationResolution && ((_b = context.programInfo["node16"].moduleKinds[entrypoint.implementationResolution.fileName]) === null || _b === void 0 ? void 0 : _b.detectedKind) === ts.ModuleKind.ESNext)) problems.push({
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({
2538
2592
  kind: "CJSResolvesToESM",
2539
2593
  entrypoint: subpath,
2540
2594
  resolutionKind
@@ -2561,14 +2615,14 @@ function getEsbuildBabelSwcExports(sourceFile) {
2561
2615
  for (const statement of sourceFile.statements) {
2562
2616
  if (possibleIndex !== -1 && statement.end < possibleIndex) continue;
2563
2617
  if (possibleIndex !== -1 && statement.pos > possibleIndex) break;
2564
- if (ts.isExpressionStatement(statement) && ts.isCallExpression(statement.expression) && ts.isIdentifier(statement.expression.expression) && statement.expression.arguments.length === 2 && ts.isIdentifier(statement.expression.arguments[0]) && ts.isObjectLiteralExpression(statement.expression.arguments[1])) {
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])) {
2565
2619
  const callTarget = statement.expression.expression;
2566
- if (callTarget.text === "__export" || callTarget.text === "_export" || isEsbuildExportFunction((_b = (_a = sourceFile.locals) === null || _a === void 0 ? void 0 : _a.get(ts.escapeLeadingUnderscores(callTarget.text))) === null || _b === void 0 ? void 0 : _b.valueDeclaration)) return statement.expression.arguments[1].properties.flatMap((prop) => {
2567
- if (ts.isPropertyAssignment(prop) && (ts.isIdentifier(prop.name) || ts.isStringOrNumericLiteralLike(prop.name))) return [{
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 [{
2568
2622
  name: prop.name.text,
2569
2623
  node: prop
2570
2624
  }];
2571
- if (ts.isShorthandPropertyAssignment(prop)) return [{
2625
+ if (_attw_typescript_default.isShorthandPropertyAssignment(prop)) return [{
2572
2626
  name: prop.name.text,
2573
2627
  node: prop
2574
2628
  }];
@@ -2579,7 +2633,7 @@ function getEsbuildBabelSwcExports(sourceFile) {
2579
2633
  }
2580
2634
  function isEsbuildExportFunction(decl) {
2581
2635
  if (!decl) return false;
2582
- return ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionExpressionOrArrowFunction(decl.initializer) && ts.isBlock(decl.initializer.body) && decl.initializer.body.statements.length == 1 && ts.isForInStatement(decl.initializer.body.statements[0]);
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]);
2583
2637
  }
2584
2638
  function isProbablyMinified(text) {
2585
2639
  return minifiedVariableAssignmentPattern.test(text);
@@ -2587,61 +2641,61 @@ function isProbablyMinified(text) {
2587
2641
  function getWebpackBootstrapExports(sourceFile) {
2588
2642
  var _a;
2589
2643
  for (const statement of sourceFile.statements) {
2590
- if (!ts.isExpressionStatement(statement) || !ts.isBinaryExpression(statement.expression)) continue;
2644
+ if (!_attw_typescript_default.isExpressionStatement(statement) || !_attw_typescript_default.isBinaryExpression(statement.expression)) continue;
2591
2645
  const assignment = statement.expression;
2592
- if (assignment.operatorToken.kind !== ts.SyntaxKind.EqualsToken || !isModuleExports$1(assignment.left)) continue;
2593
- const bootstrapCall = ts.skipParentheses(assignment.right);
2594
- if (!ts.isCallExpression(bootstrapCall)) continue;
2595
- const bootstrap = ts.skipParentheses(bootstrapCall.expression);
2596
- if (!ts.isFunctionExpression(bootstrap) || !ts.isBlock(bootstrap.body) || bootstrapCall.arguments.length !== 1 || !ts.isArrayLiteralExpression(bootstrapCall.arguments[0])) continue;
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;
2597
2651
  const entryModuleId = getWebpackEntryModuleId(bootstrap.body);
2598
2652
  if (entryModuleId === void 0) continue;
2599
2653
  const entryModule = bootstrapCall.arguments[0].elements[entryModuleId];
2600
- if (!entryModule || !ts.isFunctionExpression(entryModule)) continue;
2654
+ if (!entryModule || !_attw_typescript_default.isFunctionExpression(entryModule)) continue;
2601
2655
  const exportsParameterName = (_a = entryModule.parameters[1]) === null || _a === void 0 ? void 0 : _a.name;
2602
- if (!exportsParameterName || !ts.isIdentifier(exportsParameterName)) continue;
2656
+ if (!exportsParameterName || !_attw_typescript_default.isIdentifier(exportsParameterName)) continue;
2603
2657
  const exportsParameterText = exportsParameterName.text;
2604
2658
  const exports = [];
2605
2659
  visit(entryModule.body);
2606
2660
  return exports;
2607
2661
  function visit(node) {
2608
- if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isAccessExpression(node.left) && ts.isIdentifier(node.left.expression) && node.left.expression.text === exportsParameterText) {
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) {
2609
2663
  const name = getNameOfAccessExpression$1(node.left);
2610
2664
  if (name !== void 0) exports.push({
2611
2665
  name,
2612
2666
  node
2613
2667
  });
2614
2668
  }
2615
- ts.forEachChild(node, visit);
2669
+ _attw_typescript_default.forEachChild(node, visit);
2616
2670
  }
2617
2671
  }
2618
2672
  }
2619
2673
  function getWebpackEntryModuleId(body) {
2620
2674
  for (const statement of body.statements) {
2621
- if (!ts.isReturnStatement(statement) || !statement.expression) continue;
2675
+ if (!_attw_typescript_default.isReturnStatement(statement) || !statement.expression) continue;
2622
2676
  return getWebpackEntryModuleIdFromExpression(statement.expression);
2623
2677
  }
2624
2678
  }
2625
2679
  function getWebpackEntryModuleIdFromExpression(expression) {
2626
- expression = ts.skipParentheses(expression);
2627
- if (ts.isCallExpression(expression) && expression.arguments.length === 1) return getNumericValue(expression.arguments[0]);
2628
- if (ts.isBinaryExpression(expression) && expression.operatorToken.kind === ts.SyntaxKind.CommaToken) return getWebpackEntryModuleIdFromExpression(expression.right);
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);
2629
2683
  }
2630
2684
  function getNumericValue(node) {
2631
- node = ts.skipParentheses(node);
2632
- if (ts.isNumericLiteral(node)) return Number(node.text);
2633
- if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) return getNumericValue(node.right);
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);
2634
2688
  }
2635
2689
  function isModuleExports$1(node) {
2636
- return ts.isAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "module" && getNameOfAccessExpression$1(node) === "exports";
2690
+ return _attw_typescript_default.isAccessExpression(node) && _attw_typescript_default.isIdentifier(node.expression) && node.expression.text === "module" && getNameOfAccessExpression$1(node) === "exports";
2637
2691
  }
2638
2692
  function getNameOfAccessExpression$1(accessExpression) {
2639
- const node = ts.getNameOfAccessExpression(accessExpression);
2640
- if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) return node.text;
2693
+ const node = _attw_typescript_default.getNameOfAccessExpression(accessExpression);
2694
+ if (_attw_typescript_default.isIdentifier(node) || _attw_typescript_default.isStringLiteralLike(node)) return node.text;
2641
2695
  }
2642
2696
  // upstream/attw-core/lib/internal/checks/exportDefaultDisagreement.js
2643
2697
  const bindOptions = {
2644
- target: ts.ScriptTarget.Latest,
2698
+ target: _attw_typescript_default.ScriptTarget.Latest,
2645
2699
  allowJs: true,
2646
2700
  checkJs: true
2647
2701
  };
@@ -2652,38 +2706,38 @@ var exportDefaultDisagreement_default = defineCheck({
2652
2706
  const entrypoint = entrypoints[subpath].resolutions[resolutionKind];
2653
2707
  const typesFileName = (_a = entrypoint.resolution) === null || _a === void 0 ? void 0 : _a.fileName;
2654
2708
  const implementationFileName = (_b = entrypoint.implementationResolution) === null || _b === void 0 ? void 0 : _b.fileName;
2655
- if (typesFileName && ((_d = (_c = programInfo[getResolutionOption(resolutionKind)].moduleKinds) === null || _c === void 0 ? void 0 : _c[typesFileName]) === null || _d === void 0 ? void 0 : _d.detectedKind) === ts.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) === ts.ModuleKind.ESNext) return [];
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 [];
2656
2710
  return [typesFileName, implementationFileName];
2657
2711
  },
2658
2712
  execute: ([typesFileName, implementationFileName], context) => {
2659
2713
  var _a, _b;
2660
- if (!typesFileName || !implementationFileName || !ts.hasTSFileExtension(typesFileName)) return;
2714
+ if (!typesFileName || !implementationFileName || !_attw_typescript_default.hasTSFileExtension(typesFileName)) return;
2661
2715
  const host = context.hosts.findHostForFiles([typesFileName]);
2662
2716
  const typesSourceFile = host.getSourceFile(typesFileName);
2663
- ts.bindSourceFile(typesSourceFile, bindOptions);
2717
+ _attw_typescript_default.bindSourceFile(typesSourceFile, bindOptions);
2664
2718
  if (!((_a = typesSourceFile.symbol) === null || _a === void 0 ? void 0 : _a.exports)) return;
2665
2719
  const implementationSourceFile = host.getSourceFile(implementationFileName);
2666
- ts.bindSourceFile(implementationSourceFile, bindOptions);
2720
+ _attw_typescript_default.bindSourceFile(implementationSourceFile, bindOptions);
2667
2721
  if (!((_b = implementationSourceFile.symbol) === null || _b === void 0 ? void 0 : _b.exports) || implementationSourceFile.externalModuleIndicator) return;
2668
- if (typesSourceFile.symbol.exports.has(ts.InternalSymbolName.Default) && !getImplHasDefault() && implIsAnalyzable()) return {
2722
+ if (typesSourceFile.symbol.exports.has(_attw_typescript_default.InternalSymbolName.Default) && !getImplHasDefault() && implIsAnalyzable()) return {
2669
2723
  kind: "FalseExportDefault",
2670
2724
  typesFileName,
2671
2725
  implementationFileName
2672
2726
  };
2673
2727
  if (!getImplHasDefault() || !implIsAnalyzable()) return;
2674
- if (!typesSourceFile.symbol.exports.has(ts.InternalSymbolName.ExportEquals) && implementationSourceFile.symbol.exports.has(ts.InternalSymbolName.ExportEquals) && getTypesDefaultSymbol() && (getImplExportEqualsIsExportDefault() && getTypesChecker().typeHasCallOrConstructSignatures(getTypesTypeOfDefault()) || getImplChecker().typeHasCallOrConstructSignatures(getImplTypeOfModuleExports()))) return {
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 {
2675
2729
  kind: "MissingExportEquals",
2676
2730
  typesFileName,
2677
2731
  implementationFileName
2678
2732
  };
2679
2733
  if (!Array.from(typesSourceFile.symbol.exports.values()).some((s) => {
2680
2734
  if (s.escapedName === "default") return false;
2681
- if (s.flags & ts.SymbolFlags.Value) return true;
2682
- while (s.flags & ts.SymbolFlags.Alias) {
2735
+ if (s.flags & _attw_typescript_default.SymbolFlags.Value) return true;
2736
+ while (s.flags & _attw_typescript_default.SymbolFlags.Alias) {
2683
2737
  s = getTypesChecker().getAliasedSymbol(s);
2684
- if (s.flags & ts.SymbolFlags.Value) return true;
2738
+ if (s.flags & _attw_typescript_default.SymbolFlags.Value) return true;
2685
2739
  }
2686
- }) && typeIsObjecty(getTypesTypeOfDefault(), getTypesChecker()) && (Array.from(implementationSourceFile.symbol.exports.keys()).some((name) => isNotDefaultOrEsModule(ts.unescapeLeadingUnderscores(name))) || getImplProbableExports().some(({ name }) => isNotDefaultOrEsModule(name))) && getTypesDefaultSymbol()) return {
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 {
2687
2741
  kind: "MissingExportEquals",
2688
2742
  typesFileName,
2689
2743
  implementationFileName
@@ -2700,7 +2754,7 @@ var exportDefaultDisagreement_default = defineCheck({
2700
2754
  function getImplHasDefault() {
2701
2755
  var _a, _b, _c, _d, _e;
2702
2756
  var _f;
2703
- 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(ts.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");
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");
2704
2758
  }
2705
2759
  function getTypesChecker() {
2706
2760
  var _a;
@@ -2708,7 +2762,7 @@ var exportDefaultDisagreement_default = defineCheck({
2708
2762
  }
2709
2763
  function getTypesDefaultSymbol() {
2710
2764
  var _a, _b;
2711
- return (_a = typesDefaultSymbol) !== null && _a !== void 0 ? _a : typesDefaultSymbol = (_b = typesSourceFile.symbol.exports.get(ts.InternalSymbolName.Default)) !== null && _b !== void 0 ? _b : getTypesChecker().getExportsAndPropertiesOfModule(typesSourceFile.symbol).find((s) => s.escapedName === "default");
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");
2712
2766
  }
2713
2767
  function getTypesTypeOfDefault() {
2714
2768
  var _a;
@@ -2718,19 +2772,19 @@ var exportDefaultDisagreement_default = defineCheck({
2718
2772
  function getImplTypeOfModuleExports() {
2719
2773
  if (implTypeOfModuleExports) return implTypeOfModuleExports;
2720
2774
  const type = getImplChecker().getTypeOfSymbol(getImplChecker().resolveExternalModuleSymbol(implementationSourceFile.symbol));
2721
- if (type.flags & ts.TypeFlags.Any && getImplExportEqualsIsExportDefault()) return implTypeOfModuleExports = getImplChecker().getTypeOfSymbol(implementationSourceFile.symbol.exports.get(ts.InternalSymbolName.Default));
2775
+ if (type.flags & _attw_typescript_default.TypeFlags.Any && getImplExportEqualsIsExportDefault()) return implTypeOfModuleExports = getImplChecker().getTypeOfSymbol(implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default));
2722
2776
  return implTypeOfModuleExports = type;
2723
2777
  }
2724
2778
  function getImplExportEqualsIsExportDefault() {
2725
2779
  var _a;
2726
2780
  if (implExportEqualsIsExportDefault !== void 0) return implExportEqualsIsExportDefault;
2727
- const exportEquals = implementationSourceFile.symbol.exports.get(ts.InternalSymbolName.ExportEquals);
2781
+ const exportEquals = implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.ExportEquals);
2728
2782
  if (!exportEquals) return implExportEqualsIsExportDefault = false;
2729
- const exportDefault = implementationSourceFile.symbol.exports.get(ts.InternalSymbolName.Default);
2783
+ const exportDefault = implementationSourceFile.symbol.exports.get(_attw_typescript_default.InternalSymbolName.Default);
2730
2784
  if (!exportDefault) return implExportEqualsIsExportDefault = false;
2731
- for (const assignment of [exportEquals.valueDeclaration, ts.findAncestor((_a = exportDefault.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isBinaryExpression)]) {
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)]) {
2732
2786
  let seenModuleExports = false, seenExportsDefault = false;
2733
- if (assignment && ts.isBinaryExpression(assignment) && assignment.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
2787
+ if (assignment && _attw_typescript_default.isBinaryExpression(assignment) && assignment.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken) {
2734
2788
  if (!!forEachAssignmentTarget(assignment, (target) => {
2735
2789
  if (!seenExportsDefault && isExportsDefault(target)) seenExportsDefault = true;
2736
2790
  else if (!seenModuleExports && isModuleExports(target)) seenModuleExports = true;
@@ -2742,10 +2796,10 @@ var exportDefaultDisagreement_default = defineCheck({
2742
2796
  }
2743
2797
  function implIsAnalyzable() {
2744
2798
  var _a, _b, _c;
2745
- if (((_b = (_a = implementationSourceFile.symbol.exports.get(ts.InternalSymbolName.ExportEquals)) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.length) > 1) {
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) {
2746
2800
  let commonContainer;
2747
- for (const decl of implementationSourceFile.symbol.exports.get(ts.InternalSymbolName.ExportEquals).declarations) {
2748
- const container = ts.findAncestor(decl, (node) => ts.isFunctionBlock(node) || ts.isSourceFile(node));
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));
2749
2803
  if (commonContainer === void 0) commonContainer = container;
2750
2804
  else if (commonContainer !== container) return false;
2751
2805
  }
@@ -2755,31 +2809,31 @@ var exportDefaultDisagreement_default = defineCheck({
2755
2809
  }
2756
2810
  });
2757
2811
  function typeIsObjecty(type, checker) {
2758
- return type.flags & ts.TypeFlags.Object && !(type.flags & ts.TypeFlags.Primitive) && !checker.typeHasCallOrConstructSignatures(type);
2812
+ return type.flags & _attw_typescript_default.TypeFlags.Object && !(type.flags & _attw_typescript_default.TypeFlags.Primitive) && !checker.typeHasCallOrConstructSignatures(type);
2759
2813
  }
2760
2814
  function isModuleExports(target) {
2761
- return ts.isAccessExpression(target) && ts.isIdentifier(target.expression) && target.expression.text === "module" && getNameOfAccessExpression(target) === "exports" || ts.isIdentifier(target) && target.text === "exports";
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";
2762
2816
  }
2763
2817
  function isExportsDefault(target) {
2764
- return ts.isAccessExpression(target) && ts.isIdentifier(target.expression) && target.expression.text === "exports" && getNameOfAccessExpression(target) === "default" || ts.isAccessExpression(target) && ts.isAccessExpression(target.expression) && ts.isIdentifier(target.expression.expression) && target.expression.expression.text === "module" && getNameOfAccessExpression(target.expression) === "exports" && getNameOfAccessExpression(target) === "default";
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";
2765
2819
  }
2766
2820
  function isNotDefaultOrEsModule(name) {
2767
2821
  return name !== "default" && name !== "__esModule";
2768
2822
  }
2769
2823
  function forEachAssignmentTarget(assignment, cb) {
2770
- const target = ts.skipParentheses(assignment.right);
2771
- if (ts.isBinaryExpression(target) && target.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
2824
+ const target = _attw_typescript_default.skipParentheses(assignment.right);
2825
+ if (_attw_typescript_default.isBinaryExpression(target) && target.operatorToken.kind === _attw_typescript_default.SyntaxKind.EqualsToken) {
2772
2826
  const res = forEachAssignmentTarget(target, cb);
2773
2827
  if (res) return res;
2774
2828
  } else {
2775
2829
  const res = cb(target);
2776
2830
  if (res) return res;
2777
2831
  }
2778
- return cb(ts.skipParentheses(assignment.left));
2832
+ return cb(_attw_typescript_default.skipParentheses(assignment.left));
2779
2833
  }
2780
2834
  function getNameOfAccessExpression(accessExpression) {
2781
- const node = ts.getNameOfAccessExpression(accessExpression);
2782
- if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) return node.text;
2835
+ const node = _attw_typescript_default.getNameOfAccessExpression(accessExpression);
2836
+ if (_attw_typescript_default.isIdentifier(node) || _attw_typescript_default.isStringLiteralLike(node)) return node.text;
2783
2837
  }
2784
2838
  // upstream/attw-core/lib/internal/checks/internalResolutionError.js
2785
2839
  var internalResolutionError_default = defineCheck({
@@ -2787,15 +2841,15 @@ var internalResolutionError_default = defineCheck({
2787
2841
  enumerateFiles: true,
2788
2842
  dependencies: ({ resolutionOption, fileName }) => [resolutionOption, fileName],
2789
2843
  execute: ([resolutionOption, fileName], context) => {
2790
- if (!ts.hasTSFileExtension(fileName)) return;
2844
+ if (!_attw_typescript_default.hasTSFileExtension(fileName)) return;
2791
2845
  const host = context.hosts[resolutionOption];
2792
2846
  const sourceFile = host.getSourceFile(fileName);
2793
2847
  if (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.imports) {
2794
2848
  const problems = [];
2795
2849
  for (const moduleSpecifier of sourceFile.imports) {
2796
2850
  const reference = moduleSpecifier.text;
2797
- if (reference !== context.pkg.packageName && !reference.startsWith(`${context.pkg.packageName}/`) && reference[0] !== "#" && !ts.pathIsRelative(reference)) continue;
2798
- const resolutionMode = ts.getModeForUsageLocation(sourceFile, moduleSpecifier, host.getCompilerOptions());
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());
2799
2853
  const resolution = host.getResolvedModule(sourceFile, moduleSpecifier.text, resolutionMode);
2800
2854
  if (!resolution) throw new Error(`Expected resolution for '${moduleSpecifier.text}' in ${fileName}`);
2801
2855
  if (!resolution.resolvedModule) problems.push({
@@ -2832,14 +2886,14 @@ var checks_default = [
2832
2886
  },
2833
2887
  execute: ([typesFileName, implementationFileName, typesModuleKind, implementationModuleKind]) => {
2834
2888
  if (typesFileName && implementationFileName && typesModuleKind && implementationModuleKind) {
2835
- if (typesModuleKind.detectedKind === ts.ModuleKind.ESNext && implementationModuleKind.detectedKind === ts.ModuleKind.CommonJS) return {
2889
+ if (typesModuleKind.detectedKind === _attw_typescript_default.ModuleKind.ESNext && implementationModuleKind.detectedKind === _attw_typescript_default.ModuleKind.CommonJS) return {
2836
2890
  kind: "FalseESM",
2837
2891
  typesFileName,
2838
2892
  implementationFileName,
2839
2893
  typesModuleKind,
2840
2894
  implementationModuleKind
2841
2895
  };
2842
- else if (typesModuleKind.detectedKind === ts.ModuleKind.CommonJS && implementationModuleKind.detectedKind === ts.ModuleKind.ESNext) return {
2896
+ else if (typesModuleKind.detectedKind === _attw_typescript_default.ModuleKind.CommonJS && implementationModuleKind.detectedKind === _attw_typescript_default.ModuleKind.ESNext) return {
2843
2897
  kind: "FalseCJS",
2844
2898
  typesFileName,
2845
2899
  implementationFileName,
@@ -2861,9 +2915,9 @@ var checks_default = [
2861
2915
  },
2862
2916
  execute: ([fileName, expectedModuleKind], context) => {
2863
2917
  var _a, _b;
2864
- if (!expectedModuleKind || !ts.hasJSFileExtension(fileName)) return;
2918
+ if (!expectedModuleKind || !_attw_typescript_default.hasJSFileExtension(fileName)) return;
2865
2919
  const sourceFile = ((_a = context.hosts.findHostForFiles([fileName])) !== null && _a !== void 0 ? _a : context.hosts.bundler).getSourceFile(fileName);
2866
- const syntaxImpliedModuleKind = sourceFile.externalModuleIndicator ? ts.ModuleKind.ESNext : sourceFile.commonJsModuleIndicator ? ts.ModuleKind.CommonJS : void 0;
2920
+ const syntaxImpliedModuleKind = sourceFile.externalModuleIndicator ? _attw_typescript_default.ModuleKind.ESNext : sourceFile.commonJsModuleIndicator ? _attw_typescript_default.ModuleKind.CommonJS : void 0;
2867
2921
  if (syntaxImpliedModuleKind !== void 0 && expectedModuleKind.detectedKind !== syntaxImpliedModuleKind) {
2868
2922
  const syntax = (_b = sourceFile.externalModuleIndicator) !== null && _b !== void 0 ? _b : sourceFile.commonJsModuleIndicator;
2869
2923
  return {
@@ -3028,7 +3082,7 @@ const assignedIdentifier = (declaration) => {
3028
3082
  if (isExportAssignment(declaration)) return Option.liftPredicate(declaration.expression, (node) => isIdentifier(node));
3029
3083
  return Option.none();
3030
3084
  };
3031
- 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)))))));
3032
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(() => []));
3033
3087
  // src/shared/lib/typescript/type-only.ts
3034
3088
  const isTypeOnlyImportClause = (node) => isImportClause(node) && node.phaseModifier === SyntaxKind.TypeKeyword;
@@ -3306,43 +3360,28 @@ const attempt = (kind, extension, usingTsExtension = false) => ({
3306
3360
  extension,
3307
3361
  usingTsExtension
3308
3362
  });
3309
- const esmAttempts = (original) => {
3310
- const explicit = original === Extension.Mts || original === Extension.Dmts;
3311
- return [
3312
- attempt("TypeScript", Extension.Mts, explicit),
3313
- attempt("Declaration", Extension.Dmts, explicit),
3314
- attempt("JavaScript", Extension.Mjs)
3315
- ];
3316
- };
3317
- const cjsAttempts = (original) => {
3318
- const explicit = original === Extension.Cts || original === Extension.Dcts;
3319
- return [
3320
- attempt("TypeScript", Extension.Cts, explicit),
3321
- attempt("Declaration", Extension.Dcts, explicit),
3322
- attempt("JavaScript", Extension.Cjs)
3323
- ];
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)))];
3324
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]]);
3325
3369
  const jsonAttempts = () => [attempt("Declaration", ".d.json.ts"), attempt("Json", Extension.Json)];
3326
- const jsxAttempts = (original) => {
3327
- const explicit = original === Extension.Tsx;
3328
- return [
3329
- attempt("TypeScript", Extension.Tsx, explicit),
3330
- attempt("TypeScript", Extension.Ts, explicit),
3331
- attempt("Declaration", Extension.Dts, explicit),
3332
- attempt("JavaScript", Extension.Jsx),
3333
- attempt("JavaScript", Extension.Js)
3334
- ];
3335
- };
3336
- const defaultAttempts = (original) => {
3337
- const explicit = original === Extension.Ts || original === Extension.Dts;
3338
- return [
3339
- attempt("TypeScript", Extension.Ts, explicit),
3340
- attempt("TypeScript", Extension.Tsx, explicit),
3341
- attempt("Declaration", Extension.Dts, explicit),
3342
- attempt("JavaScript", Extension.Js),
3343
- attempt("JavaScript", Extension.Jsx)
3344
- ];
3345
- };
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]);
3346
3385
  const arbitraryAttempts = (candidate, original) => Option.liftPredicate(`${candidate}${original}`, (path) => !isDeclarationFileName(path)).pipe(Option.match({
3347
3386
  onNone: () => [],
3348
3387
  onSome: () => [attempt("Declaration", `.d${original}.ts`)]
@@ -4183,16 +4222,18 @@ const fromSelfName = (lookup, features, state) => {
4183
4222
  if (features.selfName) return loadModuleFromSelfNameReference(lookup, state);
4184
4223
  return Option.none();
4185
4224
  };
4186
- const resolveNonRelative = (lookup, features, state) => fromPackageImports(lookup, features, state).pipe(Option.orElse(() => fromSelfName(lookup, features, state)), Option.orElse(() => resolveFromNodeModulesWithTrace(lookup, state)), Option.map(Option.map((resolved) => ({
4225
+ const foundAs = (isExternalLibraryImport) => (resolved) => ({
4187
4226
  resolved,
4188
- isExternalLibraryImport: true
4189
- }))));
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
+ };
4190
4233
  const resolveRelative = (lookup, state) => {
4191
4234
  const { resolved, insideNodeModules } = loadRelativeModule(lookup, state);
4192
- return resolved.pipe(Option.map((value) => ({
4193
- resolved: value,
4194
- isExternalLibraryImport: insideNodeModules
4195
- })));
4235
+ const found = foundAs(insideNodeModules);
4236
+ return resolved.pipe(Option.map(found));
4196
4237
  };
4197
4238
  const tryResolve = (extensions, request, state) => {
4198
4239
  const lookup = {
@@ -4309,18 +4350,18 @@ const resolveInDirectory = Function.dual(DATA_FIRST_ARITY$7, (request, context)
4309
4350
  extensions: extensionsFor(request.options),
4310
4351
  conditions: conditionsFor$1(request)
4311
4352
  }, context));
4353
+ const cacheKeyOf = (request) => ({
4354
+ name: request.moduleName,
4355
+ mode: request.mode,
4356
+ directory: getDirectoryPath(request.containingFile)
4357
+ });
4312
4358
  const resolveUncached = (request, context) => {
4313
- const containingDirectory = getDirectoryPath(request.containingFile);
4359
+ const key = cacheKeyOf(request);
4314
4360
  traceMessage(context, Messages.explicitResolutionKind, request.options.moduleResolution);
4315
4361
  const result = resolveInDirectory({
4316
4362
  ...request,
4317
- containingDirectory
4363
+ containingDirectory: key.directory
4318
4364
  }, context);
4319
- const key = {
4320
- name: request.moduleName,
4321
- mode: request.mode,
4322
- directory: containingDirectory
4323
- };
4324
4365
  for (const cache of Option.toArray(context.cache)) {
4325
4366
  cache.setForDirectory(key, result);
4326
4367
  if (!isExternalModuleNameRelative(request.moduleName)) cache.setForNonRelative(key, result);
@@ -4339,13 +4380,9 @@ const traceOutcome = (moduleName, result, trace) => {
4339
4380
  emitTrace(trace, message);
4340
4381
  };
4341
4382
  const reuseCachedWithTrace = (request, context) => {
4342
- const directory = getDirectoryPath(request.containingFile);
4343
- return context.cache.pipe(Option.flatMap((cache) => cache.getFromDirectory({
4344
- name: request.moduleName,
4345
- mode: request.mode,
4346
- directory
4347
- })), Option.map((cached) => {
4348
- 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);
4349
4386
  return cached;
4350
4387
  }));
4351
4388
  };
@@ -4741,7 +4778,7 @@ const createProgram = Function.dual(DATA_FIRST_ARITY$5, (site, rootNames) => {
4741
4778
  },
4742
4779
  resolvedModules: programFiles.resolvedModules,
4743
4780
  dispose: () => {
4744
- for (const created of Option.toArray(MutableRef.get(checker))) created.dispose();
4781
+ for (const created of checker.pipe(MutableRef.get, Option.toArray)) created.dispose();
4745
4782
  }
4746
4783
  };
4747
4784
  });
@@ -5007,8 +5044,7 @@ const impliedFormatOf = (source, fileName) => {
5007
5044
  if (fileExtensionIsOneOf(path, ESM_EXTENSIONS)) return Option.some("ESNext");
5008
5045
  if (fileExtensionIsOneOf(path, CJS_EXTENSIONS)) return Option.some("CommonJS");
5009
5046
  if (!shouldLookupPackageJson(source.kind, path)) return Option.none();
5010
- const scope = cachedScope(source, getDirectoryPath(path));
5011
- return Option.some(formatOfScope(scope));
5047
+ return cachedScope(source, getDirectoryPath(path)).pipe(formatOfScope, Option.some);
5012
5048
  };
5013
5049
  const scopeReason = (info) => {
5014
5050
  if (Predicate.isTruthy(info.contents.packageJsonContent["type"])) return "type";
@@ -5271,7 +5307,7 @@ function getEntrypoints(fs, exportsObject, options) {
5271
5307
  const rootDir = `/node_modules/${fs.packageName}`;
5272
5308
  const proxies = getProxyDirectories(rootDir, fs);
5273
5309
  if (proxies.length === 0) {
5274
- if (options === null || options === void 0 ? void 0 : options.entrypointsLegacy) return fs.listFiles().filter((f) => !ts.isDeclarationFileName(f) && extensions.has(f.slice(f.lastIndexOf(".")))).map((f) => "." + f.slice(rootDir.length));
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));
5275
5311
  return ["."];
5276
5312
  }
5277
5313
  return proxies;
@@ -5318,10 +5354,10 @@ function getProxyDirectories(rootDir, fs) {
5318
5354
  }
5319
5355
  } catch {}
5320
5356
  return proxyDirectories.sort((a, b) => {
5321
- return ts.comparePathsCaseInsensitive(a, b);
5357
+ return _attw_typescript_default.comparePathsCaseInsensitive(a, b);
5322
5358
  });
5323
5359
  function isInsideVendorDirectory(file) {
5324
- return !!ts.forEachAncestorDirectory(file, (dir) => {
5360
+ return !!_attw_typescript_default.forEachAncestorDirectory(file, (dir) => {
5325
5361
  if (vendorDirectories.has(dir)) return true;
5326
5362
  });
5327
5363
  }
@@ -5360,7 +5396,7 @@ function getEntrypointResolution(packageName, host, resolutionKind, entrypoint)
5360
5396
  };
5361
5397
  const moduleSpecifier = packageName + entrypoint.substring(1);
5362
5398
  const importingFileName = resolutionKind === "node16-esm" ? "/index.mts" : "/index.ts";
5363
- const resolutionMode = resolutionKind === "node16-esm" ? ts.ModuleKind.ESNext : resolutionKind === "node16-cjs" ? ts.ModuleKind.CommonJS : void 0;
5399
+ const resolutionMode = resolutionKind === "node16-esm" ? _attw_typescript_default.ModuleKind.ESNext : resolutionKind === "node16-cjs" ? _attw_typescript_default.ModuleKind.CommonJS : void 0;
5364
5400
  const resolution = tryResolve();
5365
5401
  return {
5366
5402
  name: entrypoint,
@@ -5376,8 +5412,8 @@ function getEntrypointResolution(packageName, host, resolutionKind, entrypoint)
5376
5412
  if (!fileName) return;
5377
5413
  return {
5378
5414
  fileName,
5379
- isJson: resolution.resolvedModule.extension === ts.Extension.Json,
5380
- isTypeScript: ts.hasTSFileExtension(resolution.resolvedModule.resolvedFileName),
5415
+ isJson: resolution.resolvedModule.extension === _attw_typescript_default.Extension.Json,
5416
+ isTypeScript: _attw_typescript_default.hasTSFileExtension(resolution.resolvedModule.resolvedFileName),
5381
5417
  trace
5382
5418
  };
5383
5419
  }