@effect/language-service 0.27.2 → 0.28.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 +1 -0
- package/cli.js +48 -2
- package/cli.js.map +1 -1
- package/index.js +871 -360
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +48 -2
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all3) => {
|
|
4
|
+
for (var name in all3)
|
|
5
|
+
__defProp(target, name, { get: all3[name], enumerable: true });
|
|
6
|
+
};
|
|
2
7
|
|
|
3
8
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Function.js
|
|
4
9
|
var isFunction = (input) => typeof input === "function";
|
|
@@ -130,14 +135,150 @@ var globalValue = (id, compute) => {
|
|
|
130
135
|
};
|
|
131
136
|
|
|
132
137
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Predicate.js
|
|
138
|
+
var Predicate_exports = {};
|
|
139
|
+
__export(Predicate_exports, {
|
|
140
|
+
all: () => all,
|
|
141
|
+
and: () => and,
|
|
142
|
+
compose: () => compose,
|
|
143
|
+
eqv: () => eqv,
|
|
144
|
+
every: () => every,
|
|
145
|
+
hasProperty: () => hasProperty,
|
|
146
|
+
implies: () => implies,
|
|
147
|
+
isBigInt: () => isBigInt,
|
|
148
|
+
isBoolean: () => isBoolean,
|
|
149
|
+
isDate: () => isDate,
|
|
150
|
+
isError: () => isError,
|
|
151
|
+
isFunction: () => isFunction2,
|
|
152
|
+
isIterable: () => isIterable,
|
|
153
|
+
isMap: () => isMap,
|
|
154
|
+
isNever: () => isNever,
|
|
155
|
+
isNotNull: () => isNotNull,
|
|
156
|
+
isNotNullable: () => isNotNullable,
|
|
157
|
+
isNotUndefined: () => isNotUndefined,
|
|
158
|
+
isNull: () => isNull,
|
|
159
|
+
isNullable: () => isNullable,
|
|
160
|
+
isNumber: () => isNumber,
|
|
161
|
+
isObject: () => isObject,
|
|
162
|
+
isPromise: () => isPromise,
|
|
163
|
+
isPromiseLike: () => isPromiseLike,
|
|
164
|
+
isPropertyKey: () => isPropertyKey,
|
|
165
|
+
isReadonlyRecord: () => isReadonlyRecord,
|
|
166
|
+
isRecord: () => isRecord,
|
|
167
|
+
isRecordOrArray: () => isRecordOrArray,
|
|
168
|
+
isRegExp: () => isRegExp,
|
|
169
|
+
isSet: () => isSet,
|
|
170
|
+
isString: () => isString,
|
|
171
|
+
isSymbol: () => isSymbol,
|
|
172
|
+
isTagged: () => isTagged,
|
|
173
|
+
isTruthy: () => isTruthy,
|
|
174
|
+
isTupleOf: () => isTupleOf,
|
|
175
|
+
isTupleOfAtLeast: () => isTupleOfAtLeast,
|
|
176
|
+
isUint8Array: () => isUint8Array,
|
|
177
|
+
isUndefined: () => isUndefined,
|
|
178
|
+
isUnknown: () => isUnknown,
|
|
179
|
+
mapInput: () => mapInput,
|
|
180
|
+
nand: () => nand,
|
|
181
|
+
nor: () => nor,
|
|
182
|
+
not: () => not,
|
|
183
|
+
or: () => or,
|
|
184
|
+
product: () => product,
|
|
185
|
+
productMany: () => productMany,
|
|
186
|
+
some: () => some,
|
|
187
|
+
struct: () => struct,
|
|
188
|
+
tuple: () => tuple,
|
|
189
|
+
xor: () => xor
|
|
190
|
+
});
|
|
191
|
+
var mapInput = /* @__PURE__ */ dual(2, (self, f) => (b) => self(f(b)));
|
|
192
|
+
var isTupleOf = /* @__PURE__ */ dual(2, (self, n) => self.length === n);
|
|
193
|
+
var isTupleOfAtLeast = /* @__PURE__ */ dual(2, (self, n) => self.length >= n);
|
|
194
|
+
var isTruthy = (input) => !!input;
|
|
195
|
+
var isSet = (input) => input instanceof Set;
|
|
196
|
+
var isMap = (input) => input instanceof Map;
|
|
133
197
|
var isString = (input) => typeof input === "string";
|
|
134
198
|
var isNumber = (input) => typeof input === "number";
|
|
135
199
|
var isBoolean = (input) => typeof input === "boolean";
|
|
200
|
+
var isBigInt = (input) => typeof input === "bigint";
|
|
201
|
+
var isSymbol = (input) => typeof input === "symbol";
|
|
202
|
+
var isPropertyKey = (u) => isString(u) || isNumber(u) || isSymbol(u);
|
|
136
203
|
var isFunction2 = isFunction;
|
|
204
|
+
var isUndefined = (input) => input === void 0;
|
|
205
|
+
var isNotUndefined = (input) => input !== void 0;
|
|
206
|
+
var isNull = (input) => input === null;
|
|
207
|
+
var isNotNull = (input) => input !== null;
|
|
208
|
+
var isNever = (_) => false;
|
|
209
|
+
var isUnknown = (_) => true;
|
|
137
210
|
var isRecordOrArray = (input) => typeof input === "object" && input !== null;
|
|
138
211
|
var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
139
212
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
213
|
+
var isTagged = /* @__PURE__ */ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
|
|
214
|
+
var isNullable = (input) => input === null || input === void 0;
|
|
215
|
+
var isNotNullable = (input) => input !== null && input !== void 0;
|
|
216
|
+
var isError = (input) => input instanceof Error;
|
|
217
|
+
var isUint8Array = (input) => input instanceof Uint8Array;
|
|
218
|
+
var isDate = (input) => input instanceof Date;
|
|
219
|
+
var isIterable = (input) => hasProperty(input, Symbol.iterator);
|
|
140
220
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
221
|
+
var isReadonlyRecord = isRecord;
|
|
222
|
+
var isPromise = (input) => hasProperty(input, "then") && "catch" in input && isFunction2(input.then) && isFunction2(input.catch);
|
|
223
|
+
var isPromiseLike = (input) => hasProperty(input, "then") && isFunction2(input.then);
|
|
224
|
+
var isRegExp = (input) => input instanceof RegExp;
|
|
225
|
+
var compose = /* @__PURE__ */ dual(2, (ab, bc) => (a) => ab(a) && bc(a));
|
|
226
|
+
var product = (self, that) => ([a, b]) => self(a) && that(b);
|
|
227
|
+
var all = (collection) => {
|
|
228
|
+
return (as) => {
|
|
229
|
+
let collectionIndex = 0;
|
|
230
|
+
for (const p of collection) {
|
|
231
|
+
if (collectionIndex >= as.length) {
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
if (p(as[collectionIndex]) === false) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
collectionIndex++;
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
var productMany = (self, collection) => {
|
|
243
|
+
const rest = all(collection);
|
|
244
|
+
return ([head2, ...tail]) => self(head2) === false ? false : rest(tail);
|
|
245
|
+
};
|
|
246
|
+
var tuple = (...elements) => all(elements);
|
|
247
|
+
var struct = (fields) => {
|
|
248
|
+
const keys = Object.keys(fields);
|
|
249
|
+
return (a) => {
|
|
250
|
+
for (const key of keys) {
|
|
251
|
+
if (!fields[key](a[key])) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
var not = (self) => (a) => !self(a);
|
|
259
|
+
var or = /* @__PURE__ */ dual(2, (self, that) => (a) => self(a) || that(a));
|
|
260
|
+
var and = /* @__PURE__ */ dual(2, (self, that) => (a) => self(a) && that(a));
|
|
261
|
+
var xor = /* @__PURE__ */ dual(2, (self, that) => (a) => self(a) !== that(a));
|
|
262
|
+
var eqv = /* @__PURE__ */ dual(2, (self, that) => (a) => self(a) === that(a));
|
|
263
|
+
var implies = /* @__PURE__ */ dual(2, (antecedent, consequent) => (a) => antecedent(a) ? consequent(a) : true);
|
|
264
|
+
var nor = /* @__PURE__ */ dual(2, (self, that) => (a) => !(self(a) || that(a)));
|
|
265
|
+
var nand = /* @__PURE__ */ dual(2, (self, that) => (a) => !(self(a) && that(a)));
|
|
266
|
+
var every = (collection) => (a) => {
|
|
267
|
+
for (const p of collection) {
|
|
268
|
+
if (!p(a)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
};
|
|
274
|
+
var some = (collection) => (a) => {
|
|
275
|
+
for (const p of collection) {
|
|
276
|
+
if (p(a)) {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
};
|
|
141
282
|
|
|
142
283
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/errors.js
|
|
143
284
|
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
@@ -650,7 +791,7 @@ var isOption = (input) => hasProperty(input, TypeId);
|
|
|
650
791
|
var isNone = (fa) => fa._tag === "None";
|
|
651
792
|
var isSome = (fa) => fa._tag === "Some";
|
|
652
793
|
var none = /* @__PURE__ */ Object.create(NoneProto);
|
|
653
|
-
var
|
|
794
|
+
var some2 = (value) => {
|
|
654
795
|
const a = Object.create(SomeProto);
|
|
655
796
|
a.value = value;
|
|
656
797
|
return a;
|
|
@@ -732,7 +873,7 @@ var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
|
732
873
|
|
|
733
874
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Option.js
|
|
734
875
|
var none2 = () => none;
|
|
735
|
-
var
|
|
876
|
+
var some3 = some2;
|
|
736
877
|
var isNone2 = isNone;
|
|
737
878
|
var isSome2 = isSome;
|
|
738
879
|
var match = /* @__PURE__ */ dual(2, (self, {
|
|
@@ -741,9 +882,9 @@ var match = /* @__PURE__ */ dual(2, (self, {
|
|
|
741
882
|
}) => isNone2(self) ? onNone() : onSome(self.value));
|
|
742
883
|
var getOrElse2 = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
|
|
743
884
|
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
|
|
744
|
-
var fromNullable = (nullableValue) => nullableValue == null ? none2() :
|
|
885
|
+
var fromNullable = (nullableValue) => nullableValue == null ? none2() : some3(nullableValue);
|
|
745
886
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
746
|
-
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() :
|
|
887
|
+
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some3(f(self.value)));
|
|
747
888
|
|
|
748
889
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/array.js
|
|
749
890
|
var isNonEmptyArray = (self) => self.length > 0;
|
|
@@ -759,7 +900,7 @@ var isNonEmptyReadonlyArray = isNonEmptyArray;
|
|
|
759
900
|
var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
|
|
760
901
|
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
761
902
|
const i = Math.floor(index);
|
|
762
|
-
return isOutOfBounds(i, self) ? none2() :
|
|
903
|
+
return isOutOfBounds(i, self) ? none2() : some3(self[i]);
|
|
763
904
|
});
|
|
764
905
|
var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
765
906
|
const i = Math.floor(index);
|
|
@@ -816,6 +957,7 @@ var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
|
816
957
|
}
|
|
817
958
|
return out;
|
|
818
959
|
});
|
|
960
|
+
var every2 = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
819
961
|
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
820
962
|
const input = fromIterable(self);
|
|
821
963
|
if (isNonEmptyReadonlyArray(input)) {
|
|
@@ -1084,7 +1226,7 @@ function cachedBy(fa, type, lookupKey) {
|
|
|
1084
1226
|
var option = (fa) => {
|
|
1085
1227
|
const nano = Object.create(MatchProto);
|
|
1086
1228
|
nano[args] = fa;
|
|
1087
|
-
nano[contA] = (_) => succeed(
|
|
1229
|
+
nano[contA] = (_) => succeed(some3(_));
|
|
1088
1230
|
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(none2());
|
|
1089
1231
|
return nano;
|
|
1090
1232
|
};
|
|
@@ -1095,7 +1237,7 @@ var ignore = (fa) => {
|
|
|
1095
1237
|
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : void_;
|
|
1096
1238
|
return nano;
|
|
1097
1239
|
};
|
|
1098
|
-
var
|
|
1240
|
+
var all2 = fn("all")(
|
|
1099
1241
|
function* (...args2) {
|
|
1100
1242
|
const results = [];
|
|
1101
1243
|
for (const fa of args2) {
|
|
@@ -1131,13 +1273,17 @@ function parsePackageContentNameAndVersionFromScope(v) {
|
|
|
1131
1273
|
...hasProperty(packageJsonContent, "peerDependencies") && isObject(packageJsonContent.peerDependencies) ? packageJsonContent.peerDependencies : {},
|
|
1132
1274
|
...hasProperty(packageJsonContent, "devDependencies") && isObject(packageJsonContent.devDependencies) ? packageJsonContent.devDependencies : {}
|
|
1133
1275
|
});
|
|
1276
|
+
const exportsKeys = Object.keys(
|
|
1277
|
+
hasProperty(packageJsonContent, "exports") && isObject(packageJsonContent.exports) ? packageJsonContent.exports : {}
|
|
1278
|
+
);
|
|
1134
1279
|
return {
|
|
1135
1280
|
name: name.toLowerCase(),
|
|
1136
1281
|
version: version.toLowerCase(),
|
|
1137
1282
|
hasEffectInPeerDependencies,
|
|
1138
1283
|
contents: packageJsonContent,
|
|
1139
1284
|
packageDirectory: packageJsonScope.packageDirectory,
|
|
1140
|
-
referencedPackages
|
|
1285
|
+
referencedPackages,
|
|
1286
|
+
exportsKeys
|
|
1141
1287
|
};
|
|
1142
1288
|
}
|
|
1143
1289
|
var resolveModulePattern = fn("resolveModulePattern")(
|
|
@@ -1337,7 +1483,7 @@ var findImportedModuleIdentifier = fn("AST.findImportedModuleIdentifier")(
|
|
|
1337
1483
|
} else if (ts.isNamedImports(namedBindings)) {
|
|
1338
1484
|
for (const importSpecifier of namedBindings.elements) {
|
|
1339
1485
|
const importProperty = fromNullable(importSpecifier.propertyName).pipe(
|
|
1340
|
-
orElse(() =>
|
|
1486
|
+
orElse(() => some3(importSpecifier.name))
|
|
1341
1487
|
);
|
|
1342
1488
|
if (yield* test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
|
|
1343
1489
|
return importSpecifier.name;
|
|
@@ -1370,20 +1516,20 @@ var simplifyTypeNode = fn("AST.simplifyTypeNode")(function* (typeNode) {
|
|
|
1370
1516
|
function collectCallable(typeNode2) {
|
|
1371
1517
|
if (ts.isParenthesizedTypeNode(typeNode2)) return collectCallable(typeNode2.type);
|
|
1372
1518
|
if (ts.isFunctionTypeNode(typeNode2)) {
|
|
1373
|
-
return
|
|
1519
|
+
return some3([
|
|
1374
1520
|
ts.factory.createCallSignature(typeNode2.typeParameters, typeNode2.parameters, typeNode2.type)
|
|
1375
1521
|
]);
|
|
1376
1522
|
}
|
|
1377
1523
|
if (ts.isTypeLiteralNode(typeNode2)) {
|
|
1378
1524
|
const allCallSignatures = typeNode2.members.every(ts.isCallSignatureDeclaration);
|
|
1379
1525
|
if (allCallSignatures) {
|
|
1380
|
-
return
|
|
1526
|
+
return some3(typeNode2.members);
|
|
1381
1527
|
}
|
|
1382
1528
|
}
|
|
1383
1529
|
if (ts.isIntersectionTypeNode(typeNode2)) {
|
|
1384
1530
|
const members = typeNode2.types.map((node) => collectCallable(node));
|
|
1385
1531
|
if (members.every(isSome2)) {
|
|
1386
|
-
return
|
|
1532
|
+
return some3(members.map((_) => isSome2(_) ? _.value : []).flat());
|
|
1387
1533
|
}
|
|
1388
1534
|
}
|
|
1389
1535
|
return none2();
|
|
@@ -2299,7 +2445,7 @@ function make3(ts, typeChecker) {
|
|
|
2299
2445
|
return invariantTypeArgument(propertyType);
|
|
2300
2446
|
};
|
|
2301
2447
|
const effectVarianceStruct = (type, atLocation) => map4(
|
|
2302
|
-
|
|
2448
|
+
all2(
|
|
2303
2449
|
varianceStructCovariantType(type, atLocation, "_A"),
|
|
2304
2450
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
2305
2451
|
varianceStructCovariantType(type, atLocation, "_R")
|
|
@@ -2307,7 +2453,7 @@ function make3(ts, typeChecker) {
|
|
|
2307
2453
|
([A, E, R]) => ({ A, E, R })
|
|
2308
2454
|
);
|
|
2309
2455
|
const layerVarianceStruct = (type, atLocation) => map4(
|
|
2310
|
-
|
|
2456
|
+
all2(
|
|
2311
2457
|
varianceStructContravariantType(type, atLocation, "_ROut"),
|
|
2312
2458
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
2313
2459
|
varianceStructCovariantType(type, atLocation, "_RIn")
|
|
@@ -2615,7 +2761,7 @@ function make3(ts, typeChecker) {
|
|
|
2615
2761
|
(node) => node
|
|
2616
2762
|
);
|
|
2617
2763
|
const effectSchemaVarianceStruct = (type, atLocation) => map4(
|
|
2618
|
-
|
|
2764
|
+
all2(
|
|
2619
2765
|
varianceStructInvariantType(type, atLocation, "_A"),
|
|
2620
2766
|
varianceStructInvariantType(type, atLocation, "_I"),
|
|
2621
2767
|
varianceStructCovariantType(type, atLocation, "_R")
|
|
@@ -2647,7 +2793,7 @@ function make3(ts, typeChecker) {
|
|
|
2647
2793
|
(type) => type
|
|
2648
2794
|
);
|
|
2649
2795
|
const contextTagVarianceStruct = (type, atLocation) => map4(
|
|
2650
|
-
|
|
2796
|
+
all2(
|
|
2651
2797
|
varianceStructInvariantType(type, atLocation, "_Identifier"),
|
|
2652
2798
|
varianceStructInvariantType(type, atLocation, "_Service")
|
|
2653
2799
|
),
|
|
@@ -2713,6 +2859,47 @@ function make3(ts, typeChecker) {
|
|
|
2713
2859
|
"TypeParser.scopeType",
|
|
2714
2860
|
(type) => type
|
|
2715
2861
|
);
|
|
2862
|
+
const promiseLike = cachedBy(
|
|
2863
|
+
function(type, atLocation) {
|
|
2864
|
+
const thenProperty = type.getProperty("then");
|
|
2865
|
+
if (!thenProperty) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2866
|
+
const thenType = typeChecker.getTypeOfSymbolAtLocation(thenProperty, atLocation);
|
|
2867
|
+
if (!thenType) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2868
|
+
for (const callSignature of thenType.getCallSignatures()) {
|
|
2869
|
+
const parameter = callSignature.parameters[0];
|
|
2870
|
+
if (!parameter) continue;
|
|
2871
|
+
const parameterType = callSignature.getTypeParameterAtPosition(0);
|
|
2872
|
+
if (!parameterType) continue;
|
|
2873
|
+
let callbackCallSignatures = [];
|
|
2874
|
+
let toTest = [parameterType];
|
|
2875
|
+
while (toTest.length > 0) {
|
|
2876
|
+
const type2 = toTest.shift();
|
|
2877
|
+
if (!type2) continue;
|
|
2878
|
+
const callSignatures = type2.getCallSignatures();
|
|
2879
|
+
callbackCallSignatures = callbackCallSignatures.concat(callSignatures);
|
|
2880
|
+
if (type2.isUnion()) {
|
|
2881
|
+
toTest = toTest.concat(type2.types);
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
for (const callableType of callbackCallSignatures) {
|
|
2885
|
+
const callbackParameter = callableType.parameters[0];
|
|
2886
|
+
if (!callbackParameter) {
|
|
2887
|
+
continue;
|
|
2888
|
+
}
|
|
2889
|
+
const callbackParameterType = callableType.getTypeParameterAtPosition(0);
|
|
2890
|
+
if (!callbackParameterType) {
|
|
2891
|
+
continue;
|
|
2892
|
+
}
|
|
2893
|
+
return succeed({
|
|
2894
|
+
type: callbackParameterType
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
return typeParserIssue("not a promise", type, atLocation);
|
|
2899
|
+
},
|
|
2900
|
+
"TypeParser.promiseLike",
|
|
2901
|
+
(type) => type
|
|
2902
|
+
);
|
|
2716
2903
|
return {
|
|
2717
2904
|
effectType,
|
|
2718
2905
|
strictEffectType,
|
|
@@ -2728,7 +2915,8 @@ function make3(ts, typeChecker) {
|
|
|
2728
2915
|
contextTag,
|
|
2729
2916
|
pipeableType,
|
|
2730
2917
|
pipeCall,
|
|
2731
|
-
scopeType
|
|
2918
|
+
scopeType,
|
|
2919
|
+
promiseLike
|
|
2732
2920
|
};
|
|
2733
2921
|
}
|
|
2734
2922
|
|
|
@@ -2883,7 +3071,7 @@ var importFromBarrel = createDiagnostic({
|
|
|
2883
3071
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2884
3072
|
const program = yield* service(TypeScriptProgram);
|
|
2885
3073
|
const packageNamesToCheck = flatten(
|
|
2886
|
-
yield*
|
|
3074
|
+
yield* all2(
|
|
2887
3075
|
...languageServicePluginOptions.namespaceImportPackages.map(
|
|
2888
3076
|
(packageName) => resolveModulePattern(sourceFile, packageName)
|
|
2889
3077
|
)
|
|
@@ -3135,7 +3323,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
3135
3323
|
const typeParser = yield* service(TypeParser);
|
|
3136
3324
|
const typeOrder = yield* deterministicTypeOrder;
|
|
3137
3325
|
const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
|
|
3138
|
-
|
|
3326
|
+
all2(
|
|
3139
3327
|
typeParser.effectType(expectedType, node),
|
|
3140
3328
|
typeParser.effectType(realType, valueNode)
|
|
3141
3329
|
),
|
|
@@ -3201,7 +3389,7 @@ var missingEffectError = createDiagnostic({
|
|
|
3201
3389
|
[ts.factory.createStringLiteral(message)]
|
|
3202
3390
|
);
|
|
3203
3391
|
const checkForMissingErrorTypes = (node, expectedType, valueNode, realType) => pipe(
|
|
3204
|
-
|
|
3392
|
+
all2(
|
|
3205
3393
|
typeParser.effectType(expectedType, node),
|
|
3206
3394
|
typeParser.effectType(realType, valueNode)
|
|
3207
3395
|
),
|
|
@@ -4200,102 +4388,251 @@ var completions = [
|
|
|
4200
4388
|
schemaBrand
|
|
4201
4389
|
];
|
|
4202
4390
|
|
|
4203
|
-
//
|
|
4204
|
-
var
|
|
4205
|
-
|
|
4391
|
+
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
4392
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
4393
|
+
|
|
4394
|
+
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
4395
|
+
var encode = (bytes) => {
|
|
4396
|
+
const length = bytes.length;
|
|
4397
|
+
let result = "";
|
|
4398
|
+
let i;
|
|
4399
|
+
for (i = 2; i < length; i += 3) {
|
|
4400
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
4401
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
4402
|
+
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
4403
|
+
result += base64abc[bytes[i] & 63];
|
|
4404
|
+
}
|
|
4405
|
+
if (i === length + 1) {
|
|
4406
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
4407
|
+
result += base64abc[(bytes[i - 2] & 3) << 4];
|
|
4408
|
+
result += "==";
|
|
4409
|
+
}
|
|
4410
|
+
if (i === length) {
|
|
4411
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
4412
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
4413
|
+
result += base64abc[(bytes[i - 1] & 15) << 2];
|
|
4414
|
+
result += "=";
|
|
4415
|
+
}
|
|
4416
|
+
return result;
|
|
4417
|
+
};
|
|
4418
|
+
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
4419
|
+
|
|
4420
|
+
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
4421
|
+
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
4422
|
+
|
|
4423
|
+
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Encoding.js
|
|
4424
|
+
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
4425
|
+
|
|
4426
|
+
// src/core/AutoImport.ts
|
|
4427
|
+
var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
|
|
4206
4428
|
const ts = yield* service(TypeScriptApi);
|
|
4207
4429
|
const program = yield* service(TypeScriptProgram);
|
|
4208
4430
|
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
4209
4431
|
const host = program;
|
|
4210
|
-
const
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4432
|
+
const getModuleSpecifier = makeGetModuleSpecifier(ts);
|
|
4433
|
+
function collectSourceFileReexports(sourceFile) {
|
|
4434
|
+
const namespaceExports = [];
|
|
4435
|
+
const namedExports = [];
|
|
4436
|
+
for (const statement of sourceFile.statements) {
|
|
4437
|
+
if (!ts.isExportDeclaration(statement)) continue;
|
|
4438
|
+
if (!statement.exportClause) continue;
|
|
4439
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
4440
|
+
if (!moduleSpecifier) continue;
|
|
4441
|
+
if (!ts.isStringLiteral(moduleSpecifier)) continue;
|
|
4442
|
+
const exportClause = statement.exportClause;
|
|
4443
|
+
if (ts.isNamespaceExport(exportClause)) {
|
|
4444
|
+
if (!exportClause.name) continue;
|
|
4445
|
+
if (!ts.isIdentifier(exportClause.name)) continue;
|
|
4446
|
+
namespaceExports.push({
|
|
4447
|
+
moduleSpecifier,
|
|
4448
|
+
exportClause,
|
|
4449
|
+
name: exportClause.name.text
|
|
4450
|
+
});
|
|
4451
|
+
}
|
|
4452
|
+
if (ts.isNamedExports(exportClause)) {
|
|
4453
|
+
for (const exportSpecifier of exportClause.elements) {
|
|
4454
|
+
const exportName = exportSpecifier.propertyName || exportSpecifier.name;
|
|
4455
|
+
if (!ts.isIdentifier(exportName)) continue;
|
|
4456
|
+
if (!ts.isIdentifier(exportSpecifier.name)) continue;
|
|
4457
|
+
namedExports.push({
|
|
4458
|
+
moduleSpecifier,
|
|
4459
|
+
exportClause,
|
|
4460
|
+
name: exportName.text,
|
|
4461
|
+
aliasName: exportSpecifier.name.text
|
|
4462
|
+
});
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
return { namespaceExports, namedExports };
|
|
4467
|
+
}
|
|
4468
|
+
function getPackageInfo(fromFileName, packageName) {
|
|
4469
|
+
try {
|
|
4470
|
+
const packageJsonInfo = ts.resolvePackageNameToPackageJson(
|
|
4471
|
+
packageName,
|
|
4472
|
+
fromFileName,
|
|
4473
|
+
program.getCompilerOptions(),
|
|
4474
|
+
host
|
|
4475
|
+
);
|
|
4476
|
+
if (!packageJsonInfo) return;
|
|
4477
|
+
const _entrypoints = ts.getEntrypointsFromPackageJsonInfo(
|
|
4478
|
+
packageJsonInfo,
|
|
4479
|
+
program.getCompilerOptions(),
|
|
4480
|
+
host
|
|
4481
|
+
);
|
|
4482
|
+
if (!_entrypoints) return;
|
|
4483
|
+
if (!isArray(_entrypoints)) return;
|
|
4484
|
+
if (!every2(Predicate_exports.isString)) return;
|
|
4485
|
+
const entrypoints = _entrypoints.map((_) => String(_));
|
|
4486
|
+
const info = parsePackageContentNameAndVersionFromScope({ packageJsonScope: packageJsonInfo });
|
|
4487
|
+
if (!info) return { entrypoints, exportedKeys: [] };
|
|
4488
|
+
return { entrypoints, exportedKeys: info.exportsKeys };
|
|
4489
|
+
} catch (_) {
|
|
4490
|
+
return void 0;
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
const mapFromBarrelToNamespace = /* @__PURE__ */ new Map();
|
|
4494
|
+
const mapFromNamespaceToBarrel = /* @__PURE__ */ new Map();
|
|
4495
|
+
const mapFilenameToModuleAlias = /* @__PURE__ */ new Map();
|
|
4496
|
+
const mapFilenameToExportExcludes = /* @__PURE__ */ new Map();
|
|
4497
|
+
const mapFilenameToModuleName = /* @__PURE__ */ new Map();
|
|
4498
|
+
const collectModuleNames = (packageName, exportedKey) => {
|
|
4499
|
+
const appendPart = exportedKey === "." ? "" : exportedKey.startsWith("./") ? exportedKey.slice(1) : exportedKey;
|
|
4500
|
+
const absoluteName = packageName + appendPart;
|
|
4501
|
+
const absoluteFileName = ts.resolveModuleName(
|
|
4502
|
+
absoluteName,
|
|
4503
|
+
fromSourceFile.fileName,
|
|
4504
|
+
program.getCompilerOptions(),
|
|
4505
|
+
host
|
|
4506
|
+
);
|
|
4507
|
+
if (!absoluteFileName) return;
|
|
4508
|
+
if (!absoluteFileName.resolvedModule) return;
|
|
4509
|
+
const realPath = host.realpath ? host.realpath(absoluteFileName.resolvedModule.resolvedFileName) : absoluteFileName.resolvedModule.resolvedFileName;
|
|
4510
|
+
if (mapFilenameToModuleName.has(realPath)) return;
|
|
4511
|
+
mapFilenameToModuleName.set(realPath, absoluteName);
|
|
4512
|
+
};
|
|
4513
|
+
const collectImportCache = fn("TypeScriptApi")(
|
|
4514
|
+
function* (packagePatterns, kind) {
|
|
4515
|
+
for (const packagePattern of packagePatterns) {
|
|
4516
|
+
const packageNames = yield* resolveModulePattern(fromSourceFile, packagePattern);
|
|
4517
|
+
for (const packageName of packageNames) {
|
|
4518
|
+
const packageInfo = getPackageInfo(fromSourceFile.fileName, packageName);
|
|
4519
|
+
if (!packageInfo) continue;
|
|
4520
|
+
for (const exportedKey of packageInfo.exportedKeys) {
|
|
4521
|
+
collectModuleNames(packageName, exportedKey);
|
|
4522
|
+
}
|
|
4523
|
+
for (const _fileName of packageInfo.entrypoints) {
|
|
4524
|
+
const realFileName = host.realpath ? host.realpath(_fileName) : _fileName;
|
|
4525
|
+
const isPackageRoot = mapFilenameToModuleName.get(realFileName) === packageName;
|
|
4526
|
+
const barrelSourceFile = program.getSourceFile(realFileName) || ts.createSourceFile(realFileName, host.readFile(realFileName) || "", fromSourceFile.languageVersion, true);
|
|
4527
|
+
const reExports = collectSourceFileReexports(barrelSourceFile);
|
|
4528
|
+
if (!reExports) continue;
|
|
4529
|
+
if (reExports.namespaceExports.length === 0) continue;
|
|
4530
|
+
for (const namespaceReexport of reExports.namespaceExports) {
|
|
4531
|
+
const reexportedFile = ts.resolveModuleName(
|
|
4532
|
+
namespaceReexport.moduleSpecifier.text,
|
|
4533
|
+
barrelSourceFile.fileName,
|
|
4534
|
+
program.getCompilerOptions(),
|
|
4535
|
+
host
|
|
4536
|
+
);
|
|
4537
|
+
if (!reexportedFile) continue;
|
|
4538
|
+
if (!reexportedFile.resolvedModule) continue;
|
|
4539
|
+
switch (kind) {
|
|
4540
|
+
case "namespace": {
|
|
4541
|
+
mapFromBarrelToNamespace.set(
|
|
4542
|
+
barrelSourceFile.fileName,
|
|
4543
|
+
{
|
|
4544
|
+
...mapFromBarrelToNamespace.get(barrelSourceFile.fileName) || {},
|
|
4545
|
+
[namespaceReexport.name]: reexportedFile.resolvedModule.resolvedFileName
|
|
4281
4546
|
}
|
|
4282
|
-
|
|
4547
|
+
);
|
|
4548
|
+
mapFilenameToModuleAlias.set(
|
|
4549
|
+
reexportedFile.resolvedModule.resolvedFileName,
|
|
4550
|
+
namespaceReexport.name
|
|
4551
|
+
);
|
|
4552
|
+
continue;
|
|
4283
4553
|
}
|
|
4554
|
+
case "barrel": {
|
|
4555
|
+
mapFromNamespaceToBarrel.set(reexportedFile.resolvedModule.resolvedFileName, {
|
|
4556
|
+
fileName: barrelSourceFile.fileName,
|
|
4557
|
+
alias: namespaceReexport.name
|
|
4558
|
+
});
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4562
|
+
if (isPackageRoot) {
|
|
4563
|
+
for (const namedExport of reExports.namedExports) {
|
|
4564
|
+
mapFilenameToExportExcludes.set(barrelSourceFile.fileName, [
|
|
4565
|
+
...mapFilenameToExportExcludes.get(barrelSourceFile.fileName) || [],
|
|
4566
|
+
namedExport.name
|
|
4567
|
+
]);
|
|
4568
|
+
break;
|
|
4284
4569
|
}
|
|
4285
4570
|
}
|
|
4286
4571
|
}
|
|
4287
4572
|
}
|
|
4288
4573
|
}
|
|
4289
4574
|
}
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4575
|
+
);
|
|
4576
|
+
yield* collectImportCache(languageServicePluginOptions.namespaceImportPackages, "namespace");
|
|
4577
|
+
yield* collectImportCache(languageServicePluginOptions.barrelImportPackages, "barrel");
|
|
4578
|
+
const resolveModuleName = (fileName) => {
|
|
4579
|
+
const fixedModuleName = mapFilenameToModuleName.get(fileName);
|
|
4580
|
+
if (fixedModuleName) return fixedModuleName;
|
|
4581
|
+
if (!getModuleSpecifier) return fileName;
|
|
4582
|
+
const moduleSpecifier = getModuleSpecifier(
|
|
4583
|
+
program.getCompilerOptions(),
|
|
4584
|
+
fromSourceFile,
|
|
4585
|
+
fromSourceFile.fileName,
|
|
4586
|
+
fileName,
|
|
4587
|
+
host
|
|
4588
|
+
);
|
|
4589
|
+
if (!moduleSpecifier) return fileName;
|
|
4590
|
+
return moduleSpecifier;
|
|
4591
|
+
};
|
|
4592
|
+
return (exportFileName, exportName) => {
|
|
4593
|
+
const excludedExports = mapFilenameToExportExcludes.get(exportFileName);
|
|
4594
|
+
if (excludedExports && excludedExports.includes(exportName)) return;
|
|
4595
|
+
const mapToNamespace = mapFromBarrelToNamespace.get(exportFileName);
|
|
4596
|
+
if (mapToNamespace && exportName in mapToNamespace) {
|
|
4597
|
+
const namespacedFileName = mapToNamespace[exportName];
|
|
4598
|
+
if (namespacedFileName) {
|
|
4599
|
+
const introducedAlias2 = mapFilenameToModuleAlias.get(namespacedFileName);
|
|
4600
|
+
if (introducedAlias2) {
|
|
4601
|
+
return {
|
|
4602
|
+
_tag: "NamespaceImport",
|
|
4603
|
+
fileName: namespacedFileName,
|
|
4604
|
+
moduleName: resolveModuleName(namespacedFileName),
|
|
4605
|
+
name: introducedAlias2,
|
|
4606
|
+
introducedPrefix: void 0
|
|
4607
|
+
};
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4611
|
+
const introducedAlias = mapFilenameToModuleAlias.get(exportFileName);
|
|
4612
|
+
if (introducedAlias) {
|
|
4613
|
+
return {
|
|
4614
|
+
_tag: "NamespaceImport",
|
|
4615
|
+
fileName: exportFileName,
|
|
4616
|
+
moduleName: resolveModuleName(exportFileName),
|
|
4617
|
+
name: introducedAlias,
|
|
4618
|
+
introducedPrefix: introducedAlias
|
|
4619
|
+
};
|
|
4620
|
+
}
|
|
4621
|
+
const mapToBarrel = mapFromNamespaceToBarrel.get(exportFileName);
|
|
4622
|
+
if (mapToBarrel) {
|
|
4623
|
+
return {
|
|
4624
|
+
_tag: "NamedImport",
|
|
4625
|
+
fileName: mapToBarrel.fileName,
|
|
4626
|
+
moduleName: resolveModuleName(mapToBarrel.fileName),
|
|
4627
|
+
name: mapToBarrel.alias,
|
|
4628
|
+
introducedPrefix: mapToBarrel.alias
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4297
4631
|
};
|
|
4298
4632
|
});
|
|
4633
|
+
|
|
4634
|
+
// src/completions/middlewareAutoImports.ts
|
|
4635
|
+
var importProvidersCache = /* @__PURE__ */ new Map();
|
|
4299
4636
|
var appendEffectCompletionEntryData = fn("appendEffectCompletionEntryData")(
|
|
4300
4637
|
function* (_sourceFile, applicableCompletions) {
|
|
4301
4638
|
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
@@ -4349,8 +4686,9 @@ var isAutoImportOnlyCodeActions = fn("isAutoImportOnlyCodeActions")(
|
|
|
4349
4686
|
}
|
|
4350
4687
|
}
|
|
4351
4688
|
);
|
|
4352
|
-
var
|
|
4689
|
+
var addImportCodeAction = fn("getImportFromNamespaceCodeActions")(function* (formatOptions, preferences, languageServiceHost, sourceFile, effectReplaceSpan, effectAutoImport) {
|
|
4353
4690
|
const ts = yield* service(TypeScriptApi);
|
|
4691
|
+
let description = "auto-import";
|
|
4354
4692
|
const formatContext = ts.formatting.getFormatContext(
|
|
4355
4693
|
formatOptions || {},
|
|
4356
4694
|
languageServiceHost
|
|
@@ -4362,113 +4700,104 @@ var getImportFromNamespaceCodeActions = fn("getImportFromNamespaceCodeActions")(
|
|
|
4362
4700
|
preferences: preferences || {}
|
|
4363
4701
|
},
|
|
4364
4702
|
(changeTracker) => {
|
|
4365
|
-
|
|
4366
|
-
changeTracker,
|
|
4367
|
-
sourceFile,
|
|
4368
|
-
ts.factory.createImportDeclaration(
|
|
4369
|
-
void 0,
|
|
4370
|
-
ts.factory.createImportClause(
|
|
4371
|
-
false,
|
|
4372
|
-
void 0,
|
|
4373
|
-
ts.factory.createNamespaceImport(ts.factory.createIdentifier(effectNamespaceName))
|
|
4374
|
-
),
|
|
4375
|
-
ts.factory.createStringLiteral(newModuleSpecifier)
|
|
4376
|
-
),
|
|
4377
|
-
true,
|
|
4378
|
-
preferences || {}
|
|
4379
|
-
);
|
|
4380
|
-
if (!effectUnbarreledModulePath) {
|
|
4703
|
+
if (effectAutoImport.introducedPrefix) {
|
|
4381
4704
|
changeTracker.insertText(
|
|
4382
4705
|
sourceFile,
|
|
4383
4706
|
effectReplaceSpan.start,
|
|
4384
|
-
|
|
4707
|
+
effectAutoImport.introducedPrefix + "."
|
|
4385
4708
|
);
|
|
4386
4709
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
const
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4710
|
+
switch (effectAutoImport._tag) {
|
|
4711
|
+
case "NamespaceImport": {
|
|
4712
|
+
const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
|
|
4713
|
+
description = `Import * as ${effectAutoImport.name} from "${importModule}"`;
|
|
4714
|
+
ts.insertImports(
|
|
4715
|
+
changeTracker,
|
|
4716
|
+
sourceFile,
|
|
4717
|
+
ts.factory.createImportDeclaration(
|
|
4718
|
+
void 0,
|
|
4719
|
+
ts.factory.createImportClause(
|
|
4720
|
+
false,
|
|
4721
|
+
void 0,
|
|
4722
|
+
ts.factory.createNamespaceImport(ts.factory.createIdentifier(effectAutoImport.name))
|
|
4723
|
+
),
|
|
4724
|
+
ts.factory.createStringLiteral(importModule)
|
|
4725
|
+
),
|
|
4726
|
+
true,
|
|
4727
|
+
preferences || {}
|
|
4728
|
+
);
|
|
4729
|
+
break;
|
|
4730
|
+
}
|
|
4731
|
+
case "NamedImport": {
|
|
4732
|
+
const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
|
|
4733
|
+
description = `Import { ${effectAutoImport.name} } from "${importModule}"`;
|
|
4734
|
+
let foundImportDeclaration = false;
|
|
4735
|
+
for (const statement of sourceFile.statements) {
|
|
4736
|
+
if (ts.isImportDeclaration(statement)) {
|
|
4737
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
4738
|
+
if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier) && moduleSpecifier.text === importModule) {
|
|
4739
|
+
const importClause = statement.importClause;
|
|
4740
|
+
if (importClause && importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
|
|
4741
|
+
const namedImports = importClause.namedBindings;
|
|
4742
|
+
const existingImportSpecifier = namedImports.elements.find(
|
|
4743
|
+
(element) => element.name.text === effectAutoImport.name
|
|
4744
|
+
);
|
|
4745
|
+
if (existingImportSpecifier) {
|
|
4746
|
+
foundImportDeclaration = true;
|
|
4747
|
+
break;
|
|
4748
|
+
}
|
|
4749
|
+
changeTracker.replaceNode(
|
|
4750
|
+
sourceFile,
|
|
4751
|
+
namedImports,
|
|
4752
|
+
ts.factory.createNamedImports(
|
|
4753
|
+
namedImports.elements.concat([
|
|
4754
|
+
ts.factory.createImportSpecifier(
|
|
4755
|
+
false,
|
|
4756
|
+
void 0,
|
|
4757
|
+
ts.factory.createIdentifier(effectAutoImport.name)
|
|
4758
|
+
)
|
|
4759
|
+
])
|
|
4760
|
+
)
|
|
4761
|
+
);
|
|
4762
|
+
foundImportDeclaration = true;
|
|
4763
|
+
break;
|
|
4764
|
+
}
|
|
4423
4765
|
}
|
|
4424
|
-
changeTracker.replaceNode(
|
|
4425
|
-
sourceFile,
|
|
4426
|
-
namedImports,
|
|
4427
|
-
ts.factory.createNamedImports(
|
|
4428
|
-
namedImports.elements.concat([
|
|
4429
|
-
ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier(barrelExportName))
|
|
4430
|
-
])
|
|
4431
|
-
)
|
|
4432
|
-
);
|
|
4433
|
-
foundImportDeclaration = true;
|
|
4434
|
-
break;
|
|
4435
4766
|
}
|
|
4436
4767
|
}
|
|
4768
|
+
if (!foundImportDeclaration) {
|
|
4769
|
+
ts.insertImports(
|
|
4770
|
+
changeTracker,
|
|
4771
|
+
sourceFile,
|
|
4772
|
+
ts.factory.createImportDeclaration(
|
|
4773
|
+
void 0,
|
|
4774
|
+
ts.factory.createImportClause(
|
|
4775
|
+
false,
|
|
4776
|
+
void 0,
|
|
4777
|
+
ts.factory.createNamedImports(
|
|
4778
|
+
[
|
|
4779
|
+
ts.factory.createImportSpecifier(
|
|
4780
|
+
false,
|
|
4781
|
+
void 0,
|
|
4782
|
+
ts.factory.createIdentifier(effectAutoImport.name)
|
|
4783
|
+
)
|
|
4784
|
+
]
|
|
4785
|
+
)
|
|
4786
|
+
),
|
|
4787
|
+
ts.factory.createStringLiteral(importModule)
|
|
4788
|
+
),
|
|
4789
|
+
true,
|
|
4790
|
+
preferences || {}
|
|
4791
|
+
);
|
|
4792
|
+
}
|
|
4793
|
+
break;
|
|
4437
4794
|
}
|
|
4438
4795
|
}
|
|
4439
|
-
if (!foundImportDeclaration) {
|
|
4440
|
-
ts.insertImports(
|
|
4441
|
-
changeTracker,
|
|
4442
|
-
sourceFile,
|
|
4443
|
-
ts.factory.createImportDeclaration(
|
|
4444
|
-
void 0,
|
|
4445
|
-
ts.factory.createImportClause(
|
|
4446
|
-
false,
|
|
4447
|
-
void 0,
|
|
4448
|
-
ts.factory.createNamedImports(
|
|
4449
|
-
[
|
|
4450
|
-
ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier(barrelExportName))
|
|
4451
|
-
]
|
|
4452
|
-
)
|
|
4453
|
-
),
|
|
4454
|
-
ts.factory.createStringLiteral(newModuleSpecifier)
|
|
4455
|
-
),
|
|
4456
|
-
true,
|
|
4457
|
-
preferences || {}
|
|
4458
|
-
);
|
|
4459
|
-
}
|
|
4460
|
-
if (shouldPrependExportName) {
|
|
4461
|
-
changeTracker.insertText(
|
|
4462
|
-
sourceFile,
|
|
4463
|
-
effectReplaceSpan.start,
|
|
4464
|
-
barrelExportName + "."
|
|
4465
|
-
);
|
|
4466
|
-
}
|
|
4467
4796
|
}
|
|
4468
4797
|
);
|
|
4469
4798
|
return [
|
|
4470
4799
|
{
|
|
4471
|
-
description
|
|
4800
|
+
description,
|
|
4472
4801
|
changes
|
|
4473
4802
|
}
|
|
4474
4803
|
];
|
|
@@ -4477,10 +4806,6 @@ var postprocessCompletionEntryDetails = fn("postprocessCompletionEntryDetails")(
|
|
|
4477
4806
|
function* (sourceFile, data, applicableCompletionEntryDetails, formatOptions, preferences, languageServiceHost) {
|
|
4478
4807
|
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
4479
4808
|
if (languageServicePluginOptions.namespaceImportPackages.length === 0 && languageServicePluginOptions.barrelImportPackages.length === 0) return applicableCompletionEntryDetails;
|
|
4480
|
-
const ts = yield* service(TypeScriptApi);
|
|
4481
|
-
const program = yield* service(TypeScriptProgram);
|
|
4482
|
-
const getModuleSpecifier = makeGetModuleSpecifier(ts);
|
|
4483
|
-
if (!getModuleSpecifier) return applicableCompletionEntryDetails;
|
|
4484
4809
|
if (!applicableCompletionEntryDetails) return applicableCompletionEntryDetails;
|
|
4485
4810
|
if (!data) return applicableCompletionEntryDetails;
|
|
4486
4811
|
const { exportName, fileName, moduleSpecifier } = data;
|
|
@@ -4495,78 +4820,22 @@ var postprocessCompletionEntryDetails = fn("postprocessCompletionEntryDetails")(
|
|
|
4495
4820
|
exportName
|
|
4496
4821
|
);
|
|
4497
4822
|
if (!result) return applicableCompletionEntryDetails;
|
|
4498
|
-
const packagesMetadata =
|
|
4499
|
-
|
|
4500
|
-
const
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
preferences,
|
|
4510
|
-
languageServiceHost,
|
|
4511
|
-
sourceFile,
|
|
4512
|
-
effectReplaceSpan,
|
|
4513
|
-
asBarrelFunctionImport.packageName,
|
|
4514
|
-
asBarrelFunctionImport.exportName,
|
|
4515
|
-
false
|
|
4516
|
-
);
|
|
4517
|
-
return {
|
|
4518
|
-
...applicableCompletionEntryDetails,
|
|
4519
|
-
codeActions
|
|
4520
|
-
};
|
|
4521
|
-
}
|
|
4522
|
-
const asBarrelModuleImport = packagesMetadata.getBarreledModulePath(fileName);
|
|
4523
|
-
if (asBarrelModuleImport) {
|
|
4524
|
-
const codeActions = yield* getImportFromBarrelCodeActions(
|
|
4525
|
-
formatOptions,
|
|
4526
|
-
preferences,
|
|
4527
|
-
languageServiceHost,
|
|
4528
|
-
sourceFile,
|
|
4529
|
-
effectReplaceSpan,
|
|
4530
|
-
asBarrelModuleImport.packageName,
|
|
4531
|
-
asBarrelModuleImport.exportName,
|
|
4532
|
-
true
|
|
4533
|
-
);
|
|
4534
|
-
return {
|
|
4535
|
-
...applicableCompletionEntryDetails,
|
|
4536
|
-
codeActions
|
|
4537
|
-
};
|
|
4538
|
-
}
|
|
4539
|
-
const effectUnbarreledModulePath = packagesMetadata.getUnbarreledModulePath(
|
|
4540
|
-
fileName,
|
|
4541
|
-
exportName
|
|
4542
|
-
);
|
|
4543
|
-
const asNamespaceImport = packagesMetadata.getImportNamespaceByFileName(
|
|
4544
|
-
effectUnbarreledModulePath || fileName
|
|
4823
|
+
const packagesMetadata = importProvidersCache.get(sourceFile.fileName) || (yield* makeAutoImportProvider(sourceFile));
|
|
4824
|
+
importProvidersCache.set(sourceFile.fileName, packagesMetadata);
|
|
4825
|
+
const effectAutoImport = packagesMetadata(fileName, exportName);
|
|
4826
|
+
if (!effectAutoImport) return applicableCompletionEntryDetails;
|
|
4827
|
+
const codeActions = yield* addImportCodeAction(
|
|
4828
|
+
formatOptions,
|
|
4829
|
+
preferences,
|
|
4830
|
+
languageServiceHost,
|
|
4831
|
+
sourceFile,
|
|
4832
|
+
effectReplaceSpan,
|
|
4833
|
+
effectAutoImport
|
|
4545
4834
|
);
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
sourceFile.fileName,
|
|
4551
|
-
String(effectUnbarreledModulePath || fileName),
|
|
4552
|
-
program
|
|
4553
|
-
) : moduleSpecifier;
|
|
4554
|
-
const codeActions = yield* getImportFromNamespaceCodeActions(
|
|
4555
|
-
formatOptions,
|
|
4556
|
-
preferences,
|
|
4557
|
-
languageServiceHost,
|
|
4558
|
-
sourceFile,
|
|
4559
|
-
effectReplaceSpan,
|
|
4560
|
-
asNamespaceImport,
|
|
4561
|
-
effectUnbarreledModulePath,
|
|
4562
|
-
newModuleSpecifier
|
|
4563
|
-
);
|
|
4564
|
-
return {
|
|
4565
|
-
...applicableCompletionEntryDetails,
|
|
4566
|
-
codeActions
|
|
4567
|
-
};
|
|
4568
|
-
}
|
|
4569
|
-
return applicableCompletionEntryDetails;
|
|
4835
|
+
return {
|
|
4836
|
+
...applicableCompletionEntryDetails,
|
|
4837
|
+
codeActions
|
|
4838
|
+
};
|
|
4570
4839
|
}
|
|
4571
4840
|
);
|
|
4572
4841
|
|
|
@@ -4793,41 +5062,6 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
4793
5062
|
);
|
|
4794
5063
|
}
|
|
4795
5064
|
|
|
4796
|
-
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
4797
|
-
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
4798
|
-
|
|
4799
|
-
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
4800
|
-
var encode = (bytes) => {
|
|
4801
|
-
const length = bytes.length;
|
|
4802
|
-
let result = "";
|
|
4803
|
-
let i;
|
|
4804
|
-
for (i = 2; i < length; i += 3) {
|
|
4805
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
4806
|
-
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
4807
|
-
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
4808
|
-
result += base64abc[bytes[i] & 63];
|
|
4809
|
-
}
|
|
4810
|
-
if (i === length + 1) {
|
|
4811
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
4812
|
-
result += base64abc[(bytes[i - 2] & 3) << 4];
|
|
4813
|
-
result += "==";
|
|
4814
|
-
}
|
|
4815
|
-
if (i === length) {
|
|
4816
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
4817
|
-
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
4818
|
-
result += base64abc[(bytes[i - 1] & 15) << 2];
|
|
4819
|
-
result += "=";
|
|
4820
|
-
}
|
|
4821
|
-
return result;
|
|
4822
|
-
};
|
|
4823
|
-
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
4824
|
-
|
|
4825
|
-
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
4826
|
-
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
4827
|
-
|
|
4828
|
-
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Encoding.js
|
|
4829
|
-
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
4830
|
-
|
|
4831
5065
|
// node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs
|
|
4832
5066
|
var Z_FIXED$1 = 4;
|
|
4833
5067
|
var Z_BINARY = 0;
|
|
@@ -9048,7 +9282,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
9048
9282
|
const maybeLayer = yield* option(typeParser.layerType(type, node));
|
|
9049
9283
|
if (isSome2(maybeLayer)) {
|
|
9050
9284
|
const argNodes = yield* option(
|
|
9051
|
-
|
|
9285
|
+
all2(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
|
|
9052
9286
|
);
|
|
9053
9287
|
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
9054
9288
|
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
@@ -9092,7 +9326,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
9092
9326
|
);
|
|
9093
9327
|
if (ts.isCallExpression(node)) {
|
|
9094
9328
|
const argNodes = yield* option(
|
|
9095
|
-
|
|
9329
|
+
all2(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
|
|
9096
9330
|
);
|
|
9097
9331
|
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
9098
9332
|
return new GraphNodeCompoundTransform(
|
|
@@ -9222,7 +9456,7 @@ function processNodeMermaid(graph, ctx, ctxL) {
|
|
|
9222
9456
|
return subgraphDefs;
|
|
9223
9457
|
}
|
|
9224
9458
|
case "GraphNodeCompoundTransform": {
|
|
9225
|
-
const childs = flatten(yield*
|
|
9459
|
+
const childs = flatten(yield* all2(...graph.args.map((_) => processNodeMermaid(_, ctx, ctxL))));
|
|
9226
9460
|
let currentEdges = [];
|
|
9227
9461
|
const connectedNodes = /* @__PURE__ */ new Set();
|
|
9228
9462
|
for (const requiredServiceKey of graph.rin) {
|
|
@@ -10007,7 +10241,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
10007
10241
|
for (let i = 0; i < callSignatures.length; i++) {
|
|
10008
10242
|
const callSignature = callSignatures[i];
|
|
10009
10243
|
if (callSignature.parameters.length === node2.arguments.length + 1) {
|
|
10010
|
-
return
|
|
10244
|
+
return some3(
|
|
10011
10245
|
ts.factory.createCallExpression(
|
|
10012
10246
|
node2.expression,
|
|
10013
10247
|
[],
|
|
@@ -10049,7 +10283,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
10049
10283
|
}
|
|
10050
10284
|
}
|
|
10051
10285
|
}
|
|
10052
|
-
return didSomething ?
|
|
10286
|
+
return didSomething ? some3([node2, newNode2]) : none2();
|
|
10053
10287
|
}),
|
|
10054
10288
|
filter(isSome2),
|
|
10055
10289
|
map3((_) => _.value),
|
|
@@ -10377,17 +10611,17 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
|
|
|
10377
10611
|
case "Pick":
|
|
10378
10612
|
case "Omit":
|
|
10379
10613
|
case "Record":
|
|
10380
|
-
return
|
|
10614
|
+
return some3(name.text);
|
|
10381
10615
|
case "ReadonlyArray":
|
|
10382
10616
|
case "Array":
|
|
10383
|
-
return
|
|
10617
|
+
return some3("Array");
|
|
10384
10618
|
}
|
|
10385
10619
|
return none2();
|
|
10386
10620
|
}
|
|
10387
10621
|
if (!ts.isIdentifier(name.left)) return none2();
|
|
10388
10622
|
for (const moduleName in moduleToImportedName) {
|
|
10389
10623
|
if (name.left.text === moduleToImportedName[moduleName] && name.right.text === moduleName) {
|
|
10390
|
-
return
|
|
10624
|
+
return some3(moduleName);
|
|
10391
10625
|
}
|
|
10392
10626
|
}
|
|
10393
10627
|
return none2();
|
|
@@ -10426,7 +10660,7 @@ var parseAllLiterals = fn(
|
|
|
10426
10660
|
}
|
|
10427
10661
|
}
|
|
10428
10662
|
if (ts.isUnionTypeNode(node)) {
|
|
10429
|
-
return flatten(yield*
|
|
10663
|
+
return flatten(yield* all2(...node.types.map((_) => parseAllLiterals(_))));
|
|
10430
10664
|
}
|
|
10431
10665
|
if (ts.isParenthesizedTypeNode(node)) {
|
|
10432
10666
|
return yield* parseAllLiterals(node.type);
|
|
@@ -10473,11 +10707,11 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
|
|
|
10473
10707
|
if (ts.isUnionTypeNode(node)) {
|
|
10474
10708
|
const allLiterals = yield* option(parseAllLiterals(node));
|
|
10475
10709
|
if (isSome2(allLiterals)) return createApiCall("Literal", allLiterals.value);
|
|
10476
|
-
const members = yield*
|
|
10710
|
+
const members = yield* all2(...node.types.map((_) => processNode(_, isVirtualTypeNode)));
|
|
10477
10711
|
return createApiCall("Union", members);
|
|
10478
10712
|
}
|
|
10479
10713
|
if (ts.isIntersectionTypeNode(node)) {
|
|
10480
|
-
const [firstSchema, ...otherSchemas] = yield*
|
|
10714
|
+
const [firstSchema, ...otherSchemas] = yield* all2(
|
|
10481
10715
|
...node.types.map((_) => processNode(_, isVirtualTypeNode))
|
|
10482
10716
|
);
|
|
10483
10717
|
if (otherSchemas.length === 0) return firstSchema;
|
|
@@ -10533,13 +10767,13 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
|
|
|
10533
10767
|
case "Option":
|
|
10534
10768
|
case "Chunk":
|
|
10535
10769
|
case "Array": {
|
|
10536
|
-
const elements = yield*
|
|
10770
|
+
const elements = yield* all2(
|
|
10537
10771
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
10538
10772
|
);
|
|
10539
10773
|
return createApiCall(parsedName.value, elements);
|
|
10540
10774
|
}
|
|
10541
10775
|
case "Record": {
|
|
10542
|
-
const elements = yield*
|
|
10776
|
+
const elements = yield* all2(
|
|
10543
10777
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
10544
10778
|
);
|
|
10545
10779
|
if (elements.length >= 2) {
|
|
@@ -10553,7 +10787,7 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
|
|
|
10553
10787
|
return createUnsupportedNodeComment(ts, sourceFile, node);
|
|
10554
10788
|
}
|
|
10555
10789
|
case "Either": {
|
|
10556
|
-
const elements = yield*
|
|
10790
|
+
const elements = yield* all2(
|
|
10557
10791
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
10558
10792
|
);
|
|
10559
10793
|
if (elements.length >= 2) {
|
|
@@ -10891,6 +11125,273 @@ var wrapWithPipe = createRefactor({
|
|
|
10891
11125
|
})
|
|
10892
11126
|
});
|
|
10893
11127
|
|
|
11128
|
+
// src/refactors/writeTagClassAccessors.ts
|
|
11129
|
+
var writeTagClassAccessors = createRefactor({
|
|
11130
|
+
name: "writeTagClassAccessors",
|
|
11131
|
+
description: "Implement Service accessors",
|
|
11132
|
+
apply: fn("writeTagClassAccessors.apply")(function* (sourceFile, textRange) {
|
|
11133
|
+
const ts = yield* service(TypeScriptApi);
|
|
11134
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
11135
|
+
const typeParser = yield* service(TypeParser);
|
|
11136
|
+
const effectIdentifier = pipe(
|
|
11137
|
+
yield* option(
|
|
11138
|
+
findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect")
|
|
11139
|
+
),
|
|
11140
|
+
match({
|
|
11141
|
+
onNone: () => "Effect",
|
|
11142
|
+
onSome: (_) => _.text
|
|
11143
|
+
})
|
|
11144
|
+
);
|
|
11145
|
+
const createConstantProperty = (className, propertyName, type) => ts.factory.createPropertyDeclaration(
|
|
11146
|
+
[ts.factory.createModifier(ts.SyntaxKind.StaticKeyword)],
|
|
11147
|
+
propertyName,
|
|
11148
|
+
void 0,
|
|
11149
|
+
type,
|
|
11150
|
+
ts.factory.createCallExpression(
|
|
11151
|
+
ts.factory.createPropertyAccessExpression(
|
|
11152
|
+
ts.factory.createIdentifier(effectIdentifier),
|
|
11153
|
+
"andThen"
|
|
11154
|
+
),
|
|
11155
|
+
void 0,
|
|
11156
|
+
[
|
|
11157
|
+
ts.factory.createIdentifier(className.text),
|
|
11158
|
+
ts.factory.createArrowFunction(
|
|
11159
|
+
void 0,
|
|
11160
|
+
void 0,
|
|
11161
|
+
[ts.factory.createParameterDeclaration(
|
|
11162
|
+
void 0,
|
|
11163
|
+
void 0,
|
|
11164
|
+
"_"
|
|
11165
|
+
)],
|
|
11166
|
+
void 0,
|
|
11167
|
+
void 0,
|
|
11168
|
+
ts.factory.createPropertyAccessExpression(
|
|
11169
|
+
ts.factory.createIdentifier("_"),
|
|
11170
|
+
propertyName
|
|
11171
|
+
)
|
|
11172
|
+
)
|
|
11173
|
+
]
|
|
11174
|
+
)
|
|
11175
|
+
);
|
|
11176
|
+
const createFunctionProperty = (className, propertyName, type, forceAny) => {
|
|
11177
|
+
const arrowBody = ts.factory.createCallExpression(
|
|
11178
|
+
ts.factory.createPropertyAccessExpression(
|
|
11179
|
+
ts.factory.createIdentifier(effectIdentifier),
|
|
11180
|
+
"andThen"
|
|
11181
|
+
),
|
|
11182
|
+
void 0,
|
|
11183
|
+
[
|
|
11184
|
+
ts.factory.createIdentifier(className.text),
|
|
11185
|
+
ts.factory.createArrowFunction(
|
|
11186
|
+
void 0,
|
|
11187
|
+
void 0,
|
|
11188
|
+
[ts.factory.createParameterDeclaration(
|
|
11189
|
+
void 0,
|
|
11190
|
+
void 0,
|
|
11191
|
+
"_",
|
|
11192
|
+
void 0,
|
|
11193
|
+
forceAny ? ts.factory.createTypeReferenceNode("any") : void 0
|
|
11194
|
+
)],
|
|
11195
|
+
void 0,
|
|
11196
|
+
void 0,
|
|
11197
|
+
ts.factory.createCallExpression(
|
|
11198
|
+
ts.factory.createPropertyAccessExpression(
|
|
11199
|
+
ts.factory.createIdentifier("_"),
|
|
11200
|
+
propertyName
|
|
11201
|
+
),
|
|
11202
|
+
void 0,
|
|
11203
|
+
[
|
|
11204
|
+
ts.factory.createSpreadElement(ts.factory.createIdentifier("args"))
|
|
11205
|
+
]
|
|
11206
|
+
)
|
|
11207
|
+
)
|
|
11208
|
+
]
|
|
11209
|
+
);
|
|
11210
|
+
return ts.factory.createPropertyDeclaration(
|
|
11211
|
+
[ts.factory.createModifier(ts.SyntaxKind.StaticKeyword)],
|
|
11212
|
+
propertyName,
|
|
11213
|
+
void 0,
|
|
11214
|
+
type,
|
|
11215
|
+
ts.factory.createArrowFunction(
|
|
11216
|
+
void 0,
|
|
11217
|
+
void 0,
|
|
11218
|
+
[ts.factory.createParameterDeclaration(
|
|
11219
|
+
void 0,
|
|
11220
|
+
ts.factory.createToken(ts.SyntaxKind.DotDotDotToken),
|
|
11221
|
+
"args",
|
|
11222
|
+
void 0,
|
|
11223
|
+
forceAny ? ts.factory.createArrayTypeNode(ts.factory.createTypeReferenceNode("any")) : void 0
|
|
11224
|
+
)],
|
|
11225
|
+
void 0,
|
|
11226
|
+
void 0,
|
|
11227
|
+
forceAny ? ts.factory.createAsExpression(arrowBody, ts.factory.createTypeReferenceNode("any")) : arrowBody
|
|
11228
|
+
)
|
|
11229
|
+
);
|
|
11230
|
+
};
|
|
11231
|
+
const generateReturnType = (type, atLocation, className) => pipe(
|
|
11232
|
+
typeParser.effectType(type, atLocation),
|
|
11233
|
+
flatMap2((returnedEffect) => {
|
|
11234
|
+
const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(className.text) : ts.factory.createUnionTypeNode(
|
|
11235
|
+
[
|
|
11236
|
+
ts.factory.createTypeReferenceNode(className.text),
|
|
11237
|
+
typeChecker.typeToTypeNode(returnedEffect.R, atLocation, ts.NodeBuilderFlags.NoTruncation)
|
|
11238
|
+
]
|
|
11239
|
+
);
|
|
11240
|
+
const successType = typeChecker.typeToTypeNode(
|
|
11241
|
+
returnedEffect.A,
|
|
11242
|
+
atLocation,
|
|
11243
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
11244
|
+
);
|
|
11245
|
+
if (!successType) return fail("error generating success type");
|
|
11246
|
+
const failureType = typeChecker.typeToTypeNode(
|
|
11247
|
+
returnedEffect.E,
|
|
11248
|
+
atLocation,
|
|
11249
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
11250
|
+
);
|
|
11251
|
+
if (!failureType) return fail("error generating failure type");
|
|
11252
|
+
const typeNode = ts.factory.createTypeReferenceNode(
|
|
11253
|
+
ts.factory.createQualifiedName(
|
|
11254
|
+
ts.factory.createIdentifier(effectIdentifier),
|
|
11255
|
+
ts.factory.createIdentifier("Effect")
|
|
11256
|
+
),
|
|
11257
|
+
[successType, failureType, contextType]
|
|
11258
|
+
);
|
|
11259
|
+
return succeed(typeNode);
|
|
11260
|
+
}),
|
|
11261
|
+
orElse2(
|
|
11262
|
+
() => pipe(
|
|
11263
|
+
typeParser.promiseLike(type, atLocation),
|
|
11264
|
+
flatMap2(({ type: type2 }) => {
|
|
11265
|
+
const successType = typeChecker.typeToTypeNode(
|
|
11266
|
+
type2,
|
|
11267
|
+
atLocation,
|
|
11268
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
11269
|
+
);
|
|
11270
|
+
if (!successType) return fail("error generating success type");
|
|
11271
|
+
return succeed(ts.factory.createTypeReferenceNode(
|
|
11272
|
+
ts.factory.createQualifiedName(
|
|
11273
|
+
ts.factory.createIdentifier(effectIdentifier),
|
|
11274
|
+
ts.factory.createIdentifier("Effect")
|
|
11275
|
+
),
|
|
11276
|
+
[
|
|
11277
|
+
successType,
|
|
11278
|
+
ts.factory.createTypeReferenceNode(
|
|
11279
|
+
ts.factory.createQualifiedName(
|
|
11280
|
+
ts.factory.createIdentifier("Cause"),
|
|
11281
|
+
ts.factory.createIdentifier("UnknownException")
|
|
11282
|
+
)
|
|
11283
|
+
),
|
|
11284
|
+
ts.factory.createTypeReferenceNode(className.text)
|
|
11285
|
+
]
|
|
11286
|
+
));
|
|
11287
|
+
})
|
|
11288
|
+
)
|
|
11289
|
+
),
|
|
11290
|
+
orElse2(() => {
|
|
11291
|
+
const successType = typeChecker.typeToTypeNode(type, atLocation, ts.NodeBuilderFlags.NoTruncation);
|
|
11292
|
+
if (!successType) return fail("error generating success type");
|
|
11293
|
+
const typeNode = ts.factory.createTypeReferenceNode(
|
|
11294
|
+
ts.factory.createQualifiedName(
|
|
11295
|
+
ts.factory.createIdentifier(effectIdentifier),
|
|
11296
|
+
ts.factory.createIdentifier("Effect")
|
|
11297
|
+
),
|
|
11298
|
+
[
|
|
11299
|
+
successType,
|
|
11300
|
+
ts.factory.createTypeReferenceNode("never"),
|
|
11301
|
+
ts.factory.createTypeReferenceNode(className.text)
|
|
11302
|
+
]
|
|
11303
|
+
);
|
|
11304
|
+
return succeed(typeNode);
|
|
11305
|
+
})
|
|
11306
|
+
);
|
|
11307
|
+
const proxySignature = (signature, atLocation, className) => gen(function* () {
|
|
11308
|
+
const signatureDeclaration = typeChecker.signatureToSignatureDeclaration(
|
|
11309
|
+
signature,
|
|
11310
|
+
ts.SyntaxKind.FunctionType,
|
|
11311
|
+
atLocation,
|
|
11312
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
11313
|
+
);
|
|
11314
|
+
if (!signatureDeclaration) return yield* fail("error generating signature");
|
|
11315
|
+
const returnType = yield* generateReturnType(signature.getReturnType(), atLocation, className);
|
|
11316
|
+
return ts.factory.createFunctionTypeNode(
|
|
11317
|
+
signatureDeclaration.typeParameters,
|
|
11318
|
+
signatureDeclaration.parameters,
|
|
11319
|
+
returnType
|
|
11320
|
+
);
|
|
11321
|
+
});
|
|
11322
|
+
const writeAccessors = fn("writeTagClassAccessors.writeAccessors")(
|
|
11323
|
+
function* (service2, className, atLocation) {
|
|
11324
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
11325
|
+
const insertLocation = atLocation.members.length > 0 ? atLocation.members[0].pos : atLocation.getEnd() - 1;
|
|
11326
|
+
for (const property of typeChecker.getPropertiesOfType(service2)) {
|
|
11327
|
+
const servicePropertyType = typeChecker.getTypeOfSymbolAtLocation(property, atLocation);
|
|
11328
|
+
const callSignatures = [];
|
|
11329
|
+
let propertyDeclaration = void 0;
|
|
11330
|
+
for (const signature of servicePropertyType.getCallSignatures()) {
|
|
11331
|
+
yield* pipe(
|
|
11332
|
+
proxySignature(signature, atLocation, className),
|
|
11333
|
+
map4((sig) => {
|
|
11334
|
+
callSignatures.push(sig);
|
|
11335
|
+
}),
|
|
11336
|
+
ignore
|
|
11337
|
+
);
|
|
11338
|
+
}
|
|
11339
|
+
if (callSignatures.length === 0) {
|
|
11340
|
+
yield* pipe(
|
|
11341
|
+
generateReturnType(servicePropertyType, atLocation, className),
|
|
11342
|
+
map4((type) => {
|
|
11343
|
+
propertyDeclaration = createConstantProperty(className, property.getName(), type);
|
|
11344
|
+
}),
|
|
11345
|
+
ignore
|
|
11346
|
+
);
|
|
11347
|
+
} else {
|
|
11348
|
+
const allSignatures = ts.factory.createIntersectionTypeNode(callSignatures);
|
|
11349
|
+
const type = yield* simplifyTypeNode(allSignatures);
|
|
11350
|
+
propertyDeclaration = createFunctionProperty(className, property.getName(), type, callSignatures.length > 1);
|
|
11351
|
+
}
|
|
11352
|
+
if (propertyDeclaration) {
|
|
11353
|
+
const oldProperty = atLocation.members.filter(ts.isPropertyDeclaration).find((p) => {
|
|
11354
|
+
const symbol3 = typeChecker.getSymbolAtLocation(p.name);
|
|
11355
|
+
return symbol3?.getName() === property.getName();
|
|
11356
|
+
});
|
|
11357
|
+
if (oldProperty) {
|
|
11358
|
+
changeTracker.deleteRange(sourceFile, {
|
|
11359
|
+
pos: oldProperty.getStart(sourceFile),
|
|
11360
|
+
end: oldProperty.getEnd()
|
|
11361
|
+
});
|
|
11362
|
+
changeTracker.insertNodeAt(sourceFile, oldProperty.getStart(sourceFile), propertyDeclaration);
|
|
11363
|
+
} else {
|
|
11364
|
+
changeTracker.insertNodeAt(sourceFile, insertLocation, propertyDeclaration, { suffix: "\n" });
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
}
|
|
11368
|
+
}
|
|
11369
|
+
);
|
|
11370
|
+
const writeTagClassAccessors2 = (node) => gen(function* () {
|
|
11371
|
+
if (!ts.isClassDeclaration(node)) return yield* fail(new RefactorNotApplicableError());
|
|
11372
|
+
if (!node.name) return yield* fail(new RefactorNotApplicableError());
|
|
11373
|
+
const classSym = typeChecker.getSymbolAtLocation(node.name);
|
|
11374
|
+
if (!classSym) return yield* fail(new RefactorNotApplicableError());
|
|
11375
|
+
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
11376
|
+
const { Service } = yield* pipe(
|
|
11377
|
+
typeParser.contextTag(type, node),
|
|
11378
|
+
orElse2(() => fail(new RefactorNotApplicableError()))
|
|
11379
|
+
);
|
|
11380
|
+
return {
|
|
11381
|
+
kind: "refactor.rewrite.effect.writeTagClassAccessors",
|
|
11382
|
+
description: "Implement Service accessors",
|
|
11383
|
+
apply: pipe(
|
|
11384
|
+
writeAccessors(Service, node.name, node),
|
|
11385
|
+
provideService(TypeCheckerApi, typeChecker),
|
|
11386
|
+
provideService(TypeScriptApi, ts)
|
|
11387
|
+
)
|
|
11388
|
+
};
|
|
11389
|
+
});
|
|
11390
|
+
const parentNodes = yield* getAncestorNodesInRange(sourceFile, textRange);
|
|
11391
|
+
return yield* firstSuccessOf(parentNodes.map(writeTagClassAccessors2));
|
|
11392
|
+
})
|
|
11393
|
+
});
|
|
11394
|
+
|
|
10894
11395
|
// src/refactors.ts
|
|
10895
11396
|
var refactors = [
|
|
10896
11397
|
asyncAwaitToGen,
|
|
@@ -10908,7 +11409,8 @@ var refactors = [
|
|
|
10908
11409
|
wrapWithEffectGen,
|
|
10909
11410
|
wrapWithPipe,
|
|
10910
11411
|
effectGenToFn,
|
|
10911
|
-
togglePipeStyle
|
|
11412
|
+
togglePipeStyle,
|
|
11413
|
+
writeTagClassAccessors
|
|
10912
11414
|
];
|
|
10913
11415
|
|
|
10914
11416
|
// src/index.ts
|
|
@@ -10956,8 +11458,7 @@ var init = (modules) => {
|
|
|
10956
11458
|
);
|
|
10957
11459
|
}
|
|
10958
11460
|
const effectCodeFixesForFile = /* @__PURE__ */ new Map();
|
|
10959
|
-
|
|
10960
|
-
const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
|
|
11461
|
+
const runDiagnosticsAndCacheCodeFixes = (fileName) => {
|
|
10961
11462
|
const program = languageService.getProgram();
|
|
10962
11463
|
if (languageServicePluginOptions.diagnostics && program) {
|
|
10963
11464
|
effectCodeFixesForFile.delete(fileName);
|
|
@@ -10968,13 +11469,17 @@ var init = (modules) => {
|
|
|
10968
11469
|
runNano(program),
|
|
10969
11470
|
map(({ codeFixes, diagnostics: diagnostics2 }) => {
|
|
10970
11471
|
effectCodeFixesForFile.set(fileName, codeFixes);
|
|
10971
|
-
return diagnostics2
|
|
11472
|
+
return diagnostics2;
|
|
10972
11473
|
}),
|
|
10973
|
-
getOrElse(() =>
|
|
11474
|
+
getOrElse(() => [])
|
|
10974
11475
|
);
|
|
10975
11476
|
}
|
|
10976
11477
|
}
|
|
10977
|
-
return
|
|
11478
|
+
return [];
|
|
11479
|
+
};
|
|
11480
|
+
proxy.getSemanticDiagnostics = (fileName, ...args2) => {
|
|
11481
|
+
const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
|
|
11482
|
+
return runDiagnosticsAndCacheCodeFixes(fileName).concat(applicableDiagnostics);
|
|
10978
11483
|
};
|
|
10979
11484
|
proxy.getSupportedCodeFixes = (...args2) => languageService.getSupportedCodeFixes(...args2).concat(
|
|
10980
11485
|
diagnosticsErrorCodes.map((_) => "" + _)
|
|
@@ -10989,41 +11494,47 @@ var init = (modules) => {
|
|
|
10989
11494
|
preferences,
|
|
10990
11495
|
...args2
|
|
10991
11496
|
);
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
(
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
);
|
|
11002
|
-
for (const applicableFix of applicableFixes) {
|
|
11003
|
-
const changes = modules.typescript.textChanges.ChangeTracker.with(
|
|
11004
|
-
{
|
|
11005
|
-
formatContext,
|
|
11006
|
-
host: info.languageServiceHost,
|
|
11007
|
-
preferences: preferences || {}
|
|
11008
|
-
},
|
|
11009
|
-
(changeTracker) => pipe(
|
|
11010
|
-
applicableFix.apply,
|
|
11011
|
-
provideService(ChangeTracker, changeTracker),
|
|
11012
|
-
run
|
|
11013
|
-
)
|
|
11497
|
+
if (languageServicePluginOptions.diagnostics) {
|
|
11498
|
+
return pipe(
|
|
11499
|
+
sync(() => {
|
|
11500
|
+
const effectCodeFixes = [];
|
|
11501
|
+
if (!effectCodeFixesForFile.has(fileName)) {
|
|
11502
|
+
runDiagnosticsAndCacheCodeFixes(fileName);
|
|
11503
|
+
}
|
|
11504
|
+
const applicableFixes = (effectCodeFixesForFile.get(fileName) || []).filter(
|
|
11505
|
+
(_) => _.start === start && _.end === end && errorCodes.indexOf(_.code) > -1
|
|
11014
11506
|
);
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11507
|
+
const formatContext = modules.typescript.formatting.getFormatContext(
|
|
11508
|
+
formatOptions,
|
|
11509
|
+
info.languageServiceHost
|
|
11510
|
+
);
|
|
11511
|
+
for (const applicableFix of applicableFixes) {
|
|
11512
|
+
const changes = modules.typescript.textChanges.ChangeTracker.with(
|
|
11513
|
+
{
|
|
11514
|
+
formatContext,
|
|
11515
|
+
host: info.languageServiceHost,
|
|
11516
|
+
preferences: preferences || {}
|
|
11517
|
+
},
|
|
11518
|
+
(changeTracker) => pipe(
|
|
11519
|
+
applicableFix.apply,
|
|
11520
|
+
provideService(ChangeTracker, changeTracker),
|
|
11521
|
+
run
|
|
11522
|
+
)
|
|
11523
|
+
);
|
|
11524
|
+
effectCodeFixes.push({
|
|
11525
|
+
fixName: applicableFix.fixName,
|
|
11526
|
+
description: applicableFix.description,
|
|
11527
|
+
changes
|
|
11528
|
+
});
|
|
11529
|
+
}
|
|
11530
|
+
return effectCodeFixes;
|
|
11531
|
+
}),
|
|
11532
|
+
run,
|
|
11533
|
+
map((effectCodeFixes) => applicableCodeFixes.concat(effectCodeFixes)),
|
|
11534
|
+
getOrElse(() => applicableCodeFixes)
|
|
11535
|
+
);
|
|
11536
|
+
}
|
|
11537
|
+
return applicableCodeFixes;
|
|
11027
11538
|
};
|
|
11028
11539
|
proxy.getApplicableRefactors = (...args2) => {
|
|
11029
11540
|
const applicableRefactors = languageService.getApplicableRefactors(...args2);
|