@effect/language-service 0.75.0 → 0.76.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.
@@ -27,15 +27,44 @@ __export(effect_lsp_patch_utils_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(effect_lsp_patch_utils_exports);
29
29
 
30
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Function.js
31
- var isFunction = (input) => typeof input === "function";
30
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Pipeable.js
31
+ var pipeArguments = (self, args3) => {
32
+ switch (args3.length) {
33
+ case 0:
34
+ return self;
35
+ case 1:
36
+ return args3[0](self);
37
+ case 2:
38
+ return args3[1](args3[0](self));
39
+ case 3:
40
+ return args3[2](args3[1](args3[0](self)));
41
+ case 4:
42
+ return args3[3](args3[2](args3[1](args3[0](self))));
43
+ case 5:
44
+ return args3[4](args3[3](args3[2](args3[1](args3[0](self)))));
45
+ case 6:
46
+ return args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self))))));
47
+ case 7:
48
+ return args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self)))))));
49
+ case 8:
50
+ return args3[7](args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self))))))));
51
+ case 9:
52
+ return args3[8](args3[7](args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self)))))))));
53
+ default: {
54
+ let ret = self;
55
+ for (let i = 0, len = args3.length; i < len; i++) {
56
+ ret = args3[i](ret);
57
+ }
58
+ return ret;
59
+ }
60
+ }
61
+ };
62
+
63
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Function.js
32
64
  var dual = function(arity, body) {
33
65
  if (typeof arity === "function") {
34
66
  return function() {
35
- if (arity(arguments)) {
36
- return body.apply(this, arguments);
37
- }
38
- return (self) => body(self, ...arguments);
67
+ return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
39
68
  };
40
69
  }
41
70
  switch (arity) {
@@ -60,32 +89,14 @@ var dual = function(arity, body) {
60
89
  return body(self, a, b);
61
90
  };
62
91
  };
63
- case 4:
64
- return function(a, b, c, d) {
65
- if (arguments.length >= 4) {
66
- return body(a, b, c, d);
67
- }
68
- return function(self) {
69
- return body(self, a, b, c);
70
- };
71
- };
72
- case 5:
73
- return function(a, b, c, d, e) {
74
- if (arguments.length >= 5) {
75
- return body(a, b, c, d, e);
76
- }
77
- return function(self) {
78
- return body(self, a, b, c, d);
79
- };
80
- };
81
92
  default:
82
93
  return function() {
83
94
  if (arguments.length >= arity) {
84
95
  return body.apply(this, arguments);
85
96
  }
86
- const args2 = arguments;
97
+ const args3 = arguments;
87
98
  return function(self) {
88
- return body(self, ...args2);
99
+ return body(self, ...args3);
89
100
  };
90
101
  };
91
102
  }
@@ -93,189 +104,57 @@ var dual = function(arity, body) {
93
104
  var identity = (a) => a;
94
105
  var constant = (value) => () => value;
95
106
  var constUndefined = /* @__PURE__ */ constant(void 0);
96
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
97
- switch (arguments.length) {
98
- case 1:
99
- return a;
100
- case 2:
101
- return ab(a);
102
- case 3:
103
- return bc(ab(a));
104
- case 4:
105
- return cd(bc(ab(a)));
106
- case 5:
107
- return de(cd(bc(ab(a))));
108
- case 6:
109
- return ef(de(cd(bc(ab(a)))));
110
- case 7:
111
- return fg(ef(de(cd(bc(ab(a))))));
112
- case 8:
113
- return gh(fg(ef(de(cd(bc(ab(a)))))));
114
- case 9:
115
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
116
- default: {
117
- let ret = arguments[0];
118
- for (let i = 1; i < arguments.length; i++) {
119
- ret = arguments[i](ret);
120
- }
121
- return ret;
122
- }
123
- }
107
+ function pipe(a, ...args3) {
108
+ return pipeArguments(a, args3);
124
109
  }
125
110
 
126
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/GlobalValue.js
127
- var globalStoreId = `effect/GlobalValue`;
128
- var globalStore;
129
- var globalValue = (id, compute) => {
130
- if (!globalStore) {
131
- globalThis[globalStoreId] ??= /* @__PURE__ */ new Map();
132
- globalStore = globalThis[globalStoreId];
133
- }
134
- if (!globalStore.has(id)) {
135
- globalStore.set(id, compute());
136
- }
137
- return globalStore.get(id);
111
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/equal.js
112
+ var getAllObjectKeys = (obj) => {
113
+ const keys2 = new Set(Reflect.ownKeys(obj));
114
+ if (obj.constructor === Object) return keys2;
115
+ if (obj instanceof Error) {
116
+ keys2.delete("stack");
117
+ }
118
+ const proto = Object.getPrototypeOf(obj);
119
+ let current = proto;
120
+ while (current !== null && current !== Object.prototype) {
121
+ const ownKeys = Reflect.ownKeys(current);
122
+ for (let i = 0; i < ownKeys.length; i++) {
123
+ keys2.add(ownKeys[i]);
124
+ }
125
+ current = Object.getPrototypeOf(current);
126
+ }
127
+ if (keys2.has("constructor") && typeof obj.constructor === "function" && proto === obj.constructor.prototype) {
128
+ keys2.delete("constructor");
129
+ }
130
+ return keys2;
138
131
  };
132
+ var byReferenceInstances = /* @__PURE__ */ new WeakSet();
139
133
 
140
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Predicate.js
141
- var isString = (input) => typeof input === "string";
142
- var isNumber = (input) => typeof input === "number";
143
- var isBoolean = (input) => typeof input === "boolean";
144
- var isFunction2 = isFunction;
145
- var isRecordOrArray = (input) => typeof input === "object" && input !== null;
146
- var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
147
- var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
148
- var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
149
-
150
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Utils.js
151
- var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
152
- var GenKindImpl = class {
153
- value;
154
- constructor(value) {
155
- this.value = value;
156
- }
157
- /**
158
- * @since 2.0.0
159
- */
160
- get _F() {
161
- return identity;
162
- }
163
- /**
164
- * @since 2.0.0
165
- */
166
- get _R() {
167
- return (_) => _;
168
- }
169
- /**
170
- * @since 2.0.0
171
- */
172
- get _O() {
173
- return (_) => _;
174
- }
175
- /**
176
- * @since 2.0.0
177
- */
178
- get _E() {
179
- return (_) => _;
180
- }
181
- /**
182
- * @since 2.0.0
183
- */
184
- [GenKindTypeId] = GenKindTypeId;
185
- /**
186
- * @since 2.0.0
187
- */
188
- [Symbol.iterator]() {
189
- return new SingleShotGen(this);
190
- }
191
- };
192
- var SingleShotGen = class _SingleShotGen {
193
- self;
194
- called = false;
195
- constructor(self) {
196
- this.self = self;
197
- }
198
- /**
199
- * @since 2.0.0
200
- */
201
- next(a) {
202
- return this.called ? {
203
- value: a,
204
- done: true
205
- } : (this.called = true, {
206
- value: this.self,
207
- done: false
208
- });
209
- }
210
- /**
211
- * @since 2.0.0
212
- */
213
- return(a) {
214
- return {
215
- value: a,
216
- done: true
217
- };
218
- }
219
- /**
220
- * @since 2.0.0
221
- */
222
- throw(e) {
223
- throw e;
224
- }
225
- /**
226
- * @since 2.0.0
227
- */
228
- [Symbol.iterator]() {
229
- return new _SingleShotGen(this.self);
230
- }
231
- };
232
- var MUL_HI = 1481765933 >>> 0;
233
- var MUL_LO = 1284865837 >>> 0;
234
- var YieldWrapTypeId = /* @__PURE__ */ Symbol.for("effect/Utils/YieldWrap");
235
- var YieldWrap = class {
236
- /**
237
- * @since 3.0.6
238
- */
239
- #value;
240
- constructor(value) {
241
- this.#value = value;
242
- }
243
- /**
244
- * @since 3.0.6
245
- */
246
- [YieldWrapTypeId]() {
247
- return this.#value;
248
- }
249
- };
250
- var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructuralRegion", () => ({
251
- enabled: false,
252
- tester: void 0
253
- }));
254
- var standard = {
255
- effect_internal_function: (body) => {
256
- return body();
257
- }
258
- };
259
- var forced = {
260
- effect_internal_function: (body) => {
261
- try {
262
- return body();
263
- } finally {
264
- }
265
- }
266
- };
267
- var isNotOptimizedAway = /* @__PURE__ */ standard.effect_internal_function(() => new Error().stack)?.includes("effect_internal_function") === true;
268
- var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forced.effect_internal_function;
269
- var genConstructor = function* () {
270
- }.constructor;
134
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Predicate.js
135
+ function isString(input) {
136
+ return typeof input === "string";
137
+ }
138
+ function isNumber(input) {
139
+ return typeof input === "number";
140
+ }
141
+ function isBoolean(input) {
142
+ return typeof input === "boolean";
143
+ }
144
+ function isFunction(input) {
145
+ return typeof input === "function";
146
+ }
147
+ function isObject(input) {
148
+ return typeof input === "object" && input !== null && !Array.isArray(input);
149
+ }
150
+ function isObjectKeyword(input) {
151
+ return typeof input === "object" && input !== null || isFunction(input);
152
+ }
153
+ var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObjectKeyword(self) && property in self);
271
154
 
