@effect/language-service 0.27.2 → 0.28.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/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 some = (value) => {
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 some2 = some;
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() : some2(nullableValue);
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() : some2(f(self.value)));
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() : some2(self[i]);
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(some2(_));
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 all = fn("all")(
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(() => some2(importSpecifier.name))
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 some2([
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 some2(typeNode2.members);
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 some2(members.map((_) => isSome2(_) ? _.value : []).flat());
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
- all(
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
- all(
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
- all(
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
- all(
2796
+ all2(
2651
2797
  varianceStructInvariantType(type, atLocation, "_Identifier"),
2652
2798
  varianceStructInvariantType(type, atLocation, "_Service")
2653
2799
  ),
@@ -2883,7 +3029,7 @@ var importFromBarrel = createDiagnostic({
2883
3029
  const typeChecker = yield* service(TypeCheckerApi);
2884
3030
  const program = yield* service(TypeScriptProgram);
2885
3031
  const packageNamesToCheck = flatten(
2886
- yield* all(
3032
+ yield* all2(
2887
3033
  ...languageServicePluginOptions.namespaceImportPackages.map(
2888
3034
  (packageName) => resolveModulePattern(sourceFile, packageName)
2889
3035
  )
@@ -3135,7 +3281,7 @@ var missingEffectContext = createDiagnostic({
3135
3281
  const typeParser = yield* service(TypeParser);
3136
3282
  const typeOrder = yield* deterministicTypeOrder;
3137
3283
  const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
3138
- all(
3284
+ all2(
3139
3285
  typeParser.effectType(expectedType, node),
3140
3286
  typeParser.effectType(realType, valueNode)
3141
3287
  ),
@@ -3201,7 +3347,7 @@ var missingEffectError = createDiagnostic({
3201
3347
  [ts.factory.createStringLiteral(message)]
3202
3348
  );
3203
3349
  const checkForMissingErrorTypes = (node, expectedType, valueNode, realType) => pipe(
3204
- all(
3350
+ all2(
3205
3351
  typeParser.effectType(expectedType, node),
3206
3352
  typeParser.effectType(realType, valueNode)
3207
3353
  ),
@@ -4200,102 +4346,251 @@ var completions = [
4200
4346
  schemaBrand
4201
4347
  ];
4202
4348
 
4203
- // src/completions/middlewareAutoImports.ts
4204
- var importablePackagesMetadataCache = /* @__PURE__ */ new Map();
4205
- var makeImportablePackagesMetadata = fn("makeImportablePackagesMetadata")(function* (sourceFile) {
4349
+ // node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/common.js
4350
+ var encoder = /* @__PURE__ */ new TextEncoder();
4351
+
4352
+ // node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64.js
4353
+ var encode = (bytes) => {
4354
+ const length = bytes.length;
4355
+ let result = "";
4356
+ let i;
4357
+ for (i = 2; i < length; i += 3) {
4358
+ result += base64abc[bytes[i - 2] >> 2];
4359
+ result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
4360
+ result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
4361
+ result += base64abc[bytes[i] & 63];
4362
+ }
4363
+ if (i === length + 1) {
4364
+ result += base64abc[bytes[i - 2] >> 2];
4365
+ result += base64abc[(bytes[i - 2] & 3) << 4];
4366
+ result += "==";
4367
+ }
4368
+ if (i === length) {
4369
+ result += base64abc[bytes[i - 2] >> 2];
4370
+ result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
4371
+ result += base64abc[(bytes[i - 1] & 15) << 2];
4372
+ result += "=";
4373
+ }
4374
+ return result;
4375
+ };
4376
+ 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", "+", "/"];
4377
+
4378
+ // node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/internal/encoding/base64Url.js
4379
+ var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
4380
+
4381
+ // node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Encoding.js
4382
+ var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
4383
+
4384
+ // src/core/AutoImport.ts
4385
+ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
4206
4386
  const ts = yield* service(TypeScriptApi);
4207
4387
  const program = yield* service(TypeScriptProgram);
4208
4388
  const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
4209
4389
  const host = program;
4210
- const namespaceByFileName = /* @__PURE__ */ new Map();
4211
- const excludedByFileName = /* @__PURE__ */ new Map();
4212
- const unbarreledModulePathByFileName = /* @__PURE__ */ new Map();
4213
- const barreledModulePathByFileName = /* @__PURE__ */ new Map();
4214
- const barreledFunctionPathByFileName = /* @__PURE__ */ new Map();
4215
- const packages = [
4216
- ...languageServicePluginOptions.namespaceImportPackages.map((packagePattern) => ({
4217
- packagePattern,
4218
- kind: "namespace"
4219
- })),
4220
- ...languageServicePluginOptions.barrelImportPackages.map((packagePattern) => ({
4221
- packagePattern,
4222
- kind: "barrel"
4223
- }))
4224
- ];
4225
- for (const { kind, packagePattern } of packages) {
4226
- for (const packageName of yield* resolveModulePattern(sourceFile, packagePattern)) {
4227
- const barrelModule = ts.resolveModuleName(packageName, sourceFile.fileName, program.getCompilerOptions(), host);
4228
- if (barrelModule.resolvedModule) {
4229
- const barrelPath = barrelModule.resolvedModule.resolvedFileName;
4230
- const barrelSource = program.getSourceFile(barrelPath) || ts.createSourceFile(barrelPath, host.readFile(barrelPath) || "", sourceFile.languageVersion, true);
4231
- if (barrelSource) {
4232
- for (const statement of barrelSource.statements) {
4233
- if (ts.isExportDeclaration(statement)) {
4234
- const exportClause = statement.exportClause;
4235
- const moduleSpecifier = statement.moduleSpecifier;
4236
- if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier)) {
4237
- const unbarreledModulePathResolved = ts.resolveModuleName(
4238
- moduleSpecifier.text,
4239
- barrelSource.fileName,
4240
- program.getCompilerOptions(),
4241
- host
4242
- );
4243
- if (unbarreledModulePathResolved.resolvedModule) {
4244
- const unbarreledModulePath = unbarreledModulePathResolved.resolvedModule.resolvedFileName;
4245
- if (exportClause && ts.isNamespaceExport(exportClause) && ts.isIdentifier(exportClause.name)) {
4246
- if (kind === "namespace") {
4247
- namespaceByFileName.set(unbarreledModulePath, exportClause.name.text);
4248
- const existingUnbarreledModulePath = unbarreledModulePathByFileName.get(barrelSource.fileName) || [];
4249
- existingUnbarreledModulePath.push({
4250
- fileName: unbarreledModulePath,
4251
- exportName: exportClause.name.text
4252
- });
4253
- unbarreledModulePathByFileName.set(barrelSource.fileName, existingUnbarreledModulePath);
4254
- }
4255
- if (kind === "barrel") {
4256
- barreledModulePathByFileName.set(unbarreledModulePath, {
4257
- fileName: barrelSource.fileName,
4258
- exportName: exportClause.name.text,
4259
- packageName
4260
- });
4261
- }
4262
- }
4263
- if (exportClause && ts.isNamedExports(exportClause)) {
4264
- for (const element of exportClause.elements) {
4265
- if (!ts.isIdentifier(element.name)) continue;
4266
- const methodName = element.name.text;
4267
- if (kind === "namespace") {
4268
- const excludedMethods = excludedByFileName.get(methodName) || [];
4269
- excludedMethods.push(unbarreledModulePath);
4270
- excludedByFileName.set(methodName, excludedMethods);
4271
- }
4272
- if (kind === "barrel") {
4273
- const previousBarreledFunctionPath = barreledFunctionPathByFileName.get(unbarreledModulePath) || [];
4274
- previousBarreledFunctionPath.push({
4275
- fileName: barrelSource.fileName,
4276
- exportName: methodName,
4277
- packageName
4278
- });
4279
- barreledFunctionPathByFileName.set(unbarreledModulePath, previousBarreledFunctionPath);
4280
- }
4390
+ const getModuleSpecifier = makeGetModuleSpecifier(ts);
4391
+ function collectSourceFileReexports(sourceFile) {
4392
+ const namespaceExports = [];
4393
+ const namedExports = [];
4394
+ for (const statement of sourceFile.statements) {
4395
+ if (!ts.isExportDeclaration(statement)) continue;
4396
+ if (!statement.exportClause) continue;
4397
+ const moduleSpecifier = statement.moduleSpecifier;
4398
+ if (!moduleSpecifier) continue;
4399
+ if (!ts.isStringLiteral(moduleSpecifier)) continue;
4400
+ const exportClause = statement.exportClause;
4401
+ if (ts.isNamespaceExport(exportClause)) {
4402
+ if (!exportClause.name) continue;
4403
+ if (!ts.isIdentifier(exportClause.name)) continue;
4404
+ namespaceExports.push({
4405
+ moduleSpecifier,
4406
+ exportClause,
4407
+ name: exportClause.name.text
4408
+ });
4409
+ }
4410
+ if (ts.isNamedExports(exportClause)) {
4411
+ for (const exportSpecifier of exportClause.elements) {
4412
+ const exportName = exportSpecifier.propertyName || exportSpecifier.name;
4413
+ if (!ts.isIdentifier(exportName)) continue;
4414
+ if (!ts.isIdentifier(exportSpecifier.name)) continue;
4415
+ namedExports.push({
4416
+ moduleSpecifier,
4417
+ exportClause,
4418
+ name: exportName.text,
4419
+ aliasName: exportSpecifier.name.text
4420
+ });
4421
+ }
4422
+ }
4423
+ }
4424
+ return { namespaceExports, namedExports };
4425
+ }
4426
+ function getPackageInfo(fromFileName, packageName) {
4427
+ try {
4428
+ const packageJsonInfo = ts.resolvePackageNameToPackageJson(
4429
+ packageName,
4430
+ fromFileName,
4431
+ program.getCompilerOptions(),
4432
+ host
4433
+ );
4434
+ if (!packageJsonInfo) return;
4435
+ const _entrypoints = ts.getEntrypointsFromPackageJsonInfo(
4436
+ packageJsonInfo,
4437
+ program.getCompilerOptions(),
4438
+ host
4439
+ );
4440
+ if (!_entrypoints) return;
4441
+ if (!isArray(_entrypoints)) return;
4442
+ if (!every2(Predicate_exports.isString)) return;
4443
+ const entrypoints = _entrypoints.map((_) => String(_));
4444
+ const info = parsePackageContentNameAndVersionFromScope({ packageJsonScope: packageJsonInfo });
4445
+ if (!info) return { entrypoints, exportedKeys: [] };
4446
+ return { entrypoints, exportedKeys: info.exportsKeys };
4447
+ } catch (_) {
4448
+ return void 0;
4449
+ }
4450
+ }
4451
+ const mapFromBarrelToNamespace = /* @__PURE__ */ new Map();
4452
+ const mapFromNamespaceToBarrel = /* @__PURE__ */ new Map();
4453
+ const mapFilenameToModuleAlias = /* @__PURE__ */ new Map();
4454
+ const mapFilenameToExportExcludes = /* @__PURE__ */ new Map();
4455
+ const mapFilenameToModuleName = /* @__PURE__ */ new Map();
4456
+ const collectModuleNames = (packageName, exportedKey) => {
4457
+ const appendPart = exportedKey === "." ? "" : exportedKey.startsWith("./") ? exportedKey.slice(1) : exportedKey;
4458
+ const absoluteName = packageName + appendPart;
4459
+ const absoluteFileName = ts.resolveModuleName(
4460
+ absoluteName,
4461
+ fromSourceFile.fileName,
4462
+ program.getCompilerOptions(),
4463
+ host
4464
+ );
4465
+ if (!absoluteFileName) return;
4466
+ if (!absoluteFileName.resolvedModule) return;
4467
+ const realPath = host.realpath ? host.realpath(absoluteFileName.resolvedModule.resolvedFileName) : absoluteFileName.resolvedModule.resolvedFileName;
4468
+ if (mapFilenameToModuleName.has(realPath)) return;
4469
+ mapFilenameToModuleName.set(realPath, absoluteName);
4470
+ };
4471
+ const collectImportCache = fn("TypeScriptApi")(
4472
+ function* (packagePatterns, kind) {
4473
+ for (const packagePattern of packagePatterns) {
4474
+ const packageNames = yield* resolveModulePattern(fromSourceFile, packagePattern);
4475
+ for (const packageName of packageNames) {
4476
+ const packageInfo = getPackageInfo(fromSourceFile.fileName, packageName);
4477
+ if (!packageInfo) continue;
4478
+ for (const exportedKey of packageInfo.exportedKeys) {
4479
+ collectModuleNames(packageName, exportedKey);
4480
+ }
4481
+ for (const _fileName of packageInfo.entrypoints) {
4482
+ const realFileName = host.realpath ? host.realpath(_fileName) : _fileName;
4483
+ const isPackageRoot = mapFilenameToModuleName.get(realFileName) === packageName;
4484
+ const barrelSourceFile = program.getSourceFile(realFileName) || ts.createSourceFile(realFileName, host.readFile(realFileName) || "", fromSourceFile.languageVersion, true);
4485
+ const reExports = collectSourceFileReexports(barrelSourceFile);
4486
+ if (!reExports) continue;
4487
+ if (reExports.namespaceExports.length === 0) continue;
4488
+ for (const namespaceReexport of reExports.namespaceExports) {
4489
+ const reexportedFile = ts.resolveModuleName(
4490
+ namespaceReexport.moduleSpecifier.text,
4491
+ barrelSourceFile.fileName,
4492
+ program.getCompilerOptions(),
4493
+ host
4494
+ );
4495
+ if (!reexportedFile) continue;
4496
+ if (!reexportedFile.resolvedModule) continue;
4497
+ switch (kind) {
4498
+ case "namespace": {
4499
+ mapFromBarrelToNamespace.set(
4500
+ barrelSourceFile.fileName,
4501
+ {
4502
+ ...mapFromBarrelToNamespace.get(barrelSourceFile.fileName) || {},
4503
+ [namespaceReexport.name]: reexportedFile.resolvedModule.resolvedFileName
4281
4504
  }
4282
- }
4505
+ );
4506
+ mapFilenameToModuleAlias.set(
4507
+ reexportedFile.resolvedModule.resolvedFileName,
4508
+ namespaceReexport.name
4509
+ );
4510
+ continue;
4511
+ }
4512
+ case "barrel": {
4513
+ mapFromNamespaceToBarrel.set(reexportedFile.resolvedModule.resolvedFileName, {
4514
+ fileName: barrelSourceFile.fileName,
4515
+ alias: namespaceReexport.name
4516
+ });
4283
4517
  }
4284
4518
  }
4285
4519
  }
4520
+ if (isPackageRoot) {
4521
+ for (const namedExport of reExports.namedExports) {
4522
+ mapFilenameToExportExcludes.set(barrelSourceFile.fileName, [
4523
+ ...mapFilenameToExportExcludes.get(barrelSourceFile.fileName) || [],
4524
+ namedExport.name
4525
+ ]);
4526
+ break;
4527
+ }
4528
+ }
4286
4529
  }
4287
4530
  }
4288
4531
  }
4289
4532
  }
4290
- }
4291
- return {
4292
- getImportNamespaceByFileName: (fileName) => namespaceByFileName.get(fileName),
4293
- isExcludedFromNamespaceImport: (fileName, exportName) => (excludedByFileName.get(exportName) || []).includes(fileName),
4294
- getUnbarreledModulePath: (fileName, exportName) => unbarreledModulePathByFileName.get(fileName)?.find((_) => _.exportName === exportName)?.fileName,
4295
- getBarreledModulePath: (fileName) => barreledModulePathByFileName.get(fileName),
4296
- getBarreledFunctionPath: (fileName, exportName) => barreledFunctionPathByFileName.get(fileName)?.find((_) => _.exportName === exportName)
4533
+ );
4534
+ yield* collectImportCache(languageServicePluginOptions.namespaceImportPackages, "namespace");
4535
+ yield* collectImportCache(languageServicePluginOptions.barrelImportPackages, "barrel");
4536
+ const resolveModuleName = (fileName) => {
4537
+ const fixedModuleName = mapFilenameToModuleName.get(fileName);
4538
+ if (fixedModuleName) return fixedModuleName;
4539
+ if (!getModuleSpecifier) return fileName;
4540
+ const moduleSpecifier = getModuleSpecifier(
4541
+ program.getCompilerOptions(),
4542
+ fromSourceFile,
4543
+ fromSourceFile.fileName,
4544
+ fileName,
4545
+ host
4546
+ );
4547
+ if (!moduleSpecifier) return fileName;
4548
+ return moduleSpecifier;
4549
+ };
4550
+ return (exportFileName, exportName) => {
4551
+ const excludedExports = mapFilenameToExportExcludes.get(exportFileName);
4552
+ if (excludedExports && excludedExports.includes(exportName)) return;
4553
+ const mapToNamespace = mapFromBarrelToNamespace.get(exportFileName);
4554
+ if (mapToNamespace && exportName in mapToNamespace) {
4555
+ const namespacedFileName = mapToNamespace[exportName];
4556
+ if (namespacedFileName) {
4557
+ const introducedAlias2 = mapFilenameToModuleAlias.get(namespacedFileName);
4558
+ if (introducedAlias2) {
4559
+ return {
4560
+ _tag: "NamespaceImport",
4561
+ fileName: namespacedFileName,
4562
+ moduleName: resolveModuleName(namespacedFileName),
4563
+ name: introducedAlias2,
4564
+ introducedPrefix: void 0
4565
+ };
4566
+ }
4567
+ }
4568
+ }
4569
+ const introducedAlias = mapFilenameToModuleAlias.get(exportFileName);
4570
+ if (introducedAlias) {
4571
+ return {
4572
+ _tag: "NamespaceImport",
4573
+ fileName: exportFileName,
4574
+ moduleName: resolveModuleName(exportFileName),
4575
+ name: introducedAlias,
4576
+ introducedPrefix: introducedAlias
4577
+ };
4578
+ }
4579
+ const mapToBarrel = mapFromNamespaceToBarrel.get(exportFileName);
4580
+ if (mapToBarrel) {
4581
+ return {
4582
+ _tag: "NamedImport",
4583
+ fileName: mapToBarrel.fileName,
4584
+ moduleName: resolveModuleName(mapToBarrel.fileName),
4585
+ name: mapToBarrel.alias,
4586
+ introducedPrefix: mapToBarrel.alias
4587
+ };
4588
+ }
4297
4589
  };
4298
4590
  });
4591
+
4592
+ // src/completions/middlewareAutoImports.ts
4593
+ var importProvidersCache = /* @__PURE__ */ new Map();
4299
4594
  var appendEffectCompletionEntryData = fn("appendEffectCompletionEntryData")(
4300
4595
  function* (_sourceFile, applicableCompletions) {
4301
4596
  const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
@@ -4349,8 +4644,9 @@ var isAutoImportOnlyCodeActions = fn("isAutoImportOnlyCodeActions")(
4349
4644
  }
4350
4645
  }
4351
4646
  );
4352
- var getImportFromNamespaceCodeActions = fn("getImportFromNamespaceCodeActions")(function* (formatOptions, preferences, languageServiceHost, sourceFile, effectReplaceSpan, effectNamespaceName, effectUnbarreledModulePath, newModuleSpecifier) {
4647
+ var addImportCodeAction = fn("getImportFromNamespaceCodeActions")(function* (formatOptions, preferences, languageServiceHost, sourceFile, effectReplaceSpan, effectAutoImport) {
4353
4648
  const ts = yield* service(TypeScriptApi);
4649
+ let description = "auto-import";
4354
4650
  const formatContext = ts.formatting.getFormatContext(
4355
4651
  formatOptions || {},
4356
4652
  languageServiceHost
@@ -4362,113 +4658,104 @@ var getImportFromNamespaceCodeActions = fn("getImportFromNamespaceCodeActions")(
4362
4658
  preferences: preferences || {}
4363
4659
  },
4364
4660
  (changeTracker) => {
4365
- ts.insertImports(
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) {
4661
+ if (effectAutoImport.introducedPrefix) {
4381
4662
  changeTracker.insertText(
4382
4663
  sourceFile,
4383
4664
  effectReplaceSpan.start,
4384
- effectNamespaceName + "."
4665
+ effectAutoImport.introducedPrefix + "."
4385
4666
  );
4386
4667
  }
4387
- }
4388
- );
4389
- return [
4390
- {
4391
- description: "Import * as " + effectNamespaceName + " from " + newModuleSpecifier,
4392
- changes
4393
- }
4394
- ];
4395
- });
4396
- var getImportFromBarrelCodeActions = fn("getImportFromBarrelCodeActions")(function* (formatOptions, preferences, languageServiceHost, sourceFile, effectReplaceSpan, newModuleSpecifier, barrelExportName, shouldPrependExportName) {
4397
- const ts = yield* service(TypeScriptApi);
4398
- const formatContext = ts.formatting.getFormatContext(
4399
- formatOptions || {},
4400
- languageServiceHost
4401
- );
4402
- const changes = ts.textChanges.ChangeTracker.with(
4403
- {
4404
- formatContext,
4405
- host: languageServiceHost,
4406
- preferences: preferences || {}
4407
- },
4408
- (changeTracker) => {
4409
- let foundImportDeclaration = false;
4410
- for (const statement of sourceFile.statements) {
4411
- if (ts.isImportDeclaration(statement)) {
4412
- const moduleSpecifier = statement.moduleSpecifier;
4413
- if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier) && moduleSpecifier.text === newModuleSpecifier) {
4414
- const importClause = statement.importClause;
4415
- if (importClause && importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
4416
- const namedImports = importClause.namedBindings;
4417
- const existingImportSpecifier = namedImports.elements.find(
4418
- (element) => element.name.text.toLowerCase() === barrelExportName.toLowerCase()
4419
- );
4420
- if (existingImportSpecifier) {
4421
- foundImportDeclaration = true;
4422
- break;
4668
+ switch (effectAutoImport._tag) {
4669
+ case "NamespaceImport": {
4670
+ const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
4671
+ description = `Import * as ${effectAutoImport.name} from "${importModule}"`;
4672
+ ts.insertImports(
4673
+ changeTracker,
4674
+ sourceFile,
4675
+ ts.factory.createImportDeclaration(
4676
+ void 0,
4677
+ ts.factory.createImportClause(
4678
+ false,
4679
+ void 0,
4680
+ ts.factory.createNamespaceImport(ts.factory.createIdentifier(effectAutoImport.name))
4681
+ ),
4682
+ ts.factory.createStringLiteral(importModule)
4683
+ ),
4684
+ true,
4685
+ preferences || {}
4686
+ );
4687
+ break;
4688
+ }
4689
+ case "NamedImport": {
4690
+ const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
4691
+ description = `Import { ${effectAutoImport.name} } from "${importModule}"`;
4692
+ let foundImportDeclaration = false;
4693
+ for (const statement of sourceFile.statements) {
4694
+ if (ts.isImportDeclaration(statement)) {
4695
+ const moduleSpecifier = statement.moduleSpecifier;
4696
+ if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier) && moduleSpecifier.text === importModule) {
4697
+ const importClause = statement.importClause;
4698
+ if (importClause && importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
4699
+ const namedImports = importClause.namedBindings;
4700
+ const existingImportSpecifier = namedImports.elements.find(
4701
+ (element) => element.name.text === effectAutoImport.name
4702
+ );
4703
+ if (existingImportSpecifier) {
4704
+ foundImportDeclaration = true;
4705
+ break;
4706
+ }
4707
+ changeTracker.replaceNode(
4708
+ sourceFile,
4709
+ namedImports,
4710
+ ts.factory.createNamedImports(
4711
+ namedImports.elements.concat([
4712
+ ts.factory.createImportSpecifier(
4713
+ false,
4714
+ void 0,
4715
+ ts.factory.createIdentifier(effectAutoImport.name)
4716
+ )
4717
+ ])
4718
+ )
4719
+ );
4720
+ foundImportDeclaration = true;
4721
+ break;
4722
+ }
4423
4723
  }
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
4724
  }
4436
4725
  }
4726
+ if (!foundImportDeclaration) {
4727
+ ts.insertImports(
4728
+ changeTracker,
4729
+ sourceFile,
4730
+ ts.factory.createImportDeclaration(
4731
+ void 0,
4732
+ ts.factory.createImportClause(
4733
+ false,
4734
+ void 0,
4735
+ ts.factory.createNamedImports(
4736
+ [
4737
+ ts.factory.createImportSpecifier(
4738
+ false,
4739
+ void 0,
4740
+ ts.factory.createIdentifier(effectAutoImport.name)
4741
+ )
4742
+ ]
4743
+ )
4744
+ ),
4745
+ ts.factory.createStringLiteral(importModule)
4746
+ ),
4747
+ true,
4748
+ preferences || {}
4749
+ );
4750
+ }
4751
+ break;
4437
4752
  }
4438
4753
  }
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
4754
  }
4468
4755
  );
4469
4756
  return [
4470
4757
  {
4471
- description: "Import { " + barrelExportName + " } from " + newModuleSpecifier,
4758
+ description,
4472
4759
  changes
4473
4760
  }
4474
4761
  ];
@@ -4477,10 +4764,6 @@ var postprocessCompletionEntryDetails = fn("postprocessCompletionEntryDetails")(
4477
4764
  function* (sourceFile, data, applicableCompletionEntryDetails, formatOptions, preferences, languageServiceHost) {
4478
4765
  const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
4479
4766
  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
4767
  if (!applicableCompletionEntryDetails) return applicableCompletionEntryDetails;
4485
4768
  if (!data) return applicableCompletionEntryDetails;
4486
4769
  const { exportName, fileName, moduleSpecifier } = data;
@@ -4495,78 +4778,22 @@ var postprocessCompletionEntryDetails = fn("postprocessCompletionEntryDetails")(
4495
4778
  exportName
4496
4779
  );
4497
4780
  if (!result) return applicableCompletionEntryDetails;
4498
- const packagesMetadata = importablePackagesMetadataCache.get(sourceFile.fileName) || (yield* makeImportablePackagesMetadata(sourceFile));
4499
- importablePackagesMetadataCache.set(sourceFile.fileName, packagesMetadata);
4500
- const isExcluded = packagesMetadata.isExcludedFromNamespaceImport(
4501
- fileName,
4502
- exportName
4503
- );
4504
- if (isExcluded) return applicableCompletionEntryDetails;
4505
- const asBarrelFunctionImport = packagesMetadata.getBarreledFunctionPath(fileName, exportName);
4506
- if (asBarrelFunctionImport) {
4507
- const codeActions = yield* getImportFromBarrelCodeActions(
4508
- formatOptions,
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
4781
+ const packagesMetadata = importProvidersCache.get(sourceFile.fileName) || (yield* makeAutoImportProvider(sourceFile));
4782
+ importProvidersCache.set(sourceFile.fileName, packagesMetadata);
4783
+ const effectAutoImport = packagesMetadata(fileName, exportName);
4784
+ if (!effectAutoImport) return applicableCompletionEntryDetails;
4785
+ const codeActions = yield* addImportCodeAction(
4786
+ formatOptions,
4787
+ preferences,
4788
+ languageServiceHost,
4789
+ sourceFile,
4790
+ effectReplaceSpan,
4791
+ effectAutoImport
4545
4792
  );
4546
- if (asNamespaceImport) {
4547
- const newModuleSpecifier = effectUnbarreledModulePath ? getModuleSpecifier(
4548
- program.getCompilerOptions(),
4549
- sourceFile,
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;
4793
+ return {
4794
+ ...applicableCompletionEntryDetails,
4795
+ codeActions
4796
+ };
4570
4797
  }
4571
4798
  );
4572
4799
 
@@ -4793,41 +5020,6 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
4793
5020
  );
4794
5021
  }
4795
5022
 
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
5023
  // node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs
4832
5024
  var Z_FIXED$1 = 4;
4833
5025
  var Z_BINARY = 0;
@@ -9048,7 +9240,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
9048
9240
  const maybeLayer = yield* option(typeParser.layerType(type, node));
9049
9241
  if (isSome2(maybeLayer)) {
9050
9242
  const argNodes = yield* option(
9051
- all(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
9243
+ all2(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
9052
9244
  );
9053
9245
  if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
9054
9246
  const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
@@ -9092,7 +9284,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
9092
9284
  );
9093
9285
  if (ts.isCallExpression(node)) {
9094
9286
  const argNodes = yield* option(
9095
- all(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
9287
+ all2(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
9096
9288
  );
9097
9289
  if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
9098
9290
  return new GraphNodeCompoundTransform(
@@ -9222,7 +9414,7 @@ function processNodeMermaid(graph, ctx, ctxL) {
9222
9414
  return subgraphDefs;
9223
9415
  }
9224
9416
  case "GraphNodeCompoundTransform": {
9225
- const childs = flatten(yield* all(...graph.args.map((_) => processNodeMermaid(_, ctx, ctxL))));
9417
+ const childs = flatten(yield* all2(...graph.args.map((_) => processNodeMermaid(_, ctx, ctxL))));
9226
9418
  let currentEdges = [];
9227
9419
  const connectedNodes = /* @__PURE__ */ new Set();
9228
9420
  for (const requiredServiceKey of graph.rin) {
@@ -10007,7 +10199,7 @@ var pipeableToDatafirst = createRefactor({
10007
10199
  for (let i = 0; i < callSignatures.length; i++) {
10008
10200
  const callSignature = callSignatures[i];
10009
10201
  if (callSignature.parameters.length === node2.arguments.length + 1) {
10010
- return some2(
10202
+ return some3(
10011
10203
  ts.factory.createCallExpression(
10012
10204
  node2.expression,
10013
10205
  [],
@@ -10049,7 +10241,7 @@ var pipeableToDatafirst = createRefactor({
10049
10241
  }
10050
10242
  }
10051
10243
  }
10052
- return didSomething ? some2([node2, newNode2]) : none2();
10244
+ return didSomething ? some3([node2, newNode2]) : none2();
10053
10245
  }),
10054
10246
  filter(isSome2),
10055
10247
  map3((_) => _.value),
@@ -10377,17 +10569,17 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
10377
10569
  case "Pick":
10378
10570
  case "Omit":
10379
10571
  case "Record":
10380
- return some2(name.text);
10572
+ return some3(name.text);
10381
10573
  case "ReadonlyArray":
10382
10574
  case "Array":
10383
- return some2("Array");
10575
+ return some3("Array");
10384
10576
  }
10385
10577
  return none2();
10386
10578
  }
10387
10579
  if (!ts.isIdentifier(name.left)) return none2();
10388
10580
  for (const moduleName in moduleToImportedName) {
10389
10581
  if (name.left.text === moduleToImportedName[moduleName] && name.right.text === moduleName) {
10390
- return some2(moduleName);
10582
+ return some3(moduleName);
10391
10583
  }
10392
10584
  }
10393
10585
  return none2();
@@ -10426,7 +10618,7 @@ var parseAllLiterals = fn(
10426
10618
  }
10427
10619
  }
10428
10620
  if (ts.isUnionTypeNode(node)) {
10429
- return flatten(yield* all(...node.types.map((_) => parseAllLiterals(_))));
10621
+ return flatten(yield* all2(...node.types.map((_) => parseAllLiterals(_))));
10430
10622
  }
10431
10623
  if (ts.isParenthesizedTypeNode(node)) {
10432
10624
  return yield* parseAllLiterals(node.type);
@@ -10473,11 +10665,11 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
10473
10665
  if (ts.isUnionTypeNode(node)) {
10474
10666
  const allLiterals = yield* option(parseAllLiterals(node));
10475
10667
  if (isSome2(allLiterals)) return createApiCall("Literal", allLiterals.value);
10476
- const members = yield* all(...node.types.map((_) => processNode(_, isVirtualTypeNode)));
10668
+ const members = yield* all2(...node.types.map((_) => processNode(_, isVirtualTypeNode)));
10477
10669
  return createApiCall("Union", members);
10478
10670
  }
10479
10671
  if (ts.isIntersectionTypeNode(node)) {
10480
- const [firstSchema, ...otherSchemas] = yield* all(
10672
+ const [firstSchema, ...otherSchemas] = yield* all2(
10481
10673
  ...node.types.map((_) => processNode(_, isVirtualTypeNode))
10482
10674
  );
10483
10675
  if (otherSchemas.length === 0) return firstSchema;
@@ -10533,13 +10725,13 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
10533
10725
  case "Option":
10534
10726
  case "Chunk":
10535
10727
  case "Array": {
10536
- const elements = yield* all(
10728
+ const elements = yield* all2(
10537
10729
  ...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
10538
10730
  );
10539
10731
  return createApiCall(parsedName.value, elements);
10540
10732
  }
10541
10733
  case "Record": {
10542
- const elements = yield* all(
10734
+ const elements = yield* all2(
10543
10735
  ...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
10544
10736
  );
10545
10737
  if (elements.length >= 2) {
@@ -10553,7 +10745,7 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
10553
10745
  return createUnsupportedNodeComment(ts, sourceFile, node);
10554
10746
  }
10555
10747
  case "Either": {
10556
- const elements = yield* all(
10748
+ const elements = yield* all2(
10557
10749
  ...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
10558
10750
  );
10559
10751
  if (elements.length >= 2) {
@@ -10956,8 +11148,7 @@ var init = (modules) => {
10956
11148
  );
10957
11149
  }
10958
11150
  const effectCodeFixesForFile = /* @__PURE__ */ new Map();
10959
- proxy.getSemanticDiagnostics = (fileName, ...args2) => {
10960
- const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
11151
+ const runDiagnosticsAndCacheCodeFixes = (fileName) => {
10961
11152
  const program = languageService.getProgram();
10962
11153
  if (languageServicePluginOptions.diagnostics && program) {
10963
11154
  effectCodeFixesForFile.delete(fileName);
@@ -10968,13 +11159,17 @@ var init = (modules) => {
10968
11159
  runNano(program),
10969
11160
  map(({ codeFixes, diagnostics: diagnostics2 }) => {
10970
11161
  effectCodeFixesForFile.set(fileName, codeFixes);
10971
- return diagnostics2.concat(applicableDiagnostics);
11162
+ return diagnostics2;
10972
11163
  }),
10973
- getOrElse(() => applicableDiagnostics)
11164
+ getOrElse(() => [])
10974
11165
  );
10975
11166
  }
10976
11167
  }
10977
- return applicableDiagnostics;
11168
+ return [];
11169
+ };
11170
+ proxy.getSemanticDiagnostics = (fileName, ...args2) => {
11171
+ const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
11172
+ return runDiagnosticsAndCacheCodeFixes(fileName).concat(applicableDiagnostics);
10978
11173
  };
10979
11174
  proxy.getSupportedCodeFixes = (...args2) => languageService.getSupportedCodeFixes(...args2).concat(
10980
11175
  diagnosticsErrorCodes.map((_) => "" + _)
@@ -10989,41 +11184,47 @@ var init = (modules) => {
10989
11184
  preferences,
10990
11185
  ...args2
10991
11186
  );
10992
- return pipe(
10993
- sync(() => {
10994
- const effectCodeFixes = [];
10995
- const applicableFixes = (effectCodeFixesForFile.get(fileName) || []).filter(
10996
- (_) => _.start === start && _.end === end && errorCodes.indexOf(_.code) > -1
10997
- );
10998
- const formatContext = modules.typescript.formatting.getFormatContext(
10999
- formatOptions,
11000
- info.languageServiceHost
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
- )
11187
+ if (languageServicePluginOptions.diagnostics) {
11188
+ return pipe(
11189
+ sync(() => {
11190
+ const effectCodeFixes = [];
11191
+ if (!effectCodeFixesForFile.has(fileName)) {
11192
+ runDiagnosticsAndCacheCodeFixes(fileName);
11193
+ }
11194
+ const applicableFixes = (effectCodeFixesForFile.get(fileName) || []).filter(
11195
+ (_) => _.start === start && _.end === end && errorCodes.indexOf(_.code) > -1
11014
11196
  );
11015
- effectCodeFixes.push({
11016
- fixName: applicableFix.fixName,
11017
- description: applicableFix.description,
11018
- changes
11019
- });
11020
- }
11021
- return effectCodeFixes;
11022
- }),
11023
- run,
11024
- map((effectCodeFixes) => applicableCodeFixes.concat(effectCodeFixes)),
11025
- getOrElse(() => applicableCodeFixes)
11026
- );
11197
+ const formatContext = modules.typescript.formatting.getFormatContext(
11198
+ formatOptions,
11199
+ info.languageServiceHost
11200
+ );
11201
+ for (const applicableFix of applicableFixes) {
11202
+ const changes = modules.typescript.textChanges.ChangeTracker.with(
11203
+ {
11204
+ formatContext,
11205
+ host: info.languageServiceHost,
11206
+ preferences: preferences || {}
11207
+ },
11208
+ (changeTracker) => pipe(
11209
+ applicableFix.apply,
11210
+ provideService(ChangeTracker, changeTracker),
11211
+ run
11212
+ )
11213
+ );
11214
+ effectCodeFixes.push({
11215
+ fixName: applicableFix.fixName,
11216
+ description: applicableFix.description,
11217
+ changes
11218
+ });
11219
+ }
11220
+ return effectCodeFixes;
11221
+ }),
11222
+ run,
11223
+ map((effectCodeFixes) => applicableCodeFixes.concat(effectCodeFixes)),
11224
+ getOrElse(() => applicableCodeFixes)
11225
+ );
11226
+ }
11227
+ return applicableCodeFixes;
11027
11228
  };
11028
11229
  proxy.getApplicableRefactors = (...args2) => {
11029
11230
  const applicableRefactors = languageService.getApplicableRefactors(...args2);