@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
package/transform.js
CHANGED
|
@@ -24,15 +24,44 @@ __export(transform_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(transform_exports);
|
|
26
26
|
|
|
27
|
-
// ../../node_modules/.pnpm/effect@
|
|
28
|
-
var
|
|
27
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Pipeable.js
|
|
28
|
+
var pipeArguments = (self, args3) => {
|
|
29
|
+
switch (args3.length) {
|
|
30
|
+
case 0:
|
|
31
|
+
return self;
|
|
32
|
+
case 1:
|
|
33
|
+
return args3[0](self);
|
|
34
|
+
case 2:
|
|
35
|
+
return args3[1](args3[0](self));
|
|
36
|
+
case 3:
|
|
37
|
+
return args3[2](args3[1](args3[0](self)));
|
|
38
|
+
case 4:
|
|
39
|
+
return args3[3](args3[2](args3[1](args3[0](self))));
|
|
40
|
+
case 5:
|
|
41
|
+
return args3[4](args3[3](args3[2](args3[1](args3[0](self)))));
|
|
42
|
+
case 6:
|
|
43
|
+
return args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self))))));
|
|
44
|
+
case 7:
|
|
45
|
+
return args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self)))))));
|
|
46
|
+
case 8:
|
|
47
|
+
return args3[7](args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self))))))));
|
|
48
|
+
case 9:
|
|
49
|
+
return args3[8](args3[7](args3[6](args3[5](args3[4](args3[3](args3[2](args3[1](args3[0](self)))))))));
|
|
50
|
+
default: {
|
|
51
|
+
let ret = self;
|
|
52
|
+
for (let i = 0, len = args3.length; i < len; i++) {
|
|
53
|
+
ret = args3[i](ret);
|
|
54
|
+
}
|
|
55
|
+
return ret;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Function.js
|
|
29
61
|
var dual = function(arity, body) {
|
|
30
62
|
if (typeof arity === "function") {
|
|
31
63
|
return function() {
|
|
32
|
-
|
|
33
|
-
return body.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
return (self) => body(self, ...arguments);
|
|
64
|
+
return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
|
|
36
65
|
};
|
|
37
66
|
}
|
|
38
67
|
switch (arity) {
|
|
@@ -57,32 +86,14 @@ var dual = function(arity, body) {
|
|
|
57
86
|
return body(self, a, b);
|
|
58
87
|
};
|
|
59
88
|
};
|
|
60
|
-
case 4:
|
|
61
|
-
return function(a, b, c, d) {
|
|
62
|
-
if (arguments.length >= 4) {
|
|
63
|
-
return body(a, b, c, d);
|
|
64
|
-
}
|
|
65
|
-
return function(self) {
|
|
66
|
-
return body(self, a, b, c);
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
case 5:
|
|
70
|
-
return function(a, b, c, d, e) {
|
|
71
|
-
if (arguments.length >= 5) {
|
|
72
|
-
return body(a, b, c, d, e);
|
|
73
|
-
}
|
|
74
|
-
return function(self) {
|
|
75
|
-
return body(self, a, b, c, d);
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
89
|
default:
|
|
79
90
|
return function() {
|
|
80
91
|
if (arguments.length >= arity) {
|
|
81
92
|
return body.apply(this, arguments);
|
|
82
93
|
}
|
|
83
|
-
const
|
|
94
|
+
const args3 = arguments;
|
|
84
95
|
return function(self) {
|
|
85
|
-
return body(self, ...
|
|
96
|
+
return body(self, ...args3);
|
|
86
97
|
};
|
|
87
98
|
};
|
|
88
99
|
}
|
|
@@ -90,189 +101,57 @@ var dual = function(arity, body) {
|
|
|
90
101
|
var identity = (a) => a;
|
|
91
102
|
var constant = (value) => () => value;
|
|
92
103
|
var constUndefined = /* @__PURE__ */ constant(void 0);
|
|
93
|
-
function pipe(a,
|
|
94
|
-
|
|
95
|
-
case 1:
|
|
96
|
-
return a;
|
|
97
|
-
case 2:
|
|
98
|
-
return ab(a);
|
|
99
|
-
case 3:
|
|
100
|
-
return bc(ab(a));
|
|
101
|
-
case 4:
|
|
102
|
-
return cd(bc(ab(a)));
|
|
103
|
-
case 5:
|
|
104
|
-
return de(cd(bc(ab(a))));
|
|
105
|
-
case 6:
|
|
106
|
-
return ef(de(cd(bc(ab(a)))));
|
|
107
|
-
case 7:
|
|
108
|
-
return fg(ef(de(cd(bc(ab(a))))));
|
|
109
|
-
case 8:
|
|
110
|
-
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
111
|
-
case 9:
|
|
112
|
-
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
113
|
-
default: {
|
|
114
|
-
let ret = arguments[0];
|
|
115
|
-
for (let i = 1; i < arguments.length; i++) {
|
|
116
|
-
ret = arguments[i](ret);
|
|
117
|
-
}
|
|
118
|
-
return ret;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
104
|
+
function pipe(a, ...args3) {
|
|
105
|
+
return pipeArguments(a, args3);
|
|
121
106
|
}
|
|
122
107
|
|
|
123
|
-
// ../../node_modules/.pnpm/effect@
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
108
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/equal.js
|
|
109
|
+
var getAllObjectKeys = (obj) => {
|
|
110
|
+
const keys2 = new Set(Reflect.ownKeys(obj));
|
|
111
|
+
if (obj.constructor === Object) return keys2;
|
|
112
|
+
if (obj instanceof Error) {
|
|
113
|
+
keys2.delete("stack");
|
|
114
|
+
}
|
|
115
|
+
const proto = Object.getPrototypeOf(obj);
|
|
116
|
+
let current = proto;
|
|
117
|
+
while (current !== null && current !== Object.prototype) {
|
|
118
|
+
const ownKeys = Reflect.ownKeys(current);
|
|
119
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
120
|
+
keys2.add(ownKeys[i]);
|
|
121
|
+
}
|
|
122
|
+
current = Object.getPrototypeOf(current);
|
|
123
|
+
}
|
|
124
|
+
if (keys2.has("constructor") && typeof obj.constructor === "function" && proto === obj.constructor.prototype) {
|
|
125
|
+
keys2.delete("constructor");
|
|
126
|
+
}
|
|
127
|
+
return keys2;
|
|
135
128
|
};
|
|
129
|
+
var byReferenceInstances = /* @__PURE__ */ new WeakSet();
|
|
136
130
|
|
|
137
|
-
// ../../node_modules/.pnpm/effect@
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
get _F() {
|
|
158
|
-
return identity;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* @since 2.0.0
|
|
162
|
-
*/
|
|
163
|
-
get _R() {
|
|
164
|
-
return (_) => _;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @since 2.0.0
|
|
168
|
-
*/
|
|
169
|
-
get _O() {
|
|
170
|
-
return (_) => _;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @since 2.0.0
|
|
174
|
-
*/
|
|
175
|
-
get _E() {
|
|
176
|
-
return (_) => _;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* @since 2.0.0
|
|
180
|
-
*/
|
|
181
|
-
[GenKindTypeId] = GenKindTypeId;
|
|
182
|
-
/**
|
|
183
|
-
* @since 2.0.0
|
|
184
|
-
*/
|
|
185
|
-
[Symbol.iterator]() {
|
|
186
|
-
return new SingleShotGen(this);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
var SingleShotGen = class _SingleShotGen {
|
|
190
|
-
self;
|
|
191
|
-
called = false;
|
|
192
|
-
constructor(self) {
|
|
193
|
-
this.self = self;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* @since 2.0.0
|
|
197
|
-
*/
|
|
198
|
-
next(a) {
|
|
199
|
-
return this.called ? {
|
|
200
|
-
value: a,
|
|
201
|
-
done: true
|
|
202
|
-
} : (this.called = true, {
|
|
203
|
-
value: this.self,
|
|
204
|
-
done: false
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* @since 2.0.0
|
|
209
|
-
*/
|
|
210
|
-
return(a) {
|
|
211
|
-
return {
|
|
212
|
-
value: a,
|
|
213
|
-
done: true
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* @since 2.0.0
|
|
218
|
-
*/
|
|
219
|
-
throw(e) {
|
|
220
|
-
throw e;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* @since 2.0.0
|
|
224
|
-
*/
|
|
225
|
-
[Symbol.iterator]() {
|
|
226
|
-
return new _SingleShotGen(this.self);
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
var MUL_HI = 1481765933 >>> 0;
|
|
230
|
-
var MUL_LO = 1284865837 >>> 0;
|
|
231
|
-
var YieldWrapTypeId = /* @__PURE__ */ Symbol.for("effect/Utils/YieldWrap");
|
|
232
|
-
var YieldWrap = class {
|
|
233
|
-
/**
|
|
234
|
-
* @since 3.0.6
|
|
235
|
-
*/
|
|
236
|
-
#value;
|
|
237
|
-
constructor(value) {
|
|
238
|
-
this.#value = value;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* @since 3.0.6
|
|
242
|
-
*/
|
|
243
|
-
[YieldWrapTypeId]() {
|
|
244
|
-
return this.#value;
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructuralRegion", () => ({
|
|
248
|
-
enabled: false,
|
|
249
|
-
tester: void 0
|
|
250
|
-
}));
|
|
251
|
-
var standard = {
|
|
252
|
-
effect_internal_function: (body) => {
|
|
253
|
-
return body();
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
var forced = {
|
|
257
|
-
effect_internal_function: (body) => {
|
|
258
|
-
try {
|
|
259
|
-
return body();
|
|
260
|
-
} finally {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
var isNotOptimizedAway = /* @__PURE__ */ standard.effect_internal_function(() => new Error().stack)?.includes("effect_internal_function") === true;
|
|
265
|
-
var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forced.effect_internal_function;
|
|
266
|
-
var genConstructor = function* () {
|
|
267
|
-
}.constructor;
|
|
131
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Predicate.js
|
|
132
|
+
function isString(input) {
|
|
133
|
+
return typeof input === "string";
|
|
134
|
+
}
|
|
135
|
+
function isNumber(input) {
|
|
136
|
+
return typeof input === "number";
|
|
137
|
+
}
|
|
138
|
+
function isBoolean(input) {
|
|
139
|
+
return typeof input === "boolean";
|
|
140
|
+
}
|
|
141
|
+
function isFunction(input) {
|
|
142
|
+
return typeof input === "function";
|
|
143
|
+
}
|
|
144
|
+
function isObject(input) {
|
|
145
|
+
return typeof input === "object" && input !== null && !Array.isArray(input);
|
|
146
|
+
}
|
|
147
|
+
function isObjectKeyword(input) {
|
|
148
|
+
return typeof input === "object" && input !== null || isFunction(input);
|
|
149
|
+
}
|
|
150
|
+
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObjectKeyword(self) && property in self);
|
|
268
151
|
|
|
269
|
-
// ../../node_modules/.pnpm/effect@
|
|
270
|
-
var
|
|
271
|
-
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
152
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Hash.js
|
|
153
|
+
var symbol = "~effect/interfaces/Hash";
|
|
272
154
|
var hash = (self) => {
|
|
273
|
-
if (structuralRegionState.enabled === true) {
|
|
274
|
-
return 0;
|
|
275
|
-
}
|
|
276
155
|
switch (typeof self) {
|
|
277
156
|
case "number":
|
|
278
157
|
return number(self);
|
|
@@ -291,16 +170,32 @@ var hash = (self) => {
|
|
|
291
170
|
if (self === null) {
|
|
292
171
|
return string("null");
|
|
293
172
|
} else if (self instanceof Date) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return hash(self.toISOString());
|
|
298
|
-
} else if (self instanceof URL) {
|
|
299
|
-
return hash(self.href);
|
|
300
|
-
} else if (isHash(self)) {
|
|
301
|
-
return self[symbol]();
|
|
173
|
+
return string(self.toISOString());
|
|
174
|
+
} else if (self instanceof RegExp) {
|
|
175
|
+
return string(self.toString());
|
|
302
176
|
} else {
|
|
303
|
-
|
|
177
|
+
if (byReferenceInstances.has(self)) {
|
|
178
|
+
return random(self);
|
|
179
|
+
}
|
|
180
|
+
if (hashCache.has(self)) {
|
|
181
|
+
return hashCache.get(self);
|
|
182
|
+
}
|
|
183
|
+
const h = withVisitedTracking(self, () => {
|
|
184
|
+
if (isHash(self)) {
|
|
185
|
+
return self[symbol]();
|
|
186
|
+
} else if (typeof self === "function") {
|
|
187
|
+
return random(self);
|
|
188
|
+
} else if (Array.isArray(self)) {
|
|
189
|
+
return array(self);
|
|
190
|
+
} else if (self instanceof Map) {
|
|
191
|
+
return hashMap(self);
|
|
192
|
+
} else if (self instanceof Set) {
|
|
193
|
+
return hashSet(self);
|
|
194
|
+
}
|
|
195
|
+
return structure(self);
|
|
196
|
+
});
|
|
197
|
+
hashCache.set(self, h);
|
|
198
|
+
return h;
|
|
304
199
|
}
|
|
305
200
|
}
|
|
306
201
|
default:
|
|
@@ -313,12 +208,18 @@ var random = (self) => {
|
|
|
313
208
|
}
|
|
314
209
|
return randomHashCache.get(self);
|
|
315
210
|
};
|
|
316
|
-
var combine =
|
|
211
|
+
var combine = /* @__PURE__ */ dual(2, (self, b) => self * 53 ^ b);
|
|
317
212
|
var optimize = (n) => n & 3221225471 | n >>> 1 & 1073741824;
|
|
318
213
|
var isHash = (u) => hasProperty(u, symbol);
|
|
319
214
|
var number = (n) => {
|
|
320
|
-
if (n !== n
|
|
321
|
-
return
|
|
215
|
+
if (n !== n) {
|
|
216
|
+
return string("NaN");
|
|
217
|
+
}
|
|
218
|
+
if (n === Infinity) {
|
|
219
|
+
return string("Infinity");
|
|
220
|
+
}
|
|
221
|
+
if (n === -Infinity) {
|
|
222
|
+
return string("-Infinity");
|
|
322
223
|
}
|
|
323
224
|
let h = n | 0;
|
|
324
225
|
if (h !== n) {
|
|
@@ -338,38 +239,37 @@ var string = (str) => {
|
|
|
338
239
|
};
|
|
339
240
|
var structureKeys = (o, keys2) => {
|
|
340
241
|
let h = 12289;
|
|
341
|
-
for (
|
|
342
|
-
h ^=
|
|
242
|
+
for (const key of keys2) {
|
|
243
|
+
h ^= combine(hash(key), hash(o[key]));
|
|
343
244
|
}
|
|
344
245
|
return optimize(h);
|
|
345
246
|
};
|
|
346
|
-
var structure = (o) => structureKeys(o,
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
Object.defineProperty(self2, symbol, {
|
|
352
|
-
value() {
|
|
353
|
-
return hash3;
|
|
354
|
-
},
|
|
355
|
-
enumerable: false
|
|
356
|
-
});
|
|
357
|
-
return hash3;
|
|
358
|
-
};
|
|
247
|
+
var structure = (o) => structureKeys(o, getAllObjectKeys(o));
|
|
248
|
+
var iterableWith = (seed, f) => (iter) => {
|
|
249
|
+
let h = seed;
|
|
250
|
+
for (const element of iter) {
|
|
251
|
+
h ^= f(element);
|
|
359
252
|
}
|
|
360
|
-
|
|
361
|
-
const hash2 = arguments[1];
|
|
362
|
-
Object.defineProperty(self, symbol, {
|
|
363
|
-
value() {
|
|
364
|
-
return hash2;
|
|
365
|
-
},
|
|
366
|
-
enumerable: false
|
|
367
|
-
});
|
|
368
|
-
return hash2;
|
|
253
|
+
return optimize(h);
|
|
369
254
|
};
|
|
255
|
+
var array = /* @__PURE__ */ iterableWith(6151, hash);
|
|
256
|
+
var hashMap = /* @__PURE__ */ iterableWith(/* @__PURE__ */ string("Map"), ([k, v]) => combine(hash(k), hash(v)));
|
|
257
|
+
var hashSet = /* @__PURE__ */ iterableWith(/* @__PURE__ */ string("Set"), hash);
|
|
258
|
+
var randomHashCache = /* @__PURE__ */ new WeakMap();
|
|
259
|
+
var hashCache = /* @__PURE__ */ new WeakMap();
|
|
260
|
+
var visitedObjects = /* @__PURE__ */ new WeakSet();
|
|
261
|
+
function withVisitedTracking(obj, fn2) {
|
|
262
|
+
if (visitedObjects.has(obj)) {
|
|
263
|
+
return string("[Circular]");
|
|
264
|
+
}
|
|
265
|
+
visitedObjects.add(obj);
|
|
266
|
+
const result = fn2();
|
|
267
|
+
visitedObjects.delete(obj);
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
370
270
|
|
|
371
|
-
// ../../node_modules/.pnpm/effect@
|
|
372
|
-
var symbol2 =
|
|
271
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Equal.js
|
|
272
|
+
var symbol2 = "~effect/interfaces/Equal";
|
|
373
273
|
function equals() {
|
|
374
274
|
if (arguments.length === 1) {
|
|
375
275
|
return (self) => compareBoth(self, arguments[0]);
|
|
@@ -377,71 +277,274 @@ function equals() {
|
|
|
377
277
|
return compareBoth(arguments[0], arguments[1]);
|
|
378
278
|
}
|
|
379
279
|
function compareBoth(self, that) {
|
|
380
|
-
if (self === that)
|
|
381
|
-
|
|
382
|
-
}
|
|
280
|
+
if (self === that) return true;
|
|
281
|
+
if (self == null || that == null) return false;
|
|
383
282
|
const selfType = typeof self;
|
|
384
283
|
if (selfType !== typeof that) {
|
|
385
284
|
return false;
|
|
386
285
|
}
|
|
387
|
-
if (selfType === "
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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
|
-
|
|
286
|
+
if (selfType === "number" && self !== self && that !== that) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
if (selfType !== "object" && selfType !== "function") {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
if (byReferenceInstances.has(self) || byReferenceInstances.has(that)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
return withCache(self, that, compareObjects);
|
|
296
|
+
}
|
|
297
|
+
function withVisitedTracking2(self, that, fn2) {
|
|
298
|
+
const hasLeft = visitedLeft.has(self);
|
|
299
|
+
const hasRight = visitedRight.has(that);
|
|
300
|
+
if (hasLeft && hasRight) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
if (hasLeft || hasRight) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
visitedLeft.add(self);
|
|
307
|
+
visitedRight.add(that);
|
|
308
|
+
const result = fn2();
|
|
309
|
+
visitedLeft.delete(self);
|
|
310
|
+
visitedRight.delete(that);
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
var visitedLeft = /* @__PURE__ */ new WeakSet();
|
|
314
|
+
var visitedRight = /* @__PURE__ */ new WeakSet();
|
|
315
|
+
function compareObjects(self, that) {
|
|
316
|
+
if (hash(self) !== hash(that)) {
|
|
317
|
+
return false;
|
|
318
|
+
} else if (self instanceof Date) {
|
|
319
|
+
if (!(that instanceof Date)) return false;
|
|
320
|
+
return self.toISOString() === that.toISOString();
|
|
321
|
+
} else if (self instanceof RegExp) {
|
|
322
|
+
if (!(that instanceof RegExp)) return false;
|
|
323
|
+
return self.toString() === that.toString();
|
|
324
|
+
}
|
|
325
|
+
const selfIsEqual = isEqual(self);
|
|
326
|
+
const thatIsEqual = isEqual(that);
|
|
327
|
+
if (selfIsEqual !== thatIsEqual) return false;
|
|
328
|
+
const bothEquals = selfIsEqual && thatIsEqual;
|
|
329
|
+
if (typeof self === "function" && !bothEquals) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
return withVisitedTracking2(self, that, () => {
|
|
333
|
+
if (bothEquals) {
|
|
334
|
+
return self[symbol2](that);
|
|
335
|
+
} else if (Array.isArray(self)) {
|
|
336
|
+
if (!Array.isArray(that) || self.length !== that.length) {
|
|
337
|
+
return false;
|
|
418
338
|
}
|
|
419
|
-
return
|
|
339
|
+
return compareArrays(self, that);
|
|
340
|
+
} else if (self instanceof Map) {
|
|
341
|
+
if (!(that instanceof Map) || self.size !== that.size) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
return compareMaps(self, that);
|
|
345
|
+
} else if (self instanceof Set) {
|
|
346
|
+
if (!(that instanceof Set) || self.size !== that.size) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
return compareSets(self, that);
|
|
350
|
+
}
|
|
351
|
+
return compareRecords(self, that);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function withCache(self, that, f) {
|
|
355
|
+
let selfMap = equalityCache.get(self);
|
|
356
|
+
if (!selfMap) {
|
|
357
|
+
selfMap = /* @__PURE__ */ new WeakMap();
|
|
358
|
+
equalityCache.set(self, selfMap);
|
|
359
|
+
} else if (selfMap.has(that)) {
|
|
360
|
+
return selfMap.get(that);
|
|
361
|
+
}
|
|
362
|
+
const result = f(self, that);
|
|
363
|
+
selfMap.set(that, result);
|
|
364
|
+
let thatMap = equalityCache.get(that);
|
|
365
|
+
if (!thatMap) {
|
|
366
|
+
thatMap = /* @__PURE__ */ new WeakMap();
|
|
367
|
+
equalityCache.set(that, thatMap);
|
|
368
|
+
}
|
|
369
|
+
thatMap.set(self, result);
|
|
370
|
+
return result;
|
|
371
|
+
}
|
|
372
|
+
var equalityCache = /* @__PURE__ */ new WeakMap();
|
|
373
|
+
function compareArrays(self, that) {
|
|
374
|
+
for (let i = 0; i < self.length; i++) {
|
|
375
|
+
if (!compareBoth(self[i], that[i])) {
|
|
376
|
+
return false;
|
|
420
377
|
}
|
|
421
378
|
}
|
|
422
|
-
return
|
|
379
|
+
return true;
|
|
423
380
|
}
|
|
381
|
+
function compareRecords(self, that) {
|
|
382
|
+
const selfKeys = getAllObjectKeys(self);
|
|
383
|
+
const thatKeys = getAllObjectKeys(that);
|
|
384
|
+
if (selfKeys.size !== thatKeys.size) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
for (const key of selfKeys) {
|
|
388
|
+
if (!thatKeys.has(key) || !compareBoth(self[key], that[key])) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
function makeCompareMap(keyEquivalence, valueEquivalence) {
|
|
395
|
+
return function compareMaps2(self, that) {
|
|
396
|
+
for (const [selfKey, selfValue] of self) {
|
|
397
|
+
let found = false;
|
|
398
|
+
for (const [thatKey, thatValue] of that) {
|
|
399
|
+
if (keyEquivalence(selfKey, thatKey) && valueEquivalence(selfValue, thatValue)) {
|
|
400
|
+
found = true;
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!found) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
var compareMaps = /* @__PURE__ */ makeCompareMap(compareBoth, compareBoth);
|
|
412
|
+
function makeCompareSet(equivalence) {
|
|
413
|
+
return function compareSets2(self, that) {
|
|
414
|
+
for (const selfValue of self) {
|
|
415
|
+
let found = false;
|
|
416
|
+
for (const thatValue of that) {
|
|
417
|
+
if (equivalence(selfValue, thatValue)) {
|
|
418
|
+
found = true;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (!found) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth);
|
|
424
430
|
var isEqual = (u) => hasProperty(u, symbol2);
|
|
425
|
-
var
|
|
431
|
+
var asEquivalence = () => equals;
|
|
432
|
+
|
|
433
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Redactable.js
|
|
434
|
+
var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Inspectable/redactable");
|
|
435
|
+
var isRedactable = (u) => hasProperty(u, symbolRedactable);
|
|
436
|
+
function redact(u) {
|
|
437
|
+
if (isRedactable(u)) return getRedacted(u);
|
|
438
|
+
return u;
|
|
439
|
+
}
|
|
440
|
+
function getRedacted(redactable) {
|
|
441
|
+
return redactable[symbolRedactable](globalThis[currentFiberTypeId]?.services ?? emptyServiceMap);
|
|
442
|
+
}
|
|
443
|
+
var currentFiberTypeId = "~effect/Fiber/currentFiber";
|
|
444
|
+
var emptyServiceMap = {
|
|
445
|
+
"~effect/ServiceMap": {},
|
|
446
|
+
mapUnsafe: /* @__PURE__ */ new Map(),
|
|
447
|
+
pipe() {
|
|
448
|
+
return pipeArguments(this, arguments);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
426
451
|
|
|
427
|
-
// ../../node_modules/.pnpm/effect@
|
|
452
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Formatter.js
|
|
453
|
+
function format(input, options) {
|
|
454
|
+
const space = options?.space ?? 0;
|
|
455
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
456
|
+
const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
|
|
457
|
+
const ind = (d) => gap.repeat(d);
|
|
458
|
+
const wrap = (v, body) => {
|
|
459
|
+
const ctor = v?.constructor;
|
|
460
|
+
return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
|
|
461
|
+
};
|
|
462
|
+
const ownKeys = (o) => {
|
|
463
|
+
try {
|
|
464
|
+
return Reflect.ownKeys(o);
|
|
465
|
+
} catch {
|
|
466
|
+
return ["[ownKeys threw]"];
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
function recur(v, d = 0) {
|
|
470
|
+
if (Array.isArray(v)) {
|
|
471
|
+
if (seen.has(v)) return CIRCULAR;
|
|
472
|
+
seen.add(v);
|
|
473
|
+
if (!gap || v.length <= 1) return `[${v.map((x) => recur(x, d)).join(",")}]`;
|
|
474
|
+
const inner = v.map((x) => recur(x, d + 1)).join(",\n" + ind(d + 1));
|
|
475
|
+
return `[
|
|
476
|
+
${ind(d + 1)}${inner}
|
|
477
|
+
${ind(d)}]`;
|
|
478
|
+
}
|
|
479
|
+
if (v instanceof Date) return formatDate(v);
|
|
480
|
+
if (!options?.ignoreToString && hasProperty(v, "toString") && typeof v["toString"] === "function" && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
|
|
481
|
+
const s = safeToString(v);
|
|
482
|
+
if (v instanceof Error && v.cause) {
|
|
483
|
+
return `${s} (cause: ${recur(v.cause, d)})`;
|
|
484
|
+
}
|
|
485
|
+
return s;
|
|
486
|
+
}
|
|
487
|
+
if (typeof v === "string") return JSON.stringify(v);
|
|
488
|
+
if (typeof v === "number" || v == null || typeof v === "boolean" || typeof v === "symbol") return String(v);
|
|
489
|
+
if (typeof v === "bigint") return String(v) + "n";
|
|
490
|
+
if (typeof v === "object" || typeof v === "function") {
|
|
491
|
+
if (seen.has(v)) return CIRCULAR;
|
|
492
|
+
seen.add(v);
|
|
493
|
+
if (symbolRedactable in v) return format(getRedacted(v));
|
|
494
|
+
if (Symbol.iterator in v) {
|
|
495
|
+
return `${v.constructor.name}(${recur(Array.from(v), d)})`;
|
|
496
|
+
}
|
|
497
|
+
const keys2 = ownKeys(v);
|
|
498
|
+
if (!gap || keys2.length <= 1) {
|
|
499
|
+
const body2 = `{${keys2.map((k) => `${formatPropertyKey(k)}:${recur(v[k], d)}`).join(",")}}`;
|
|
500
|
+
return wrap(v, body2);
|
|
501
|
+
}
|
|
502
|
+
const body = `{
|
|
503
|
+
${keys2.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${recur(v[k], d + 1)}`).join(",\n")}
|
|
504
|
+
${ind(d)}}`;
|
|
505
|
+
return wrap(v, body);
|
|
506
|
+
}
|
|
507
|
+
return String(v);
|
|
508
|
+
}
|
|
509
|
+
return recur(input, 0);
|
|
510
|
+
}
|
|
511
|
+
var CIRCULAR = "[Circular]";
|
|
512
|
+
function formatPropertyKey(name) {
|
|
513
|
+
return typeof name === "string" ? JSON.stringify(name) : String(name);
|
|
514
|
+
}
|
|
515
|
+
function formatDate(date) {
|
|
516
|
+
try {
|
|
517
|
+
return date.toISOString();
|
|
518
|
+
} catch {
|
|
519
|
+
return "Invalid Date";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function safeToString(input) {
|
|
523
|
+
try {
|
|
524
|
+
const s = input.toString();
|
|
525
|
+
return typeof s === "string" ? s : String(s);
|
|
526
|
+
} catch {
|
|
527
|
+
return "[toString threw]";
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Inspectable.js
|
|
428
532
|
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
429
|
-
var
|
|
533
|
+
var toJson = (input) => {
|
|
430
534
|
try {
|
|
431
|
-
if (hasProperty(
|
|
432
|
-
return
|
|
433
|
-
} else if (Array.isArray(
|
|
434
|
-
return
|
|
535
|
+
if (hasProperty(input, "toJSON") && isFunction(input["toJSON"]) && input["toJSON"].length === 0) {
|
|
536
|
+
return input.toJSON();
|
|
537
|
+
} else if (Array.isArray(input)) {
|
|
538
|
+
return input.map(toJson);
|
|
435
539
|
}
|
|
436
540
|
} catch {
|
|
437
|
-
return
|
|
541
|
+
return "[toJSON threw]";
|
|
438
542
|
}
|
|
439
|
-
return redact(
|
|
543
|
+
return redact(input);
|
|
440
544
|
};
|
|
441
|
-
var format = (x) => JSON.stringify(x, null, 2);
|
|
442
545
|
var BaseProto = {
|
|
443
546
|
toJSON() {
|
|
444
|
-
return
|
|
547
|
+
return toJson(this);
|
|
445
548
|
},
|
|
446
549
|
[NodeInspectSymbol]() {
|
|
447
550
|
return this.toJSON();
|
|
@@ -451,171 +554,447 @@ var BaseProto = {
|
|
|
451
554
|
}
|
|
452
555
|
};
|
|
453
556
|
var Class = class {
|
|
557
|
+
/**
|
|
558
|
+
* Node.js custom inspection method.
|
|
559
|
+
*
|
|
560
|
+
* @since 2.0.0
|
|
561
|
+
*/
|
|
562
|
+
[NodeInspectSymbol]() {
|
|
563
|
+
return this.toJSON();
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Returns a formatted string representation of this object.
|
|
567
|
+
*
|
|
568
|
+
* @since 2.0.0
|
|
569
|
+
*/
|
|
570
|
+
toString() {
|
|
571
|
+
return format(this.toJSON());
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Utils.js
|
|
576
|
+
var GenKindTypeId = "~effect/Utils/GenKind";
|
|
577
|
+
var GenKindImpl = class {
|
|
578
|
+
value;
|
|
579
|
+
constructor(value) {
|
|
580
|
+
this.value = value;
|
|
581
|
+
}
|
|
582
|
+
get _F() {
|
|
583
|
+
return identity;
|
|
584
|
+
}
|
|
585
|
+
get _R() {
|
|
586
|
+
return (_) => _;
|
|
587
|
+
}
|
|
588
|
+
get _O() {
|
|
589
|
+
return (_) => _;
|
|
590
|
+
}
|
|
591
|
+
get _E() {
|
|
592
|
+
return (_) => _;
|
|
593
|
+
}
|
|
594
|
+
[GenKindTypeId] = GenKindTypeId;
|
|
595
|
+
[Symbol.iterator]() {
|
|
596
|
+
return new SingleShotGen(this);
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
var SingleShotGen = class _SingleShotGen {
|
|
600
|
+
called = false;
|
|
601
|
+
self;
|
|
602
|
+
constructor(self) {
|
|
603
|
+
this.self = self;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* @since 2.0.0
|
|
607
|
+
*/
|
|
608
|
+
next(a) {
|
|
609
|
+
return this.called ? {
|
|
610
|
+
value: a,
|
|
611
|
+
done: true
|
|
612
|
+
} : (this.called = true, {
|
|
613
|
+
value: this.self,
|
|
614
|
+
done: false
|
|
615
|
+
});
|
|
616
|
+
}
|
|
454
617
|
/**
|
|
455
618
|
* @since 2.0.0
|
|
456
619
|
*/
|
|
620
|
+
[Symbol.iterator]() {
|
|
621
|
+
return new _SingleShotGen(this.self);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
var InternalTypeId = "~effect/Effect/internal";
|
|
625
|
+
var standard = {
|
|
626
|
+
[InternalTypeId]: (body) => {
|
|
627
|
+
return body();
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var forced = {
|
|
631
|
+
[InternalTypeId]: (body) => {
|
|
632
|
+
try {
|
|
633
|
+
return body();
|
|
634
|
+
} finally {
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var isNotOptimizedAway = /* @__PURE__ */ standard[InternalTypeId](() => new Error().stack)?.includes(InternalTypeId) === true;
|
|
639
|
+
var internalCall = isNotOptimizedAway ? standard[InternalTypeId] : forced[InternalTypeId];
|
|
640
|
+
var genConstructor = function* () {
|
|
641
|
+
}.constructor;
|
|
642
|
+
|
|
643
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/core.js
|
|
644
|
+
var EffectTypeId = `~effect/Effect`;
|
|
645
|
+
var ExitTypeId = `~effect/Exit`;
|
|
646
|
+
var effectVariance = {
|
|
647
|
+
_A: identity,
|
|
648
|
+
_E: identity,
|
|
649
|
+
_R: identity
|
|
650
|
+
};
|
|
651
|
+
var identifier = `${EffectTypeId}/identifier`;
|
|
652
|
+
var args = `${EffectTypeId}/args`;
|
|
653
|
+
var evaluate = `${EffectTypeId}/evaluate`;
|
|
654
|
+
var contA = `${EffectTypeId}/successCont`;
|
|
655
|
+
var contE = `${EffectTypeId}/failureCont`;
|
|
656
|
+
var contAll = `${EffectTypeId}/ensureCont`;
|
|
657
|
+
var PipeInspectableProto = {
|
|
658
|
+
pipe() {
|
|
659
|
+
return pipeArguments(this, arguments);
|
|
660
|
+
},
|
|
661
|
+
toJSON() {
|
|
662
|
+
return {
|
|
663
|
+
...this
|
|
664
|
+
};
|
|
665
|
+
},
|
|
666
|
+
toString() {
|
|
667
|
+
return format(this.toJSON(), {
|
|
668
|
+
ignoreToString: true,
|
|
669
|
+
space: 2
|
|
670
|
+
});
|
|
671
|
+
},
|
|
672
|
+
[NodeInspectSymbol]() {
|
|
673
|
+
return this.toJSON();
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
var StructuralProto = {
|
|
677
|
+
[symbol]() {
|
|
678
|
+
return structureKeys(this, Object.keys(this));
|
|
679
|
+
},
|
|
680
|
+
[symbol2](that) {
|
|
681
|
+
const selfKeys = Object.keys(this);
|
|
682
|
+
const thatKeys = Object.keys(that);
|
|
683
|
+
if (selfKeys.length !== thatKeys.length) return false;
|
|
684
|
+
for (let i = 0; i < selfKeys.length; i++) {
|
|
685
|
+
if (selfKeys[i] !== thatKeys[i] && !equals(this[selfKeys[i]], that[selfKeys[i]])) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return true;
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
var YieldableProto = {
|
|
693
|
+
[Symbol.iterator]() {
|
|
694
|
+
return new SingleShotGen(this);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
var YieldableErrorProto = {
|
|
698
|
+
...YieldableProto,
|
|
699
|
+
pipe() {
|
|
700
|
+
return pipeArguments(this, arguments);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var EffectProto = {
|
|
704
|
+
[EffectTypeId]: effectVariance,
|
|
705
|
+
...PipeInspectableProto,
|
|
706
|
+
[Symbol.iterator]() {
|
|
707
|
+
return new SingleShotGen(this);
|
|
708
|
+
},
|
|
709
|
+
asEffect() {
|
|
710
|
+
return this;
|
|
711
|
+
},
|
|
712
|
+
toJSON() {
|
|
713
|
+
return {
|
|
714
|
+
_id: "Effect",
|
|
715
|
+
op: this[identifier],
|
|
716
|
+
...args in this ? {
|
|
717
|
+
args: this[args]
|
|
718
|
+
} : void 0
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var isExit = (u) => hasProperty(u, ExitTypeId);
|
|
723
|
+
var CauseTypeId = "~effect/Cause";
|
|
724
|
+
var CauseReasonTypeId = "~effect/Cause/Reason";
|
|
725
|
+
var isCause = (self) => hasProperty(self, CauseTypeId);
|
|
726
|
+
var CauseImpl = class {
|
|
727
|
+
[CauseTypeId];
|
|
728
|
+
reasons;
|
|
729
|
+
constructor(failures) {
|
|
730
|
+
this[CauseTypeId] = CauseTypeId;
|
|
731
|
+
this.reasons = failures;
|
|
732
|
+
}
|
|
733
|
+
pipe() {
|
|
734
|
+
return pipeArguments(this, arguments);
|
|
735
|
+
}
|
|
736
|
+
toJSON() {
|
|
737
|
+
return {
|
|
738
|
+
_id: "Cause",
|
|
739
|
+
failures: this.reasons.map((f) => f.toJSON())
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
toString() {
|
|
743
|
+
return `Cause(${format(this.reasons)})`;
|
|
744
|
+
}
|
|
745
|
+
[NodeInspectSymbol]() {
|
|
746
|
+
return this.toJSON();
|
|
747
|
+
}
|
|
748
|
+
[symbol2](that) {
|
|
749
|
+
return isCause(that) && this.reasons.length === that.reasons.length && this.reasons.every((e, i) => equals(e, that.reasons[i]));
|
|
750
|
+
}
|
|
751
|
+
[symbol]() {
|
|
752
|
+
return array(this.reasons);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
var annotationsMap = /* @__PURE__ */ new WeakMap();
|
|
756
|
+
var ReasonBase = class {
|
|
757
|
+
[CauseReasonTypeId];
|
|
758
|
+
annotations;
|
|
759
|
+
_tag;
|
|
760
|
+
constructor(_tag, annotations, originalError) {
|
|
761
|
+
this[CauseReasonTypeId] = CauseReasonTypeId;
|
|
762
|
+
this._tag = _tag;
|
|
763
|
+
if (annotations !== constEmptyAnnotations && typeof originalError === "object" && originalError !== null && annotations.size > 0) {
|
|
764
|
+
const prevAnnotations = annotationsMap.get(originalError);
|
|
765
|
+
if (prevAnnotations) {
|
|
766
|
+
annotations = new Map([...prevAnnotations, ...annotations]);
|
|
767
|
+
}
|
|
768
|
+
annotationsMap.set(originalError, annotations);
|
|
769
|
+
}
|
|
770
|
+
this.annotations = annotations;
|
|
771
|
+
}
|
|
772
|
+
annotate(annotations, options) {
|
|
773
|
+
if (annotations.mapUnsafe.size === 0) return this;
|
|
774
|
+
const newAnnotations = new Map(this.annotations);
|
|
775
|
+
annotations.mapUnsafe.forEach((value, key) => {
|
|
776
|
+
if (options?.overwrite !== true && newAnnotations.has(key)) return;
|
|
777
|
+
newAnnotations.set(key, value);
|
|
778
|
+
});
|
|
779
|
+
const self = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
780
|
+
self.annotations = newAnnotations;
|
|
781
|
+
return self;
|
|
782
|
+
}
|
|
783
|
+
pipe() {
|
|
784
|
+
return pipeArguments(this, arguments);
|
|
785
|
+
}
|
|
786
|
+
toString() {
|
|
787
|
+
return format(this);
|
|
788
|
+
}
|
|
457
789
|
[NodeInspectSymbol]() {
|
|
458
|
-
return this.
|
|
790
|
+
return this.toString();
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
var constEmptyAnnotations = /* @__PURE__ */ new Map();
|
|
794
|
+
var Fail = class extends ReasonBase {
|
|
795
|
+
error;
|
|
796
|
+
constructor(error, annotations = constEmptyAnnotations) {
|
|
797
|
+
super("Fail", annotations, error);
|
|
798
|
+
this.error = error;
|
|
459
799
|
}
|
|
460
|
-
/**
|
|
461
|
-
* @since 2.0.0
|
|
462
|
-
*/
|
|
463
800
|
toString() {
|
|
464
|
-
return format(this.
|
|
801
|
+
return `Fail(${format(this.error)})`;
|
|
465
802
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}));
|
|
472
|
-
var redact = (u) => {
|
|
473
|
-
if (isRedactable(u) && redactableState.fiberRefs !== void 0) {
|
|
474
|
-
return u[symbolRedactable](redactableState.fiberRefs);
|
|
803
|
+
toJSON() {
|
|
804
|
+
return {
|
|
805
|
+
_tag: "Fail",
|
|
806
|
+
error: this.error
|
|
807
|
+
};
|
|
475
808
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
switch (args2.length) {
|
|
482
|
-
case 0:
|
|
483
|
-
return self;
|
|
484
|
-
case 1:
|
|
485
|
-
return args2[0](self);
|
|
486
|
-
case 2:
|
|
487
|
-
return args2[1](args2[0](self));
|
|
488
|
-
case 3:
|
|
489
|
-
return args2[2](args2[1](args2[0](self)));
|
|
490
|
-
case 4:
|
|
491
|
-
return args2[3](args2[2](args2[1](args2[0](self))));
|
|
492
|
-
case 5:
|
|
493
|
-
return args2[4](args2[3](args2[2](args2[1](args2[0](self)))));
|
|
494
|
-
case 6:
|
|
495
|
-
return args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))));
|
|
496
|
-
case 7:
|
|
497
|
-
return args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))));
|
|
498
|
-
case 8:
|
|
499
|
-
return args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))))));
|
|
500
|
-
case 9:
|
|
501
|
-
return args2[8](args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))))));
|
|
502
|
-
default: {
|
|
503
|
-
let ret = self;
|
|
504
|
-
for (let i = 0, len = args2.length; i < len; i++) {
|
|
505
|
-
ret = args2[i](ret);
|
|
506
|
-
}
|
|
507
|
-
return ret;
|
|
508
|
-
}
|
|
809
|
+
[symbol2](that) {
|
|
810
|
+
return isFailReason(that) && equals(this.error, that.error) && equals(this.annotations, that.annotations);
|
|
811
|
+
}
|
|
812
|
+
[symbol]() {
|
|
813
|
+
return combine(string(this._tag))(combine(hash(this.error))(hash(this.annotations)));
|
|
509
814
|
}
|
|
510
815
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
816
|
+
var causeFail = (error) => new CauseImpl([new Fail(error)]);
|
|
817
|
+
var Die = class extends ReasonBase {
|
|
818
|
+
defect;
|
|
819
|
+
constructor(defect, annotations = constEmptyAnnotations) {
|
|
820
|
+
super("Die", annotations, defect);
|
|
821
|
+
this.defect = defect;
|
|
822
|
+
}
|
|
823
|
+
toString() {
|
|
824
|
+
return `Die(${format(this.defect)})`;
|
|
825
|
+
}
|
|
826
|
+
toJSON() {
|
|
827
|
+
return {
|
|
828
|
+
_tag: "Die",
|
|
829
|
+
defect: this.defect
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
[symbol2](that) {
|
|
833
|
+
return isDieReason(that) && equals(this.defect, that.defect) && equals(this.annotations, that.annotations);
|
|
834
|
+
}
|
|
835
|
+
[symbol]() {
|
|
836
|
+
return combine(string(this._tag))(combine(hash(this.defect))(hash(this.annotations)));
|
|
837
|
+
}
|
|
532
838
|
};
|
|
533
|
-
var
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
839
|
+
var causeDie = (defect) => new CauseImpl([new Die(defect)]);
|
|
840
|
+
var causeAnnotate = /* @__PURE__ */ dual((args3) => isCause(args3[0]), (self, annotations, options) => {
|
|
841
|
+
if (annotations.mapUnsafe.size === 0) return self;
|
|
842
|
+
return new CauseImpl(self.reasons.map((f) => f.annotate(annotations, options)));
|
|
843
|
+
});
|
|
844
|
+
var isFailReason = (self) => self._tag === "Fail";
|
|
845
|
+
var isDieReason = (self) => self._tag === "Die";
|
|
846
|
+
function defaultEvaluate(_fiber) {
|
|
847
|
+
return exitDie(`Effect.evaluate: Not implemented`);
|
|
848
|
+
}
|
|
849
|
+
var makePrimitiveProto = (options) => ({
|
|
850
|
+
...EffectProto,
|
|
851
|
+
[identifier]: options.op,
|
|
852
|
+
[evaluate]: options[evaluate] ?? defaultEvaluate,
|
|
853
|
+
[contA]: options[contA],
|
|
854
|
+
[contE]: options[contE],
|
|
855
|
+
[contAll]: options[contAll]
|
|
856
|
+
});
|
|
857
|
+
var makePrimitive = (options) => {
|
|
858
|
+
const Proto = makePrimitiveProto(options);
|
|
859
|
+
return function() {
|
|
860
|
+
const self = Object.create(Proto);
|
|
861
|
+
self[args] = options.single === false ? arguments : arguments[0];
|
|
862
|
+
return self;
|
|
863
|
+
};
|
|
544
864
|
};
|
|
545
|
-
var
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
865
|
+
var makeExit = (options) => {
|
|
866
|
+
const Proto = {
|
|
867
|
+
...makePrimitiveProto(options),
|
|
868
|
+
[ExitTypeId]: ExitTypeId,
|
|
869
|
+
_tag: options.op,
|
|
870
|
+
get [options.prop]() {
|
|
871
|
+
return this[args];
|
|
872
|
+
},
|
|
873
|
+
toString() {
|
|
874
|
+
return `${options.op}(${format(this[args])})`;
|
|
875
|
+
},
|
|
876
|
+
toJSON() {
|
|
877
|
+
return {
|
|
878
|
+
_id: "Exit",
|
|
879
|
+
_tag: options.op,
|
|
880
|
+
[options.prop]: this[args]
|
|
881
|
+
};
|
|
882
|
+
},
|
|
883
|
+
[symbol2](that) {
|
|
884
|
+
return isExit(that) && that._tag === this._tag && equals(this[args], that[args]);
|
|
885
|
+
},
|
|
886
|
+
[symbol]() {
|
|
887
|
+
return combine(string(options.op), hash(this[args]));
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
return function(value) {
|
|
891
|
+
const self = Object.create(Proto);
|
|
892
|
+
self[args] = value;
|
|
893
|
+
return self;
|
|
894
|
+
};
|
|
560
895
|
};
|
|
561
|
-
var
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
[
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
return this === that;
|
|
568
|
-
},
|
|
569
|
-
[symbol]() {
|
|
570
|
-
return cached(this, random(this));
|
|
571
|
-
},
|
|
572
|
-
[Symbol.iterator]() {
|
|
573
|
-
return new SingleShotGen(new YieldWrap(this));
|
|
574
|
-
},
|
|
575
|
-
pipe() {
|
|
576
|
-
return pipeArguments(this, arguments);
|
|
896
|
+
var exitSucceed = /* @__PURE__ */ makeExit({
|
|
897
|
+
op: "Success",
|
|
898
|
+
prop: "value",
|
|
899
|
+
[evaluate](fiber) {
|
|
900
|
+
const cont = fiber.getCont(contA);
|
|
901
|
+
return cont ? cont[contA](this[args], fiber, this) : fiber.yieldWith(this);
|
|
577
902
|
}
|
|
903
|
+
});
|
|
904
|
+
var StackTraceKey = {
|
|
905
|
+
key: "effect/Cause/StackTrace"
|
|
578
906
|
};
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
907
|
+
var exitFailCause = /* @__PURE__ */ makeExit({
|
|
908
|
+
op: "Failure",
|
|
909
|
+
prop: "cause",
|
|
910
|
+
[evaluate](fiber) {
|
|
911
|
+
let cause = this[args];
|
|
912
|
+
let annotated = false;
|
|
913
|
+
if (fiber.currentStackFrame) {
|
|
914
|
+
cause = causeAnnotate(cause, {
|
|
915
|
+
mapUnsafe: /* @__PURE__ */ new Map([[StackTraceKey.key, fiber.currentStackFrame]])
|
|
916
|
+
});
|
|
917
|
+
annotated = true;
|
|
588
918
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
919
|
+
let cont = fiber.getCont(contE);
|
|
920
|
+
while (fiber.interruptible && fiber._interruptedCause && cont) {
|
|
921
|
+
cont = fiber.getCont(contE);
|
|
593
922
|
}
|
|
594
|
-
return
|
|
923
|
+
return cont ? cont[contE](cause, fiber, annotated ? void 0 : this) : fiber.yieldWith(annotated ? this : exitFailCause(cause));
|
|
595
924
|
}
|
|
925
|
+
});
|
|
926
|
+
var exitFail = (e) => exitFailCause(causeFail(e));
|
|
927
|
+
var exitDie = (defect) => exitFailCause(causeDie(defect));
|
|
928
|
+
var withFiber = /* @__PURE__ */ makePrimitive({
|
|
929
|
+
op: "WithFiber",
|
|
930
|
+
[evaluate](fiber) {
|
|
931
|
+
return this[args](fiber);
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
var YieldableError = /* @__PURE__ */ (function() {
|
|
935
|
+
class YieldableError2 extends globalThis.Error {
|
|
936
|
+
asEffect() {
|
|
937
|
+
return exitFail(this);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
Object.assign(YieldableError2.prototype, YieldableErrorProto);
|
|
941
|
+
return YieldableError2;
|
|
942
|
+
})();
|
|
943
|
+
var Error2 = /* @__PURE__ */ (function() {
|
|
944
|
+
const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
|
|
945
|
+
return class Base extends YieldableError {
|
|
946
|
+
constructor(args3) {
|
|
947
|
+
super(args3?.message, args3?.cause ? {
|
|
948
|
+
cause: args3.cause
|
|
949
|
+
} : void 0);
|
|
950
|
+
if (args3) {
|
|
951
|
+
Object.assign(this, args3);
|
|
952
|
+
Object.defineProperty(this, plainArgsSymbol, {
|
|
953
|
+
value: args3,
|
|
954
|
+
enumerable: false
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
toJSON() {
|
|
959
|
+
return {
|
|
960
|
+
...this[plainArgsSymbol],
|
|
961
|
+
...this
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
})();
|
|
966
|
+
var TaggedError = (tag) => {
|
|
967
|
+
class Base extends Error2 {
|
|
968
|
+
_tag = tag;
|
|
969
|
+
}
|
|
970
|
+
;
|
|
971
|
+
Base.prototype.name = tag;
|
|
972
|
+
return Base;
|
|
596
973
|
};
|
|
597
|
-
var
|
|
598
|
-
|
|
599
|
-
|
|
974
|
+
var NoSuchElementErrorTypeId = "~effect/Cause/NoSuchElementError";
|
|
975
|
+
var NoSuchElementError = class extends (/* @__PURE__ */ TaggedError("NoSuchElementError")) {
|
|
976
|
+
[NoSuchElementErrorTypeId] = NoSuchElementErrorTypeId;
|
|
977
|
+
constructor(message) {
|
|
978
|
+
super({
|
|
979
|
+
message
|
|
980
|
+
});
|
|
981
|
+
}
|
|
600
982
|
};
|
|
601
|
-
var
|
|
602
|
-
|
|
603
|
-
|
|
983
|
+
var DoneTypeId = "~effect/Cause/Done";
|
|
984
|
+
var DoneVoid = {
|
|
985
|
+
[DoneTypeId]: DoneTypeId,
|
|
986
|
+
_tag: "Done",
|
|
987
|
+
value: void 0
|
|
604
988
|
};
|
|
605
989
|
|
|
606
|
-
// ../../node_modules/.pnpm/effect@
|
|
607
|
-
var TypeId =
|
|
990
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/option.js
|
|
991
|
+
var TypeId = "~effect/data/Option";
|
|
608
992
|
var CommonProto = {
|
|
609
|
-
...EffectPrototype,
|
|
610
993
|
[TypeId]: {
|
|
611
994
|
_A: (_) => _
|
|
612
995
|
},
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
},
|
|
616
|
-
toString() {
|
|
617
|
-
return format(this.toJSON());
|
|
618
|
-
}
|
|
996
|
+
...PipeInspectableProto,
|
|
997
|
+
...YieldableProto
|
|
619
998
|
};
|
|
620
999
|
var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
|
|
621
1000
|
_tag: "Some",
|
|
@@ -624,14 +1003,20 @@ var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
|
|
|
624
1003
|
return isOption(that) && isSome(that) && equals(this.value, that.value);
|
|
625
1004
|
},
|
|
626
1005
|
[symbol]() {
|
|
627
|
-
return
|
|
1006
|
+
return combine(hash(this._tag))(hash(this.value));
|
|
1007
|
+
},
|
|
1008
|
+
toString() {
|
|
1009
|
+
return `some(${format(this.value)})`;
|
|
628
1010
|
},
|
|
629
1011
|
toJSON() {
|
|
630
1012
|
return {
|
|
631
1013
|
_id: "Option",
|
|
632
1014
|
_tag: this._tag,
|
|
633
|
-
value:
|
|
1015
|
+
value: toJson(this.value)
|
|
634
1016
|
};
|
|
1017
|
+
},
|
|
1018
|
+
asEffect() {
|
|
1019
|
+
return exitSucceed(this.value);
|
|
635
1020
|
}
|
|
636
1021
|
});
|
|
637
1022
|
var NoneHash = /* @__PURE__ */ hash("None");
|
|
@@ -644,11 +1029,17 @@ var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Comm
|
|
|
644
1029
|
[symbol]() {
|
|
645
1030
|
return NoneHash;
|
|
646
1031
|
},
|
|
1032
|
+
toString() {
|
|
1033
|
+
return `none()`;
|
|
1034
|
+
},
|
|
647
1035
|
toJSON() {
|
|
648
1036
|
return {
|
|
649
1037
|
_id: "Option",
|
|
650
1038
|
_tag: this._tag
|
|
651
1039
|
};
|
|
1040
|
+
},
|
|
1041
|
+
asEffect() {
|
|
1042
|
+
return exitFail(new NoSuchElementError());
|
|
652
1043
|
}
|
|
653
1044
|
});
|
|
654
1045
|
var isOption = (input) => hasProperty(input, TypeId);
|
|
@@ -661,94 +1052,113 @@ var some = (value) => {
|
|
|
661
1052
|
return a;
|
|
662
1053
|
};
|
|
663
1054
|
|
|
664
|
-
// ../../node_modules/.pnpm/effect@
|
|
665
|
-
var TypeId2 =
|
|
1055
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/result.js
|
|
1056
|
+
var TypeId2 = "~effect/data/Result";
|
|
666
1057
|
var CommonProto2 = {
|
|
667
|
-
...EffectPrototype,
|
|
668
1058
|
[TypeId2]: {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
return this.toJSON();
|
|
1059
|
+
/* v8 ignore next 2 */
|
|
1060
|
+
_A: (_) => _,
|
|
1061
|
+
_E: (_) => _
|
|
673
1062
|
},
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
1063
|
+
...PipeInspectableProto,
|
|
1064
|
+
...YieldableProto
|
|
677
1065
|
};
|
|
678
|
-
var
|
|
679
|
-
_tag: "
|
|
680
|
-
_op: "
|
|
1066
|
+
var SuccessProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
1067
|
+
_tag: "Success",
|
|
1068
|
+
_op: "Success",
|
|
681
1069
|
[symbol2](that) {
|
|
682
|
-
return
|
|
1070
|
+
return isResult(that) && isSuccess(that) && equals(this.success, that.success);
|
|
683
1071
|
},
|
|
684
1072
|
[symbol]() {
|
|
685
|
-
return combine(hash(this._tag))(hash(this.
|
|
1073
|
+
return combine(hash(this._tag))(hash(this.success));
|
|
1074
|
+
},
|
|
1075
|
+
toString() {
|
|
1076
|
+
return `success(${format(this.success)})`;
|
|
686
1077
|
},
|
|
687
1078
|
toJSON() {
|
|
688
1079
|
return {
|
|
689
|
-
_id: "
|
|
1080
|
+
_id: "Result",
|
|
690
1081
|
_tag: this._tag,
|
|
691
|
-
|
|
1082
|
+
value: toJson(this.success)
|
|
692
1083
|
};
|
|
1084
|
+
},
|
|
1085
|
+
asEffect() {
|
|
1086
|
+
return exitSucceed(this.success);
|
|
693
1087
|
}
|
|
694
1088
|
});
|
|
695
|
-
var
|
|
696
|
-
_tag: "
|
|
697
|
-
_op: "
|
|
1089
|
+
var FailureProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
1090
|
+
_tag: "Failure",
|
|
1091
|
+
_op: "Failure",
|
|
698
1092
|
[symbol2](that) {
|
|
699
|
-
return
|
|
1093
|
+
return isResult(that) && isFailure(that) && equals(this.failure, that.failure);
|
|
700
1094
|
},
|
|
701
1095
|
[symbol]() {
|
|
702
|
-
return combine(hash(this._tag))(hash(this.
|
|
1096
|
+
return combine(hash(this._tag))(hash(this.failure));
|
|
1097
|
+
},
|
|
1098
|
+
toString() {
|
|
1099
|
+
return `failure(${format(this.failure)})`;
|
|
703
1100
|
},
|
|
704
1101
|
toJSON() {
|
|
705
1102
|
return {
|
|
706
|
-
_id: "
|
|
1103
|
+
_id: "Result",
|
|
707
1104
|
_tag: this._tag,
|
|
708
|
-
|
|
1105
|
+
failure: toJson(this.failure)
|
|
709
1106
|
};
|
|
1107
|
+
},
|
|
1108
|
+
asEffect() {
|
|
1109
|
+
return exitFail(this.failure);
|
|
710
1110
|
}
|
|
711
1111
|
});
|
|
712
|
-
var
|
|
713
|
-
var
|
|
714
|
-
var
|
|
715
|
-
var
|
|
716
|
-
const a = Object.create(
|
|
717
|
-
a.
|
|
1112
|
+
var isResult = (input) => hasProperty(input, TypeId2);
|
|
1113
|
+
var isFailure = (result) => result._tag === "Failure";
|
|
1114
|
+
var isSuccess = (result) => result._tag === "Success";
|
|
1115
|
+
var fail = (failure) => {
|
|
1116
|
+
const a = Object.create(FailureProto);
|
|
1117
|
+
a.failure = failure;
|
|
718
1118
|
return a;
|
|
719
1119
|
};
|
|
720
|
-
var
|
|
721
|
-
const a = Object.create(
|
|
722
|
-
a.
|
|
1120
|
+
var succeed = (success) => {
|
|
1121
|
+
const a = Object.create(SuccessProto);
|
|
1122
|
+
a.success = success;
|
|
723
1123
|
return a;
|
|
724
1124
|
};
|
|
725
1125
|
|
|
726
|
-
// ../../node_modules/.pnpm/effect@
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
var
|
|
731
|
-
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
732
|
-
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
733
|
-
|
|
734
|
-
// ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/array.js
|
|
735
|
-
var isNonEmptyArray = (self) => self.length > 0;
|
|
736
|
-
|
|
737
|
-
// ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/Order.js
|
|
738
|
-
var make = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
739
|
-
var string2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
|
|
1126
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Order.js
|
|
1127
|
+
function make(compare) {
|
|
1128
|
+
return (self, that) => self === that ? 0 : compare(self, that);
|
|
1129
|
+
}
|
|
1130
|
+
var String2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
|
|
740
1131
|
|
|
741
|
-
// ../../node_modules/.pnpm/effect@
|
|
1132
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Option.js
|
|
742
1133
|
var none2 = () => none;
|
|
743
1134
|
var some2 = some;
|
|
744
1135
|
var isNone2 = isNone;
|
|
745
1136
|
var isSome2 = isSome;
|
|
746
|
-
var
|
|
1137
|
+
var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
|
|
747
1138
|
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
|
|
748
|
-
var
|
|
749
|
-
var getOrUndefined = /* @__PURE__ */
|
|
1139
|
+
var fromNullishOr = (a) => a == null ? none2() : some2(a);
|
|
1140
|
+
var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
|
|
1141
|
+
|
|
1142
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Result.js
|
|
1143
|
+
var succeed2 = succeed;
|
|
1144
|
+
var fail2 = fail;
|
|
1145
|
+
var isFailure2 = isFailure;
|
|
1146
|
+
var isSuccess2 = isSuccess;
|
|
1147
|
+
var map = /* @__PURE__ */ dual(2, (self, f) => isSuccess2(self) ? succeed2(f(self.success)) : fail2(self.failure));
|
|
1148
|
+
var getOrElse2 = /* @__PURE__ */ dual(2, (self, onFailure) => isFailure2(self) ? onFailure(self.failure) : self.success);
|
|
1149
|
+
|
|
1150
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Filter.js
|
|
1151
|
+
var apply = (filter2, input, ...args3) => {
|
|
1152
|
+
const result = filter2(input, ...args3);
|
|
1153
|
+
if (result === true) return succeed2(input);
|
|
1154
|
+
if (result === false) return fail2(input);
|
|
1155
|
+
return result;
|
|
1156
|
+
};
|
|
750
1157
|
|
|
751
|
-
// ../../node_modules/.pnpm/effect@
|
|
1158
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/array.js
|
|
1159
|
+
var isArrayNonEmpty = (self) => self.length > 0;
|
|
1160
|
+
|
|
1161
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Record.js
|
|
752
1162
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
753
1163
|
const out = {
|
|
754
1164
|
...self
|
|
@@ -760,31 +1170,34 @@ var map2 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
760
1170
|
});
|
|
761
1171
|
var keys = (self) => Object.keys(self);
|
|
762
1172
|
|
|
763
|
-
// ../../node_modules/.pnpm/effect@
|
|
764
|
-
var
|
|
1173
|
+
// ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Array.js
|
|
1174
|
+
var Array2 = globalThis.Array;
|
|
1175
|
+
var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection);
|
|
765
1176
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
766
1177
|
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
767
|
-
var isArray =
|
|
768
|
-
var
|
|
769
|
-
var
|
|
770
|
-
var
|
|
771
|
-
|
|
1178
|
+
var isArray = Array2.isArray;
|
|
1179
|
+
var isArrayEmpty = (self) => self.length === 0;
|
|
1180
|
+
var isReadonlyArrayEmpty = isArrayEmpty;
|
|
1181
|
+
var isReadonlyArrayNonEmpty = isArrayNonEmpty;
|
|
1182
|
+
function isOutOfBounds(i, as) {
|
|
1183
|
+
return i < 0 || i >= as.length;
|
|
1184
|
+
}
|
|
772
1185
|
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
773
1186
|
const i = Math.floor(index);
|
|
774
1187
|
return isOutOfBounds(i, self) ? none2() : some2(self[i]);
|
|
775
1188
|
});
|
|
776
|
-
var
|
|
1189
|
+
var getUnsafe = /* @__PURE__ */ dual(2, (self, index) => {
|
|
777
1190
|
const i = Math.floor(index);
|
|
778
1191
|
if (isOutOfBounds(i, self)) {
|
|
779
|
-
throw new Error(`Index
|
|
1192
|
+
throw new Error(`Index out of bounds: ${i}`);
|
|
780
1193
|
}
|
|
781
1194
|
return self[i];
|
|
782
1195
|
});
|
|
783
1196
|
var head = /* @__PURE__ */ get(0);
|
|
784
|
-
var headNonEmpty = /* @__PURE__ */
|
|
1197
|
+
var headNonEmpty = /* @__PURE__ */ getUnsafe(0);
|
|
785
1198
|
var tailNonEmpty = (self) => self.slice(1);
|
|
786
1199
|
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
787
|
-
const out =
|
|
1200
|
+
const out = Array2.from(self);
|
|
788
1201
|
out.sort(O);
|
|
789
1202
|
return out;
|
|
790
1203
|
});
|
|
@@ -796,19 +1209,18 @@ var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
|
796
1209
|
}
|
|
797
1210
|
return false;
|
|
798
1211
|
});
|
|
799
|
-
var _equivalence = /* @__PURE__ */ equivalence();
|
|
800
1212
|
var intersectionWith = (isEquivalent) => {
|
|
801
1213
|
const has = containsWith(isEquivalent);
|
|
802
1214
|
return dual(2, (self, that) => {
|
|
803
|
-
const
|
|
804
|
-
return fromIterable(self).filter((a) => has(
|
|
1215
|
+
const thatArray = fromIterable(that);
|
|
1216
|
+
return fromIterable(self).filter((a) => has(thatArray, a));
|
|
805
1217
|
});
|
|
806
1218
|
};
|
|
807
|
-
var intersection = /* @__PURE__ */ intersectionWith(
|
|
1219
|
+
var intersection = /* @__PURE__ */ intersectionWith(/* @__PURE__ */ asEquivalence());
|
|
808
1220
|
var empty = () => [];
|
|
809
1221
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
810
1222
|
var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
811
|
-
if (
|
|
1223
|
+
if (isReadonlyArrayEmpty(self)) {
|
|
812
1224
|
return [];
|
|
813
1225
|
}
|
|
814
1226
|
const out = [];
|
|
@@ -821,19 +1233,20 @@ var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
821
1233
|
return out;
|
|
822
1234
|
});
|
|
823
1235
|
var flatten = /* @__PURE__ */ flatMap(identity);
|
|
824
|
-
var filter = /* @__PURE__ */ dual(2, (self,
|
|
1236
|
+
var filter = /* @__PURE__ */ dual(2, (self, f) => {
|
|
825
1237
|
const as = fromIterable(self);
|
|
826
1238
|
const out = [];
|
|
827
1239
|
for (let i = 0; i < as.length; i++) {
|
|
828
|
-
|
|
829
|
-
|
|
1240
|
+
const result = apply(f, as[i], i);
|
|
1241
|
+
if (!isFailure2(result)) {
|
|
1242
|
+
out.push(result.success);
|
|
830
1243
|
}
|
|
831
1244
|
}
|
|
832
1245
|
return out;
|
|
833
1246
|
});
|
|
834
1247
|
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
835
1248
|
const input = fromIterable(self);
|
|
836
|
-
if (
|
|
1249
|
+
if (isReadonlyArrayNonEmpty(input)) {
|
|
837
1250
|
const out = [headNonEmpty(input)];
|
|
838
1251
|
const rest = tailNonEmpty(input);
|
|
839
1252
|
for (const r of rest) {
|
|
@@ -845,16 +1258,17 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
|
845
1258
|
}
|
|
846
1259
|
return [];
|
|
847
1260
|
});
|
|
848
|
-
var dedupe = (self) => dedupeWith(self,
|
|
1261
|
+
var dedupe = (self) => dedupeWith(self, asEquivalence());
|
|
849
1262
|
var join = /* @__PURE__ */ dual(2, (self, sep) => fromIterable(self).join(sep));
|
|
850
1263
|
|
|
851
1264
|
// src/core/Nano.ts
|
|
1265
|
+
var debugPerformance = false;
|
|
852
1266
|
var NanoTag = class {
|
|
853
1267
|
constructor(key) {
|
|
854
1268
|
this.key = key;
|
|
855
1269
|
}
|
|
856
1270
|
};
|
|
857
|
-
var Tag = (
|
|
1271
|
+
var Tag = (identifier2) => new NanoTag(identifier2);
|
|
858
1272
|
var SingleShotGen2 = class _SingleShotGen {
|
|
859
1273
|
called = false;
|
|
860
1274
|
self;
|
|
@@ -880,12 +1294,12 @@ var SingleShotGen2 = class _SingleShotGen {
|
|
|
880
1294
|
return new _SingleShotGen(this.self);
|
|
881
1295
|
}
|
|
882
1296
|
};
|
|
883
|
-
var
|
|
884
|
-
var
|
|
885
|
-
var
|
|
886
|
-
var
|
|
1297
|
+
var evaluate2 = /* @__PURE__ */ Symbol.for("Nano.evaluate");
|
|
1298
|
+
var contA2 = /* @__PURE__ */ Symbol.for("Nano.contA");
|
|
1299
|
+
var contE2 = /* @__PURE__ */ Symbol.for("Nano.contE");
|
|
1300
|
+
var contAll2 = /* @__PURE__ */ Symbol.for("Nano.contAll");
|
|
887
1301
|
var NanoYield = /* @__PURE__ */ Symbol.for("Nano.yield");
|
|
888
|
-
var
|
|
1302
|
+
var args2 = /* @__PURE__ */ Symbol.for("Nano.args");
|
|
889
1303
|
var NanoDefectException = class {
|
|
890
1304
|
constructor(message, lastSpan) {
|
|
891
1305
|
this.message = message;
|
|
@@ -902,43 +1316,43 @@ var SucceedProto = {
|
|
|
902
1316
|
...PrimitiveProto,
|
|
903
1317
|
_tag: "Success",
|
|
904
1318
|
get value() {
|
|
905
|
-
return this[
|
|
1319
|
+
return this[args2];
|
|
906
1320
|
},
|
|
907
|
-
[
|
|
908
|
-
const cont = fiber.getCont(
|
|
909
|
-
return cont ? cont[
|
|
1321
|
+
[evaluate2](fiber) {
|
|
1322
|
+
const cont = fiber.getCont(contA2);
|
|
1323
|
+
return cont ? cont[contA2](this[args2], fiber) : fiber.yieldWith(this);
|
|
910
1324
|
}
|
|
911
1325
|
};
|
|
912
|
-
var
|
|
1326
|
+
var succeed3 = (value) => {
|
|
913
1327
|
const nano = Object.create(SucceedProto);
|
|
914
|
-
nano[
|
|
1328
|
+
nano[args2] = value;
|
|
915
1329
|
return nano;
|
|
916
1330
|
};
|
|
917
|
-
var
|
|
1331
|
+
var FailureProto2 = {
|
|
918
1332
|
...PrimitiveProto,
|
|
919
1333
|
_tag: "Failure",
|
|
920
1334
|
get value() {
|
|
921
|
-
return this[
|
|
1335
|
+
return this[args2];
|
|
922
1336
|
},
|
|
923
|
-
[
|
|
924
|
-
const cont = fiber.getCont(
|
|
925
|
-
return cont ? cont[
|
|
1337
|
+
[evaluate2](fiber) {
|
|
1338
|
+
const cont = fiber.getCont(contE2);
|
|
1339
|
+
return cont ? cont[contE2](this[args2], fiber) : fiber.yieldWith(this);
|
|
926
1340
|
}
|
|
927
1341
|
};
|
|
928
|
-
var
|
|
929
|
-
const nano = Object.create(
|
|
930
|
-
nano[
|
|
1342
|
+
var fail3 = (error) => {
|
|
1343
|
+
const nano = Object.create(FailureProto2);
|
|
1344
|
+
nano[args2] = error;
|
|
931
1345
|
return nano;
|
|
932
1346
|
};
|
|
933
1347
|
var SuspendProto = {
|
|
934
1348
|
...PrimitiveProto,
|
|
935
|
-
[
|
|
936
|
-
return this[
|
|
1349
|
+
[evaluate2]() {
|
|
1350
|
+
return this[args2]();
|
|
937
1351
|
}
|
|
938
1352
|
};
|
|
939
1353
|
var suspend = (fn2) => {
|
|
940
1354
|
const nano = Object.create(SuspendProto);
|
|
941
|
-
nano[
|
|
1355
|
+
nano[args2] = fn2;
|
|
942
1356
|
return nano;
|
|
943
1357
|
};
|
|
944
1358
|
var NanoFiber = class {
|
|
@@ -946,12 +1360,11 @@ var NanoFiber = class {
|
|
|
946
1360
|
_yielded = void 0;
|
|
947
1361
|
_services = {};
|
|
948
1362
|
_cache = {};
|
|
949
|
-
_perf = false;
|
|
950
1363
|
_lastSpan = "";
|
|
951
1364
|
runLoop(nano) {
|
|
952
1365
|
let current = nano;
|
|
953
1366
|
while (true) {
|
|
954
|
-
current = current[
|
|
1367
|
+
current = current[evaluate2](this);
|
|
955
1368
|
if (current === NanoYield) {
|
|
956
1369
|
return this._yielded;
|
|
957
1370
|
}
|
|
@@ -961,7 +1374,7 @@ var NanoFiber = class {
|
|
|
961
1374
|
while (true) {
|
|
962
1375
|
const op = this._stack.pop();
|
|
963
1376
|
if (!op) return void 0;
|
|
964
|
-
const cont = op[
|
|
1377
|
+
const cont = op[contAll2] && op[contAll2](this);
|
|
965
1378
|
if (cont) return { [symbol3]: cont };
|
|
966
1379
|
if (op[symbol3]) return op;
|
|
967
1380
|
}
|
|
@@ -975,9 +1388,9 @@ var timings = {};
|
|
|
975
1388
|
var timingsCount = {};
|
|
976
1389
|
var WithSpanProto = {
|
|
977
1390
|
...PrimitiveProto,
|
|
978
|
-
[
|
|
979
|
-
const [fa, name] = this[
|
|
980
|
-
if (!
|
|
1391
|
+
[evaluate2](fiber) {
|
|
1392
|
+
const [fa, name] = this[args2];
|
|
1393
|
+
if (!debugPerformance) return fa;
|
|
981
1394
|
const previousSpan = fiber._lastSpan;
|
|
982
1395
|
fiber._lastSpan = name;
|
|
983
1396
|
const start = performance.now();
|
|
@@ -987,20 +1400,20 @@ var WithSpanProto = {
|
|
|
987
1400
|
const end = performance.now();
|
|
988
1401
|
timings[name] = (timings[name] || 0) + (end - start);
|
|
989
1402
|
fiber._lastSpan = previousSpan;
|
|
990
|
-
return
|
|
1403
|
+
return succeed3(_);
|
|
991
1404
|
},
|
|
992
1405
|
onFailure: (_) => {
|
|
993
1406
|
const end = performance.now();
|
|
994
1407
|
timings[name] = (timings[name] || 0) + (end - start);
|
|
995
1408
|
fiber._lastSpan = previousSpan;
|
|
996
|
-
return
|
|
1409
|
+
return fail3(_);
|
|
997
1410
|
}
|
|
998
1411
|
});
|
|
999
1412
|
}
|
|
1000
1413
|
};
|
|
1001
1414
|
var withSpan = (name) => (fa) => {
|
|
1002
1415
|
const nano = Object.create(WithSpanProto);
|
|
1003
|
-
nano[
|
|
1416
|
+
nano[args2] = [fa, name];
|
|
1004
1417
|
return nano;
|
|
1005
1418
|
};
|
|
1006
1419
|
var run = (nano) => {
|
|
@@ -1008,86 +1421,86 @@ var run = (nano) => {
|
|
|
1008
1421
|
try {
|
|
1009
1422
|
const result = fiber.runLoop(nano);
|
|
1010
1423
|
if (result._tag === "Success") {
|
|
1011
|
-
return
|
|
1424
|
+
return succeed2(result.value);
|
|
1012
1425
|
}
|
|
1013
|
-
return
|
|
1426
|
+
return fail2(result.value);
|
|
1014
1427
|
} catch (e) {
|
|
1015
|
-
return
|
|
1428
|
+
return fail2(new NanoDefectException(e, fiber._lastSpan));
|
|
1016
1429
|
}
|
|
1017
1430
|
};
|
|
1018
1431
|
var OnSuccessProto = {
|
|
1019
1432
|
...PrimitiveProto,
|
|
1020
|
-
[
|
|
1433
|
+
[evaluate2](fiber) {
|
|
1021
1434
|
fiber._stack.push(this);
|
|
1022
|
-
return this[
|
|
1435
|
+
return this[args2];
|
|
1023
1436
|
}
|
|
1024
1437
|
};
|
|
1025
1438
|
var flatMap2 = dual(2, (fa, f) => {
|
|
1026
1439
|
const nano = Object.create(OnSuccessProto);
|
|
1027
|
-
nano[
|
|
1028
|
-
nano[
|
|
1440
|
+
nano[args2] = fa;
|
|
1441
|
+
nano[contA2] = f;
|
|
1029
1442
|
return nano;
|
|
1030
1443
|
});
|
|
1031
|
-
var map4 = dual(2, (fa, f) => flatMap2(fa, (_) =>
|
|
1444
|
+
var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed3(f(_))));
|
|
1032
1445
|
var SyncProto = {
|
|
1033
1446
|
...PrimitiveProto,
|
|
1034
|
-
[
|
|
1035
|
-
const value = this[
|
|
1036
|
-
const cont = fiber.getCont(
|
|
1037
|
-
return cont ? cont[
|
|
1447
|
+
[evaluate2](fiber) {
|
|
1448
|
+
const value = this[args2]();
|
|
1449
|
+
const cont = fiber.getCont(contA2);
|
|
1450
|
+
return cont ? cont[contA2](value, fiber) : fiber.yieldWith(succeed3(value));
|
|
1038
1451
|
}
|
|
1039
1452
|
};
|
|
1040
1453
|
var sync = (f) => {
|
|
1041
1454
|
const nano = Object.create(SyncProto);
|
|
1042
|
-
nano[
|
|
1455
|
+
nano[args2] = f;
|
|
1043
1456
|
return nano;
|
|
1044
1457
|
};
|
|
1045
|
-
var void_ =
|
|
1458
|
+
var void_ = succeed3(void 0);
|
|
1046
1459
|
var FromIteratorProto = {
|
|
1047
1460
|
...PrimitiveProto,
|
|
1048
|
-
[
|
|
1049
|
-
const state = this[
|
|
1050
|
-
if (state.done) return
|
|
1461
|
+
[contA2](value, fiber) {
|
|
1462
|
+
const state = this[args2][0].next(value);
|
|
1463
|
+
if (state.done) return succeed3(state.value);
|
|
1051
1464
|
fiber._stack.push(this);
|
|
1052
1465
|
return state.value;
|
|
1053
1466
|
},
|
|
1054
|
-
[
|
|
1055
|
-
return this[
|
|
1467
|
+
[evaluate2](fiber) {
|
|
1468
|
+
return this[contA2](this[args2][1], fiber);
|
|
1056
1469
|
}
|
|
1057
1470
|
};
|
|
1058
1471
|
var unsafeFromIterator = (iterator, initial) => {
|
|
1059
1472
|
const nano = Object.create(FromIteratorProto);
|
|
1060
|
-
nano[
|
|
1473
|
+
nano[args2] = [iterator, initial];
|
|
1061
1474
|
return nano;
|
|
1062
1475
|
};
|
|
1063
|
-
var gen = (...
|
|
1064
|
-
var fn = (_) => (body) => (...
|
|
1476
|
+
var gen = (...args3) => suspend(() => unsafeFromIterator(args3[0]()));
|
|
1477
|
+
var fn = (_) => (body) => (...args3) => withSpan(_)(suspend(() => unsafeFromIterator(body(...args3))));
|
|
1065
1478
|
var MatchProto = {
|
|
1066
1479
|
...PrimitiveProto,
|
|
1067
|
-
[
|
|
1480
|
+
[evaluate2](fiber) {
|
|
1068
1481
|
fiber._stack.push(this);
|
|
1069
|
-
return this[
|
|
1482
|
+
return this[args2];
|
|
1070
1483
|
}
|
|
1071
1484
|
};
|
|
1072
1485
|
var match = (fa, opts) => {
|
|
1073
1486
|
const nano = Object.create(MatchProto);
|
|
1074
|
-
nano[
|
|
1075
|
-
nano[
|
|
1076
|
-
nano[
|
|
1487
|
+
nano[args2] = fa;
|
|
1488
|
+
nano[contA2] = opts.onSuccess;
|
|
1489
|
+
nano[contE2] = opts.onFailure;
|
|
1077
1490
|
return nano;
|
|
1078
1491
|
};
|
|
1079
1492
|
var orElse2 = (f) => (fa) => {
|
|
1080
1493
|
const nano = Object.create(MatchProto);
|
|
1081
|
-
nano[
|
|
1082
|
-
nano[
|
|
1494
|
+
nano[args2] = fa;
|
|
1495
|
+
nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : f(_);
|
|
1083
1496
|
return nano;
|
|
1084
1497
|
};
|
|
1085
1498
|
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
|
|
1086
1499
|
var ProvideServiceProto = {
|
|
1087
1500
|
...PrimitiveProto,
|
|
1088
|
-
[
|
|
1501
|
+
[evaluate2](fiber) {
|
|
1089
1502
|
const prevServices = fiber._services;
|
|
1090
|
-
const [fa, tag, value] = this[
|
|
1503
|
+
const [fa, tag, value] = this[args2];
|
|
1091
1504
|
fiber._services = {
|
|
1092
1505
|
...fiber._services,
|
|
1093
1506
|
[tag.key]: value
|
|
@@ -1095,54 +1508,54 @@ var ProvideServiceProto = {
|
|
|
1095
1508
|
return match(fa, {
|
|
1096
1509
|
onSuccess: (_) => {
|
|
1097
1510
|
fiber._services = prevServices;
|
|
1098
|
-
return
|
|
1511
|
+
return succeed3(_);
|
|
1099
1512
|
},
|
|
1100
1513
|
onFailure: (_) => {
|
|
1101
1514
|
fiber._services = prevServices;
|
|
1102
|
-
return
|
|
1515
|
+
return fail3(_);
|
|
1103
1516
|
}
|
|
1104
1517
|
});
|
|
1105
1518
|
}
|
|
1106
1519
|
};
|
|
1107
1520
|
var provideService = (tag, value) => (fa) => {
|
|
1108
1521
|
const nano = Object.create(ProvideServiceProto);
|
|
1109
|
-
nano[
|
|
1522
|
+
nano[args2] = [fa, tag, value];
|
|
1110
1523
|
return nano;
|
|
1111
1524
|
};
|
|
1112
1525
|
var ServiceProto = {
|
|
1113
1526
|
...PrimitiveProto,
|
|
1114
|
-
[
|
|
1115
|
-
const tag = this[
|
|
1527
|
+
[evaluate2](fiber) {
|
|
1528
|
+
const tag = this[args2];
|
|
1116
1529
|
if (tag.key in fiber._services) {
|
|
1117
1530
|
const value = fiber._services[tag.key];
|
|
1118
|
-
const cont2 = fiber.getCont(
|
|
1119
|
-
return cont2 ? cont2[
|
|
1531
|
+
const cont2 = fiber.getCont(contA2);
|
|
1532
|
+
return cont2 ? cont2[contA2](value, fiber) : fiber.yieldWith(succeed3(value));
|
|
1120
1533
|
}
|
|
1121
|
-
const cont = fiber.getCont(
|
|
1122
|
-
return cont ? cont[
|
|
1534
|
+
const cont = fiber.getCont(contE2);
|
|
1535
|
+
return cont ? cont[contE2](tag, fiber) : fiber.yieldWith(fail3(new NanoDefectException(`Service ${tag.key} not found`, fiber._lastSpan)));
|
|
1123
1536
|
}
|
|
1124
1537
|
};
|
|
1125
1538
|
var service = (tag) => {
|
|
1126
1539
|
const nano = Object.create(ServiceProto);
|
|
1127
|
-
nano[
|
|
1540
|
+
nano[args2] = tag;
|
|
1128
1541
|
return nano;
|
|
1129
1542
|
};
|
|
1130
1543
|
var CachedProto = {
|
|
1131
1544
|
...PrimitiveProto,
|
|
1132
|
-
[
|
|
1133
|
-
const [fa, type, key] = this[
|
|
1545
|
+
[evaluate2](fiber) {
|
|
1546
|
+
const [fa, type, key] = this[args2];
|
|
1134
1547
|
const cache = fiber._cache[type] || /* @__PURE__ */ new WeakMap();
|
|
1135
1548
|
fiber._cache[type] = cache;
|
|
1136
|
-
const
|
|
1137
|
-
if (
|
|
1549
|
+
const cached = cache.get(key);
|
|
1550
|
+
if (cached) return cached;
|
|
1138
1551
|
return match(fa, {
|
|
1139
1552
|
onSuccess: (_) => {
|
|
1140
|
-
cache.set(key,
|
|
1141
|
-
return
|
|
1553
|
+
cache.set(key, succeed3(_));
|
|
1554
|
+
return succeed3(_);
|
|
1142
1555
|
},
|
|
1143
1556
|
onFailure: (_) => {
|
|
1144
|
-
cache.set(key,
|
|
1145
|
-
return
|
|
1557
|
+
cache.set(key, fail3(_));
|
|
1558
|
+
return fail3(_);
|
|
1146
1559
|
}
|
|
1147
1560
|
});
|
|
1148
1561
|
}
|
|
@@ -1150,35 +1563,35 @@ var CachedProto = {
|
|
|
1150
1563
|
function cachedBy(fa, type, lookupKey) {
|
|
1151
1564
|
return (...p) => {
|
|
1152
1565
|
const nano = Object.create(CachedProto);
|
|
1153
|
-
nano[
|
|
1566
|
+
nano[args2] = [fa(...p), type, lookupKey(...p)];
|
|
1154
1567
|
return nano;
|
|
1155
1568
|
};
|
|
1156
1569
|
}
|
|
1157
1570
|
var option = (fa) => {
|
|
1158
1571
|
const nano = Object.create(MatchProto);
|
|
1159
|
-
nano[
|
|
1160
|
-
nano[
|
|
1161
|
-
nano[
|
|
1572
|
+
nano[args2] = fa;
|
|
1573
|
+
nano[contA2] = (_) => succeed3(some2(_));
|
|
1574
|
+
nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : succeed3(none2());
|
|
1162
1575
|
return nano;
|
|
1163
1576
|
};
|
|
1164
1577
|
var orUndefined = (fa) => {
|
|
1165
1578
|
const nano = Object.create(MatchProto);
|
|
1166
|
-
nano[
|
|
1167
|
-
nano[
|
|
1168
|
-
nano[
|
|
1579
|
+
nano[args2] = fa;
|
|
1580
|
+
nano[contA2] = (_) => succeed3(_);
|
|
1581
|
+
nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : succeed3(void 0);
|
|
1169
1582
|
return nano;
|
|
1170
1583
|
};
|
|
1171
1584
|
var ignore = (fa) => {
|
|
1172
1585
|
const nano = Object.create(MatchProto);
|
|
1173
|
-
nano[
|
|
1174
|
-
nano[
|
|
1175
|
-
nano[
|
|
1586
|
+
nano[args2] = fa;
|
|
1587
|
+
nano[contA2] = (_) => void_;
|
|
1588
|
+
nano[contE2] = (_) => _ instanceof NanoDefectException ? fail3(_) : void_;
|
|
1176
1589
|
return nano;
|
|
1177
1590
|
};
|
|
1178
1591
|
var all = fn("all")(
|
|
1179
|
-
function* (...
|
|
1592
|
+
function* (...args3) {
|
|
1180
1593
|
const results = [];
|
|
1181
|
-
for (const fa of
|
|
1594
|
+
for (const fa of args3) {
|
|
1182
1595
|
const result = yield* fa;
|
|
1183
1596
|
results.push(result);
|
|
1184
1597
|
}
|
|
@@ -1192,7 +1605,7 @@ function isValidSeverityLevel(value) {
|
|
|
1192
1605
|
return value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion";
|
|
1193
1606
|
}
|
|
1194
1607
|
function parseDiagnosticSeverity(config) {
|
|
1195
|
-
if (!
|
|
1608
|
+
if (!isObject(config)) return {};
|
|
1196
1609
|
return Object.fromEntries(
|
|
1197
1610
|
pipe(
|
|
1198
1611
|
Object.entries(config),
|
|
@@ -1255,7 +1668,7 @@ function parse(config) {
|
|
|
1255
1668
|
return {
|
|
1256
1669
|
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1257
1670
|
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1258
|
-
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") &&
|
|
1671
|
+
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isObject(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1259
1672
|
diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
|
|
1260
1673
|
missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
|
|
1261
1674
|
includeSuggestionsInTsc: isObject(config) && hasProperty(config, "includeSuggestionsInTsc") && isBoolean(config.includeSuggestionsInTsc) ? config.includeSuggestionsInTsc : defaults.includeSuggestionsInTsc,
|
|
@@ -1270,7 +1683,7 @@ function parse(config) {
|
|
|
1270
1683
|
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1271
1684
|
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1272
1685
|
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") &&
|
|
1686
|
+
importAliases: isObject(config) && hasProperty(config, "importAliases") && isObject(config.importAliases) ? map2(config.importAliases, (value) => String(value)) : defaults.importAliases,
|
|
1274
1687
|
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
|
|
1275
1688
|
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1276
1689
|
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
|
|
@@ -1289,9 +1702,9 @@ var TypeScriptProgram = Tag("TypeScriptProgram");
|
|
|
1289
1702
|
var ChangeTracker = Tag("ChangeTracker");
|
|
1290
1703
|
function getPackageJsonInfoCache(program) {
|
|
1291
1704
|
try {
|
|
1292
|
-
if (hasProperty(program, "getModuleResolutionCache") &&
|
|
1705
|
+
if (hasProperty(program, "getModuleResolutionCache") && isFunction(program.getModuleResolutionCache)) {
|
|
1293
1706
|
const moduleResolutionCache = program.getModuleResolutionCache();
|
|
1294
|
-
if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") &&
|
|
1707
|
+
if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") && isFunction(moduleResolutionCache.getPackageJsonInfoCache)) {
|
|
1295
1708
|
return moduleResolutionCache.getPackageJsonInfoCache();
|
|
1296
1709
|
}
|
|
1297
1710
|
}
|
|
@@ -1302,7 +1715,7 @@ function getPackageJsonInfoCache(program) {
|
|
|
1302
1715
|
}
|
|
1303
1716
|
function getDirectoryPath(ts, path) {
|
|
1304
1717
|
try {
|
|
1305
|
-
if (hasProperty(ts, "getDirectoryPath") &&
|
|
1718
|
+
if (hasProperty(ts, "getDirectoryPath") && isFunction(ts.getDirectoryPath)) {
|
|
1306
1719
|
return ts.getDirectoryPath(path);
|
|
1307
1720
|
}
|
|
1308
1721
|
return path;
|
|
@@ -1311,7 +1724,7 @@ function getDirectoryPath(ts, path) {
|
|
|
1311
1724
|
}
|
|
1312
1725
|
}
|
|
1313
1726
|
function makeGetModuleSpecifier(ts) {
|
|
1314
|
-
if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") &&
|
|
1727
|
+
if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction(ts.moduleSpecifiers.getModuleSpecifier))) return;
|
|
1315
1728
|
const _internal = ts.moduleSpecifiers.getModuleSpecifier;
|
|
1316
1729
|
return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) => {
|
|
1317
1730
|
return _internal(
|
|
@@ -1325,14 +1738,14 @@ function makeGetModuleSpecifier(ts) {
|
|
|
1325
1738
|
};
|
|
1326
1739
|
}
|
|
1327
1740
|
function makeGetTemporaryModuleResolutionState(ts) {
|
|
1328
|
-
if (hasProperty(ts, "getTemporaryModuleResolutionState") &&
|
|
1741
|
+
if (hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction(ts.getTemporaryModuleResolutionState)) {
|
|
1329
1742
|
const _internal = ts.getTemporaryModuleResolutionState;
|
|
1330
1743
|
return (cache, program, compilerOptions) => _internal(cache, program, compilerOptions);
|
|
1331
1744
|
}
|
|
1332
1745
|
return void 0;
|
|
1333
1746
|
}
|
|
1334
1747
|
function makeGetPackageScopeForPath(ts) {
|
|
1335
|
-
if (hasProperty(ts, "getPackageScopeForPath") &&
|
|
1748
|
+
if (hasProperty(ts, "getPackageScopeForPath") && isFunction(ts.getPackageScopeForPath)) {
|
|
1336
1749
|
const _internal = ts.getPackageScopeForPath;
|
|
1337
1750
|
return (path, state) => _internal(path, state);
|
|
1338
1751
|
}
|
|
@@ -1590,7 +2003,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1590
2003
|
}
|
|
1591
2004
|
} else if (ts.isNamedImports(namedBindings)) {
|
|
1592
2005
|
for (const importSpecifier of namedBindings.elements) {
|
|
1593
|
-
const importProperty =
|
|
2006
|
+
const importProperty = fromNullishOr(importSpecifier.propertyName).pipe(
|
|
1594
2007
|
orElse(() => some2(importSpecifier.name))
|
|
1595
2008
|
);
|
|
1596
2009
|
if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
|
|
@@ -1920,14 +2333,44 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
1920
2333
|
}
|
|
1921
2334
|
return effectRefactors;
|
|
1922
2335
|
});
|
|
2336
|
+
function codeFixNameToFullyQualifiedName(name) {
|
|
2337
|
+
return `@effect/language-service/codefixes/${name}`;
|
|
2338
|
+
}
|
|
2339
|
+
var codeFixesToApplicableRefactor = fn("LSP.codeFixesToApplicableRefactor")(function* (codeFixes, sourceFile, positionOrRange) {
|
|
2340
|
+
const effectRefactors = [];
|
|
2341
|
+
const range = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
2342
|
+
const inRangeCodeFixes = codeFixes.filter((_) => _.start <= range.pos && _.end >= range.end);
|
|
2343
|
+
for (const codeFix of inRangeCodeFixes) {
|
|
2344
|
+
effectRefactors.push({
|
|
2345
|
+
name: codeFixNameToFullyQualifiedName(codeFix.fixName),
|
|
2346
|
+
description: "Quick Fix: " + codeFix.description,
|
|
2347
|
+
actions: [{
|
|
2348
|
+
name: codeFixNameToFullyQualifiedName(codeFix.fixName),
|
|
2349
|
+
description: "Quick Fix: " + codeFix.description,
|
|
2350
|
+
kind: "refactor.rewrite.codeFixEffect." + codeFix.fixName
|
|
2351
|
+
}]
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
return effectRefactors;
|
|
2355
|
+
});
|
|
1923
2356
|
var getEditsForRefactor = fn("LSP.getEditsForRefactor")(function* (refactors, sourceFile, positionOrRange, refactorName) {
|
|
1924
2357
|
const refactor = refactors.find((refactor2) => refactorNameToFullyQualifiedName(refactor2.name) === refactorName);
|
|
1925
2358
|
if (!refactor) {
|
|
1926
|
-
return yield*
|
|
2359
|
+
return yield* fail3(new RefactorNotApplicableError());
|
|
1927
2360
|
}
|
|
1928
2361
|
const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
1929
2362
|
return yield* refactor.apply(sourceFile, textRange);
|
|
1930
2363
|
});
|
|
2364
|
+
var getEditsForCodeFixes = fn("LSP.getEditsForCodeFixes")(function* (codeFixes, positionOrRange, refactorName) {
|
|
2365
|
+
const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
2366
|
+
const fixToRun = codeFixes.find(
|
|
2367
|
+
(_) => codeFixNameToFullyQualifiedName(_.fixName) === refactorName && _.start <= textRange.pos && _.end >= textRange.end
|
|
2368
|
+
);
|
|
2369
|
+
if (!fixToRun) {
|
|
2370
|
+
return yield* fail3(new RefactorNotApplicableError());
|
|
2371
|
+
}
|
|
2372
|
+
return fixToRun;
|
|
2373
|
+
});
|
|
1931
2374
|
var getCompletionsAtPosition = fn("LSP.getCompletionsAtPosition")(function* (completions, sourceFile, position, options, formatCodeSettings) {
|
|
1932
2375
|
let effectCompletions = [];
|
|
1933
2376
|
for (const completion of completions) {
|
|
@@ -2011,7 +2454,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
2011
2454
|
message: ts.DiagnosticCategory.Message,
|
|
2012
2455
|
suggestion: ts.DiagnosticCategory.Suggestion
|
|
2013
2456
|
};
|
|
2014
|
-
const execute = (
|
|
2457
|
+
const execute = fn("LSP.execute")(function* (rule) {
|
|
2015
2458
|
const diagnostics2 = [];
|
|
2016
2459
|
const codeFixes = [];
|
|
2017
2460
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
@@ -2179,7 +2622,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2179
2622
|
(codegen2) => codegen2.range.pos <= textRange.pos && codegen2.range.end >= textRange.end
|
|
2180
2623
|
);
|
|
2181
2624
|
if (inRangeCodegens.length !== 1) {
|
|
2182
|
-
return yield*
|
|
2625
|
+
return yield* fail3(new CodegenNotApplicableError("zero or multiple codegens in range"));
|
|
2183
2626
|
}
|
|
2184
2627
|
const { codegen, range } = inRangeCodegens[0];
|
|
2185
2628
|
const edit = yield* codegen.apply(sourceFile, range);
|
|
@@ -2378,8 +2821,8 @@ function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
|
|
|
2378
2821
|
};
|
|
2379
2822
|
const expectedAndRealTypeCache = /* @__PURE__ */ new WeakMap();
|
|
2380
2823
|
const expectedAndRealType = (sourceFile) => {
|
|
2381
|
-
const
|
|
2382
|
-
if (
|
|
2824
|
+
const cached = expectedAndRealTypeCache.get(sourceFile);
|
|
2825
|
+
if (cached) return cached;
|
|
2383
2826
|
const result = [];
|
|
2384
2827
|
const nodeToVisit = [sourceFile];
|
|
2385
2828
|
const appendNodeToVisit = (node) => {
|
|
@@ -2596,7 +3039,7 @@ var nanoLayer3 = (fa) => gen(function* () {
|
|
|
2596
3039
|
});
|
|
2597
3040
|
var TypeParserIssue = class _TypeParserIssue {
|
|
2598
3041
|
_tag = "@effect/language-service/TypeParserIssue";
|
|
2599
|
-
static issue =
|
|
3042
|
+
static issue = fail3(new _TypeParserIssue());
|
|
2600
3043
|
};
|
|
2601
3044
|
function typeParserIssue(_message, _type, _node) {
|
|
2602
3045
|
return TypeParserIssue.issue;
|
|
@@ -2792,21 +3235,30 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
2792
3235
|
if (signatures.length !== 1) {
|
|
2793
3236
|
return typeParserIssue("Covariant type has no call signature", type);
|
|
2794
3237
|
}
|
|
2795
|
-
|
|
3238
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
3239
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
3240
|
+
}
|
|
3241
|
+
return succeed3(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
2796
3242
|
}
|
|
2797
3243
|
function contravariantTypeArgument(type) {
|
|
2798
3244
|
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
2799
3245
|
if (signatures.length !== 1) {
|
|
2800
3246
|
return typeParserIssue("Contravariant type has no call signature", type);
|
|
2801
3247
|
}
|
|
2802
|
-
|
|
3248
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
3249
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
3250
|
+
}
|
|
3251
|
+
return succeed3(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
|
|
2803
3252
|
}
|
|
2804
3253
|
function invariantTypeArgument(type) {
|
|
2805
3254
|
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
2806
3255
|
if (signatures.length !== 1) {
|
|
2807
3256
|
return typeParserIssue("Invariant type has no call signature", type);
|
|
2808
3257
|
}
|
|
2809
|
-
|
|
3258
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
3259
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
3260
|
+
}
|
|
3261
|
+
return succeed3(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
2810
3262
|
}
|
|
2811
3263
|
const pipeableType = cachedBy(
|
|
2812
3264
|
function(type, atLocation) {
|
|
@@ -2819,7 +3271,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
2819
3271
|
if (signatures.length === 0) {
|
|
2820
3272
|
return typeParserIssue("'pipe' property is not callable", type, atLocation);
|
|
2821
3273
|
}
|
|
2822
|
-
return
|
|
3274
|
+
return succeed3(type);
|
|
2823
3275
|
},
|
|
2824
3276
|
"TypeParser.pipeableType",
|
|
2825
3277
|
(type) => type
|
|
@@ -3283,7 +3735,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
3283
3735
|
const type = typeCheckerUtils.getTypeAtLocation(yieldedExpression);
|
|
3284
3736
|
if (!type) continue;
|
|
3285
3737
|
const { A: successType } = yield* effectType(type, yieldedExpression);
|
|
3286
|
-
let replacementNode =
|
|
3738
|
+
let replacementNode = succeed3(yieldedExpression);
|
|
3287
3739
|
if (!explicitReturn && !(successType.flags & ts.TypeFlags.VoidLike)) {
|
|
3288
3740
|
replacementNode = pipe(
|
|
3289
3741
|
gen(function* () {
|
|
@@ -3494,15 +3946,15 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
3494
3946
|
if (node.arguments.length === 0) {
|
|
3495
3947
|
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
3496
3948
|
}
|
|
3497
|
-
const [subject, ...
|
|
3498
|
-
return
|
|
3949
|
+
const [subject, ...args3] = node.arguments;
|
|
3950
|
+
return succeed3({
|
|
3499
3951
|
node,
|
|
3500
3952
|
subject,
|
|
3501
|
-
args:
|
|
3953
|
+
args: args3,
|
|
3502
3954
|
kind: "pipe"
|
|
3503
3955
|
});
|
|
3504
3956
|
}
|
|
3505
|
-
return
|
|
3957
|
+
return succeed3({
|
|
3506
3958
|
node,
|
|
3507
3959
|
subject: baseExpression,
|
|
3508
3960
|
args: Array.from(node.arguments),
|
|
@@ -3512,8 +3964,8 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
3512
3964
|
);
|
|
3513
3965
|
}
|
|
3514
3966
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "pipe" && node.arguments.length > 0) {
|
|
3515
|
-
const [subject, ...
|
|
3516
|
-
return
|
|
3967
|
+
const [subject, ...args3] = node.arguments;
|
|
3968
|
+
return succeed3({ node, subject, args: args3, kind: "pipe" });
|
|
3517
3969
|
}
|
|
3518
3970
|
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
3519
3971
|
},
|
|
@@ -3528,7 +3980,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
3528
3980
|
if (node.arguments.length !== 1) {
|
|
3529
3981
|
return typeParserIssue("Node must have exactly one argument", void 0, node);
|
|
3530
3982
|
}
|
|
3531
|
-
return
|
|
3983
|
+
return succeed3({
|
|
3532
3984
|
node,
|
|
3533
3985
|
callee: node.expression,
|
|
3534
3986
|
subject: node.arguments[0]
|
|
@@ -3590,7 +4042,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
3590
4042
|
if (!callbackParameterType) {
|
|
3591
4043
|
continue;
|
|
3592
4044
|
}
|
|
3593
|
-
return
|
|
4045
|
+
return succeed3({
|
|
3594
4046
|
type: callbackParameterType
|
|
3595
4047
|
});
|
|
3596
4048
|
}
|
|
@@ -4002,9 +4454,9 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4002
4454
|
let accessors2 = void 0;
|
|
4003
4455
|
let dependencies = void 0;
|
|
4004
4456
|
if (wholeCall.arguments.length >= 2) {
|
|
4005
|
-
const
|
|
4006
|
-
if (ts.isObjectLiteralExpression(
|
|
4007
|
-
for (const property of
|
|
4457
|
+
const args3 = wholeCall.arguments[1];
|
|
4458
|
+
if (ts.isObjectLiteralExpression(args3)) {
|
|
4459
|
+
for (const property of args3.properties) {
|
|
4008
4460
|
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
4009
4461
|
accessors2 = true;
|
|
4010
4462
|
}
|
|
@@ -4209,7 +4661,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4209
4661
|
const body = node.body;
|
|
4210
4662
|
const returnType = node.type;
|
|
4211
4663
|
if (ts.isArrowFunction(node) && !ts.isBlock(body)) {
|
|
4212
|
-
return
|
|
4664
|
+
return succeed3({
|
|
4213
4665
|
node,
|
|
4214
4666
|
body,
|
|
4215
4667
|
expression: body,
|
|
@@ -4227,7 +4679,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4227
4679
|
if (!stmt.expression) {
|
|
4228
4680
|
return typeParserIssue("Return statement must have an expression", void 0, node);
|
|
4229
4681
|
}
|
|
4230
|
-
return
|
|
4682
|
+
return succeed3({
|
|
4231
4683
|
node,
|
|
4232
4684
|
body,
|
|
4233
4685
|
expression: stmt.expression,
|
|
@@ -4252,7 +4704,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4252
4704
|
if (body.statements.length !== 0) {
|
|
4253
4705
|
return typeParserIssue("Block must have zero statements", void 0, node);
|
|
4254
4706
|
}
|
|
4255
|
-
return
|
|
4707
|
+
return succeed3({
|
|
4256
4708
|
node,
|
|
4257
4709
|
body,
|
|
4258
4710
|
returnType
|
|
@@ -4693,32 +5145,38 @@ var catchAllToMapError = createDiagnostic({
|
|
|
4693
5145
|
return void 0;
|
|
4694
5146
|
};
|
|
4695
5147
|
const getEffectFailCallInfo = (body) => {
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
return { failCall: body, failArg: body.arguments[0] };
|
|
4704
|
-
}
|
|
4705
|
-
}
|
|
4706
|
-
if (ts.isBlock(body)) {
|
|
4707
|
-
const statements = body.statements;
|
|
4708
|
-
if (statements.length === 1) {
|
|
4709
|
-
const stmt = statements[0];
|
|
4710
|
-
if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
|
|
4711
|
-
const isFailCall = yield* pipe(
|
|
4712
|
-
typeParser.isNodeReferenceToEffectModuleApi("fail")(stmt.expression.expression),
|
|
4713
|
-
orUndefined
|
|
4714
|
-
);
|
|
4715
|
-
if (isFailCall && stmt.expression.arguments.length >= 1) {
|
|
4716
|
-
return { failCall: stmt.expression, failArg: stmt.expression.arguments[0] };
|
|
4717
|
-
}
|
|
5148
|
+
if (ts.isCallExpression(body)) {
|
|
5149
|
+
return pipe(
|
|
5150
|
+
typeParser.isNodeReferenceToEffectModuleApi("fail")(body.expression),
|
|
5151
|
+
orUndefined,
|
|
5152
|
+
map4((isFailCall) => {
|
|
5153
|
+
if (isFailCall && body.arguments.length >= 1) {
|
|
5154
|
+
return { failCall: body, failArg: body.arguments[0] };
|
|
4718
5155
|
}
|
|
5156
|
+
return void 0;
|
|
5157
|
+
})
|
|
5158
|
+
);
|
|
5159
|
+
}
|
|
5160
|
+
if (ts.isBlock(body)) {
|
|
5161
|
+
const statements = body.statements;
|
|
5162
|
+
if (statements.length === 1) {
|
|
5163
|
+
const stmt = statements[0];
|
|
5164
|
+
if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
|
|
5165
|
+
const callExpr = stmt.expression;
|
|
5166
|
+
return pipe(
|
|
5167
|
+
typeParser.isNodeReferenceToEffectModuleApi("fail")(callExpr.expression),
|
|
5168
|
+
orUndefined,
|
|
5169
|
+
map4((isFailCall) => {
|
|
5170
|
+
if (isFailCall && callExpr.arguments.length >= 1) {
|
|
5171
|
+
return { failCall: callExpr, failArg: callExpr.arguments[0] };
|
|
5172
|
+
}
|
|
5173
|
+
return void 0;
|
|
5174
|
+
})
|
|
5175
|
+
);
|
|
4719
5176
|
}
|
|
4720
5177
|
}
|
|
4721
|
-
}
|
|
5178
|
+
}
|
|
5179
|
+
return void_;
|
|
4722
5180
|
};
|
|
4723
5181
|
const flows = yield* typeParser.pipingFlows(true)(sourceFile);
|
|
4724
5182
|
for (const flow2 of flows) {
|
|
@@ -4943,10 +5401,10 @@ var getOrMakeKeyBuilder = fn("getOrMakeKeyBuilder")(function* (sourceFile) {
|
|
|
4943
5401
|
keyBuilderCache.set(sourceFile.fileName, keyBuilder);
|
|
4944
5402
|
return keyBuilder;
|
|
4945
5403
|
});
|
|
4946
|
-
function createString(sourceFile,
|
|
5404
|
+
function createString(sourceFile, identifier2, kind) {
|
|
4947
5405
|
return map4(
|
|
4948
5406
|
getOrMakeKeyBuilder(sourceFile),
|
|
4949
|
-
(identifierBuilder) => identifierBuilder.createString(
|
|
5407
|
+
(identifierBuilder) => identifierBuilder.createString(identifier2, kind)
|
|
4950
5408
|
);
|
|
4951
5409
|
}
|
|
4952
5410
|
|
|
@@ -4963,20 +5421,21 @@ var deterministicKeys = createDiagnostic({
|
|
|
4963
5421
|
const typeScriptUtils = yield* service(TypeScriptUtils);
|
|
4964
5422
|
const options = yield* service(LanguageServicePluginOptions);
|
|
4965
5423
|
const parseExtendsCustom = cachedBy(
|
|
4966
|
-
|
|
5424
|
+
(classDeclaration) => {
|
|
4967
5425
|
if (!options.extendedKeyDetection) {
|
|
4968
|
-
return
|
|
5426
|
+
return TypeParserIssue.issue;
|
|
4969
5427
|
}
|
|
4970
5428
|
if (!classDeclaration.name) {
|
|
4971
|
-
return
|
|
5429
|
+
return TypeParserIssue.issue;
|
|
4972
5430
|
}
|
|
4973
5431
|
if (!ts.isIdentifier(classDeclaration.name)) {
|
|
4974
|
-
return
|
|
5432
|
+
return TypeParserIssue.issue;
|
|
4975
5433
|
}
|
|
4976
5434
|
const heritageClauses = classDeclaration.heritageClauses;
|
|
4977
5435
|
if (!heritageClauses) {
|
|
4978
|
-
return
|
|
5436
|
+
return TypeParserIssue.issue;
|
|
4979
5437
|
}
|
|
5438
|
+
const className = classDeclaration.name;
|
|
4980
5439
|
const nodeToVisit2 = [...classDeclaration.heritageClauses];
|
|
4981
5440
|
const appendNodeToVisit2 = (node) => {
|
|
4982
5441
|
nodeToVisit2.push(node);
|
|
@@ -4997,7 +5456,7 @@ var deterministicKeys = createDiagnostic({
|
|
|
4997
5456
|
const parameterSourceFile = typeScriptUtils.getSourceFileOfNode(declaration);
|
|
4998
5457
|
const paramText = parameterSourceFile.text.substring(declaration.pos, declaration.end);
|
|
4999
5458
|
if (paramText.toLowerCase().includes("@effect-identifier")) {
|
|
5000
|
-
return { className
|
|
5459
|
+
return succeed3({ className, keyStringLiteral: arg, target: "custom" });
|
|
5001
5460
|
}
|
|
5002
5461
|
}
|
|
5003
5462
|
}
|
|
@@ -5006,12 +5465,8 @@ var deterministicKeys = createDiagnostic({
|
|
|
5006
5465
|
}
|
|
5007
5466
|
ts.forEachChild(node, appendNodeToVisit2);
|
|
5008
5467
|
}
|
|
5009
|
-
return
|
|
5010
|
-
|
|
5011
|
-
void 0,
|
|
5012
|
-
classDeclaration
|
|
5013
|
-
);
|
|
5014
|
-
}),
|
|
5468
|
+
return TypeParserIssue.issue;
|
|
5469
|
+
},
|
|
5015
5470
|
"deterministicKeys.parseExtendsCustom",
|
|
5016
5471
|
(classDeclaration) => classDeclaration
|
|
5017
5472
|
);
|
|
@@ -5290,25 +5745,27 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
5290
5745
|
}
|
|
5291
5746
|
return false;
|
|
5292
5747
|
};
|
|
5293
|
-
const tryExtractWithSpanExpression = (
|
|
5748
|
+
const tryExtractWithSpanExpression = fn("effectFnOpportunity.tryExtractWithSpanExpression")(function* (expr) {
|
|
5294
5749
|
if (!ts.isCallExpression(expr)) return void 0;
|
|
5295
5750
|
const callee = expr.expression;
|
|
5296
5751
|
const isWithSpan = yield* pipe(
|
|
5297
5752
|
typeParser.isNodeReferenceToEffectModuleApi("withSpan")(callee),
|
|
5298
5753
|
map4(() => true),
|
|
5299
|
-
orElse2(() =>
|
|
5754
|
+
orElse2(() => succeed3(false))
|
|
5300
5755
|
);
|
|
5301
5756
|
if (!isWithSpan) return void 0;
|
|
5302
5757
|
if (expr.arguments.length === 0) return void 0;
|
|
5303
5758
|
return expr.arguments[0];
|
|
5304
5759
|
});
|
|
5305
|
-
const tryParseGenOpportunity = (
|
|
5760
|
+
const tryParseGenOpportunity = fn(
|
|
5761
|
+
"effectFnOpportunity.tryParseGenOpportunity"
|
|
5762
|
+
)(function* (fnNode) {
|
|
5306
5763
|
const bodyExpression = getBodyExpression(fnNode);
|
|
5307
5764
|
if (!bodyExpression) return yield* TypeParserIssue.issue;
|
|
5308
5765
|
const { pipeArguments: pipeArguments2, subject } = yield* pipe(
|
|
5309
5766
|
typeParser.pipeCall(bodyExpression),
|
|
5310
|
-
map4(({ args:
|
|
5311
|
-
orElse2(() =>
|
|
5767
|
+
map4(({ args: args3, subject: subject2 }) => ({ subject: subject2, pipeArguments: args3 })),
|
|
5768
|
+
orElse2(() => succeed3({ subject: bodyExpression, pipeArguments: [] }))
|
|
5312
5769
|
);
|
|
5313
5770
|
const { effectModule, generatorFunction } = yield* typeParser.effectGen(subject);
|
|
5314
5771
|
const effectModuleName = ts.isIdentifier(effectModule) ? ts.idText(effectModule) : sourceEffectModuleName;
|
|
@@ -5325,75 +5782,80 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
5325
5782
|
const isInsideEffectFn = (fnNode) => {
|
|
5326
5783
|
const parent = fnNode.parent;
|
|
5327
5784
|
if (!parent || !ts.isCallExpression(parent)) {
|
|
5328
|
-
return
|
|
5785
|
+
return succeed3(false);
|
|
5329
5786
|
}
|
|
5330
5787
|
if (parent.arguments[0] !== fnNode) {
|
|
5331
|
-
return
|
|
5788
|
+
return succeed3(false);
|
|
5332
5789
|
}
|
|
5333
5790
|
return pipe(
|
|
5334
5791
|
typeParser.effectFn(parent),
|
|
5335
5792
|
orElse2(() => typeParser.effectFnGen(parent)),
|
|
5336
5793
|
orElse2(() => typeParser.effectFnUntracedGen(parent)),
|
|
5337
5794
|
map4(() => true),
|
|
5338
|
-
orElse2(() =>
|
|
5795
|
+
orElse2(() => succeed3(false))
|
|
5339
5796
|
);
|
|
5340
5797
|
};
|
|
5341
|
-
const
|
|
5798
|
+
const parseEffectFnOpportunityTargetGen = fn("effectFnOpportunity.parseEffectFnOpportunityTarget")(
|
|
5799
|
+
function* (node, returnType, traceName, nameIdentifier) {
|
|
5800
|
+
if (yield* isInsideEffectFn(node)) {
|
|
5801
|
+
return yield* TypeParserIssue.issue;
|
|
5802
|
+
}
|
|
5803
|
+
const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
|
|
5804
|
+
yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
|
|
5805
|
+
const opportunity = yield* pipe(
|
|
5806
|
+
tryParseGenOpportunity(node),
|
|
5807
|
+
orElse2(() => {
|
|
5808
|
+
if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
|
|
5809
|
+
return TypeParserIssue.issue;
|
|
5810
|
+
}
|
|
5811
|
+
const body = ts.isArrowFunction(node) ? node.body : node.body;
|
|
5812
|
+
if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
|
|
5813
|
+
return TypeParserIssue.issue;
|
|
5814
|
+
}
|
|
5815
|
+
return succeed3({
|
|
5816
|
+
effectModuleName: sourceEffectModuleName,
|
|
5817
|
+
pipeArguments: [],
|
|
5818
|
+
generatorFunction: void 0,
|
|
5819
|
+
explicitTraceExpression: void 0
|
|
5820
|
+
});
|
|
5821
|
+
})
|
|
5822
|
+
);
|
|
5823
|
+
return {
|
|
5824
|
+
node,
|
|
5825
|
+
nameIdentifier,
|
|
5826
|
+
effectModuleName: opportunity.effectModuleName,
|
|
5827
|
+
inferredTraceName: traceName,
|
|
5828
|
+
explicitTraceExpression: opportunity.explicitTraceExpression,
|
|
5829
|
+
pipeArguments: opportunity.pipeArguments,
|
|
5830
|
+
generatorFunction: opportunity.generatorFunction,
|
|
5831
|
+
hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
|
|
5832
|
+
};
|
|
5833
|
+
}
|
|
5834
|
+
);
|
|
5835
|
+
const parseEffectFnOpportunityTarget = (node) => {
|
|
5342
5836
|
if (!ts.isFunctionExpression(node) && !ts.isArrowFunction(node) && !ts.isFunctionDeclaration(node)) {
|
|
5343
|
-
return
|
|
5837
|
+
return TypeParserIssue.issue;
|
|
5344
5838
|
}
|
|
5345
5839
|
if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) {
|
|
5346
|
-
return
|
|
5840
|
+
return TypeParserIssue.issue;
|
|
5347
5841
|
}
|
|
5348
5842
|
if (ts.isFunctionExpression(node) && node.name) {
|
|
5349
|
-
return
|
|
5843
|
+
return TypeParserIssue.issue;
|
|
5350
5844
|
}
|
|
5351
5845
|
if (node.type) {
|
|
5352
|
-
return
|
|
5353
|
-
}
|
|
5354
|
-
if (yield* isInsideEffectFn(node)) {
|
|
5355
|
-
return yield* TypeParserIssue.issue;
|
|
5846
|
+
return TypeParserIssue.issue;
|
|
5356
5847
|
}
|
|
5357
5848
|
const functionType = typeChecker.getTypeAtLocation(node);
|
|
5358
|
-
if (!functionType) return
|
|
5849
|
+
if (!functionType) return TypeParserIssue.issue;
|
|
5359
5850
|
const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call);
|
|
5360
|
-
if (callSignatures.length !== 1) return
|
|
5851
|
+
if (callSignatures.length !== 1) return TypeParserIssue.issue;
|
|
5361
5852
|
const signature = callSignatures[0];
|
|
5362
5853
|
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
5363
|
-
const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
|
|
5364
|
-
yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
|
|
5365
5854
|
const nameIdentifier = getNameIdentifier(node);
|
|
5366
5855
|
const traceName = nameIdentifier ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text : void 0;
|
|
5367
|
-
if (!traceName) return
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
orElse2(() => {
|
|
5371
|
-
if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
|
|
5372
|
-
return TypeParserIssue.issue;
|
|
5373
|
-
}
|
|
5374
|
-
const body = ts.isArrowFunction(node) ? node.body : node.body;
|
|
5375
|
-
if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
|
|
5376
|
-
return TypeParserIssue.issue;
|
|
5377
|
-
}
|
|
5378
|
-
return succeed({
|
|
5379
|
-
effectModuleName: sourceEffectModuleName,
|
|
5380
|
-
pipeArguments: [],
|
|
5381
|
-
generatorFunction: void 0,
|
|
5382
|
-
explicitTraceExpression: void 0
|
|
5383
|
-
});
|
|
5384
|
-
})
|
|
5385
|
-
);
|
|
5386
|
-
return {
|
|
5387
|
-
node,
|
|
5388
|
-
nameIdentifier,
|
|
5389
|
-
effectModuleName: opportunity.effectModuleName,
|
|
5390
|
-
inferredTraceName: traceName,
|
|
5391
|
-
explicitTraceExpression: opportunity.explicitTraceExpression,
|
|
5392
|
-
pipeArguments: opportunity.pipeArguments,
|
|
5393
|
-
generatorFunction: opportunity.generatorFunction,
|
|
5394
|
-
hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
|
|
5395
|
-
};
|
|
5396
|
-
});
|
|
5856
|
+
if (!traceName) return TypeParserIssue.issue;
|
|
5857
|
+
return parseEffectFnOpportunityTargetGen(node, returnType, traceName, nameIdentifier);
|
|
5858
|
+
};
|
|
5397
5859
|
const getFunctionBodyBlock = (node) => {
|
|
5398
5860
|
if (ts.isArrowFunction(node)) {
|
|
5399
5861
|
if (ts.isBlock(node.body)) {
|
|
@@ -5549,7 +6011,7 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
5549
6011
|
}).join(", ");
|
|
5550
6012
|
const fnSignature = `function*${typeParamNames}(${paramNames}) { ... }`;
|
|
5551
6013
|
const pipeArgsForWithSpan = pipeArguments2.slice(0, -1);
|
|
5552
|
-
const pipeArgsSuffix = (
|
|
6014
|
+
const pipeArgsSuffix = (args3) => args3.length > 0 ? ", ...pipeTransformations" : "";
|
|
5553
6015
|
switch (firstFix.fixName) {
|
|
5554
6016
|
case "effectFnOpportunity_toEffectFnWithSpan": {
|
|
5555
6017
|
const traceName = explicitTraceExpression ? sourceFile.text.slice(explicitTraceExpression.pos, explicitTraceExpression.end).trim() : void 0;
|
|
@@ -5634,7 +6096,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
5634
6096
|
);
|
|
5635
6097
|
return { voidedEffect };
|
|
5636
6098
|
}
|
|
5637
|
-
return yield*
|
|
6099
|
+
return yield* TypeParserIssue.issue;
|
|
5638
6100
|
});
|
|
5639
6101
|
const entries = typeCheckerUtils.expectedAndRealType(sourceFile);
|
|
5640
6102
|
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
@@ -5695,7 +6157,7 @@ var effectMapVoid = createDiagnostic({
|
|
|
5695
6157
|
() => pipe(
|
|
5696
6158
|
typeParser.lazyExpression(callback),
|
|
5697
6159
|
flatMap2(
|
|
5698
|
-
(lazy) => tsUtils.isVoidExpression(lazy.expression) ?
|
|
6160
|
+
(lazy) => tsUtils.isVoidExpression(lazy.expression) ? succeed3(lazy) : typeParserIssue("Expression is not void")
|
|
5699
6161
|
)
|
|
5700
6162
|
)
|
|
5701
6163
|
),
|
|
@@ -6356,11 +6818,11 @@ var leakingRequirements = createDiagnostic({
|
|
|
6356
6818
|
memory,
|
|
6357
6819
|
effectContextType,
|
|
6358
6820
|
(type) => {
|
|
6359
|
-
if (type.flags & ts.TypeFlags.Never) return
|
|
6821
|
+
if (type.flags & ts.TypeFlags.Never) return succeed3(true);
|
|
6360
6822
|
return pipe(
|
|
6361
6823
|
typeParser.scopeType(type, atLocation),
|
|
6362
6824
|
map4(() => true),
|
|
6363
|
-
orElse2(() =>
|
|
6825
|
+
orElse2(() => succeed3(false))
|
|
6364
6826
|
);
|
|
6365
6827
|
}
|
|
6366
6828
|
);
|
|
@@ -6775,7 +7237,7 @@ var missingEffectError = createDiagnostic({
|
|
|
6775
7237
|
map3((_) => _.literal),
|
|
6776
7238
|
filter((_) => ts.isLiteralExpression(_)),
|
|
6777
7239
|
map3((_) => _.text),
|
|
6778
|
-
sort(
|
|
7240
|
+
sort(String2),
|
|
6779
7241
|
map3(
|
|
6780
7242
|
(_) => ts.factory.createPropertyAssignment(
|
|
6781
7243
|
ts.factory.createIdentifier(_),
|
|
@@ -6868,7 +7330,7 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
6868
7330
|
);
|
|
6869
7331
|
if (layerResult) {
|
|
6870
7332
|
const servicesMemory = /* @__PURE__ */ new Map();
|
|
6871
|
-
const excludeNever = (type) =>
|
|
7333
|
+
const excludeNever = (type) => succeed3((type.flags & ts.TypeFlags.Never) !== 0);
|
|
6872
7334
|
const { allIndexes: requiredIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
6873
7335
|
servicesMemory,
|
|
6874
7336
|
layerResult.RIn,
|
|
@@ -7384,13 +7846,13 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7384
7846
|
atLocation2,
|
|
7385
7847
|
ts.NodeBuilderFlags.NoTruncation
|
|
7386
7848
|
);
|
|
7387
|
-
if (!successType) return
|
|
7849
|
+
if (!successType) return fail3("error generating success type");
|
|
7388
7850
|
const failureType = typeChecker.typeToTypeNode(
|
|
7389
7851
|
returnedEffect.E,
|
|
7390
7852
|
atLocation2,
|
|
7391
7853
|
ts.NodeBuilderFlags.NoTruncation
|
|
7392
7854
|
);
|
|
7393
|
-
if (!failureType) return
|
|
7855
|
+
if (!failureType) return fail3("error generating failure type");
|
|
7394
7856
|
const typeNode = ts.factory.createTypeReferenceNode(
|
|
7395
7857
|
ts.factory.createQualifiedName(
|
|
7396
7858
|
ts.factory.createIdentifier(effectIdentifier),
|
|
@@ -7398,7 +7860,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7398
7860
|
),
|
|
7399
7861
|
[successType, failureType, contextType]
|
|
7400
7862
|
);
|
|
7401
|
-
return
|
|
7863
|
+
return succeed3(typeNode);
|
|
7402
7864
|
}),
|
|
7403
7865
|
orElse2(
|
|
7404
7866
|
() => pipe(
|
|
@@ -7409,8 +7871,8 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7409
7871
|
atLocation2,
|
|
7410
7872
|
ts.NodeBuilderFlags.NoTruncation
|
|
7411
7873
|
);
|
|
7412
|
-
if (!successType) return
|
|
7413
|
-
return
|
|
7874
|
+
if (!successType) return fail3("error generating success type");
|
|
7875
|
+
return succeed3(ts.factory.createTypeReferenceNode(
|
|
7414
7876
|
ts.factory.createQualifiedName(
|
|
7415
7877
|
ts.factory.createIdentifier(effectIdentifier),
|
|
7416
7878
|
ts.factory.createIdentifier("Effect")
|
|
@@ -7431,7 +7893,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7431
7893
|
),
|
|
7432
7894
|
orElse2(() => {
|
|
7433
7895
|
const successType = typeChecker.typeToTypeNode(type, atLocation2, ts.NodeBuilderFlags.NoTruncation);
|
|
7434
|
-
if (!successType) return
|
|
7896
|
+
if (!successType) return fail3("error generating success type");
|
|
7435
7897
|
const typeNode = ts.factory.createTypeReferenceNode(
|
|
7436
7898
|
ts.factory.createQualifiedName(
|
|
7437
7899
|
ts.factory.createIdentifier(effectIdentifier),
|
|
@@ -7443,28 +7905,30 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7443
7905
|
ts.factory.createTypeReferenceNode(ts.idText(className2))
|
|
7444
7906
|
]
|
|
7445
7907
|
);
|
|
7446
|
-
return
|
|
7908
|
+
return succeed3(typeNode);
|
|
7447
7909
|
})
|
|
7448
7910
|
);
|
|
7449
|
-
const proxySignature = (
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7911
|
+
const proxySignature = fn("writeTagClassAccessors.proxySignature")(
|
|
7912
|
+
function* (signature, atLocation2, className2) {
|
|
7913
|
+
const signatureDeclaration = typeChecker.signatureToSignatureDeclaration(
|
|
7914
|
+
signature,
|
|
7915
|
+
ts.SyntaxKind.FunctionType,
|
|
7916
|
+
atLocation2,
|
|
7917
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
7918
|
+
);
|
|
7919
|
+
if (!signatureDeclaration) return yield* fail3("error generating signature");
|
|
7920
|
+
const returnType = yield* generateReturnType(
|
|
7921
|
+
typeChecker.getReturnTypeOfSignature(signature),
|
|
7922
|
+
atLocation2,
|
|
7923
|
+
className2
|
|
7924
|
+
);
|
|
7925
|
+
return ts.factory.createFunctionTypeNode(
|
|
7926
|
+
signatureDeclaration.typeParameters,
|
|
7927
|
+
signatureDeclaration.parameters,
|
|
7928
|
+
returnType
|
|
7929
|
+
);
|
|
7930
|
+
}
|
|
7931
|
+
);
|
|
7468
7932
|
for (const { property, propertyType } of involvedMembers) {
|
|
7469
7933
|
const callSignatures = [];
|
|
7470
7934
|
let propertyDeclaration = void 0;
|
|
@@ -7501,21 +7965,21 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
7501
7965
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7502
7966
|
const typeParser = yield* service(TypeParser);
|
|
7503
7967
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7504
|
-
if (typeParser.supportedEffect() === "v4") return yield*
|
|
7505
|
-
if (!ts.isClassDeclaration(node)) return yield*
|
|
7968
|
+
if (typeParser.supportedEffect() === "v4") return yield* fail3("not applicable to Effect v4");
|
|
7969
|
+
if (!ts.isClassDeclaration(node)) return yield* fail3("not a class declaration");
|
|
7506
7970
|
const { Service, accessors: accessors2, className, kind } = yield* pipe(
|
|
7507
7971
|
map4(typeParser.extendsEffectService(node), (_) => ({ kind: "effectService", ..._ })),
|
|
7508
7972
|
orElse2(
|
|
7509
7973
|
() => map4(typeParser.extendsEffectTag(node), (_) => ({ kind: "effectTag", accessors: true, ..._ }))
|
|
7510
7974
|
),
|
|
7511
|
-
orElse2(() =>
|
|
7975
|
+
orElse2(() => fail3("not a class extending Effect.Service call"))
|
|
7512
7976
|
);
|
|
7513
|
-
if (accessors2 !== true) return yield*
|
|
7977
|
+
if (accessors2 !== true) return yield* fail3("accessors are not enabled in the Effect.Service call");
|
|
7514
7978
|
const involvedMembers = [];
|
|
7515
7979
|
const nonPrimitiveServices = typeCheckerUtils.unrollUnionMembers(Service).filter(
|
|
7516
7980
|
(_) => !(_.flags & ts.TypeFlags.Number || _.flags & ts.TypeFlags.String || _.flags & ts.TypeFlags.Boolean || _.flags & ts.TypeFlags.Literal)
|
|
7517
7981
|
);
|
|
7518
|
-
if (nonPrimitiveServices.length === 0) return yield*
|
|
7982
|
+
if (nonPrimitiveServices.length === 0) return yield* fail3("Service type is a primitive type");
|
|
7519
7983
|
for (const serviceShape of nonPrimitiveServices) {
|
|
7520
7984
|
for (const property of typeChecker.getPropertiesOfType(serviceShape)) {
|
|
7521
7985
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, node);
|
|
@@ -7556,7 +8020,7 @@ var writeTagClassAccessors = createRefactor({
|
|
|
7556
8020
|
const parentNodes = tsUtils.getAncestorNodesInRange(sourceFile, textRange);
|
|
7557
8021
|
return yield* pipe(
|
|
7558
8022
|
firstSuccessOf(parentNodes.map(parseNode)),
|
|
7559
|
-
orElse2(() =>
|
|
8023
|
+
orElse2(() => fail3(new RefactorNotApplicableError()))
|
|
7560
8024
|
);
|
|
7561
8025
|
})
|
|
7562
8026
|
});
|
|
@@ -7571,7 +8035,7 @@ var accessors = createCodegen({
|
|
|
7571
8035
|
const typeParser = yield* service(TypeParser);
|
|
7572
8036
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7573
8037
|
const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
|
|
7574
|
-
if (!nodeAndCommentRange) return yield*
|
|
8038
|
+
if (!nodeAndCommentRange) return yield* fail3(new CodegenNotApplicableError("no node and comment range"));
|
|
7575
8039
|
return yield* pipe(
|
|
7576
8040
|
parse2(nodeAndCommentRange.node),
|
|
7577
8041
|
map4(
|
|
@@ -7588,7 +8052,7 @@ var accessors = createCodegen({
|
|
|
7588
8052
|
)
|
|
7589
8053
|
})
|
|
7590
8054
|
),
|
|
7591
|
-
orElse2((cause) =>
|
|
8055
|
+
orElse2((cause) => fail3(new CodegenNotApplicableError(cause)))
|
|
7592
8056
|
);
|
|
7593
8057
|
})
|
|
7594
8058
|
});
|
|
@@ -7601,7 +8065,7 @@ var annotate = createCodegen({
|
|
|
7601
8065
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
7602
8066
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7603
8067
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7604
|
-
const parse3 = (
|
|
8068
|
+
const parse3 = fn("annotate.parse")(function* (node) {
|
|
7605
8069
|
let variableDeclarations = [];
|
|
7606
8070
|
const result = [];
|
|
7607
8071
|
if (ts.isVariableStatement(node)) {
|
|
@@ -7612,14 +8076,14 @@ var annotate = createCodegen({
|
|
|
7612
8076
|
variableDeclarations = [...variableDeclarations, node];
|
|
7613
8077
|
}
|
|
7614
8078
|
if (variableDeclarations.length === 0) {
|
|
7615
|
-
return yield*
|
|
8079
|
+
return yield* fail3(new CodegenNotApplicableError("not a variable declaration"));
|
|
7616
8080
|
}
|
|
7617
8081
|
for (const variableDeclaration of variableDeclarations) {
|
|
7618
8082
|
if (!variableDeclaration.initializer) continue;
|
|
7619
8083
|
const initializerType = typeCheckerUtils.getTypeAtLocation(variableDeclaration.initializer);
|
|
7620
8084
|
if (!initializerType) continue;
|
|
7621
8085
|
const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
7622
|
-
const initializerTypeNode =
|
|
8086
|
+
const initializerTypeNode = fromNullishOr(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
7623
8087
|
initializerType,
|
|
7624
8088
|
enclosingNode,
|
|
7625
8089
|
ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
|
|
@@ -7632,7 +8096,7 @@ var annotate = createCodegen({
|
|
|
7632
8096
|
result.push({ variableDeclaration, initializerTypeNode, hash: hash3 });
|
|
7633
8097
|
}
|
|
7634
8098
|
if (result.length === 0) {
|
|
7635
|
-
return yield*
|
|
8099
|
+
return yield* fail3(new CodegenNotApplicableError("no variable declarations with initializers"));
|
|
7636
8100
|
}
|
|
7637
8101
|
const hash2 = cyrb53(result.map((_) => _.hash).join("/"));
|
|
7638
8102
|
return {
|
|
@@ -7641,7 +8105,7 @@ var annotate = createCodegen({
|
|
|
7641
8105
|
};
|
|
7642
8106
|
});
|
|
7643
8107
|
const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
|
|
7644
|
-
if (!nodeAndCommentRange) return yield*
|
|
8108
|
+
if (!nodeAndCommentRange) return yield* fail3(new CodegenNotApplicableError("no node and comment range"));
|
|
7645
8109
|
return yield* pipe(
|
|
7646
8110
|
parse3(nodeAndCommentRange.node),
|
|
7647
8111
|
map4(
|
|
@@ -7702,13 +8166,13 @@ var makeStructuralSchemaGenContext = fn("StructuralSchemaGen.makeContext")(
|
|
|
7702
8166
|
ts.factory.createIdentifier(effectSchemaIdentifier),
|
|
7703
8167
|
apiName
|
|
7704
8168
|
),
|
|
7705
|
-
createApiCall: (apiName,
|
|
8169
|
+
createApiCall: (apiName, args3) => ts.factory.createCallExpression(
|
|
7706
8170
|
ts.factory.createPropertyAccessExpression(
|
|
7707
8171
|
ts.factory.createIdentifier(effectSchemaIdentifier),
|
|
7708
8172
|
apiName
|
|
7709
8173
|
),
|
|
7710
8174
|
[],
|
|
7711
|
-
|
|
8175
|
+
args3
|
|
7712
8176
|
),
|
|
7713
8177
|
hoistedSchemas: /* @__PURE__ */ new Map(),
|
|
7714
8178
|
typeToStatementIndex: /* @__PURE__ */ new Map(),
|
|
@@ -7758,7 +8222,7 @@ var processType = fn(
|
|
|
7758
8222
|
StructuralSchemaGenContext
|
|
7759
8223
|
);
|
|
7760
8224
|
if (processingContext.depth >= processingContext.maxDepth) {
|
|
7761
|
-
return yield*
|
|
8225
|
+
return yield* fail3(new UnsupportedTypeError(type, "Maximum depth exceeded"));
|
|
7762
8226
|
}
|
|
7763
8227
|
let hoistName = fromIterable(nameToType.entries()).find(([_, existingType]) => existingType === type)?.[0];
|
|
7764
8228
|
if (!hoistName && type && type.symbol && type.symbol.declarations && type.symbol.declarations.length === 1) {
|
|
@@ -7872,7 +8336,7 @@ var processTypeImpl = fn(
|
|
|
7872
8336
|
const objectType = type;
|
|
7873
8337
|
return yield* processObjectType(objectType, context);
|
|
7874
8338
|
}
|
|
7875
|
-
return yield*
|
|
8339
|
+
return yield* fail3(
|
|
7876
8340
|
new UnsupportedTypeError(
|
|
7877
8341
|
type,
|
|
7878
8342
|
`Type with flags ${type.flags} is not supported`
|
|
@@ -7952,7 +8416,7 @@ var processArrayType = fn(
|
|
|
7952
8416
|
const { createApiCall, typeChecker, typeCheckerUtils } = yield* service(StructuralSchemaGenContext);
|
|
7953
8417
|
const typeArgs = typeChecker.getTypeArguments(type);
|
|
7954
8418
|
if (typeArgs.length === 0) {
|
|
7955
|
-
return yield*
|
|
8419
|
+
return yield* fail3(new UnsupportedTypeError(type, "Array type has no type arguments"));
|
|
7956
8420
|
}
|
|
7957
8421
|
const elementSchema = yield* processType(typeArgs[0], context);
|
|
7958
8422
|
const expr = createApiCall("Array", [elementSchema]);
|
|
@@ -8028,7 +8492,7 @@ var processObjectType = fn(
|
|
|
8028
8492
|
);
|
|
8029
8493
|
}
|
|
8030
8494
|
const indexInfos = typeChecker.getIndexInfosOfType(type);
|
|
8031
|
-
const
|
|
8495
|
+
const args3 = [
|
|
8032
8496
|
ts.factory.createObjectLiteralExpression(propertyAssignments, propertyAssignments.length > 0)
|
|
8033
8497
|
];
|
|
8034
8498
|
const records = [];
|
|
@@ -8043,7 +8507,7 @@ var processObjectType = fn(
|
|
|
8043
8507
|
if (records.length > 0) {
|
|
8044
8508
|
return [
|
|
8045
8509
|
createApiCall("StructWithRest", [
|
|
8046
|
-
createApiCall("Struct",
|
|
8510
|
+
createApiCall("Struct", args3),
|
|
8047
8511
|
ts.factory.createArrayLiteralExpression(
|
|
8048
8512
|
records.map(({ key, value }) => createApiCall("Record", [key, value]))
|
|
8049
8513
|
)
|
|
@@ -8075,7 +8539,7 @@ var processObjectType = fn(
|
|
|
8075
8539
|
[ts.factory.createStringLiteral(context.hoistName)]
|
|
8076
8540
|
),
|
|
8077
8541
|
[],
|
|
8078
|
-
|
|
8542
|
+
args3
|
|
8079
8543
|
),
|
|
8080
8544
|
[]
|
|
8081
8545
|
)
|
|
@@ -8088,14 +8552,14 @@ var processObjectType = fn(
|
|
|
8088
8552
|
return [ctx.hoistedSchemas.get(type)(), true];
|
|
8089
8553
|
}
|
|
8090
8554
|
for (const { key, value } of records) {
|
|
8091
|
-
|
|
8555
|
+
args3.push(
|
|
8092
8556
|
ts.factory.createObjectLiteralExpression([
|
|
8093
8557
|
ts.factory.createPropertyAssignment("key", key),
|
|
8094
8558
|
ts.factory.createPropertyAssignment("value", value)
|
|
8095
8559
|
])
|
|
8096
8560
|
);
|
|
8097
8561
|
}
|
|
8098
|
-
return [createApiCall("Struct",
|
|
8562
|
+
return [createApiCall("Struct", args3), propertyAssignments.length === 0];
|
|
8099
8563
|
}
|
|
8100
8564
|
);
|
|
8101
8565
|
var findNodeToProcess = fn("StructuralSchemaGen.findNodeToProcess")(
|
|
@@ -8182,7 +8646,7 @@ var process = fn("StructuralSchemaGen.process")(
|
|
|
8182
8646
|
([name, type]) => pipe(
|
|
8183
8647
|
processType(type, createProcessingContext(typeParser.supportedEffect())),
|
|
8184
8648
|
orElse2(
|
|
8185
|
-
(error) =>
|
|
8649
|
+
(error) => succeed3(ts.addSyntheticLeadingComment(
|
|
8186
8650
|
ts.factory.createIdentifier(""),
|
|
8187
8651
|
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
8188
8652
|
" " + String(error) + " ",
|
|
@@ -8255,10 +8719,10 @@ var process = fn("StructuralSchemaGen.process")(
|
|
|
8255
8719
|
}
|
|
8256
8720
|
);
|
|
8257
8721
|
var applyAtNode = fn("StructuralSchemaGen.applyAtNode")(
|
|
8258
|
-
function* (sourceFile, node,
|
|
8722
|
+
function* (sourceFile, node, identifier2, type, isExported) {
|
|
8259
8723
|
const changeTracker = yield* service(ChangeTracker);
|
|
8260
8724
|
const ts = yield* service(TypeScriptApi);
|
|
8261
|
-
const ctx = yield* process(sourceFile, node, /* @__PURE__ */ new Map([[ts.idText(
|
|
8725
|
+
const ctx = yield* process(sourceFile, node, /* @__PURE__ */ new Map([[ts.idText(identifier2), type]]), isExported, false);
|
|
8262
8726
|
for (const statement of ctx.schemaStatements) {
|
|
8263
8727
|
changeTracker.insertNodeAt(sourceFile, node.pos, statement, { prefix: "\n", suffix: "\n" });
|
|
8264
8728
|
}
|
|
@@ -8277,13 +8741,13 @@ var typeToSchema = createCodegen({
|
|
|
8277
8741
|
const program = yield* service(TypeScriptProgram);
|
|
8278
8742
|
const inThisFile = yield* getCodegensForSourceFile([typeToSchema], sourceFile);
|
|
8279
8743
|
if (inThisFile.length > 1) {
|
|
8280
|
-
return yield*
|
|
8744
|
+
return yield* fail3(
|
|
8281
8745
|
new CodegenNotApplicableError("the typeToSchema codegen can be used only once per file")
|
|
8282
8746
|
);
|
|
8283
8747
|
}
|
|
8284
|
-
const parse3 = (
|
|
8748
|
+
const parse3 = fn("typeToSchema.parse")(function* (node) {
|
|
8285
8749
|
if (!ts.isTypeAliasDeclaration(node)) {
|
|
8286
|
-
return yield*
|
|
8750
|
+
return yield* fail3(
|
|
8287
8751
|
new CodegenNotApplicableError(
|
|
8288
8752
|
"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}`"
|
|
8289
8753
|
)
|
|
@@ -8291,7 +8755,7 @@ var typeToSchema = createCodegen({
|
|
|
8291
8755
|
}
|
|
8292
8756
|
const type = typeCheckerUtils.getTypeAtLocation(node.name);
|
|
8293
8757
|
if (!type) {
|
|
8294
|
-
return yield*
|
|
8758
|
+
return yield* fail3(
|
|
8295
8759
|
new CodegenNotApplicableError(
|
|
8296
8760
|
"error getting the type to process"
|
|
8297
8761
|
)
|
|
@@ -8324,7 +8788,7 @@ var typeToSchema = createCodegen({
|
|
|
8324
8788
|
});
|
|
8325
8789
|
const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
|
|
8326
8790
|
if (!nodeAndCommentRange) {
|
|
8327
|
-
return yield*
|
|
8791
|
+
return yield* fail3(new CodegenNotApplicableError("no node and comment range affected"));
|
|
8328
8792
|
}
|
|
8329
8793
|
return yield* pipe(
|
|
8330
8794
|
parse3(nodeAndCommentRange.node),
|
|
@@ -8460,7 +8924,7 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
8460
8924
|
const isSchema = yield* pipe(
|
|
8461
8925
|
typeParser.effectSchemaType(typeAtLocation, type.expression),
|
|
8462
8926
|
map4(() => true),
|
|
8463
|
-
orElse2(() =>
|
|
8927
|
+
orElse2(() => succeed3(false))
|
|
8464
8928
|
);
|
|
8465
8929
|
if (isSchema) {
|
|
8466
8930
|
extendsSchema = true;
|
|
@@ -8558,73 +9022,99 @@ var preferSchemaOverJson = createDiagnostic({
|
|
|
8558
9022
|
apply: fn("preferSchemaOverJson.apply")(function* (sourceFile, report) {
|
|
8559
9023
|
const ts = yield* service(TypeScriptApi);
|
|
8560
9024
|
const typeParser = yield* service(TypeParser);
|
|
8561
|
-
const
|
|
8562
|
-
|
|
8563
|
-
const
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
9025
|
+
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");
|
|
9026
|
+
const findEnclosingEffectTry = (jsonCall) => {
|
|
9027
|
+
const parent = jsonCall.parent;
|
|
9028
|
+
let lazy;
|
|
9029
|
+
if (ts.isArrowFunction(parent) && parent.body === jsonCall && parent.parameters.length === 0 && (!parent.typeParameters || parent.typeParameters.length === 0)) {
|
|
9030
|
+
lazy = parent;
|
|
9031
|
+
}
|
|
9032
|
+
if (!lazy && ts.isReturnStatement(parent) && parent.expression === jsonCall) {
|
|
9033
|
+
const block = parent.parent;
|
|
9034
|
+
if (ts.isBlock(block) && block.statements.length === 1) {
|
|
9035
|
+
const fn2 = block.parent;
|
|
9036
|
+
if ((ts.isArrowFunction(fn2) || ts.isFunctionExpression(fn2)) && fn2.parameters.length === 0 && (!fn2.typeParameters || fn2.typeParameters.length === 0)) {
|
|
9037
|
+
lazy = fn2;
|
|
9038
|
+
}
|
|
9039
|
+
}
|
|
8569
9040
|
}
|
|
8570
|
-
if (
|
|
8571
|
-
|
|
9041
|
+
if (!lazy) return void 0;
|
|
9042
|
+
const lazyParent = lazy.parent;
|
|
9043
|
+
if (ts.isCallExpression(lazyParent) && lazyParent.arguments.length > 0 && lazyParent.arguments[0] === lazy) {
|
|
9044
|
+
return lazyParent;
|
|
8572
9045
|
}
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
9046
|
+
if (ts.isPropertyAssignment(lazyParent) && ts.isIdentifier(lazyParent.name) && ts.idText(lazyParent.name) === "try") {
|
|
9047
|
+
const objLiteral = lazyParent.parent;
|
|
9048
|
+
if (ts.isObjectLiteralExpression(objLiteral)) {
|
|
9049
|
+
const callExpr = objLiteral.parent;
|
|
9050
|
+
if (ts.isCallExpression(callExpr) && callExpr.arguments.length > 0 && callExpr.arguments[0] === objLiteral) {
|
|
9051
|
+
return callExpr;
|
|
9052
|
+
}
|
|
9053
|
+
}
|
|
9054
|
+
}
|
|
9055
|
+
return void 0;
|
|
9056
|
+
};
|
|
9057
|
+
const jsonCalls = [];
|
|
9058
|
+
const collectJsonCalls = (node) => {
|
|
9059
|
+
if (isJsonCall(node)) {
|
|
9060
|
+
jsonCalls.push(node);
|
|
9061
|
+
}
|
|
9062
|
+
ts.forEachChild(node, collectJsonCalls);
|
|
9063
|
+
};
|
|
9064
|
+
ts.forEachChild(sourceFile, collectJsonCalls);
|
|
9065
|
+
if (jsonCalls.length === 0) return;
|
|
9066
|
+
const effectTrySimple = fn("preferSchemaOverJson.effectTrySimple")(function* (node) {
|
|
8577
9067
|
yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
|
|
8578
|
-
if (node.arguments.length === 0) return yield*
|
|
9068
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
8579
9069
|
const lazyFn = yield* typeParser.lazyExpression(node.arguments[0]);
|
|
8580
|
-
|
|
8581
|
-
return
|
|
9070
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
9071
|
+
return lazyFn.expression;
|
|
8582
9072
|
});
|
|
8583
|
-
const effectTryObject = (
|
|
8584
|
-
if (!ts.isCallExpression(node)) return yield* fail("node is not a call expression");
|
|
9073
|
+
const effectTryObject = fn("preferSchemaOverJson.effectTryObject")(function* (node) {
|
|
8585
9074
|
yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
|
|
8586
|
-
if (node.arguments.length === 0) return yield*
|
|
9075
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
8587
9076
|
const arg = node.arguments[0];
|
|
8588
|
-
if (!ts.isObjectLiteralExpression(arg)) return yield*
|
|
9077
|
+
if (!ts.isObjectLiteralExpression(arg)) return yield* TypeParserIssue.issue;
|
|
8589
9078
|
const tryProp = arg.properties.find(
|
|
8590
9079
|
(p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && ts.idText(p.name) === "try"
|
|
8591
9080
|
);
|
|
8592
|
-
if (!tryProp) return yield*
|
|
9081
|
+
if (!tryProp) return yield* TypeParserIssue.issue;
|
|
8593
9082
|
const lazyFn = yield* typeParser.lazyExpression(tryProp.initializer);
|
|
8594
|
-
|
|
8595
|
-
return
|
|
9083
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
9084
|
+
return lazyFn.expression;
|
|
8596
9085
|
});
|
|
8597
|
-
const jsonMethodInEffectGen = (
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
9086
|
+
const jsonMethodInEffectGen = fn("preferSchemaOverJson.jsonMethodInEffectGen")(
|
|
9087
|
+
function* (jsonCall) {
|
|
9088
|
+
const { effectGen, scopeNode } = yield* typeParser.findEnclosingScopes(jsonCall);
|
|
9089
|
+
if (!effectGen || effectGen.body.statements.length === 0) {
|
|
9090
|
+
return yield* TypeParserIssue.issue;
|
|
9091
|
+
}
|
|
9092
|
+
if (scopeNode && scopeNode !== effectGen.generatorFunction) {
|
|
9093
|
+
return yield* TypeParserIssue.issue;
|
|
9094
|
+
}
|
|
9095
|
+
return jsonCall;
|
|
8602
9096
|
}
|
|
8603
|
-
|
|
8604
|
-
|
|
9097
|
+
);
|
|
9098
|
+
for (const jsonCall of jsonCalls) {
|
|
9099
|
+
const effectTryCall = findEnclosingEffectTry(jsonCall);
|
|
9100
|
+
let match2;
|
|
9101
|
+
if (effectTryCall) {
|
|
9102
|
+
match2 = yield* pipe(
|
|
9103
|
+
firstSuccessOf([
|
|
9104
|
+
effectTrySimple(effectTryCall),
|
|
9105
|
+
effectTryObject(effectTryCall)
|
|
9106
|
+
]),
|
|
9107
|
+
option
|
|
9108
|
+
);
|
|
9109
|
+
} else {
|
|
9110
|
+
match2 = yield* pipe(
|
|
9111
|
+
jsonMethodInEffectGen(jsonCall),
|
|
9112
|
+
option
|
|
9113
|
+
);
|
|
8605
9114
|
}
|
|
8606
|
-
return { node: jsonMethod.node, methodName: jsonMethod.methodName };
|
|
8607
|
-
});
|
|
8608
|
-
const nodeToVisit = [];
|
|
8609
|
-
const appendNodeToVisit = (node) => {
|
|
8610
|
-
nodeToVisit.push(node);
|
|
8611
|
-
return void 0;
|
|
8612
|
-
};
|
|
8613
|
-
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
8614
|
-
while (nodeToVisit.length > 0) {
|
|
8615
|
-
const node = nodeToVisit.shift();
|
|
8616
|
-
ts.forEachChild(node, appendNodeToVisit);
|
|
8617
|
-
const match2 = yield* pipe(
|
|
8618
|
-
firstSuccessOf([
|
|
8619
|
-
effectTrySimple(node),
|
|
8620
|
-
effectTryObject(node),
|
|
8621
|
-
jsonMethodInEffectGen(node)
|
|
8622
|
-
]),
|
|
8623
|
-
option
|
|
8624
|
-
);
|
|
8625
9115
|
if (isSome2(match2)) {
|
|
8626
9116
|
report({
|
|
8627
|
-
location: match2.value
|
|
9117
|
+
location: match2.value,
|
|
8628
9118
|
messageText: "Consider using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify",
|
|
8629
9119
|
fixes: []
|
|
8630
9120
|
});
|
|
@@ -9041,11 +9531,11 @@ var schemaUnionOfLiterals = createDiagnostic({
|
|
|
9041
9531
|
orElse2(() => void_)
|
|
9042
9532
|
);
|
|
9043
9533
|
if (isSchemaUnionCall) {
|
|
9044
|
-
const
|
|
9045
|
-
if (
|
|
9046
|
-
const allAreCallExpressions =
|
|
9534
|
+
const args3 = fromIterable(node.arguments);
|
|
9535
|
+
if (args3.length >= 2) {
|
|
9536
|
+
const allAreCallExpressions = args3.every((arg) => ts.isCallExpression(arg));
|
|
9047
9537
|
if (allAreCallExpressions) {
|
|
9048
|
-
const literalChecks =
|
|
9538
|
+
const literalChecks = args3.map((arg) => {
|
|
9049
9539
|
const callArg = arg;
|
|
9050
9540
|
return pipe(
|
|
9051
9541
|
typeParser.isNodeReferenceToEffectSchemaModuleApi("Literal")(callArg.expression),
|
|
@@ -9268,19 +9758,24 @@ var strictEffectProvide = createDiagnostic({
|
|
|
9268
9758
|
const ts = yield* service(TypeScriptApi);
|
|
9269
9759
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
9270
9760
|
const typeParser = yield* service(TypeParser);
|
|
9271
|
-
const
|
|
9761
|
+
const parseEffectProvideWithLayerGen = fn("strictEffectProvide.parseEffectProvideWithLayer")(
|
|
9762
|
+
function* (node) {
|
|
9763
|
+
yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
|
|
9764
|
+
return yield* firstSuccessOf(
|
|
9765
|
+
node.arguments.map((arg) => {
|
|
9766
|
+
const argType = typeCheckerUtils.getTypeAtLocation(arg);
|
|
9767
|
+
if (!argType) return typeParserIssue("Could not get argument type");
|
|
9768
|
+
return typeParser.layerType(argType, arg);
|
|
9769
|
+
})
|
|
9770
|
+
);
|
|
9771
|
+
}
|
|
9772
|
+
);
|
|
9773
|
+
const parseEffectProvideWithLayer = (node) => {
|
|
9272
9774
|
if (!ts.isCallExpression(node) || node.arguments.length === 0) {
|
|
9273
|
-
return
|
|
9274
|
-
}
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
node.arguments.map((arg) => {
|
|
9278
|
-
const argType = typeCheckerUtils.getTypeAtLocation(arg);
|
|
9279
|
-
if (!argType) return typeParserIssue("Could not get argument type");
|
|
9280
|
-
return typeParser.layerType(argType, arg);
|
|
9281
|
-
})
|
|
9282
|
-
);
|
|
9283
|
-
});
|
|
9775
|
+
return TypeParserIssue.issue;
|
|
9776
|
+
}
|
|
9777
|
+
return parseEffectProvideWithLayerGen(node);
|
|
9778
|
+
};
|
|
9284
9779
|
const nodeToVisit = [];
|
|
9285
9780
|
const appendNodeToVisit = (node) => {
|
|
9286
9781
|
nodeToVisit.push(node);
|
|
@@ -9546,8 +10041,8 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
9546
10041
|
if (ts.isCallExpression(node)) {
|
|
9547
10042
|
yield* pipe(
|
|
9548
10043
|
typeParser.pipeCall(node),
|
|
9549
|
-
map4(({ args:
|
|
9550
|
-
if (
|
|
10044
|
+
map4(({ args: args3, subject }) => {
|
|
10045
|
+
if (args3.length === 0) {
|
|
9551
10046
|
report({
|
|
9552
10047
|
location: node,
|
|
9553
10048
|
messageText: `This pipe call contains no arguments.`,
|
|
@@ -9666,7 +10161,7 @@ var unsupportedServiceAccessors = createDiagnostic({
|
|
|
9666
10161
|
if (ts.isClassDeclaration(node)) {
|
|
9667
10162
|
const parseResult = yield* pipe(
|
|
9668
10163
|
parse2(node),
|
|
9669
|
-
orElse2(() =>
|
|
10164
|
+
orElse2(() => succeed3(null))
|
|
9670
10165
|
);
|
|
9671
10166
|
if (parseResult && parseResult.involvedMembers.length > 0) {
|
|
9672
10167
|
const existingStaticMembers = /* @__PURE__ */ new Set();
|
|
@@ -9778,7 +10273,7 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
|
|
|
9778
10273
|
(_2) => _2.category === tsInstance.DiagnosticCategory.Error || _2.category === tsInstance.DiagnosticCategory.Warning
|
|
9779
10274
|
)
|
|
9780
10275
|
),
|
|
9781
|
-
|
|
10276
|
+
getOrElse2(() => []),
|
|
9782
10277
|
map3(addDiagnostic)
|
|
9783
10278
|
);
|
|
9784
10279
|
return sourceFile;
|