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