@r_masseater/vite-plus-adopt 0.14.0 → 0.15.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 +41 -3
- package/dist/attw.mjs +135 -157
- package/dist/attw.mjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +1 -1
- package/dist/{vpa-jp87uBqF.mjs → vpa-B16TImrg.mjs} +336 -102
- package/dist/vpa-B16TImrg.mjs.map +1 -0
- package/package.json +3 -4
- package/skills/configure-checks/SKILL.md +0 -1
- package/dist/vpa-jp87uBqF.mjs.map +0 -1
package/dist/attw.mjs
CHANGED
|
@@ -33,8 +33,64 @@ const hasFlag = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => sharedFlags(
|
|
|
33
33
|
const withFlags = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => flags + mask - sharedFlags(flags, mask));
|
|
34
34
|
const withoutFlags = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => flags - sharedFlags(flags, mask));
|
|
35
35
|
const combineFlags = (...masks) => Array$1.reduce(masks, 0, withFlags);
|
|
36
|
-
// src/shared/lib/typescript/
|
|
36
|
+
// src/shared/lib/typescript/source-file.ts
|
|
37
37
|
const DATA_FIRST_ARITY$35 = 2;
|
|
38
|
+
const infos = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
const UNSET = Object.freeze({
|
|
40
|
+
writable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
enumerable: true
|
|
43
|
+
});
|
|
44
|
+
const attachFileInfo = Function.dual(DATA_FIRST_ARITY$35, (sourceFile, impliedNodeFormat) => {
|
|
45
|
+
infos.set(sourceFile, {
|
|
46
|
+
impliedNodeFormat,
|
|
47
|
+
packageJsonScope: Option.none(),
|
|
48
|
+
imports: sourceFile.imports,
|
|
49
|
+
moduleAugmentations: sourceFile.moduleAugmentations
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(sourceFile, "imports", UNSET);
|
|
52
|
+
Object.defineProperty(sourceFile, "moduleAugmentations", UNSET);
|
|
53
|
+
return sourceFile;
|
|
54
|
+
});
|
|
55
|
+
const infoOf = (sourceFile) => Option.fromNullishOr(infos.get(sourceFile));
|
|
56
|
+
const impliedNodeFormatOf = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.impliedNodeFormat);
|
|
57
|
+
const packageJsonScopeOf$1 = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.packageJsonScope);
|
|
58
|
+
const setPackageJsonScope = Function.dual(DATA_FIRST_ARITY$35, (sourceFile, scope) => {
|
|
59
|
+
Option.map(infoOf(sourceFile), (info) => infos.set(sourceFile, {
|
|
60
|
+
...info,
|
|
61
|
+
packageJsonScope: scope
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
const collectExternalModuleReferences = (sourceFile) => {
|
|
65
|
+
Option.map(infoOf(sourceFile), (info) => {
|
|
66
|
+
Object.defineProperty(sourceFile, "imports", {
|
|
67
|
+
...UNSET,
|
|
68
|
+
value: info.imports
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(sourceFile, "moduleAugmentations", {
|
|
71
|
+
...UNSET,
|
|
72
|
+
value: info.moduleAugmentations
|
|
73
|
+
});
|
|
74
|
+
return info;
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const importsOf = (sourceFile) => Option.match(infoOf(sourceFile), {
|
|
78
|
+
onNone: () => sourceFile.imports,
|
|
79
|
+
onSome: (info) => info.imports
|
|
80
|
+
});
|
|
81
|
+
const moduleAugmentationsOf = (sourceFile) => Option.match(infoOf(sourceFile), {
|
|
82
|
+
onNone: () => sourceFile.moduleAugmentations,
|
|
83
|
+
onSome: (info) => info.moduleAugmentations
|
|
84
|
+
});
|
|
85
|
+
const isSourceFileJS = (sourceFile) => sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX;
|
|
86
|
+
const isJSDocNode = (node) => hasFlag(node.flags, NodeFlags.JSDoc);
|
|
87
|
+
const sourceFileOf = (node) => {
|
|
88
|
+
let current = node;
|
|
89
|
+
while (!isSourceFile(current)) current = current.parent;
|
|
90
|
+
return current;
|
|
91
|
+
};
|
|
92
|
+
// src/shared/lib/typescript/binder-symbols.ts
|
|
93
|
+
const DATA_FIRST_ARITY$34 = 2;
|
|
38
94
|
const UNDERSCORE = "_";
|
|
39
95
|
const DOUBLE_UNDERSCORE = "__";
|
|
40
96
|
const TRIPLE_UNDERSCORE = "___";
|
|
@@ -47,11 +103,6 @@ const escapeLeadingUnderscores$1 = (name) => {
|
|
|
47
103
|
if (String$1.startsWith(DOUBLE_UNDERSCORE)(name)) return `${UNDERSCORE}${name}`;
|
|
48
104
|
return name;
|
|
49
105
|
};
|
|
50
|
-
const isInJsFileNode = (node) => {
|
|
51
|
-
let current = node;
|
|
52
|
-
while (!isSourceFile(current)) current = current.parent;
|
|
53
|
-
return current.scriptKind === ScriptKind.JS || current.scriptKind === ScriptKind.JSX;
|
|
54
|
-
};
|
|
55
106
|
const isAmbientNode = (node) => hasFlag(node.flags, NodeFlags.Ambient);
|
|
56
107
|
const ASSIGNMENT_DECLARATION_KINDS = /* @__PURE__ */ new Set([
|
|
57
108
|
SyntaxKind.BinaryExpression,
|
|
@@ -62,7 +113,7 @@ const ASSIGNMENT_DECLARATION_KINDS = /* @__PURE__ */ new Set([
|
|
|
62
113
|
]);
|
|
63
114
|
const isAssignmentDeclarationNode = (node) => ASSIGNMENT_DECLARATION_KINDS.has(node.kind);
|
|
64
115
|
const isEffectiveModuleDeclaration = (node) => node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.Identifier;
|
|
65
|
-
const isAmbientOverride = (existing, node) => isAmbientNode(node) && !
|
|
116
|
+
const isAmbientOverride = (existing, node) => isAmbientNode(node) && !isSourceFileJS(sourceFileOf(node)) && !isAmbientNode(existing);
|
|
66
117
|
const replacesAssignmentDeclaration = (existing, node) => !isAmbientOverride(existing, node) && isAssignmentDeclarationNode(existing) && !isAssignmentDeclarationNode(node);
|
|
67
118
|
const replacesModuleDeclaration = (existing, node) => existing.kind !== node.kind && isEffectiveModuleDeclaration(existing);
|
|
68
119
|
const replacesValueDeclaration = (existing, node) => replacesAssignmentDeclaration(existing, node) || replacesModuleDeclaration(existing, node);
|
|
@@ -135,7 +186,7 @@ const symbolInTable = (table, name, declaration) => {
|
|
|
135
186
|
if (conflicts(found, declaration)) return new BoundSymbol(0, name);
|
|
136
187
|
return found;
|
|
137
188
|
};
|
|
138
|
-
const exportOf = Function.dual(DATA_FIRST_ARITY$
|
|
189
|
+
const exportOf = Function.dual(DATA_FIRST_ARITY$34, (owner, name) => Option.flatMap(Option.fromNullishOr(owner.exports), (table) => Option.fromNullishOr(table.get(name))));
|
|
139
190
|
const declareSymbol = (declaration) => {
|
|
140
191
|
const symbol = Option.getOrElse(Option.zipWith(declaration.table, declaration.name, (table, name) => symbolInTable(table, name, declaration)), () => new BoundSymbol(0, MISSING_NAME));
|
|
141
192
|
symbol.addDeclaration(declaration.node, declaration.includes);
|
|
@@ -143,7 +194,7 @@ const declareSymbol = (declaration) => {
|
|
|
143
194
|
return symbol;
|
|
144
195
|
};
|
|
145
196
|
// src/shared/lib/typescript/binder-syntax.ts
|
|
146
|
-
const DATA_FIRST_ARITY$
|
|
197
|
+
const DATA_FIRST_ARITY$33 = 2;
|
|
147
198
|
const REQUIRE_ARGUMENTS = 1;
|
|
148
199
|
const DEFINE_PROPERTY_ARGUMENTS = 3;
|
|
149
200
|
const ZERO_TEXT = "0";
|
|
@@ -170,7 +221,7 @@ const isStaticAccess = (node) => isPropertyAccessExpression(node) || isLiteralLi
|
|
|
170
221
|
const hasStaticName = (node) => !isPropertyAccessExpression(node) || isIdentifier(node.name);
|
|
171
222
|
const isAllowedThis = (node, rules) => !rules.excludeThisKeyword && isThisKeyword(node);
|
|
172
223
|
const hasBindableOwner = (node, rules, isBindable) => isAllowedThis(node.expression, rules) || hasStaticName(node) && isBindable(node.expression, STATIC_NAME);
|
|
173
|
-
const isBindableStatic = Function.dual(DATA_FIRST_ARITY$
|
|
224
|
+
const isBindableStatic = Function.dual(DATA_FIRST_ARITY$33, (node, rules) => isAllowedEntityName(node, rules) || isStaticAccess(node) && hasBindableOwner(node, rules, isBindableStatic));
|
|
174
225
|
const nameText = (node) => {
|
|
175
226
|
if (isIdentifier(node) || isStringOrNumericLiteralLike(node)) return Option.some(node.text);
|
|
176
227
|
return Option.none();
|
|
@@ -179,14 +230,14 @@ const getElementOrPropertyAccessName = (node) => {
|
|
|
179
230
|
if (isPropertyAccessExpression(node)) return nameText(node.name).pipe(Option.map(escapeLeadingUnderscores$1));
|
|
180
231
|
return Option.liftPredicate(skipParentheses(node.argumentExpression), isStringOrNumericLiteralLike).pipe(Option.map((literal) => escapeLeadingUnderscores$1(literal.text)));
|
|
181
232
|
};
|
|
182
|
-
const isNamedIdentifier = Function.dual(DATA_FIRST_ARITY$
|
|
233
|
+
const isNamedIdentifier = Function.dual(DATA_FIRST_ARITY$33, (node, name) => isIdentifier(node) && node.text === name);
|
|
183
234
|
const isExportsIdentifier = (node) => isIdentifier(node) && node.text === "exports";
|
|
184
235
|
const isModuleExportsAccessExpression = (node) => (isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) && isNamedIdentifier(node.expression, "module") && Option.contains(getElementOrPropertyAccessName(node), "exports");
|
|
185
236
|
const hasRequireArgument = (node, requireStringLiteral) => {
|
|
186
237
|
const [argument] = node.arguments;
|
|
187
238
|
return node.arguments.length === REQUIRE_ARGUMENTS && (!requireStringLiteral || Option.fromNullishOr(argument).pipe(Option.exists((value) => isStringLiteralLikeNode(value))));
|
|
188
239
|
};
|
|
189
|
-
const isRequireCall$1 = Function.dual(DATA_FIRST_ARITY$
|
|
240
|
+
const isRequireCall$1 = Function.dual(DATA_FIRST_ARITY$33, (node, requireStringLiteral) => isCallExpression(node) && isNamedIdentifier(node.expression, "require") && hasRequireArgument(node, requireStringLiteral));
|
|
190
241
|
const isAssignmentExpression = (node) => isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken;
|
|
191
242
|
const getRightMostAssignedExpression = (node) => {
|
|
192
243
|
let current = node;
|
|
@@ -207,7 +258,7 @@ const isBindableObjectDefinePropertyCall = (node) => {
|
|
|
207
258
|
};
|
|
208
259
|
const isAliasableExpression = (node) => isEntityNameExpression(node) || node.kind === SyntaxKind.ClassExpression;
|
|
209
260
|
// src/shared/lib/typescript/binder-assignment.ts
|
|
210
|
-
const DATA_FIRST_ARITY$
|
|
261
|
+
const DATA_FIRST_ARITY$32 = 2;
|
|
211
262
|
const AssignmentKind = {
|
|
212
263
|
None: "None",
|
|
213
264
|
ExportsProperty: "ExportsProperty",
|
|
@@ -244,18 +295,6 @@ const isExportsTarget = (nextToLast) => isNamedIdentifier(nextToLast.expression,
|
|
|
244
295
|
const firstMatchingKind = (rules, subject) => Array$1.findFirst(rules, ([matches]) => matches(subject)).pipe(Option.map(([, kind]) => kind), Option.getOrElse(() => AssignmentKind.None));
|
|
245
296
|
const isExportsProperty = (left) => isExportsTarget(leftmostAccess(left)) && isBindableStatic(left, STATIC_ACCESS);
|
|
246
297
|
const isNamedProperty = (left) => isBindableStatic(left, STATIC_NAME) || isDynamicElementAccess(left);
|
|
247
|
-
const STATIC_NAME_KINDS = [
|
|
248
|
-
[(left) => isPrototypeAccess(left.expression), AssignmentKind.PrototypeProperty],
|
|
249
|
-
[isExportsProperty, AssignmentKind.ExportsProperty],
|
|
250
|
-
[isNamedProperty, AssignmentKind.Property]
|
|
251
|
-
];
|
|
252
|
-
const staticNamePropertyKind = (left) => firstMatchingKind(STATIC_NAME_KINDS, left);
|
|
253
|
-
const propertyAccessKind = (left) => {
|
|
254
|
-
if (isThisKeyword(left.expression)) return AssignmentKind.ThisProperty;
|
|
255
|
-
if (isModuleExportsAccessExpression(left)) return AssignmentKind.ModuleExports;
|
|
256
|
-
if (isBindableStatic(left.expression, STATIC_NAME)) return staticNamePropertyKind(left);
|
|
257
|
-
return AssignmentKind.None;
|
|
258
|
-
};
|
|
259
298
|
const initializerOfBinary = (node) => {
|
|
260
299
|
let current = node;
|
|
261
300
|
while (isBinaryExpression(current.right)) current = current.right;
|
|
@@ -264,12 +303,20 @@ const initializerOfBinary = (node) => {
|
|
|
264
303
|
const isPrototypeObjectAssignment = (node, left) => isBindableStatic(left.expression, STATIC_NAME) && Option.contains(getElementOrPropertyAccessName(left), PROTOTYPE) && isObjectLiteralExpression(initializerOfBinary(node));
|
|
265
304
|
const isPlainAssignment = (node) => node.operatorToken.kind === SyntaxKind.EqualsToken && !isVoidZero(getRightMostAssignedExpression(node));
|
|
266
305
|
const assignedAccess = (node) => Option.liftPredicate(node.left, isAccessExpression).pipe(Option.filter(() => isPlainAssignment(node)));
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
306
|
+
const onStaticName = (matches) => ({ left }) => isBindableStatic(left.expression, STATIC_NAME) && matches(left);
|
|
307
|
+
const ACCESS_ASSIGNMENT_KINDS = [
|
|
308
|
+
[({ node, left }) => isPrototypeObjectAssignment(node, left), AssignmentKind.Prototype],
|
|
309
|
+
[({ left }) => isThisKeyword(left.expression), AssignmentKind.ThisProperty],
|
|
310
|
+
[({ left }) => isModuleExportsAccessExpression(left), AssignmentKind.ModuleExports],
|
|
311
|
+
[onStaticName((left) => isPrototypeAccess(left.expression)), AssignmentKind.PrototypeProperty],
|
|
312
|
+
[onStaticName(isExportsProperty), AssignmentKind.ExportsProperty],
|
|
313
|
+
[onStaticName(isNamedProperty), AssignmentKind.Property]
|
|
314
|
+
];
|
|
315
|
+
const binaryAssignmentKind = (node) => assignedAccess(node).pipe(Option.map((left) => firstMatchingKind(ACCESS_ASSIGNMENT_KINDS, {
|
|
316
|
+
node,
|
|
317
|
+
left
|
|
318
|
+
})), Option.getOrElse(() => AssignmentKind.None));
|
|
319
|
+
const getAssignmentDeclarationKind = Function.dual(DATA_FIRST_ARITY$32, (node, inJsFile) => {
|
|
273
320
|
const kind = Option.match(Option.liftPredicate(node, isCallExpression), {
|
|
274
321
|
onNone: () => Option.match(Option.liftPredicate(node, isBinaryExpression), {
|
|
275
322
|
onNone: () => AssignmentKind.None,
|
|
@@ -281,7 +328,7 @@ const getAssignmentDeclarationKind = Function.dual(DATA_FIRST_ARITY$33, (node, i
|
|
|
281
328
|
return AssignmentKind.None;
|
|
282
329
|
});
|
|
283
330
|
// src/shared/lib/typescript/binder-names.ts
|
|
284
|
-
const DATA_FIRST_ARITY$
|
|
331
|
+
const DATA_FIRST_ARITY$31 = 2;
|
|
285
332
|
const isNodeValue = (value) => Predicate.hasProperty(value, "kind") && Predicate.isNumber(value.kind);
|
|
286
333
|
const declaredName = (node) => {
|
|
287
334
|
if ("name" in node && isNodeValue(node.name)) return Option.some(node.name);
|
|
@@ -291,7 +338,7 @@ const syntacticModifierFlags = (node) => {
|
|
|
291
338
|
if ("modifierFlags" in node && Predicate.isNumber(node.modifierFlags)) return node.modifierFlags;
|
|
292
339
|
return 0;
|
|
293
340
|
};
|
|
294
|
-
const hasSyntacticModifier = Function.dual(DATA_FIRST_ARITY$
|
|
341
|
+
const hasSyntacticModifier = Function.dual(DATA_FIRST_ARITY$31, (node, flag) => hasFlag(syntacticModifierFlags(node), flag));
|
|
295
342
|
const declarationOfBinding$1 = (node) => {
|
|
296
343
|
let current = node;
|
|
297
344
|
while (isBindingElement(current)) current = current.parent.parent;
|
|
@@ -347,7 +394,7 @@ const unnamedDeclarationName = (node) => {
|
|
|
347
394
|
if (node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.BinaryExpression) return Option.some("export=");
|
|
348
395
|
return Option.none();
|
|
349
396
|
};
|
|
350
|
-
const declarationName = Function.dual(DATA_FIRST_ARITY$
|
|
397
|
+
const declarationName = Function.dual(DATA_FIRST_ARITY$31, (node, inJsFile) => {
|
|
351
398
|
if (isExportAssignment(node)) return Option.some(Option.match(Option.liftPredicate(node, () => node.isExportEquals), {
|
|
352
399
|
onNone: () => "default",
|
|
353
400
|
onSome: () => "export="
|
|
@@ -358,7 +405,7 @@ const declarationName = Function.dual(DATA_FIRST_ARITY$32, (node, inJsFile) => {
|
|
|
358
405
|
});
|
|
359
406
|
});
|
|
360
407
|
// src/shared/lib/typescript/messages.ts
|
|
361
|
-
const DATA_FIRST_ARITY$
|
|
408
|
+
const DATA_FIRST_ARITY$30 = 2;
|
|
362
409
|
const Messages = {
|
|
363
410
|
directoryDoesNotExist: "Directory '{0}' does not exist, skipping all lookups in it.",
|
|
364
411
|
directoryHasNoPackageScope: "Directory '{0}' has no containing package.json scope. Imports will not resolve.",
|
|
@@ -422,7 +469,7 @@ const filled = (args) => (part, position) => {
|
|
|
422
469
|
return args[Number(part)] ?? `{${part}}`;
|
|
423
470
|
};
|
|
424
471
|
const formatMessage = (message, ...args) => pipe(String$1.split(message, PLACEHOLDER), Array$1.map(filled(args)), Array$1.join(""));
|
|
425
|
-
const emitTrace = Function.dual(DATA_FIRST_ARITY$
|
|
472
|
+
const emitTrace = Function.dual(DATA_FIRST_ARITY$30, (trace, message) => {
|
|
426
473
|
for (const sink of Option.toArray(trace)) sink(message);
|
|
427
474
|
});
|
|
428
475
|
const traceMessage = (state, message, ...args) => {
|
|
@@ -477,18 +524,14 @@ const fileUrlVolumeSeparatorEnd = (url, start) => {
|
|
|
477
524
|
if (url[start] === ":") return Option.some(start + NEXT$2);
|
|
478
525
|
return Option.liftPredicate(start + ENCODED_SEPARATOR_LENGTH, () => ENCODED_VOLUME_SEPARATOR.test(String$1.slice(start)(url)));
|
|
479
526
|
};
|
|
480
|
-
const
|
|
527
|
+
const isLocalFileUrl = (url, schemeEnd, authorityEnd) => String$1.slice(FIRST$2, schemeEnd)(url) === FILE_SCHEME && LOCAL_AUTHORITIES.has(String$1.slice(schemeEnd + 3, authorityEnd)(url)) && isVolumeCharacter(url[authorityEnd + NEXT$2]);
|
|
528
|
+
const fileUrlVolumeRoot = (url, schemeEnd, authorityEnd) => Option.liftPredicate(url, () => isLocalFileUrl(url, schemeEnd, authorityEnd)).pipe(Option.flatMap(() => fileUrlVolumeSeparatorEnd(url, authorityEnd + AFTER_NEXT)), Option.flatMap((end) => {
|
|
481
529
|
if (url[end] === SLASH) return Option.some(urlRoot(end + NEXT$2));
|
|
482
530
|
return Option.liftPredicate(urlRoot(end), () => end === url.length);
|
|
483
531
|
}));
|
|
484
|
-
const isLocalFileUrl = (url, schemeEnd, authorityEnd) => String$1.slice(FIRST$2, schemeEnd)(url) === FILE_SCHEME && LOCAL_AUTHORITIES.has(String$1.slice(schemeEnd + 3, authorityEnd)(url)) && isVolumeCharacter(url[authorityEnd + NEXT$2]);
|
|
485
|
-
const urlRootAt = (url, schemeEnd, authorityEnd) => {
|
|
486
|
-
const volume = Option.liftPredicate(url, () => isLocalFileUrl(url, schemeEnd, authorityEnd)).pipe(Option.flatMap(() => fileUrlVolumeRoot(url, authorityEnd)));
|
|
487
|
-
return Option.getOrElse(volume, () => urlRoot(authorityEnd + NEXT$2));
|
|
488
|
-
};
|
|
489
532
|
const urlRootOf = (url, schemeEnd) => Option.match(indexFrom(url, SLASH, schemeEnd + 3), {
|
|
490
533
|
onNone: () => urlRoot(url.length),
|
|
491
|
-
onSome: (authorityEnd) =>
|
|
534
|
+
onSome: (authorityEnd) => Option.getOrElse(fileUrlVolumeRoot(url, schemeEnd, authorityEnd), () => urlRoot(authorityEnd + NEXT$2))
|
|
492
535
|
});
|
|
493
536
|
const getPathRoot = (path) => {
|
|
494
537
|
const [first] = path;
|
|
@@ -504,7 +547,7 @@ const isRootedDiskPath = (path) => {
|
|
|
504
547
|
return root.length > FIRST$2 && !root.isUrl;
|
|
505
548
|
};
|
|
506
549
|
// src/shared/lib/typescript/paths.ts
|
|
507
|
-
const DATA_FIRST_ARITY$
|
|
550
|
+
const DATA_FIRST_ARITY$29 = 2;
|
|
508
551
|
const SEPARATOR$1 = "/";
|
|
509
552
|
const ROOT_LENGTH$1 = 1;
|
|
510
553
|
const NOT_FOUND$1 = -1;
|
|
@@ -607,7 +650,7 @@ const getBaseFileName = (path) => {
|
|
|
607
650
|
});
|
|
608
651
|
return String$1.slice(start)(trimmed);
|
|
609
652
|
};
|
|
610
|
-
const getNormalizedAbsolutePath = Function.dual(DATA_FIRST_ARITY$
|
|
653
|
+
const getNormalizedAbsolutePath = Function.dual(DATA_FIRST_ARITY$29, (path, currentDirectory) => {
|
|
611
654
|
const components = getPathComponents(combinePaths(currentDirectory, path));
|
|
612
655
|
return getPathFromPathComponents(reducePathComponents(components));
|
|
613
656
|
});
|
|
@@ -615,7 +658,7 @@ const toPath = (fileName) => Option.liftPredicate(fileName, isRootedDiskPath).pi
|
|
|
615
658
|
onNone: () => getNormalizedAbsolutePath(fileName, SEPARATOR$1),
|
|
616
659
|
onSome: normalizePath
|
|
617
660
|
}), String$1.toLowerCase);
|
|
618
|
-
const forEachAncestorDirectory$1 = Function.dual(DATA_FIRST_ARITY$
|
|
661
|
+
const forEachAncestorDirectory$1 = Function.dual(DATA_FIRST_ARITY$29, (directory, visit) => {
|
|
619
662
|
let current = directory;
|
|
620
663
|
for (;;) {
|
|
621
664
|
const result = visit(current);
|
|
@@ -632,7 +675,7 @@ const sharedPrefixLength = (from, to) => {
|
|
|
632
675
|
while (index < limit && from[index] === to[index]) index += ROOT_LENGTH$1;
|
|
633
676
|
return index;
|
|
634
677
|
};
|
|
635
|
-
const getRelativePathFromDirectory = Function.dual(DATA_FIRST_ARITY$
|
|
678
|
+
const getRelativePathFromDirectory = Function.dual(DATA_FIRST_ARITY$29, (fromDirectory, to) => {
|
|
636
679
|
const from = reducePathComponents(getPathComponents(fromDirectory));
|
|
637
680
|
const target = reducePathComponents(getPathComponents(to));
|
|
638
681
|
const start = sharedPrefixLength(from, target);
|
|
@@ -643,7 +686,7 @@ const getRelativePathFromDirectory = Function.dual(DATA_FIRST_ARITY$30, (fromDir
|
|
|
643
686
|
...target.slice(start)
|
|
644
687
|
]);
|
|
645
688
|
});
|
|
646
|
-
const containsPath = Function.dual(DATA_FIRST_ARITY$
|
|
689
|
+
const containsPath = Function.dual(DATA_FIRST_ARITY$29, (parent, child) => {
|
|
647
690
|
const parentComponents = reducePathComponents(getPathComponents(parent));
|
|
648
691
|
const childComponents = reducePathComponents(getPathComponents(child));
|
|
649
692
|
return parent === child || childComponents.length >= parentComponents.length && sharedPrefixLength(parentComponents, childComponents) === parentComponents.length;
|
|
@@ -693,7 +736,7 @@ const readPackageJsonMainField = Function.dual(DATA_FIRST_ARITY_3$20, (content,
|
|
|
693
736
|
}, state));
|
|
694
737
|
const asRecord = (value) => Option.liftPredicate(value, Predicate.isObject).pipe(Option.getOrElse(() => ({})));
|
|
695
738
|
// src/shared/lib/typescript/types-versions.ts
|
|
696
|
-
const DATA_FIRST_ARITY$
|
|
739
|
+
const DATA_FIRST_ARITY$28 = 2;
|
|
697
740
|
const RESOLUTION_VERSION = "5.6.1-rc";
|
|
698
741
|
const RESOLUTION_VERSION_MAJOR_MINOR = "5.6";
|
|
699
742
|
const RANGE_OPTIONS$1 = { includePrerelease: true };
|
|
@@ -727,9 +770,9 @@ const resolveTypesVersionPathsWithTrace = (content, state) => resolvePackageJson
|
|
|
727
770
|
field: "typesVersions",
|
|
728
771
|
expected: "object"
|
|
729
772
|
}, state).pipe(Option.flatMap((typesVersions) => selectVersionPathsWithTrace(asRecord(typesVersions), state)));
|
|
730
|
-
const getVersionPaths = Function.dual(DATA_FIRST_ARITY$
|
|
773
|
+
const getVersionPaths = Function.dual(DATA_FIRST_ARITY$28, (info, state) => info.contents.versionPaths(() => resolveTypesVersionPathsWithTrace(info.contents.packageJsonContent, state)));
|
|
731
774
|
// src/shared/lib/typescript/binder-declarations.ts
|
|
732
|
-
const DATA_FIRST_ARITY$
|
|
775
|
+
const DATA_FIRST_ARITY$27 = 2;
|
|
733
776
|
const DATA_FIRST_ARITY_3$19 = 3;
|
|
734
777
|
var FileBinding = class {
|
|
735
778
|
file;
|
|
@@ -772,7 +815,7 @@ const fileLocals = (binding) => ({
|
|
|
772
815
|
});
|
|
773
816
|
const isExportSpecifierNamedDefault = (node) => isExportSpecifier(node) && Option.contains(nameText(node.name), DEFAULT_NAME);
|
|
774
817
|
const isDefaultExport = (request) => Option.isSome(request.target.parent) && (hasSyntacticModifier(request.node, ModifierFlags.Default) || isExportSpecifierNamedDefault(request.node));
|
|
775
|
-
const declare = Function.dual(DATA_FIRST_ARITY$
|
|
818
|
+
const declare = Function.dual(DATA_FIRST_ARITY$27, (binding, request) => {
|
|
776
819
|
const name = Option.orElse(Option.liftPredicate(DEFAULT_NAME, () => isDefaultExport(request)), () => declarationName(request.node, binding.isJs));
|
|
777
820
|
return declareSymbol({
|
|
778
821
|
table: request.target.table,
|
|
@@ -795,8 +838,8 @@ const declareExport = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node, flags
|
|
|
795
838
|
}));
|
|
796
839
|
const isJSDocTypeAliasWithName = (node) => (isJSDocTypedefTag(node) || isJSDocCallbackTag(node)) && Predicate.isNotUndefined(node.name);
|
|
797
840
|
const isExportedMember = (node) => hasExportModifier(node) || isJSDocTypeAliasWithName(node);
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
841
|
+
const declareWhen = (binding, node, flags) => (exported, declareExported) => {
|
|
842
|
+
if (exported) return declareExported(binding, node, flags);
|
|
800
843
|
return declareLocal(binding, node, flags);
|
|
801
844
|
};
|
|
802
845
|
const localExportFlags = (flags) => ({
|
|
@@ -810,10 +853,10 @@ const declareExportedMember = (binding, node, flags) => {
|
|
|
810
853
|
return local;
|
|
811
854
|
};
|
|
812
855
|
const isExportedDeclaration = (binding, node) => !isAmbientModule(node) && (isExportedMember(node) || binding.exportContext);
|
|
856
|
+
const isExportedAlias = (node) => isExportSpecifier(node) || isImportEqualsDeclaration(node) && isExportedMember(node);
|
|
813
857
|
const declareModuleMember = (binding, node, flags) => {
|
|
814
|
-
if (hasFlag(flags.includes, SymbolFlags.Alias)) return
|
|
815
|
-
|
|
816
|
-
return declareLocal(binding, node, flags);
|
|
858
|
+
if (hasFlag(flags.includes, SymbolFlags.Alias)) return declareWhen(binding, node, flags)(isExportedAlias(node), declareExport);
|
|
859
|
+
return declareWhen(binding, node, flags)(isExportedDeclaration(binding, node), declareExportedMember);
|
|
817
860
|
};
|
|
818
861
|
const declareSourceFileMember = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node, flags) => {
|
|
819
862
|
if (binding.isExternalModule) return declareModuleMember(binding, node, flags);
|
|
@@ -834,7 +877,7 @@ const inBlock = (flags) => (binding, node, scope) => {
|
|
|
834
877
|
if (scope.blockIsFile) declareBlockScoped(binding, node, flags);
|
|
835
878
|
};
|
|
836
879
|
// src/shared/lib/typescript/binder-cjs.ts
|
|
837
|
-
const DATA_FIRST_ARITY$
|
|
880
|
+
const DATA_FIRST_ARITY$26 = 2;
|
|
838
881
|
const DATA_FIRST_ARITY_3$18 = 3;
|
|
839
882
|
const MAX_ALIAS_STEPS = 100;
|
|
840
883
|
const ALIAS_STEP = 1;
|
|
@@ -853,11 +896,11 @@ const createFileSymbol = (binding) => {
|
|
|
853
896
|
symbol.addDeclaration(binding.file, SymbolFlags.ValueModule);
|
|
854
897
|
binding.attach(symbol);
|
|
855
898
|
};
|
|
856
|
-
const lookupSymbolForName = Function.dual(DATA_FIRST_ARITY$
|
|
899
|
+
const lookupSymbolForName = Function.dual(DATA_FIRST_ARITY$26, (binding, name) => {
|
|
857
900
|
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)))));
|
|
858
901
|
});
|
|
859
|
-
const lookupIdentifier = Function.dual(DATA_FIRST_ARITY$
|
|
860
|
-
const variableInitializer = Function.dual(DATA_FIRST_ARITY$
|
|
902
|
+
const lookupIdentifier = Function.dual(DATA_FIRST_ARITY$26, (binding, node) => Option.flatMap(Option.liftPredicate(node, isIdentifier), (identifier) => lookupSymbolForName(binding, escapeLeadingUnderscores$1(identifier.text))));
|
|
903
|
+
const variableInitializer = Function.dual(DATA_FIRST_ARITY$26, (binding, node) => lookupIdentifier(binding, node).pipe(Option.flatMap((symbol) => Option.fromNullishOr(symbol.valueDeclaration)), Option.filter(isVariableDeclaration), Option.flatMap((declaration) => Option.fromNullishOr(declaration.initializer))));
|
|
861
904
|
const aliasSources = (binding, node) => variableInitializer(binding, node).pipe(Option.map((initializer) => Option.match(Option.liftPredicate(initializer, isAssignmentExpression), {
|
|
862
905
|
onNone: () => [initializer],
|
|
863
906
|
onSome: (assignment) => [
|
|
@@ -872,8 +915,8 @@ const searchExportsAlias = (binding, queue, steps) => {
|
|
|
872
915
|
if (Predicate.isUndefined(next) || steps >= MAX_ALIAS_STEPS) return false;
|
|
873
916
|
return isExportsReference(next) || searchExportsAlias(binding, [...rest, ...aliasSources(binding, next)], steps + ALIAS_STEP);
|
|
874
917
|
};
|
|
875
|
-
const isExportsOrModuleExportsOrAlias = Function.dual(DATA_FIRST_ARITY$
|
|
876
|
-
const setCommonJsModuleIndicator = Function.dual(DATA_FIRST_ARITY$
|
|
918
|
+
const isExportsOrModuleExportsOrAlias = Function.dual(DATA_FIRST_ARITY$26, (binding, node) => searchExportsAlias(binding, [node], 0));
|
|
919
|
+
const setCommonJsModuleIndicator = Function.dual(DATA_FIRST_ARITY$26, (binding, node) => {
|
|
877
920
|
if (binding.isExternalModule) return false;
|
|
878
921
|
if (Predicate.isUndefined(binding.commonJsModuleIndicator)) {
|
|
879
922
|
binding.markCommonJs(node);
|
|
@@ -886,8 +929,8 @@ const accessNameOrArgument = (node) => {
|
|
|
886
929
|
return node.argumentExpression;
|
|
887
930
|
};
|
|
888
931
|
const lookupInFileContainer = (binding, walk) => Option.liftPredicate(binding, () => walk.containerIsFile).pipe(Option.flatMap((bound) => lookupIdentifier(bound, walk.node)));
|
|
889
|
-
const memberOfAccess = (
|
|
890
|
-
const forEachIdentifierInEntityName = Function.dual(DATA_FIRST_ARITY$
|
|
932
|
+
const memberOfAccess = (parent) => (node) => getElementOrPropertyAccessName(node).pipe(Option.flatMap((key) => parent.pipe(Option.flatMap((symbol) => exportOf(symbol, key)))));
|
|
933
|
+
const forEachIdentifierInEntityName = Function.dual(DATA_FIRST_ARITY$26, (binding, walk) => {
|
|
891
934
|
const { node } = walk;
|
|
892
935
|
if (isExportsOrModuleExportsOrAlias(binding, node)) return Option.fromNullishOr(binding.symbol);
|
|
893
936
|
if (isIdentifier(node)) return walk.action(node, lookupInFileContainer(binding, walk), Option.none());
|
|
@@ -896,7 +939,7 @@ const forEachIdentifierInEntityName = Function.dual(DATA_FIRST_ARITY$27, (bindin
|
|
|
896
939
|
...walk,
|
|
897
940
|
node: node.expression
|
|
898
941
|
});
|
|
899
|
-
return walk.action(accessNameOrArgument(node), memberOfAccess(
|
|
942
|
+
return walk.action(accessNameOrArgument(node), memberOfAccess(parent)(node), parent);
|
|
900
943
|
});
|
|
901
944
|
const markModuleAssignment = (name, symbol) => symbol.pipe(Option.map((found) => {
|
|
902
945
|
found.addDeclaration(name, MODULE_ASSIGNMENT);
|
|
@@ -1004,7 +1047,7 @@ const hasAncestor = (node, predicate) => {
|
|
|
1004
1047
|
const containerIsFile = (node) => !hasAncestor(node, isContainer);
|
|
1005
1048
|
const blockScopeIsFile = (node) => !hasAncestor(node, isBlockScopeContainer);
|
|
1006
1049
|
// src/shared/lib/typescript/binder-jsdoc.ts
|
|
1007
|
-
const DATA_FIRST_ARITY$
|
|
1050
|
+
const DATA_FIRST_ARITY$25 = 2;
|
|
1008
1051
|
const TYPE_ALIAS = {
|
|
1009
1052
|
includes: SymbolFlags.TypeAlias,
|
|
1010
1053
|
excludes: SymbolFlags.TypeAliasExcludes
|
|
@@ -1017,7 +1060,7 @@ const typeAliasTagSites = (hosts) => Array$1.dedupeWith(pipe(hosts, Array$1.flat
|
|
|
1017
1060
|
host
|
|
1018
1061
|
}))))), (left, right) => left.tag.pos === right.tag.pos);
|
|
1019
1062
|
const declaresFileTypeAlias = (site) => Predicate.isNotUndefined(site.tag.name) && isIdentifier(site.tag.name) && containerIsFile(site.host) && blockScopeIsFile(site.host);
|
|
1020
|
-
const bindJSDocTypeAliases = Function.dual(DATA_FIRST_ARITY$
|
|
1063
|
+
const bindJSDocTypeAliases = Function.dual(DATA_FIRST_ARITY$25, (binding, hosts) => {
|
|
1021
1064
|
for (const site of typeAliasTagSites(hosts)) if (declaresFileTypeAlias(site)) declareBlockScoped(binding, site.tag, TYPE_ALIAS);
|
|
1022
1065
|
});
|
|
1023
1066
|
// src/shared/lib/typescript/binder-expando-symbol.ts
|
|
@@ -1078,8 +1121,7 @@ const ACCESSOR_FLAGS = [["set", {
|
|
|
1078
1121
|
const lookupSymbolForPropertyAccess = (binding, node) => {
|
|
1079
1122
|
if (isIdentifier(node)) return lookupIdentifier(binding, node);
|
|
1080
1123
|
if (!isAccessExpression(node)) return Option.none();
|
|
1081
|
-
|
|
1082
|
-
return getElementOrPropertyAccessName(node).pipe(Option.flatMap((name) => parent.pipe(Option.flatMap((owner) => exportOf(owner, name)))));
|
|
1124
|
+
return memberOfAccess(lookupSymbolForPropertyAccess(binding, node.expression))(node);
|
|
1083
1125
|
};
|
|
1084
1126
|
const isAliasSymbol = (symbol) => Option.exists(symbol, (found) => hasFlag(found.flags, SymbolFlags.Alias));
|
|
1085
1127
|
const addNamespaceDeclaration = (binding) => (name, symbol, parent) => {
|
|
@@ -1218,7 +1260,7 @@ const bindModuleExportsAccess = Function.dual(DATA_FIRST_ARITY_3$16, (binding, n
|
|
|
1218
1260
|
});
|
|
1219
1261
|
});
|
|
1220
1262
|
// src/shared/lib/typescript/binder-this.ts
|
|
1221
|
-
const DATA_FIRST_ARITY$
|
|
1263
|
+
const DATA_FIRST_ARITY$24 = 2;
|
|
1222
1264
|
const THIS_CONTAINER_KINDS = /* @__PURE__ */ new Set([
|
|
1223
1265
|
SyntaxKind.FunctionDeclaration,
|
|
1224
1266
|
SyntaxKind.FunctionExpression,
|
|
@@ -1250,7 +1292,7 @@ const thisContainerIsFile = (node) => {
|
|
|
1250
1292
|
while (!THIS_CONTAINER_KINDS.has(current.kind)) current = current.parent;
|
|
1251
1293
|
return isSourceFile(current);
|
|
1252
1294
|
};
|
|
1253
|
-
const bindThisPropertyAssignment = Function.dual(DATA_FIRST_ARITY$
|
|
1295
|
+
const bindThisPropertyAssignment = Function.dual(DATA_FIRST_ARITY$24, (binding, node) => {
|
|
1254
1296
|
if (!thisContainerIsFile(node) || isDynamicElementAccess(node.left)) return;
|
|
1255
1297
|
if (Predicate.isNotUndefined(binding.commonJsModuleIndicator)) {
|
|
1256
1298
|
declareExport(binding, node, THIS_PROPERTY_EXPORT);
|
|
@@ -1258,7 +1300,7 @@ const bindThisPropertyAssignment = Function.dual(DATA_FIRST_ARITY$25, (binding,
|
|
|
1258
1300
|
}
|
|
1259
1301
|
declareSourceFileMember(binding, node, THIS_PROPERTY_LOCAL);
|
|
1260
1302
|
});
|
|
1261
|
-
const isThisInitialized = Function.dual(DATA_FIRST_ARITY$
|
|
1303
|
+
const isThisInitialized = Function.dual(DATA_FIRST_ARITY$24, (binding, node) => isAccessExpression(node.left) && variableInitializer(binding, node.left.expression).pipe(Option.exists(isThisKeyword)));
|
|
1262
1304
|
// src/shared/lib/typescript/binder-expressions.ts
|
|
1263
1305
|
const EXPRESSION_ARITY = 3;
|
|
1264
1306
|
const isThisAliasAssignment = (binding, node, scope) => binding.isJs && scope.blockIsFile && isThisInitialized(binding, node);
|
|
@@ -1552,14 +1594,9 @@ const createBinding = (file) => {
|
|
|
1552
1594
|
});
|
|
1553
1595
|
};
|
|
1554
1596
|
const declareFileSymbol = (binding) => {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
}
|
|
1559
|
-
if (binding.file.scriptKind === ScriptKind.JSON) {
|
|
1560
|
-
createFileSymbol(binding);
|
|
1561
|
-
declareExport(binding, binding.file, JSON_EXPORT);
|
|
1562
|
-
}
|
|
1597
|
+
const json = !binding.isExternalModule && binding.file.scriptKind === ScriptKind.JSON;
|
|
1598
|
+
if (binding.isExternalModule || json) createFileSymbol(binding);
|
|
1599
|
+
if (json) declareExport(binding, binding.file, JSON_EXPORT);
|
|
1563
1600
|
};
|
|
1564
1601
|
const writableValue = (value) => ({
|
|
1565
1602
|
value,
|
|
@@ -1585,7 +1622,7 @@ const bindSourceFile = (file) => {
|
|
|
1585
1622
|
exposeOnSourceFile(binding);
|
|
1586
1623
|
};
|
|
1587
1624
|
// src/shared/lib/typescript/extensions.ts
|
|
1588
|
-
const DATA_FIRST_ARITY$
|
|
1625
|
+
const DATA_FIRST_ARITY$23 = 2;
|
|
1589
1626
|
const Extension = {
|
|
1590
1627
|
Ts: ".ts",
|
|
1591
1628
|
Tsx: ".tsx",
|
|
@@ -1615,8 +1652,8 @@ const EXTENSION_KIND_NAMES = {
|
|
|
1615
1652
|
};
|
|
1616
1653
|
const extensionsOf = (...kinds) => pipe(EXTENSION_KIND_ORDER, Array$1.filter((kind) => kinds.includes(kind)));
|
|
1617
1654
|
const PRIORITY_KINDS = extensionsOf("TypeScript", "Declaration");
|
|
1618
|
-
const intersectExtensions = Function.dual(DATA_FIRST_ARITY$
|
|
1619
|
-
const subtractExtensions = Function.dual(DATA_FIRST_ARITY$
|
|
1655
|
+
const intersectExtensions = Function.dual(DATA_FIRST_ARITY$23, (left, right) => pipe(left, Array$1.filter((kind) => right.includes(kind))));
|
|
1656
|
+
const subtractExtensions = Function.dual(DATA_FIRST_ARITY$23, (left, right) => pipe(left, Array$1.filter((kind) => !right.includes(kind))));
|
|
1620
1657
|
const formatExtensions = (extensions) => pipe(extensions, Array$1.map((kind) => EXTENSION_KIND_NAMES[kind]), Array$1.join(", "));
|
|
1621
1658
|
const SUPPORTED_TS = [
|
|
1622
1659
|
Extension.Ts,
|
|
@@ -1669,7 +1706,7 @@ const REMOVABLE = [
|
|
|
1669
1706
|
];
|
|
1670
1707
|
const ZERO = 0;
|
|
1671
1708
|
const fileExtensionIs = (path, extension) => path.length > extension.length && String$1.endsWith(extension)(path);
|
|
1672
|
-
const fileExtensionIsOneOf = Function.dual(DATA_FIRST_ARITY$
|
|
1709
|
+
const fileExtensionIsOneOf = Function.dual(DATA_FIRST_ARITY$23, (path, extensions) => pipe(extensions, Array$1.some((extension) => fileExtensionIs(path, extension))));
|
|
1673
1710
|
const findExtension = (path, extensions) => Array$1.findFirst(extensions, (extension) => fileExtensionIs(path, extension));
|
|
1674
1711
|
const hasTSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_TS);
|
|
1675
1712
|
const hasJSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_JS);
|
|
@@ -1689,7 +1726,7 @@ const removeFileExtension = (path) => findExtension(path, REMOVABLE).pipe(Option
|
|
|
1689
1726
|
}));
|
|
1690
1727
|
const tryGetExtensionFromPath = (path) => findExtension(path, REMOVABLE);
|
|
1691
1728
|
const tryExtractTSExtension = (fileName) => findExtension(fileName, EXTRACTABLE_TS);
|
|
1692
|
-
const isTSFileExtensionForPackageField = Function.dual(DATA_FIRST_ARITY$
|
|
1729
|
+
const isTSFileExtensionForPackageField = Function.dual(DATA_FIRST_ARITY$23, (extensions, candidate) => extensions.includes("TypeScript") && fileExtensionIsOneOf(candidate, SUPPORTED_TS_IMPLEMENTATION) || extensions.includes("Declaration") && fileExtensionIsOneOf(candidate, SUPPORTED_DECLARATION));
|
|
1693
1730
|
const EXTENSIONS_FOR_KIND = {
|
|
1694
1731
|
TypeScript: [
|
|
1695
1732
|
Extension.Ts,
|
|
@@ -1710,58 +1747,7 @@ const EXTENSIONS_FOR_KIND = {
|
|
|
1710
1747
|
],
|
|
1711
1748
|
Json: [Extension.Json]
|
|
1712
1749
|
};
|
|
1713
|
-
const extensionIsOk = Function.dual(DATA_FIRST_ARITY$
|
|
1714
|
-
// src/shared/lib/typescript/source-file.ts
|
|
1715
|
-
const DATA_FIRST_ARITY$23 = 2;
|
|
1716
|
-
const infos = /* @__PURE__ */ new WeakMap();
|
|
1717
|
-
const UNSET = Object.freeze({
|
|
1718
|
-
writable: true,
|
|
1719
|
-
configurable: true,
|
|
1720
|
-
enumerable: true
|
|
1721
|
-
});
|
|
1722
|
-
const attachFileInfo = Function.dual(DATA_FIRST_ARITY$23, (sourceFile, impliedNodeFormat) => {
|
|
1723
|
-
infos.set(sourceFile, {
|
|
1724
|
-
impliedNodeFormat,
|
|
1725
|
-
packageJsonScope: Option.none(),
|
|
1726
|
-
imports: sourceFile.imports,
|
|
1727
|
-
moduleAugmentations: sourceFile.moduleAugmentations
|
|
1728
|
-
});
|
|
1729
|
-
Object.defineProperty(sourceFile, "imports", UNSET);
|
|
1730
|
-
Object.defineProperty(sourceFile, "moduleAugmentations", UNSET);
|
|
1731
|
-
return sourceFile;
|
|
1732
|
-
});
|
|
1733
|
-
const infoOf = (sourceFile) => Option.fromNullishOr(infos.get(sourceFile));
|
|
1734
|
-
const impliedNodeFormatOf = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.impliedNodeFormat);
|
|
1735
|
-
const packageJsonScopeOf$1 = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.packageJsonScope);
|
|
1736
|
-
const setPackageJsonScope = Function.dual(DATA_FIRST_ARITY$23, (sourceFile, scope) => {
|
|
1737
|
-
Option.map(infoOf(sourceFile), (info) => infos.set(sourceFile, {
|
|
1738
|
-
...info,
|
|
1739
|
-
packageJsonScope: scope
|
|
1740
|
-
}));
|
|
1741
|
-
});
|
|
1742
|
-
const collectExternalModuleReferences = (sourceFile) => {
|
|
1743
|
-
Option.map(infoOf(sourceFile), (info) => {
|
|
1744
|
-
Object.defineProperty(sourceFile, "imports", {
|
|
1745
|
-
...UNSET,
|
|
1746
|
-
value: info.imports
|
|
1747
|
-
});
|
|
1748
|
-
Object.defineProperty(sourceFile, "moduleAugmentations", {
|
|
1749
|
-
...UNSET,
|
|
1750
|
-
value: info.moduleAugmentations
|
|
1751
|
-
});
|
|
1752
|
-
return info;
|
|
1753
|
-
});
|
|
1754
|
-
};
|
|
1755
|
-
const importsOf = (sourceFile) => Option.match(infoOf(sourceFile), {
|
|
1756
|
-
onNone: () => sourceFile.imports,
|
|
1757
|
-
onSome: (info) => info.imports
|
|
1758
|
-
});
|
|
1759
|
-
const moduleAugmentationsOf = (sourceFile) => Option.match(infoOf(sourceFile), {
|
|
1760
|
-
onNone: () => sourceFile.moduleAugmentations,
|
|
1761
|
-
onSome: (info) => info.moduleAugmentations
|
|
1762
|
-
});
|
|
1763
|
-
const isSourceFileJS = (sourceFile) => sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX;
|
|
1764
|
-
const isJSDocNode = (node) => hasFlag(node.flags, NodeFlags.JSDoc);
|
|
1750
|
+
const extensionIsOk = Function.dual(DATA_FIRST_ARITY$23, (extensions, extension) => pipe(EXTENSION_KIND_ORDER, Array$1.some((kind) => extensions.includes(kind) && EXTENSIONS_FOR_KIND[kind].includes(extension))));
|
|
1765
1751
|
// src/shared/lib/typescript/module-mode.ts
|
|
1766
1752
|
const DATA_FIRST_ARITY$22 = 2;
|
|
1767
1753
|
const DATA_FIRST_ARITY_3$14 = 3;
|
|
@@ -3034,11 +3020,6 @@ const openCheckerSession = (program) => {
|
|
|
3034
3020
|
const DATA_FIRST_ARITY$19 = 2;
|
|
3035
3021
|
const EXPORT_EQUALS = "export=";
|
|
3036
3022
|
const isCheckerSymbol = (symbol) => "getExports" in symbol;
|
|
3037
|
-
const sourceFileOf = (node) => {
|
|
3038
|
-
let current = node;
|
|
3039
|
-
while (!isSourceFile(current)) current = current.parent;
|
|
3040
|
-
return current;
|
|
3041
|
-
};
|
|
3042
3023
|
const firstDeclaration = (symbol) => Option.fromNullishOr(symbol.declarations).pipe(Option.flatMap((declarations) => Array$1.head(declarations)));
|
|
3043
3024
|
const NAMEABLE_GUARDS = [
|
|
3044
3025
|
isExpression,
|
|
@@ -3136,7 +3117,7 @@ const exportsAndPropertiesOf = (session, symbol) => {
|
|
|
3136
3117
|
if (exportEquals.id === moduleSymbol.id) return exports;
|
|
3137
3118
|
return [...exports, ...propertiesAsExports(session, symbol, exportEquals)];
|
|
3138
3119
|
};
|
|
3139
|
-
const aliasHasTypeOnlyDeclaration = (session, symbol) => pipe(symbol.declarations, Array$1.some((handle) => Option.fromNullishOr(handle.resolve(session.project))
|
|
3120
|
+
const aliasHasTypeOnlyDeclaration = (session, symbol) => pipe(symbol.declarations, Array$1.some((handle) => Option.exists(Option.fromNullishOr(handle.resolve(session.project)), isTypeOnlyImportOrExportDeclaration)));
|
|
3140
3121
|
const aliasChainIsTypeOnly = (session, symbol) => {
|
|
3141
3122
|
const seen = /* @__PURE__ */ new Set();
|
|
3142
3123
|
const isUnvisitedAlias = (candidate) => isAlias(candidate) && !seen.has(candidate.id);
|
|
@@ -3967,8 +3948,10 @@ const directoryMissing = Function.dual(DATA_FIRST_ARITY$11, (directory, state) =
|
|
|
3967
3948
|
traceMessage(state, Messages.directoryDoesNotExist, directory);
|
|
3968
3949
|
return true;
|
|
3969
3950
|
});
|
|
3970
|
-
const
|
|
3971
|
-
const
|
|
3951
|
+
const loadAsFile = (request, state) => loadModuleFromFile(request, state).pipe(Option.flatMap((resolved) => {
|
|
3952
|
+
const info = Option.liftPredicate(request.considerPackageJson, (consider) => consider).pipe(Option.flatMap(() => parseNodeModuleFromPath(resolved.path)), Option.flatMap((packageDirectory) => resolvePackageJsonInfo(packageDirectory, false, state)));
|
|
3953
|
+
return withPackageId(info, Option.some(resolved), state);
|
|
3954
|
+
}));
|
|
3972
3955
|
const fileAttempt = (request, state) => {
|
|
3973
3956
|
if (hasTrailingDirectorySeparator(request.candidate)) return {
|
|
3974
3957
|
found: Option.none(),
|
|
@@ -4226,23 +4209,18 @@ const foundAs = (isExternalLibraryImport) => (resolved) => ({
|
|
|
4226
4209
|
resolved,
|
|
4227
4210
|
isExternalLibraryImport
|
|
4228
4211
|
});
|
|
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
|
-
};
|
|
4233
|
-
const resolveRelative = (lookup, state) => {
|
|
4234
|
-
const { resolved, insideNodeModules } = loadRelativeModule(lookup, state);
|
|
4235
|
-
const found = foundAs(insideNodeModules);
|
|
4236
|
-
return resolved.pipe(Option.map(found));
|
|
4237
|
-
};
|
|
4238
4212
|
const tryResolve = (extensions, request, state) => {
|
|
4239
4213
|
const lookup = {
|
|
4240
4214
|
extensions,
|
|
4241
4215
|
moduleName: request.moduleName,
|
|
4242
4216
|
directory: request.containingDirectory
|
|
4243
4217
|
};
|
|
4244
|
-
if (!isExternalModuleNameRelative(request.moduleName))
|
|
4245
|
-
|
|
4218
|
+
if (!isExternalModuleNameRelative(request.moduleName)) {
|
|
4219
|
+
const external = Option.map(foundAs(true));
|
|
4220
|
+
return fromPackageImports(lookup, request.features, state).pipe(Option.orElse(() => fromSelfName(lookup, request.features, state)), Option.orElse(() => resolveFromNodeModulesWithTrace(lookup, state)), Option.map(external));
|
|
4221
|
+
}
|
|
4222
|
+
const { resolved, insideNodeModules } = loadRelativeModule(lookup, state);
|
|
4223
|
+
return resolved.pipe(Option.map(foundAs(insideNodeModules)), Option.map(Option.some));
|
|
4246
4224
|
};
|
|
4247
4225
|
const tryNonEmpty = (extensions, request, state) => {
|
|
4248
4226
|
if (extensions.length === EMPTY$1) return Option.none();
|