@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.
- package/README.md +1 -0
- package/cli.js +26538 -31884
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +1347 -853
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +2202 -3117
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +1348 -853
- package/transform.js.map +1 -1
|
@@ -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@
|
|
31
|
-
var
|
|
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
|
-
|
|
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
|
|
97
|
+
const args3 = arguments;
|
|
87
98
|
return function(self) {
|
|
88
|
-
return body(self, ...
|
|
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,
|
|
97
|
-
|
|
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@
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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@
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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@
|
|
273
|
-
var
|
|
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
|
-
|
|
298
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
324
|
-
return
|
|
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 (
|
|
345
|
-
h ^=
|
|
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,
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
|
|
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@
|
|
375
|
-
var symbol2 =
|
|
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
|
-
|
|
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 === "
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
|
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
|
|
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
|
|
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@
|
|
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
|
|
536
|
+
var toJson = (input) => {
|
|
433
537
|
try {
|
|
434
|
-
if (hasProperty(
|
|
435
|
-
return
|
|
436
|
-
} else if (Array.isArray(
|
|
437
|
-
return
|
|
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(
|
|
546
|
+
return redact(input);
|
|
443
547
|
};
|
|
444
|
-
var format = (x) => JSON.stringify(x, null, 2);
|
|
445
548
|
var BaseProto = {
|
|
446
549
|
toJSON() {
|
|
447
|
-
return
|
|
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.
|
|
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.
|
|
804
|
+
return `Fail(${format(this.error)})`;
|
|
468
805
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
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
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
[
|
|
568
|
-
|
|
569
|
-
|
|
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
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
922
|
+
let cont = fiber.getCont(contE);
|
|
923
|
+
while (fiber.interruptible && fiber._interruptedCause && cont) {
|
|
924
|
+
cont = fiber.getCont(contE);
|
|
596
925
|
}
|
|
597
|
-
return
|
|
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
|
|
601
|
-
|
|
602
|
-
|
|
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
|
|
605
|
-
|
|
606
|
-
|
|
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@
|
|
610
|
-
var TypeId =
|
|
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
|
-
|
|
617
|
-
|
|
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
|
|
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:
|
|
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@
|
|
668
|
-
var TypeId2 =
|
|
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
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
return this.toJSON();
|
|
1062
|
+
/* v8 ignore next 2 */
|
|
1063
|
+
_A: (_) => _,
|
|
1064
|
+
_E: (_) => _
|
|
676
1065
|
},
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
1066
|
+
...PipeInspectableProto,
|
|
1067
|
+
...YieldableProto
|
|
680
1068
|
};
|
|
681
|
-
var
|
|
682
|
-
_tag: "
|
|
683
|
-
_op: "
|
|
1069
|
+
var SuccessProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
1070
|
+
_tag: "Success",
|
|
1071
|
+
_op: "Success",
|
|
684
1072
|
[symbol2](that) {
|
|
685
|
-
return
|
|
1073
|
+
return isResult(that) && isSuccess(that) && equals(this.success, that.success);
|
|
686
1074
|
},
|
|
687
1075
|
[symbol]() {
|
|
688
|
-
return combine(hash(this._tag))(hash(this.
|
|
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: "
|
|
1083
|
+
_id: "Result",
|
|
693
1084
|
_tag: this._tag,
|
|
694
|
-
|
|
1085
|
+
value: toJson(this.success)
|
|
695
1086
|
};
|
|
1087
|
+
},
|
|
1088
|
+
asEffect() {
|
|
1089
|
+
return exitSucceed(this.success);
|
|
696
1090
|
}
|
|
697
1091
|
});
|
|
698
|
-
var
|
|
699
|
-
_tag: "
|
|
700
|
-
_op: "
|
|
1092
|
+
var FailureProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
1093
|
+
_tag: "Failure",
|
|
1094
|
+
_op: "Failure",
|
|
701
1095
|
[symbol2](that) {
|
|
702
|
-
return
|
|
1096
|
+
return isResult(that) && isFailure(that) && equals(this.failure, that.failure);
|
|
703
1097
|
},
|
|
704
1098
|
[symbol]() {
|
|
705
|
-
return combine(hash(this._tag))(hash(this.
|
|
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: "
|
|
1106
|
+
_id: "Result",
|
|
710
1107
|
_tag: this._tag,
|
|
711
|
-
|
|
1108
|
+
failure: toJson(this.failure)
|
|
712
1109
|
};
|
|
1110
|
+
},
|
|
1111
|
+
asEffect() {
|
|
1112
|
+
return exitFail(this.failure);
|
|
713
1113
|
}
|
|
714
1114
|
});
|
|
715
|
-
var
|
|
716
|
-
var
|
|
717
|
-
var
|
|
718
|
-
var
|
|
719
|
-
const a = Object.create(
|
|
720
|
-
a.
|
|
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
|
|
724
|
-
const a = Object.create(
|
|
725
|
-
a.
|
|
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@
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
var
|
|
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@
|
|
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
|
|
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
|
|
752
|
-
var getOrUndefined = /* @__PURE__ */
|
|
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@
|
|
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@
|
|
767
|
-
var
|
|
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 =
|
|
771
|
-
var
|
|
772
|
-
var
|
|
773
|
-
var
|
|
774
|
-
|
|
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
|
|
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
|
|
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__ */
|
|
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 =
|
|
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
|
|
807
|
-
return fromIterable(self).filter((a) => has(
|
|
1218
|
+
const thatArray = fromIterable(that);
|
|
1219
|
+
return fromIterable(self).filter((a) => has(thatArray, a));
|
|
808
1220
|
});
|
|
809
1221
|
};
|
|
810
|
-
var intersection = /* @__PURE__ */ intersectionWith(
|
|
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 (
|
|
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,
|
|
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
|
-
|
|
832
|
-
|
|
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 (
|
|
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,
|
|
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 = (
|
|
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
|
|
887
|
-
var
|
|
888
|
-
var
|
|
889
|
-
var
|
|
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
|
|
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[
|
|
1322
|
+
return this[args2];
|
|
909
1323
|
},
|
|
910
|
-
[
|
|
911
|
-
const cont = fiber.getCont(
|
|
912
|
-
return cont ? cont[
|
|
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
|
|
1329
|
+
var succeed3 = (value) => {
|
|
916
1330
|
const nano = Object.create(SucceedProto);
|
|
917
|
-
nano[
|
|
1331
|
+
nano[args2] = value;
|
|
918
1332
|
return nano;
|
|
919
1333
|
};
|
|
920
|
-
var
|
|
1334
|
+
var FailureProto2 = {
|
|
921
1335
|
...PrimitiveProto,
|
|
922
1336
|
_tag: "Failure",
|
|
923
1337
|
get value() {
|
|
924
|
-
return this[
|
|
1338
|
+
return this[args2];
|
|
925
1339
|
},
|
|
926
|
-
[
|
|
927
|
-
const cont = fiber.getCont(
|
|
928
|
-
return cont ? cont[
|
|
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
|
|
932
|
-
const nano = Object.create(
|
|
933
|
-
nano[
|
|
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
|
-
[
|
|
939
|
-
return this[
|
|
1352
|
+
[evaluate2]() {
|
|
1353
|
+
return this[args2]();
|
|
940
1354
|
}
|
|
941
1355
|
};
|
|
942
1356
|
var suspend = (fn2) => {
|
|
943
1357
|
const nano = Object.create(SuspendProto);
|
|
944
|
-
nano[
|
|
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[
|
|
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[
|
|
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
|
-
[
|
|
982
|
-
const [fa, name] = this[
|
|
983
|
-
if (!
|
|
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
|
|
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
|
|
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[
|
|
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
|
|
1426
|
+
return succeed2(result.value);
|
|
1015
1427
|
}
|
|
1016
|
-
return
|
|
1428
|
+
return fail2(result.value);
|
|
1017
1429
|
};
|
|
1018
1430
|
var OnSuccessProto = {
|
|
1019
1431
|
...PrimitiveProto,
|
|
1020
|
-
[
|
|
1432
|
+
[evaluate2](fiber) {
|
|
1021
1433
|
fiber._stack.push(this);
|
|
1022
|
-
return this[
|
|
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[
|
|
1028
|
-
nano[
|
|
1439
|
+
nano[args2] = fa;
|
|
1440
|
+
nano[contA2] = f;
|
|
1029
1441
|
return nano;
|
|
1030
1442
|
});
|
|
1031
|
-
var map4 = dual(2, (fa, f) => flatMap2(fa, (_) =>
|
|
1443
|
+
var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed3(f(_))));
|
|
1032
1444
|
var SyncProto = {
|
|
1033
1445
|
...PrimitiveProto,
|
|
1034
|
-
[
|
|
1035
|
-
const value = this[
|
|
1036
|
-
const cont = fiber.getCont(
|
|
1037
|
-
return cont ? cont[
|
|
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[
|
|
1454
|
+
nano[args2] = f;
|
|
1043
1455
|
return nano;
|
|
1044
1456
|
};
|
|
1045
|
-
var void_ =
|
|
1457
|
+
var void_ = succeed3(void 0);
|
|
1046
1458
|
var FromIteratorProto = {
|
|
1047
1459
|
...PrimitiveProto,
|
|
1048
|
-
[
|
|
1049
|
-
const state = this[
|
|
1050
|
-
if (state.done) return
|
|
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
|
-
[
|
|
1055
|
-
return this[
|
|
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[
|
|
1472
|
+
nano[args2] = [iterator, initial];
|
|
1061
1473
|
return nano;
|
|
1062
1474
|
};
|
|
1063
|
-
var gen = (...
|
|
1064
|
-
var fn = (_) => (body) => (...
|
|
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
|
-
[
|
|
1479
|
+
[evaluate2](fiber) {
|
|
1068
1480
|
fiber._stack.push(this);
|
|
1069
|
-
return this[
|
|
1481
|
+
return this[args2];
|
|
1070
1482
|
}
|
|
1071
1483
|
};
|
|
1072
1484
|
var match = (fa, opts) => {
|
|
1073
1485
|
const nano = Object.create(MatchProto);
|
|
1074
|
-
nano[
|
|
1075
|
-
nano[
|
|
1076
|
-
nano[
|
|
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[
|
|
1082
|
-
nano[
|
|
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
|
-
[
|
|
1500
|
+
[evaluate2](fiber) {
|
|
1089
1501
|
const prevServices = fiber._services;
|
|
1090
|
-
const [fa, tag, value] = this[
|
|
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
|
|
1510
|
+
return succeed3(_);
|
|
1099
1511
|
},
|
|
1100
1512
|
onFailure: (_) => {
|
|
1101
1513
|
fiber._services = prevServices;
|
|
1102
|
-
return
|
|
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[
|
|
1521
|
+
nano[args2] = [fa, tag, value];
|
|
1110
1522
|
return nano;
|
|
1111
1523
|
};
|
|
1112
1524
|
var ServiceProto = {
|
|
1113
1525
|
...PrimitiveProto,
|
|
1114
|
-
[
|
|
1115
|
-
const tag = this[
|
|
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(
|
|
1119
|
-
return cont2 ? cont2[
|
|
1530
|
+
const cont2 = fiber.getCont(contA2);
|
|
1531
|
+
return cont2 ? cont2[contA2](value, fiber) : fiber.yieldWith(succeed3(value));
|
|
1120
1532
|
}
|
|
1121
|
-
const cont = fiber.getCont(
|
|
1122
|
-
return cont ? cont[
|
|
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[
|
|
1539
|
+
nano[args2] = tag;
|
|
1128
1540
|
return nano;
|
|
1129
1541
|
};
|
|
1130
1542
|
var CachedProto = {
|
|
1131
1543
|
...PrimitiveProto,
|
|
1132
|
-
[
|
|
1133
|
-
const [fa, type, key] = this[
|
|
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
|
|
1137
|
-
if (
|
|
1548
|
+
const cached = cache.get(key);
|
|
1549
|
+
if (cached) return cached;
|
|
1138
1550
|
return match(fa, {
|
|
1139
1551
|
onSuccess: (_) => {
|
|
1140
|
-
cache.set(key,
|
|
1141
|
-
return
|
|
1552
|
+
cache.set(key, succeed3(_));
|
|
1553
|
+
return succeed3(_);
|
|
1142
1554
|
},
|
|
1143
1555
|
onFailure: (_) => {
|
|
1144
|
-
cache.set(key,
|
|
1145
|
-
return
|
|
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[
|
|
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[
|
|
1160
|
-
nano[
|
|
1161
|
-
nano[
|
|
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[
|
|
1167
|
-
nano[
|
|
1168
|
-
nano[
|
|
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[
|
|
1174
|
-
nano[
|
|
1175
|
-
nano[
|
|
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* (...
|
|
1591
|
+
function* (...args3) {
|
|
1180
1592
|
const results = [];
|
|
1181
|
-
for (const fa of
|
|
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 (!
|
|
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") &&
|
|
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") &&
|
|
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") &&
|
|
1704
|
+
if (hasProperty(program, "getModuleResolutionCache") && isFunction(program.getModuleResolutionCache)) {
|
|
1293
1705
|
const moduleResolutionCache = program.getModuleResolutionCache();
|
|
1294
|
-
if (hasProperty(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") &&
|
|
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") &&
|
|
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") &&
|
|
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") &&
|
|
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 =
|
|
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*
|
|
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 = (
|
|
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*
|
|
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
|
|
2387
|
-
if (
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
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, ...
|
|
3503
|
-
return
|
|
3953
|
+
const [subject, ...args3] = node.arguments;
|
|
3954
|
+
return succeed3({
|
|
3504
3955
|
node,
|
|
3505
3956
|
subject,
|
|
3506
|
-
args:
|
|
3957
|
+
args: args3,
|
|
3507
3958
|
kind: "pipe"
|
|
3508
3959
|
});
|
|
3509
3960
|
}
|
|
3510
|
-
return
|
|
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, ...
|
|
3521
|
-
return
|
|
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
|
|
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
|
|
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
|
|
4011
|
-
if (ts.isObjectLiteralExpression(
|
|
4012
|
-
for (const property of
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
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,
|
|
5408
|
+
function createString(sourceFile, identifier2, kind) {
|
|
4952
5409
|
return map4(
|
|
4953
5410
|
getOrMakeKeyBuilder(sourceFile),
|
|
4954
|
-
(identifierBuilder) => identifierBuilder.createString(
|
|
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
|
-
|
|
5428
|
+
(classDeclaration) => {
|
|
4972
5429
|
if (!options.extendedKeyDetection) {
|
|
4973
|
-
return
|
|
5430
|
+
return TypeParserIssue.issue;
|
|
4974
5431
|
}
|
|
4975
5432
|
if (!classDeclaration.name) {
|
|
4976
|
-
return
|
|
5433
|
+
return TypeParserIssue.issue;
|
|
4977
5434
|
}
|
|
4978
5435
|
if (!ts.isIdentifier(classDeclaration.name)) {
|
|
4979
|
-
return
|
|
5436
|
+
return TypeParserIssue.issue;
|
|
4980
5437
|
}
|
|
4981
5438
|
const heritageClauses = classDeclaration.heritageClauses;
|
|
4982
5439
|
if (!heritageClauses) {
|
|
4983
|
-
return
|
|
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
|
|
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
|
|
5015
|
-
|
|
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 = (
|
|
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(() =>
|
|
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 = (
|
|
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:
|
|
5316
|
-
orElse2(() =>
|
|
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
|
|
5789
|
+
return succeed3(false);
|
|
5334
5790
|
}
|
|
5335
5791
|
if (parent.arguments[0] !== fnNode) {
|
|
5336
|
-
return
|
|
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(() =>
|
|
5799
|
+
orElse2(() => succeed3(false))
|
|
5344
5800
|
);
|
|
5345
5801
|
};
|
|
5346
|
-
const
|
|
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
|
|
5841
|
+
return TypeParserIssue.issue;
|
|
5349
5842
|
}
|
|
5350
5843
|
if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) {
|
|
5351
|
-
return
|
|
5844
|
+
return TypeParserIssue.issue;
|
|
5352
5845
|
}
|
|
5353
5846
|
if (ts.isFunctionExpression(node) && node.name) {
|
|
5354
|
-
return
|
|
5847
|
+
return TypeParserIssue.issue;
|
|
5355
5848
|
}
|
|
5356
5849
|
if (node.type) {
|
|
5357
|
-
return
|
|
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
|
|
5853
|
+
if (!functionType) return TypeParserIssue.issue;
|
|
5364
5854
|
const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call);
|
|
5365
|
-
if (callSignatures.length !== 1) return
|
|
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
|
|
5373
|
-
|
|
5374
|
-
|
|
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 = (
|
|
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*
|
|
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) ?
|
|
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
|
|
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(() =>
|
|
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(
|
|
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) =>
|
|
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
|
|
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
|
|
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
|
|
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
|
|
7418
|
-
return
|
|
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
|
|
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
|
|
7912
|
+
return succeed3(typeNode);
|
|
7452
7913
|
})
|
|
7453
7914
|
);
|
|
7454
|
-
const proxySignature = (
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
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*
|
|
7510
|
-
if (!ts.isClassDeclaration(node)) return yield*
|
|
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(() =>
|
|
7979
|
+
orElse2(() => fail3("not a class extending Effect.Service call"))
|
|
7517
7980
|
);
|
|
7518
|
-
if (accessors2 !== true) return yield*
|
|
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*
|
|
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(() =>
|
|
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*
|
|
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) =>
|
|
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 = (
|
|
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*
|
|
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 =
|
|
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*
|
|
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*
|
|
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,
|
|
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
|
-
|
|
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*
|
|
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*
|
|
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*
|
|
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
|
|
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",
|
|
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
|
-
|
|
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
|
-
|
|
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",
|
|
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) =>
|
|
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,
|
|
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(
|
|
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*
|
|
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 = (
|
|
8752
|
+
const parse3 = fn("typeToSchema.parse")(function* (node) {
|
|
8290
8753
|
if (!ts.isTypeAliasDeclaration(node)) {
|
|
8291
|
-
return yield*
|
|
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*
|
|
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*
|
|
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(() =>
|
|
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
|
|
8567
|
-
|
|
8568
|
-
const
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
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 (
|
|
8576
|
-
|
|
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
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
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*
|
|
9072
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
8584
9073
|
const lazyFn = yield* typeParser.lazyExpression(node.arguments[0]);
|
|
8585
|
-
|
|
8586
|
-
return
|
|
9074
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
9075
|
+
return lazyFn.expression;
|
|
8587
9076
|
});
|
|
8588
|
-
const effectTryObject = (
|
|
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*
|
|
9079
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
8592
9080
|
const arg = node.arguments[0];
|
|
8593
|
-
if (!ts.isObjectLiteralExpression(arg)) return yield*
|
|
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*
|
|
9085
|
+
if (!tryProp) return yield* TypeParserIssue.issue;
|
|
8598
9086
|
const lazyFn = yield* typeParser.lazyExpression(tryProp.initializer);
|
|
8599
|
-
|
|
8600
|
-
return
|
|
9087
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
9088
|
+
return lazyFn.expression;
|
|
8601
9089
|
});
|
|
8602
|
-
const jsonMethodInEffectGen = (
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
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
|
-
|
|
8609
|
-
|
|
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
|
|
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
|
|
9050
|
-
if (
|
|
9051
|
-
const allAreCallExpressions =
|
|
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 =
|
|
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
|
|
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
|
|
9279
|
-
}
|
|
9280
|
-
|
|
9281
|
-
|
|
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:
|
|
9555
|
-
if (
|
|
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(() =>
|
|
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
|
-
|
|
10312
|
+
getOrElse2((e) => {
|
|
9819
10313
|
console.error(e.message, "at", e.lastSpan);
|
|
9820
10314
|
return [];
|
|
9821
10315
|
}),
|