@effect/language-service 0.2.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 +694 -245
  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,16 +355,42 @@ 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/Equivalence.js
393
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Equivalence.js
428
394
  var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
429
395
  var array = (item) => make((self, that) => {
430
396
  if (self.length !== that.length) {
@@ -439,21 +405,63 @@ var array = (item) => make((self, that) => {
439
405
  return true;
440
406
  });
441
407
 
442
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/Inspectable.js
408
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Inspectable.js
443
409
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
444
410
  var toJSON = (x) => {
445
- if (hasProperty(x, "toJSON") && isFunction2(x["toJSON"]) && x["toJSON"].length === 0) {
446
- return x.toJSON();
447
- } else if (Array.isArray(x)) {
448
- 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 {};
449
419
  }
450
- return x;
420
+ return redact(x);
451
421
  };
452
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
+ };
453
459
 
454
- // 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
455
461
  var pipeArguments = (self, args) => {
456
462
  switch (args.length) {
463
+ case 0:
464
+ return self;
457
465
  case 1:
458
466
  return args[0](self);
459
467
  case 2:
@@ -482,10 +490,10 @@ var pipeArguments = (self, args) => {
482
490
  }
483
491
  };
484
492
 
485
- // 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
486
494
  var OP_COMMIT = "Commit";
487
495
 
488
- // 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
489
497
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
490
498
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
491
499
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -497,19 +505,19 @@ var effectVariance = {
497
505
  _E: (_) => _,
498
506
  /* c8 ignore next */
499
507
  _A: (_) => _,
500
- _V: moduleVersion
508
+ _V: /* @__PURE__ */ getCurrentVersion()
501
509
  };
502
510
  var sinkVariance = {
503
511
  /* c8 ignore next */
504
- _R: (_) => _,
505
- /* c8 ignore next */
506
- _E: (_) => _,
512
+ _A: (_) => _,
507
513
  /* c8 ignore next */
508
514
  _In: (_) => _,
509
515
  /* c8 ignore next */
510
516
  _L: (_) => _,
511
517
  /* c8 ignore next */
512
- _Z: (_) => _
518
+ _E: (_) => _,
519
+ /* c8 ignore next */
520
+ _R: (_) => _
513
521
  };
514
522
  var channelVariance = {
515
523
  /* c8 ignore next */
@@ -536,7 +544,10 @@ var EffectPrototype = {
536
544
  return this === that;
537
545
  },
538
546
  [symbol]() {
539
- return random(this);
547
+ return cached(this, random(this));
548
+ },
549
+ [Symbol.iterator]() {
550
+ return new SingleShotGen(new YieldWrap(this));
540
551
  },
541
552
  pipe() {
542
553
  return pipeArguments(this, arguments);
@@ -544,7 +555,7 @@ var EffectPrototype = {
544
555
  };
545
556
  var StructuralPrototype = {
546
557
  [symbol]() {
547
- return structure(this);
558
+ return cached(this, structure(this));
548
559
  },
549
560
  [symbol2](that) {
550
561
  const selfKeys = Object.keys(this);
@@ -569,7 +580,7 @@ var StructuralCommitPrototype = {
569
580
  ...StructuralPrototype
570
581
  };
571
582
 
572
- // 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
573
584
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
574
585
  var CommonProto = {
575
586
  ...EffectPrototype,
@@ -587,10 +598,10 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
587
598
  _tag: "Some",
588
599
  _op: "Some",
589
600
  [symbol2](that) {
590
- return isOption(that) && isSome(that) && equals(that.value, this.value);
601
+ return isOption(that) && isSome(that) && equals(this.value, that.value);
591
602
  },
592
603
  [symbol]() {
593
- return combine(hash(this._tag))(hash(this.value));
604
+ return cached(this, combine(hash(this._tag))(hash(this.value)));
594
605
  },
595
606
  toJSON() {
596
607
  return {
@@ -600,6 +611,7 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
600
611
  };
601
612
  }
602
613
  });
614
+ var NoneHash = /* @__PURE__ */ hash("None");
603
615
  var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
604
616
  _tag: "None",
605
617
  _op: "None",
@@ -607,7 +619,7 @@ var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
607
619
  return isOption(that) && isNone(that);
608
620
  },
609
621
  [symbol]() {
610
- return combine(hash(this._tag));
622
+ return NoneHash;
611
623
  },
612
624
  toJSON() {
613
625
  return {
@@ -626,7 +638,10 @@ var some = (value) => {
626
638
  return a;
627
639
  };
628
640
 
629
- // 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
630
645
  var none2 = () => none;
631
646
  var some2 = some;
632
647
  var isNone2 = isNone;
@@ -636,14 +651,252 @@ var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : se
636
651
  var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
637
652
  var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
638
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
+ }
639
722
 
640
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/internal/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
641
893
  var isNonEmptyArray = (self) => self.length > 0;
642
894
 
643
- // node_modules/.pnpm/effect@2.0.0-next.59/node_modules/effect/dist/esm/ReadonlyArray.js
895
+ // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Array.js
644
896
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
645
897
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
646
898
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
899
+ var isArray = Array.isArray;
647
900
  var isNonEmptyReadonlyArray = isNonEmptyArray;
648
901
  var isOutOfBound = (i, as) => i < 0 || i >= as.length;
649
902
  var get = /* @__PURE__ */ dual(2, (self, index) => {
@@ -660,6 +913,11 @@ var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
660
913
  var head = /* @__PURE__ */ get(0);
661
914
  var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
662
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
+ });
663
921
  var empty = () => [];
664
922
  var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
665
923
  var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
@@ -687,44 +945,7 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
687
945
  return [];
688
946
  });
689
947
 
690
- // src/quickinfo.ts
691
- var SymbolDisplayPartEq = make(
692
- (fa, fb) => fa.kind === fb.kind && fa.text === fb.text
693
- );
694
- var JSDocTagInfoEq = make(
695
- (fa, fb) => fa.name === fb.name && typeof fa.text === typeof fb.text && (typeof fa.text !== "undefined" ? array(SymbolDisplayPartEq)(fa.text, fb.text) : true)
696
- );
697
- function dedupeJsDocTags(quickInfo) {
698
- if (quickInfo.tags) {
699
- return {
700
- ...quickInfo,
701
- tags: dedupeWith(quickInfo.tags, JSDocTagInfoEq)
702
- };
703
- }
704
- return quickInfo;
705
- }
706
-
707
- // src/definition.ts
708
- function createRefactor(definition) {
709
- return definition;
710
- }
711
-
712
948
  // src/utils/AST.ts
713
- var NoSuchSourceFile = class {
714
- constructor(fileName) {
715
- this.fileName = fileName;
716
- }
717
- _tag = "NoSuchSourceFile";
718
- };
719
- function getSourceFile(program) {
720
- return (fileName) => {
721
- const sourceFile = program.getSourceFile(fileName);
722
- if (!sourceFile) {
723
- throw new NoSuchSourceFile(fileName);
724
- }
725
- return sourceFile;
726
- };
727
- }
728
949
  function getNodesContainingRange(ts) {
729
950
  return (sourceFile, textRange) => {
730
951
  const precedingToken = ts.findPrecedingToken(textRange.pos, sourceFile);
@@ -733,7 +954,9 @@ function getNodesContainingRange(ts) {
733
954
  let result = empty();
734
955
  let parent = precedingToken;
735
956
  while (parent) {
736
- result = pipe(result, append(parent));
957
+ if (parent.end >= textRange.end) {
958
+ result = pipe(result, append(parent));
959
+ }
737
960
  parent = parent.parent;
738
961
  }
739
962
  return result;
@@ -822,20 +1045,14 @@ function findModuleImportIdentifierNameViaTypeChecker(ts, typeChecker) {
822
1045
  }));
823
1046
  };
824
1047
  }
825
- function transformAsyncAwaitToEffectGen(ts, preferredEffectGenAdapterName) {
1048
+ function transformAsyncAwaitToEffectGen(ts) {
826
1049
  return (node, effectName, onAwait) => {
827
1050
  function visitor(_) {
828
1051
  if (ts.isAwaitExpression(_)) {
829
1052
  const expression = ts.visitEachChild(_.expression, visitor, ts.nullTransformationContext);
830
1053
  return ts.factory.createYieldExpression(
831
1054
  ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
832
- ts.factory.createCallExpression(
833
- ts.factory.createIdentifier(preferredEffectGenAdapterName),
834
- void 0,
835
- [
836
- onAwait(expression)
837
- ]
838
- )
1055
+ onAwait(expression)
839
1056
  );
840
1057
  }
841
1058
  return ts.visitEachChild(_, visitor, ts.nullTransformationContext);
@@ -846,7 +1063,7 @@ function transformAsyncAwaitToEffectGen(ts, preferredEffectGenAdapterName) {
846
1063
  ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
847
1064
  void 0,
848
1065
  [],
849
- [ts.factory.createParameterDeclaration(void 0, void 0, preferredEffectGenAdapterName)],
1066
+ [],
850
1067
  void 0,
851
1068
  generatorBody
852
1069
  // NOTE(mattia): intended, to use same routine for both ConciseBody and Body
@@ -1007,16 +1224,204 @@ function asDataFirstExpression(ts, checker) {
1007
1224
  return none2();
1008
1225
  };
1009
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
+ }
1010
1413
 
1011
1414
  // src/refactors/asyncAwaitToGen.ts
1012
1415
  var asyncAwaitToGen = createRefactor({
1013
1416
  name: "effect/asyncAwaitToGen",
1014
1417
  description: "Convert to Effect.gen",
1015
- apply: (ts, program, options) => (sourceFile, textRange) => pipe(
1418
+ apply: (ts, program) => (sourceFile, textRange) => pipe(
1016
1419
  getNodesContainingRange(ts)(sourceFile, textRange),
1017
1420
  filter(ts.isFunctionDeclaration),
1018
1421
  filter((node) => !!node.body),
1019
- filter((node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)),
1422
+ filter(
1423
+ (node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)
1424
+ ),
1020
1425
  head,
1021
1426
  map((node) => ({
1022
1427
  kind: "refactor.rewrite.effect.asyncAwaitToGen",
@@ -1024,8 +1429,7 @@ var asyncAwaitToGen = createRefactor({
1024
1429
  apply: (changeTracker) => {
1025
1430
  const effectName = getEffectModuleIdentifier(ts, program.getTypeChecker())(sourceFile);
1026
1431
  const newDeclaration = transformAsyncAwaitToEffectGen(
1027
- ts,
1028
- options.preferredEffectGenAdapterName
1432
+ ts
1029
1433
  )(
1030
1434
  node,
1031
1435
  effectName,
@@ -1057,11 +1461,13 @@ var asyncAwaitToGen = createRefactor({
1057
1461
  var asyncAwaitToGenTryPromise = createRefactor({
1058
1462
  name: "effect/asyncAwaitToGenTryPromise",
1059
1463
  description: "Convert to Effect.gen with failures",
1060
- apply: (ts, program, options) => (sourceFile, textRange) => pipe(
1464
+ apply: (ts, program) => (sourceFile, textRange) => pipe(
1061
1465
  getNodesContainingRange(ts)(sourceFile, textRange),
1062
1466
  filter(ts.isFunctionDeclaration),
1063
1467
  filter((node) => !!node.body),
1064
- filter((node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)),
1468
+ filter(
1469
+ (node) => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)
1470
+ ),
1065
1471
  head,
1066
1472
  map((node) => ({
1067
1473
  kind: "refactor.rewrite.effect.asyncAwaitToGenTryPromise",
@@ -1083,8 +1489,7 @@ var asyncAwaitToGenTryPromise = createRefactor({
1083
1489
  ]);
1084
1490
  }
1085
1491
  const newDeclaration = transformAsyncAwaitToEffectGen(
1086
- ts,
1087
- options.preferredEffectGenAdapterName
1492
+ ts
1088
1493
  )(
1089
1494
  node,
1090
1495
  effectName,
@@ -1421,12 +1826,48 @@ var init = (modules) => {
1421
1826
  function create(info) {
1422
1827
  const languageService = info.languageService;
1423
1828
  const pluginOptions = {
1424
- preferredEffectGenAdapterName: info.config.preferredEffectGenAdapterName ?? "_"
1829
+ diagnostics: info.config && "diagnostics" in info.config && typeof info.config.diagnostics === "boolean" ? info.config.diagnostics : true
1425
1830
  };
1426
1831
  const proxy = /* @__PURE__ */ Object.create(null);
1427
1832
  for (const k of Object.keys(info.languageService)) {
1428
1833
  proxy[k] = (...args) => languageService[k].apply(languageService, args);
1429
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
+ };
1430
1871
  proxy.getApplicableRefactors = (...args) => {
1431
1872
  const applicableRefactors = languageService.getApplicableRefactors(...args);
1432
1873
  const [fileName, positionOrRange] = args;
@@ -1434,30 +1875,33 @@ var init = (modules) => {
1434
1875
  if (program) {
1435
1876
  const textRange = toTextRange(positionOrRange);
1436
1877
  const effectRefactors = pipe(
1437
- getSourceFile(program)(fileName),
1438
- (sourceFile) => pipe(
1439
- Object.values(refactors).map(
1440
- (refactor) => pipe(
1441
- refactor.apply(modules.typescript, program, pluginOptions)(
1442
- sourceFile,
1443
- textRange
1444
- ),
1445
- map((_) => ({
1446
- name: refactor.name,
1447
- description: refactor.description,
1448
- 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((_) => ({
1449
1888
  name: refactor.name,
1450
- description: _.description,
1451
- kind: _.kind
1452
- }]
1453
- }))
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
+ []
1454
1901
  )
1455
- ),
1456
- (_) => _.reduce(
1457
- (arr, maybeRefactor) => arr.concat(isSome2(maybeRefactor) ? [maybeRefactor.value] : []),
1458
- []
1459
1902
  )
1460
- )
1903
+ ),
1904
+ getOrElse(() => [])
1461
1905
  );
1462
1906
  info.project.projectService.logger.info(
1463
1907
  "[@effect/language-service] possible refactors are " + JSON.stringify(effectRefactors)
@@ -1471,11 +1915,15 @@ var init = (modules) => {
1471
1915
  if (program) {
1472
1916
  for (const refactor of Object.values(refactors)) {
1473
1917
  if (refactor.name === refactorName) {
1474
- const sourceFile = getSourceFile(program)(fileName);
1475
1918
  const textRange = toTextRange(positionOrRange);
1476
- const possibleRefactor = refactor.apply(modules.typescript, program, pluginOptions)(
1477
- sourceFile,
1478
- 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
+ )
1479
1927
  );
1480
1928
  if (isNone2(possibleRefactor)) {
1481
1929
  info.project.projectService.logger.info(
@@ -1521,3 +1969,4 @@ var init = (modules) => {
1521
1969
  return { create };
1522
1970
  };
1523
1971
  module.exports = init;
1972
+ //# sourceMappingURL=index.cjs.map