@effect/language-service 0.34.0 → 0.35.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 +5 -4
- package/cli.js +76 -7
- package/cli.js.map +1 -1
- package/index.js +232 -18
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +101 -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
|
+
fnName,
|
|
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,
|
|
@@ -1536,6 +1595,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1536
1595
|
getAncestorNodesInRange,
|
|
1537
1596
|
toTextRange,
|
|
1538
1597
|
isNodeInRange,
|
|
1598
|
+
transformAsyncAwaitToEffectFn,
|
|
1539
1599
|
transformAsyncAwaitToEffectGen,
|
|
1540
1600
|
findImportedModuleIdentifierByPackageAndNameOrBarrel,
|
|
1541
1601
|
simplifyTypeNode,
|
|
@@ -4893,43 +4953,32 @@ var diagnostics = [
|
|
|
4893
4953
|
];
|
|
4894
4954
|
|
|
4895
4955
|
// src/transform.ts
|
|
4896
|
-
var programsChecked = /* @__PURE__ */ new WeakMap();
|
|
4897
4956
|
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;
|
|
4957
|
+
return (_) => {
|
|
4958
|
+
return (sourceFile) => {
|
|
4959
|
+
pipe(
|
|
4960
|
+
getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
|
|
4961
|
+
nanoLayer2,
|
|
4962
|
+
nanoLayer,
|
|
4963
|
+
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
4964
|
+
provideService(TypeScriptProgram, program),
|
|
4965
|
+
provideService(TypeScriptApi, tsInstance),
|
|
4966
|
+
provideService(
|
|
4967
|
+
LanguageServicePluginOptions,
|
|
4968
|
+
parse(pluginConfig)
|
|
4969
|
+
),
|
|
4970
|
+
run,
|
|
4971
|
+
map((_2) => _2.diagnostics),
|
|
4972
|
+
map(
|
|
4973
|
+
filter(
|
|
4974
|
+
(_2) => _2.category === tsInstance.DiagnosticCategory.Error || _2.category === tsInstance.DiagnosticCategory.Warning
|
|
4975
|
+
)
|
|
4976
|
+
),
|
|
4977
|
+
getOrElse(() => []),
|
|
4978
|
+
map2(addDiagnostic)
|
|
4979
|
+
);
|
|
4980
|
+
return sourceFile;
|
|
4981
|
+
};
|
|
4933
4982
|
};
|
|
4934
4983
|
}
|
|
4935
4984
|
//# sourceMappingURL=transform.js.map
|