@effect/language-service 0.1.0 → 0.3.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.
Files changed (3) hide show
  1. package/index.cjs +741 -226
  2. package/index.cjs.map +1 -0
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Function.js
3
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Function.js
4
4
  var isFunction = (input) => typeof input === "function";
5
5
  var dual = function(arity, body) {
6
6
  if (typeof arity === "function") {
@@ -94,32 +94,36 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
94
94
  }
95
95
  }
96
96
 
97
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/internal/version.js
98
- var moduleVersion = "2.0.0-next.59";
97
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/version.js
98
+ var moduleVersion = "3.12.5";
99
+ var getCurrentVersion = () => moduleVersion;
99
100
 
100
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/GlobalValue.js
101
- var globalStoreId = /* @__PURE__ */ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
102
- if (!(globalStoreId in globalThis)) {
103
- ;
104
- globalThis[globalStoreId] = /* @__PURE__ */ new Map();
105
- }
106
- var globalStore = globalThis[globalStoreId];
101
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/GlobalValue.js
102
+ var globalStoreId = `effect/GlobalValue/globalStoreId/${/* @__PURE__ */ getCurrentVersion()}`;
103
+ var globalStore;
107
104
  var globalValue = (id, compute) => {
105
+ if (!globalStore) {
106
+ globalThis[globalStoreId] ??= /* @__PURE__ */ new Map();
107
+ globalStore = globalThis[globalStoreId];
108
+ }
108
109
  if (!globalStore.has(id)) {
109
110
  globalStore.set(id, compute());
110
111
  }
111
112
  return globalStore.get(id);
112
113
  };
113
114
 
114
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Predicate.js
115
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Predicate.js
115
116
  var isFunction2 = isFunction;
116
117
  var isRecordOrArray = (input) => typeof input === "object" && input !== null;
117
118
  var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
118
119
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
119
- var isNullable = (input) => input === null || input === void 0;
120
120
 
