@effect/language-service 0.34.0 → 0.35.1
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 +5 -4
- package/cli.js +109 -7
- package/cli.js.map +1 -1
- package/index.js +314 -29
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +134 -52
- package/transform.js.map +1 -1
package/package.json
CHANGED
package/transform.js
CHANGED
|
@@ -142,9 +142,6 @@ var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
|
142
142
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
143
143
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
144
144
|
|
|
145
|
-
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/errors.js
|
|
146
|
-
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
147
|
-
|
|
148
145
|
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Utils.js
|
|
149
146
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
150
147
|
var GenKindImpl = class {
|
|
@@ -245,12 +242,6 @@ var YieldWrap = class {
|
|
|
245
242
|
return this.#value;
|
|
246
243
|
}
|
|
247
244
|
};
|
|
248
|
-
function yieldWrapGet(self) {
|
|
249
|
-
if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
|
|
250
|
-
return self[YieldWrapTypeId]();
|
|
251
|
-
}
|
|
252
|
-
throw new Error(getBugErrorMessage("yieldWrapGet"));
|
|
253
|
-
}
|
|
254
245
|
var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructuralRegion", () => ({
|
|
255
246
|
enabled: false,
|
|
256
247
|
tester: void 0
|
|
@@ -834,6 +825,31 @@ var NanoTag = class {
|
|
|
834
825
|
}
|
|
835
826
|
};
|
|
836
827
|
var Tag = (identifier) => new NanoTag(identifier);
|
|
828
|
+
var SingleShotGen2 = class _SingleShotGen {
|
|
829
|
+
called = false;
|
|
830
|
+
self;
|
|
831
|
+
constructor(self) {
|
|
832
|
+
this.self = self;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* @since 2.0.0
|
|
836
|
+
*/
|
|
837
|
+
next(a) {
|
|
838
|
+
return this.called ? {
|
|
839
|
+
value: a,
|
|
840
|
+
done: true
|
|
841
|
+
} : (this.called = true, {
|
|
842
|
+
value: this.self,
|
|
843
|
+
done: false
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* @since 2.0.0
|
|
848
|
+
*/
|
|
849
|
+
[Symbol.iterator]() {
|
|
850
|
+
return new _SingleShotGen(this.self);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
837
853
|
var evaluate = Symbol.for("Nano.evaluate");
|
|
838
854
|
var contA = Symbol.for("Nano.contA");
|
|
839
855
|
var contE = Symbol.for("Nano.contE");
|
|
@@ -848,7 +864,7 @@ var NanoDefectException = class {
|
|
|
848
864
|
};
|
|
849
865
|
var PrimitiveProto = {
|
|
850
866
|
[Symbol.iterator]() {
|
|
851
|
-
return new
|
|
867
|
+
return new SingleShotGen2(this);
|
|
852
868
|
}
|
|
853
869
|
};
|
|
854
870
|
var SucceedProto = {
|
|
@@ -971,7 +987,7 @@ var FromIteratorProto = {
|
|
|
971
987
|
const state = this[args][0].next(value);
|
|
972
988
|
if (state.done) return succeed(state.value);
|
|
973
989
|
fiber._stack.push(this);
|
|
974
|
-
return
|
|
990
|
+
return state.value;
|
|
975
991
|
},
|
|
976
992
|
[evaluate](fiber) {
|
|
977
993
|
return this[contA](this[args][1], fiber);
|
|
@@ -1300,7 +1316,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1300
1316
|
function isNodeInRange(textRange) {
|
|
1301
1317
|
return (node) => node.pos <= textRange.pos && node.end >= textRange.end;
|
|
1302
1318
|
}
|
|
1303
|
-
function
|
|
1319
|
+
function transformAsyncAwaitToEffectGeneratorBody(body, onAwait) {
|
|
1304
1320
|
function visitor(_) {
|
|
1305
1321
|
if (ts.isAwaitExpression(_)) {
|
|
1306
1322
|
const expression = ts.visitEachChild(_.expression, visitor, ts.nullTransformationContext);
|
|
@@ -1311,7 +1327,44 @@ function makeTypeScriptUtils(ts) {
|
|
|
1311
1327
|
}
|
|
1312
1328
|
return ts.visitEachChild(_, visitor, ts.nullTransformationContext);
|
|
1313
1329
|
}
|
|
1314
|
-
|
|
1330
|
+
return visitor(body);
|
|
1331
|
+
}
|
|
1332
|
+
function transformAsyncAwaitToEffectFn(node, effectModuleName, onAwait) {
|
|
1333
|
+
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
1334
|
+
const fnName = node.name && ts.isIdentifier(node.name) ? node.name : ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && node.parent.initializer === node ? node.parent.name : void 0;
|
|
1335
|
+
let fnCall = ts.factory.createPropertyAccessExpression(
|
|
1336
|
+
ts.factory.createIdentifier(effectModuleName),
|
|
1337
|
+
"fn"
|
|
1338
|
+
);
|
|
1339
|
+
if (fnName) {
|
|
1340
|
+
fnCall = ts.factory.createCallExpression(
|
|
1341
|
+
fnCall,
|
|
1342
|
+
void 0,
|
|
1343
|
+
[ts.factory.createStringLiteral(fnName.text)]
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
return tryPreserveDeclarationSemantics(
|
|
1347
|
+
node,
|
|
1348
|
+
ts.factory.createCallExpression(
|
|
1349
|
+
fnCall,
|
|
1350
|
+
void 0,
|
|
1351
|
+
[
|
|
1352
|
+
ts.factory.createFunctionExpression(
|
|
1353
|
+
void 0,
|
|
1354
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
1355
|
+
void 0,
|
|
1356
|
+
node.typeParameters,
|
|
1357
|
+
node.parameters,
|
|
1358
|
+
void 0,
|
|
1359
|
+
ts.isBlock(generatorBody) ? generatorBody : ts.factory.createBlock([ts.factory.createReturnStatement(generatorBody)])
|
|
1360
|
+
)
|
|
1361
|
+
]
|
|
1362
|
+
),
|
|
1363
|
+
true
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
1366
|
+
function transformAsyncAwaitToEffectGen(node, effectModuleName, onAwait) {
|
|
1367
|
+
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
1315
1368
|
const effectGenCallExp = createEffectGenCallExpression(effectModuleName, generatorBody);
|
|
1316
1369
|
let currentFlags = ts.getCombinedModifierFlags(node);
|
|
1317
1370
|
currentFlags &= ~ts.ModifierFlags.Async;
|
|
@@ -1415,12 +1468,15 @@ function makeTypeScriptUtils(ts) {
|
|
|
1415
1468
|
}
|
|
1416
1469
|
return typeNode;
|
|
1417
1470
|
}
|
|
1418
|
-
function tryPreserveDeclarationSemantics(nodeToReplace, node) {
|
|
1471
|
+
function tryPreserveDeclarationSemantics(nodeToReplace, node, dropAsync) {
|
|
1419
1472
|
if (!ts.isExpression(node)) return node;
|
|
1420
1473
|
if (ts.isFunctionDeclaration(nodeToReplace)) {
|
|
1421
1474
|
if (!nodeToReplace.name) return node;
|
|
1475
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
1476
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
1477
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
1422
1478
|
return ts.factory.createVariableStatement(
|
|
1423
|
-
|
|
1479
|
+
newModifiers,
|
|
1424
1480
|
ts.factory.createVariableDeclarationList(
|
|
1425
1481
|
[ts.factory.createVariableDeclaration(
|
|
1426
1482
|
nodeToReplace.name,
|
|
@@ -1432,8 +1488,11 @@ function makeTypeScriptUtils(ts) {
|
|
|
1432
1488
|
)
|
|
1433
1489
|
);
|
|
1434
1490
|
} else if (ts.isMethodDeclaration(nodeToReplace)) {
|
|
1491
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
1492
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
1493
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
1435
1494
|
return ts.factory.createPropertyDeclaration(
|
|
1436
|
-
|
|
1495
|
+
newModifiers,
|
|
1437
1496
|
nodeToReplace.name,
|
|
1438
1497
|
void 0,
|
|
1439
1498
|
void 0,
|
|
@@ -1527,6 +1586,38 @@ function makeTypeScriptUtils(ts) {
|
|
|
1527
1586
|
)
|
|
1528
1587
|
);
|
|
1529
1588
|
}
|
|
1589
|
+
function createDataTaggedErrorDeclaration(dataModuleIdentifier, name, fields) {
|
|
1590
|
+
const invokeTaggedError = ts.factory.createCallExpression(
|
|
1591
|
+
ts.factory.createPropertyAccessExpression(
|
|
1592
|
+
ts.factory.createIdentifier(dataModuleIdentifier),
|
|
1593
|
+
"TaggedError"
|
|
1594
|
+
),
|
|
1595
|
+
void 0,
|
|
1596
|
+
[
|
|
1597
|
+
ts.factory.createStringLiteral(name)
|
|
1598
|
+
]
|
|
1599
|
+
);
|
|
1600
|
+
const withTypeFields = ts.factory.createExpressionWithTypeArguments(
|
|
1601
|
+
invokeTaggedError,
|
|
1602
|
+
[
|
|
1603
|
+
ts.factory.createTypeLiteralNode(fields)
|
|
1604
|
+
]
|
|
1605
|
+
);
|
|
1606
|
+
return ts.factory.createClassDeclaration(
|
|
1607
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
1608
|
+
name,
|
|
1609
|
+
void 0,
|
|
1610
|
+
[
|
|
1611
|
+
ts.factory.createHeritageClause(
|
|
1612
|
+
ts.SyntaxKind.ExtendsKeyword,
|
|
1613
|
+
[
|
|
1614
|
+
withTypeFields
|
|
1615
|
+
]
|
|
1616
|
+
)
|
|
1617
|
+
],
|
|
1618
|
+
[]
|
|
1619
|
+
);
|
|
1620
|
+
}
|
|
1530
1621
|
return {
|
|
1531
1622
|
findNodeAtPositionIncludingTrivia,
|
|
1532
1623
|
parsePackageContentNameAndVersionFromScope,
|
|
@@ -1536,7 +1627,9 @@ function makeTypeScriptUtils(ts) {
|
|
|
1536
1627
|
getAncestorNodesInRange,
|
|
1537
1628
|
toTextRange,
|
|
1538
1629
|
isNodeInRange,
|
|
1630
|
+
transformAsyncAwaitToEffectFn,
|
|
1539
1631
|
transformAsyncAwaitToEffectGen,
|
|
1632
|
+
createDataTaggedErrorDeclaration,
|
|
1540
1633
|
findImportedModuleIdentifierByPackageAndNameOrBarrel,
|
|
1541
1634
|
simplifyTypeNode,
|
|
1542
1635
|
tryPreserveDeclarationSemantics,
|
|
@@ -4893,43 +4986,32 @@ var diagnostics = [
|
|
|
4893
4986
|
];
|
|
4894
4987
|
|
|
4895
4988
|
// src/transform.ts
|
|
4896
|
-
var programsChecked = /* @__PURE__ */ new WeakMap();
|
|
4897
4989
|
function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstance }) {
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
)
|
|
4920
|
-
)
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
);
|
|
4924
|
-
}
|
|
4925
|
-
const rootFileNames = program.getRootFileNames();
|
|
4926
|
-
const sourceFiles = program.getSourceFiles().filter((_) => rootFileNames.indexOf(_.fileName) > -1);
|
|
4927
|
-
for (const sourceFile of sourceFiles) {
|
|
4928
|
-
runDiagnostics(program, sourceFile);
|
|
4929
|
-
}
|
|
4930
|
-
return (_) => (sourceFile) => {
|
|
4931
|
-
runDiagnostics(program, sourceFile);
|
|
4932
|
-
return sourceFile;
|
|
4990
|
+
return (_) => {
|
|
4991
|
+
return (sourceFile) => {
|
|
4992
|
+
pipe(
|
|
4993
|
+
getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
|
|
4994
|
+
nanoLayer2,
|
|
4995
|
+
nanoLayer,
|
|
4996
|
+
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
4997
|
+
provideService(TypeScriptProgram, program),
|
|
4998
|
+
provideService(TypeScriptApi, tsInstance),
|
|
4999
|
+
provideService(
|
|
5000
|
+
LanguageServicePluginOptions,
|
|
5001
|
+
parse(pluginConfig)
|
|
5002
|
+
),
|
|
5003
|
+
run,
|
|
5004
|
+
map((_2) => _2.diagnostics),
|
|
5005
|
+
map(
|
|
5006
|
+
filter(
|
|
5007
|
+
(_2) => _2.category === tsInstance.DiagnosticCategory.Error || _2.category === tsInstance.DiagnosticCategory.Warning
|
|
5008
|
+
)
|
|
5009
|
+
),
|
|
5010
|
+
getOrElse(() => []),
|
|
5011
|
+
map2(addDiagnostic)
|
|
5012
|
+
);
|
|
5013
|
+
return sourceFile;
|
|
5014
|
+
};
|
|
4933
5015
|
};
|
|
4934
5016
|
}
|
|
4935
5017
|
//# sourceMappingURL=transform.js.map
|