272
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Hash.js
273
- var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
274
- var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
155
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Hash.js
156
+ var symbol = "~effect/interfaces/Hash";
275
157
  var hash = (self) => {
276
- if (structuralRegionState.enabled === true) {
277
- return 0;
278
- }
279
158
  switch (typeof self) {
280
159
  case "number":
281
160
  return number(self);
@@ -294,16 +173,32 @@ var hash = (self) => {
294
173
  if (self === null) {
295
174
  return string("null");
296
175
  } else if (self instanceof Date) {
297
- if (Number.isNaN(self.getTime())) {
298
- return string("Invalid Date");
299
- }
300
- return hash(self.toISOString());
301
- } else if (self instanceof URL) {
302
- return hash(self.href);
303
- } else if (isHash(self)) {
304
- return self[symbol]();
176
+ return string(self.toISOString());
177
+ } else if (self instanceof RegExp) {
178
+ return string(self.toString());
305
179
  } else {
306
- return random(self);
180
+ if (byReferenceInstances.has(self)) {
181
+ return random(self);
182
+ }
183
+ if (hashCache.has(self)) {
184
+ return hashCache.get(self);
185
+ }
186
+ const h = withVisitedTracking(self, () => {
187
+ if (isHash(self)) {
188
+ return self[symbol]();
189
+ } else if (typeof self === "function") {
190
+ return random(self);
191
+ } else if (Array.isArray(self)) {
192
+ return array(self);
193
+ } else if (self instanceof Map) {
194
+ return hashMap(self);
195
+ } else if (self instanceof Set) {
196
+ return hashSet(self);
197
+ }
198
+ return structure(self);
199
+ });
200
+ hashCache.set(self, h);
201
+ return h;
307
202
  }
308
203
  }
309
204
  default:
@@ -316,12 +211,18 @@ var random = (self) => {
316
211
  }
317
212
  return randomHashCache.get(self);
318
213
  };
319
- var combine = (b) => (self) => self * 53 ^ b;
214
+ var combine = /* @__PURE__ */ dual(2, (self, b) => self * 53 ^ b);
320
215
  var optimize = (n) => n & 3221225471 | n >>> 1 & 1073741824;
321
216
  var isHash = (u) => hasProperty(u, symbol);
322
217
  var number = (n) => {
323
- if (n !== n || n === Infinity) {
324
- return 0;
218
+ if (n !== n) {
219
+ return string("NaN");
220
+ }
221
+ if (n === Infinity) {
222
+ return string("Infinity");
223
+ }
224
+ if (n === -Infinity) {
225
+ return string("-Infinity");
325
226
  }
326
227
  let h = n | 0;
327
228
  if (h !== n) {
@@ -341,38 +242,37 @@ var string = (str) => {
341
242
  };
342
243
  var structureKeys = (o, keys2) => {
343
244
  let h = 12289;
344
- for (let i = 0; i < keys2.length; i++) {
345
- h ^= pipe(string(keys2[i]), combine(hash(o[keys2[i]])));
245
+ for (const key of keys2) {
246
+ h ^= combine(hash(key), hash(o[key]));
346
247
  }
347
248
  return optimize(h);
348
249
  };
349
- var structure = (o) => structureKeys(o, Object.keys(o));
350
- var cached = function() {
351
- if (arguments.length === 1) {
352
- const self2 = arguments[0];
353
- return function(hash3) {
354
- Object.defineProperty(self2, symbol, {
355
- value() {
356
- return hash3;
357
- },
358
- enumerable: false
359
- });
360
- return hash3;
361
- };
250
+ var structure = (o) => structureKeys(o, getAllObjectKeys(o));
251
+ var iterableWith = (seed, f) => (iter) => {
252
+ let h = seed;
253
+ for (const element of iter) {
254
+ h ^= f(element);
362
255
  }
363
- const self = arguments[0];
364
- const hash2 = arguments[1];
365
- Object.defineProperty(self, symbol, {
366
- value() {
367
- return hash2;
368
- },
369
- enumerable: false
370
- });
371
- return hash2;
256
+ return optimize(h);
372
257
  };
258
+ var array = /* @__PURE__ */ iterableWith(6151, hash);
259
+ var hashMap = /* @__PURE__ */ iterableWith(/* @__PURE__ */ string("Map"), ([k, v]) => combine(hash(k), hash(v)));
260
+ var hashSet = /* @__PURE__ */ iterableWith(/* @__PURE__ */ string("Set"), hash);
261
+ var randomHashCache = /* @__PURE__ */ new WeakMap();
262
+ var hashCache = /* @__PURE__ */ new WeakMap();
263
+ var visitedObjects = /* @__PURE__ */ new WeakSet();
264
+ function withVisitedTracking(obj, fn2) {
265
+ if (visitedObjects.has(obj)) {
266
+ return string("[Circular]");
267
+ }
268
+ visitedObjects.add(obj);
269
+ const result = fn2();
270
+ visitedObjects.delete(obj);
271
+ return result;
272
+ }
373
273
 
374
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Equal.js
375
- var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
274
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Equal.js
275
+ var symbol2 = "~effect/interfaces/Equal";
376
276
  function equals() {
377
277
  if (arguments.length === 1) {
378
278
  return (self) => compareBoth(self, arguments[0]);
@@ -380,71 +280,274 @@ function equals() {
380
280
  return compareBoth(arguments[0], arguments[1]);
381
281
  }
382
282
  function compareBoth(self, that) {
383
- if (self === that) {
384
- return true;
385
- }
283
+ if (self === that) return true;
284
+ if (self == null || that == null) return false;
386
285
  const selfType = typeof self;
387
286
  if (selfType !== typeof that) {
388
287
  return false;
389
288
  }
390
- if (selfType === "object" || selfType === "function") {
391
- if (self !== null && that !== null) {
392
- if (isEqual(self) && isEqual(that)) {
393
- if (hash(self) === hash(that) && self[symbol2](that)) {
394
- return true;
395
- } else {
396
- return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
397
- }
398
- } else if (self instanceof Date && that instanceof Date) {
399
- const t1 = self.getTime();
400
- const t2 = that.getTime();
401
- return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
402
- } else if (self instanceof URL && that instanceof URL) {
403
- return self.href === that.href;
404
- }
405
- }
406
- if (structuralRegionState.enabled) {
407
- if (Array.isArray(self) && Array.isArray(that)) {
408
- return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
409
- }
410
- if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(self) === Object.prototype) {
411
- const keysSelf = Object.keys(self);
412
- const keysThat = Object.keys(that);
413
- if (keysSelf.length === keysThat.length) {
414
- for (const key of keysSelf) {
415
- if (!(key in that && compareBoth(self[key], that[key]))) {
416
- return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
417
- }
418
- }
419
- return true;
420
- }
289
+ if (selfType === "number" && self !== self && that !== that) {
290
+ return true;
291
+ }
292
+ if (selfType !== "object" && selfType !== "function") {
293
+ return false;
294
+ }
295
+ if (byReferenceInstances.has(self) || byReferenceInstances.has(that)) {
296
+ return false;
297
+ }
298
+ return withCache(self, that, compareObjects);
299
+ }
300
+ function withVisitedTracking2(self, that, fn2) {
301
+ const hasLeft = visitedLeft.has(self);
302
+ const hasRight = visitedRight.has(that);
303
+ if (hasLeft && hasRight) {
304
+ return true;
305
+ }
306
+ if (hasLeft || hasRight) {
307
+ return false;
308
+ }
309
+ visitedLeft.add(self);
310
+ visitedRight.add(that);
311
+ const result = fn2();
312
+ visitedLeft.delete(self);
313
+ visitedRight.delete(that);
314
+ return result;
315
+ }
316
+ var visitedLeft = /* @__PURE__ */ new WeakSet();
317
+ var visitedRight = /* @__PURE__ */ new WeakSet();
318
+ function compareObjects(self, that) {
319
+ if (hash(self) !== hash(that)) {
320
+ return false;
321
+ } else if (self instanceof Date) {
322
+ if (!(that instanceof Date)) return false;
323
+ return self.toISOString() === that.toISOString();
324
+ } else if (self instanceof RegExp) {
325
+ if (!(that instanceof RegExp)) return false;
326
+ return self.toString() === that.toString();
327
+ }
328
+ const selfIsEqual = isEqual(self);
329
+ const thatIsEqual = isEqual(that);
330
+ if (selfIsEqual !== thatIsEqual) return false;
331
+ const bothEquals = selfIsEqual && thatIsEqual;
332
+ if (typeof self === "function" && !bothEquals) {
333
+ return false;
334
+ }
335
+ return withVisitedTracking2(self, that, () => {
336
+ if (bothEquals) {
337
+ return self[symbol2](that);
338
+ } else if (Array.isArray(self)) {
339
+ if (!Array.isArray(that) || self.length !== that.length) {
340
+ return false;
421
341
  }
422
- return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
342
+ return compareArrays(self, that);
343
+ } else if (self instanceof Map) {
344
+ if (!(that instanceof Map) || self.size !== that.size) {
345
+ return false;
346
+ }
347
+ return compareMaps(self, that);
348
+ } else if (self instanceof Set) {
349
+ if (!(that instanceof Set) || self.size !== that.size) {
350
+ return false;
351
+ }
352
+ return compareSets(self, that);
353
+ }
354
+ return compareRecords(self, that);
355
+ });
356
+ }
357
+ function withCache(self, that, f) {
358
+ let selfMap = equalityCache.get(self);
359
+ if (!selfMap) {
360
+ selfMap = /* @__PURE__ */ new WeakMap();
361
+ equalityCache.set(self, selfMap);
362
+ } else if (selfMap.has(that)) {
363
+ return selfMap.get(that);
364
+ }
365
+ const result = f(self, that);
366
+ selfMap.set(that, result);
367
+ let thatMap = equalityCache.get(that);
368
+ if (!thatMap) {
369
+ thatMap = /* @__PURE__ */ new WeakMap();
370
+ equalityCache.set(that, thatMap);
371
+ }
372
+ thatMap.set(self, result);
373
+ return result;
374
+ }
375
+ var equalityCache = /* @__PURE__ */ new WeakMap();
376
+ function compareArrays(self, that) {
377
+ for (let i = 0; i < self.length; i++) {
378
+ if (!compareBoth(self[i], that[i])) {
379
+ return false;
423
380
  }
424
381
  }
425
- return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
382
+ return true;
426
383
  }
384
+ function compareRecords(self, that) {
385
+ const selfKeys = getAllObjectKeys(self);
386
+ const thatKeys = getAllObjectKeys(that);
387
+ if (selfKeys.size !== thatKeys.size) {
388
+ return false;
389
+ }
390
+ for (const key of selfKeys) {
391
+ if (!thatKeys.has(key) || !compareBoth(self[key], that[key])) {
392
+ return false;
393
+ }
394
+ }
395
+ return true;
396
+ }
397
+ function makeCompareMap(keyEquivalence, valueEquivalence) {
398
+ return function compareMaps2(self, that) {
399
+ for (const [selfKey, selfValue] of self) {
400
+ let found = false;
401
+ for (const [thatKey, thatValue] of that) {
402
+ if (keyEquivalence(selfKey, thatKey) && valueEquivalence(selfValue, thatValue)) {
403
+ found = true;
404
+ break;
405
+ }
406
+ }
407
+ if (!found) {
408
+ return false;
409
+ }
410
+ }
411
+ return true;
412
+ };
413
+ }
414
+ var compareMaps = /* @__PURE__ */ makeCompareMap(compareBoth, compareBoth);
415
+ function makeCompareSet(equivalence) {
416
+ return function compareSets2(self, that) {
417
+ for (const selfValue of self) {
418
+ let found = false;
419
+ for (const thatValue of that) {
420
+ if (equivalence(selfValue, thatValue)) {
421
+ found = true;
422
+ break;
423
+ }
424
+ }
425
+ if (!found) {
426
+ return false;
427
+ }
428
+ }
429
+ return true;
430
+ };
431
+ }
432
+ var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth);
427
433
  var isEqual = (u) => hasProperty(u, symbol2);
428
- var equivalence = () => equals;
434
+ var asEquivalence = () => equals;
435
+
436
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Redactable.js
437
+ var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Inspectable/redactable");
438
+ var isRedactable = (u) => hasProperty(u, symbolRedactable);
439
+ function redact(u) {
440
+ if (isRedactable(u)) return getRedacted(u);
441
+ return u;
442
+ }
443
+ function getRedacted(redactable) {
444
+ return redactable[symbolRedactable](globalThis[currentFiberTypeId]?.services ?? emptyServiceMap);
445
+ }
446
+ var currentFiberTypeId = "~effect/Fiber/currentFiber";
447
+ var emptyServiceMap = {
448
+ "~effect/ServiceMap": {},
449
+ mapUnsafe: /* @__PURE__ */ new Map(),
450
+ pipe() {
451
+ return pipeArguments(this, arguments);
452
+ }
453
+ };
429
454
 
430
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Inspectable.js
455
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Formatter.js
456
+ function format(input, options) {
457
+ const space = options?.space ?? 0;
458
+ const seen = /* @__PURE__ */ new WeakSet();
459
+ const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
460
+ const ind = (d) => gap.repeat(d);
461
+ const wrap = (v, body) => {
462
+ const ctor = v?.constructor;
463
+ return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
464
+ };
465
+ const ownKeys = (o) => {
466
+ try {
467
+ return Reflect.ownKeys(o);
468
+ } catch {
469
+ return ["[ownKeys threw]"];
470
+ }
471
+ };
472
+ function recur(v, d = 0) {
473
+ if (Array.isArray(v)) {
474
+ if (seen.has(v)) return CIRCULAR;
475
+ seen.add(v);
476
+ if (!gap || v.length <= 1) return `[${v.map((x) => recur(x, d)).join(",")}]`;
477
+ const inner = v.map((x) => recur(x, d + 1)).join(",\n" + ind(d + 1));
478
+ return `[
479
+ ${ind(d + 1)}${inner}
480
+ ${ind(d)}]`;
481
+ }
482
+ if (v instanceof Date) return formatDate(v);
483
+ if (!options?.ignoreToString && hasProperty(v, "toString") && typeof v["toString"] === "function" && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
484
+ const s = safeToString(v);
485
+ if (v instanceof Error && v.cause) {
486
+ return `${s} (cause: ${recur(v.cause, d)})`;
487
+ }
488
+ return s;
489
+ }
490
+ if (typeof v === "string") return JSON.stringify(v);
491
+ if (typeof v === "number" || v == null || typeof v === "boolean" || typeof v === "symbol") return String(v);
492
+ if (typeof v === "bigint") return String(v) + "n";
493
+ if (typeof v === "object" || typeof v === "function") {
494
+ if (seen.has(v)) return CIRCULAR;
495
+ seen.add(v);
496
+ if (symbolRedactable in v) return format(getRedacted(v));
497
+ if (Symbol.iterator in v) {
498
+ return `${v.constructor.name}(${recur(Array.from(v), d)})`;
499
+ }
500
+ const keys2 = ownKeys(v);
501
+ if (!gap || keys2.length <= 1) {
502
+ const body2 = `{${keys2.map((k) => `${formatPropertyKey(k)}:${recur(v[k], d)}`).join(",")}}`;
503
+ return wrap(v, body2);
504
+ }
505
+ const body = `{
506
+ ${keys2.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${recur(v[k], d + 1)}`).join(",\n")}
507
+ ${ind(d)}}`;
508
+ return wrap(v, body);
509
+ }
510
+ return String(v);
511
+ }
512
+ return recur(input, 0);
513
+ }
514
+ var CIRCULAR = "[Circular]";
515
+ function formatPropertyKey(name) {
516
+ return typeof name === "string" ? JSON.stringify(name) : String(name);
517
+ }
518
+ function formatDate(date) {
519
+ try {
520
+ return date.toISOString();
521
+ } catch {
522
+ return "Invalid Date";
523
+ }
524
+ }
525
+ function safeToString(input) {
526
+ try {
527
+ const s = input.toString();
528
+ return typeof s === "string" ? s : String(s);
529
+ } catch {
530
+ return "[toString threw]";
531
+ }
532
+ }
533
+
534
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Inspectable.js
431
535
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
432
- var toJSON = (x) => {
536
+ var toJson = (input) => {
433
537
  try {
434
- if (hasProperty(x, "toJSON") && isFunction2(x["toJSON"]) && x["toJSON"].length === 0) {
435
- return x.toJSON();
436
- } else if (Array.isArray(x)) {
437
- return x.map(toJSON);
538
+ if (hasProperty(input, "toJSON") && isFunction(input["toJSON"]) && input["toJSON"].length === 0) {
539
+ return input.toJSON();
540
+ } else if (Array.isArray(input)) {
541
+ return input.map(toJson);
438
542
  }
439
543
  } catch {
440
- return {};
544
+ return "[toJSON threw]";
441
545
  }
442
- return redact(x);
546
+ return redact(input);
443
547
  };
444
- var format = (x) => JSON.stringify(x, null, 2);
445
548
  var BaseProto = {
446
549
  toJSON() {
447
- return toJSON(this);
550
+ return toJson(this);
448
551
  },
449
552
  [NodeInspectSymbol]() {
450
553
  return this.toJSON();
@@ -454,171 +557,447 @@ var BaseProto = {
454
557
  }
455
558
  };
456
559
  var Class = class {
560
+ /**
561
+ * Node.js custom inspection method.
562
+ *
563
+ * @since 2.0.0
564
+ */
565
+ [NodeInspectSymbol]() {
566
+ return this.toJSON();
567
+ }
568
+ /**
569
+ * Returns a formatted string representation of this object.
570
+ *
571
+ * @since 2.0.0
572
+ */
573
+ toString() {
574
+ return format(this.toJSON());
575
+ }
576
+ };
577
+
578
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Utils.js
579
+ var GenKindTypeId = "~effect/Utils/GenKind";
580
+ var GenKindImpl = class {
581
+ value;
582
+ constructor(value) {
583
+ this.value = value;
584
+ }
585
+ get _F() {
586
+ return identity;
587
+ }
588
+ get _R() {
589
+ return (_) => _;
590
+ }
591
+ get _O() {
592
+ return (_) => _;
593
+ }
594
+ get _E() {
595
+ return (_) => _;
596
+ }
597
+ [GenKindTypeId] = GenKindTypeId;
598
+ [Symbol.iterator]() {
599
+ return new SingleShotGen(this);
600
+ }
601
+ };
602
+ var SingleShotGen = class _SingleShotGen {
603
+ called = false;
604
+ self;
605
+ constructor(self) {
606
+ this.self = self;
607
+ }
608
+ /**
609
+ * @since 2.0.0
610
+ */
611
+ next(a) {
612
+ return this.called ? {
613
+ value: a,
614
+ done: true
615
+ } : (this.called = true, {
616
+ value: this.self,
617
+ done: false
618
+ });
619
+ }
457
620
  /**
458
621
  * @since 2.0.0
459
622
  */
623
+ [Symbol.iterator]() {
624
+ return new _SingleShotGen(this.self);
625
+ }
626
+ };
627
+ var InternalTypeId = "~effect/Effect/internal";
628
+ var standard = {
629
+ [InternalTypeId]: (body) => {
630
+ return body();
631
+ }
632
+ };
633
+ var forced = {
634
+ [InternalTypeId]: (body) => {
635
+ try {
636
+ return body();
637
+ } finally {
638
+ }
639
+ }
640
+ };
641
+ var isNotOptimizedAway = /* @__PURE__ */ standard[InternalTypeId](() => new Error().stack)?.includes(InternalTypeId) === true;
642
+ var internalCall = isNotOptimizedAway ? standard[InternalTypeId] : forced[InternalTypeId];
643
+ var genConstructor = function* () {
644
+ }.constructor;
645
+
646
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/core.js
647
+ var EffectTypeId = `~effect/Effect`;
648
+ var ExitTypeId = `~effect/Exit`;
649
+ var effectVariance = {
650
+ _A: identity,
651
+ _E: identity,
652
+ _R: identity
653
+ };
654
+ var identifier = `${EffectTypeId}/identifier`;
655
+ var args = `${EffectTypeId}/args`;
656
+ var evaluate = `${EffectTypeId}/evaluate`;
657
+ var contA = `${EffectTypeId}/successCont`;
658
+ var contE = `${EffectTypeId}/failureCont`;
659
+ var contAll = `${EffectTypeId}/ensureCont`;
660
+ var PipeInspectableProto = {
661
+ pipe() {
662
+ return pipeArguments(this, arguments);
663
+ },
664
+ toJSON() {
665
+ return {
666
+ ...this
667
+ };
668
+ },
669
+ toString() {
670
+ return format(this.toJSON(), {
671
+ ignoreToString: true,
672
+ space: 2
673
+ });
674
+ },
675
+ [NodeInspectSymbol]() {
676
+ return this.toJSON();
677
+ }
678
+ };
679
+ var StructuralProto = {
680
+ [symbol]() {
681
+ return structureKeys(this, Object.keys(this));
682
+ },
683
+ [symbol2](that) {
684
+ const selfKeys = Object.keys(this);
685
+ const thatKeys = Object.keys(that);
686
+ if (selfKeys.length !== thatKeys.length) return false;
687
+ for (let i = 0; i < selfKeys.length; i++) {
688
+ if (selfKeys[i] !== thatKeys[i] && !equals(this[selfKeys[i]], that[selfKeys[i]])) {
689
+ return false;
690
+ }
691
+ }
692
+ return true;
693
+ }
694
+ };
695
+ var YieldableProto = {
696
+ [Symbol.iterator]() {
697
+ return new SingleShotGen(this);
698
+ }
699
+ };
700
+ var YieldableErrorProto = {
701
+ ...YieldableProto,
702
+ pipe() {
703
+ return pipeArguments(this, arguments);
704
+ }
705
+ };
706
+ var EffectProto = {
707
+ [EffectTypeId]: effectVariance,
708
+ ...PipeInspectableProto,
709
+ [Symbol.iterator]() {
710
+ return new SingleShotGen(this);
711
+ },
712
+ asEffect() {
713
+ return this;
714
+ },
715
+ toJSON() {
716
+ return {
717
+ _id: "Effect",
718
+ op: this[identifier],
719
+ ...args in this ? {
720
+ args: this[args]
721
+ } : void 0
722
+ };
723
+ }
724
+ };
725
+ var isExit = (u) => hasProperty(u, ExitTypeId);
726
+ var CauseTypeId = "~effect/Cause";
727
+ var CauseReasonTypeId = "~effect/Cause/Reason";
728
+ var isCause = (self) => hasProperty(self, CauseTypeId);
729
+ var CauseImpl = class {
730
+ [CauseTypeId];
731
+ reasons;
732
+ constructor(failures) {
733
+ this[CauseTypeId] = CauseTypeId;
734
+ this.reasons = failures;
735
+ }
736
+ pipe() {
737
+ return pipeArguments(this, arguments);
738
+ }
739
+ toJSON() {
740
+ return {
741
+ _id: "Cause",
742
+ failures: this.reasons.map((f) => f.toJSON())
743
+ };
744
+ }
745
+ toString() {
746
+ return `Cause(${format(this.reasons)})`;
747
+ }
748
+ [NodeInspectSymbol]() {
749
+ return this.toJSON();
750
+ }
751
+ [symbol2](that) {
752
+ return isCause(that) && this.reasons.length === that.reasons.length && this.reasons.every((e, i) => equals(e, that.reasons[i]));
753
+ }
754
+ [symbol]() {
755
+ return array(this.reasons);
756
+ }
757
+ };
758
+ var annotationsMap = /* @__PURE__ */ new WeakMap();
759
+ var ReasonBase = class {
760
+ [CauseReasonTypeId];
761
+ annotations;
762
+ _tag;
763
+ constructor(_tag, annotations, originalError) {
764
+ this[CauseReasonTypeId] = CauseReasonTypeId;
765
+ this._tag = _tag;
766
+ if (annotations !== constEmptyAnnotations && typeof originalError === "object" && originalError !== null && annotations.size > 0) {
767
+ const prevAnnotations = annotationsMap.get(originalError);
768
+ if (prevAnnotations) {
769
+ annotations = new Map([...prevAnnotations, ...annotations]);
770
+ }
771
+ annotationsMap.set(originalError, annotations);
772
+ }
773
+ this.annotations = annotations;
774
+ }
775
+ annotate(annotations, options) {
776
+ if (annotations.mapUnsafe.size === 0) return this;
777
+ const newAnnotations = new Map(this.annotations);
778
+ annotations.mapUnsafe.forEach((value, key) => {
779
+ if (options?.overwrite !== true && newAnnotations.has(key)) return;
780
+ newAnnotations.set(key, value);
781
+ });
782
+ const self = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
783
+ self.annotations = newAnnotations;
784
+ return self;
785
+ }
786
+ pipe() {
787
+ return pipeArguments(this, arguments);
788
+ }
789
+ toString() {
790
+ return format(this);
791
+ }
460
792
  [NodeInspectSymbol]() {
461
- return this.toJSON();
793
+ return this.toString();
794
+ }
795
+ };
796
+ var constEmptyAnnotations = /* @__PURE__ */ new Map();
797
+ var Fail = class extends ReasonBase {
798
+ error;
799
+ constructor(error, annotations = constEmptyAnnotations) {
800
+ super("Fail", annotations, error);
801
+ this.error = error;
462
802
  }
463
- /**
464
- * @since 2.0.0
465
- */
466
803
  toString() {
467
- return format(this.toJSON());
804
+ return `Fail(${format(this.error)})`;
468
805
  }
469
- };
470
- var symbolRedactable = /* @__PURE__ */ Symbol.for("effect/Inspectable/Redactable");
471
- var isRedactable = (u) => typeof u === "object" && u !== null && symbolRedactable in u;
472
- var redactableState = /* @__PURE__ */ globalValue("effect/Inspectable/redactableState", () => ({
473
- fiberRefs: void 0
474
- }));
475
- var redact = (u) => {
476
- if (isRedactable(u) && redactableState.fiberRefs !== void 0) {
477
- return u[symbolRedactable](redactableState.fiberRefs);
806
+ toJSON() {
807
+ return {
808
+ _tag: "Fail",
809
+ error: this.error
810
+ };
478
811
  }
479
- return u;
480
- };
481
-
482
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Pipeable.js
483
- var pipeArguments = (self, args2) => {
484
- switch (args2.length) {
485
- case 0:
486
- return self;
487
- case 1:
488
- return args2[0](self);
489
- case 2:
490
- return args2[1](args2[0](self));
491
- case 3:
492
- return args2[2](args2[1](args2[0](self)));
493
- case 4:
494
- return args2[3](args2[2](args2[1](args2[0](self))));
495
- case 5:
496
- return args2[4](args2[3](args2[2](args2[1](args2[0](self)))));
497
- case 6:
498
- return args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))));
499
- case 7:
500
- return args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))));
501
- case 8:
502
- return args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))))));
503
- case 9:
504
- return args2[8](args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))))));
505
- default: {
506
- let ret = self;
507
- for (let i = 0, len = args2.length; i < len; i++) {
508
- ret = args2[i](ret);
509
- }
510
- return ret;
511
- }
812
+ [symbol2](that) {
813
+ return isFailReason(that) && equals(this.error, that.error) && equals(this.annotations, that.annotations);
814
+ }
815
+ [symbol]() {
816
+ return combine(string(this._tag))(combine(hash(this.error))(hash(this.annotations)));
512
817
  }
513
818
  };
514
-
515
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/opCodes/effect.js
516
- var OP_COMMIT = "Commit";
517
-
518
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/version.js
519
- var moduleVersion = "3.19.14";
520
- var getCurrentVersion = () => moduleVersion;
521
-
522
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/effectable.js
523
- var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
524
- var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
525
- var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
526
- var ChannelTypeId = /* @__PURE__ */ Symbol.for("effect/Channel");
527
- var effectVariance = {
528
- /* c8 ignore next */
529
- _R: (_) => _,
530
- /* c8 ignore next */
531
- _E: (_) => _,
532
- /* c8 ignore next */
533
- _A: (_) => _,
534
- _V: /* @__PURE__ */ getCurrentVersion()
819
+ var causeFail = (error) => new CauseImpl([new Fail(error)]);
820
+ var Die = class extends ReasonBase {
821
+ defect;
822
+ constructor(defect, annotations = constEmptyAnnotations) {
823
+ super("Die", annotations, defect);
824
+ this.defect = defect;
825
+ }
826
+ toString() {
827
+ return `Die(${format(this.defect)})`;
828
+ }
829
+ toJSON() {
830
+ return {
831
+ _tag: "Die",
832
+ defect: this.defect
833
+ };
834
+ }
835
+ [symbol2](that) {
836
+ return isDieReason(that) && equals(this.defect, that.defect) && equals(this.annotations, that.annotations);
837
+ }
838
+ [symbol]() {
839
+ return combine(string(this._tag))(combine(hash(this.defect))(hash(this.annotations)));
840
+ }
535
841
  };
536
- var sinkVariance = {
537
- /* c8 ignore next */
538
- _A: (_) => _,
539
- /* c8 ignore next */
540
- _In: (_) => _,
541
- /* c8 ignore next */
542
- _L: (_) => _,
543
- /* c8 ignore next */
544
- _E: (_) => _,
545
- /* c8 ignore next */
546
- _R: (_) => _
842
+ var causeDie = (defect) => new CauseImpl([new Die(defect)]);
843
+ var causeAnnotate = /* @__PURE__ */ dual((args3) => isCause(args3[0]), (self, annotations, options) => {
844
+ if (annotations.mapUnsafe.size === 0) return self;
845
+ return new CauseImpl(self.reasons.map((f) => f.annotate(annotations, options)));
846
+ });
847
+ var isFailReason = (self) => self._tag === "Fail";
848
+ var isDieReason = (self) => self._tag === "Die";
849
+ function defaultEvaluate(_fiber) {
850
+ return exitDie(`Effect.evaluate: Not implemented`);
851
+ }
852
+ var makePrimitiveProto = (options) => ({
853
+ ...EffectProto,
854
+ [identifier]: options.op,
855
+ [evaluate]: options[evaluate] ?? defaultEvaluate,
856
+ [contA]: options[contA],
857
+ [contE]: options[contE],
858
+ [contAll]: options[contAll]
859
+ });
860
+ var makePrimitive = (options) => {
861
+ const Proto = makePrimitiveProto(options);
862
+ return function() {
863
+ const self = Object.create(Proto);
864
+ self[args] = options.single === false ? arguments : arguments[0];
865
+ return self;
866
+ };
547
867
  };
548
- var channelVariance = {
549
- /* c8 ignore next */
550
- _Env: (_) => _,
551
- /* c8 ignore next */
552
- _InErr: (_) => _,
553
- /* c8 ignore next */
554
- _InElem: (_) => _,
555
- /* c8 ignore next */
556
- _InDone: (_) => _,
557
- /* c8 ignore next */
558
- _OutErr: (_) => _,
559
- /* c8 ignore next */
560
- _OutElem: (_) => _,
561
- /* c8 ignore next */
562
- _OutDone: (_) => _
868
+ var makeExit = (options) => {
869
+ const Proto = {
870
+ ...makePrimitiveProto(options),
871
+ [ExitTypeId]: ExitTypeId,
872
+ _tag: options.op,
873
+ get [options.prop]() {
874
+ return this[args];
875
+ },
876
+ toString() {
877
+ return `${options.op}(${format(this[args])})`;
878
+ },
879
+ toJSON() {
880
+ return {
881
+ _id: "Exit",
882
+ _tag: options.op,
883
+ [options.prop]: this[args]
884
+ };
885
+ },
886
+ [symbol2](that) {
887
+ return isExit(that) && that._tag === this._tag && equals(this[args], that[args]);
888
+ },
889
+ [symbol]() {
890
+ return combine(string(options.op), hash(this[args]));
891
+ }
892
+ };
893
+ return function(value) {
894
+ const self = Object.create(Proto);
895
+ self[args] = value;
896
+ return self;
897
+ };
563
898
  };
564
- var EffectPrototype = {
565
- [EffectTypeId]: effectVariance,
566
- [StreamTypeId]: effectVariance,
567
- [SinkTypeId]: sinkVariance,
568
- [ChannelTypeId]: channelVariance,
569
- [symbol2](that) {
570
- return this === that;
571
- },
572
- [symbol]() {
573
- return cached(this, random(this));
574
- },
575
- [Symbol.iterator]() {
576
- return new SingleShotGen(new YieldWrap(this));
577
- },
578
- pipe() {
579
- return pipeArguments(this, arguments);
899
+ var exitSucceed = /* @__PURE__ */ makeExit({
900
+ op: "Success",
901
+ prop: "value",
902
+ [evaluate](fiber) {
903
+ const cont = fiber.getCont(contA);
904
+ return cont ? cont[contA](this[args], fiber, this) : fiber.yieldWith(this);
580
905
  }
906
+ });
907
+ var StackTraceKey = {
908
+ key: "effect/Cause/StackTrace"
581
909
  };
582
- var StructuralPrototype = {
583
- [symbol]() {
584
- return cached(this, structure(this));
585
- },
586
- [symbol2](that) {
587
- const selfKeys = Object.keys(this);
588
- const thatKeys = Object.keys(that);
589
- if (selfKeys.length !== thatKeys.length) {
590
- return false;
910
+ var exitFailCause = /* @__PURE__ */ makeExit({
911
+ op: "Failure",
912
+ prop: "cause",
913
+ [evaluate](fiber) {
914
+ let cause = this[args];
915
+ let annotated = false;
916
+ if (fiber.currentStackFrame) {
917
+ cause = causeAnnotate(cause, {
918
+ mapUnsafe: /* @__PURE__ */ new Map([[StackTraceKey.key, fiber.currentStackFrame]])
919
+ });
920
+ annotated = true;
591
921
  }
592
- for (const key of selfKeys) {
593
- if (!(key in that && equals(this[key], that[key]))) {
594
- return false;
595
- }
922
+ let cont = fiber.getCont(contE);
923
+ while (fiber.interruptible && fiber._interruptedCause && cont) {
924
+ cont = fiber.getCont(contE);
596
925
  }
597
- return true;
926
+ return cont ? cont[contE](cause, fiber, annotated ? void 0 : this) : fiber.yieldWith(annotated ? this : exitFailCause(cause));
598
927
  }
928
+ });
929
+ var exitFail = (e) => exitFailCause(causeFail(e));
930
+ var exitDie = (defect) => exitFailCause(causeDie(defect));
931
+ var withFiber = /* @__PURE__ */ makePrimitive({
932
+ op: "WithFiber",
933
+ [evaluate](fiber) {
934
+ return this[args](fiber);
935
+ }
936
+ });
937
+ var YieldableError = /* @__PURE__ */ (function() {
938
+ class YieldableError2 extends globalThis.Error {
939
+ asEffect() {
940
+ return exitFail(this);
941
+ }
942
+ }
943
+ Object.assign(YieldableError2.prototype, YieldableErrorProto);
944
+ return YieldableError2;
945
+ })();
946
+ var Error2 = /* @__PURE__ */ (function() {
947
+ const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
948
+ return class Base extends YieldableError {
949
+ constructor(args3) {
950
+ super(args3?.message, args3?.cause ? {
951
+ cause: args3.cause
952
+ } : void 0);
953
+ if (args3) {
954
+ Object.assign(this, args3);
955
+ Object.defineProperty(this, plainArgsSymbol, {
956
+ value: args3,
957
+ enumerable: false
958
+ });
959
+ }
960
+ }
961
+ toJSON() {
962
+ return {
963
+ ...this[plainArgsSymbol],
964
+ ...this
965
+ };
966
+ }
967
+ };
968
+ })();
969
+ var TaggedError = (tag) => {
970
+ class Base extends Error2 {
971
+ _tag = tag;
972
+ }
973
+ ;
974
+ Base.prototype.name = tag;
975
+ return Base;
599
976
  };
600
- var CommitPrototype = {
601
- ...EffectPrototype,
602
- _op: OP_COMMIT
977
+ var NoSuchElementErrorTypeId = "~effect/Cause/NoSuchElementError";
978
+ var NoSuchElementError = class extends (/* @__PURE__ */ TaggedError("NoSuchElementError")) {
979
+ [NoSuchElementErrorTypeId] = NoSuchElementErrorTypeId;
980
+ constructor(message) {
981
+ super({
982
+ message
983
+ });
984
+ }
603
985
  };
604
- var StructuralCommitPrototype = {
605
- ...CommitPrototype,
606
- ...StructuralPrototype
986
+ var DoneTypeId = "~effect/Cause/Done";
987
+ var DoneVoid = {
988
+ [DoneTypeId]: DoneTypeId,
989
+ _tag: "Done",
990
+ value: void 0
607
991
  };
608
992
 
609
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/option.js
610
- var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
993
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/option.js
994
+ var TypeId = "~effect/data/Option";
611
995
  var CommonProto = {
612
- ...EffectPrototype,
613
996
  [TypeId]: {
614
997
  _A: (_) => _
615
998
  },
616
- [NodeInspectSymbol]() {
617
- return this.toJSON();
618
- },
619
- toString() {
620
- return format(this.toJSON());
621
- }
999
+ ...PipeInspectableProto,
1000
+ ...YieldableProto
622
1001
  };
623
1002
  var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
624
1003
  _tag: "Some",
@@ -627,14 +1006,20 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
627
1006
  return isOption(that) && isSome(that) && equals(this.value, that.value);
628
1007
  },
629
1008
  [symbol]() {
630
- return cached(this, combine(hash(this._tag))(hash(this.value)));
1009
+ return combine(hash(this._tag))(hash(this.value));
1010
+ },
1011
+ toString() {
1012
+ return `some(${format(this.value)})`;
631
1013
  },
632
1014
  toJSON() {
633
1015
  return {
634
1016
  _id: "Option",
635
1017
  _tag: this._tag,
636
- value: toJSON(this.value)
1018
+ value: toJson(this.value)
637
1019
  };
1020
+ },
1021
+ asEffect() {
1022
+ return exitSucceed(this.value);
638
1023
  }
639
1024
  });
640
1025
  var NoneHash = /* @__PURE__ */ hash("None");
@@ -647,11 +1032,17 @@ var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
647
1032
  [symbol]() {
648
1033
  return NoneHash;
649
1034
  },
1035
+ toString() {
1036
+ return `none()`;
1037
+ },
650
1038
  toJSON() {
651
1039
  return {
652
1040
  _id: "Option",
653
1041
  _tag: this._tag
654
1042
  };
1043
+ },
1044
+ asEffect() {
1045
+ return exitFail(new NoSuchElementError());
655
1046
  }
656
1047
  });
657
1048
  var isOption = (input) => hasProperty(input, TypeId);
@@ -664,94 +1055,113 @@ var some = (value) => {
664
1055
  return a;
665
1056
  };
666
1057
 
667
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/either.js
668
- var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
1058
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/result.js
1059
+ var TypeId2 = "~effect/data/Result";
669
1060
  var CommonProto2 = {
670
- ...EffectPrototype,
671
1061
  [TypeId2]: {
672
- _R: (_) => _
673
- },
674
- [NodeInspectSymbol]() {
675
- return this.toJSON();
1062
+ /* v8 ignore next 2 */
1063
+ _A: (_) => _,
1064
+ _E: (_) => _
676
1065
  },
677
- toString() {
678
- return format(this.toJSON());
679
- }
1066
+ ...PipeInspectableProto,
1067
+ ...YieldableProto
680
1068
  };
681
- var RightProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
682
- _tag: "Right",
683
- _op: "Right",
1069
+ var SuccessProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
1070
+ _tag: "Success",
1071
+ _op: "Success",
684
1072
  [symbol2](that) {
685
- return isEither(that) && isRight(that) && equals(this.right, that.right);
1073
+ return isResult(that) && isSuccess(that) && equals(this.success, that.success);
686
1074
  },
687
1075
  [symbol]() {
688
- return combine(hash(this._tag))(hash(this.right));
1076
+ return combine(hash(this._tag))(hash(this.success));
1077
+ },
1078
+ toString() {
1079
+ return `success(${format(this.success)})`;
689
1080
  },
690
1081
  toJSON() {
691
1082
  return {
692
- _id: "Either",
1083
+ _id: "Result",
693
1084
  _tag: this._tag,
694
- right: toJSON(this.right)
1085
+ value: toJson(this.success)
695
1086
  };
1087
+ },
1088
+ asEffect() {
1089
+ return exitSucceed(this.success);
696
1090
  }
697
1091
  });
698
- var LeftProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
699
- _tag: "Left",
700
- _op: "Left",
1092
+ var FailureProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
1093
+ _tag: "Failure",
1094
+ _op: "Failure",
701
1095
  [symbol2](that) {
702
- return isEither(that) && isLeft(that) && equals(this.left, that.left);
1096
+ return isResult(that) && isFailure(that) && equals(this.failure, that.failure);
703
1097
  },
704
1098
  [symbol]() {
705
- return combine(hash(this._tag))(hash(this.left));
1099
+ return combine(hash(this._tag))(hash(this.failure));
1100
+ },
1101
+ toString() {
1102
+ return `failure(${format(this.failure)})`;
706
1103
  },
707
1104
  toJSON() {
708
1105
  return {
709
- _id: "Either",
1106
+ _id: "Result",
710
1107
  _tag: this._tag,
711
- left: toJSON(this.left)
1108
+ failure: toJson(this.failure)
712
1109
  };
1110
+ },
1111
+ asEffect() {
1112
+ return exitFail(this.failure);
713
1113
  }
714
1114
  });
715
- var isEither = (input) => hasProperty(input, TypeId2);
716
- var isLeft = (ma) => ma._tag === "Left";
717
- var isRight = (ma) => ma._tag === "Right";
718
- var left = (left3) => {
719
- const a = Object.create(LeftProto);
720
- a.left = left3;
1115
+ var isResult = (input) => hasProperty(input, TypeId2);
1116
+ var isFailure = (result) => result._tag === "Failure";
1117
+ var isSuccess = (result) => result._tag === "Success";
1118
+ var fail = (failure) => {
1119
+ const a = Object.create(FailureProto);
1120
+ a.failure = failure;
721
1121
  return a;
722
1122
  };
723
- var right = (right3) => {
724
- const a = Object.create(RightProto);
725
- a.right = right3;
1123
+ var succeed = (success) => {
1124
+ const a = Object.create(SuccessProto);
1125
+ a.success = success;
726
1126
  return a;
727
1127
  };
728
1128
 
729
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Either.js
730
- var right2 = right;
731
- var left2 = left;
732
- var isLeft2 = isLeft;
733
- var isRight2 = isRight;
734
- var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
735
- var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
736
-
737
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/array.js
738
- var isNonEmptyArray = (self) => self.length > 0;
739
-
740
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Order.js
741
- var make = (compare) => (self, that) => self === that ? 0 : compare(self, that);
742
- var string2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
1129
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Order.js
1130
+ function make(compare) {
1131
+ return (self, that) => self === that ? 0 : compare(self, that);
1132
+ }
1133
+ var String2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
743
1134
 
744
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Option.js
1135
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Option.js
745
1136
  var none2 = () => none;
746
1137
  var some2 = some;
747
1138
  var isNone2 = isNone;
748
1139
  var isSome2 = isSome;
749
- var getOrElse2 = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
1140
+ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
750
1141
  var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
751
- var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
752
- var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
1142
+ var fromNullishOr = (a) => a == null ? none2() : some2(a);
1143
+ var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
1144
+
1145
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Result.js
1146
+ var succeed2 = succeed;
1147
+ var fail2 = fail;
1148
+ var isFailure2 = isFailure;
1149
+ var isSuccess2 = isSuccess;
1150
+ var map = /* @__PURE__ */ dual(2, (self, f) => isSuccess2(self) ? succeed2(f(self.success)) : fail2(self.failure));
1151
+ var getOrElse2 = /* @__PURE__ */ dual(2, (self, onFailure) => isFailure2(self) ? onFailure(self.failure) : self.success);
1152
+
1153
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Filter.js
1154
+ var apply = (filter2, input, ...args3) => {
1155
+ const result = filter2(input, ...args3);
1156
+ if (result === true) return succeed2(input);
1157
+ if (result === false) return fail2(input);
1158
+ return result;
1159
+ };
753
1160
 
754
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Record.js
1161
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/array.js
1162
+ var isArrayNonEmpty = (self) => self.length > 0;
1163
+
1164
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Record.js
755
1165
  var map2 = /* @__PURE__ */ dual(2, (self, f) => {
756
1166
  const out = {
757
1167
  ...self
@@ -763,31 +1173,34 @@ var map2 = /* @__PURE__ */ dual(2, (self, f) => {
763
1173
  });
764
1174
  var keys = (self) => Object.keys(self);
765
1175
 
766
- // ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Array.js
767
- var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
1176
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Array.js
1177
+ var Array2 = globalThis.Array;
1178
+ var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection);
768
1179
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
769
1180
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
770
- var isArray = Array.isArray;
771
- var isEmptyArray = (self) => self.length === 0;
772
- var isEmptyReadonlyArray = isEmptyArray;
773
- var isNonEmptyReadonlyArray = isNonEmptyArray;
774
- var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
1181
+ var isArray = Array2.isArray;
1182
+ var isArrayEmpty = (self) => self.length === 0;
1183
+ var isReadonlyArrayEmpty = isArrayEmpty;
1184
+ var isReadonlyArrayNonEmpty = isArrayNonEmpty;
1185
+ function isOutOfBounds(i, as) {
1186
+ return i < 0 || i >= as.length;
1187
+ }
775
1188
  var get = /* @__PURE__ */ dual(2, (self, index) => {
776
1189
  const i = Math.floor(index);
777
1190
  return isOutOfBounds(i, self) ? none2() : some2(self[i]);
778
1191
  });
779
- var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
1192
+ var getUnsafe = /* @__PURE__ */ dual(2, (self, index) => {
780
1193
  const i = Math.floor(index);
781
1194
  if (isOutOfBounds(i, self)) {
782
- throw new Error(`Index ${i} out of bounds`);
1195
+ throw new Error(`Index out of bounds: ${i}`);
783
1196
  }
784
1197
  return self[i];
785
1198
  });
786
1199
  var head = /* @__PURE__ */ get(0);
787
- var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
1200
+ var headNonEmpty = /* @__PURE__ */ getUnsafe(0);
788
1201
  var tailNonEmpty = (self) => self.slice(1);
789
1202
  var sort = /* @__PURE__ */ dual(2, (self, O) => {
790
- const out = Array.from(self);
1203
+ const out = Array2.from(self);
791
1204
  out.sort(O);
792
1205
  return out;
793
1206
  });
@@ -799,19 +1212,18 @@ var containsWith = (isEquivalent) => dual(2, (self, a) => {
799
1212
  }
800
1213
  return false;
801
1214
  });
802
- var _equivalence = /* @__PURE__ */ equivalence();
803
1215
  var intersectionWith = (isEquivalent) => {
804
1216
  const has = containsWith(isEquivalent);
805
1217
  return dual(2, (self, that) => {
806
- const bs = fromIterable(that);
807
- return fromIterable(self).filter((a) => has(bs, a));
1218
+ const thatArray = fromIterable(that);
1219
+ return fromIterable(self).filter((a) => has(thatArray, a));
808
1220
  });
809
1221
  };
810
- var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
1222
+ var intersection = /* @__PURE__ */ intersectionWith(/* @__PURE__ */ asEquivalence());
811
1223
  var empty = () => [];
812
1224
  var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
813
1225
  var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
814
- if (isEmptyReadonlyArray(self)) {
1226
+ if (isReadonlyArrayEmpty(self)) {
815
1227
  return [];
816
1228
  }
817
1229
  const out = [];
@@ -824,19 +1236,20 @@ var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
824
1236
  return out;
825
1237
  });
826
1238
  var flatten = /* @__PURE__ */ flatMap(identity);
827
- var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
1239
+ var filter = /* @__PURE__ */ dual(2, (self, f) => {
828
1240
  const as = fromIterable(self);
829
1241
  const out = [];
830
1242
  for (let i = 0; i < as.length; i++) {
831
- if (predicate(as[i], i)) {
832
- out.push(as[i]);
1243
+ const result = apply(f, as[i], i);
1244
+ if (!isFailure2(result)) {
1245
+ out.push(result.success);
833
1246
  }
834
1247
  }
835
1248
  return out;
836
1249
  });
837
1250
  var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
838
1251
  const input = fromIterable(self);
839
- if (isNonEmptyReadonlyArray(input)) {
1252
+ if (isReadonlyArrayNonEmpty(input)) {
840
1253
  const out = [headNonEmpty(input)];
841
1254
  const rest = tailNonEmpty(input);
842
1255
  for (const r of rest) {
@@ -848,16 +1261,17 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
848
1261
  }
849
1262
  return [];
850
1263
  });
851
- var dedupe = (self) => dedupeWith(self, equivalence());
1264
+ var dedupe = (self) => dedupeWith(self, asEquivalence());
852
1265
  var join = /* @__PURE__ */ dual(2, (self, sep) => fromIterable(self).join(sep));
853
1266
 
854
1267
  // src/core/Nano.ts
1268
+ var debugPerformance = false;
855
1269
  var NanoTag = class {
856
1270
  constructor(key) {
857
1271
  this.key = key;
858
1272
  }
859
1273
  };
860
- var Tag = (identifier) => new NanoTag(identifier);
1274
+ var Tag = (identifier2) => new NanoTag(identifier2);
861
1275
  var SingleShotGen2 = class _SingleShotGen {
862
1276
  called = false;
863
1277
  self;
@@ -883,12 +1297,12 @@ var SingleShotGen2 = class _SingleShotGen {
883
1297
  return new _SingleShotGen(this.self);
884
1298
  }
885
1299
  };
886
- var evaluate = /* @__PURE__ */ Symbol.for("Nano.evaluate");
887
- var contA = /* @__PURE__ */ Symbol.for("Nano.contA");
888
- var contE = /* @__PURE__ */ Symbol.for("Nano.contE");
889
- var contAll = /* @__PURE__ */ Symbol.for("Nano.contAll");
1300
+ var evaluate2 = /* @__PURE__ */ Symbol.for("Nano.evaluate");
1301
+ var contA2 = /* @__PURE__ */ Symbol.for("Nano.contA");
1302
+ var contE2 = /* @__PURE__ */ Symbol.for("Nano.contE");
1303
+ var contAll2 = /* @__PURE__ */ Symbol.for("Nano.contAll");
890
1304
  var NanoYield = /* @__PURE__ */ Symbol.for("Nano.yield");
891
- var args = /* @__PURE__ */ Symbol.for("Nano.args");
1305
+ var args2 = /* @__PURE__ */ Symbol.for("Nano.args");
892
1306
  var NanoDefectException = class {
893
1307
  constructor(message, lastSpan) {
894
1308
  this.message = message;
@@ -905,43 +1319,43 @@ var SucceedProto = {
905
1319
  ...PrimitiveProto,
906
1320
  _tag: "Success",
907
1321
  get value() {
908
- return this[args];
1322
+ return this[args2];
909
1323
  },
910
- [evaluate](fiber) {
911
- const cont = fiber.getCont(contA);
912
- return cont ? cont[contA](this[args], fiber) : fiber.yieldWith(this);
1324
+ [evaluate2](fiber) {
1325
+ const cont = fiber.getCont(contA2);
1326
+ return cont ? cont[contA2](this[args2], fiber) : fiber.yieldWith(this);
913
1327
  }
914
1328
  };
915
- var succeed = (value) => {
1329
+ var succeed3 = (value) => {
916
1330
  const nano = Object.create(SucceedProto);
917
- nano[args] = value;
1331
+ nano[args2] = value;
918
1332
  return nano;
919
1333
  };
920
- var FailureProto = {
1334
+ var FailureProto2 = {
921
1335
  ...PrimitiveProto,
922
1336
  _tag: "Failure",
923
1337
  get value() {
924
- return this[args];
1338
+ return this[args2];
925
1339
  },
926
- [evaluate](fiber) {
927
- const cont = fiber.getCont(contE);
928
- return cont ? cont[contE](this[args], fiber) : fiber.yieldWith(this);
1340
+ [evaluate2](fiber) {
1341
+ const cont = fiber.getCont(contE2);
1342
+ return cont ? cont[contE2](this[args2], fiber) : fiber.yieldWith(this);
929
1343
  }
930
1344
  };
931
- var fail = (error) => {
932
- const nano = Object.create(FailureProto);
933
- nano[args] = error;
1345
+ var fail3 = (error) => {
1346
+ const nano = Object.create(FailureProto2);
1347
+ nano[args2] = error;
934
1348
  return nano;
935
1349
  };
936
1350
  var SuspendProto = {
937
1351
  ...PrimitiveProto,
938
- [evaluate]() {
939
- return this[args]();
1352
+ [evaluate2]() {
1353
+ return this[args2]();
940
1354
  }
941
1355
  };
942
1356
  var suspend = (fn2) => {
943
1357
  const nano = Object.create(SuspendProto);
944
- nano[args] = fn2;
1358
+ nano[args2] = fn2;
945
1359
  return nano;
946
1360
  };
947
1361
  var NanoFiber = class {
@@ -949,12 +1363,11 @@ var NanoFiber = class {
949
1363
  _yielded = void 0;
950
1364
  _services = {};
951
1365
  _cache = {};
952
- _perf = false;
953
1366
  _lastSpan = "";
954
1367
  runLoop(nano) {
955
1368
  let current = nano;
956
1369
  while (true) {
957
- current = current[evaluate](this);
1370
+ current = current[evaluate2](this);
958
1371
  if (current === NanoYield) {
959
1372
  return this._yielded;
960
1373
  }
@@ -964,7 +1377,7 @@ var NanoFiber = class {
964
1377
  while (true) {
965
1378
  const op = this._stack.pop();
966
1379
  if (!op) return void 0;
967
- const cont = op[contAll] && op[contAll](this);
1380
+ const cont = op[contAll2] && op[contAll2](this);
968
1381
  if (cont) return { [symbol3]: cont };
969
1382
  if (op[symbol3]) return op;
970
1383
  }
@@ -978,9 +1391,9 @@ var timings = {};
978
1391
  var timingsCount = {};
979
1392
  var WithSpanProto = {
980
1393
  ...PrimitiveProto,
981
- [evaluate](fiber) {
982
- const [fa, name] = this[args];
983
- if (!fiber._perf) return fa;
1394
+ [evaluate2](fiber) {
1395
+ const [fa, name] = this[args2];
1396
+ if (!debugPerformance) return fa;
984
1397
  const previousSpan = fiber._lastSpan;
985
1398
  fiber._lastSpan = name;
986
1399
  const start = performance.now();
@@ -990,104 +1403,103 @@ var WithSpanProto = {
990
1403
  const end = performance.now();
991
1404
  timings[name] = (timings[name] || 0) + (end - start);
992
1405
  fiber._lastSpan = previousSpan;
993
- return succeed(_);
1406
+ return succeed3(_);
994
1407
  },
995
1408
  onFailure: (_) => {
996
1409
  const end = performance.now();
997
1410
  timings[name] = (timings[name] || 0) + (end - start);
998
1411
  fiber._lastSpan = previousSpan;
999
- return fail(_);
1412
+ return fail3(_);
1000
1413
  }
1001
1414
  });
1002
1415
  }
1003
1416
  };
1004
1417
  var withSpan = (name) => (fa) => {
1005
1418
  const nano = Object.create(WithSpanProto);
1006
- nano[args] = [fa, name];
1419
+ nano[args2] = [fa, name];
1007
1420
  return nano;
1008
1421
  };
1009
1422
  var unsafeRun = (nano) => {
1010
1423
  const fiber = new NanoFiber();
1011
- globalThis.currentFiber = fiber;
1012
1424
  const result = fiber.runLoop(nano);
1013
1425
  if (result._tag === "Success") {
1014
- return right2(result.value);
1426
+ return succeed2(result.value);
1015
1427
  }
1016
- return left2(result.value);
1428
+ return fail2(result.value);
1017
1429
  };
1018
1430
  var OnSuccessProto = {
1019
1431
  ...PrimitiveProto,
1020
- [evaluate](fiber) {
1432
+ [evaluate2](fiber) {
1021
1433
  fiber._stack.push(this);
1022
- return this[args];
1434
+ return this[args2];
1023
1435
  }
1024
1436
  };
1025
1437
  var flatMap2 = dual(2, (fa, f) => {
1026
1438
  const nano = Object.create(OnSuccessProto);
1027
- nano[args] = fa;
1028
- nano[contA] = f;
1439
+ nano[args2] = fa;
1440
+ nano[contA2] = f;
1029
1441
  return nano;
1030
1442
  });
1031
- var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
1443
+ var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed3(f(_))));
1032
1444
  var SyncProto = {
1033
1445
  ...PrimitiveProto,
1034
- [evaluate](fiber) {
1035
- const value = this[args]();
1036
- const cont = fiber.getCont(contA);
1037
- return cont ? cont[contA](value, fiber) : fiber.yieldWith(succeed(value));
1446
+ [evaluate2](fiber) {
1447
+ const value = this[args2]();
1448
+ const cont = fiber.getCont(contA2);
1449
+ return cont ? cont[contA2](value, fiber) : fiber.yieldWith(succeed3(value));
1038
1450
  }
1039
1451
  };
1040
1452
  var sync = (f) => {
1041
1453
  const nano = Object.create(SyncProto);
1042
- nano[args] = f;
1454
+ nano[args2] = f;
1043
1455
  return nano;
1044
1456
  };
1045
- var void_ = succeed(void 0);
1457
+ var void_ = succeed3(void 0);
1046
1458
  var FromIteratorProto = {
1047
1459
  ...PrimitiveProto,
1048
- [contA](value, fiber) {
1049
- const state = this[args][0].next(value);
1050
- if (state.done) return succeed(state.value);
1460
+ [contA2](value, fiber) {
1461
+ const state = this[args2][0].next(value);
1462
+ if (state.done) return succeed3(state.value);
1051
1463
  fiber._stack.push(this);
1052
1464
  return state.value;
1053
1465
  },
1054
- [evaluate](fiber) {
1055
- return this[contA](this[args][1], fiber);
1466
+ [evaluate2](fiber) {
1467
+ return this[contA2](this[args2][1], fiber);
1056
1468
  }
1057
1469
  };
1058
1470
  var unsafeFromIterator = (iterator, initial) => {
1059
1471
  const nano = Object.create(FromIteratorProto);
1060
- nano[args] = [iterator, initial];
1472
+ nano[args2] = [iterator, initial];
1061
1473
  return nano;
1062
1474
  };
1063
- var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
1064
- var fn = (_) => (body) => (...args2) => withSpan(_)(suspend(() => unsafeFromIterator(body(...args2))));
1475
+ var gen = (...args3) => suspend(() => unsafeFromIterator(args3[0]()));
1476
+ var fn = (_) => (body) => (...args3) => withSpan(_)(suspend(() => unsafeFromIterator(body(...args3))));
1065
1477
  var MatchProto = {
1066
1478
  ...PrimitiveProto,
1067
- [evaluate](fiber) {
1479
+ [evaluate2](fiber) {
1068
1480
  fiber._stack.push(this);
1069
- return this[args];
1481
+ return this[args2];
1070
1482
  }
1071
1483
  };
1072
1484
  var match = (fa, opts) => {
1073
1485
  const nano = Object.create(MatchProto);
1074
- nano[args] = fa;
1075
- nano[contA] = opts.onSuccess;
1076
- nano[contE] = opts.onFailure;
1486
+ nano[args2] = fa;
1487
+ nano[contA2] = opts.onSuccess;
1488
+ nano[contE2] = opts.onFailure;
1077
1489
  return nano;
1078
1490
  };
1079
1491
  var orElse2 = (f) => (fa) => {
1080
1492
  const nano = Object.create(MatchProto);
1081
- nano[args] = fa;
1082
- nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : f(_);
1493
+ nano[args2] = fa;
1494
+ nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : f(_);
1083
1495
  return nano;
1084
1496
  };
1085
1497
  var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
1086
1498
  var ProvideServiceProto = {
1087
1499
  ...PrimitiveProto,
1088
- [evaluate](fiber) {
1500
+ [evaluate2](fiber) {
1089
1501
  const prevServices = fiber._services;
1090
- const [fa, tag, value] = this[args];
1502
+ const [fa, tag, value] = this[args2];
1091
1503
  fiber._services = {
1092
1504
  ...fiber._services,
1093
1505
  [tag.key]: value
@@ -1095,54 +1507,54 @@ var ProvideServiceProto = {
1095
1507
  return match(fa, {
1096
1508
  onSuccess: (_) => {
1097
1509
  fiber._services = prevServices;
1098
- return succeed(_);
1510
+ return succeed3(_);
1099
1511
  },
1100
1512
  onFailure: (_) => {
1101
1513
  fiber._services = prevServices;
1102
- return fail(_);
1514
+ return fail3(_);
1103
1515
  }
1104
1516
  });
1105
1517
  }
1106
1518
  };
1107
1519
  var provideService = (tag, value) => (fa) => {
1108
1520
  const nano = Object.create(ProvideServiceProto);
1109
- nano[args] = [fa, tag, value];
1521
+ nano[args2] = [fa, tag, value];
1110
1522
  return nano;
1111
1523
  };
1112
1524
  var ServiceProto = {
1113
1525
  ...PrimitiveProto,
1114
- [evaluate](fiber) {
1115
- const tag = this[args];
1526
+ [evaluate2](fiber) {
1527
+ const tag = this[args2];
1116
1528
  if (tag.key in fiber._services) {
1117
1529
  const value = fiber._services[tag.key];
1118
- const cont2 = fiber.getCont(contA);
1119
- return cont2 ? cont2[contA](value, fiber) : fiber.yieldWith(succeed(value));
1530
+ const cont2 = fiber.getCont(contA2);
1531
+ return cont2 ? cont2[contA2](value, fiber) : fiber.yieldWith(succeed3(value));
1120
1532
  }
1121
- const cont = fiber.getCont(contE);
1122
- return cont ? cont[contE](tag, fiber) : fiber.yieldWith(fail(new NanoDefectException(`Service ${tag.key} not found`, fiber._lastSpan)));
1533
+ const cont = fiber.getCont(contE2);
1534
+ return cont ? cont[contE2](tag, fiber) : fiber.yieldWith(fail3(new NanoDefectException(`Service ${tag.key} not found`, fiber._lastSpan)));
1123
1535
  }
1124
1536
  };
1125
1537
  var service = (tag) => {
1126
1538
  const nano = Object.create(ServiceProto);
1127
- nano[args] = tag;
1539
+ nano[args2] = tag;
1128
1540
  return nano;
1129
1541
  };
1130
1542
  var CachedProto = {
1131
1543
  ...PrimitiveProto,
1132
- [evaluate](fiber) {
1133
- const [fa, type, key] = this[args];
1544
+ [evaluate2](fiber) {
1545
+ const [fa, type, key] = this[args2];
1134
1546
  const cache = fiber._cache[type] || /* @__PURE__ */ new WeakMap();
1135
1547
  fiber._cache[type] = cache;
1136
- const cached2 = cache.get(key);
1137
- if (cached2) return cached2;
1548
+ const cached = cache.get(key);
1549
+ if (cached) return cached;
1138
1550
  return match(fa, {
1139
1551
  onSuccess: (_) => {
1140
- cache.set(key, succeed(_));
1141
- return succeed(_);
1552
+ cache.set(key, succeed3(_));
1553
+ return succeed3(_);
1142
1554
  },
1143
1555
  onFailure: (_) => {
1144
- cache.set(key, fail(_));
1145
- return fail(_);
1556
+ cache.set(key, fail3(_));
1557
+ return fail3(_);
1146
1558
  }
1147
1559
  });
1148
1560
  }
@@ -1150,35 +1562,35 @@ var CachedProto = {
1150
1562
  function cachedBy(fa, type, lookupKey) {
1151
1563
  return (...p) => {
1152
1564
  const nano = Object.create(CachedProto);
1153
- nano[args] = [fa(...p), type, lookupKey(...p)];
1565
+ nano[args2] = [fa(...p), type, lookupKey(...p)];
1154
1566
  return nano;
1155
1567
  };
1156
1568
  }
1157
1569
  var option = (fa) => {
1158
1570
  const nano = Object.create(MatchProto);
1159
- nano[args] = fa;
1160
- nano[contA] = (_) => succeed(some2(_));
1161
- nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(none2());
1571
+ nano[args2] = fa;
1572
+ nano[contA2] = (_) => succeed3(some2(_));
1573
+ nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : succeed3(none2());
1162
1574
  return nano;
1163
1575
  };
1164
1576
  var orUndefined = (fa) => {
1165
1577
  const nano = Object.create(MatchProto);
1166
- nano[args] = fa;
1167
- nano[contA] = (_) => succeed(_);
1168
- nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(void 0);
1578
+ nano[args2] = fa;
1579
+ nano[contA2] = (_) => succeed3(_);
1580
+ nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : succeed3(void 0);
1169
1581
  return nano;
1170
1582
  };
1171
1583
  var ignore = (fa) => {
1172
1584
  const nano = Object.create(MatchProto);
1173
- nano[args] = fa;
1174
- nano[contA] = (_) => void_;
1175
- nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : void_;
1585
+ nano[args2] = fa;
1586
+ nano[contA2] = (_) => void_;
1587
+ nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : void_;
1176
1588
  return nano;
1177
1589
  };
1178
1590
  var all = fn("all")(
1179
- function* (...args2) {
1591
+ function* (...args3) {
1180
1592
  const results = [];
1181
- for (const fa of args2) {
1593
+ for (const fa of args3) {
1182
1594
  const result = yield* fa;
1183
1595
  results.push(result);
1184
1596
  }
@@ -1192,7 +1604,7 @@ function isValidSeverityLevel(value) {
1192
1604
  return value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion";
1193
1605
  }
1194
1606
  function parseDiagnosticSeverity(config) {
1195
- if (!isRecord(config)) return {};
1607
+ if (!isObject(config)) return {};
1196
1608
  return Object.fromEntries(
1197
1609
  pipe(
1198
1610
  Object.entries(config),
@@ -1255,7 +1667,7 @@ function parse(config) {
1255
1667
  return {
1256
1668
  refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
1257
1669
  diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
1258
- diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
1670
+ diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isObject(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
1259
1671
  diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
1260
1672
  missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
1261
1673
  includeSuggestionsInTsc: isObject(config) && hasProperty(config, "includeSuggestionsInTsc") && isBoolean(config.includeSuggestionsInTsc) ? config.includeSuggestionsInTsc : defaults.includeSuggestionsInTsc,
@@ -1270,7 +1682,7 @@ function parse(config) {
1270
1682
  allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
1271
1683
  namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
1272
1684
  barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
1273
- importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map2(config.importAliases, (value) => String(value)) : defaults.importAliases,
1685
+ importAliases: isObject(config) && hasProperty(config, "importAliases") && isObject(config.importAliases) ? map2(config.importAliases, (value) => String(value)) : defaults.importAliases,
1274
1686
  topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
1275
1687
  renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
1276
1688
  noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
@@ -1289,9 +1701,9 @@ var TypeScriptProgram = Tag("TypeScriptProgram");
1289
1701
  var ChangeTracker = Tag("ChangeTracker");
1290
1702
  function getPackageJsonInfoCache(program) {
1291
1703
  try {
1292
- if (hasProperty(program, "getModuleResolutionCache") && isFunction2(program.getModuleResolutionCache)) {
1704
+ if (hasProperty(program, "getModuleResolutionCache") && isFunction(program.getModuleResolutionCache)) {
1293
1705
  const moduleResolutionCache = program.getModuleResolutionCache();
1294
- if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") && isFunction2(moduleResolutionCache.getPackageJsonInfoCache)) {
1706
+ if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") && isFunction(moduleResolutionCache.getPackageJsonInfoCache)) {
1295
1707
  return moduleResolutionCache.getPackageJsonInfoCache();
1296
1708
  }
1297
1709
  }
@@ -1302,7 +1714,7 @@ function getPackageJsonInfoCache(program) {
1302
1714
  }
1303
1715
  function getDirectoryPath(ts, path) {
1304
1716
  try {
1305
- if (hasProperty(ts, "getDirectoryPath") && isFunction2(ts.getDirectoryPath)) {
1717
+ if (hasProperty(ts, "getDirectoryPath") && isFunction(ts.getDirectoryPath)) {
1306
1718
  return ts.getDirectoryPath(path);
1307
1719
  }
1308
1720
  return path;
@@ -1311,7 +1723,7 @@ function getDirectoryPath(ts, path) {
1311
1723
  }
1312
1724
  }
1313
1725
  function makeGetModuleSpecifier(ts) {
1314
- if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction2(ts.moduleSpecifiers.getModuleSpecifier))) return;
1726
+ if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction(ts.moduleSpecifiers.getModuleSpecifier))) return;
1315
1727
  const _internal = ts.moduleSpecifiers.getModuleSpecifier;
1316
1728
  return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) => {
1317
1729
  return _internal(
@@ -1325,14 +1737,14 @@ function makeGetModuleSpecifier(ts) {
1325
1737
  };
1326
1738
  }
1327
1739
  function makeGetTemporaryModuleResolutionState(ts) {
1328
- if (hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction2(ts.getTemporaryModuleResolutionState)) {
1740
+ if (hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction(ts.getTemporaryModuleResolutionState)) {
1329
1741
  const _internal = ts.getTemporaryModuleResolutionState;
1330
1742
  return (cache, program, compilerOptions) => _internal(cache, program, compilerOptions);
1331
1743
  }
1332
1744
  return void 0;
1333
1745
  }
1334
1746
  function makeGetPackageScopeForPath(ts) {
1335
- if (hasProperty(ts, "getPackageScopeForPath") && isFunction2(ts.getPackageScopeForPath)) {
1747
+ if (hasProperty(ts, "getPackageScopeForPath") && isFunction(ts.getPackageScopeForPath)) {
1336
1748
  const _internal = ts.getPackageScopeForPath;
1337
1749
  return (path, state) => _internal(path, state);
1338
1750
  }
@@ -1590,7 +2002,7 @@ function makeTypeScriptUtils(ts) {
1590
2002
  }
1591
2003
  } else if (ts.isNamedImports(namedBindings)) {
1592
2004
  for (const importSpecifier of namedBindings.elements) {
1593
- const importProperty = fromNullable(importSpecifier.propertyName).pipe(
2005
+ const importProperty = fromNullishOr(importSpecifier.propertyName).pipe(
1594
2006
  orElse(() => some2(importSpecifier.name))
1595
2007
  );
1596
2008
  if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
@@ -1920,14 +2332,44 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
1920
2332
  }
1921
2333
  return effectRefactors;
1922
2334
  });
2335
+ function codeFixNameToFullyQualifiedName(name) {
2336
+ return `@effect/language-service/codefixes/${name}`;
2337
+ }
2338
+ var codeFixesToApplicableRefactor = fn("LSP.codeFixesToApplicableRefactor")(function* (codeFixes, sourceFile, positionOrRange) {
2339
+ const effectRefactors = [];
2340
+ const range = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
2341
+ const inRangeCodeFixes = codeFixes.filter((_) => _.start <= range.pos && _.end >= range.end);
2342
+ for (const codeFix of inRangeCodeFixes) {
2343
+ effectRefactors.push({
2344
+ name: codeFixNameToFullyQualifiedName(codeFix.fixName),
2345
+ description: "Quick Fix: " + codeFix.description,
2346
+ actions: [{
2347
+ name: codeFixNameToFullyQualifiedName(codeFix.fixName),
2348
+ description: "Quick Fix: " + codeFix.description,
2349
+ kind: "refactor.rewrite.codeFixEffect." + codeFix.fixName
2350
+ }]
2351
+ });
2352
+ }
2353
+ return effectRefactors;
2354
+ });
1923
2355
  var getEditsForRefactor = fn("LSP.getEditsForRefactor")(function* (refactors, sourceFile, positionOrRange, refactorName) {
1924
2356
  const refactor = refactors.find((refactor2) => refactorNameToFullyQualifiedName(refactor2.name) === refactorName);
1925
2357
  if (!refactor) {
1926
- return yield* fail(new RefactorNotApplicableError());
2358
+ return yield* fail3(new RefactorNotApplicableError());
1927
2359
  }
1928
2360
  const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
1929
2361
  return yield* refactor.apply(sourceFile, textRange);
1930
2362
  });
2363
+ var getEditsForCodeFixes = fn("LSP.getEditsForCodeFixes")(function* (codeFixes, positionOrRange, refactorName) {
2364
+ const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
2365
+ const fixToRun = codeFixes.find(
2366
+ (_) => codeFixNameToFullyQualifiedName(_.fixName) === refactorName && _.start <= textRange.pos && _.end >= textRange.end
2367
+ );
2368
+ if (!fixToRun) {
2369
+ return yield* fail3(new RefactorNotApplicableError());
2370
+ }
2371
+ return fixToRun;
2372
+ });
1931
2373
  var getCompletionsAtPosition = fn("LSP.getCompletionsAtPosition")(function* (completions, sourceFile, position, options, formatCodeSettings) {
1932
2374
  let effectCompletions = [];
1933
2375
  for (const completion of completions) {
@@ -2011,7 +2453,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
2011
2453
  message: ts.DiagnosticCategory.Message,
2012
2454
  suggestion: ts.DiagnosticCategory.Suggestion
2013
2455
  };
2014
- const execute = (rule) => gen(function* () {
2456
+ const execute = fn("LSP.execute")(function* (rule) {
2015
2457
  const diagnostics2 = [];
2016
2458
  const codeFixes = [];
2017
2459
  const ruleNameLowered = rule.name.toLowerCase();
@@ -2179,7 +2621,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
2179
2621
  (codegen2) => codegen2.range.pos <= textRange.pos && codegen2.range.end >= textRange.end
2180
2622
  );
2181
2623
  if (inRangeCodegens.length !== 1) {
2182
- return yield* fail(new CodegenNotApplicableError("zero or multiple codegens in range"));
2624
+ return yield* fail3(new CodegenNotApplicableError("zero or multiple codegens in range"));
2183
2625
  }
2184
2626
  const { codegen, range } = inRangeCodegens[0];
2185
2627
  const edit = yield* codegen.apply(sourceFile, range);
@@ -2383,8 +2825,8 @@ function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
2383
2825
  };
2384
2826
  const expectedAndRealTypeCache = /* @__PURE__ */ new WeakMap();
2385
2827
  const expectedAndRealType = (sourceFile) => {
2386
- const cached2 = expectedAndRealTypeCache.get(sourceFile);
2387
- if (cached2) return cached2;
2828
+ const cached = expectedAndRealTypeCache.get(sourceFile);
2829
+ if (cached) return cached;
2388
2830
  const result = [];
2389
2831
  const nodeToVisit = [sourceFile];
2390
2832
  const appendNodeToVisit = (node) => {
@@ -2601,7 +3043,7 @@ var nanoLayer3 = (fa) => gen(function* () {
2601
3043
  });
2602
3044
  var TypeParserIssue = class _TypeParserIssue {
2603
3045
  _tag = "@effect/language-service/TypeParserIssue";
2604
- static issue = fail(new _TypeParserIssue());
3046
+ static issue = fail3(new _TypeParserIssue());
2605
3047
  };
2606
3048
  function typeParserIssue(_message, _type, _node) {
2607
3049
  return TypeParserIssue.issue;
@@ -2797,21 +3239,30 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
2797
3239
  if (signatures.length !== 1) {
2798
3240
  return typeParserIssue("Covariant type has no call signature", type);
2799
3241
  }
2800
- return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
3242
+ if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
3243
+ return typeParserIssue("Invariant type should not have type parameters", type);
3244
+ }
3245
+ return succeed3(typeChecker.getReturnTypeOfSignature(signatures[0]));
2801
3246
  }
2802
3247
  function contravariantTypeArgument(type) {
2803
3248
  const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
2804
3249
  if (signatures.length !== 1) {
2805
3250
  return typeParserIssue("Contravariant type has no call signature", type);
2806
3251
  }
2807
- return succeed(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
3252
+ if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
3253
+ return typeParserIssue("Invariant type should not have type parameters", type);
3254
+ }
3255
+ return succeed3(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
2808
3256
  }
2809
3257
  function invariantTypeArgument(type) {
2810
3258
  const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
2811
3259
  if (signatures.length !== 1) {
2812
3260
  return typeParserIssue("Invariant type has no call signature", type);
2813
3261
  }
2814
- return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
3262
+ if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
3263
+ return typeParserIssue("Invariant type should not have type parameters", type);
3264
+ }
3265
+ return succeed3(typeChecker.getReturnTypeOfSignature(signatures[0]));
2815
3266
  }
2816
3267
  const pipeableType = cachedBy(
2817
3268
  function(type, atLocation) {
@@ -2824,7 +3275,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
2824
3275
  if (signatures.length === 0) {
2825
3276
  return typeParserIssue("'pipe' property is not callable", type, atLocation);
2826
3277
  }
2827
- return succeed(type);
3278
+ return succeed3(type);
2828
3279
  },
2829
3280
  "TypeParser.pipeableType",
2830
3281
  (type) => type
@@ -3288,7 +3739,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3288
3739
  const type = typeCheckerUtils.getTypeAtLocation(yieldedExpression);
3289
3740
  if (!type) continue;
3290
3741
  const { A: successType } = yield* effectType(type, yieldedExpression);
3291
- let replacementNode = succeed(yieldedExpression);
3742
+ let replacementNode = succeed3(yieldedExpression);
3292
3743
  if (!explicitReturn && !(successType.flags & ts.TypeFlags.VoidLike)) {
3293
3744
  replacementNode = pipe(
3294
3745
  gen(function* () {
@@ -3499,15 +3950,15 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3499
3950
  if (node.arguments.length === 0) {
3500
3951
  return typeParserIssue("Node is not a pipe call", void 0, node);
3501
3952
  }
3502
- const [subject, ...args2] = node.arguments;
3503
- return succeed({
3953
+ const [subject, ...args3] = node.arguments;
3954
+ return succeed3({
3504
3955
  node,
3505
3956
  subject,
3506
- args: args2,
3957
+ args: args3,
3507
3958
  kind: "pipe"
3508
3959
  });
3509
3960
  }
3510
- return succeed({
3961
+ return succeed3({
3511
3962
  node,
3512
3963
  subject: baseExpression,
3513
3964
  args: Array.from(node.arguments),
@@ -3517,8 +3968,8 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3517
3968
  );
3518
3969
  }
3519
3970
  if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "pipe" && node.arguments.length > 0) {
3520
- const [subject, ...args2] = node.arguments;
3521
- return succeed({ node, subject, args: args2, kind: "pipe" });
3971
+ const [subject, ...args3] = node.arguments;
3972
+ return succeed3({ node, subject, args: args3, kind: "pipe" });
3522
3973
  }
3523
3974
  return typeParserIssue("Node is not a pipe call", void 0, node);
3524
3975
  },
@@ -3533,7 +3984,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3533
3984
  if (node.arguments.length !== 1) {
3534
3985
  return typeParserIssue("Node must have exactly one argument", void 0, node);
3535
3986
  }
3536
- return succeed({
3987
+ return succeed3({
3537
3988
  node,
3538
3989
  callee: node.expression,
3539
3990
  subject: node.arguments[0]
@@ -3595,7 +4046,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3595
4046
  if (!callbackParameterType) {
3596
4047
  continue;
3597
4048
  }
3598
- return succeed({
4049
+ return succeed3({
3599
4050
  type: callbackParameterType
3600
4051
  });
3601
4052
  }
@@ -4007,9 +4458,9 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4007
4458
  let accessors2 = void 0;
4008
4459
  let dependencies = void 0;
4009
4460
  if (wholeCall.arguments.length >= 2) {
4010
- const args2 = wholeCall.arguments[1];
4011
- if (ts.isObjectLiteralExpression(args2)) {
4012
- for (const property of args2.properties) {
4461
+ const args3 = wholeCall.arguments[1];
4462
+ if (ts.isObjectLiteralExpression(args3)) {
4463
+ for (const property of args3.properties) {
4013
4464
  if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
4014
4465
  accessors2 = true;
4015
4466
  }
@@ -4214,7 +4665,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4214
4665
  const body = node.body;
4215
4666
  const returnType = node.type;
4216
4667
  if (ts.isArrowFunction(node) && !ts.isBlock(body)) {
4217
- return succeed({
4668
+ return succeed3({
4218
4669
  node,
4219
4670
  body,
4220
4671
  expression: body,
@@ -4232,7 +4683,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4232
4683
  if (!stmt.expression) {
4233
4684
  return typeParserIssue("Return statement must have an expression", void 0, node);
4234
4685
  }
4235
- return succeed({
4686
+ return succeed3({
4236
4687
  node,
4237
4688
  body,
4238
4689
  expression: stmt.expression,
@@ -4257,7 +4708,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4257
4708
  if (body.statements.length !== 0) {
4258
4709
  return typeParserIssue("Block must have zero statements", void 0, node);
4259
4710
  }
4260
- return succeed({
4711
+ return succeed3({
4261
4712
  node,
4262
4713
  body,
4263
4714
  returnType
@@ -4698,32 +5149,38 @@ var catchAllToMapError = createDiagnostic({
4698
5149
  return void 0;
4699
5150
  };
4700
5151
  const getEffectFailCallInfo = (body) => {
4701
- return gen(function* () {
4702
- if (ts.isCallExpression(body)) {
4703
- const isFailCall = yield* pipe(
4704
- typeParser.isNodeReferenceToEffectModuleApi("fail")(body.expression),
4705
- orUndefined
4706
- );
4707
- if (isFailCall && body.arguments.length >= 1) {
4708
- return { failCall: body, failArg: body.arguments[0] };
4709
- }
4710
- }
4711
- if (ts.isBlock(body)) {
4712
- const statements = body.statements;
4713
- if (statements.length === 1) {
4714
- const stmt = statements[0];
4715
- if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
4716
- const isFailCall = yield* pipe(
4717
- typeParser.isNodeReferenceToEffectModuleApi("fail")(stmt.expression.expression),
4718
- orUndefined
4719
- );
4720
- if (isFailCall && stmt.expression.arguments.length >= 1) {
4721
- return { failCall: stmt.expression, failArg: stmt.expression.arguments[0] };
4722
- }
5152
+ if (ts.isCallExpression(body)) {
5153
+ return pipe(
5154
+ typeParser.isNodeReferenceToEffectModuleApi("fail")(body.expression),
5155
+ orUndefined,
5156
+ map4((isFailCall) => {
5157
+ if (isFailCall && body.arguments.length >= 1) {
5158
+ return { failCall: body, failArg: body.arguments[0] };
4723
5159
  }
5160
+ return void 0;
5161
+ })
5162
+ );
5163
+ }
5164
+ if (ts.isBlock(body)) {
5165
+ const statements = body.statements;
5166
+ if (statements.length === 1) {
5167
+ const stmt = statements[0];
5168
+ if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
5169
+ const callExpr = stmt.expression;
5170
+ return pipe(
5171
+ typeParser.isNodeReferenceToEffectModuleApi("fail")(callExpr.expression),
5172
+ orUndefined,
5173
+ map4((isFailCall) => {
5174
+ if (isFailCall && callExpr.arguments.length >= 1) {
5175
+ return { failCall: callExpr, failArg: callExpr.arguments[0] };
5176
+ }
5177
+ return void 0;
5178
+ })
5179
+ );
4724
5180
  }
4725
5181
  }
4726
- });
5182
+ }
5183
+ return void_;
4727
5184
  };
4728
5185
  const flows = yield* typeParser.pipingFlows(true)(sourceFile);
4729
5186
  for (const flow2 of flows) {
@@ -4948,10 +5405,10 @@ var getOrMakeKeyBuilder = fn("getOrMakeKeyBuilder")(function* (sourceFile) {
4948
5405
  keyBuilderCache.set(sourceFile.fileName, keyBuilder);
4949
5406
  return keyBuilder;
4950
5407
  });
4951
- function createString(sourceFile, identifier, kind) {
5408
+ function createString(sourceFile, identifier2, kind) {
4952
5409
  return map4(
4953
5410
  getOrMakeKeyBuilder(sourceFile),
4954
- (identifierBuilder) => identifierBuilder.createString(identifier, kind)
5411
+ (identifierBuilder) => identifierBuilder.createString(identifier2, kind)
4955
5412
  );
4956
5413
  }
4957
5414
 
@@ -4968,20 +5425,21 @@ var deterministicKeys = createDiagnostic({
4968
5425
  const typeScriptUtils = yield* service(TypeScriptUtils);
4969
5426
  const options = yield* service(LanguageServicePluginOptions);
4970
5427
  const parseExtendsCustom = cachedBy(
4971
- fn("parseExtendsCustom")(function* (classDeclaration) {
5428
+ (classDeclaration) => {
4972
5429
  if (!options.extendedKeyDetection) {
4973
- return yield* typeParserIssue("Extended key detection is disabled", void 0, classDeclaration);
5430
+ return TypeParserIssue.issue;
4974
5431
  }
4975
5432
  if (!classDeclaration.name) {
4976
- return yield* typeParserIssue("Class has no name", void 0, classDeclaration);
5433
+ return TypeParserIssue.issue;
4977
5434
  }
4978
5435
  if (!ts.isIdentifier(classDeclaration.name)) {
4979
- return yield* typeParserIssue("Class name is not an identifier", void 0, classDeclaration);
5436
+ return TypeParserIssue.issue;
4980
5437
  }
4981
5438
  const heritageClauses = classDeclaration.heritageClauses;
4982
5439
  if (!heritageClauses) {
4983
- return yield* typeParserIssue("Class has no heritage clauses", void 0, classDeclaration);
5440
+ return TypeParserIssue.issue;
4984
5441
  }
5442
+ const className = classDeclaration.name;
4985
5443
  const nodeToVisit2 = [...classDeclaration.heritageClauses];
4986
5444
  const appendNodeToVisit2 = (node) => {
4987
5445
  nodeToVisit2.push(node);
@@ -5002,7 +5460,7 @@ var deterministicKeys = createDiagnostic({
5002
5460
  const parameterSourceFile = typeScriptUtils.getSourceFileOfNode(declaration);
5003
5461
  const paramText = parameterSourceFile.text.substring(declaration.pos, declaration.end);
5004
5462
  if (paramText.toLowerCase().includes("@effect-identifier")) {
5005
- return { className: classDeclaration.name, keyStringLiteral: arg, target: "custom" };
5463
+ return succeed3({ className, keyStringLiteral: arg, target: "custom" });
5006
5464
  }
5007
5465
  }
5008
5466
  }
@@ -5011,12 +5469,8 @@ var deterministicKeys = createDiagnostic({
5011
5469
  }
5012
5470
  ts.forEachChild(node, appendNodeToVisit2);
5013
5471
  }
5014
- return yield* typeParserIssue(
5015
- "Class does not extend any custom pattern",
5016
- void 0,
5017
- classDeclaration
5018
- );
5019
- }),
5472
+ return TypeParserIssue.issue;
5473
+ },
5020
5474
  "deterministicKeys.parseExtendsCustom",
5021
5475
  (classDeclaration) => classDeclaration
5022
5476
  );
@@ -5295,25 +5749,27 @@ var effectFnOpportunity = createDiagnostic({
5295
5749
  }
5296
5750
  return false;
5297
5751
  };
5298
- const tryExtractWithSpanExpression = (expr) => gen(function* () {
5752
+ const tryExtractWithSpanExpression = fn("effectFnOpportunity.tryExtractWithSpanExpression")(function* (expr) {
5299
5753
  if (!ts.isCallExpression(expr)) return void 0;
5300
5754
  const callee = expr.expression;
5301
5755
  const isWithSpan = yield* pipe(
5302
5756
  typeParser.isNodeReferenceToEffectModuleApi("withSpan")(callee),
5303
5757
  map4(() => true),
5304
- orElse2(() => succeed(false))
5758
+ orElse2(() => succeed3(false))
5305
5759
  );
5306
5760
  if (!isWithSpan) return void 0;
5307
5761
  if (expr.arguments.length === 0) return void 0;
5308
5762
  return expr.arguments[0];
5309
5763
  });
5310
- const tryParseGenOpportunity = (fnNode) => gen(function* () {
5764
+ const tryParseGenOpportunity = fn(
5765
+ "effectFnOpportunity.tryParseGenOpportunity"
5766
+ )(function* (fnNode) {
5311
5767
  const bodyExpression = getBodyExpression(fnNode);
5312
5768
  if (!bodyExpression) return yield* TypeParserIssue.issue;
5313
5769
  const { pipeArguments: pipeArguments2, subject } = yield* pipe(
5314
5770
  typeParser.pipeCall(bodyExpression),
5315
- map4(({ args: args2, subject: subject2 }) => ({ subject: subject2, pipeArguments: args2 })),
5316
- orElse2(() => succeed({ subject: bodyExpression, pipeArguments: [] }))
5771
+ map4(({ args: args3, subject: subject2 }) => ({ subject: subject2, pipeArguments: args3 })),
5772
+ orElse2(() => succeed3({ subject: bodyExpression, pipeArguments: [] }))
5317
5773
  );
5318
5774
  const { effectModule, generatorFunction } = yield* typeParser.effectGen(subject);
5319
5775
  const effectModuleName = ts.isIdentifier(effectModule) ? ts.idText(effectModule) : sourceEffectModuleName;
@@ -5330,75 +5786,80 @@ var effectFnOpportunity = createDiagnostic({
5330
5786
  const isInsideEffectFn = (fnNode) => {
5331
5787
  const parent = fnNode.parent;
5332
5788
  if (!parent || !ts.isCallExpression(parent)) {
5333
- return succeed(false);
5789
+ return succeed3(false);
5334
5790
  }
5335
5791
  if (parent.arguments[0] !== fnNode) {
5336
- return succeed(false);
5792
+ return succeed3(false);
5337
5793
  }
5338
5794
  return pipe(
5339
5795
  typeParser.effectFn(parent),
5340
5796
  orElse2(() => typeParser.effectFnGen(parent)),
5341
5797
  orElse2(() => typeParser.effectFnUntracedGen(parent)),
5342
5798
  map4(() => true),
5343
- orElse2(() => succeed(false))
5799
+ orElse2(() => succeed3(false))
5344
5800
  );
5345
5801
  };
5346
- const parseEffectFnOpportunityTarget = (node) => gen(function* () {
5802
+ const parseEffectFnOpportunityTargetGen = fn("effectFnOpportunity.parseEffectFnOpportunityTarget")(
5803
+ function* (node, returnType, traceName, nameIdentifier) {
5804
+ if (yield* isInsideEffectFn(node)) {
5805
+ return yield* TypeParserIssue.issue;
5806
+ }
5807
+ const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
5808
+ yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
5809
+ const opportunity = yield* pipe(
5810
+ tryParseGenOpportunity(node),
5811
+ orElse2(() => {
5812
+ if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
5813
+ return TypeParserIssue.issue;
5814
+ }
5815
+ const body = ts.isArrowFunction(node) ? node.body : node.body;
5816
+ if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
5817
+ return TypeParserIssue.issue;
5818
+ }
5819
+ return succeed3({
5820
+ effectModuleName: sourceEffectModuleName,
5821
+ pipeArguments: [],
5822
+ generatorFunction: void 0,
5823
+ explicitTraceExpression: void 0
5824
+ });
5825
+ })
5826
+ );
5827
+ return {
5828
+ node,
5829
+ nameIdentifier,
5830
+ effectModuleName: opportunity.effectModuleName,
5831
+ inferredTraceName: traceName,
5832
+ explicitTraceExpression: opportunity.explicitTraceExpression,
5833
+ pipeArguments: opportunity.pipeArguments,
5834
+ generatorFunction: opportunity.generatorFunction,
5835
+ hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
5836
+ };
5837
+ }
5838
+ );
5839
+ const parseEffectFnOpportunityTarget = (node) => {
5347
5840
  if (!ts.isFunctionExpression(node) && !ts.isArrowFunction(node) && !ts.isFunctionDeclaration(node)) {
5348
- return yield* TypeParserIssue.issue;
5841
+ return TypeParserIssue.issue;
5349
5842
  }
5350
5843
  if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) {
5351
- return yield* TypeParserIssue.issue;
5844
+ return TypeParserIssue.issue;
5352
5845
  }
5353
5846
  if (ts.isFunctionExpression(node) && node.name) {
5354
- return yield* TypeParserIssue.issue;
5847
+ return TypeParserIssue.issue;
5355
5848
  }
5356
5849
  if (node.type) {
5357
- return yield* TypeParserIssue.issue;
5358
- }
5359
- if (yield* isInsideEffectFn(node)) {
5360
- return yield* TypeParserIssue.issue;
5850
+ return TypeParserIssue.issue;
5361
5851
  }
5362
5852
  const functionType = typeChecker.getTypeAtLocation(node);
5363
- if (!functionType) return yield* TypeParserIssue.issue;
5853
+ if (!functionType) return TypeParserIssue.issue;
5364
5854
  const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call);
5365
- if (callSignatures.length !== 1) return yield* TypeParserIssue.issue;
5855
+ if (callSignatures.length !== 1) return TypeParserIssue.issue;
5366
5856
  const signature = callSignatures[0];
5367
5857
  const returnType = typeChecker.getReturnTypeOfSignature(signature);
5368
- const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
5369
- yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
5370
5858
  const nameIdentifier = getNameIdentifier(node);
5371
5859
  const traceName = nameIdentifier ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text : void 0;
5372
- if (!traceName) return yield* TypeParserIssue.issue;
5373
- const opportunity = yield* pipe(
5374
- tryParseGenOpportunity(node),
5375
- orElse2(() => {
5376
- if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
5377
- return TypeParserIssue.issue;
5378
- }
5379
- const body = ts.isArrowFunction(node) ? node.body : node.body;
5380
- if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
5381
- return TypeParserIssue.issue;
5382
- }
5383
- return succeed({
5384
- effectModuleName: sourceEffectModuleName,
5385
- pipeArguments: [],
5386
- generatorFunction: void 0,
5387
- explicitTraceExpression: void 0
5388
- });
5389
- })
5390
- );
5391
- return {
5392
- node,
5393
- nameIdentifier,
5394
- effectModuleName: opportunity.effectModuleName,
5395
- inferredTraceName: traceName,
5396
- explicitTraceExpression: opportunity.explicitTraceExpression,
5397
- pipeArguments: opportunity.pipeArguments,
5398
- generatorFunction: opportunity.generatorFunction,
5399
- hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
5400
- };
5401
- });
5860
+ if (!traceName) return TypeParserIssue.issue;
5861
+ return parseEffectFnOpportunityTargetGen(node, returnType, traceName, nameIdentifier);
5862
+ };
5402
5863
  const getFunctionBodyBlock = (node) => {
5403
5864
  if (ts.isArrowFunction(node)) {
5404
5865
  if (ts.isBlock(node.body)) {
@@ -5554,7 +6015,7 @@ var effectFnOpportunity = createDiagnostic({
5554
6015
  }).join(", ");
5555
6016
  const fnSignature = `function*${typeParamNames}(${paramNames}) { ... }`;
5556
6017
  const pipeArgsForWithSpan = pipeArguments2.slice(0, -1);
5557
- const pipeArgsSuffix = (args2) => args2.length > 0 ? ", ...pipeTransformations" : "";
6018
+ const pipeArgsSuffix = (args3) => args3.length > 0 ? ", ...pipeTransformations" : "";
5558
6019
  switch (firstFix.fixName) {
5559
6020
  case "effectFnOpportunity_toEffectFnWithSpan": {
5560
6021
  const traceName = explicitTraceExpression ? sourceFile.text.slice(explicitTraceExpression.pos, explicitTraceExpression.end).trim() : void 0;
@@ -5639,7 +6100,7 @@ var effectInVoidSuccess = createDiagnostic({
5639
6100
  );
5640
6101
  return { voidedEffect };
5641
6102
  }
5642
- return yield* fail(typeParserIssue("expectedEffect success is not void"));
6103
+ return yield* TypeParserIssue.issue;
5643
6104
  });
5644
6105
  const entries = typeCheckerUtils.expectedAndRealType(sourceFile);
5645
6106
  for (const [node, expectedType, valueNode, realType] of entries) {
@@ -5700,7 +6161,7 @@ var effectMapVoid = createDiagnostic({
5700
6161
  () => pipe(
5701
6162
  typeParser.lazyExpression(callback),
5702
6163
  flatMap2(
5703
- (lazy) => tsUtils.isVoidExpression(lazy.expression) ? succeed(lazy) : typeParserIssue("Expression is not void")
6164
+ (lazy) => tsUtils.isVoidExpression(lazy.expression) ? succeed3(lazy) : typeParserIssue("Expression is not void")
5704
6165
  )
5705
6166
  )
5706
6167
  ),
@@ -6361,11 +6822,11 @@ var leakingRequirements = createDiagnostic({
6361
6822
  memory,
6362
6823
  effectContextType,
6363
6824
  (type) => {
6364
- if (type.flags & ts.TypeFlags.Never) return succeed(true);
6825
+ if (type.flags & ts.TypeFlags.Never) return succeed3(true);
6365
6826
  return pipe(
6366
6827
  typeParser.scopeType(type, atLocation),
6367
6828
  map4(() => true),
6368
- orElse2(() => succeed(false))
6829
+ orElse2(() => succeed3(false))
6369
6830
  );
6370
6831
  }
6371
6832
  );
@@ -6780,7 +7241,7 @@ var missingEffectError = createDiagnostic({
6780
7241
  map3((_) => _.literal),
6781
7242
  filter((_) => ts.isLiteralExpression(_)),
6782
7243
  map3((_) => _.text),
6783
- sort(string2),
7244
+ sort(String2),
6784
7245
  map3(
6785
7246
  (_) => ts.factory.createPropertyAssignment(
6786
7247
  ts.factory.createIdentifier(_),
@@ -6873,7 +7334,7 @@ var missingEffectServiceDependency = createDiagnostic({
6873
7334
  );
6874
7335
  if (layerResult) {
6875
7336
  const servicesMemory = /* @__PURE__ */ new Map();
6876
- const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
7337
+ const excludeNever = (type) => succeed3((type.flags & ts.TypeFlags.Never) !== 0);
6877
7338
  const { allIndexes: requiredIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
6878
7339
  servicesMemory,
6879
7340
  layerResult.RIn,
@@ -7389,13 +7850,13 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
7389
7850
  atLocation2,
7390
7851
  ts.NodeBuilderFlags.NoTruncation
7391
7852
  );
7392
- if (!successType) return fail("error generating success type");
7853
+ if (!successType) return fail3("error generating success type");
7393
7854
  const failureType = typeChecker.typeToTypeNode(
7394
7855
  returnedEffect.E,
7395
7856
  atLocation2,
7396
7857
  ts.NodeBuilderFlags.NoTruncation
7397
7858
  );
7398
- if (!failureType) return fail("error generating failure type");
7859
+ if (!failureType) return fail3("error generating failure type");
7399
7860
  const typeNode = ts.factory.createTypeReferenceNode(
7400
7861
  ts.factory.createQualifiedName(
7401
7862
  ts.factory.createIdentifier(effectIdentifier),
@@ -7403,7 +7864,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
7403
7864
  ),
7404
7865
  [successType, failureType, contextType]
7405
7866
  );
7406
- return succeed(typeNode);
7867
+ return succeed3(typeNode);
7407
7868
  }),
7408
7869
  orElse2(
7409
7870
  () => pipe(
@@ -7414,8 +7875,8 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
7414
7875
  atLocation2,
7415
7876
  ts.NodeBuilderFlags.NoTruncation
7416
7877
  );
7417
- if (!successType) return fail("error generating success type");
7418
- return succeed(ts.factory.createTypeReferenceNode(
7878
+ if (!successType) return fail3("error generating success type");
7879
+ return succeed3(ts.factory.createTypeReferenceNode(
7419
7880
  ts.factory.createQualifiedName(
7420
7881
  ts.factory.createIdentifier(effectIdentifier),
7421
7882
  ts.factory.createIdentifier("Effect")
@@ -7436,7 +7897,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
7436
7897
  ),
7437
7898
  orElse2(() => {
7438
7899
  const successType = typeChecker.typeToTypeNode(type, atLocation2, ts.NodeBuilderFlags.NoTruncation);
7439
- if (!successType) return fail("error generating success type");
7900
+ if (!successType) return fail3("error generating success type");
7440
7901
  const typeNode = ts.factory.createTypeReferenceNode(
7441
7902
  ts.factory.createQualifiedName(
7442
7903
  ts.factory.createIdentifier(effectIdentifier),
@@ -7448,28 +7909,30 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
7448
7909
  ts.factory.createTypeReferenceNode(ts.idText(className2))
7449
7910
  ]
7450
7911
  );
7451
- return succeed(typeNode);
7912
+ return succeed3(typeNode);
7452
7913
  })
7453
7914
  );
7454
- const proxySignature = (signature, atLocation2, className2) => gen(function* () {
7455
- const signatureDeclaration = typeChecker.signatureToSignatureDeclaration(
7456
- signature,
7457
- ts.SyntaxKind.FunctionType,
7458
- atLocation2,
7459
- ts.NodeBuilderFlags.NoTruncation
7460
- );
7461
- if (!signatureDeclaration) return yield* fail("error generating signature");
7462
- const returnType = yield* generateReturnType(
7463
- typeChecker.getReturnTypeOfSignature(signature),
7464
- atLocation2,
7465
- className2
7466
- );
7467
- return ts.factory.createFunctionTypeNode(
7468
- signatureDeclaration.typeParameters,
7469
- signatureDeclaration.parameters,
7470
- returnType
7471
- );
7472
- });
7915
+ const proxySignature = fn("writeTagClassAccessors.proxySignature")(
7916
+ function* (signature, atLocation2, className2) {
7917
+ const signatureDeclaration = typeChecker.signatureToSignatureDeclaration(
7918
+ signature,
7919
+ ts.SyntaxKind.FunctionType,
7920
+ atLocation2,
7921
+ ts.NodeBuilderFlags.NoTruncation
7922
+ );
7923
+ if (!signatureDeclaration) return yield* fail3("error generating signature");
7924
+ const returnType = yield* generateReturnType(
7925
+ typeChecker.getReturnTypeOfSignature(signature),
7926
+ atLocation2,
7927
+ className2
7928
+ );
7929
+ return ts.factory.createFunctionTypeNode(
7930
+ signatureDeclaration.typeParameters,
7931
+ signatureDeclaration.parameters,
7932
+ returnType
7933
+ );
7934
+ }
7935
+ );
7473
7936
  for (const { property, propertyType } of involvedMembers) {
7474
7937
  const callSignatures = [];
7475
7938
  let propertyDeclaration = void 0;
@@ -7506,21 +7969,21 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
7506
7969
  const typeChecker = yield* service(TypeCheckerApi);
7507
7970
  const typeParser = yield* service(TypeParser);
7508
7971
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
7509
- if (typeParser.supportedEffect() === "v4") return yield* fail("not applicable to Effect v4");
7510
- if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
7972
+ if (typeParser.supportedEffect() === "v4") return yield* fail3("not applicable to Effect v4");
7973
+ if (!ts.isClassDeclaration(node)) return yield* fail3("not a class declaration");
7511
7974
  const { Service, accessors: accessors2, className, kind } = yield* pipe(
7512
7975
  map4(typeParser.extendsEffectService(node), (_) => ({ kind: "effectService", ..._ })),
7513
7976
  orElse2(
7514
7977
  () => map4(typeParser.extendsEffectTag(node), (_) => ({ kind: "effectTag", accessors: true, ..._ }))
7515
7978
  ),
7516
- orElse2(() => fail("not a class extending Effect.Service call"))
7979
+ orElse2(() => fail3("not a class extending Effect.Service call"))
7517
7980
  );
7518
- if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
7981
+ if (accessors2 !== true) return yield* fail3("accessors are not enabled in the Effect.Service call");
7519
7982
  const involvedMembers = [];
7520
7983
  const nonPrimitiveServices = typeCheckerUtils.unrollUnionMembers(Service).filter(
7521
7984
  (_) => !(_.flags & ts.TypeFlags.Number || _.flags & ts.TypeFlags.String || _.flags & ts.TypeFlags.Boolean || _.flags & ts.TypeFlags.Literal)
7522
7985
  );
7523
- if (nonPrimitiveServices.length === 0) return yield* fail("Service type is a primitive type");
7986
+ if (nonPrimitiveServices.length === 0) return yield* fail3("Service type is a primitive type");
7524
7987
  for (const serviceShape of nonPrimitiveServices) {
7525
7988
  for (const property of typeChecker.getPropertiesOfType(serviceShape)) {
7526
7989
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, node);
@@ -7561,7 +8024,7 @@ var writeTagClassAccessors = createRefactor({
7561
8024
  const parentNodes = tsUtils.getAncestorNodesInRange(sourceFile, textRange);
7562
8025
  return yield* pipe(
7563
8026
  firstSuccessOf(parentNodes.map(parseNode)),
7564
- orElse2(() => fail(new RefactorNotApplicableError()))
8027
+ orElse2(() => fail3(new RefactorNotApplicableError()))
7565
8028
  );
7566
8029
  })
7567
8030
  });
@@ -7576,7 +8039,7 @@ var accessors = createCodegen({
7576
8039
  const typeParser = yield* service(TypeParser);
7577
8040
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
7578
8041
  const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
7579
- if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
8042
+ if (!nodeAndCommentRange) return yield* fail3(new CodegenNotApplicableError("no node and comment range"));
7580
8043
  return yield* pipe(
7581
8044
  parse2(nodeAndCommentRange.node),
7582
8045
  map4(
@@ -7593,7 +8056,7 @@ var accessors = createCodegen({
7593
8056
  )
7594
8057
  })
7595
8058
  ),
7596
- orElse2((cause) => fail(new CodegenNotApplicableError(cause)))
8059
+ orElse2((cause) => fail3(new CodegenNotApplicableError(cause)))
7597
8060
  );
7598
8061
  })
7599
8062
  });
@@ -7606,7 +8069,7 @@ var annotate = createCodegen({
7606
8069
  const tsUtils = yield* service(TypeScriptUtils);
7607
8070
  const typeChecker = yield* service(TypeCheckerApi);
7608
8071
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
7609
- const parse3 = (node) => gen(function* () {
8072
+ const parse3 = fn("annotate.parse")(function* (node) {
7610
8073
  let variableDeclarations = [];
7611
8074
  const result = [];
7612
8075
  if (ts.isVariableStatement(node)) {
@@ -7617,14 +8080,14 @@ var annotate = createCodegen({
7617
8080
  variableDeclarations = [...variableDeclarations, node];
7618
8081
  }
7619
8082
  if (variableDeclarations.length === 0) {
7620
- return yield* fail(new CodegenNotApplicableError("not a variable declaration"));
8083
+ return yield* fail3(new CodegenNotApplicableError("not a variable declaration"));
7621
8084
  }
7622
8085
  for (const variableDeclaration of variableDeclarations) {
7623
8086
  if (!variableDeclaration.initializer) continue;
7624
8087
  const initializerType = typeCheckerUtils.getTypeAtLocation(variableDeclaration.initializer);
7625
8088
  if (!initializerType) continue;
7626
8089
  const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
7627
- const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
8090
+ const initializerTypeNode = fromNullishOr(typeCheckerUtils.typeToSimplifiedTypeNode(
7628
8091
  initializerType,
7629
8092
  enclosingNode,
7630
8093
  ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
@@ -7637,7 +8100,7 @@ var annotate = createCodegen({
7637
8100
  result.push({ variableDeclaration, initializerTypeNode, hash: hash3 });
7638
8101
  }
7639
8102
  if (result.length === 0) {
7640
- return yield* fail(new CodegenNotApplicableError("no variable declarations with initializers"));
8103
+ return yield* fail3(new CodegenNotApplicableError("no variable declarations with initializers"));
7641
8104
  }
7642
8105
  const hash2 = cyrb53(result.map((_) => _.hash).join("/"));
7643
8106
  return {
@@ -7646,7 +8109,7 @@ var annotate = createCodegen({
7646
8109
  };
7647
8110
  });
7648
8111
  const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
7649
- if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
8112
+ if (!nodeAndCommentRange) return yield* fail3(new CodegenNotApplicableError("no node and comment range"));
7650
8113
  return yield* pipe(
7651
8114
  parse3(nodeAndCommentRange.node),
7652
8115
  map4(
@@ -7707,13 +8170,13 @@ var makeStructuralSchemaGenContext = fn("StructuralSchemaGen.makeContext")(
7707
8170
  ts.factory.createIdentifier(effectSchemaIdentifier),
7708
8171
  apiName
7709
8172
  ),
7710
- createApiCall: (apiName, args2) => ts.factory.createCallExpression(
8173
+ createApiCall: (apiName, args3) => ts.factory.createCallExpression(
7711
8174
  ts.factory.createPropertyAccessExpression(
7712
8175
  ts.factory.createIdentifier(effectSchemaIdentifier),
7713
8176
  apiName
7714
8177
  ),
7715
8178
  [],
7716
- args2
8179
+ args3
7717
8180
  ),
7718
8181
  hoistedSchemas: /* @__PURE__ */ new Map(),
7719
8182
  typeToStatementIndex: /* @__PURE__ */ new Map(),
@@ -7763,7 +8226,7 @@ var processType = fn(
7763
8226
  StructuralSchemaGenContext
7764
8227
  );
7765
8228
  if (processingContext.depth >= processingContext.maxDepth) {
7766
- return yield* fail(new UnsupportedTypeError(type, "Maximum depth exceeded"));
8229
+ return yield* fail3(new UnsupportedTypeError(type, "Maximum depth exceeded"));
7767
8230
  }
7768
8231
  let hoistName = fromIterable(nameToType.entries()).find(([_, existingType]) => existingType === type)?.[0];
7769
8232
  if (!hoistName && type && type.symbol && type.symbol.declarations && type.symbol.declarations.length === 1) {
@@ -7877,7 +8340,7 @@ var processTypeImpl = fn(
7877
8340
  const objectType = type;
7878
8341
  return yield* processObjectType(objectType, context);
7879
8342
  }
7880
- return yield* fail(
8343
+ return yield* fail3(
7881
8344
  new UnsupportedTypeError(
7882
8345
  type,
7883
8346
  `Type with flags ${type.flags} is not supported`
@@ -7957,7 +8420,7 @@ var processArrayType = fn(
7957
8420
  const { createApiCall, typeChecker, typeCheckerUtils } = yield* service(StructuralSchemaGenContext);
7958
8421
  const typeArgs = typeChecker.getTypeArguments(type);
7959
8422
  if (typeArgs.length === 0) {
7960
- return yield* fail(new UnsupportedTypeError(type, "Array type has no type arguments"));
8423
+ return yield* fail3(new UnsupportedTypeError(type, "Array type has no type arguments"));
7961
8424
  }
7962
8425
  const elementSchema = yield* processType(typeArgs[0], context);
7963
8426
  const expr = createApiCall("Array", [elementSchema]);
@@ -8033,7 +8496,7 @@ var processObjectType = fn(
8033
8496
  );
8034
8497
  }
8035
8498
  const indexInfos = typeChecker.getIndexInfosOfType(type);
8036
- const args2 = [
8499
+ const args3 = [
8037
8500
  ts.factory.createObjectLiteralExpression(propertyAssignments, propertyAssignments.length > 0)
8038
8501
  ];
8039
8502
  const records = [];
@@ -8048,7 +8511,7 @@ var processObjectType = fn(
8048
8511
  if (records.length > 0) {
8049
8512
  return [
8050
8513
  createApiCall("StructWithRest", [
8051
- createApiCall("Struct", args2),
8514
+ createApiCall("Struct", args3),
8052
8515
  ts.factory.createArrayLiteralExpression(
8053
8516
  records.map(({ key, value }) => createApiCall("Record", [key, value]))
8054
8517
  )
@@ -8080,7 +8543,7 @@ var processObjectType = fn(
8080
8543
  [ts.factory.createStringLiteral(context.hoistName)]
8081
8544
  ),
8082
8545
  [],
8083
- args2
8546
+ args3
8084
8547
  ),
8085
8548
  []
8086
8549
  )
@@ -8093,14 +8556,14 @@ var processObjectType = fn(
8093
8556
  return [ctx.hoistedSchemas.get(type)(), true];
8094
8557
  }
8095
8558
  for (const { key, value } of records) {
8096
- args2.push(
8559
+ args3.push(
8097
8560
  ts.factory.createObjectLiteralExpression([
8098
8561
  ts.factory.createPropertyAssignment("key", key),
8099
8562
  ts.factory.createPropertyAssignment("value", value)
8100
8563
  ])
8101
8564
  );
8102
8565
  }
8103
- return [createApiCall("Struct", args2), propertyAssignments.length === 0];
8566
+ return [createApiCall("Struct", args3), propertyAssignments.length === 0];
8104
8567
  }
8105
8568
  );
8106
8569
  var findNodeToProcess = fn("StructuralSchemaGen.findNodeToProcess")(
@@ -8187,7 +8650,7 @@ var process = fn("StructuralSchemaGen.process")(
8187
8650
  ([name, type]) => pipe(
8188
8651
  processType(type, createProcessingContext(typeParser.supportedEffect())),
8189
8652
  orElse2(
8190
- (error) => succeed(ts.addSyntheticLeadingComment(
8653
+ (error) => succeed3(ts.addSyntheticLeadingComment(
8191
8654
  ts.factory.createIdentifier(""),
8192
8655
  ts.SyntaxKind.MultiLineCommentTrivia,
8193
8656
  " " + String(error) + " ",
@@ -8260,10 +8723,10 @@ var process = fn("StructuralSchemaGen.process")(
8260
8723
  }
8261
8724
  );
8262
8725
  var applyAtNode = fn("StructuralSchemaGen.applyAtNode")(
8263
- function* (sourceFile, node, identifier, type, isExported) {
8726
+ function* (sourceFile, node, identifier2, type, isExported) {
8264
8727
  const changeTracker = yield* service(ChangeTracker);
8265
8728
  const ts = yield* service(TypeScriptApi);
8266
- const ctx = yield* process(sourceFile, node, /* @__PURE__ */ new Map([[ts.idText(identifier), type]]), isExported, false);
8729
+ const ctx = yield* process(sourceFile, node, /* @__PURE__ */ new Map([[ts.idText(identifier2), type]]), isExported, false);
8267
8730
  for (const statement of ctx.schemaStatements) {
8268
8731
  changeTracker.insertNodeAt(sourceFile, node.pos, statement, { prefix: "\n", suffix: "\n" });
8269
8732
  }
@@ -8282,13 +8745,13 @@ var typeToSchema = createCodegen({
8282
8745
  const program = yield* service(TypeScriptProgram);
8283
8746
  const inThisFile = yield* getCodegensForSourceFile([typeToSchema], sourceFile);
8284
8747
  if (inThisFile.length > 1) {
8285
- return yield* fail(
8748
+ return yield* fail3(
8286
8749
  new CodegenNotApplicableError("the typeToSchema codegen can be used only once per file")
8287
8750
  );
8288
8751
  }
8289
- const parse3 = (node) => gen(function* () {
8752
+ const parse3 = fn("typeToSchema.parse")(function* (node) {
8290
8753
  if (!ts.isTypeAliasDeclaration(node)) {
8291
- return yield* fail(
8754
+ return yield* fail3(
8292
8755
  new CodegenNotApplicableError(
8293
8756
  "this codegen is applicable only to a type alias where each object member is a schema to generate. e.g. `type ToGenerate = { UserSchema: User, TodoSchema: Todo}`"
8294
8757
  )
@@ -8296,7 +8759,7 @@ var typeToSchema = createCodegen({
8296
8759
  }
8297
8760
  const type = typeCheckerUtils.getTypeAtLocation(node.name);
8298
8761
  if (!type) {
8299
- return yield* fail(
8762
+ return yield* fail3(
8300
8763
  new CodegenNotApplicableError(
8301
8764
  "error getting the type to process"
8302
8765
  )
@@ -8329,7 +8792,7 @@ var typeToSchema = createCodegen({
8329
8792
  });
8330
8793
  const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
8331
8794
  if (!nodeAndCommentRange) {
8332
- return yield* fail(new CodegenNotApplicableError("no node and comment range affected"));
8795
+ return yield* fail3(new CodegenNotApplicableError("no node and comment range affected"));
8333
8796
  }
8334
8797
  return yield* pipe(
8335
8798
  parse3(nodeAndCommentRange.node),
@@ -8465,7 +8928,7 @@ var overriddenSchemaConstructor = createDiagnostic({
8465
8928
  const isSchema = yield* pipe(
8466
8929
  typeParser.effectSchemaType(typeAtLocation, type.expression),
8467
8930
  map4(() => true),
8468
- orElse2(() => succeed(false))
8931
+ orElse2(() => succeed3(false))
8469
8932
  );
8470
8933
  if (isSchema) {
8471
8934
  extendsSchema = true;
@@ -8563,73 +9026,99 @@ var preferSchemaOverJson = createDiagnostic({
8563
9026
  apply: fn("preferSchemaOverJson.apply")(function* (sourceFile, report) {
8564
9027
  const ts = yield* service(TypeScriptApi);
8565
9028
  const typeParser = yield* service(TypeParser);
8566
- const parseJsonMethod = (node) => gen(function* () {
8567
- if (!ts.isCallExpression(node)) return yield* fail("node is not a call expression");
8568
- const expression = node.expression;
8569
- if (!ts.isPropertyAccessExpression(expression)) return yield* fail("expression is not a property access");
8570
- const objectExpr = expression.expression;
8571
- const methodName = ts.idText(expression.name);
8572
- if (!ts.isIdentifier(objectExpr) || ts.idText(objectExpr) !== "JSON") {
8573
- return yield* fail("object is not JSON");
9029
+ const isJsonCall = (node) => ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && ts.idText(node.expression.expression) === "JSON" && (ts.idText(node.expression.name) === "parse" || ts.idText(node.expression.name) === "stringify");
9030
+ const findEnclosingEffectTry = (jsonCall) => {
9031
+ const parent = jsonCall.parent;
9032
+ let lazy;
9033
+ if (ts.isArrowFunction(parent) && parent.body === jsonCall && parent.parameters.length === 0 && (!parent.typeParameters || parent.typeParameters.length === 0)) {
9034
+ lazy = parent;
9035
+ }
9036
+ if (!lazy && ts.isReturnStatement(parent) && parent.expression === jsonCall) {
9037
+ const block = parent.parent;
9038
+ if (ts.isBlock(block) && block.statements.length === 1) {
9039
+ const fn2 = block.parent;
9040
+ if ((ts.isArrowFunction(fn2) || ts.isFunctionExpression(fn2)) && fn2.parameters.length === 0 && (!fn2.typeParameters || fn2.typeParameters.length === 0)) {
9041
+ lazy = fn2;
9042
+ }
9043
+ }
8574
9044
  }
8575
- if (methodName !== "parse" && methodName !== "stringify") {
8576
- return yield* fail("method is not parse or stringify");
9045
+ if (!lazy) return void 0;
9046
+ const lazyParent = lazy.parent;
9047
+ if (ts.isCallExpression(lazyParent) && lazyParent.arguments.length > 0 && lazyParent.arguments[0] === lazy) {
9048
+ return lazyParent;
8577
9049
  }
8578
- return { node, methodName };
8579
- });
8580
- const effectTrySimple = (node) => gen(function* () {
8581
- if (!ts.isCallExpression(node)) return yield* fail("node is not a call expression");
9050
+ if (ts.isPropertyAssignment(lazyParent) && ts.isIdentifier(lazyParent.name) && ts.idText(lazyParent.name) === "try") {
9051
+ const objLiteral = lazyParent.parent;
9052
+ if (ts.isObjectLiteralExpression(objLiteral)) {
9053
+ const callExpr = objLiteral.parent;
9054
+ if (ts.isCallExpression(callExpr) && callExpr.arguments.length > 0 && callExpr.arguments[0] === objLiteral) {
9055
+ return callExpr;
9056
+ }
9057
+ }
9058
+ }
9059
+ return void 0;
9060
+ };
9061
+ const jsonCalls = [];
9062
+ const collectJsonCalls = (node) => {
9063
+ if (isJsonCall(node)) {
9064
+ jsonCalls.push(node);
9065
+ }
9066
+ ts.forEachChild(node, collectJsonCalls);
9067
+ };
9068
+ ts.forEachChild(sourceFile, collectJsonCalls);
9069
+ if (jsonCalls.length === 0) return;
9070
+ const effectTrySimple = fn("preferSchemaOverJson.effectTrySimple")(function* (node) {
8582
9071
  yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
8583
- if (node.arguments.length === 0) return yield* fail("Effect.try has no arguments");
9072
+ if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
8584
9073
  const lazyFn = yield* typeParser.lazyExpression(node.arguments[0]);
8585
- const jsonMethod = yield* parseJsonMethod(lazyFn.expression);
8586
- return { node: jsonMethod.node, methodName: jsonMethod.methodName };
9074
+ if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
9075
+ return lazyFn.expression;
8587
9076
  });
8588
- const effectTryObject = (node) => gen(function* () {
8589
- if (!ts.isCallExpression(node)) return yield* fail("node is not a call expression");
9077
+ const effectTryObject = fn("preferSchemaOverJson.effectTryObject")(function* (node) {
8590
9078
  yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
8591
- if (node.arguments.length === 0) return yield* fail("Effect.try has no arguments");
9079
+ if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
8592
9080
  const arg = node.arguments[0];
8593
- if (!ts.isObjectLiteralExpression(arg)) return yield* fail("argument is not an object literal");
9081
+ if (!ts.isObjectLiteralExpression(arg)) return yield* TypeParserIssue.issue;
8594
9082
  const tryProp = arg.properties.find(
8595
9083
  (p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && ts.idText(p.name) === "try"
8596
9084
  );
8597
- if (!tryProp) return yield* fail("object has no 'try' property");
9085
+ if (!tryProp) return yield* TypeParserIssue.issue;
8598
9086
  const lazyFn = yield* typeParser.lazyExpression(tryProp.initializer);
8599
- const jsonMethod = yield* parseJsonMethod(lazyFn.expression);
8600
- return { node: jsonMethod.node, methodName: jsonMethod.methodName };
9087
+ if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
9088
+ return lazyFn.expression;
8601
9089
  });
8602
- const jsonMethodInEffectGen = (node) => gen(function* () {
8603
- const jsonMethod = yield* parseJsonMethod(node);
8604
- const { effectGen, scopeNode } = yield* typeParser.findEnclosingScopes(node);
8605
- if (!effectGen || effectGen.body.statements.length === 0) {
8606
- return yield* fail("not inside an Effect generator");
9090
+ const jsonMethodInEffectGen = fn("preferSchemaOverJson.jsonMethodInEffectGen")(
9091
+ function* (jsonCall) {
9092
+ const { effectGen, scopeNode } = yield* typeParser.findEnclosingScopes(jsonCall);
9093
+ if (!effectGen || effectGen.body.statements.length === 0) {
9094
+ return yield* TypeParserIssue.issue;
9095
+ }
9096
+ if (scopeNode && scopeNode !== effectGen.generatorFunction) {
9097
+ return yield* TypeParserIssue.issue;
9098
+ }
9099
+ return jsonCall;
8607
9100
  }
8608
- if (scopeNode && scopeNode !== effectGen.generatorFunction) {
8609
- return yield* fail("inside a nested function scope");
9101
+ );
9102
+ for (const jsonCall of jsonCalls) {
9103
+ const effectTryCall = findEnclosingEffectTry(jsonCall);
9104
+ let match2;
9105
+ if (effectTryCall) {
9106
+ match2 = yield* pipe(
9107
+ firstSuccessOf([
9108
+ effectTrySimple(effectTryCall),
9109
+ effectTryObject(effectTryCall)
9110
+ ]),
9111
+ option
9112
+ );
9113
+ } else {
9114
+ match2 = yield* pipe(
9115
+ jsonMethodInEffectGen(jsonCall),
9116
+ option
9117
+ );
8610
9118
  }
8611
- return { node: jsonMethod.node, methodName: jsonMethod.methodName };
8612
- });
8613
- const nodeToVisit = [];
8614
- const appendNodeToVisit = (node) => {
8615
- nodeToVisit.push(node);
8616
- return void 0;
8617
- };
8618
- ts.forEachChild(sourceFile, appendNodeToVisit);
8619
- while (nodeToVisit.length > 0) {
8620
- const node = nodeToVisit.shift();
8621
- ts.forEachChild(node, appendNodeToVisit);
8622
- const match2 = yield* pipe(
8623
- firstSuccessOf([
8624
- effectTrySimple(node),
8625
- effectTryObject(node),
8626
- jsonMethodInEffectGen(node)
8627
- ]),
8628
- option
8629
- );
8630
9119
  if (isSome2(match2)) {
8631
9120
  report({
8632
- location: match2.value.node,
9121
+ location: match2.value,
8633
9122
  messageText: "Consider using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify",
8634
9123
  fixes: []
8635
9124
  });
@@ -9046,11 +9535,11 @@ var schemaUnionOfLiterals = createDiagnostic({
9046
9535
  orElse2(() => void_)
9047
9536
  );
9048
9537
  if (isSchemaUnionCall) {
9049
- const args2 = fromIterable(node.arguments);
9050
- if (args2.length >= 2) {
9051
- const allAreCallExpressions = args2.every((arg) => ts.isCallExpression(arg));
9538
+ const args3 = fromIterable(node.arguments);
9539
+ if (args3.length >= 2) {
9540
+ const allAreCallExpressions = args3.every((arg) => ts.isCallExpression(arg));
9052
9541
  if (allAreCallExpressions) {
9053
- const literalChecks = args2.map((arg) => {
9542
+ const literalChecks = args3.map((arg) => {
9054
9543
  const callArg = arg;
9055
9544
  return pipe(
9056
9545
  typeParser.isNodeReferenceToEffectSchemaModuleApi("Literal")(callArg.expression),
@@ -9273,19 +9762,24 @@ var strictEffectProvide = createDiagnostic({
9273
9762
  const ts = yield* service(TypeScriptApi);
9274
9763
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
9275
9764
  const typeParser = yield* service(TypeParser);
9276
- const parseEffectProvideWithLayer = (node) => gen(function* () {
9765
+ const parseEffectProvideWithLayerGen = fn("strictEffectProvide.parseEffectProvideWithLayer")(
9766
+ function* (node) {
9767
+ yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
9768
+ return yield* firstSuccessOf(
9769
+ node.arguments.map((arg) => {
9770
+ const argType = typeCheckerUtils.getTypeAtLocation(arg);
9771
+ if (!argType) return typeParserIssue("Could not get argument type");
9772
+ return typeParser.layerType(argType, arg);
9773
+ })
9774
+ );
9775
+ }
9776
+ );
9777
+ const parseEffectProvideWithLayer = (node) => {
9277
9778
  if (!ts.isCallExpression(node) || node.arguments.length === 0) {
9278
- return yield* typeParserIssue("Not an Effect.provide call");
9279
- }
9280
- yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
9281
- return yield* firstSuccessOf(
9282
- node.arguments.map((arg) => {
9283
- const argType = typeCheckerUtils.getTypeAtLocation(arg);
9284
- if (!argType) return typeParserIssue("Could not get argument type");
9285
- return typeParser.layerType(argType, arg);
9286
- })
9287
- );
9288
- });
9779
+ return TypeParserIssue.issue;
9780
+ }
9781
+ return parseEffectProvideWithLayerGen(node);
9782
+ };
9289
9783
  const nodeToVisit = [];
9290
9784
  const appendNodeToVisit = (node) => {
9291
9785
  nodeToVisit.push(node);
@@ -9551,8 +10045,8 @@ var unnecessaryPipe = createDiagnostic({
9551
10045
  if (ts.isCallExpression(node)) {
9552
10046
  yield* pipe(
9553
10047
  typeParser.pipeCall(node),
9554
- map4(({ args: args2, subject }) => {
9555
- if (args2.length === 0) {
10048
+ map4(({ args: args3, subject }) => {
10049
+ if (args3.length === 0) {
9556
10050
  report({
9557
10051
  location: node,
9558
10052
  messageText: `This pipe call contains no arguments.`,
@@ -9671,7 +10165,7 @@ var unsupportedServiceAccessors = createDiagnostic({
9671
10165
  if (ts.isClassDeclaration(node)) {
9672
10166
  const parseResult = yield* pipe(
9673
10167
  parse2(node),
9674
- orElse2(() => succeed(null))
10168
+ orElse2(() => succeed3(null))
9675
10169
  );
9676
10170
  if (parseResult && parseResult.involvedMembers.length > 0) {
9677
10171
  const existingStaticMembers = /* @__PURE__ */ new Set();
@@ -9815,7 +10309,7 @@ function checkSourceFileWorker(tsInstance, program, sourceFile, compilerOptions,
9815
10309
  return _;
9816
10310
  })
9817
10311
  ),
9818
- getOrElse((e) => {
10312
+ getOrElse2((e) => {
9819
10313
  console.error(e.message, "at", e.lastSpan);
9820
10314
  return [];
9821
10315
  }),