121
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Utils.js
121
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/errors.js
122
+ var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
123
+
124
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Utils.js
122
125
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
126
+ var isGenKind = (u) => isObject(u) && GenKindTypeId in u;
123
127
  var GenKindImpl = class {
124
128
  value;
125
129
  constructor(value) {
@@ -200,139 +204,51 @@ var SingleShotGen = class _SingleShotGen {
200
204
  return new _SingleShotGen(this.self);
201
205
  }
202
206
  };
203
- var defaultIncHi = 335903614;
204
- var defaultIncLo = 4150755663;
207
+ var adapter = () => function() {
208
+ let x = arguments[0];
209
+ for (let i = 1; i < arguments.length; i++) {
210
+ x = arguments[i](x);
211
+ }
212
+ return new GenKindImpl(x);
213
+ };
205
214
  var MUL_HI = 1481765933 >>> 0;
206
215
  var MUL_LO = 1284865837 >>> 0;
207
- var BIT_53 = 9007199254740992;
208
- var BIT_27 = 134217728;
209
- var PCGRandom = class {
210
- _state;
211
- constructor(seedHi, seedLo, incHi, incLo) {
212
- if (isNullable(seedLo) && isNullable(seedHi)) {
213
- seedLo = Math.random() * 4294967295 >>> 0;
214
- seedHi = 0;
215
- } else if (isNullable(seedLo)) {
216
- seedLo = seedHi;
217
- seedHi = 0;
218
- }
219
- if (isNullable(incLo) && isNullable(incHi)) {
220
- incLo = this._state ? this._state[3] : defaultIncLo;
221
- incHi = this._state ? this._state[2] : defaultIncHi;
222
- } else if (isNullable(incLo)) {
223
- incLo = incHi;
224
- incHi = 0;
225
- }
226
- this._state = new Int32Array([0, 0, incHi >>> 0, ((incLo || 0) | 1) >>> 0]);
227
- this._next();
228
- add64(this._state, this._state[0], this._state[1], seedHi >>> 0, seedLo >>> 0);
229
- this._next();
230
- return this;
231
- }
216
+ var YieldWrapTypeId = /* @__PURE__ */ Symbol.for("effect/Utils/YieldWrap");
217
+ var YieldWrap = class {
232
218
  /**
233
- * Returns a copy of the internal state of this random number generator as a
234
- * JavaScript Array.
235
- *
236
- * @category getters
237
- * @since 2.0.0
238
- */
239
- getState() {
240
- return [this._state[0], this._state[1], this._state[2], this._state[3]];
241
- }
242
- /**
243
- * Restore state previously retrieved using `getState()`.
244
- *
245
- * @since 2.0.0
246
- */
247
- setState(state) {
248
- this._state[0] = state[0];
249
- this._state[1] = state[1];
250
- this._state[2] = state[2];
251
- this._state[3] = state[3] | 1;
252
- }
253
- /**
254
- * Get a uniformly distributed 32 bit integer between [0, max).
255
- *
256
- * @category getter
257
- * @since 2.0.0
219
+ * @since 3.0.6
258
220
  */
259
- integer(max) {
260
- if (!max) {
261
- return this._next();
262
- }
263
- max = max >>> 0;
264
- if ((max & max - 1) === 0) {
265
- return this._next() & max - 1;
266
- }
267
- let num = 0;
268
- const skew = (-max >>> 0) % max >>> 0;
269
- for (num = this._next(); num < skew; num = this._next()) {
270
- }
271
- return num % max;
221
+ #value;
222
+ constructor(value) {
223
+ this.#value = value;
272
224
  }
273
225
  /**
274
- * Get a uniformly distributed IEEE-754 double between 0.0 and 1.0, with
275
- * 53 bits of precision (every bit of the mantissa is randomized).
276
- *
277
- * @category getters
278
- * @since 2.0.0
226
+ * @since 3.0.6
279
227
  */
280
- number() {
281
- const hi = (this._next() & 67108863) * 1;
282
- const lo = (this._next() & 134217727) * 1;
283
- return (hi * BIT_27 + lo) / BIT_53;
284
- }
285
- /** @internal */
286
- _next() {
287
- const oldHi = this._state[0] >>> 0;
288
- const oldLo = this._state[1] >>> 0;
289
- mul64(this._state, oldHi, oldLo, MUL_HI, MUL_LO);
290
- add64(this._state, this._state[0], this._state[1], this._state[2], this._state[3]);
291
- let xsHi = oldHi >>> 18;
292
- let xsLo = (oldLo >>> 18 | oldHi << 14) >>> 0;
293
- xsHi = (xsHi ^ oldHi) >>> 0;
294
- xsLo = (xsLo ^ oldLo) >>> 0;
295
- const xorshifted = (xsLo >>> 27 | xsHi << 5) >>> 0;
296
- const rot = oldHi >>> 27;
297
- const rot2 = (-rot >>> 0 & 31) >>> 0;
298
- return (xorshifted >>> rot | xorshifted << rot2) >>> 0;
228
+ [YieldWrapTypeId]() {
229
+ return this.#value;
299
230
  }
300
231
  };
301
- function mul64(out, aHi, aLo, bHi, bLo) {
302
- let c1 = (aLo >>> 16) * (bLo & 65535) >>> 0;
303
- let c0 = (aLo & 65535) * (bLo >>> 16) >>> 0;
304
- let lo = (aLo & 65535) * (bLo & 65535) >>> 0;
305
- let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
306
- c0 = c0 << 16 >>> 0;
307
- lo = lo + c0 >>> 0;
308
- if (lo >>> 0 < c0 >>> 0) {
309
- hi = hi + 1 >>> 0;
310
- }
311
- c1 = c1 << 16 >>> 0;
312
- lo = lo + c1 >>> 0;
313
- if (lo >>> 0 < c1 >>> 0) {
314
- hi = hi + 1 >>> 0;
315
- }
316
- hi = hi + Math.imul(aLo, bHi) >>> 0;
317
- hi = hi + Math.imul(aHi, bLo) >>> 0;
318
- out[0] = hi;
319
- out[1] = lo;
320
- }
321
- function add64(out, aHi, aLo, bHi, bLo) {
322
- let hi = aHi + bHi >>> 0;
323
- const lo = aLo + bLo >>> 0;
324
- if (lo >>> 0 < aLo >>> 0) {
325
- hi = hi + 1 | 0;
232
+ function yieldWrapGet(self) {
233
+ if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
234
+ return self[YieldWrapTypeId]();
326
235
  }
327
- out[0] = hi;
328
- out[1] = lo;
236
+ throw new Error(getBugErrorMessage("yieldWrapGet"));
329
237
  }
238
+ var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructuralRegion", () => ({
239
+ enabled: false,
240
+ tester: void 0
241
+ }));
242
+ var genConstructor = function* () {
243
+ }.constructor;
330
244
 
331
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Hash.js
245
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Hash.js
332
246
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
333
- var pcgr = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/pcgr"), () => new PCGRandom());
334
247
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
335
248
  var hash = (self) => {
249
+ if (structuralRegionState.enabled === true) {
250
+ return 0;
251
+ }
336
252
  switch (typeof self) {
337
253
  case "number":
338
254
  return number(self);
@@ -350,8 +266,9 @@ var hash = (self) => {
350
266
  case "object": {
351
267
  if (self === null) {
352
268
  return string("null");
353
- }
354
- if (isHash(self)) {
269
+ } else if (self instanceof Date) {
270
+ return hash(self.toISOString());
271
+ } else if (isHash(self)) {
355
272
  return self[symbol]();
356
273
  } else {
357
274
  return random(self);
@@ -363,7 +280,7 @@ var hash = (self) => {
363
280
  };
364
281
  var random = (self) => {
365
282
  if (!randomHashCache.has(self)) {
366
- randomHashCache.set(self, number(pcgr.integer(Number.MAX_SAFE_INTEGER)));
283
+ randomHashCache.set(self, number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)));
367
284
  }
368
285
  return randomHashCache.get(self);
369
286
  };
@@ -381,7 +298,7 @@ var number = (n) => {
381
298
  while (n > 4294967295) {
382
299
  h ^= n /= 4294967295;
383
300
  }
384
- return optimize(n);
301
+ return optimize(h);
385
302
  };
386
303
  var string = (str) => {
387
304
  let h = 5381, i = str.length;
@@ -398,8 +315,31 @@ var structureKeys = (o, keys) => {
398
315
  return optimize(h);
399
316
  };
400
317
  var structure = (o) => structureKeys(o, Object.keys(o));
318
+ var cached = function() {
319
+ if (arguments.length === 1) {
320
+ const self2 = arguments[0];
321
+ return function(hash3) {
322
+ Object.defineProperty(self2, symbol, {
323
+ value() {
324
+ return hash3;
325
+ },
326
+ enumerable: false
327
+ });
328
+ return hash3;
329
+ };
330
+ }
331
+ const self = arguments[0];
332
+ const hash2 = arguments[1];
333
+ Object.defineProperty(self, symbol, {
334
+ value() {
335
+ return hash2;
336
+ },
337
+ enumerable: false
338
+ });
339
+ return hash2;
340
+ };
401
341
 
402
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Equal.js
342
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Equal.js
403
343
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
404
344
  function equals() {
405
345
  if (arguments.length === 1) {
@@ -415,30 +355,113 @@ function compareBoth(self, that) {
415
355
  if (selfType !== typeof that) {
416
356
  return false;
417
357
  }
418
- if ((selfType === "object" || selfType === "function") && self !== null && that !== null) {
419
- if (isEqual(self) && isEqual(that)) {
420
- return hash(self) === hash(that) && self[symbol2](that);
358
+ if (selfType === "object" || selfType === "function") {
359
+ if (self !== null && that !== null) {
360
+ if (isEqual(self) && isEqual(that)) {
361
+ if (hash(self) === hash(that) && self[symbol2](that)) {
362
+ return true;
363
+ } else {
364
+ return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
365
+ }
366
+ } else if (self instanceof Date && that instanceof Date) {
367
+ return self.toISOString() === that.toISOString();
368
+ }
369
+ }
370
+ if (structuralRegionState.enabled) {
371
+ if (Array.isArray(self) && Array.isArray(that)) {
372
+ return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
373
+ }
374
+ if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(self) === Object.prototype) {
375
+ const keysSelf = Object.keys(self);
376
+ const keysThat = Object.keys(that);
377
+ if (keysSelf.length === keysThat.length) {
378
+ for (const key of keysSelf) {
379
+ if (!(key in that && compareBoth(self[key], that[key]))) {
380
+ return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
381
+ }
382
+ }
383
+ return true;
384
+ }
385
+ }
386
+ return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
421
387
  }
422
388
  }
423
- return false;
389
+ return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
424
390
  }
425
391
  var isEqual = (u) => hasProperty(u, symbol2);
426
392
 
427
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Inspectable.js
393
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Equivalence.js
394
+ var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
395
+ var array = (item) => make((self, that) => {
396
+ if (self.length !== that.length) {
397
+ return false;
398
+ }
399
+ for (let i = 0; i < self.length; i++) {
400
+ const isEq = item(self[i], that[i]);
401
+ if (!isEq) {
402
+ return false;
403
+ }
404
+ }
405
+ return true;
406
+ });
407
+
408
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Inspectable.js
428
409
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
429
410
  var toJSON = (x) => {
430
- if (hasProperty(x, "toJSON") && isFunction2(x["toJSON"]) && x["toJSON"].length === 0) {
431
- return x.toJSON();
432
- } else if (Array.isArray(x)) {
433
- return x.map(toJSON);
411
+ try {
412
+ if (hasProperty(x, "toJSON") && isFunction2(x["toJSON"]) && x["toJSON"].length === 0) {
413
+ return x.toJSON();
414
+ } else if (Array.isArray(x)) {
415
+ return x.map(toJSON);
416
+ }
417
+ } catch (_) {
418
+ return {};
434
419
  }
435
- return x;
420
+ return redact(x);
436
421
  };
437
422
  var format = (x) => JSON.stringify(x, null, 2);
423
+ var BaseProto = {
424
+ toJSON() {
425
+ return toJSON(this);
426
+ },
427
+ [NodeInspectSymbol]() {
428
+ return this.toJSON();
429
+ },
430
+ toString() {
431
+ return format(this.toJSON());
432
+ }
433
+ };
434
+ var Class = class {
435
+ /**
436
+ * @since 2.0.0
437
+ */
438
+ [NodeInspectSymbol]() {
439
+ return this.toJSON();
440
+ }
441
+ /**
442
+ * @since 2.0.0
443
+ */
444
+ toString() {
445
+ return format(this.toJSON());
446
+ }
447
+ };
448
+ var symbolRedactable = /* @__PURE__ */ Symbol.for("effect/Inspectable/Redactable");
449
+ var isRedactable = (u) => typeof u === "object" && u !== null && symbolRedactable in u;
450
+ var redactableState = /* @__PURE__ */ globalValue("effect/Inspectable/redactableState", () => ({
451
+ fiberRefs: void 0
452
+ }));
453
+ var redact = (u) => {
454
+ if (isRedactable(u) && redactableState.fiberRefs !== void 0) {
455
+ return u[symbolRedactable](redactableState.fiberRefs);
456
+ }
457
+ return u;
458
+ };
438
459
 
439
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Pipeable.js
460
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Pipeable.js
440
461
  var pipeArguments = (self, args) => {
441
462
  switch (args.length) {
463
+ case 0:
464
+ return self;
442
465
  case 1:
443
466
  return args[0](self);
444
467
  case 2:
@@ -467,10 +490,10 @@ var pipeArguments = (self, args) => {
467
490
  }
468
491
  };
469
492
 
470
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/internal/opCodes/effect.js
493
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/opCodes/effect.js
471
494
  var OP_COMMIT = "Commit";
472
495
 
473
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/internal/effectable.js
496
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/effectable.js
474
497
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
475
498
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
476
499
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -482,19 +505,19 @@ var effectVariance = {
482
505
  _E: (_) => _,
483
506
  /* c8 ignore next */
484
507
  _A: (_) => _,
485
- _V: moduleVersion
508
+ _V: /* @__PURE__ */ getCurrentVersion()
486
509
  };
487
510
  var sinkVariance = {
488
511
  /* c8 ignore next */
489
- _R: (_) => _,
490
- /* c8 ignore next */
491
- _E: (_) => _,
512
+ _A: (_) => _,
492
513
  /* c8 ignore next */
493
514
  _In: (_) => _,
494
515
  /* c8 ignore next */
495
516
  _L: (_) => _,
496
517
  /* c8 ignore next */
497
- _Z: (_) => _
518
+ _E: (_) => _,
519
+ /* c8 ignore next */
520
+ _R: (_) => _
498
521
  };
499
522
  var channelVariance = {
500
523
  /* c8 ignore next */
@@ -521,7 +544,10 @@ var EffectPrototype = {
521
544
  return this === that;
522
545
  },
523
546
  [symbol]() {
524
- return random(this);
547
+ return cached(this, random(this));
548
+ },
549
+ [Symbol.iterator]() {
550
+ return new SingleShotGen(new YieldWrap(this));
525
551
  },
526
552
  pipe() {
527
553
  return pipeArguments(this, arguments);
@@ -529,7 +555,7 @@ var EffectPrototype = {
529
555
  };
530
556
  var StructuralPrototype = {
531
557
  [symbol]() {
532
- return structure(this);
558
+ return cached(this, structure(this));
533
559
  },
534
560
  [symbol2](that) {
535
561
  const selfKeys = Object.keys(this);
@@ -554,7 +580,7 @@ var StructuralCommitPrototype = {
554
580
  ...StructuralPrototype
555
581
  };
556
582
 
557
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/internal/option.js
583
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/option.js
558
584
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
559
585
  var CommonProto = {
560
586
  ...EffectPrototype,
@@ -572,10 +598,10 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
572
598
  _tag: "Some",
573
599
  _op: "Some",
574
600
  [symbol2](that) {
575
- return isOption(that) && isSome(that) && equals(that.value, this.value);
601
+ return isOption(that) && isSome(that) && equals(this.value, that.value);
576
602
  },
577
603
  [symbol]() {
578
- return combine(hash(this._tag))(hash(this.value));
604
+ return cached(this, combine(hash(this._tag))(hash(this.value)));
579
605
  },
580
606
  toJSON() {
581
607
  return {
@@ -585,6 +611,7 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
585
611
  };
586
612
  }
587
613
  });
614
+ var NoneHash = /* @__PURE__ */ hash("None");
588
615
  var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
589
616
  _tag: "None",
590
617
  _op: "None",
@@ -592,7 +619,7 @@ var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
592
619
  return isOption(that) && isNone(that);
593
620
  },
594
621
  [symbol]() {
595
- return combine(hash(this._tag));
622
+ return NoneHash;
596
623
  },
597
624
  toJSON() {
598
625
  return {
@@ -611,7 +638,10 @@ var some = (value) => {
611
638
  return a;
612
639
  };
613
640
 
614
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Option.js
641
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Order.js
642
+ var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
643
+
644
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Option.js
615
645
  var none2 = () => none;
616
646
  var some2 = some;
617
647
  var isNone2 = isNone;
@@ -621,17 +651,273 @@ var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : se
621
651
  var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
622
652
  var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
623
653
  var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value));
654
+ var all = (input) => {
655
+ if (Symbol.iterator in input) {
656
+ const out2 = [];
657
+ for (const o of input) {
658
+ if (isNone2(o)) {
659
+ return none2();
660
+ }
661
+ out2.push(o.value);
662
+ }
663
+ return some2(out2);
664
+ }
665
+ const out = {};
666
+ for (const key of Object.keys(input)) {
667
+ const o = input[key];
668
+ if (isNone2(o)) {
669
+ return none2();
670
+ }
671
+ out[key] = o.value;
672
+ }
673
+ return some2(out);
674
+ };
675
+ var adapter2 = /* @__PURE__ */ adapter();
676
+ var gen = (...args) => {
677
+ let f;
678
+ if (args.length === 1) {
679
+ f = args[0];
680
+ } else {
681
+ f = args[1].bind(args[0]);
682
+ }
683
+ const iterator = f(adapter2);
684
+ let state = iterator.next();
685
+ if (state.done) {
686
+ return some2(state.value);
687
+ } else {
688
+ let current = state.value;
689
+ if (isGenKind(current)) {
690
+ current = current.value;
691
+ } else {
692
+ current = yieldWrapGet(current);
693
+ }
694
+ if (isNone2(current)) {
695
+ return current;
696
+ }
697
+ while (!state.done) {
698
+ state = iterator.next(current.value);
699
+ if (!state.done) {
700
+ current = state.value;
701
+ if (isGenKind(current)) {
702
+ current = current.value;
703
+ } else {
704
+ current = yieldWrapGet(current);
705
+ }
706
+ if (isNone2(current)) {
707
+ return current;
708
+ }
709
+ }
710
+ }
711
+ return some2(state.value);
712
+ }
713
+ };
714
+
715
+ // src/definition.ts
716
+ function createRefactor(definition) {
717
+ return definition;
718
+ }
719
+ function createDiagnostic(definition) {
720
+ return definition;
721
+ }
624
722
 
625
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/ReadonlyArray.js
723
+ // src/utils/TypeParser.ts
724
+ var covariantTypeArgument = (type) => {
725
+ const signatures = type.getCallSignatures();
726
+ if (signatures.length !== 1)
727
+ return none2();
728
+ return some2(signatures[0].getReturnType());
729
+ };
730
+ function pipeableType(ts, typeChecker) {
731
+ return (type, atLocation) => {
732
+ const pipeSymbol = typeChecker.getPropertyOfType(type, "pipe");
733
+ if (!pipeSymbol)
734
+ return none2();
735
+ const pipeType = typeChecker.getTypeOfSymbolAtLocation(pipeSymbol, atLocation);
736
+ const signatures = pipeType.getCallSignatures();
737
+ if (signatures.length === 0)
738
+ return none2();
739
+ return some2(type);
740
+ };
741
+ }
742
+ function varianceStructCovariant(ts, typeChecker) {
743
+ return (type, atLocation, propertyName) => gen(function* (_) {
744
+ const propertySymbol = yield* fromNullable(
745
+ typeChecker.getPropertyOfType(type, propertyName)
746
+ );
747
+ const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
748
+ return yield* covariantTypeArgument(propertyType);
749
+ });
750
+ }
751
+ function effectVarianceStruct(ts, typeChecker) {
752
+ return (type, atLocation) => all({
753
+ A: varianceStructCovariant(ts, typeChecker)(type, atLocation, "_A"),
754
+ E: varianceStructCovariant(ts, typeChecker)(type, atLocation, "_E"),
755
+ R: varianceStructCovariant(ts, typeChecker)(type, atLocation, "_R")
756
+ });
757
+ }
758
+ function effectTypeArguments(ts, typeChecker) {
759
+ return (type, atLocation) => gen(function* (_) {
760
+ yield* pipeableType(ts, typeChecker)(type, atLocation);
761
+ for (const propertySymbol of typeChecker.getPropertiesOfType(type)) {
762
+ const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
763
+ const varianceArgs = effectVarianceStruct(ts, typeChecker)(
764
+ propertyType,
765
+ atLocation
766
+ );
767
+ if (isSome2(varianceArgs)) {
768
+ return yield* varianceArgs;
769
+ }
770
+ }
771
+ return yield* none2();
772
+ });
773
+ }
774
+ function importedEffectModule(ts, typeChecker) {
775
+ return (node) => gen(function* () {
776
+ const type = typeChecker.getTypeAtLocation(node);
777
+ const propertySymbol = yield* fromNullable(
778
+ typeChecker.getPropertyOfType(type, "never")
779
+ );
780
+ const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, node);
781
+ return yield* effectTypeArguments(ts, typeChecker)(propertyType, node).pipe(
782
+ map(() => node)
783
+ );
784
+ });
785
+ }
786
+ function effectGen(ts, typeChecker) {
787
+ return (node) => gen(function* () {
788
+ if (!ts.isCallExpression(node))
789
+ return yield* none2();
790
+ if (node.arguments.length === 0)
791
+ return yield* none2();
792
+ const generatorFunction = node.arguments[0];
793
+ if (!ts.isFunctionExpression(generatorFunction))
794
+ return yield* none2();
795
+ if (generatorFunction.asteriskToken === void 0)
796
+ return yield* none2();
797
+ if (!ts.isPropertyAccessExpression(node.expression))
798
+ return yield* none2();
799
+ const propertyAccess = node.expression;
800
+ if (propertyAccess.name.text !== "gen")
801
+ return yield* none2();
802
+ return yield* importedEffectModule(ts, typeChecker)(propertyAccess.expression).pipe(
803
+ map(() => ({ body: generatorFunction.body }))
804
+ );
805
+ });
806
+ }
807
+ function expectedAndRealType(ts, typeChecker) {
808
+ return (node) => {
809
+ if (ts.isVariableDeclaration(node) && node.initializer) {
810
+ const expectedType = typeChecker.getTypeAtLocation(node.name);
811
+ const realType = typeChecker.getTypeAtLocation(node.initializer);
812
+ return [[node.name, expectedType, node.initializer, realType]];
813
+ }
814
+ if (ts.isCallExpression(node)) {
815
+ const resolvedSignature = typeChecker.getResolvedSignature(node);
816
+ if (resolvedSignature) {
817
+ return resolvedSignature.getParameters().map((parameter, index) => {
818
+ const expectedType = typeChecker.getTypeOfSymbolAtLocation(parameter, node);
819
+ const realType = typeChecker.getTypeAtLocation(node.arguments[index]);
820
+ return [node.arguments[index], expectedType, node.arguments[index], realType];
821
+ });
822
+ }
823
+ }
824
+ if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
825
+ const parent = node.parent;
826
+ if (ts.isObjectLiteralElement(parent)) {
827
+ if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
828
+ const type = typeChecker.getContextualType(parent.parent);
829
+ if (type) {
830
+ const symbol3 = typeChecker.getPropertyOfType(type, node.text);
831
+ if (symbol3) {
832
+ const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
833
+ const realType = typeChecker.getTypeAtLocation(node);
834
+ return [[node, expectedType, node, realType]];
835
+ }
836
+ }
837
+ }
838
+ }
839
+ }
840
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
841
+ const expectedType = typeChecker.getTypeAtLocation(node.left);
842
+ const realType = typeChecker.getTypeAtLocation(node.right);
843
+ return [[node.left, expectedType, node.right, realType]];
844
+ }
845
+ if (ts.isReturnStatement(node) && node.expression) {
846
+ const expectedType = typeChecker.getContextualType(node.expression);
847
+ const realType = typeChecker.getTypeAtLocation(node.expression);
848
+ if (expectedType)
849
+ return [[node, expectedType, node, realType]];
850
+ }
851
+ if (ts.isArrowFunction(node) && ts.isExpression(node.body)) {
852
+ const body = node.body;
853
+ const expectedType = typeChecker.getContextualType(body);
854
+ const realType = typeChecker.getTypeAtLocation(body);
855
+ if (expectedType)
856
+ return [[body, expectedType, body, realType]];
857
+ }
858
+ if (ts.isSatisfiesExpression(node)) {
859
+ const expectedType = typeChecker.getTypeAtLocation(node.type);
860
+ const realType = typeChecker.getTypeAtLocation(node.expression);
861
+ return [[node.expression, expectedType, node.expression, realType]];
862
+ }
863
+ return [];
864
+ };
865
+ }
866
+
867
+ // src/diagnostics/floatingEffect.ts
868
+ var floatingEffect = createDiagnostic({
869
+ code: 3,
870
+ apply: (ts, program) => (sourceFile) => {
871
+ const typeChecker = program.getTypeChecker();
872
+ const effectDiagnostics = [];
873
+ const visit = (node) => {
874
+ if (ts.isExpressionStatement(node) && (ts.isBlock(node.parent) || ts.isSourceFile(node.parent))) {
875
+ const type = typeChecker.getTypeAtLocation(node.expression);
876
+ const effect = effectTypeArguments(ts, typeChecker)(type, node.expression);
877
+ if (isSome2(effect)) {
878
+ effectDiagnostics.push({
879
+ node,
880
+ category: ts.DiagnosticCategory.Error,
881
+ messageText: `Effect must be yielded or assigned to a variable.`
882
+ });
883
+ }
884
+ }
885
+ ts.forEachChild(node, visit);
886
+ };
887
+ ts.forEachChild(sourceFile, visit);
888
+ return effectDiagnostics;
889
+ }
890
+ });
891
+
892
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/array.js
893
+ var isNonEmptyArray = (self) => self.length > 0;
894
+
895
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Array.js
626
896
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
627
897
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
628
898
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
899
+ var isArray = Array.isArray;
900
+ var isNonEmptyReadonlyArray = isNonEmptyArray;
629
901
  var isOutOfBound = (i, as) => i < 0 || i >= as.length;
630
902
  var get = /* @__PURE__ */ dual(2, (self, index) => {
631
903
  const i = Math.floor(index);
632
904
  return isOutOfBound(i, self) ? none2() : some2(self[i]);
633
905
  });
906
+ var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
907
+ const i = Math.floor(index);
908
+ if (isOutOfBound(i, self)) {
909
+ throw new Error(`Index ${i} out of bounds`);
910
+ }
911
+ return self[i];
912
+ });
634
913
  var head = /* @__PURE__ */ get(0);
914
+ var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
915
+ var tailNonEmpty = (self) => self.slice(1);
916
+ var sort = /* @__PURE__ */ dual(2, (self, O) => {
917
+ const out = Array.from(self);
918
+ out.sort(O);
919
+ return out;
920
+ });
635
921
  var empty = () => [];
636
922
  var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
637
923
  var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
@@ -644,28 +930,22 @@ var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
644
930
  }
645
931
  return out;
646
932
  });
647
-
648
- // src/definition.ts
649
- function createRefactor(definition) {
650
- return definition;
651
- }
933
+ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
934
+ const input = fromIterable(self);
935
+ if (isNonEmptyReadonlyArray(input)) {
936
+ const out = [headNonEmpty(input)];
937
+ const rest = tailNonEmpty(input);
938
+ for (const r of rest) {
939
+ if (out.every((a) => !isEquivalent(r, a))) {
940
+ out.push(r);
941
+ }
942
+ }
943
+ return out;
944
+ }
945
+ return [];
946
+ });
652
947
 
653
948
  // src/utils/AST.ts
654
- var NoSuchSourceFile = class {
655
- constructor(fileName) {
656
- this.fileName = fileName;
657
- }
658
- _tag = "NoSuchSourceFile";
659
- };
660
- function getSourceFile(program) {
661
- return (fileName) => {
662
- const sourceFile = program.getSourceFile(fileName);
663
- if (!sourceFile) {
664
- throw new NoSuchSourceFile(fileName);
665
- }
666
- return sourceFile;
667
- };
668
- }
669
949
  function getNodesContainingRange(ts) {
670
950
  return (sourceFile, textRange) => {
671
951
  const precedingToken = ts.findPrecedingToken(textRange.pos, sourceFile);
@@ -674,7 +954,9 @@ function getNodesContainingRange(ts) {
674
954
  let result = empty();
675
955
  let parent = precedingToken;
676
956
  while (parent) {
677
- result = pipe(result, append(parent));
957
+ if (parent.end >= textRange.end) {
958
+ result = pipe(result, append(parent));
959
+ }
678
960
  parent = parent.parent;
679
961
  }
680
962
  return result;
@@ -763,20 +1045,14 @@ function findModuleImportIdentifierNameViaTypeChecker(ts, typeChecker) {
763
1045
  }));
764
1046
  };
765
1047
  }
766
- function transformAsyncAwaitToEffectGen(ts, preferredEffectGenAdapterName) {
1048
+ function transformAsyncAwaitToEffectGen(ts) {
767
1049
  return (node, effectName, onAwait) => {
768
1050
  function visitor(_) {
769
1051
  if (ts.isAwaitExpression(_)) {
770
1052
  const expression = ts.visitEachChild(_.expression, visitor, ts.nullTransformationContext);
771
1053
  return ts.factory.createYieldExpression(
772
1054
  ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
773
- ts.factory.createCallExpression(
774
- ts.factory.createIdentifier(preferredEffectGenAdapterName),
775
- void 0,
776
- [
777
- onAwait(expression)
778
- ]
779
- )
1055
+ onAwait(expression)
780
1056
  );
781
1057
  }
782
1058
  return ts.visitEachChild(_, visitor, ts.nullTransformationContext);
@@ -787,7 +1063,7 @@ function transformAsyncAwaitToEffectGen(ts, preferredEffectGenAdapterName) {
787
1063
  ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
788
1064
  void 0,
789
1065
  [],
790
- [ts.factory.createParameterDeclaration(void 0, void 0, preferredEffectGenAdapterName)],
1066
+ [],
791
1067
  void 0,
792
1068
  generatorBody
793
1069
  // NOTE(mattia): intended, to use same routine for both ConciseBody and Body
@@ -948,16 +1224,204 @@ function asDataFirstExpression(ts, checker) {
948
1224
  return none2();
949
1225
  };
950
1226
  }
1227
+ function deterministicTypeOrder(ts, typeChecker) {
1228
+ return make2((a, b) => {
1229
+ const aName = typeChecker.typeToString(a);
1230
+ const bName = typeChecker.typeToString(b);
1231
+ if (aName < bName)
1232
+ return -1;
1233
+ if (aName > bName)
1234
+ return 1;
1235
+ return 0;
1236
+ });
1237
+ }
1238
+
1239
+ // src/utils/TypeCheckerApi.ts
1240
+ function getMissingTypeEntriesInTargetType(ts, typeChecker) {
1241
+ return (realType, expectedType) => {
1242
+ const result = [];
1243
+ const toTest = [realType];
1244
+ while (toTest.length > 0) {
1245
+ const type = toTest.pop();
1246
+ if (!type)
1247
+ return result;
1248
+ if (type.isUnion()) {
1249
+ toTest.push(...type.types);
1250
+ } else {
1251
+ const assignable = typeChecker.isTypeAssignableTo(type, expectedType);
1252
+ if (!assignable) {
1253
+ result.push(type);
1254
+ }
1255
+ }
1256
+ }
1257
+ return result;
1258
+ };
1259
+ }
1260
+
1261
+ // src/diagnostics/missingEffectContext.ts
1262
+ var missingEffectContext = createDiagnostic({
1263
+ code: 1,
1264
+ apply: (ts, program) => (sourceFile) => {
1265
+ const typeChecker = program.getTypeChecker();
1266
+ const effectDiagnostics = [];
1267
+ const sortTypes = sort(deterministicTypeOrder(ts, typeChecker));
1268
+ const visit = (node) => {
1269
+ const entries = expectedAndRealType(ts, typeChecker)(node);
1270
+ for (const [node2, expectedType, valueNode, realType] of entries) {
1271
+ gen(function* () {
1272
+ const expectedEffect = yield* effectTypeArguments(ts, typeChecker)(
1273
+ expectedType,
1274
+ node2
1275
+ );
1276
+ const realEffect = yield* effectTypeArguments(ts, typeChecker)(
1277
+ realType,
1278
+ valueNode
1279
+ );
1280
+ const missingContext = getMissingTypeEntriesInTargetType(
1281
+ ts,
1282
+ typeChecker
1283
+ )(
1284
+ realEffect.R,
1285
+ expectedEffect.R
1286
+ );
1287
+ if (missingContext.length > 0) {
1288
+ effectDiagnostics.push(
1289
+ {
1290
+ node: node2,
1291
+ category: ts.DiagnosticCategory.Error,
1292
+ messageText: `Missing '${sortTypes(missingContext).map((_) => typeChecker.typeToString(_)).join(" | ")}' in the expected Effect context.`
1293
+ }
1294
+ );
1295
+ }
1296
+ });
1297
+ }
1298
+ ts.forEachChild(node, visit);
1299
+ };
1300
+ ts.forEachChild(sourceFile, visit);
1301
+ return effectDiagnostics;
1302
+ }
1303
+ });
1304
+
1305
+ // src/diagnostics/missingEffectError.ts
1306
+ var missingEffectError = createDiagnostic({
1307
+ code: 2,
1308
+ apply: (ts, program) => (sourceFile) => {
1309
+ const typeChecker = program.getTypeChecker();
1310
+ const effectDiagnostics = [];
1311
+ const sortTypes = sort(deterministicTypeOrder(ts, typeChecker));
1312
+ const visit = (node) => {
1313
+ const entries = expectedAndRealType(ts, typeChecker)(node);
1314
+ for (const [node2, expectedType, valueNode, realType] of entries) {
1315
+ gen(function* () {
1316
+ const expectedEffect = yield* effectTypeArguments(ts, typeChecker)(
1317
+ expectedType,
1318
+ node2
1319
+ );
1320
+ const realEffect = yield* effectTypeArguments(ts, typeChecker)(
1321
+ realType,
1322
+ valueNode
1323
+ );
1324
+ const missingErrorTypes = getMissingTypeEntriesInTargetType(
1325
+ ts,
1326
+ typeChecker
1327
+ )(
1328
+ realEffect.E,
1329
+ expectedEffect.E
1330
+ );
1331
+ if (missingErrorTypes.length > 0) {
1332
+ effectDiagnostics.push(
1333
+ {
1334
+ node: node2,
1335
+ category: ts.DiagnosticCategory.Error,
1336
+ messageText: `Missing '${sortTypes(missingErrorTypes).map((_) => typeChecker.typeToString(_)).join(" | ")}' in the expected Effect errors.`
1337
+ }
1338
+ );
1339
+ }
1340
+ });
1341
+ }
1342
+ ts.forEachChild(node, visit);
1343
+ };
1344
+ ts.forEachChild(sourceFile, visit);
1345
+ return effectDiagnostics;
1346
+ }
1347
+ });
1348
+
1349
+ // src/diagnostics/missingStarInYieldEffectGen.ts
1350
+ var missingStarInYieldEffectGen = createDiagnostic({
1351
+ code: 4,
1352
+ apply: (ts, program) => (sourceFile) => {
1353
+ const typeChecker = program.getTypeChecker();
1354
+ const effectDiagnostics = [];
1355
+ const visitWhileInGenerator = (node) => {
1356
+ if (ts.isYieldExpression(node) && node.expression && node.asteriskToken === void 0) {
1357
+ const type = typeChecker.getTypeAtLocation(node.expression);
1358
+ const effect = effectTypeArguments(ts, typeChecker)(type, node.expression);
1359
+ if (isSome2(effect)) {
1360
+ effectDiagnostics.push({
1361
+ node,
1362
+ category: ts.DiagnosticCategory.Error,
1363
+ messageText: `When yielding Effects inside Effect.gen, you should use yield* instead of yield.`
1364
+ });
1365
+ }
1366
+ }
1367
+ const effectGen2 = effectGen(ts, typeChecker)(node);
1368
+ if (isSome2(effectGen2)) {
1369
+ ts.forEachChild(effectGen2.value.body, visitWhileInGenerator);
1370
+ } else if ((ts.isFunctionExpression(node) || ts.isMethodDeclaration(node)) && node.asteriskToken !== void 0) {
1371
+ ts.forEachChild(node, visit);
1372
+ } else {
1373
+ ts.forEachChild(node, visitWhileInGenerator);
1374
+ }
1375
+ };
1376
+ const visit = (node) => {
1377
+ const effectGen2 = effectGen(ts, typeChecker)(node);
1378
+ if (isSome2(effectGen2)) {
1379
+ ts.forEachChild(effectGen2.value.body, visitWhileInGenerator);
1380
+ } else {
1381
+ ts.forEachChild(node, visit);
1382
+ }
1383
+ };
1384
+ ts.forEachChild(sourceFile, visit);
1385
+ return effectDiagnostics;
1386
+ }
1387
+ });
1388
+
1389
+ // src/diagnostics.ts
1390
+ var diagnostics = {
1391
+ missingEffectContext,
1392
+ missingEffectError,
1393
+ floatingEffect,
1394
+ missingStarInYieldEffectGen
1395
+ };
1396
+
1397
+ // src/quickinfo.ts
1398
+ var SymbolDisplayPartEq = make(
1399
+ (fa, fb) => fa.kind === fb.kind && fa.text === fb.text
1400
+ );
1401
+ var JSDocTagInfoEq = make(
1402
+ (fa, fb) => fa.name === fb.name && typeof fa.text === typeof fb.text && (typeof fa.text !== "undefined" ? array(SymbolDisplayPartEq)(fa.text, fb.text) : true)
1403
+ );
1404
+ function dedupeJsDocTags(quickInfo) {
1405
+ if (quickInfo.tags) {
1406
+ return {
1407
+ ...quickInfo,
1408
+ tags: dedupeWith(quickInfo.tags, JSDocTagInfoEq)
1409
+ };
1410
+ }
1411
+ return quickInfo;
1412
+ }
951
1413
 
952
1414
  // src/refactors/asyncAwaitToGen.ts
953
1415
  var asyncAwaitToGen = createRefactor({
954
1416
  name: "effect/asyncAwaitToGen",
955
1417
  description: "Convert to Effect.gen",
956
- apply: (ts, program, options) => (sourceFile, textRange) => pipe(
1418
+ apply: (ts, program) => (sourceFile, textRange) => pipe(
957
1419
  getNodesContainingRange(ts)(sourceFile, textRange),
958
1420
  filter(ts.isFunctionDeclaration),
959
1421
  filter((node) => !!node.body),
960
- filter((node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)),
1422
+ filter(
1423
+ (node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)
1424
+ ),
961
1425
  head,
962
1426
  map((node) => ({
963
1427
  kind: "refactor.rewrite.effect.asyncAwaitToGen",
@@ -965,8 +1429,7 @@ var asyncAwaitToGen = createRefactor({
965
1429
  apply: (changeTracker) => {
966
1430
  const effectName = getEffectModuleIdentifier(ts, program.getTypeChecker())(sourceFile);
967
1431
  const newDeclaration = transformAsyncAwaitToEffectGen(
968
- ts,
969
- options.preferredEffectGenAdapterName
1432
+ ts
970
1433
  )(
971
1434
  node,
972
1435
  effectName,
@@ -998,11 +1461,13 @@ var asyncAwaitToGen = createRefactor({
998
1461
  var asyncAwaitToGenTryPromise = createRefactor({
999
1462
  name: "effect/asyncAwaitToGenTryPromise",
1000
1463
  description: "Convert to Effect.gen with failures",
1001
- apply: (ts, program, options) => (sourceFile, textRange) => pipe(
1464
+ apply: (ts, program) => (sourceFile, textRange) => pipe(
1002
1465
  getNodesContainingRange(ts)(sourceFile, textRange),
1003
1466
  filter(ts.isFunctionDeclaration),
1004
1467
  filter((node) => !!node.body),
1005
- filter((node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)),
1468
+ filter(
1469
+ (node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)
1470
+ ),
1006
1471
  head,
1007
1472
  map((node) => ({
1008
1473
  kind: "refactor.rewrite.effect.asyncAwaitToGenTryPromise",
@@ -1024,8 +1489,7 @@ var asyncAwaitToGenTryPromise = createRefactor({
1024
1489
  ]);
1025
1490
  }
1026
1491
  const newDeclaration = transformAsyncAwaitToEffectGen(
1027
- ts,
1028
- options.preferredEffectGenAdapterName
1492
+ ts
1029
1493
  )(
1030
1494
  node,
1031
1495
  effectName,
@@ -1362,12 +1826,48 @@ var init = (modules) => {
1362
1826
  function create(info) {
1363
1827
  const languageService = info.languageService;
1364
1828
  const pluginOptions = {
1365
- preferredEffectGenAdapterName: info.config.preferredEffectGenAdapterName ?? "_"
1829
+ diagnostics: info.config && "diagnostics" in info.config && typeof info.config.diagnostics === "boolean" ? info.config.diagnostics : true
1366
1830
  };
1367
1831
  const proxy = /* @__PURE__ */ Object.create(null);
1368
1832
  for (const k of Object.keys(info.languageService)) {
1369
1833
  proxy[k] = (...args) => languageService[k].apply(languageService, args);
1370
1834
  }
1835
+ proxy.getSemanticDiagnostics = (fileName, ...args) => {
1836
+ const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args);
1837
+ const program = languageService.getProgram();
1838
+ if (pluginOptions.diagnostics && program) {
1839
+ const effectDiagnostics = pipe(
1840
+ fromNullable(program.getSourceFile(fileName)),
1841
+ map(
1842
+ (sourceFile) => pipe(
1843
+ Object.values(diagnostics).map(
1844
+ (diagnostic) => pipe(
1845
+ diagnostic.apply(modules.typescript, program, pluginOptions)(
1846
+ sourceFile,
1847
+ applicableDiagnostics
1848
+ ).map((_) => ({
1849
+ file: sourceFile,
1850
+ start: _.node.getStart(sourceFile),
1851
+ length: _.node.getEnd() - _.node.getStart(sourceFile),
1852
+ messageText: _.messageText,
1853
+ category: _.category,
1854
+ code: diagnostic.code,
1855
+ source: "effect"
1856
+ }))
1857
+ )
1858
+ ),
1859
+ (_) => _.reduce(
1860
+ (arr, maybeRefactor) => arr.concat(maybeRefactor),
1861
+ []
1862
+ )
1863
+ )
1864
+ ),
1865
+ getOrElse(() => [])
1866
+ );
1867
+ return effectDiagnostics.concat(applicableDiagnostics);
1868
+ }
1869
+ return applicableDiagnostics;
1870
+ };
1371
1871
  proxy.getApplicableRefactors = (...args) => {
1372
1872
  const applicableRefactors = languageService.getApplicableRefactors(...args);
1373
1873
  const [fileName, positionOrRange] = args;
@@ -1375,30 +1875,33 @@ var init = (modules) => {
1375
1875
  if (program) {
1376
1876
  const textRange = toTextRange(positionOrRange);
1377
1877
  const effectRefactors = pipe(
1378
- getSourceFile(program)(fileName),
1379
- (sourceFile) => pipe(
1380
- Object.values(refactors).map(
1381
- (refactor) => pipe(
1382
- refactor.apply(modules.typescript, program, pluginOptions)(
1383
- sourceFile,
1384
- textRange
1385
- ),
1386
- map((_) => ({
1387
- name: refactor.name,
1388
- description: refactor.description,
1389
- actions: [{
1878
+ fromNullable(program.getSourceFile(fileName)),
1879
+ map(
1880
+ (sourceFile) => pipe(
1881
+ Object.values(refactors).map(
1882
+ (refactor) => pipe(
1883
+ refactor.apply(modules.typescript, program, pluginOptions)(
1884
+ sourceFile,
1885
+ textRange
1886
+ ),
1887
+ map((_) => ({
1390
1888
  name: refactor.name,
1391
- description: _.description,
1392
- kind: _.kind
1393
- }]
1394
- }))
1889
+ description: refactor.description,
1890
+ actions: [{
1891
+ name: refactor.name,
1892
+ description: _.description,
1893
+ kind: _.kind
1894
+ }]
1895
+ }))
1896
+ )
1897
+ ),
1898
+ (_) => _.reduce(
1899
+ (arr, maybeRefactor) => arr.concat(isSome2(maybeRefactor) ? [maybeRefactor.value] : []),
1900
+ []
1395
1901
  )
1396
- ),
1397
- (_) => _.reduce(
1398
- (arr, maybeRefactor) => arr.concat(isSome2(maybeRefactor) ? [maybeRefactor.value] : []),
1399
- []
1400
1902
  )
1401
- )
1903
+ ),
1904
+ getOrElse(() => [])
1402
1905
  );
1403
1906
  info.project.projectService.logger.info(
1404
1907
  "[@effect/language-service] possible refactors are " + JSON.stringify(effectRefactors)
@@ -1412,11 +1915,15 @@ var init = (modules) => {
1412
1915
  if (program) {
1413
1916
  for (const refactor of Object.values(refactors)) {
1414
1917
  if (refactor.name === refactorName) {
1415
- const sourceFile = getSourceFile(program)(fileName);
1416
1918
  const textRange = toTextRange(positionOrRange);
1417
- const possibleRefactor = refactor.apply(modules.typescript, program, pluginOptions)(
1418
- sourceFile,
1419
- textRange
1919
+ const possibleRefactor = pipe(
1920
+ fromNullable(program.getSourceFile(fileName)),
1921
+ flatMap(
1922
+ (sourceFile) => refactor.apply(modules.typescript, program, pluginOptions)(
1923
+ sourceFile,
1924
+ textRange
1925
+ )
1926
+ )
1420
1927
  );
1421
1928
  if (isNone2(possibleRefactor)) {
1422
1929
  info.project.projectService.logger.info(
@@ -1450,8 +1957,16 @@ var init = (modules) => {
1450
1957
  ...args
1451
1958
  );
1452
1959
  };
1960
+ proxy.getQuickInfoAtPosition = (fileName, position, ...args) => {
1961
+ const quickInfo = languageService.getQuickInfoAtPosition(fileName, position, ...args);
1962
+ if (quickInfo) {
1963
+ return dedupeJsDocTags(quickInfo);
1964
+ }
1965
+ return quickInfo;
1966
+ };
1453
1967
  return proxy;
1454
1968
  }
1455
1969
  return { create };
1456
1970
  };
1457
1971
  module.exports = init;
1972
+ //# sourceMappingURL=index.cjs.map