@effect/language-service 0.48.0 → 0.50.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 +272 -206
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +88 -22
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +3058 -731
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +88 -22
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm
|
|
3
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/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") {
|
|
@@ -65,6 +65,8 @@ var dual = function(arity, body) {
|
|
|
65
65
|
};
|
|
66
66
|
var identity = (a) => a;
|
|
67
67
|
var constant = (value) => () => value;
|
|
68
|
+
var constTrue = /* @__PURE__ */ constant(true);
|
|
69
|
+
var constFalse = /* @__PURE__ */ constant(false);
|
|
68
70
|
var constUndefined = /* @__PURE__ */ constant(void 0);
|
|
69
71
|
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
70
72
|
switch (arguments.length) {
|
|
@@ -96,7 +98,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
// node_modules/.pnpm
|
|
101
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Equivalence.js
|
|
100
102
|
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
101
103
|
var array = (item) => make((self, that) => {
|
|
102
104
|
if (self.length !== that.length) {
|
|
@@ -111,7 +113,7 @@ var array = (item) => make((self, that) => {
|
|
|
111
113
|
return true;
|
|
112
114
|
});
|
|
113
115
|
|
|
114
|
-
// node_modules/.pnpm
|
|
116
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/GlobalValue.js
|
|
115
117
|
var globalStoreId = `effect/GlobalValue`;
|
|
116
118
|
var globalStore;
|
|
117
119
|
var globalValue = (id, compute) => {
|
|
@@ -125,7 +127,7 @@ var globalValue = (id, compute) => {
|
|
|
125
127
|
return globalStore.get(id);
|
|
126
128
|
};
|
|
127
129
|
|
|
128
|
-
// node_modules/.pnpm
|
|
130
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Predicate.js
|
|
129
131
|
var isString = (input) => typeof input === "string";
|
|
130
132
|
var isNumber = (input) => typeof input === "number";
|
|
131
133
|
var isBoolean = (input) => typeof input === "boolean";
|
|
@@ -133,9 +135,13 @@ var isFunction2 = isFunction;
|
|
|
133
135
|
var isRecordOrArray = (input) => typeof input === "object" && input !== null;
|
|
134
136
|
var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
135
137
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
138
|
+
var isTagged = /* @__PURE__ */ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
|
|
136
139
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
137
140
|
|
|
138
|
-
// node_modules/.pnpm
|
|
141
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/errors.js
|
|
142
|
+
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
143
|
+
|
|
144
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Utils.js
|
|
139
145
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
140
146
|
var GenKindImpl = class {
|
|
141
147
|
value;
|
|
@@ -257,7 +263,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
|
|
|
257
263
|
var genConstructor = function* () {
|
|
258
264
|
}.constructor;
|
|
259
265
|
|
|
260
|
-
// node_modules/.pnpm
|
|
266
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Hash.js
|
|
261
267
|
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
|
|
262
268
|
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
263
269
|
var hash = (self) => {
|
|
@@ -324,14 +330,21 @@ var string = (str) => {
|
|
|
324
330
|
}
|
|
325
331
|
return optimize(h);
|
|
326
332
|
};
|
|
327
|
-
var structureKeys = (o,
|
|
333
|
+
var structureKeys = (o, keys3) => {
|
|
328
334
|
let h = 12289;
|
|
329
|
-
for (let i = 0; i <
|
|
330
|
-
h ^= pipe(string(
|
|
335
|
+
for (let i = 0; i < keys3.length; i++) {
|
|
336
|
+
h ^= pipe(string(keys3[i]), combine(hash(o[keys3[i]])));
|
|
331
337
|
}
|
|
332
338
|
return optimize(h);
|
|
333
339
|
};
|
|
334
340
|
var structure = (o) => structureKeys(o, Object.keys(o));
|
|
341
|
+
var array2 = (arr) => {
|
|
342
|
+
let h = 6151;
|
|
343
|
+
for (let i = 0; i < arr.length; i++) {
|
|
344
|
+
h = pipe(h, combine(hash(arr[i])));
|
|
345
|
+
}
|
|
346
|
+
return optimize(h);
|
|
347
|
+
};
|
|
335
348
|
var cached = function() {
|
|
336
349
|
if (arguments.length === 1) {
|
|
337
350
|
const self2 = arguments[0];
|
|
@@ -356,7 +369,7 @@ var cached = function() {
|
|
|
356
369
|
return hash2;
|
|
357
370
|
};
|
|
358
371
|
|
|
359
|
-
// node_modules/.pnpm
|
|
372
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Equal.js
|
|
360
373
|
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
|
|
361
374
|
function equals() {
|
|
362
375
|
if (arguments.length === 1) {
|
|
@@ -410,7 +423,7 @@ function compareBoth(self, that) {
|
|
|
410
423
|
var isEqual = (u) => hasProperty(u, symbol2);
|
|
411
424
|
var equivalence = () => equals;
|
|
412
425
|
|
|
413
|
-
// node_modules/.pnpm
|
|
426
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Inspectable.js
|
|
414
427
|
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
415
428
|
var toJSON = (x) => {
|
|
416
429
|
try {
|
|
@@ -450,6 +463,12 @@ var Class = class {
|
|
|
450
463
|
return format(this.toJSON());
|
|
451
464
|
}
|
|
452
465
|
};
|
|
466
|
+
var stringifyCircular = (obj, whitespace) => {
|
|
467
|
+
let cache = [];
|
|
468
|
+
const retVal = JSON.stringify(obj, (_key, value) => typeof value === "object" && value !== null ? cache.includes(value) ? void 0 : cache.push(value) && (redactableState.fiberRefs !== void 0 && isRedactable(value) ? value[symbolRedactable](redactableState.fiberRefs) : value) : value, whitespace);
|
|
469
|
+
cache = void 0;
|
|
470
|
+
return retVal;
|
|
471
|
+
};
|
|
453
472
|
var symbolRedactable = /* @__PURE__ */ Symbol.for("effect/Inspectable/Redactable");
|
|
454
473
|
var isRedactable = (u) => typeof u === "object" && u !== null && symbolRedactable in u;
|
|
455
474
|
var redactableState = /* @__PURE__ */ globalValue("effect/Inspectable/redactableState", () => ({
|
|
@@ -462,7 +481,7 @@ var redact = (u) => {
|
|
|
462
481
|
return u;
|
|
463
482
|
};
|
|
464
483
|
|
|
465
|
-
// node_modules/.pnpm
|
|
484
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Pipeable.js
|
|
466
485
|
var pipeArguments = (self, args2) => {
|
|
467
486
|
switch (args2.length) {
|
|
468
487
|
case 0:
|
|
@@ -495,14 +514,16 @@ var pipeArguments = (self, args2) => {
|
|
|
495
514
|
}
|
|
496
515
|
};
|
|
497
516
|
|
|
498
|
-
// node_modules/.pnpm
|
|
517
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/opCodes/effect.js
|
|
499
518
|
var OP_COMMIT = "Commit";
|
|
519
|
+
var OP_FAILURE = "Failure";
|
|
520
|
+
var OP_WITH_RUNTIME = "WithRuntime";
|
|
500
521
|
|
|
501
|
-
// node_modules/.pnpm
|
|
522
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/version.js
|
|
502
523
|
var moduleVersion = "3.18.4";
|
|
503
524
|
var getCurrentVersion = () => moduleVersion;
|
|
504
525
|
|
|
505
|
-
// node_modules/.pnpm
|
|
526
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/effectable.js
|
|
506
527
|
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
507
528
|
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
|
|
508
529
|
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
|
|
@@ -589,7 +610,7 @@ var StructuralCommitPrototype = {
|
|
|
589
610
|
...StructuralPrototype
|
|
590
611
|
};
|
|
591
612
|
|
|
592
|
-
// node_modules/.pnpm
|
|
613
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/option.js
|
|
593
614
|
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
594
615
|
var CommonProto = {
|
|
595
616
|
...EffectPrototype,
|
|
@@ -647,7 +668,7 @@ var some = (value) => {
|
|
|
647
668
|
return a;
|
|
648
669
|
};
|
|
649
670
|
|
|
650
|
-
// node_modules/.pnpm
|
|
671
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/either.js
|
|
651
672
|
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
|
|
652
673
|
var CommonProto2 = {
|
|
653
674
|
...EffectPrototype,
|
|
@@ -709,7 +730,7 @@ var right = (right3) => {
|
|
|
709
730
|
return a;
|
|
710
731
|
};
|
|
711
732
|
|
|
712
|
-
// node_modules/.pnpm
|
|
733
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Either.js
|
|
713
734
|
var right2 = right;
|
|
714
735
|
var left2 = left;
|
|
715
736
|
var isLeft2 = isLeft;
|
|
@@ -717,14 +738,16 @@ var isRight2 = isRight;
|
|
|
717
738
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
718
739
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
719
740
|
|
|
720
|
-
// node_modules/.pnpm
|
|
741
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/array.js
|
|
721
742
|
var isNonEmptyArray = (self) => self.length > 0;
|
|
722
743
|
|
|
723
|
-
// node_modules/.pnpm
|
|
744
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Order.js
|
|
724
745
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
725
746
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
747
|
+
var number2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
748
|
+
var mapInput = /* @__PURE__ */ dual(2, (self, f) => make2((b1, b2) => self(f(b1), f(b2))));
|
|
726
749
|
|
|
727
|
-
// node_modules/.pnpm
|
|
750
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Option.js
|
|
728
751
|
var none2 = () => none;
|
|
729
752
|
var some2 = some;
|
|
730
753
|
var isNone2 = isNone;
|
|
@@ -735,7 +758,7 @@ var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nu
|
|
|
735
758
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
736
759
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
737
760
|
|
|
738
|
-
// node_modules/.pnpm
|
|
761
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Record.js
|
|
739
762
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
740
763
|
const out = {
|
|
741
764
|
...self
|
|
@@ -747,7 +770,7 @@ var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
747
770
|
});
|
|
748
771
|
var keys = (self) => Object.keys(self);
|
|
749
772
|
|
|
750
|
-
// node_modules/.pnpm
|
|
773
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Array.js
|
|
751
774
|
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
752
775
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
753
776
|
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
@@ -770,6 +793,7 @@ var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
|
770
793
|
var head = /* @__PURE__ */ get(0);
|
|
771
794
|
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
772
795
|
var tailNonEmpty = (self) => self.slice(1);
|
|
796
|
+
var reverse = (self) => Array.from(self).reverse();
|
|
773
797
|
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
774
798
|
const out = Array.from(self);
|
|
775
799
|
out.sort(O);
|
|
@@ -785,8 +809,8 @@ var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
|
785
809
|
});
|
|
786
810
|
var _equivalence = /* @__PURE__ */ equivalence();
|
|
787
811
|
var intersectionWith = (isEquivalent) => {
|
|
788
|
-
const
|
|
789
|
-
return dual(2, (self, that) => fromIterable(self).filter((a) =>
|
|
812
|
+
const has3 = containsWith(isEquivalent);
|
|
813
|
+
return dual(2, (self, that) => fromIterable(self).filter((a) => has3(that, a)));
|
|
790
814
|
};
|
|
791
815
|
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
792
816
|
var empty = () => [];
|
|
@@ -828,6 +852,7 @@ var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
|
828
852
|
}
|
|
829
853
|
return [left3, right3];
|
|
830
854
|
});
|
|
855
|
+
var reduce = /* @__PURE__ */ dual(3, (self, b, f) => fromIterable(self).reduce((b2, a, i) => f(b2, a, i), b));
|
|
831
856
|
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
832
857
|
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
833
858
|
const input = fromIterable(self);
|
|
@@ -1217,7 +1242,8 @@ var defaults = {
|
|
|
1217
1242
|
pattern: "default",
|
|
1218
1243
|
skipLeadingPath: ["src/"]
|
|
1219
1244
|
}],
|
|
1220
|
-
extendedKeyDetection: false
|
|
1245
|
+
extendedKeyDetection: false,
|
|
1246
|
+
pipeableMinArgCount: 1
|
|
1221
1247
|
};
|
|
1222
1248
|
function parseKeyPatterns(patterns) {
|
|
1223
1249
|
const result = [];
|
|
@@ -1252,7 +1278,8 @@ function parse(config) {
|
|
|
1252
1278
|
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1253
1279
|
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
|
|
1254
1280
|
keyPatterns: isObject(config) && hasProperty(config, "keyPatterns") && isArray(config.keyPatterns) ? parseKeyPatterns(config.keyPatterns) : defaults.keyPatterns,
|
|
1255
|
-
extendedKeyDetection: isObject(config) && hasProperty(config, "extendedKeyDetection") && isBoolean(config.extendedKeyDetection) ? config.extendedKeyDetection : defaults.extendedKeyDetection
|
|
1281
|
+
extendedKeyDetection: isObject(config) && hasProperty(config, "extendedKeyDetection") && isBoolean(config.extendedKeyDetection) ? config.extendedKeyDetection : defaults.extendedKeyDetection,
|
|
1282
|
+
pipeableMinArgCount: isObject(config) && hasProperty(config, "pipeableMinArgCount") && isNumber(config.pipeableMinArgCount) ? config.pipeableMinArgCount : defaults.pipeableMinArgCount
|
|
1256
1283
|
};
|
|
1257
1284
|
}
|
|
1258
1285
|
|
|
@@ -1917,10 +1944,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1917
1944
|
const sectionOverrides = {};
|
|
1918
1945
|
const skippedRules = [];
|
|
1919
1946
|
const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]+:(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
|
|
1920
|
-
let
|
|
1921
|
-
while ((
|
|
1922
|
-
const nextLineCaptureGroup =
|
|
1923
|
-
const rulesCaptureGroup =
|
|
1947
|
+
let match3;
|
|
1948
|
+
while ((match3 = regex.exec(sourceFile.text)) !== null) {
|
|
1949
|
+
const nextLineCaptureGroup = match3[1];
|
|
1950
|
+
const rulesCaptureGroup = match3[2];
|
|
1924
1951
|
if (rulesCaptureGroup) {
|
|
1925
1952
|
const trimmedRuleString = rulesCaptureGroup.trim();
|
|
1926
1953
|
if (trimmedRuleString) {
|
|
@@ -1932,7 +1959,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1932
1959
|
if (ruleLevel === "skip-file") skippedRules.push(ruleName);
|
|
1933
1960
|
const isOverrideNextLine = nextLineCaptureGroup && nextLineCaptureGroup.trim().toLowerCase() === "-next-line";
|
|
1934
1961
|
if (isOverrideNextLine) {
|
|
1935
|
-
const foundNode = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile,
|
|
1962
|
+
const foundNode = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, match3.index);
|
|
1936
1963
|
if (foundNode) {
|
|
1937
1964
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1938
1965
|
lineOverrides[ruleName].unshift({
|
|
@@ -1945,7 +1972,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1945
1972
|
} else {
|
|
1946
1973
|
sectionOverrides[ruleName] = sectionOverrides[ruleName] || [];
|
|
1947
1974
|
sectionOverrides[ruleName].unshift({
|
|
1948
|
-
pos:
|
|
1975
|
+
pos: match3.index,
|
|
1949
1976
|
level: ruleLevel
|
|
1950
1977
|
});
|
|
1951
1978
|
}
|
|
@@ -2088,9 +2115,9 @@ var getCodegensForSourceFile = fn("LSP.getApplicableCodegens")(function* (codege
|
|
|
2088
2115
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
2089
2116
|
const result = [];
|
|
2090
2117
|
const regex = /@effect-codegens((?:\s[a-zA-Z0-9]+(?::(?:[a-zA-Z0-9]+))?)+)+/gmid;
|
|
2091
|
-
let
|
|
2092
|
-
while ((
|
|
2093
|
-
const pos =
|
|
2118
|
+
let match3;
|
|
2119
|
+
while ((match3 = regex.exec(sourceFile.text)) !== null) {
|
|
2120
|
+
const pos = match3.indices?.[0]?.[0];
|
|
2094
2121
|
if (!pos) continue;
|
|
2095
2122
|
const commentRange = tsUtils.getCommentAtPosition(sourceFile, pos);
|
|
2096
2123
|
if (!commentRange) continue;
|
|
@@ -3994,9 +4021,9 @@ var effectCodegensComment = createCompletion({
|
|
|
3994
4021
|
apply: fn("effectCodegensComment")(function* (sourceFile, position) {
|
|
3995
4022
|
const ts = yield* service(TypeScriptApi);
|
|
3996
4023
|
const sourceText = sourceFile.text;
|
|
3997
|
-
const
|
|
3998
|
-
if (
|
|
3999
|
-
const lastIndex =
|
|
4024
|
+
const match3 = /(\/\/|\/\*(?:\*?))\s*(@)\s*$/id.exec(sourceText.substring(0, position));
|
|
4025
|
+
if (match3 && match3.indices) {
|
|
4026
|
+
const lastIndex = match3.indices[2][0];
|
|
4000
4027
|
const replacementSpan = {
|
|
4001
4028
|
start: lastIndex,
|
|
4002
4029
|
length: Math.max(0, position - lastIndex)
|
|
@@ -4048,120 +4075,2350 @@ var effectDataClasses = createCompletion({
|
|
|
4048
4075
|
})
|
|
4049
4076
|
});
|
|
4050
4077
|
|
|
4051
|
-
// node_modules/.pnpm
|
|
4052
|
-
var
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
const length = bytes.length;
|
|
4057
|
-
let result = "";
|
|
4058
|
-
let i;
|
|
4059
|
-
for (i = 2; i < length; i += 3) {
|
|
4060
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
4061
|
-
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
4062
|
-
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
4063
|
-
result += base64abc[bytes[i] & 63];
|
|
4078
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Chunk.js
|
|
4079
|
+
var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Chunk");
|
|
4080
|
+
function copy(src, srcPos, dest, destPos, len) {
|
|
4081
|
+
for (let i = srcPos; i < Math.min(src.length, srcPos + len); i++) {
|
|
4082
|
+
dest[destPos + i - srcPos] = src[i];
|
|
4064
4083
|
}
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4084
|
+
return dest;
|
|
4085
|
+
}
|
|
4086
|
+
var emptyArray = [];
|
|
4087
|
+
var getEquivalence = (isEquivalent) => make((self, that) => self.length === that.length && toReadonlyArray(self).every((value, i) => isEquivalent(value, unsafeGet2(that, i))));
|
|
4088
|
+
var _equivalence2 = /* @__PURE__ */ getEquivalence(equals);
|
|
4089
|
+
var ChunkProto = {
|
|
4090
|
+
[TypeId3]: {
|
|
4091
|
+
_A: (_) => _
|
|
4092
|
+
},
|
|
4093
|
+
toString() {
|
|
4094
|
+
return format(this.toJSON());
|
|
4095
|
+
},
|
|
4096
|
+
toJSON() {
|
|
4097
|
+
return {
|
|
4098
|
+
_id: "Chunk",
|
|
4099
|
+
values: toReadonlyArray(this).map(toJSON)
|
|
4100
|
+
};
|
|
4101
|
+
},
|
|
4102
|
+
[NodeInspectSymbol]() {
|
|
4103
|
+
return this.toJSON();
|
|
4104
|
+
},
|
|
4105
|
+
[symbol2](that) {
|
|
4106
|
+
return isChunk(that) && _equivalence2(this, that);
|
|
4107
|
+
},
|
|
4108
|
+
[symbol]() {
|
|
4109
|
+
return cached(this, array2(toReadonlyArray(this)));
|
|
4110
|
+
},
|
|
4111
|
+
[Symbol.iterator]() {
|
|
4112
|
+
switch (this.backing._tag) {
|
|
4113
|
+
case "IArray": {
|
|
4114
|
+
return this.backing.array[Symbol.iterator]();
|
|
4115
|
+
}
|
|
4116
|
+
case "IEmpty": {
|
|
4117
|
+
return emptyArray[Symbol.iterator]();
|
|
4118
|
+
}
|
|
4119
|
+
default: {
|
|
4120
|
+
return toReadonlyArray(this)[Symbol.iterator]();
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
},
|
|
4124
|
+
pipe() {
|
|
4125
|
+
return pipeArguments(this, arguments);
|
|
4069
4126
|
}
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4127
|
+
};
|
|
4128
|
+
var makeChunk = (backing) => {
|
|
4129
|
+
const chunk = Object.create(ChunkProto);
|
|
4130
|
+
chunk.backing = backing;
|
|
4131
|
+
switch (backing._tag) {
|
|
4132
|
+
case "IEmpty": {
|
|
4133
|
+
chunk.length = 0;
|
|
4134
|
+
chunk.depth = 0;
|
|
4135
|
+
chunk.left = chunk;
|
|
4136
|
+
chunk.right = chunk;
|
|
4137
|
+
break;
|
|
4138
|
+
}
|
|
4139
|
+
case "IConcat": {
|
|
4140
|
+
chunk.length = backing.left.length + backing.right.length;
|
|
4141
|
+
chunk.depth = 1 + Math.max(backing.left.depth, backing.right.depth);
|
|
4142
|
+
chunk.left = backing.left;
|
|
4143
|
+
chunk.right = backing.right;
|
|
4144
|
+
break;
|
|
4145
|
+
}
|
|
4146
|
+
case "IArray": {
|
|
4147
|
+
chunk.length = backing.array.length;
|
|
4148
|
+
chunk.depth = 0;
|
|
4149
|
+
chunk.left = _empty;
|
|
4150
|
+
chunk.right = _empty;
|
|
4151
|
+
break;
|
|
4152
|
+
}
|
|
4153
|
+
case "ISingleton": {
|
|
4154
|
+
chunk.length = 1;
|
|
4155
|
+
chunk.depth = 0;
|
|
4156
|
+
chunk.left = _empty;
|
|
4157
|
+
chunk.right = _empty;
|
|
4158
|
+
break;
|
|
4159
|
+
}
|
|
4160
|
+
case "ISlice": {
|
|
4161
|
+
chunk.length = backing.length;
|
|
4162
|
+
chunk.depth = backing.chunk.depth + 1;
|
|
4163
|
+
chunk.left = _empty;
|
|
4164
|
+
chunk.right = _empty;
|
|
4165
|
+
break;
|
|
4166
|
+
}
|
|
4075
4167
|
}
|
|
4076
|
-
return
|
|
4168
|
+
return chunk;
|
|
4077
4169
|
};
|
|
4078
|
-
var
|
|
4170
|
+
var isChunk = (u) => hasProperty(u, TypeId3);
|
|
4171
|
+
var _empty = /* @__PURE__ */ makeChunk({
|
|
4172
|
+
_tag: "IEmpty"
|
|
4173
|
+
});
|
|
4174
|
+
var empty2 = () => _empty;
|
|
4175
|
+
var make4 = (...as) => unsafeFromNonEmptyArray(as);
|
|
4176
|
+
var of = (a) => makeChunk({
|
|
4177
|
+
_tag: "ISingleton",
|
|
4178
|
+
a
|
|
4179
|
+
});
|
|
4180
|
+
var fromIterable2 = (self) => isChunk(self) ? self : unsafeFromArray(fromIterable(self));
|
|
4181
|
+
var copyToArray = (self, array3, initial) => {
|
|
4182
|
+
switch (self.backing._tag) {
|
|
4183
|
+
case "IArray": {
|
|
4184
|
+
copy(self.backing.array, 0, array3, initial, self.length);
|
|
4185
|
+
break;
|
|
4186
|
+
}
|
|
4187
|
+
case "IConcat": {
|
|
4188
|
+
copyToArray(self.left, array3, initial);
|
|
4189
|
+
copyToArray(self.right, array3, initial + self.left.length);
|
|
4190
|
+
break;
|
|
4191
|
+
}
|
|
4192
|
+
case "ISingleton": {
|
|
4193
|
+
array3[initial] = self.backing.a;
|
|
4194
|
+
break;
|
|
4195
|
+
}
|
|
4196
|
+
case "ISlice": {
|
|
4197
|
+
let i = 0;
|
|
4198
|
+
let j = initial;
|
|
4199
|
+
while (i < self.length) {
|
|
4200
|
+
array3[j] = unsafeGet2(self, i);
|
|
4201
|
+
i += 1;
|
|
4202
|
+
j += 1;
|
|
4203
|
+
}
|
|
4204
|
+
break;
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
};
|
|
4208
|
+
var toReadonlyArray_ = (self) => {
|
|
4209
|
+
switch (self.backing._tag) {
|
|
4210
|
+
case "IEmpty": {
|
|
4211
|
+
return emptyArray;
|
|
4212
|
+
}
|
|
4213
|
+
case "IArray": {
|
|
4214
|
+
return self.backing.array;
|
|
4215
|
+
}
|
|
4216
|
+
default: {
|
|
4217
|
+
const arr = new Array(self.length);
|
|
4218
|
+
copyToArray(self, arr, 0);
|
|
4219
|
+
self.backing = {
|
|
4220
|
+
_tag: "IArray",
|
|
4221
|
+
array: arr
|
|
4222
|
+
};
|
|
4223
|
+
self.left = _empty;
|
|
4224
|
+
self.right = _empty;
|
|
4225
|
+
self.depth = 0;
|
|
4226
|
+
return arr;
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4229
|
+
};
|
|
4230
|
+
var toReadonlyArray = toReadonlyArray_;
|
|
4231
|
+
var reverseChunk = (self) => {
|
|
4232
|
+
switch (self.backing._tag) {
|
|
4233
|
+
case "IEmpty":
|
|
4234
|
+
case "ISingleton":
|
|
4235
|
+
return self;
|
|
4236
|
+
case "IArray": {
|
|
4237
|
+
return makeChunk({
|
|
4238
|
+
_tag: "IArray",
|
|
4239
|
+
array: reverse(self.backing.array)
|
|
4240
|
+
});
|
|
4241
|
+
}
|
|
4242
|
+
case "IConcat": {
|
|
4243
|
+
return makeChunk({
|
|
4244
|
+
_tag: "IConcat",
|
|
4245
|
+
left: reverse2(self.backing.right),
|
|
4246
|
+
right: reverse2(self.backing.left)
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
case "ISlice":
|
|
4250
|
+
return unsafeFromArray(reverse(toReadonlyArray(self)));
|
|
4251
|
+
}
|
|
4252
|
+
};
|
|
4253
|
+
var reverse2 = reverseChunk;
|
|
4254
|
+
var unsafeFromArray = (self) => self.length === 0 ? empty2() : self.length === 1 ? of(self[0]) : makeChunk({
|
|
4255
|
+
_tag: "IArray",
|
|
4256
|
+
array: self
|
|
4257
|
+
});
|
|
4258
|
+
var unsafeFromNonEmptyArray = (self) => unsafeFromArray(self);
|
|
4259
|
+
var unsafeGet2 = /* @__PURE__ */ dual(2, (self, index) => {
|
|
4260
|
+
switch (self.backing._tag) {
|
|
4261
|
+
case "IEmpty": {
|
|
4262
|
+
throw new Error(`Index out of bounds`);
|
|
4263
|
+
}
|
|
4264
|
+
case "ISingleton": {
|
|
4265
|
+
if (index !== 0) {
|
|
4266
|
+
throw new Error(`Index out of bounds`);
|
|
4267
|
+
}
|
|
4268
|
+
return self.backing.a;
|
|
4269
|
+
}
|
|
4270
|
+
case "IArray": {
|
|
4271
|
+
if (index >= self.length || index < 0) {
|
|
4272
|
+
throw new Error(`Index out of bounds`);
|
|
4273
|
+
}
|
|
4274
|
+
return self.backing.array[index];
|
|
4275
|
+
}
|
|
4276
|
+
case "IConcat": {
|
|
4277
|
+
return index < self.left.length ? unsafeGet2(self.left, index) : unsafeGet2(self.right, index - self.left.length);
|
|
4278
|
+
}
|
|
4279
|
+
case "ISlice": {
|
|
4280
|
+
return unsafeGet2(self.backing.chunk, index + self.backing.offset);
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
});
|
|
4284
|
+
var prepend = /* @__PURE__ */ dual(2, (self, elem) => appendAll2(of(elem), self));
|
|
4285
|
+
var appendAll2 = /* @__PURE__ */ dual(2, (self, that) => {
|
|
4286
|
+
if (self.backing._tag === "IEmpty") {
|
|
4287
|
+
return that;
|
|
4288
|
+
}
|
|
4289
|
+
if (that.backing._tag === "IEmpty") {
|
|
4290
|
+
return self;
|
|
4291
|
+
}
|
|
4292
|
+
const diff = that.depth - self.depth;
|
|
4293
|
+
if (Math.abs(diff) <= 1) {
|
|
4294
|
+
return makeChunk({
|
|
4295
|
+
_tag: "IConcat",
|
|
4296
|
+
left: self,
|
|
4297
|
+
right: that
|
|
4298
|
+
});
|
|
4299
|
+
} else if (diff < -1) {
|
|
4300
|
+
if (self.left.depth >= self.right.depth) {
|
|
4301
|
+
const nr = appendAll2(self.right, that);
|
|
4302
|
+
return makeChunk({
|
|
4303
|
+
_tag: "IConcat",
|
|
4304
|
+
left: self.left,
|
|
4305
|
+
right: nr
|
|
4306
|
+
});
|
|
4307
|
+
} else {
|
|
4308
|
+
const nrr = appendAll2(self.right.right, that);
|
|
4309
|
+
if (nrr.depth === self.depth - 3) {
|
|
4310
|
+
const nr = makeChunk({
|
|
4311
|
+
_tag: "IConcat",
|
|
4312
|
+
left: self.right.left,
|
|
4313
|
+
right: nrr
|
|
4314
|
+
});
|
|
4315
|
+
return makeChunk({
|
|
4316
|
+
_tag: "IConcat",
|
|
4317
|
+
left: self.left,
|
|
4318
|
+
right: nr
|
|
4319
|
+
});
|
|
4320
|
+
} else {
|
|
4321
|
+
const nl = makeChunk({
|
|
4322
|
+
_tag: "IConcat",
|
|
4323
|
+
left: self.left,
|
|
4324
|
+
right: self.right.left
|
|
4325
|
+
});
|
|
4326
|
+
return makeChunk({
|
|
4327
|
+
_tag: "IConcat",
|
|
4328
|
+
left: nl,
|
|
4329
|
+
right: nrr
|
|
4330
|
+
});
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
} else {
|
|
4334
|
+
if (that.right.depth >= that.left.depth) {
|
|
4335
|
+
const nl = appendAll2(self, that.left);
|
|
4336
|
+
return makeChunk({
|
|
4337
|
+
_tag: "IConcat",
|
|
4338
|
+
left: nl,
|
|
4339
|
+
right: that.right
|
|
4340
|
+
});
|
|
4341
|
+
} else {
|
|
4342
|
+
const nll = appendAll2(self, that.left.left);
|
|
4343
|
+
if (nll.depth === that.depth - 3) {
|
|
4344
|
+
const nl = makeChunk({
|
|
4345
|
+
_tag: "IConcat",
|
|
4346
|
+
left: nll,
|
|
4347
|
+
right: that.left.right
|
|
4348
|
+
});
|
|
4349
|
+
return makeChunk({
|
|
4350
|
+
_tag: "IConcat",
|
|
4351
|
+
left: nl,
|
|
4352
|
+
right: that.right
|
|
4353
|
+
});
|
|
4354
|
+
} else {
|
|
4355
|
+
const nr = makeChunk({
|
|
4356
|
+
_tag: "IConcat",
|
|
4357
|
+
left: that.left.right,
|
|
4358
|
+
right: that.right
|
|
4359
|
+
});
|
|
4360
|
+
return makeChunk({
|
|
4361
|
+
_tag: "IConcat",
|
|
4362
|
+
left: nll,
|
|
4363
|
+
right: nr
|
|
4364
|
+
});
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
});
|
|
4369
|
+
var isEmpty = (self) => self.length === 0;
|
|
4370
|
+
var isNonEmpty = (self) => self.length > 0;
|
|
4371
|
+
var unsafeHead = (self) => unsafeGet2(self, 0);
|
|
4372
|
+
var headNonEmpty2 = unsafeHead;
|
|
4079
4373
|
|
|
4080
|
-
// node_modules/.pnpm
|
|
4081
|
-
var
|
|
4374
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashMap/config.js
|
|
4375
|
+
var SIZE = 5;
|
|
4376
|
+
var BUCKET_SIZE = /* @__PURE__ */ Math.pow(2, SIZE);
|
|
4377
|
+
var MASK = BUCKET_SIZE - 1;
|
|
4378
|
+
var MAX_INDEX_NODE = BUCKET_SIZE / 2;
|
|
4379
|
+
var MIN_ARRAY_NODE = BUCKET_SIZE / 4;
|
|
4082
4380
|
|
|
4083
|
-
// node_modules/.pnpm
|
|
4084
|
-
|
|
4381
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
|
|
4382
|
+
function popcount(x) {
|
|
4383
|
+
x -= x >> 1 & 1431655765;
|
|
4384
|
+
x = (x & 858993459) + (x >> 2 & 858993459);
|
|
4385
|
+
x = x + (x >> 4) & 252645135;
|
|
4386
|
+
x += x >> 8;
|
|
4387
|
+
x += x >> 16;
|
|
4388
|
+
return x & 127;
|
|
4389
|
+
}
|
|
4390
|
+
function hashFragment(shift, h) {
|
|
4391
|
+
return h >>> shift & MASK;
|
|
4392
|
+
}
|
|
4393
|
+
function toBitmap(x) {
|
|
4394
|
+
return 1 << x;
|
|
4395
|
+
}
|
|
4396
|
+
function fromBitmap(bitmap, bit) {
|
|
4397
|
+
return popcount(bitmap & bit - 1);
|
|
4398
|
+
}
|
|
4085
4399
|
|
|
4086
|
-
//
|
|
4087
|
-
var
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4400
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/stack.js
|
|
4401
|
+
var make5 = (value, previous) => ({
|
|
4402
|
+
value,
|
|
4403
|
+
previous
|
|
4404
|
+
});
|
|
4405
|
+
|
|
4406
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashMap/array.js
|
|
4407
|
+
function arrayUpdate(mutate3, at, v, arr) {
|
|
4408
|
+
let out = arr;
|
|
4409
|
+
if (!mutate3) {
|
|
4410
|
+
const len = arr.length;
|
|
4411
|
+
out = new Array(len);
|
|
4412
|
+
for (let i = 0; i < len; ++i) out[i] = arr[i];
|
|
4413
|
+
}
|
|
4414
|
+
out[at] = v;
|
|
4415
|
+
return out;
|
|
4416
|
+
}
|
|
4417
|
+
function arraySpliceOut(mutate3, at, arr) {
|
|
4418
|
+
const newLen = arr.length - 1;
|
|
4419
|
+
let i = 0;
|
|
4420
|
+
let g = 0;
|
|
4421
|
+
let out = arr;
|
|
4422
|
+
if (mutate3) {
|
|
4423
|
+
i = g = at;
|
|
4424
|
+
} else {
|
|
4425
|
+
out = new Array(newLen);
|
|
4426
|
+
while (i < at) out[g++] = arr[i++];
|
|
4427
|
+
}
|
|
4428
|
+
++i;
|
|
4429
|
+
while (i <= newLen) out[g++] = arr[i++];
|
|
4430
|
+
if (mutate3) {
|
|
4431
|
+
out.length = newLen;
|
|
4432
|
+
}
|
|
4433
|
+
return out;
|
|
4434
|
+
}
|
|
4435
|
+
function arraySpliceIn(mutate3, at, v, arr) {
|
|
4436
|
+
const len = arr.length;
|
|
4437
|
+
if (mutate3) {
|
|
4438
|
+
let i2 = len;
|
|
4439
|
+
while (i2 >= at) arr[i2--] = arr[i2];
|
|
4440
|
+
arr[at] = v;
|
|
4441
|
+
return arr;
|
|
4442
|
+
}
|
|
4443
|
+
let i = 0, g = 0;
|
|
4444
|
+
const out = new Array(len + 1);
|
|
4445
|
+
while (i < at) out[g++] = arr[i++];
|
|
4446
|
+
out[at] = v;
|
|
4447
|
+
while (i < len) out[++g] = arr[i++];
|
|
4448
|
+
return out;
|
|
4449
|
+
}
|
|
4450
|
+
|
|
4451
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashMap/node.js
|
|
4452
|
+
var EmptyNode = class _EmptyNode {
|
|
4453
|
+
_tag = "EmptyNode";
|
|
4454
|
+
modify(edit, _shift, f, hash2, key, size4) {
|
|
4455
|
+
const v = f(none2());
|
|
4456
|
+
if (isNone2(v)) return new _EmptyNode();
|
|
4457
|
+
++size4.value;
|
|
4458
|
+
return new LeafNode(edit, hash2, key, v);
|
|
4459
|
+
}
|
|
4460
|
+
};
|
|
4461
|
+
function isEmptyNode(a) {
|
|
4462
|
+
return isTagged(a, "EmptyNode");
|
|
4463
|
+
}
|
|
4464
|
+
function isLeafNode(node) {
|
|
4465
|
+
return isEmptyNode(node) || node._tag === "LeafNode" || node._tag === "CollisionNode";
|
|
4466
|
+
}
|
|
4467
|
+
function canEditNode(node, edit) {
|
|
4468
|
+
return isEmptyNode(node) ? false : edit === node.edit;
|
|
4469
|
+
}
|
|
4470
|
+
var LeafNode = class _LeafNode {
|
|
4471
|
+
edit;
|
|
4472
|
+
hash;
|
|
4473
|
+
key;
|
|
4474
|
+
value;
|
|
4475
|
+
_tag = "LeafNode";
|
|
4476
|
+
constructor(edit, hash2, key, value) {
|
|
4477
|
+
this.edit = edit;
|
|
4478
|
+
this.hash = hash2;
|
|
4479
|
+
this.key = key;
|
|
4480
|
+
this.value = value;
|
|
4481
|
+
}
|
|
4482
|
+
modify(edit, shift, f, hash2, key, size4) {
|
|
4483
|
+
if (equals(key, this.key)) {
|
|
4484
|
+
const v2 = f(this.value);
|
|
4485
|
+
if (v2 === this.value) return this;
|
|
4486
|
+
else if (isNone2(v2)) {
|
|
4487
|
+
--size4.value;
|
|
4488
|
+
return new EmptyNode();
|
|
4489
|
+
}
|
|
4490
|
+
if (canEditNode(this, edit)) {
|
|
4491
|
+
this.value = v2;
|
|
4492
|
+
return this;
|
|
4493
|
+
}
|
|
4494
|
+
return new _LeafNode(edit, hash2, key, v2);
|
|
4495
|
+
}
|
|
4496
|
+
const v = f(none2());
|
|
4497
|
+
if (isNone2(v)) return this;
|
|
4498
|
+
++size4.value;
|
|
4499
|
+
return mergeLeaves(edit, shift, this.hash, this, hash2, new _LeafNode(edit, hash2, key, v));
|
|
4500
|
+
}
|
|
4501
|
+
};
|
|
4502
|
+
var CollisionNode = class _CollisionNode {
|
|
4503
|
+
edit;
|
|
4504
|
+
hash;
|
|
4505
|
+
children;
|
|
4506
|
+
_tag = "CollisionNode";
|
|
4507
|
+
constructor(edit, hash2, children) {
|
|
4508
|
+
this.edit = edit;
|
|
4509
|
+
this.hash = hash2;
|
|
4510
|
+
this.children = children;
|
|
4511
|
+
}
|
|
4512
|
+
modify(edit, shift, f, hash2, key, size4) {
|
|
4513
|
+
if (hash2 === this.hash) {
|
|
4514
|
+
const canEdit = canEditNode(this, edit);
|
|
4515
|
+
const list = this.updateCollisionList(canEdit, edit, this.hash, this.children, f, key, size4);
|
|
4516
|
+
if (list === this.children) return this;
|
|
4517
|
+
return list.length > 1 ? new _CollisionNode(edit, this.hash, list) : list[0];
|
|
4518
|
+
}
|
|
4519
|
+
const v = f(none2());
|
|
4520
|
+
if (isNone2(v)) return this;
|
|
4521
|
+
++size4.value;
|
|
4522
|
+
return mergeLeaves(edit, shift, this.hash, this, hash2, new LeafNode(edit, hash2, key, v));
|
|
4523
|
+
}
|
|
4524
|
+
updateCollisionList(mutate3, edit, hash2, list, f, key, size4) {
|
|
4525
|
+
const len = list.length;
|
|
4526
|
+
for (let i = 0; i < len; ++i) {
|
|
4527
|
+
const child = list[i];
|
|
4528
|
+
if ("key" in child && equals(key, child.key)) {
|
|
4529
|
+
const value = child.value;
|
|
4530
|
+
const newValue2 = f(value);
|
|
4531
|
+
if (newValue2 === value) return list;
|
|
4532
|
+
if (isNone2(newValue2)) {
|
|
4533
|
+
--size4.value;
|
|
4534
|
+
return arraySpliceOut(mutate3, i, list);
|
|
4143
4535
|
}
|
|
4536
|
+
return arrayUpdate(mutate3, i, new LeafNode(edit, hash2, key, newValue2), list);
|
|
4144
4537
|
}
|
|
4145
|
-
ts.forEachChild(node, appendNodeToVisit);
|
|
4146
4538
|
}
|
|
4147
|
-
|
|
4148
|
-
|
|
4539
|
+
const newValue = f(none2());
|
|
4540
|
+
if (isNone2(newValue)) return list;
|
|
4541
|
+
++size4.value;
|
|
4542
|
+
return arrayUpdate(mutate3, len, new LeafNode(edit, hash2, key, newValue), list);
|
|
4543
|
+
}
|
|
4544
|
+
};
|
|
4545
|
+
var IndexedNode = class _IndexedNode {
|
|
4546
|
+
edit;
|
|
4547
|
+
mask;
|
|
4548
|
+
children;
|
|
4549
|
+
_tag = "IndexedNode";
|
|
4550
|
+
constructor(edit, mask, children) {
|
|
4551
|
+
this.edit = edit;
|
|
4552
|
+
this.mask = mask;
|
|
4553
|
+
this.children = children;
|
|
4554
|
+
}
|
|
4555
|
+
modify(edit, shift, f, hash2, key, size4) {
|
|
4556
|
+
const mask = this.mask;
|
|
4557
|
+
const children = this.children;
|
|
4558
|
+
const frag = hashFragment(shift, hash2);
|
|
4559
|
+
const bit = toBitmap(frag);
|
|
4560
|
+
const indx = fromBitmap(mask, bit);
|
|
4561
|
+
const exists = mask & bit;
|
|
4562
|
+
const canEdit = canEditNode(this, edit);
|
|
4563
|
+
if (!exists) {
|
|
4564
|
+
const _newChild = new EmptyNode().modify(edit, shift + SIZE, f, hash2, key, size4);
|
|
4565
|
+
if (!_newChild) return this;
|
|
4566
|
+
return children.length >= MAX_INDEX_NODE ? expand(edit, frag, _newChild, mask, children) : new _IndexedNode(edit, mask | bit, arraySpliceIn(canEdit, indx, _newChild, children));
|
|
4567
|
+
}
|
|
4568
|
+
const current = children[indx];
|
|
4569
|
+
const child = current.modify(edit, shift + SIZE, f, hash2, key, size4);
|
|
4570
|
+
if (current === child) return this;
|
|
4571
|
+
let bitmap = mask;
|
|
4572
|
+
let newChildren;
|
|
4573
|
+
if (isEmptyNode(child)) {
|
|
4574
|
+
bitmap &= ~bit;
|
|
4575
|
+
if (!bitmap) return new EmptyNode();
|
|
4576
|
+
if (children.length <= 2 && isLeafNode(children[indx ^ 1])) {
|
|
4577
|
+
return children[indx ^ 1];
|
|
4578
|
+
}
|
|
4579
|
+
newChildren = arraySpliceOut(canEdit, indx, children);
|
|
4580
|
+
} else {
|
|
4581
|
+
newChildren = arrayUpdate(canEdit, indx, child, children);
|
|
4582
|
+
}
|
|
4583
|
+
if (canEdit) {
|
|
4584
|
+
this.mask = bitmap;
|
|
4585
|
+
this.children = newChildren;
|
|
4586
|
+
return this;
|
|
4587
|
+
}
|
|
4588
|
+
return new _IndexedNode(edit, bitmap, newChildren);
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
var ArrayNode = class _ArrayNode {
|
|
4592
|
+
edit;
|
|
4593
|
+
size;
|
|
4594
|
+
children;
|
|
4595
|
+
_tag = "ArrayNode";
|
|
4596
|
+
constructor(edit, size4, children) {
|
|
4597
|
+
this.edit = edit;
|
|
4598
|
+
this.size = size4;
|
|
4599
|
+
this.children = children;
|
|
4600
|
+
}
|
|
4601
|
+
modify(edit, shift, f, hash2, key, size4) {
|
|
4602
|
+
let count = this.size;
|
|
4603
|
+
const children = this.children;
|
|
4604
|
+
const frag = hashFragment(shift, hash2);
|
|
4605
|
+
const child = children[frag];
|
|
4606
|
+
const newChild = (child || new EmptyNode()).modify(edit, shift + SIZE, f, hash2, key, size4);
|
|
4607
|
+
if (child === newChild) return this;
|
|
4608
|
+
const canEdit = canEditNode(this, edit);
|
|
4609
|
+
let newChildren;
|
|
4610
|
+
if (isEmptyNode(child) && !isEmptyNode(newChild)) {
|
|
4611
|
+
++count;
|
|
4612
|
+
newChildren = arrayUpdate(canEdit, frag, newChild, children);
|
|
4613
|
+
} else if (!isEmptyNode(child) && isEmptyNode(newChild)) {
|
|
4614
|
+
--count;
|
|
4615
|
+
if (count <= MIN_ARRAY_NODE) {
|
|
4616
|
+
return pack(edit, count, frag, children);
|
|
4617
|
+
}
|
|
4618
|
+
newChildren = arrayUpdate(canEdit, frag, new EmptyNode(), children);
|
|
4619
|
+
} else {
|
|
4620
|
+
newChildren = arrayUpdate(canEdit, frag, newChild, children);
|
|
4621
|
+
}
|
|
4622
|
+
if (canEdit) {
|
|
4623
|
+
this.size = count;
|
|
4624
|
+
this.children = newChildren;
|
|
4625
|
+
return this;
|
|
4626
|
+
}
|
|
4627
|
+
return new _ArrayNode(edit, count, newChildren);
|
|
4628
|
+
}
|
|
4629
|
+
};
|
|
4630
|
+
function pack(edit, count, removed, elements) {
|
|
4631
|
+
const children = new Array(count - 1);
|
|
4632
|
+
let g = 0;
|
|
4633
|
+
let bitmap = 0;
|
|
4634
|
+
for (let i = 0, len = elements.length; i < len; ++i) {
|
|
4635
|
+
if (i !== removed) {
|
|
4636
|
+
const elem = elements[i];
|
|
4637
|
+
if (elem && !isEmptyNode(elem)) {
|
|
4638
|
+
children[g++] = elem;
|
|
4639
|
+
bitmap |= 1 << i;
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
return new IndexedNode(edit, bitmap, children);
|
|
4644
|
+
}
|
|
4645
|
+
function expand(edit, frag, child, bitmap, subNodes) {
|
|
4646
|
+
const arr = [];
|
|
4647
|
+
let bit = bitmap;
|
|
4648
|
+
let count = 0;
|
|
4649
|
+
for (let i = 0; bit; ++i) {
|
|
4650
|
+
if (bit & 1) arr[i] = subNodes[count++];
|
|
4651
|
+
bit >>>= 1;
|
|
4652
|
+
}
|
|
4653
|
+
arr[frag] = child;
|
|
4654
|
+
return new ArrayNode(edit, count + 1, arr);
|
|
4655
|
+
}
|
|
4656
|
+
function mergeLeavesInner(edit, shift, h1, n1, h2, n2) {
|
|
4657
|
+
if (h1 === h2) return new CollisionNode(edit, h1, [n2, n1]);
|
|
4658
|
+
const subH1 = hashFragment(shift, h1);
|
|
4659
|
+
const subH2 = hashFragment(shift, h2);
|
|
4660
|
+
if (subH1 === subH2) {
|
|
4661
|
+
return (child) => new IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), [child]);
|
|
4662
|
+
} else {
|
|
4663
|
+
const children = subH1 < subH2 ? [n1, n2] : [n2, n1];
|
|
4664
|
+
return new IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), children);
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
function mergeLeaves(edit, shift, h1, n1, h2, n2) {
|
|
4668
|
+
let stack = void 0;
|
|
4669
|
+
let currentShift = shift;
|
|
4670
|
+
while (true) {
|
|
4671
|
+
const res = mergeLeavesInner(edit, currentShift, h1, n1, h2, n2);
|
|
4672
|
+
if (typeof res === "function") {
|
|
4673
|
+
stack = make5(res, stack);
|
|
4674
|
+
currentShift = currentShift + SIZE;
|
|
4675
|
+
} else {
|
|
4676
|
+
let final = res;
|
|
4677
|
+
while (stack != null) {
|
|
4678
|
+
final = stack.value(final);
|
|
4679
|
+
stack = stack.previous;
|
|
4680
|
+
}
|
|
4681
|
+
return final;
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4149
4685
|
|
|
4150
|
-
//
|
|
4151
|
-
var
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
const
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4686
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashMap.js
|
|
4687
|
+
var HashMapSymbolKey = "effect/HashMap";
|
|
4688
|
+
var HashMapTypeId = /* @__PURE__ */ Symbol.for(HashMapSymbolKey);
|
|
4689
|
+
var HashMapProto = {
|
|
4690
|
+
[HashMapTypeId]: HashMapTypeId,
|
|
4691
|
+
[Symbol.iterator]() {
|
|
4692
|
+
return new HashMapIterator(this, (k, v) => [k, v]);
|
|
4693
|
+
},
|
|
4694
|
+
[symbol]() {
|
|
4695
|
+
let hash2 = hash(HashMapSymbolKey);
|
|
4696
|
+
for (const item of this) {
|
|
4697
|
+
hash2 ^= pipe(hash(item[0]), combine(hash(item[1])));
|
|
4698
|
+
}
|
|
4699
|
+
return cached(this, hash2);
|
|
4700
|
+
},
|
|
4701
|
+
[symbol2](that) {
|
|
4702
|
+
if (isHashMap(that)) {
|
|
4703
|
+
if (that._size !== this._size) {
|
|
4704
|
+
return false;
|
|
4705
|
+
}
|
|
4706
|
+
for (const item of this) {
|
|
4707
|
+
const elem = pipe(that, getHash(item[0], hash(item[0])));
|
|
4708
|
+
if (isNone2(elem)) {
|
|
4709
|
+
return false;
|
|
4710
|
+
} else {
|
|
4711
|
+
if (!equals(item[1], elem.value)) {
|
|
4712
|
+
return false;
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
return true;
|
|
4717
|
+
}
|
|
4718
|
+
return false;
|
|
4719
|
+
},
|
|
4720
|
+
toString() {
|
|
4721
|
+
return format(this.toJSON());
|
|
4722
|
+
},
|
|
4723
|
+
toJSON() {
|
|
4724
|
+
return {
|
|
4725
|
+
_id: "HashMap",
|
|
4726
|
+
values: Array.from(this).map(toJSON)
|
|
4727
|
+
};
|
|
4728
|
+
},
|
|
4729
|
+
[NodeInspectSymbol]() {
|
|
4730
|
+
return this.toJSON();
|
|
4731
|
+
},
|
|
4732
|
+
pipe() {
|
|
4733
|
+
return pipeArguments(this, arguments);
|
|
4734
|
+
}
|
|
4735
|
+
};
|
|
4736
|
+
var makeImpl = (editable, edit, root, size4) => {
|
|
4737
|
+
const map9 = Object.create(HashMapProto);
|
|
4738
|
+
map9._editable = editable;
|
|
4739
|
+
map9._edit = edit;
|
|
4740
|
+
map9._root = root;
|
|
4741
|
+
map9._size = size4;
|
|
4742
|
+
return map9;
|
|
4743
|
+
};
|
|
4744
|
+
var HashMapIterator = class _HashMapIterator {
|
|
4745
|
+
map;
|
|
4746
|
+
f;
|
|
4747
|
+
v;
|
|
4748
|
+
constructor(map9, f) {
|
|
4749
|
+
this.map = map9;
|
|
4750
|
+
this.f = f;
|
|
4751
|
+
this.v = visitLazy(this.map._root, this.f, void 0);
|
|
4752
|
+
}
|
|
4753
|
+
next() {
|
|
4754
|
+
if (isNone2(this.v)) {
|
|
4755
|
+
return {
|
|
4756
|
+
done: true,
|
|
4757
|
+
value: void 0
|
|
4758
|
+
};
|
|
4759
|
+
}
|
|
4760
|
+
const v0 = this.v.value;
|
|
4761
|
+
this.v = applyCont(v0.cont);
|
|
4762
|
+
return {
|
|
4763
|
+
done: false,
|
|
4764
|
+
value: v0.value
|
|
4765
|
+
};
|
|
4766
|
+
}
|
|
4767
|
+
[Symbol.iterator]() {
|
|
4768
|
+
return new _HashMapIterator(this.map, this.f);
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
var applyCont = (cont) => cont ? visitLazyChildren(cont[0], cont[1], cont[2], cont[3], cont[4]) : none2();
|
|
4772
|
+
var visitLazy = (node, f, cont = void 0) => {
|
|
4773
|
+
switch (node._tag) {
|
|
4774
|
+
case "LeafNode": {
|
|
4775
|
+
if (isSome2(node.value)) {
|
|
4776
|
+
return some2({
|
|
4777
|
+
value: f(node.key, node.value.value),
|
|
4778
|
+
cont
|
|
4779
|
+
});
|
|
4780
|
+
}
|
|
4781
|
+
return applyCont(cont);
|
|
4782
|
+
}
|
|
4783
|
+
case "CollisionNode":
|
|
4784
|
+
case "ArrayNode":
|
|
4785
|
+
case "IndexedNode": {
|
|
4786
|
+
const children = node.children;
|
|
4787
|
+
return visitLazyChildren(children.length, children, 0, f, cont);
|
|
4788
|
+
}
|
|
4789
|
+
default: {
|
|
4790
|
+
return applyCont(cont);
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
};
|
|
4794
|
+
var visitLazyChildren = (len, children, i, f, cont) => {
|
|
4795
|
+
while (i < len) {
|
|
4796
|
+
const child = children[i++];
|
|
4797
|
+
if (child && !isEmptyNode(child)) {
|
|
4798
|
+
return visitLazy(child, f, [len, children, i, f, cont]);
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
return applyCont(cont);
|
|
4802
|
+
};
|
|
4803
|
+
var _empty2 = /* @__PURE__ */ makeImpl(false, 0, /* @__PURE__ */ new EmptyNode(), 0);
|
|
4804
|
+
var empty3 = () => _empty2;
|
|
4805
|
+
var isHashMap = (u) => hasProperty(u, HashMapTypeId);
|
|
4806
|
+
var getHash = /* @__PURE__ */ dual(3, (self, key, hash2) => {
|
|
4807
|
+
let node = self._root;
|
|
4808
|
+
let shift = 0;
|
|
4809
|
+
while (true) {
|
|
4810
|
+
switch (node._tag) {
|
|
4811
|
+
case "LeafNode": {
|
|
4812
|
+
return equals(key, node.key) ? node.value : none2();
|
|
4813
|
+
}
|
|
4814
|
+
case "CollisionNode": {
|
|
4815
|
+
if (hash2 === node.hash) {
|
|
4816
|
+
const children = node.children;
|
|
4817
|
+
for (let i = 0, len = children.length; i < len; ++i) {
|
|
4818
|
+
const child = children[i];
|
|
4819
|
+
if ("key" in child && equals(key, child.key)) {
|
|
4820
|
+
return child.value;
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
return none2();
|
|
4825
|
+
}
|
|
4826
|
+
case "IndexedNode": {
|
|
4827
|
+
const frag = hashFragment(shift, hash2);
|
|
4828
|
+
const bit = toBitmap(frag);
|
|
4829
|
+
if (node.mask & bit) {
|
|
4830
|
+
node = node.children[fromBitmap(node.mask, bit)];
|
|
4831
|
+
shift += SIZE;
|
|
4832
|
+
break;
|
|
4833
|
+
}
|
|
4834
|
+
return none2();
|
|
4835
|
+
}
|
|
4836
|
+
case "ArrayNode": {
|
|
4837
|
+
node = node.children[hashFragment(shift, hash2)];
|
|
4838
|
+
if (node) {
|
|
4839
|
+
shift += SIZE;
|
|
4840
|
+
break;
|
|
4841
|
+
}
|
|
4842
|
+
return none2();
|
|
4843
|
+
}
|
|
4844
|
+
default:
|
|
4845
|
+
return none2();
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
});
|
|
4849
|
+
var set = /* @__PURE__ */ dual(3, (self, key, value) => modifyAt(self, key, () => some2(value)));
|
|
4850
|
+
var setTree = /* @__PURE__ */ dual(3, (self, newRoot, newSize) => {
|
|
4851
|
+
if (self._editable) {
|
|
4852
|
+
;
|
|
4853
|
+
self._root = newRoot;
|
|
4854
|
+
self._size = newSize;
|
|
4855
|
+
return self;
|
|
4856
|
+
}
|
|
4857
|
+
return newRoot === self._root ? self : makeImpl(self._editable, self._edit, newRoot, newSize);
|
|
4858
|
+
});
|
|
4859
|
+
var keys2 = (self) => new HashMapIterator(self, (key) => key);
|
|
4860
|
+
var size = (self) => self._size;
|
|
4861
|
+
var beginMutation = (self) => makeImpl(true, self._edit + 1, self._root, self._size);
|
|
4862
|
+
var modifyAt = /* @__PURE__ */ dual(3, (self, key, f) => modifyHash(self, key, hash(key), f));
|
|
4863
|
+
var modifyHash = /* @__PURE__ */ dual(4, (self, key, hash2, f) => {
|
|
4864
|
+
const size4 = {
|
|
4865
|
+
value: self._size
|
|
4866
|
+
};
|
|
4867
|
+
const newRoot = self._root.modify(self._editable ? self._edit : NaN, 0, f, hash2, key, size4);
|
|
4868
|
+
return pipe(self, setTree(newRoot, size4.value));
|
|
4869
|
+
});
|
|
4870
|
+
var forEach = /* @__PURE__ */ dual(2, (self, f) => reduce2(self, void 0, (_, value, key) => f(value, key)));
|
|
4871
|
+
var reduce2 = /* @__PURE__ */ dual(3, (self, zero2, f) => {
|
|
4872
|
+
const root = self._root;
|
|
4873
|
+
if (root._tag === "LeafNode") {
|
|
4874
|
+
return isSome2(root.value) ? f(zero2, root.value.value, root.key) : zero2;
|
|
4875
|
+
}
|
|
4876
|
+
if (root._tag === "EmptyNode") {
|
|
4877
|
+
return zero2;
|
|
4878
|
+
}
|
|
4879
|
+
const toVisit = [root.children];
|
|
4880
|
+
let children;
|
|
4881
|
+
while (children = toVisit.pop()) {
|
|
4882
|
+
for (let i = 0, len = children.length; i < len; ) {
|
|
4883
|
+
const child = children[i++];
|
|
4884
|
+
if (child && !isEmptyNode(child)) {
|
|
4885
|
+
if (child._tag === "LeafNode") {
|
|
4886
|
+
if (isSome2(child.value)) {
|
|
4887
|
+
zero2 = f(zero2, child.value.value, child.key);
|
|
4888
|
+
}
|
|
4889
|
+
} else {
|
|
4890
|
+
toVisit.push(child.children);
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
return zero2;
|
|
4896
|
+
});
|
|
4897
|
+
|
|
4898
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/hashSet.js
|
|
4899
|
+
var HashSetSymbolKey = "effect/HashSet";
|
|
4900
|
+
var HashSetTypeId = /* @__PURE__ */ Symbol.for(HashSetSymbolKey);
|
|
4901
|
+
var HashSetProto = {
|
|
4902
|
+
[HashSetTypeId]: HashSetTypeId,
|
|
4903
|
+
[Symbol.iterator]() {
|
|
4904
|
+
return keys2(this._keyMap);
|
|
4905
|
+
},
|
|
4906
|
+
[symbol]() {
|
|
4907
|
+
return cached(this, combine(hash(this._keyMap))(hash(HashSetSymbolKey)));
|
|
4908
|
+
},
|
|
4909
|
+
[symbol2](that) {
|
|
4910
|
+
if (isHashSet(that)) {
|
|
4911
|
+
return size(this._keyMap) === size(that._keyMap) && equals(this._keyMap, that._keyMap);
|
|
4912
|
+
}
|
|
4913
|
+
return false;
|
|
4914
|
+
},
|
|
4915
|
+
toString() {
|
|
4916
|
+
return format(this.toJSON());
|
|
4917
|
+
},
|
|
4918
|
+
toJSON() {
|
|
4919
|
+
return {
|
|
4920
|
+
_id: "HashSet",
|
|
4921
|
+
values: Array.from(this).map(toJSON)
|
|
4922
|
+
};
|
|
4923
|
+
},
|
|
4924
|
+
[NodeInspectSymbol]() {
|
|
4925
|
+
return this.toJSON();
|
|
4926
|
+
},
|
|
4927
|
+
pipe() {
|
|
4928
|
+
return pipeArguments(this, arguments);
|
|
4929
|
+
}
|
|
4930
|
+
};
|
|
4931
|
+
var makeImpl2 = (keyMap) => {
|
|
4932
|
+
const set2 = Object.create(HashSetProto);
|
|
4933
|
+
set2._keyMap = keyMap;
|
|
4934
|
+
return set2;
|
|
4935
|
+
};
|
|
4936
|
+
var isHashSet = (u) => hasProperty(u, HashSetTypeId);
|
|
4937
|
+
var _empty3 = /* @__PURE__ */ makeImpl2(/* @__PURE__ */ empty3());
|
|
4938
|
+
var empty4 = () => _empty3;
|
|
4939
|
+
var size2 = (self) => size(self._keyMap);
|
|
4940
|
+
var beginMutation2 = (self) => makeImpl2(beginMutation(self._keyMap));
|
|
4941
|
+
var endMutation = (self) => {
|
|
4942
|
+
;
|
|
4943
|
+
self._keyMap._editable = false;
|
|
4944
|
+
return self;
|
|
4945
|
+
};
|
|
4946
|
+
var mutate = /* @__PURE__ */ dual(2, (self, f) => {
|
|
4947
|
+
const transient = beginMutation2(self);
|
|
4948
|
+
f(transient);
|
|
4949
|
+
return endMutation(transient);
|
|
4950
|
+
});
|
|
4951
|
+
var add = /* @__PURE__ */ dual(2, (self, value) => self._keyMap._editable ? (set(value, true)(self._keyMap), self) : makeImpl2(set(value, true)(self._keyMap)));
|
|
4952
|
+
var union2 = /* @__PURE__ */ dual(2, (self, that) => mutate(empty4(), (set2) => {
|
|
4953
|
+
forEach2(self, (value) => add(set2, value));
|
|
4954
|
+
for (const value of that) {
|
|
4955
|
+
add(set2, value);
|
|
4956
|
+
}
|
|
4957
|
+
}));
|
|
4958
|
+
var forEach2 = /* @__PURE__ */ dual(2, (self, f) => forEach(self._keyMap, (_, k) => f(k)));
|
|
4959
|
+
|
|
4960
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/HashSet.js
|
|
4961
|
+
var empty5 = empty4;
|
|
4962
|
+
var size3 = size2;
|
|
4963
|
+
var add2 = add;
|
|
4964
|
+
var union3 = union2;
|
|
4965
|
+
|
|
4966
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/data.js
|
|
4967
|
+
var ArrayProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Array.prototype), {
|
|
4968
|
+
[symbol]() {
|
|
4969
|
+
return cached(this, array2(this));
|
|
4970
|
+
},
|
|
4971
|
+
[symbol2](that) {
|
|
4972
|
+
if (Array.isArray(that) && this.length === that.length) {
|
|
4973
|
+
return this.every((v, i) => equals(v, that[i]));
|
|
4974
|
+
} else {
|
|
4975
|
+
return false;
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
});
|
|
4979
|
+
var Structural = /* @__PURE__ */ (function() {
|
|
4980
|
+
function Structural2(args2) {
|
|
4981
|
+
if (args2) {
|
|
4982
|
+
Object.assign(this, args2);
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
Structural2.prototype = StructuralPrototype;
|
|
4986
|
+
return Structural2;
|
|
4987
|
+
})();
|
|
4988
|
+
|
|
4989
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/opCodes/cause.js
|
|
4990
|
+
var OP_DIE = "Die";
|
|
4991
|
+
var OP_EMPTY = "Empty";
|
|
4992
|
+
var OP_FAIL = "Fail";
|
|
4993
|
+
var OP_INTERRUPT = "Interrupt";
|
|
4994
|
+
var OP_PARALLEL = "Parallel";
|
|
4995
|
+
var OP_SEQUENTIAL = "Sequential";
|
|
4996
|
+
|
|
4997
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/cause.js
|
|
4998
|
+
var CauseSymbolKey = "effect/Cause";
|
|
4999
|
+
var CauseTypeId = /* @__PURE__ */ Symbol.for(CauseSymbolKey);
|
|
5000
|
+
var variance = {
|
|
5001
|
+
/* c8 ignore next */
|
|
5002
|
+
_E: (_) => _
|
|
5003
|
+
};
|
|
5004
|
+
var proto = {
|
|
5005
|
+
[CauseTypeId]: variance,
|
|
5006
|
+
[symbol]() {
|
|
5007
|
+
return pipe(hash(CauseSymbolKey), combine(hash(flattenCause(this))), cached(this));
|
|
5008
|
+
},
|
|
5009
|
+
[symbol2](that) {
|
|
5010
|
+
return isCause(that) && causeEquals(this, that);
|
|
5011
|
+
},
|
|
5012
|
+
pipe() {
|
|
5013
|
+
return pipeArguments(this, arguments);
|
|
5014
|
+
},
|
|
5015
|
+
toJSON() {
|
|
5016
|
+
switch (this._tag) {
|
|
5017
|
+
case "Empty":
|
|
5018
|
+
return {
|
|
5019
|
+
_id: "Cause",
|
|
5020
|
+
_tag: this._tag
|
|
5021
|
+
};
|
|
5022
|
+
case "Die":
|
|
5023
|
+
return {
|
|
5024
|
+
_id: "Cause",
|
|
5025
|
+
_tag: this._tag,
|
|
5026
|
+
defect: toJSON(this.defect)
|
|
5027
|
+
};
|
|
5028
|
+
case "Interrupt":
|
|
5029
|
+
return {
|
|
5030
|
+
_id: "Cause",
|
|
5031
|
+
_tag: this._tag,
|
|
5032
|
+
fiberId: this.fiberId.toJSON()
|
|
5033
|
+
};
|
|
5034
|
+
case "Fail":
|
|
5035
|
+
return {
|
|
5036
|
+
_id: "Cause",
|
|
5037
|
+
_tag: this._tag,
|
|
5038
|
+
failure: toJSON(this.error)
|
|
5039
|
+
};
|
|
5040
|
+
case "Sequential":
|
|
5041
|
+
case "Parallel":
|
|
5042
|
+
return {
|
|
5043
|
+
_id: "Cause",
|
|
5044
|
+
_tag: this._tag,
|
|
5045
|
+
left: toJSON(this.left),
|
|
5046
|
+
right: toJSON(this.right)
|
|
5047
|
+
};
|
|
5048
|
+
}
|
|
5049
|
+
},
|
|
5050
|
+
toString() {
|
|
5051
|
+
return pretty(this);
|
|
5052
|
+
},
|
|
5053
|
+
[NodeInspectSymbol]() {
|
|
5054
|
+
return this.toJSON();
|
|
5055
|
+
}
|
|
5056
|
+
};
|
|
5057
|
+
var fail2 = (error) => {
|
|
5058
|
+
const o = Object.create(proto);
|
|
5059
|
+
o._tag = OP_FAIL;
|
|
5060
|
+
o.error = error;
|
|
5061
|
+
return o;
|
|
5062
|
+
};
|
|
5063
|
+
var parallel = (left3, right3) => {
|
|
5064
|
+
const o = Object.create(proto);
|
|
5065
|
+
o._tag = OP_PARALLEL;
|
|
5066
|
+
o.left = left3;
|
|
5067
|
+
o.right = right3;
|
|
5068
|
+
return o;
|
|
5069
|
+
};
|
|
5070
|
+
var sequential = (left3, right3) => {
|
|
5071
|
+
const o = Object.create(proto);
|
|
5072
|
+
o._tag = OP_SEQUENTIAL;
|
|
5073
|
+
o.left = left3;
|
|
5074
|
+
o.right = right3;
|
|
5075
|
+
return o;
|
|
5076
|
+
};
|
|
5077
|
+
var isCause = (u) => hasProperty(u, CauseTypeId);
|
|
5078
|
+
var isInterruptedOnly = (self) => reduceWithContext(void 0, IsInterruptedOnlyCauseReducer)(self);
|
|
5079
|
+
var causeEquals = (left3, right3) => {
|
|
5080
|
+
let leftStack = of(left3);
|
|
5081
|
+
let rightStack = of(right3);
|
|
5082
|
+
while (isNonEmpty(leftStack) && isNonEmpty(rightStack)) {
|
|
5083
|
+
const [leftParallel, leftSequential] = pipe(headNonEmpty2(leftStack), reduce4([empty5(), empty2()], ([parallel2, sequential2], cause) => {
|
|
5084
|
+
const [par, seq] = evaluateCause(cause);
|
|
5085
|
+
return some2([pipe(parallel2, union3(par)), pipe(sequential2, appendAll2(seq))]);
|
|
5086
|
+
}));
|
|
5087
|
+
const [rightParallel, rightSequential] = pipe(headNonEmpty2(rightStack), reduce4([empty5(), empty2()], ([parallel2, sequential2], cause) => {
|
|
5088
|
+
const [par, seq] = evaluateCause(cause);
|
|
5089
|
+
return some2([pipe(parallel2, union3(par)), pipe(sequential2, appendAll2(seq))]);
|
|
5090
|
+
}));
|
|
5091
|
+
if (!equals(leftParallel, rightParallel)) {
|
|
5092
|
+
return false;
|
|
5093
|
+
}
|
|
5094
|
+
leftStack = leftSequential;
|
|
5095
|
+
rightStack = rightSequential;
|
|
5096
|
+
}
|
|
5097
|
+
return true;
|
|
5098
|
+
};
|
|
5099
|
+
var flattenCause = (cause) => {
|
|
5100
|
+
return flattenCauseLoop(of(cause), empty2());
|
|
5101
|
+
};
|
|
5102
|
+
var flattenCauseLoop = (causes, flattened) => {
|
|
5103
|
+
while (1) {
|
|
5104
|
+
const [parallel2, sequential2] = pipe(causes, reduce([empty5(), empty2()], ([parallel3, sequential3], cause) => {
|
|
5105
|
+
const [par, seq] = evaluateCause(cause);
|
|
5106
|
+
return [pipe(parallel3, union3(par)), pipe(sequential3, appendAll2(seq))];
|
|
5107
|
+
}));
|
|
5108
|
+
const updated = size3(parallel2) > 0 ? pipe(flattened, prepend(parallel2)) : flattened;
|
|
5109
|
+
if (isEmpty(sequential2)) {
|
|
5110
|
+
return reverse2(updated);
|
|
5111
|
+
}
|
|
5112
|
+
causes = sequential2;
|
|
5113
|
+
flattened = updated;
|
|
5114
|
+
}
|
|
5115
|
+
throw new Error(getBugErrorMessage("Cause.flattenCauseLoop"));
|
|
5116
|
+
};
|
|
5117
|
+
var evaluateCause = (self) => {
|
|
5118
|
+
let cause = self;
|
|
5119
|
+
const stack = [];
|
|
5120
|
+
let _parallel = empty5();
|
|
5121
|
+
let _sequential = empty2();
|
|
5122
|
+
while (cause !== void 0) {
|
|
5123
|
+
switch (cause._tag) {
|
|
5124
|
+
case OP_EMPTY: {
|
|
5125
|
+
if (stack.length === 0) {
|
|
5126
|
+
return [_parallel, _sequential];
|
|
5127
|
+
}
|
|
5128
|
+
cause = stack.pop();
|
|
5129
|
+
break;
|
|
5130
|
+
}
|
|
5131
|
+
case OP_FAIL: {
|
|
5132
|
+
_parallel = add2(_parallel, make4(cause._tag, cause.error));
|
|
5133
|
+
if (stack.length === 0) {
|
|
5134
|
+
return [_parallel, _sequential];
|
|
5135
|
+
}
|
|
5136
|
+
cause = stack.pop();
|
|
5137
|
+
break;
|
|
5138
|
+
}
|
|
5139
|
+
case OP_DIE: {
|
|
5140
|
+
_parallel = add2(_parallel, make4(cause._tag, cause.defect));
|
|
5141
|
+
if (stack.length === 0) {
|
|
5142
|
+
return [_parallel, _sequential];
|
|
5143
|
+
}
|
|
5144
|
+
cause = stack.pop();
|
|
5145
|
+
break;
|
|
5146
|
+
}
|
|
5147
|
+
case OP_INTERRUPT: {
|
|
5148
|
+
_parallel = add2(_parallel, make4(cause._tag, cause.fiberId));
|
|
5149
|
+
if (stack.length === 0) {
|
|
5150
|
+
return [_parallel, _sequential];
|
|
5151
|
+
}
|
|
5152
|
+
cause = stack.pop();
|
|
5153
|
+
break;
|
|
5154
|
+
}
|
|
5155
|
+
case OP_SEQUENTIAL: {
|
|
5156
|
+
switch (cause.left._tag) {
|
|
5157
|
+
case OP_EMPTY: {
|
|
5158
|
+
cause = cause.right;
|
|
5159
|
+
break;
|
|
5160
|
+
}
|
|
5161
|
+
case OP_SEQUENTIAL: {
|
|
5162
|
+
cause = sequential(cause.left.left, sequential(cause.left.right, cause.right));
|
|
5163
|
+
break;
|
|
5164
|
+
}
|
|
5165
|
+
case OP_PARALLEL: {
|
|
5166
|
+
cause = parallel(sequential(cause.left.left, cause.right), sequential(cause.left.right, cause.right));
|
|
5167
|
+
break;
|
|
5168
|
+
}
|
|
5169
|
+
default: {
|
|
5170
|
+
_sequential = prepend(_sequential, cause.right);
|
|
5171
|
+
cause = cause.left;
|
|
5172
|
+
break;
|
|
5173
|
+
}
|
|
5174
|
+
}
|
|
5175
|
+
break;
|
|
5176
|
+
}
|
|
5177
|
+
case OP_PARALLEL: {
|
|
5178
|
+
stack.push(cause.right);
|
|
5179
|
+
cause = cause.left;
|
|
5180
|
+
break;
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
throw new Error(getBugErrorMessage("Cause.evaluateCauseLoop"));
|
|
5185
|
+
};
|
|
5186
|
+
var IsInterruptedOnlyCauseReducer = {
|
|
5187
|
+
emptyCase: constTrue,
|
|
5188
|
+
failCase: constFalse,
|
|
5189
|
+
dieCase: constFalse,
|
|
5190
|
+
interruptCase: constTrue,
|
|
5191
|
+
sequentialCase: (_, left3, right3) => left3 && right3,
|
|
5192
|
+
parallelCase: (_, left3, right3) => left3 && right3
|
|
5193
|
+
};
|
|
5194
|
+
var OP_SEQUENTIAL_CASE = "SequentialCase";
|
|
5195
|
+
var OP_PARALLEL_CASE = "ParallelCase";
|
|
5196
|
+
var reduce4 = /* @__PURE__ */ dual(3, (self, zero2, pf) => {
|
|
5197
|
+
let accumulator = zero2;
|
|
5198
|
+
let cause = self;
|
|
5199
|
+
const causes = [];
|
|
5200
|
+
while (cause !== void 0) {
|
|
5201
|
+
const option2 = pf(accumulator, cause);
|
|
5202
|
+
accumulator = isSome2(option2) ? option2.value : accumulator;
|
|
5203
|
+
switch (cause._tag) {
|
|
5204
|
+
case OP_SEQUENTIAL: {
|
|
5205
|
+
causes.push(cause.right);
|
|
5206
|
+
cause = cause.left;
|
|
5207
|
+
break;
|
|
5208
|
+
}
|
|
5209
|
+
case OP_PARALLEL: {
|
|
5210
|
+
causes.push(cause.right);
|
|
5211
|
+
cause = cause.left;
|
|
5212
|
+
break;
|
|
5213
|
+
}
|
|
5214
|
+
default: {
|
|
5215
|
+
cause = void 0;
|
|
5216
|
+
break;
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
if (cause === void 0 && causes.length > 0) {
|
|
5220
|
+
cause = causes.pop();
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5223
|
+
return accumulator;
|
|
5224
|
+
});
|
|
5225
|
+
var reduceWithContext = /* @__PURE__ */ dual(3, (self, context, reducer) => {
|
|
5226
|
+
const input = [self];
|
|
5227
|
+
const output = [];
|
|
5228
|
+
while (input.length > 0) {
|
|
5229
|
+
const cause = input.pop();
|
|
5230
|
+
switch (cause._tag) {
|
|
5231
|
+
case OP_EMPTY: {
|
|
5232
|
+
output.push(right2(reducer.emptyCase(context)));
|
|
5233
|
+
break;
|
|
5234
|
+
}
|
|
5235
|
+
case OP_FAIL: {
|
|
5236
|
+
output.push(right2(reducer.failCase(context, cause.error)));
|
|
5237
|
+
break;
|
|
5238
|
+
}
|
|
5239
|
+
case OP_DIE: {
|
|
5240
|
+
output.push(right2(reducer.dieCase(context, cause.defect)));
|
|
5241
|
+
break;
|
|
5242
|
+
}
|
|
5243
|
+
case OP_INTERRUPT: {
|
|
5244
|
+
output.push(right2(reducer.interruptCase(context, cause.fiberId)));
|
|
5245
|
+
break;
|
|
5246
|
+
}
|
|
5247
|
+
case OP_SEQUENTIAL: {
|
|
5248
|
+
input.push(cause.right);
|
|
5249
|
+
input.push(cause.left);
|
|
5250
|
+
output.push(left2({
|
|
5251
|
+
_tag: OP_SEQUENTIAL_CASE
|
|
5252
|
+
}));
|
|
5253
|
+
break;
|
|
5254
|
+
}
|
|
5255
|
+
case OP_PARALLEL: {
|
|
5256
|
+
input.push(cause.right);
|
|
5257
|
+
input.push(cause.left);
|
|
5258
|
+
output.push(left2({
|
|
5259
|
+
_tag: OP_PARALLEL_CASE
|
|
5260
|
+
}));
|
|
5261
|
+
break;
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
const accumulator = [];
|
|
5266
|
+
while (output.length > 0) {
|
|
5267
|
+
const either = output.pop();
|
|
5268
|
+
switch (either._tag) {
|
|
5269
|
+
case "Left": {
|
|
5270
|
+
switch (either.left._tag) {
|
|
5271
|
+
case OP_SEQUENTIAL_CASE: {
|
|
5272
|
+
const left3 = accumulator.pop();
|
|
5273
|
+
const right3 = accumulator.pop();
|
|
5274
|
+
const value = reducer.sequentialCase(context, left3, right3);
|
|
5275
|
+
accumulator.push(value);
|
|
5276
|
+
break;
|
|
5277
|
+
}
|
|
5278
|
+
case OP_PARALLEL_CASE: {
|
|
5279
|
+
const left3 = accumulator.pop();
|
|
5280
|
+
const right3 = accumulator.pop();
|
|
5281
|
+
const value = reducer.parallelCase(context, left3, right3);
|
|
5282
|
+
accumulator.push(value);
|
|
5283
|
+
break;
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
break;
|
|
5287
|
+
}
|
|
5288
|
+
case "Right": {
|
|
5289
|
+
accumulator.push(either.right);
|
|
5290
|
+
break;
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
if (accumulator.length === 0) {
|
|
5295
|
+
throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");
|
|
5296
|
+
}
|
|
5297
|
+
return accumulator.pop();
|
|
5298
|
+
});
|
|
5299
|
+
var pretty = (cause, options) => {
|
|
5300
|
+
if (isInterruptedOnly(cause)) {
|
|
5301
|
+
return "All fibers interrupted without errors.";
|
|
5302
|
+
}
|
|
5303
|
+
return prettyErrors(cause).map(function(e) {
|
|
5304
|
+
if (options?.renderErrorCause !== true || e.cause === void 0) {
|
|
5305
|
+
return e.stack;
|
|
5306
|
+
}
|
|
5307
|
+
return `${e.stack} {
|
|
5308
|
+
${renderErrorCause(e.cause, " ")}
|
|
5309
|
+
}`;
|
|
5310
|
+
}).join("\n");
|
|
5311
|
+
};
|
|
5312
|
+
var renderErrorCause = (cause, prefix) => {
|
|
5313
|
+
const lines = cause.stack.split("\n");
|
|
5314
|
+
let stack = `${prefix}[cause]: ${lines[0]}`;
|
|
5315
|
+
for (let i = 1, len = lines.length; i < len; i++) {
|
|
5316
|
+
stack += `
|
|
5317
|
+
${prefix}${lines[i]}`;
|
|
5318
|
+
}
|
|
5319
|
+
if (cause.cause) {
|
|
5320
|
+
stack += ` {
|
|
5321
|
+
${renderErrorCause(cause.cause, `${prefix} `)}
|
|
5322
|
+
${prefix}}`;
|
|
5323
|
+
}
|
|
5324
|
+
return stack;
|
|
5325
|
+
};
|
|
5326
|
+
var PrettyError = class _PrettyError extends globalThis.Error {
|
|
5327
|
+
span = void 0;
|
|
5328
|
+
constructor(originalError) {
|
|
5329
|
+
const originalErrorIsObject = typeof originalError === "object" && originalError !== null;
|
|
5330
|
+
const prevLimit = Error.stackTraceLimit;
|
|
5331
|
+
Error.stackTraceLimit = 1;
|
|
5332
|
+
super(prettyErrorMessage(originalError), originalErrorIsObject && "cause" in originalError && typeof originalError.cause !== "undefined" ? {
|
|
5333
|
+
cause: new _PrettyError(originalError.cause)
|
|
5334
|
+
} : void 0);
|
|
5335
|
+
if (this.message === "") {
|
|
5336
|
+
this.message = "An error has occurred";
|
|
5337
|
+
}
|
|
5338
|
+
Error.stackTraceLimit = prevLimit;
|
|
5339
|
+
this.name = originalError instanceof Error ? originalError.name : "Error";
|
|
5340
|
+
if (originalErrorIsObject) {
|
|
5341
|
+
if (spanSymbol in originalError) {
|
|
5342
|
+
this.span = originalError[spanSymbol];
|
|
5343
|
+
}
|
|
5344
|
+
Object.keys(originalError).forEach((key) => {
|
|
5345
|
+
if (!(key in this)) {
|
|
5346
|
+
this[key] = originalError[key];
|
|
5347
|
+
}
|
|
5348
|
+
});
|
|
5349
|
+
}
|
|
5350
|
+
this.stack = prettyErrorStack(`${this.name}: ${this.message}`, originalError instanceof Error && originalError.stack ? originalError.stack : "", this.span);
|
|
5351
|
+
}
|
|
5352
|
+
};
|
|
5353
|
+
var prettyErrorMessage = (u) => {
|
|
5354
|
+
if (typeof u === "string") {
|
|
5355
|
+
return u;
|
|
5356
|
+
}
|
|
5357
|
+
if (typeof u === "object" && u !== null && u instanceof Error) {
|
|
5358
|
+
return u.message;
|
|
5359
|
+
}
|
|
5360
|
+
try {
|
|
5361
|
+
if (hasProperty(u, "toString") && isFunction2(u["toString"]) && u["toString"] !== Object.prototype.toString && u["toString"] !== globalThis.Array.prototype.toString) {
|
|
5362
|
+
return u["toString"]();
|
|
5363
|
+
}
|
|
5364
|
+
} catch {
|
|
5365
|
+
}
|
|
5366
|
+
return stringifyCircular(u);
|
|
5367
|
+
};
|
|
5368
|
+
var locationRegex = /\((.*)\)/g;
|
|
5369
|
+
var spanToTrace = /* @__PURE__ */ globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
5370
|
+
var prettyErrorStack = (message, stack, span) => {
|
|
5371
|
+
const out = [message];
|
|
5372
|
+
const lines = stack.startsWith(message) ? stack.slice(message.length).split("\n") : stack.split("\n");
|
|
5373
|
+
for (let i = 1; i < lines.length; i++) {
|
|
5374
|
+
if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
|
|
5375
|
+
i++;
|
|
5376
|
+
continue;
|
|
5377
|
+
}
|
|
5378
|
+
if (lines[i].includes("Generator.next")) {
|
|
5379
|
+
break;
|
|
5380
|
+
}
|
|
5381
|
+
if (lines[i].includes("effect_internal_function")) {
|
|
5382
|
+
break;
|
|
5383
|
+
}
|
|
5384
|
+
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>"));
|
|
5385
|
+
}
|
|
5386
|
+
if (span) {
|
|
5387
|
+
let current = span;
|
|
5388
|
+
let i = 0;
|
|
5389
|
+
while (current && current._tag === "Span" && i < 10) {
|
|
5390
|
+
const stackFn = spanToTrace.get(current);
|
|
5391
|
+
if (typeof stackFn === "function") {
|
|
5392
|
+
const stack2 = stackFn();
|
|
5393
|
+
if (typeof stack2 === "string") {
|
|
5394
|
+
const locationMatchAll = stack2.matchAll(locationRegex);
|
|
5395
|
+
let match3 = false;
|
|
5396
|
+
for (const [, location] of locationMatchAll) {
|
|
5397
|
+
match3 = true;
|
|
5398
|
+
out.push(` at ${current.name} (${location})`);
|
|
5399
|
+
}
|
|
5400
|
+
if (!match3) {
|
|
5401
|
+
out.push(` at ${current.name} (${stack2.replace(/^at /, "")})`);
|
|
5402
|
+
}
|
|
5403
|
+
} else {
|
|
5404
|
+
out.push(` at ${current.name}`);
|
|
5405
|
+
}
|
|
5406
|
+
} else {
|
|
5407
|
+
out.push(` at ${current.name}`);
|
|
5408
|
+
}
|
|
5409
|
+
current = getOrUndefined(current.parent);
|
|
5410
|
+
i++;
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
return out.join("\n");
|
|
5414
|
+
};
|
|
5415
|
+
var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
|
|
5416
|
+
var prettyErrors = (cause) => reduceWithContext(cause, void 0, {
|
|
5417
|
+
emptyCase: () => [],
|
|
5418
|
+
dieCase: (_, unknownError) => {
|
|
5419
|
+
return [new PrettyError(unknownError)];
|
|
5420
|
+
},
|
|
5421
|
+
failCase: (_, error) => {
|
|
5422
|
+
return [new PrettyError(error)];
|
|
5423
|
+
},
|
|
5424
|
+
interruptCase: () => [],
|
|
5425
|
+
parallelCase: (_, l, r) => [...l, ...r],
|
|
5426
|
+
sequentialCase: (_, l, r) => [...l, ...r]
|
|
5427
|
+
});
|
|
5428
|
+
|
|
5429
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/singleShotGen.js
|
|
5430
|
+
var SingleShotGen3 = class _SingleShotGen {
|
|
5431
|
+
self;
|
|
5432
|
+
called = false;
|
|
5433
|
+
constructor(self) {
|
|
5434
|
+
this.self = self;
|
|
5435
|
+
}
|
|
5436
|
+
next(a) {
|
|
5437
|
+
return this.called ? {
|
|
5438
|
+
value: a,
|
|
5439
|
+
done: true
|
|
5440
|
+
} : (this.called = true, {
|
|
5441
|
+
value: this.self,
|
|
5442
|
+
done: false
|
|
5443
|
+
});
|
|
5444
|
+
}
|
|
5445
|
+
return(a) {
|
|
5446
|
+
return {
|
|
5447
|
+
value: a,
|
|
5448
|
+
done: true
|
|
5449
|
+
};
|
|
5450
|
+
}
|
|
5451
|
+
throw(e) {
|
|
5452
|
+
throw e;
|
|
5453
|
+
}
|
|
5454
|
+
[Symbol.iterator]() {
|
|
5455
|
+
return new _SingleShotGen(this.self);
|
|
5456
|
+
}
|
|
5457
|
+
};
|
|
5458
|
+
|
|
5459
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/core.js
|
|
5460
|
+
var EffectTypeId2 = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
5461
|
+
var EffectPrimitive = class {
|
|
5462
|
+
_op;
|
|
5463
|
+
effect_instruction_i0 = void 0;
|
|
5464
|
+
effect_instruction_i1 = void 0;
|
|
5465
|
+
effect_instruction_i2 = void 0;
|
|
5466
|
+
trace = void 0;
|
|
5467
|
+
[EffectTypeId2] = effectVariance;
|
|
5468
|
+
constructor(_op) {
|
|
5469
|
+
this._op = _op;
|
|
5470
|
+
}
|
|
5471
|
+
[symbol2](that) {
|
|
5472
|
+
return this === that;
|
|
5473
|
+
}
|
|
5474
|
+
[symbol]() {
|
|
5475
|
+
return cached(this, random(this));
|
|
5476
|
+
}
|
|
5477
|
+
pipe() {
|
|
5478
|
+
return pipeArguments(this, arguments);
|
|
5479
|
+
}
|
|
5480
|
+
toJSON() {
|
|
5481
|
+
return {
|
|
5482
|
+
_id: "Effect",
|
|
5483
|
+
_op: this._op,
|
|
5484
|
+
effect_instruction_i0: toJSON(this.effect_instruction_i0),
|
|
5485
|
+
effect_instruction_i1: toJSON(this.effect_instruction_i1),
|
|
5486
|
+
effect_instruction_i2: toJSON(this.effect_instruction_i2)
|
|
5487
|
+
};
|
|
5488
|
+
}
|
|
5489
|
+
toString() {
|
|
5490
|
+
return format(this.toJSON());
|
|
5491
|
+
}
|
|
5492
|
+
[NodeInspectSymbol]() {
|
|
5493
|
+
return this.toJSON();
|
|
5494
|
+
}
|
|
5495
|
+
[Symbol.iterator]() {
|
|
5496
|
+
return new SingleShotGen3(new YieldWrap(this));
|
|
5497
|
+
}
|
|
5498
|
+
};
|
|
5499
|
+
var EffectPrimitiveFailure = class {
|
|
5500
|
+
_op;
|
|
5501
|
+
effect_instruction_i0 = void 0;
|
|
5502
|
+
effect_instruction_i1 = void 0;
|
|
5503
|
+
effect_instruction_i2 = void 0;
|
|
5504
|
+
trace = void 0;
|
|
5505
|
+
[EffectTypeId2] = effectVariance;
|
|
5506
|
+
constructor(_op) {
|
|
5507
|
+
this._op = _op;
|
|
5508
|
+
this._tag = _op;
|
|
5509
|
+
}
|
|
5510
|
+
[symbol2](that) {
|
|
5511
|
+
return exitIsExit(that) && that._op === "Failure" && // @ts-expect-error
|
|
5512
|
+
equals(this.effect_instruction_i0, that.effect_instruction_i0);
|
|
5513
|
+
}
|
|
5514
|
+
[symbol]() {
|
|
5515
|
+
return pipe(
|
|
5516
|
+
// @ts-expect-error
|
|
5517
|
+
string(this._tag),
|
|
5518
|
+
// @ts-expect-error
|
|
5519
|
+
combine(hash(this.effect_instruction_i0)),
|
|
5520
|
+
cached(this)
|
|
5521
|
+
);
|
|
5522
|
+
}
|
|
5523
|
+
get cause() {
|
|
5524
|
+
return this.effect_instruction_i0;
|
|
5525
|
+
}
|
|
5526
|
+
pipe() {
|
|
5527
|
+
return pipeArguments(this, arguments);
|
|
5528
|
+
}
|
|
5529
|
+
toJSON() {
|
|
5530
|
+
return {
|
|
5531
|
+
_id: "Exit",
|
|
5532
|
+
_tag: this._op,
|
|
5533
|
+
cause: this.cause.toJSON()
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
toString() {
|
|
5537
|
+
return format(this.toJSON());
|
|
5538
|
+
}
|
|
5539
|
+
[NodeInspectSymbol]() {
|
|
5540
|
+
return this.toJSON();
|
|
5541
|
+
}
|
|
5542
|
+
[Symbol.iterator]() {
|
|
5543
|
+
return new SingleShotGen3(new YieldWrap(this));
|
|
5544
|
+
}
|
|
5545
|
+
};
|
|
5546
|
+
var EffectPrimitiveSuccess = class {
|
|
5547
|
+
_op;
|
|
5548
|
+
effect_instruction_i0 = void 0;
|
|
5549
|
+
effect_instruction_i1 = void 0;
|
|
5550
|
+
effect_instruction_i2 = void 0;
|
|
5551
|
+
trace = void 0;
|
|
5552
|
+
[EffectTypeId2] = effectVariance;
|
|
5553
|
+
constructor(_op) {
|
|
5554
|
+
this._op = _op;
|
|
5555
|
+
this._tag = _op;
|
|
5556
|
+
}
|
|
5557
|
+
[symbol2](that) {
|
|
5558
|
+
return exitIsExit(that) && that._op === "Success" && // @ts-expect-error
|
|
5559
|
+
equals(this.effect_instruction_i0, that.effect_instruction_i0);
|
|
5560
|
+
}
|
|
5561
|
+
[symbol]() {
|
|
5562
|
+
return pipe(
|
|
5563
|
+
// @ts-expect-error
|
|
5564
|
+
string(this._tag),
|
|
5565
|
+
// @ts-expect-error
|
|
5566
|
+
combine(hash(this.effect_instruction_i0)),
|
|
5567
|
+
cached(this)
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
5570
|
+
get value() {
|
|
5571
|
+
return this.effect_instruction_i0;
|
|
5572
|
+
}
|
|
5573
|
+
pipe() {
|
|
5574
|
+
return pipeArguments(this, arguments);
|
|
5575
|
+
}
|
|
5576
|
+
toJSON() {
|
|
5577
|
+
return {
|
|
5578
|
+
_id: "Exit",
|
|
5579
|
+
_tag: this._op,
|
|
5580
|
+
value: toJSON(this.value)
|
|
5581
|
+
};
|
|
5582
|
+
}
|
|
5583
|
+
toString() {
|
|
5584
|
+
return format(this.toJSON());
|
|
5585
|
+
}
|
|
5586
|
+
[NodeInspectSymbol]() {
|
|
5587
|
+
return this.toJSON();
|
|
5588
|
+
}
|
|
5589
|
+
[Symbol.iterator]() {
|
|
5590
|
+
return new SingleShotGen3(new YieldWrap(this));
|
|
5591
|
+
}
|
|
5592
|
+
};
|
|
5593
|
+
var isEffect = (u) => hasProperty(u, EffectTypeId2);
|
|
5594
|
+
var withFiberRuntime = (withRuntime) => {
|
|
5595
|
+
const effect = new EffectPrimitive(OP_WITH_RUNTIME);
|
|
5596
|
+
effect.effect_instruction_i0 = withRuntime;
|
|
5597
|
+
return effect;
|
|
5598
|
+
};
|
|
5599
|
+
var originalSymbol = /* @__PURE__ */ Symbol.for("effect/OriginalAnnotation");
|
|
5600
|
+
var capture = (obj, span) => {
|
|
5601
|
+
if (isSome2(span)) {
|
|
5602
|
+
return new Proxy(obj, {
|
|
5603
|
+
has(target, p) {
|
|
5604
|
+
return p === spanSymbol || p === originalSymbol || p in target;
|
|
5605
|
+
},
|
|
5606
|
+
get(target, p) {
|
|
5607
|
+
if (p === spanSymbol) {
|
|
5608
|
+
return span.value;
|
|
5609
|
+
}
|
|
5610
|
+
if (p === originalSymbol) {
|
|
5611
|
+
return obj;
|
|
5612
|
+
}
|
|
5613
|
+
return target[p];
|
|
5614
|
+
}
|
|
5615
|
+
});
|
|
5616
|
+
}
|
|
5617
|
+
return obj;
|
|
5618
|
+
};
|
|
5619
|
+
var fail3 = (error) => isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber) => failCause(fail2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail2(error));
|
|
5620
|
+
var failCause = (cause) => {
|
|
5621
|
+
const effect = new EffectPrimitiveFailure(OP_FAILURE);
|
|
5622
|
+
effect.effect_instruction_i0 = cause;
|
|
5623
|
+
return effect;
|
|
5624
|
+
};
|
|
5625
|
+
var logLevelAll = {
|
|
5626
|
+
_tag: "All",
|
|
5627
|
+
syslog: 0,
|
|
5628
|
+
label: "ALL",
|
|
5629
|
+
ordinal: Number.MIN_SAFE_INTEGER,
|
|
5630
|
+
pipe() {
|
|
5631
|
+
return pipeArguments(this, arguments);
|
|
5632
|
+
}
|
|
5633
|
+
};
|
|
5634
|
+
var logLevelNone = {
|
|
5635
|
+
_tag: "None",
|
|
5636
|
+
syslog: 7,
|
|
5637
|
+
label: "OFF",
|
|
5638
|
+
ordinal: Number.MAX_SAFE_INTEGER,
|
|
5639
|
+
pipe() {
|
|
5640
|
+
return pipeArguments(this, arguments);
|
|
5641
|
+
}
|
|
5642
|
+
};
|
|
5643
|
+
var RequestResolverSymbolKey = "effect/RequestResolver";
|
|
5644
|
+
var RequestResolverTypeId = /* @__PURE__ */ Symbol.for(RequestResolverSymbolKey);
|
|
5645
|
+
var requestResolverVariance = {
|
|
5646
|
+
/* c8 ignore next */
|
|
5647
|
+
_A: (_) => _,
|
|
5648
|
+
/* c8 ignore next */
|
|
5649
|
+
_R: (_) => _
|
|
5650
|
+
};
|
|
5651
|
+
var RequestResolverImpl = class _RequestResolverImpl {
|
|
5652
|
+
runAll;
|
|
5653
|
+
target;
|
|
5654
|
+
[RequestResolverTypeId] = requestResolverVariance;
|
|
5655
|
+
constructor(runAll, target) {
|
|
5656
|
+
this.runAll = runAll;
|
|
5657
|
+
this.target = target;
|
|
5658
|
+
}
|
|
5659
|
+
[symbol]() {
|
|
5660
|
+
return cached(this, this.target ? hash(this.target) : random(this));
|
|
5661
|
+
}
|
|
5662
|
+
[symbol2](that) {
|
|
5663
|
+
return this.target ? isRequestResolver(that) && equals(this.target, that.target) : this === that;
|
|
5664
|
+
}
|
|
5665
|
+
identified(...ids) {
|
|
5666
|
+
return new _RequestResolverImpl(this.runAll, fromIterable2(ids));
|
|
5667
|
+
}
|
|
5668
|
+
pipe() {
|
|
5669
|
+
return pipeArguments(this, arguments);
|
|
5670
|
+
}
|
|
5671
|
+
};
|
|
5672
|
+
var isRequestResolver = (u) => hasProperty(u, RequestResolverTypeId);
|
|
5673
|
+
var YieldableError = /* @__PURE__ */ (function() {
|
|
5674
|
+
class YieldableError2 extends globalThis.Error {
|
|
5675
|
+
commit() {
|
|
5676
|
+
return fail3(this);
|
|
5677
|
+
}
|
|
5678
|
+
toJSON() {
|
|
5679
|
+
const obj = {
|
|
5680
|
+
...this
|
|
5681
|
+
};
|
|
5682
|
+
if (this.message) obj.message = this.message;
|
|
5683
|
+
if (this.cause) obj.cause = this.cause;
|
|
5684
|
+
return obj;
|
|
5685
|
+
}
|
|
5686
|
+
[NodeInspectSymbol]() {
|
|
5687
|
+
if (this.toString !== globalThis.Error.prototype.toString) {
|
|
5688
|
+
return this.stack ? `${this.toString()}
|
|
5689
|
+
${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
5690
|
+
} else if ("Bun" in globalThis) {
|
|
5691
|
+
return pretty(fail2(this), {
|
|
5692
|
+
renderErrorCause: true
|
|
5693
|
+
});
|
|
5694
|
+
}
|
|
5695
|
+
return this;
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5698
|
+
Object.assign(YieldableError2.prototype, StructuralCommitPrototype);
|
|
5699
|
+
return YieldableError2;
|
|
5700
|
+
})();
|
|
5701
|
+
var makeException = (proto2, tag) => {
|
|
5702
|
+
class Base extends YieldableError {
|
|
5703
|
+
_tag = tag;
|
|
5704
|
+
}
|
|
5705
|
+
Object.assign(Base.prototype, proto2);
|
|
5706
|
+
Base.prototype.name = tag;
|
|
5707
|
+
return Base;
|
|
5708
|
+
};
|
|
5709
|
+
var RuntimeExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/RuntimeException");
|
|
5710
|
+
var RuntimeException = /* @__PURE__ */ makeException({
|
|
5711
|
+
[RuntimeExceptionTypeId]: RuntimeExceptionTypeId
|
|
5712
|
+
}, "RuntimeException");
|
|
5713
|
+
var InterruptedExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/InterruptedException");
|
|
5714
|
+
var InterruptedException = /* @__PURE__ */ makeException({
|
|
5715
|
+
[InterruptedExceptionTypeId]: InterruptedExceptionTypeId
|
|
5716
|
+
}, "InterruptedException");
|
|
5717
|
+
var IllegalArgumentExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/IllegalArgument");
|
|
5718
|
+
var IllegalArgumentException = /* @__PURE__ */ makeException({
|
|
5719
|
+
[IllegalArgumentExceptionTypeId]: IllegalArgumentExceptionTypeId
|
|
5720
|
+
}, "IllegalArgumentException");
|
|
5721
|
+
var NoSuchElementExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/NoSuchElement");
|
|
5722
|
+
var NoSuchElementException = /* @__PURE__ */ makeException({
|
|
5723
|
+
[NoSuchElementExceptionTypeId]: NoSuchElementExceptionTypeId
|
|
5724
|
+
}, "NoSuchElementException");
|
|
5725
|
+
var InvalidPubSubCapacityExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/InvalidPubSubCapacityException");
|
|
5726
|
+
var InvalidPubSubCapacityException = /* @__PURE__ */ makeException({
|
|
5727
|
+
[InvalidPubSubCapacityExceptionTypeId]: InvalidPubSubCapacityExceptionTypeId
|
|
5728
|
+
}, "InvalidPubSubCapacityException");
|
|
5729
|
+
var ExceededCapacityExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/ExceededCapacityException");
|
|
5730
|
+
var ExceededCapacityException = /* @__PURE__ */ makeException({
|
|
5731
|
+
[ExceededCapacityExceptionTypeId]: ExceededCapacityExceptionTypeId
|
|
5732
|
+
}, "ExceededCapacityException");
|
|
5733
|
+
var TimeoutExceptionTypeId = /* @__PURE__ */ Symbol.for("effect/Cause/errors/Timeout");
|
|
5734
|
+
var TimeoutException = /* @__PURE__ */ makeException({
|
|
5735
|
+
[TimeoutExceptionTypeId]: TimeoutExceptionTypeId
|
|
5736
|
+
}, "TimeoutException");
|
|
5737
|
+
var exitIsExit = (u) => isEffect(u) && "_tag" in u && (u._tag === "Success" || u._tag === "Failure");
|
|
5738
|
+
var currentSpanFromFiber = (fiber) => {
|
|
5739
|
+
const span = fiber.currentSpan;
|
|
5740
|
+
return span !== void 0 && span._tag === "Span" ? some2(span) : none2();
|
|
5741
|
+
};
|
|
5742
|
+
|
|
5743
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Data.js
|
|
5744
|
+
var Class2 = Structural;
|
|
5745
|
+
var Error2 = /* @__PURE__ */ (function() {
|
|
5746
|
+
const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
|
|
5747
|
+
const O = {
|
|
5748
|
+
BaseEffectError: class extends YieldableError {
|
|
5749
|
+
constructor(args2) {
|
|
5750
|
+
super(args2?.message, args2?.cause ? {
|
|
5751
|
+
cause: args2.cause
|
|
5752
|
+
} : void 0);
|
|
5753
|
+
if (args2) {
|
|
5754
|
+
Object.assign(this, args2);
|
|
5755
|
+
Object.defineProperty(this, plainArgsSymbol, {
|
|
5756
|
+
value: args2,
|
|
5757
|
+
enumerable: false
|
|
5758
|
+
});
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
toJSON() {
|
|
5762
|
+
return {
|
|
5763
|
+
...this[plainArgsSymbol],
|
|
5764
|
+
...this
|
|
5765
|
+
};
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
};
|
|
5769
|
+
return O.BaseEffectError;
|
|
5770
|
+
})();
|
|
5771
|
+
var TaggedError = (tag) => {
|
|
5772
|
+
const O = {
|
|
5773
|
+
BaseEffectError: class extends Error2 {
|
|
5774
|
+
_tag = tag;
|
|
5775
|
+
}
|
|
5776
|
+
};
|
|
5777
|
+
O.BaseEffectError.prototype.name = tag;
|
|
5778
|
+
return O.BaseEffectError;
|
|
5779
|
+
};
|
|
5780
|
+
|
|
5781
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
5782
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
5783
|
+
|
|
5784
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
5785
|
+
var encode = (bytes) => {
|
|
5786
|
+
const length = bytes.length;
|
|
5787
|
+
let result = "";
|
|
5788
|
+
let i;
|
|
5789
|
+
for (i = 2; i < length; i += 3) {
|
|
5790
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
5791
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
5792
|
+
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
5793
|
+
result += base64abc[bytes[i] & 63];
|
|
5794
|
+
}
|
|
5795
|
+
if (i === length + 1) {
|
|
5796
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
5797
|
+
result += base64abc[(bytes[i - 2] & 3) << 4];
|
|
5798
|
+
result += "==";
|
|
5799
|
+
}
|
|
5800
|
+
if (i === length) {
|
|
5801
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
5802
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
5803
|
+
result += base64abc[(bytes[i - 1] & 15) << 2];
|
|
5804
|
+
result += "=";
|
|
5805
|
+
}
|
|
5806
|
+
return result;
|
|
5807
|
+
};
|
|
5808
|
+
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
5809
|
+
|
|
5810
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
5811
|
+
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
5812
|
+
|
|
5813
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Encoding.js
|
|
5814
|
+
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
5815
|
+
|
|
5816
|
+
// node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Graph.js
|
|
5817
|
+
var TypeId4 = "~effect/Graph";
|
|
5818
|
+
var Edge = class extends Class2 {
|
|
5819
|
+
};
|
|
5820
|
+
var ProtoGraph = {
|
|
5821
|
+
[TypeId4]: TypeId4,
|
|
5822
|
+
[Symbol.iterator]() {
|
|
5823
|
+
return this.nodes[Symbol.iterator]();
|
|
5824
|
+
},
|
|
5825
|
+
[NodeInspectSymbol]() {
|
|
5826
|
+
return this.toJSON();
|
|
5827
|
+
},
|
|
5828
|
+
[symbol2](that) {
|
|
5829
|
+
if (isGraph(that)) {
|
|
5830
|
+
if (this.nodes.size !== that.nodes.size || this.edges.size !== that.edges.size || this.type !== that.type) {
|
|
5831
|
+
return false;
|
|
5832
|
+
}
|
|
5833
|
+
for (const [nodeIndex, nodeData] of this.nodes) {
|
|
5834
|
+
if (!that.nodes.has(nodeIndex)) {
|
|
5835
|
+
return false;
|
|
5836
|
+
}
|
|
5837
|
+
const otherNodeData = that.nodes.get(nodeIndex);
|
|
5838
|
+
if (!equals(nodeData, otherNodeData)) {
|
|
5839
|
+
return false;
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
for (const [edgeIndex, edgeData] of this.edges) {
|
|
5843
|
+
if (!that.edges.has(edgeIndex)) {
|
|
5844
|
+
return false;
|
|
5845
|
+
}
|
|
5846
|
+
const otherEdge = that.edges.get(edgeIndex);
|
|
5847
|
+
if (!equals(edgeData, otherEdge)) {
|
|
5848
|
+
return false;
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
return true;
|
|
5852
|
+
}
|
|
5853
|
+
return false;
|
|
5854
|
+
},
|
|
5855
|
+
[symbol]() {
|
|
5856
|
+
let hash2 = string("Graph");
|
|
5857
|
+
hash2 = hash2 ^ string(this.type);
|
|
5858
|
+
hash2 = hash2 ^ number(this.nodes.size);
|
|
5859
|
+
hash2 = hash2 ^ number(this.edges.size);
|
|
5860
|
+
for (const [nodeIndex, nodeData] of this.nodes) {
|
|
5861
|
+
hash2 = hash2 ^ hash(nodeIndex) + hash(nodeData);
|
|
5862
|
+
}
|
|
5863
|
+
for (const [edgeIndex, edgeData] of this.edges) {
|
|
5864
|
+
hash2 = hash2 ^ hash(edgeIndex) + hash(edgeData);
|
|
5865
|
+
}
|
|
5866
|
+
return hash2;
|
|
5867
|
+
},
|
|
5868
|
+
toJSON() {
|
|
5869
|
+
return {
|
|
5870
|
+
_id: "Graph",
|
|
5871
|
+
nodeCount: this.nodes.size,
|
|
5872
|
+
edgeCount: this.edges.size,
|
|
5873
|
+
type: this.type
|
|
5874
|
+
};
|
|
5875
|
+
},
|
|
5876
|
+
toString() {
|
|
5877
|
+
return format(this);
|
|
5878
|
+
},
|
|
5879
|
+
pipe() {
|
|
5880
|
+
return pipeArguments(this, arguments);
|
|
5881
|
+
}
|
|
5882
|
+
};
|
|
5883
|
+
var GraphError = class extends (/* @__PURE__ */ TaggedError("GraphError")) {
|
|
5884
|
+
};
|
|
5885
|
+
var missingNode = (node) => new GraphError({
|
|
5886
|
+
message: `Node ${node} does not exist`
|
|
5887
|
+
});
|
|
5888
|
+
var isGraph = (u) => typeof u === "object" && u !== null && TypeId4 in u;
|
|
5889
|
+
var directed = (mutate3) => {
|
|
5890
|
+
const graph = Object.create(ProtoGraph);
|
|
5891
|
+
graph.type = "directed";
|
|
5892
|
+
graph.nodes = /* @__PURE__ */ new Map();
|
|
5893
|
+
graph.edges = /* @__PURE__ */ new Map();
|
|
5894
|
+
graph.adjacency = /* @__PURE__ */ new Map();
|
|
5895
|
+
graph.reverseAdjacency = /* @__PURE__ */ new Map();
|
|
5896
|
+
graph.nextNodeIndex = 0;
|
|
5897
|
+
graph.nextEdgeIndex = 0;
|
|
5898
|
+
graph.isAcyclic = some2(true);
|
|
5899
|
+
graph.mutable = false;
|
|
5900
|
+
if (mutate3) {
|
|
5901
|
+
const mutable = beginMutation3(graph);
|
|
5902
|
+
mutate3(mutable);
|
|
5903
|
+
return endMutation2(mutable);
|
|
5904
|
+
}
|
|
5905
|
+
return graph;
|
|
5906
|
+
};
|
|
5907
|
+
var beginMutation3 = (graph) => {
|
|
5908
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
5909
|
+
const reverseAdjacency = /* @__PURE__ */ new Map();
|
|
5910
|
+
for (const [nodeIndex, edges2] of graph.adjacency) {
|
|
5911
|
+
adjacency.set(nodeIndex, [...edges2]);
|
|
5912
|
+
}
|
|
5913
|
+
for (const [nodeIndex, edges2] of graph.reverseAdjacency) {
|
|
5914
|
+
reverseAdjacency.set(nodeIndex, [...edges2]);
|
|
5915
|
+
}
|
|
5916
|
+
const mutable = Object.create(ProtoGraph);
|
|
5917
|
+
mutable.type = graph.type;
|
|
5918
|
+
mutable.nodes = new Map(graph.nodes);
|
|
5919
|
+
mutable.edges = new Map(graph.edges);
|
|
5920
|
+
mutable.adjacency = adjacency;
|
|
5921
|
+
mutable.reverseAdjacency = reverseAdjacency;
|
|
5922
|
+
mutable.nextNodeIndex = graph.nextNodeIndex;
|
|
5923
|
+
mutable.nextEdgeIndex = graph.nextEdgeIndex;
|
|
5924
|
+
mutable.isAcyclic = graph.isAcyclic;
|
|
5925
|
+
mutable.mutable = true;
|
|
5926
|
+
return mutable;
|
|
5927
|
+
};
|
|
5928
|
+
var endMutation2 = (mutable) => {
|
|
5929
|
+
const graph = Object.create(ProtoGraph);
|
|
5930
|
+
graph.type = mutable.type;
|
|
5931
|
+
graph.nodes = new Map(mutable.nodes);
|
|
5932
|
+
graph.edges = new Map(mutable.edges);
|
|
5933
|
+
graph.adjacency = mutable.adjacency;
|
|
5934
|
+
graph.reverseAdjacency = mutable.reverseAdjacency;
|
|
5935
|
+
graph.nextNodeIndex = mutable.nextNodeIndex;
|
|
5936
|
+
graph.nextEdgeIndex = mutable.nextEdgeIndex;
|
|
5937
|
+
graph.isAcyclic = mutable.isAcyclic;
|
|
5938
|
+
graph.mutable = false;
|
|
5939
|
+
return graph;
|
|
5940
|
+
};
|
|
5941
|
+
var mutate2 = /* @__PURE__ */ dual(2, (graph, f) => {
|
|
5942
|
+
const mutable = beginMutation3(graph);
|
|
5943
|
+
f(mutable);
|
|
5944
|
+
return endMutation2(mutable);
|
|
5945
|
+
});
|
|
5946
|
+
var addNode = (mutable, data) => {
|
|
5947
|
+
const nodeIndex = mutable.nextNodeIndex;
|
|
5948
|
+
mutable.nodes.set(nodeIndex, data);
|
|
5949
|
+
mutable.adjacency.set(nodeIndex, []);
|
|
5950
|
+
mutable.reverseAdjacency.set(nodeIndex, []);
|
|
5951
|
+
mutable.nextNodeIndex = mutable.nextNodeIndex + 1;
|
|
5952
|
+
return nodeIndex;
|
|
5953
|
+
};
|
|
5954
|
+
var getNode = (graph, nodeIndex) => graph.nodes.has(nodeIndex) ? some2(graph.nodes.get(nodeIndex)) : none2();
|
|
5955
|
+
var hasNode = (graph, nodeIndex) => graph.nodes.has(nodeIndex);
|
|
5956
|
+
var nodeCount = (graph) => graph.nodes.size;
|
|
5957
|
+
var reverse3 = (mutable) => {
|
|
5958
|
+
for (const [index, edgeData] of mutable.edges) {
|
|
5959
|
+
mutable.edges.set(index, {
|
|
5960
|
+
source: edgeData.target,
|
|
5961
|
+
target: edgeData.source,
|
|
5962
|
+
data: edgeData.data
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5965
|
+
mutable.adjacency.clear();
|
|
5966
|
+
mutable.reverseAdjacency.clear();
|
|
5967
|
+
for (const [edgeIndex, edgeData] of mutable.edges) {
|
|
5968
|
+
const sourceEdges = mutable.adjacency.get(edgeData.source) || [];
|
|
5969
|
+
sourceEdges.push(edgeIndex);
|
|
5970
|
+
mutable.adjacency.set(edgeData.source, sourceEdges);
|
|
5971
|
+
const targetEdges = mutable.reverseAdjacency.get(edgeData.target) || [];
|
|
5972
|
+
targetEdges.push(edgeIndex);
|
|
5973
|
+
mutable.reverseAdjacency.set(edgeData.target, targetEdges);
|
|
5974
|
+
}
|
|
5975
|
+
mutable.isAcyclic = none2();
|
|
5976
|
+
};
|
|
5977
|
+
var invalidateCycleFlagOnRemoval = (mutable) => {
|
|
5978
|
+
if (isSome2(mutable.isAcyclic) && mutable.isAcyclic.value === false) {
|
|
5979
|
+
mutable.isAcyclic = none2();
|
|
5980
|
+
}
|
|
5981
|
+
};
|
|
5982
|
+
var invalidateCycleFlagOnAddition = (mutable) => {
|
|
5983
|
+
if (isSome2(mutable.isAcyclic) && mutable.isAcyclic.value === true) {
|
|
5984
|
+
mutable.isAcyclic = none2();
|
|
5985
|
+
}
|
|
5986
|
+
};
|
|
5987
|
+
var addEdge = (mutable, source, target, data) => {
|
|
5988
|
+
if (!mutable.nodes.has(source)) {
|
|
5989
|
+
throw missingNode(source);
|
|
5990
|
+
}
|
|
5991
|
+
if (!mutable.nodes.has(target)) {
|
|
5992
|
+
throw missingNode(target);
|
|
5993
|
+
}
|
|
5994
|
+
const edgeIndex = mutable.nextEdgeIndex;
|
|
5995
|
+
const edgeData = new Edge({
|
|
5996
|
+
source,
|
|
5997
|
+
target,
|
|
5998
|
+
data
|
|
5999
|
+
});
|
|
6000
|
+
mutable.edges.set(edgeIndex, edgeData);
|
|
6001
|
+
const sourceAdjacency = mutable.adjacency.get(source);
|
|
6002
|
+
if (sourceAdjacency !== void 0) {
|
|
6003
|
+
sourceAdjacency.push(edgeIndex);
|
|
6004
|
+
}
|
|
6005
|
+
const targetReverseAdjacency = mutable.reverseAdjacency.get(target);
|
|
6006
|
+
if (targetReverseAdjacency !== void 0) {
|
|
6007
|
+
targetReverseAdjacency.push(edgeIndex);
|
|
6008
|
+
}
|
|
6009
|
+
if (mutable.type === "undirected") {
|
|
6010
|
+
const targetAdjacency = mutable.adjacency.get(target);
|
|
6011
|
+
if (targetAdjacency !== void 0) {
|
|
6012
|
+
targetAdjacency.push(edgeIndex);
|
|
6013
|
+
}
|
|
6014
|
+
const sourceReverseAdjacency = mutable.reverseAdjacency.get(source);
|
|
6015
|
+
if (sourceReverseAdjacency !== void 0) {
|
|
6016
|
+
sourceReverseAdjacency.push(edgeIndex);
|
|
6017
|
+
}
|
|
6018
|
+
}
|
|
6019
|
+
mutable.nextEdgeIndex = mutable.nextEdgeIndex + 1;
|
|
6020
|
+
invalidateCycleFlagOnAddition(mutable);
|
|
6021
|
+
return edgeIndex;
|
|
6022
|
+
};
|
|
6023
|
+
var removeNode = (mutable, nodeIndex) => {
|
|
6024
|
+
if (!mutable.nodes.has(nodeIndex)) {
|
|
6025
|
+
return;
|
|
6026
|
+
}
|
|
6027
|
+
const edgesToRemove = [];
|
|
6028
|
+
const outgoingEdges = mutable.adjacency.get(nodeIndex);
|
|
6029
|
+
if (outgoingEdges !== void 0) {
|
|
6030
|
+
for (const edge of outgoingEdges) {
|
|
6031
|
+
edgesToRemove.push(edge);
|
|
6032
|
+
}
|
|
6033
|
+
}
|
|
6034
|
+
const incomingEdges = mutable.reverseAdjacency.get(nodeIndex);
|
|
6035
|
+
if (incomingEdges !== void 0) {
|
|
6036
|
+
for (const edge of incomingEdges) {
|
|
6037
|
+
edgesToRemove.push(edge);
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
for (const edgeIndex of edgesToRemove) {
|
|
6041
|
+
removeEdgeInternal(mutable, edgeIndex);
|
|
6042
|
+
}
|
|
6043
|
+
mutable.nodes.delete(nodeIndex);
|
|
6044
|
+
mutable.adjacency.delete(nodeIndex);
|
|
6045
|
+
mutable.reverseAdjacency.delete(nodeIndex);
|
|
6046
|
+
invalidateCycleFlagOnRemoval(mutable);
|
|
6047
|
+
};
|
|
6048
|
+
var removeEdgeInternal = (mutable, edgeIndex) => {
|
|
6049
|
+
const edge = mutable.edges.get(edgeIndex);
|
|
6050
|
+
if (edge === void 0) {
|
|
6051
|
+
return false;
|
|
6052
|
+
}
|
|
6053
|
+
const {
|
|
6054
|
+
source,
|
|
6055
|
+
target
|
|
6056
|
+
} = edge;
|
|
6057
|
+
const sourceAdjacency = mutable.adjacency.get(source);
|
|
6058
|
+
if (sourceAdjacency !== void 0) {
|
|
6059
|
+
const index = sourceAdjacency.indexOf(edgeIndex);
|
|
6060
|
+
if (index !== -1) {
|
|
6061
|
+
sourceAdjacency.splice(index, 1);
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
const targetReverseAdjacency = mutable.reverseAdjacency.get(target);
|
|
6065
|
+
if (targetReverseAdjacency !== void 0) {
|
|
6066
|
+
const index = targetReverseAdjacency.indexOf(edgeIndex);
|
|
6067
|
+
if (index !== -1) {
|
|
6068
|
+
targetReverseAdjacency.splice(index, 1);
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6071
|
+
if (mutable.type === "undirected") {
|
|
6072
|
+
const targetAdjacency = mutable.adjacency.get(target);
|
|
6073
|
+
if (targetAdjacency !== void 0) {
|
|
6074
|
+
const index = targetAdjacency.indexOf(edgeIndex);
|
|
6075
|
+
if (index !== -1) {
|
|
6076
|
+
targetAdjacency.splice(index, 1);
|
|
6077
|
+
}
|
|
6078
|
+
}
|
|
6079
|
+
const sourceReverseAdjacency = mutable.reverseAdjacency.get(source);
|
|
6080
|
+
if (sourceReverseAdjacency !== void 0) {
|
|
6081
|
+
const index = sourceReverseAdjacency.indexOf(edgeIndex);
|
|
6082
|
+
if (index !== -1) {
|
|
6083
|
+
sourceReverseAdjacency.splice(index, 1);
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
mutable.edges.delete(edgeIndex);
|
|
6088
|
+
return true;
|
|
6089
|
+
};
|
|
6090
|
+
var neighborsDirected = (graph, nodeIndex, direction) => {
|
|
6091
|
+
const adjacencyMap = direction === "incoming" ? graph.reverseAdjacency : graph.adjacency;
|
|
6092
|
+
const adjacencyList = adjacencyMap.get(nodeIndex);
|
|
6093
|
+
if (adjacencyList === void 0) {
|
|
6094
|
+
return [];
|
|
6095
|
+
}
|
|
6096
|
+
const result = [];
|
|
6097
|
+
for (const edgeIndex of adjacencyList) {
|
|
6098
|
+
const edge = graph.edges.get(edgeIndex);
|
|
6099
|
+
if (edge !== void 0) {
|
|
6100
|
+
const neighborNode = direction === "incoming" ? edge.source : edge.target;
|
|
6101
|
+
result.push(neighborNode);
|
|
6102
|
+
}
|
|
6103
|
+
}
|
|
6104
|
+
return result;
|
|
6105
|
+
};
|
|
6106
|
+
var escapeMermaidLabel = (label) => {
|
|
6107
|
+
return label.replace(/#/g, "#35;").replace(/"/g, "#quot;").replace(/</g, "#lt;").replace(/>/g, "#gt;").replace(/&/g, "#amp;").replace(/\[/g, "#91;").replace(/\]/g, "#93;").replace(/\{/g, "#123;").replace(/\}/g, "#125;").replace(/\(/g, "#40;").replace(/\)/g, "#41;").replace(/\|/g, "#124;").replace(/\\/g, "#92;").replace(/\n/g, "<br/>");
|
|
6108
|
+
};
|
|
6109
|
+
var formatMermaidNode = (nodeId, label, shape) => {
|
|
6110
|
+
switch (shape) {
|
|
6111
|
+
case "rectangle":
|
|
6112
|
+
return `${nodeId}["${label}"]`;
|
|
6113
|
+
case "rounded":
|
|
6114
|
+
return `${nodeId}("${label}")`;
|
|
6115
|
+
case "circle":
|
|
6116
|
+
return `${nodeId}(("${label}"))`;
|
|
6117
|
+
case "diamond":
|
|
6118
|
+
return `${nodeId}{"${label}"}`;
|
|
6119
|
+
case "hexagon":
|
|
6120
|
+
return `${nodeId}{{"${label}"}}`;
|
|
6121
|
+
case "stadium":
|
|
6122
|
+
return `${nodeId}(["${label}"])`;
|
|
6123
|
+
case "subroutine":
|
|
6124
|
+
return `${nodeId}[["${label}"]]`;
|
|
6125
|
+
case "cylindrical":
|
|
6126
|
+
return `${nodeId}[("${label}")]`;
|
|
6127
|
+
}
|
|
6128
|
+
};
|
|
6129
|
+
var toMermaid = (graph, options) => {
|
|
6130
|
+
const {
|
|
6131
|
+
diagramType,
|
|
6132
|
+
direction = "TD",
|
|
6133
|
+
edgeLabel = (data) => String(data),
|
|
6134
|
+
nodeLabel = (data) => String(data),
|
|
6135
|
+
nodeShape = () => "rectangle"
|
|
6136
|
+
} = options ?? {};
|
|
6137
|
+
const finalDiagramType = diagramType ?? (graph.type === "directed" ? "flowchart" : "graph");
|
|
6138
|
+
const lines = [];
|
|
6139
|
+
lines.push(`${finalDiagramType} ${direction}`);
|
|
6140
|
+
for (const [nodeIndex, nodeData] of graph.nodes) {
|
|
6141
|
+
const nodeId = String(nodeIndex);
|
|
6142
|
+
const label = escapeMermaidLabel(nodeLabel(nodeData));
|
|
6143
|
+
const shape = nodeShape(nodeData);
|
|
6144
|
+
const formattedNode = formatMermaidNode(nodeId, label, shape);
|
|
6145
|
+
lines.push(` ${formattedNode}`);
|
|
6146
|
+
}
|
|
6147
|
+
const edgeOperator = finalDiagramType === "flowchart" ? "-->" : "---";
|
|
6148
|
+
for (const [, edgeData] of graph.edges) {
|
|
6149
|
+
const sourceId = String(edgeData.source);
|
|
6150
|
+
const targetId = String(edgeData.target);
|
|
6151
|
+
const label = escapeMermaidLabel(edgeLabel(edgeData.data));
|
|
6152
|
+
if (label) {
|
|
6153
|
+
lines.push(` ${sourceId} ${edgeOperator}|"${label}"| ${targetId}`);
|
|
6154
|
+
} else {
|
|
6155
|
+
lines.push(` ${sourceId} ${edgeOperator} ${targetId}`);
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
return lines.join("\n");
|
|
6159
|
+
};
|
|
6160
|
+
var Walker = class {
|
|
6161
|
+
// @ts-ignore
|
|
6162
|
+
[Symbol.iterator];
|
|
6163
|
+
/**
|
|
6164
|
+
* Visits each element and maps it to a value using the provided function.
|
|
6165
|
+
*
|
|
6166
|
+
* Takes a function that receives the index and data,
|
|
6167
|
+
* and returns an iterable of the mapped values. Skips elements that
|
|
6168
|
+
* no longer exist in the graph.
|
|
6169
|
+
*
|
|
6170
|
+
* @example
|
|
6171
|
+
* ```ts
|
|
6172
|
+
* import { Graph } from "effect"
|
|
6173
|
+
*
|
|
6174
|
+
* const graph = Graph.directed<string, number>((mutable) => {
|
|
6175
|
+
* const a = Graph.addNode(mutable, "A")
|
|
6176
|
+
* const b = Graph.addNode(mutable, "B")
|
|
6177
|
+
* Graph.addEdge(mutable, a, b, 1)
|
|
6178
|
+
* })
|
|
6179
|
+
*
|
|
6180
|
+
* const dfs = Graph.dfs(graph, { start: [0] })
|
|
6181
|
+
*
|
|
6182
|
+
* // Map to just the node data
|
|
6183
|
+
* const values = Array.from(dfs.visit((index, data) => data))
|
|
6184
|
+
* console.log(values) // ["A", "B"]
|
|
6185
|
+
*
|
|
6186
|
+
* // Map to custom objects
|
|
6187
|
+
* const custom = Array.from(dfs.visit((index, data) => ({ id: index, name: data })))
|
|
6188
|
+
* console.log(custom) // [{ id: 0, name: "A" }, { id: 1, name: "B" }]
|
|
6189
|
+
* ```
|
|
6190
|
+
*
|
|
6191
|
+
* @since 3.18.0
|
|
6192
|
+
* @category iterators
|
|
6193
|
+
*/
|
|
6194
|
+
visit;
|
|
6195
|
+
constructor(visit) {
|
|
6196
|
+
this.visit = visit;
|
|
6197
|
+
this[Symbol.iterator] = visit((index, data) => [index, data])[Symbol.iterator];
|
|
6198
|
+
}
|
|
6199
|
+
};
|
|
6200
|
+
var indices = (walker) => walker.visit((index, _) => index);
|
|
6201
|
+
var values2 = (walker) => walker.visit((_, data) => data);
|
|
6202
|
+
var entries = (walker) => walker.visit((index, data) => [index, data]);
|
|
6203
|
+
var dfsPostOrder = (graph, config = {}) => {
|
|
6204
|
+
const start = config.start ?? [];
|
|
6205
|
+
const direction = config.direction ?? "outgoing";
|
|
6206
|
+
for (const nodeIndex of start) {
|
|
6207
|
+
if (!hasNode(graph, nodeIndex)) {
|
|
6208
|
+
throw missingNode(nodeIndex);
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6211
|
+
return new Walker((f) => ({
|
|
6212
|
+
[Symbol.iterator]: () => {
|
|
6213
|
+
const stack = [];
|
|
6214
|
+
const discovered = /* @__PURE__ */ new Set();
|
|
6215
|
+
const finished = /* @__PURE__ */ new Set();
|
|
6216
|
+
for (let i = start.length - 1; i >= 0; i--) {
|
|
6217
|
+
stack.push({
|
|
6218
|
+
node: start[i],
|
|
6219
|
+
visitedChildren: false
|
|
6220
|
+
});
|
|
6221
|
+
}
|
|
6222
|
+
const nextMapped = () => {
|
|
6223
|
+
while (stack.length > 0) {
|
|
6224
|
+
const current = stack[stack.length - 1];
|
|
6225
|
+
if (!discovered.has(current.node)) {
|
|
6226
|
+
discovered.add(current.node);
|
|
6227
|
+
current.visitedChildren = false;
|
|
6228
|
+
}
|
|
6229
|
+
if (!current.visitedChildren) {
|
|
6230
|
+
current.visitedChildren = true;
|
|
6231
|
+
const neighbors = neighborsDirected(graph, current.node, direction);
|
|
6232
|
+
for (let i = neighbors.length - 1; i >= 0; i--) {
|
|
6233
|
+
const neighbor = neighbors[i];
|
|
6234
|
+
if (!discovered.has(neighbor) && !finished.has(neighbor)) {
|
|
6235
|
+
stack.push({
|
|
6236
|
+
node: neighbor,
|
|
6237
|
+
visitedChildren: false
|
|
6238
|
+
});
|
|
6239
|
+
}
|
|
6240
|
+
}
|
|
6241
|
+
} else {
|
|
6242
|
+
const nodeToEmit = stack.pop().node;
|
|
6243
|
+
if (!finished.has(nodeToEmit)) {
|
|
6244
|
+
finished.add(nodeToEmit);
|
|
6245
|
+
const nodeData = getNode(graph, nodeToEmit);
|
|
6246
|
+
if (isSome2(nodeData)) {
|
|
6247
|
+
return {
|
|
6248
|
+
done: false,
|
|
6249
|
+
value: f(nodeToEmit, nodeData.value)
|
|
6250
|
+
};
|
|
6251
|
+
}
|
|
6252
|
+
return nextMapped();
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
return {
|
|
6257
|
+
done: true,
|
|
6258
|
+
value: void 0
|
|
6259
|
+
};
|
|
6260
|
+
};
|
|
6261
|
+
return {
|
|
6262
|
+
next: nextMapped
|
|
6263
|
+
};
|
|
6264
|
+
}
|
|
6265
|
+
}));
|
|
6266
|
+
};
|
|
6267
|
+
var nodes = (graph) => new Walker((f) => ({
|
|
6268
|
+
[Symbol.iterator]() {
|
|
6269
|
+
const nodeMap = graph.nodes;
|
|
6270
|
+
const iterator = nodeMap.entries();
|
|
6271
|
+
return {
|
|
6272
|
+
next() {
|
|
6273
|
+
const result = iterator.next();
|
|
6274
|
+
if (result.done) {
|
|
6275
|
+
return {
|
|
6276
|
+
done: true,
|
|
6277
|
+
value: void 0
|
|
6278
|
+
};
|
|
6279
|
+
}
|
|
6280
|
+
const [nodeIndex, nodeData] = result.value;
|
|
6281
|
+
return {
|
|
6282
|
+
done: false,
|
|
6283
|
+
value: f(nodeIndex, nodeData)
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
6286
|
+
};
|
|
6287
|
+
}
|
|
6288
|
+
}));
|
|
6289
|
+
var edges = (graph) => new Walker((f) => ({
|
|
6290
|
+
[Symbol.iterator]() {
|
|
6291
|
+
const edgeMap = graph.edges;
|
|
6292
|
+
const iterator = edgeMap.entries();
|
|
6293
|
+
return {
|
|
6294
|
+
next() {
|
|
6295
|
+
const result = iterator.next();
|
|
6296
|
+
if (result.done) {
|
|
6297
|
+
return {
|
|
6298
|
+
done: true,
|
|
6299
|
+
value: void 0
|
|
6300
|
+
};
|
|
6301
|
+
}
|
|
6302
|
+
const [edgeIndex, edgeData] = result.value;
|
|
6303
|
+
return {
|
|
6304
|
+
done: false,
|
|
6305
|
+
value: f(edgeIndex, edgeData)
|
|
6306
|
+
};
|
|
6307
|
+
}
|
|
6308
|
+
};
|
|
6309
|
+
}
|
|
6310
|
+
}));
|
|
6311
|
+
var externals = (graph, config = {}) => {
|
|
6312
|
+
const direction = config.direction ?? "outgoing";
|
|
6313
|
+
return new Walker((f) => ({
|
|
6314
|
+
[Symbol.iterator]: () => {
|
|
6315
|
+
const nodeMap = graph.nodes;
|
|
6316
|
+
const adjacencyMap = direction === "incoming" ? graph.reverseAdjacency : graph.adjacency;
|
|
6317
|
+
const nodeIterator = nodeMap.entries();
|
|
6318
|
+
const nextMapped = () => {
|
|
6319
|
+
let current = nodeIterator.next();
|
|
6320
|
+
while (!current.done) {
|
|
6321
|
+
const [nodeIndex, nodeData] = current.value;
|
|
6322
|
+
const adjacencyList = adjacencyMap.get(nodeIndex);
|
|
6323
|
+
if (adjacencyList === void 0 || adjacencyList.length === 0) {
|
|
6324
|
+
return {
|
|
6325
|
+
done: false,
|
|
6326
|
+
value: f(nodeIndex, nodeData)
|
|
6327
|
+
};
|
|
6328
|
+
}
|
|
6329
|
+
current = nodeIterator.next();
|
|
6330
|
+
}
|
|
6331
|
+
return {
|
|
6332
|
+
done: true,
|
|
6333
|
+
value: void 0
|
|
6334
|
+
};
|
|
6335
|
+
};
|
|
6336
|
+
return {
|
|
6337
|
+
next: nextMapped
|
|
6338
|
+
};
|
|
6339
|
+
}
|
|
6340
|
+
}));
|
|
6341
|
+
};
|
|
6342
|
+
|
|
6343
|
+
// src/diagnostics/classSelfMismatch.ts
|
|
6344
|
+
var classSelfMismatch = createDiagnostic({
|
|
6345
|
+
name: "classSelfMismatch",
|
|
6346
|
+
code: 20,
|
|
6347
|
+
severity: "error",
|
|
6348
|
+
apply: fn("classSelfMismatch.apply")(function* (sourceFile, report) {
|
|
6349
|
+
const ts = yield* service(TypeScriptApi);
|
|
6350
|
+
const typeParser = yield* service(TypeParser);
|
|
6351
|
+
const nodeToVisit = [];
|
|
6352
|
+
const appendNodeToVisit = (node) => {
|
|
6353
|
+
nodeToVisit.push(node);
|
|
6354
|
+
return void 0;
|
|
6355
|
+
};
|
|
6356
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
6357
|
+
while (nodeToVisit.length > 0) {
|
|
6358
|
+
const node = nodeToVisit.shift();
|
|
6359
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
6360
|
+
const result = yield* pipe(
|
|
6361
|
+
typeParser.extendsEffectService(node),
|
|
6362
|
+
orElse2(() => typeParser.extendsContextTag(node)),
|
|
6363
|
+
orElse2(() => typeParser.extendsEffectTag(node)),
|
|
6364
|
+
orElse2(() => typeParser.extendsSchemaClass(node)),
|
|
6365
|
+
orElse2(() => typeParser.extendsSchemaTaggedClass(node)),
|
|
6366
|
+
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
6367
|
+
orElse2(() => typeParser.extendsSchemaTaggedRequest(node)),
|
|
6368
|
+
orElse2(() => void_)
|
|
6369
|
+
);
|
|
6370
|
+
if (result) {
|
|
6371
|
+
const { className, selfTypeNode } = result;
|
|
6372
|
+
let actualName = sourceFile.text.substring(selfTypeNode.pos, selfTypeNode.end);
|
|
6373
|
+
if (ts.isTypeReferenceNode(selfTypeNode)) {
|
|
6374
|
+
if (ts.isIdentifier(selfTypeNode.typeName)) {
|
|
6375
|
+
actualName = ts.idText(selfTypeNode.typeName);
|
|
6376
|
+
} else if (ts.isQualifiedName(selfTypeNode.typeName)) {
|
|
6377
|
+
actualName = ts.idText(selfTypeNode.typeName.right);
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
const expectedName = ts.idText(className);
|
|
6381
|
+
if (actualName !== expectedName) {
|
|
6382
|
+
report({
|
|
6383
|
+
location: selfTypeNode,
|
|
6384
|
+
messageText: `Self type parameter should be '${expectedName}'`,
|
|
6385
|
+
fixes: [{
|
|
6386
|
+
fixName: "classSelfMismatch_fix",
|
|
6387
|
+
description: `Replace '${actualName}' with '${expectedName}'`,
|
|
6388
|
+
apply: gen(function* () {
|
|
6389
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
6390
|
+
const typeArgs = ts.isTypeReferenceNode(selfTypeNode) ? selfTypeNode.typeArguments : void 0;
|
|
6391
|
+
const newTypeReference = ts.factory.createTypeReferenceNode(
|
|
6392
|
+
ts.factory.createIdentifier(expectedName),
|
|
6393
|
+
typeArgs
|
|
6394
|
+
);
|
|
6395
|
+
changeTracker.replaceNode(sourceFile, selfTypeNode, newTypeReference);
|
|
6396
|
+
})
|
|
6397
|
+
}]
|
|
6398
|
+
});
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
6403
|
+
}
|
|
6404
|
+
})
|
|
6405
|
+
});
|
|
6406
|
+
|
|
6407
|
+
// src/diagnostics/deterministicKeys.ts
|
|
6408
|
+
var deterministicKeys = createDiagnostic({
|
|
6409
|
+
name: "deterministicKeys",
|
|
6410
|
+
code: 25,
|
|
6411
|
+
severity: "off",
|
|
6412
|
+
apply: fn("deterministicKeys.apply")(function* (sourceFile, report) {
|
|
6413
|
+
const ts = yield* service(TypeScriptApi);
|
|
6414
|
+
const typeParser = yield* service(TypeParser);
|
|
6415
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
6416
|
+
const typeScriptUtils = yield* service(TypeScriptUtils);
|
|
6417
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
6418
|
+
const parseExtendsCustom = cachedBy(
|
|
6419
|
+
fn("parseExtendsCustom")(function* (classDeclaration) {
|
|
6420
|
+
if (!options.extendedKeyDetection) {
|
|
6421
|
+
return yield* typeParserIssue("Extended key detection is disabled", void 0, classDeclaration);
|
|
4165
6422
|
}
|
|
4166
6423
|
if (!classDeclaration.name) {
|
|
4167
6424
|
return yield* typeParserIssue("Class has no name", void 0, classDeclaration);
|
|
@@ -4373,8 +6630,8 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4373
6630
|
}
|
|
4374
6631
|
return yield* fail(typeParserIssue("expectedEffect success is not void"));
|
|
4375
6632
|
});
|
|
4376
|
-
const
|
|
4377
|
-
for (const [node, expectedType, valueNode, realType] of
|
|
6633
|
+
const entries2 = typeCheckerUtils.expectedAndRealType(sourceFile);
|
|
6634
|
+
for (const [node, expectedType, valueNode, realType] of entries2) {
|
|
4378
6635
|
if (expectedType !== realType) {
|
|
4379
6636
|
yield* pipe(
|
|
4380
6637
|
checkForEffectInVoid(
|
|
@@ -4749,25 +7006,88 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
4749
7006
|
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
4750
7007
|
typesToCheck.push([type, node.name]);
|
|
4751
7008
|
}
|
|
4752
|
-
} else {
|
|
4753
|
-
ts.forEachChild(node, appendNodeToVisit);
|
|
4754
|
-
continue;
|
|
4755
|
-
}
|
|
4756
|
-
for (const [type, reportAt] of typesToCheck) {
|
|
4757
|
-
yield* pipe(
|
|
4758
|
-
typeParser.contextTag(type, node),
|
|
4759
|
-
flatMap2(
|
|
4760
|
-
({ Service }) => pipe(
|
|
4761
|
-
parseLeakedRequirements(Service, node),
|
|
4762
|
-
map5(
|
|
4763
|
-
(requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
|
|
4764
|
-
)
|
|
4765
|
-
)
|
|
4766
|
-
),
|
|
4767
|
-
orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
|
|
4768
|
-
ignore
|
|
4769
|
-
);
|
|
7009
|
+
} else {
|
|
7010
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
7011
|
+
continue;
|
|
7012
|
+
}
|
|
7013
|
+
for (const [type, reportAt] of typesToCheck) {
|
|
7014
|
+
yield* pipe(
|
|
7015
|
+
typeParser.contextTag(type, node),
|
|
7016
|
+
flatMap2(
|
|
7017
|
+
({ Service }) => pipe(
|
|
7018
|
+
parseLeakedRequirements(Service, node),
|
|
7019
|
+
map5(
|
|
7020
|
+
(requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
|
|
7021
|
+
)
|
|
7022
|
+
)
|
|
7023
|
+
),
|
|
7024
|
+
orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
|
|
7025
|
+
ignore
|
|
7026
|
+
);
|
|
7027
|
+
}
|
|
7028
|
+
}
|
|
7029
|
+
})
|
|
7030
|
+
});
|
|
7031
|
+
|
|
7032
|
+
// src/diagnostics/missedPipeableOpportunity.ts
|
|
7033
|
+
var missedPipeableOpportunity = createDiagnostic({
|
|
7034
|
+
name: "missedPipeableOpportunity",
|
|
7035
|
+
code: 26,
|
|
7036
|
+
severity: "off",
|
|
7037
|
+
apply: fn("missedPipeableOpportunity.apply")(function* (sourceFile, report) {
|
|
7038
|
+
const ts = yield* service(TypeScriptApi);
|
|
7039
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
7040
|
+
const typeParser = yield* service(TypeParser);
|
|
7041
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
7042
|
+
const nodeToVisit = [sourceFile];
|
|
7043
|
+
const prependNodeToVisit = (node) => {
|
|
7044
|
+
nodeToVisit.unshift(node);
|
|
7045
|
+
return void 0;
|
|
7046
|
+
};
|
|
7047
|
+
const callChainNodes = /* @__PURE__ */ new WeakMap();
|
|
7048
|
+
while (nodeToVisit.length > 0) {
|
|
7049
|
+
const node = nodeToVisit.shift();
|
|
7050
|
+
if (ts.isCallExpression(node) && node.arguments.length === 1 && node.parent) {
|
|
7051
|
+
const parentChain = callChainNodes.get(node.parent) || [];
|
|
7052
|
+
callChainNodes.set(node, parentChain.concat(node));
|
|
7053
|
+
} else if (node.parent && callChainNodes.has(node.parent) && ts.isExpression(node)) {
|
|
7054
|
+
const parentChain = callChainNodes.get(node.parent) || [];
|
|
7055
|
+
const originalParentChain = parentChain.slice();
|
|
7056
|
+
parentChain.push(node);
|
|
7057
|
+
while (parentChain.length > options.pipeableMinArgCount) {
|
|
7058
|
+
const subject = parentChain.pop();
|
|
7059
|
+
const resultType = typeChecker.getTypeAtLocation(subject);
|
|
7060
|
+
const pipeableType = yield* pipe(typeParser.pipeableType(resultType, subject), orElse2(() => void_));
|
|
7061
|
+
if (pipeableType) {
|
|
7062
|
+
report({
|
|
7063
|
+
location: parentChain[0],
|
|
7064
|
+
messageText: `Nested function calls can be converted to pipeable style for better readability.`,
|
|
7065
|
+
fixes: [{
|
|
7066
|
+
fixName: "missedPipeableOpportunity_fix",
|
|
7067
|
+
description: "Convert to pipe style",
|
|
7068
|
+
apply: gen(function* () {
|
|
7069
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
7070
|
+
changeTracker.replaceNode(
|
|
7071
|
+
sourceFile,
|
|
7072
|
+
parentChain[0],
|
|
7073
|
+
ts.factory.createCallExpression(
|
|
7074
|
+
ts.factory.createPropertyAccessExpression(
|
|
7075
|
+
subject,
|
|
7076
|
+
"pipe"
|
|
7077
|
+
),
|
|
7078
|
+
void 0,
|
|
7079
|
+
parentChain.filter(ts.isCallExpression).map((call) => call.expression)
|
|
7080
|
+
)
|
|
7081
|
+
);
|
|
7082
|
+
})
|
|
7083
|
+
}]
|
|
7084
|
+
});
|
|
7085
|
+
originalParentChain.forEach((node2) => callChainNodes.delete(node2));
|
|
7086
|
+
break;
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
4770
7089
|
}
|
|
7090
|
+
ts.forEachChild(node, prependNodeToVisit);
|
|
4771
7091
|
}
|
|
4772
7092
|
})
|
|
4773
7093
|
});
|
|
@@ -4794,8 +7114,8 @@ var missingEffectContext = createDiagnostic({
|
|
|
4794
7114
|
)
|
|
4795
7115
|
);
|
|
4796
7116
|
const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
|
|
4797
|
-
const
|
|
4798
|
-
for (const [node, expectedType, valueNode, realType] of
|
|
7117
|
+
const entries2 = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
|
|
7118
|
+
for (const [node, expectedType, valueNode, realType] of entries2) {
|
|
4799
7119
|
if (expectedType !== realType) {
|
|
4800
7120
|
yield* pipe(
|
|
4801
7121
|
checkForMissingContextTypes(
|
|
@@ -4860,8 +7180,8 @@ var missingEffectError = createDiagnostic({
|
|
|
4860
7180
|
)
|
|
4861
7181
|
);
|
|
4862
7182
|
const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
|
|
4863
|
-
const
|
|
4864
|
-
for (const [node, expectedType, valueNode, realType] of
|
|
7183
|
+
const entries2 = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
|
|
7184
|
+
for (const [node, expectedType, valueNode, realType] of entries2) {
|
|
4865
7185
|
if (expectedType !== realType) {
|
|
4866
7186
|
yield* pipe(
|
|
4867
7187
|
checkForMissingErrorTypes(
|
|
@@ -5625,9 +7945,9 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
5625
7945
|
return { methodIdentifier };
|
|
5626
7946
|
}
|
|
5627
7947
|
const reportIfLayerRequireScope = (type, node, methodIdentifier) => {
|
|
5628
|
-
const
|
|
7948
|
+
const entries2 = typeCheckerUtils.unrollUnionMembers(type);
|
|
5629
7949
|
return pipe(
|
|
5630
|
-
firstSuccessOf(
|
|
7950
|
+
firstSuccessOf(entries2.map((type2) => typeParser.scopeType(type2, node))),
|
|
5631
7951
|
map5(
|
|
5632
7952
|
() => report({
|
|
5633
7953
|
location: node,
|
|
@@ -5708,29 +8028,29 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
5708
8028
|
while (nodeToVisit.length > 0) {
|
|
5709
8029
|
const node = nodeToVisit.shift();
|
|
5710
8030
|
ts.forEachChild(node, appendNodeToVisit);
|
|
5711
|
-
const
|
|
8031
|
+
const nodes2 = [];
|
|
5712
8032
|
if (ts.isIfStatement(node)) {
|
|
5713
8033
|
conditionChecks.set(node, true);
|
|
5714
|
-
|
|
8034
|
+
nodes2.push(node.expression);
|
|
5715
8035
|
} else if (ts.isWhileStatement(node)) {
|
|
5716
8036
|
conditionChecks.set(node, true);
|
|
5717
|
-
|
|
8037
|
+
nodes2.push(node.expression);
|
|
5718
8038
|
} else if (ts.isConditionalExpression(node)) {
|
|
5719
8039
|
conditionChecks.set(node, true);
|
|
5720
|
-
|
|
8040
|
+
nodes2.push(node.condition);
|
|
5721
8041
|
} else if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {
|
|
5722
8042
|
conditionChecks.set(node, true);
|
|
5723
|
-
|
|
8043
|
+
nodes2.push(node.operand);
|
|
5724
8044
|
} else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
|
|
5725
8045
|
if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
|
|
5726
|
-
|
|
5727
|
-
|
|
8046
|
+
nodes2.push(node.left);
|
|
8047
|
+
nodes2.push(node.right);
|
|
5728
8048
|
} else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
|
|
5729
8049
|
if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
|
|
5730
|
-
|
|
5731
|
-
|
|
8050
|
+
nodes2.push(node.left);
|
|
8051
|
+
nodes2.push(node.right);
|
|
5732
8052
|
}
|
|
5733
|
-
for (const nodeToCheck of
|
|
8053
|
+
for (const nodeToCheck of nodes2) {
|
|
5734
8054
|
if (!nodeToCheck) continue;
|
|
5735
8055
|
if (!conditionChecks.has(nodeToCheck.parent)) continue;
|
|
5736
8056
|
const nodeType = typeChecker.getTypeAtLocation(nodeToCheck);
|
|
@@ -6046,7 +8366,8 @@ var diagnostics = [
|
|
|
6046
8366
|
overriddenSchemaConstructor,
|
|
6047
8367
|
unsupportedServiceAccessors,
|
|
6048
8368
|
nonObjectEffectServiceType,
|
|
6049
|
-
deterministicKeys
|
|
8369
|
+
deterministicKeys,
|
|
8370
|
+
missedPipeableOpportunity
|
|
6050
8371
|
];
|
|
6051
8372
|
|
|
6052
8373
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -6055,9 +8376,9 @@ var effectDiagnosticsComment = createCompletion({
|
|
|
6055
8376
|
apply: fn("effectDiagnosticsComment")(function* (sourceFile, position) {
|
|
6056
8377
|
const ts = yield* service(TypeScriptApi);
|
|
6057
8378
|
const sourceText = sourceFile.text;
|
|
6058
|
-
const
|
|
6059
|
-
if (
|
|
6060
|
-
const lastIndex =
|
|
8379
|
+
const match3 = /(\/\/|\/\*(?:\*?))\s*(@)\s*$/id.exec(sourceText.substring(0, position));
|
|
8380
|
+
if (match3 && match3.indices) {
|
|
8381
|
+
const lastIndex = match3.indices[2][0];
|
|
6061
8382
|
const replacementSpan = {
|
|
6062
8383
|
start: lastIndex,
|
|
6063
8384
|
length: Math.max(0, position - lastIndex)
|
|
@@ -6088,9 +8409,9 @@ var effectJsdocComment = createCompletion({
|
|
|
6088
8409
|
apply: fn("effectJsdocComment")(function* (sourceFile, position) {
|
|
6089
8410
|
const ts = yield* service(TypeScriptApi);
|
|
6090
8411
|
const sourceText = sourceFile.text;
|
|
6091
|
-
const
|
|
6092
|
-
if (
|
|
6093
|
-
const lastIndex =
|
|
8412
|
+
const match3 = /(\/\/|\/\*(?:\*?))\s*(@)\s*$/id.exec(sourceText.substring(0, position));
|
|
8413
|
+
if (match3 && match3.indices) {
|
|
8414
|
+
const lastIndex = match3.indices[2][0];
|
|
6094
8415
|
const replacementSpan = {
|
|
6095
8416
|
start: lastIndex,
|
|
6096
8417
|
length: Math.max(0, position - lastIndex)
|
|
@@ -8085,10 +10406,10 @@ var putShortMSB = (s, b) => {
|
|
|
8085
10406
|
s.pending_buf[s.pending++] = b >>> 8 & 255;
|
|
8086
10407
|
s.pending_buf[s.pending++] = b & 255;
|
|
8087
10408
|
};
|
|
8088
|
-
var read_buf = (strm, buf, start,
|
|
10409
|
+
var read_buf = (strm, buf, start, size4) => {
|
|
8089
10410
|
let len = strm.avail_in;
|
|
8090
|
-
if (len >
|
|
8091
|
-
len =
|
|
10411
|
+
if (len > size4) {
|
|
10412
|
+
len = size4;
|
|
8092
10413
|
}
|
|
8093
10414
|
if (len === 0) {
|
|
8094
10415
|
return 0;
|
|
@@ -8107,7 +10428,7 @@ var read_buf = (strm, buf, start, size) => {
|
|
|
8107
10428
|
var longest_match = (s, cur_match) => {
|
|
8108
10429
|
let chain_length = s.max_chain_length;
|
|
8109
10430
|
let scan = s.strstart;
|
|
8110
|
-
let
|
|
10431
|
+
let match3;
|
|
8111
10432
|
let len;
|
|
8112
10433
|
let best_len = s.prev_length;
|
|
8113
10434
|
let nice_match = s.nice_match;
|
|
@@ -8125,14 +10446,14 @@ var longest_match = (s, cur_match) => {
|
|
|
8125
10446
|
nice_match = s.lookahead;
|
|
8126
10447
|
}
|
|
8127
10448
|
do {
|
|
8128
|
-
|
|
8129
|
-
if (_win[
|
|
10449
|
+
match3 = cur_match;
|
|
10450
|
+
if (_win[match3 + best_len] !== scan_end || _win[match3 + best_len - 1] !== scan_end1 || _win[match3] !== _win[scan] || _win[++match3] !== _win[scan + 1]) {
|
|
8130
10451
|
continue;
|
|
8131
10452
|
}
|
|
8132
10453
|
scan += 2;
|
|
8133
|
-
|
|
10454
|
+
match3++;
|
|
8134
10455
|
do {
|
|
8135
|
-
} while (_win[++scan] === _win[++
|
|
10456
|
+
} while (_win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && scan < strend);
|
|
8136
10457
|
len = MAX_MATCH - (strend - scan);
|
|
8137
10458
|
scan = strend - MAX_MATCH;
|
|
8138
10459
|
if (len > best_len) {
|
|
@@ -8710,11 +11031,11 @@ var deflateReset = (strm) => {
|
|
|
8710
11031
|
}
|
|
8711
11032
|
return ret;
|
|
8712
11033
|
};
|
|
8713
|
-
var deflateSetHeader = (strm,
|
|
11034
|
+
var deflateSetHeader = (strm, head3) => {
|
|
8714
11035
|
if (deflateStateCheck(strm) || strm.state.wrap !== 2) {
|
|
8715
11036
|
return Z_STREAM_ERROR$2;
|
|
8716
11037
|
}
|
|
8717
|
-
strm.state.gzhead =
|
|
11038
|
+
strm.state.gzhead = head3;
|
|
8718
11039
|
return Z_OK$3;
|
|
8719
11040
|
};
|
|
8720
11041
|
var deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
@@ -8868,20 +11189,20 @@ var deflate$2 = (strm, flush) => {
|
|
|
8868
11189
|
let beg = s.pending;
|
|
8869
11190
|
let left3 = (s.gzhead.extra.length & 65535) - s.gzindex;
|
|
8870
11191
|
while (s.pending + left3 > s.pending_buf_size) {
|
|
8871
|
-
let
|
|
8872
|
-
s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex +
|
|
11192
|
+
let copy2 = s.pending_buf_size - s.pending;
|
|
11193
|
+
s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy2), s.pending);
|
|
8873
11194
|
s.pending = s.pending_buf_size;
|
|
8874
11195
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
8875
11196
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
8876
11197
|
}
|
|
8877
|
-
s.gzindex +=
|
|
11198
|
+
s.gzindex += copy2;
|
|
8878
11199
|
flush_pending(strm);
|
|
8879
11200
|
if (s.pending !== 0) {
|
|
8880
11201
|
s.last_flush = -1;
|
|
8881
11202
|
return Z_OK$3;
|
|
8882
11203
|
}
|
|
8883
11204
|
beg = 0;
|
|
8884
|
-
left3 -=
|
|
11205
|
+
left3 -= copy2;
|
|
8885
11206
|
}
|
|
8886
11207
|
let gzhead_extra = new Uint8Array(s.gzhead.extra);
|
|
8887
11208
|
s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left3), s.pending);
|
|
@@ -9833,7 +12154,7 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
9833
12154
|
let mask;
|
|
9834
12155
|
let next;
|
|
9835
12156
|
let base = null;
|
|
9836
|
-
let
|
|
12157
|
+
let match3;
|
|
9837
12158
|
const count = new Uint16Array(MAXBITS + 1);
|
|
9838
12159
|
const offs = new Uint16Array(MAXBITS + 1);
|
|
9839
12160
|
let extra = null;
|
|
@@ -9889,15 +12210,15 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
9889
12210
|
}
|
|
9890
12211
|
if (type === CODES$1) {
|
|
9891
12212
|
base = extra = work;
|
|
9892
|
-
|
|
12213
|
+
match3 = 20;
|
|
9893
12214
|
} else if (type === LENS$1) {
|
|
9894
12215
|
base = lbase;
|
|
9895
12216
|
extra = lext;
|
|
9896
|
-
|
|
12217
|
+
match3 = 257;
|
|
9897
12218
|
} else {
|
|
9898
12219
|
base = dbase;
|
|
9899
12220
|
extra = dext;
|
|
9900
|
-
|
|
12221
|
+
match3 = 0;
|
|
9901
12222
|
}
|
|
9902
12223
|
huff = 0;
|
|
9903
12224
|
sym = 0;
|
|
@@ -9913,12 +12234,12 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
9913
12234
|
}
|
|
9914
12235
|
for (; ; ) {
|
|
9915
12236
|
here_bits = len - drop;
|
|
9916
|
-
if (work[sym] + 1 <
|
|
12237
|
+
if (work[sym] + 1 < match3) {
|
|
9917
12238
|
here_op = 0;
|
|
9918
12239
|
here_val = work[sym];
|
|
9919
|
-
} else if (work[sym] >=
|
|
9920
|
-
here_op = extra[work[sym] -
|
|
9921
|
-
here_val = base[work[sym] -
|
|
12240
|
+
} else if (work[sym] >= match3) {
|
|
12241
|
+
here_op = extra[work[sym] - match3];
|
|
12242
|
+
here_val = base[work[sym] - match3];
|
|
9922
12243
|
} else {
|
|
9923
12244
|
here_op = 32 + 64;
|
|
9924
12245
|
here_val = 0;
|
|
@@ -10190,7 +12511,7 @@ var fixedtables = (state) => {
|
|
|
10190
12511
|
state.distcode = distfix;
|
|
10191
12512
|
state.distbits = 5;
|
|
10192
12513
|
};
|
|
10193
|
-
var updatewindow = (strm, src, end,
|
|
12514
|
+
var updatewindow = (strm, src, end, copy2) => {
|
|
10194
12515
|
let dist;
|
|
10195
12516
|
const state = strm.state;
|
|
10196
12517
|
if (state.window === null) {
|
|
@@ -10199,20 +12520,20 @@ var updatewindow = (strm, src, end, copy) => {
|
|
|
10199
12520
|
state.whave = 0;
|
|
10200
12521
|
state.window = new Uint8Array(state.wsize);
|
|
10201
12522
|
}
|
|
10202
|
-
if (
|
|
12523
|
+
if (copy2 >= state.wsize) {
|
|
10203
12524
|
state.window.set(src.subarray(end - state.wsize, end), 0);
|
|
10204
12525
|
state.wnext = 0;
|
|
10205
12526
|
state.whave = state.wsize;
|
|
10206
12527
|
} else {
|
|
10207
12528
|
dist = state.wsize - state.wnext;
|
|
10208
|
-
if (dist >
|
|
10209
|
-
dist =
|
|
10210
|
-
}
|
|
10211
|
-
state.window.set(src.subarray(end -
|
|
10212
|
-
|
|
10213
|
-
if (
|
|
10214
|
-
state.window.set(src.subarray(end -
|
|
10215
|
-
state.wnext =
|
|
12529
|
+
if (dist > copy2) {
|
|
12530
|
+
dist = copy2;
|
|
12531
|
+
}
|
|
12532
|
+
state.window.set(src.subarray(end - copy2, end - copy2 + dist), state.wnext);
|
|
12533
|
+
copy2 -= dist;
|
|
12534
|
+
if (copy2) {
|
|
12535
|
+
state.window.set(src.subarray(end - copy2, end), 0);
|
|
12536
|
+
state.wnext = copy2;
|
|
10216
12537
|
state.whave = state.wsize;
|
|
10217
12538
|
} else {
|
|
10218
12539
|
state.wnext += dist;
|
|
@@ -10235,7 +12556,7 @@ var inflate$2 = (strm, flush) => {
|
|
|
10235
12556
|
let hold;
|
|
10236
12557
|
let bits;
|
|
10237
12558
|
let _in, _out;
|
|
10238
|
-
let
|
|
12559
|
+
let copy2;
|
|
10239
12560
|
let from;
|
|
10240
12561
|
let from_source;
|
|
10241
12562
|
let here = 0;
|
|
@@ -10434,11 +12755,11 @@ var inflate$2 = (strm, flush) => {
|
|
|
10434
12755
|
/* falls through */
|
|
10435
12756
|
case EXTRA:
|
|
10436
12757
|
if (state.flags & 1024) {
|
|
10437
|
-
|
|
10438
|
-
if (
|
|
10439
|
-
|
|
12758
|
+
copy2 = state.length;
|
|
12759
|
+
if (copy2 > have) {
|
|
12760
|
+
copy2 = have;
|
|
10440
12761
|
}
|
|
10441
|
-
if (
|
|
12762
|
+
if (copy2) {
|
|
10442
12763
|
if (state.head) {
|
|
10443
12764
|
len = state.head.extra_len - state.length;
|
|
10444
12765
|
if (!state.head.extra) {
|
|
@@ -10449,18 +12770,18 @@ var inflate$2 = (strm, flush) => {
|
|
|
10449
12770
|
next,
|
|
10450
12771
|
// extra field is limited to 65536 bytes
|
|
10451
12772
|
// - no need for additional size check
|
|
10452
|
-
next +
|
|
12773
|
+
next + copy2
|
|
10453
12774
|
),
|
|
10454
12775
|
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
|
10455
12776
|
len
|
|
10456
12777
|
);
|
|
10457
12778
|
}
|
|
10458
12779
|
if (state.flags & 512 && state.wrap & 4) {
|
|
10459
|
-
state.check = crc32_1(state.check, input,
|
|
12780
|
+
state.check = crc32_1(state.check, input, copy2, next);
|
|
10460
12781
|
}
|
|
10461
|
-
have -=
|
|
10462
|
-
next +=
|
|
10463
|
-
state.length -=
|
|
12782
|
+
have -= copy2;
|
|
12783
|
+
next += copy2;
|
|
12784
|
+
state.length -= copy2;
|
|
10464
12785
|
}
|
|
10465
12786
|
if (state.length) {
|
|
10466
12787
|
break inf_leave;
|
|
@@ -10474,18 +12795,18 @@ var inflate$2 = (strm, flush) => {
|
|
|
10474
12795
|
if (have === 0) {
|
|
10475
12796
|
break inf_leave;
|
|
10476
12797
|
}
|
|
10477
|
-
|
|
12798
|
+
copy2 = 0;
|
|
10478
12799
|
do {
|
|
10479
|
-
len = input[next +
|
|
12800
|
+
len = input[next + copy2++];
|
|
10480
12801
|
if (state.head && len && state.length < 65536) {
|
|
10481
12802
|
state.head.name += String.fromCharCode(len);
|
|
10482
12803
|
}
|
|
10483
|
-
} while (len &&
|
|
12804
|
+
} while (len && copy2 < have);
|
|
10484
12805
|
if (state.flags & 512 && state.wrap & 4) {
|
|
10485
|
-
state.check = crc32_1(state.check, input,
|
|
12806
|
+
state.check = crc32_1(state.check, input, copy2, next);
|
|
10486
12807
|
}
|
|
10487
|
-
have -=
|
|
10488
|
-
next +=
|
|
12808
|
+
have -= copy2;
|
|
12809
|
+
next += copy2;
|
|
10489
12810
|
if (len) {
|
|
10490
12811
|
break inf_leave;
|
|
10491
12812
|
}
|
|
@@ -10500,18 +12821,18 @@ var inflate$2 = (strm, flush) => {
|
|
|
10500
12821
|
if (have === 0) {
|
|
10501
12822
|
break inf_leave;
|
|
10502
12823
|
}
|
|
10503
|
-
|
|
12824
|
+
copy2 = 0;
|
|
10504
12825
|
do {
|
|
10505
|
-
len = input[next +
|
|
12826
|
+
len = input[next + copy2++];
|
|
10506
12827
|
if (state.head && len && state.length < 65536) {
|
|
10507
12828
|
state.head.comment += String.fromCharCode(len);
|
|
10508
12829
|
}
|
|
10509
|
-
} while (len &&
|
|
12830
|
+
} while (len && copy2 < have);
|
|
10510
12831
|
if (state.flags & 512 && state.wrap & 4) {
|
|
10511
|
-
state.check = crc32_1(state.check, input,
|
|
12832
|
+
state.check = crc32_1(state.check, input, copy2, next);
|
|
10512
12833
|
}
|
|
10513
|
-
have -=
|
|
10514
|
-
next +=
|
|
12834
|
+
have -= copy2;
|
|
12835
|
+
next += copy2;
|
|
10515
12836
|
if (len) {
|
|
10516
12837
|
break inf_leave;
|
|
10517
12838
|
}
|
|
@@ -10646,23 +12967,23 @@ var inflate$2 = (strm, flush) => {
|
|
|
10646
12967
|
state.mode = COPY;
|
|
10647
12968
|
/* falls through */
|
|
10648
12969
|
case COPY:
|
|
10649
|
-
|
|
10650
|
-
if (
|
|
10651
|
-
if (
|
|
10652
|
-
|
|
12970
|
+
copy2 = state.length;
|
|
12971
|
+
if (copy2) {
|
|
12972
|
+
if (copy2 > have) {
|
|
12973
|
+
copy2 = have;
|
|
10653
12974
|
}
|
|
10654
|
-
if (
|
|
10655
|
-
|
|
12975
|
+
if (copy2 > left3) {
|
|
12976
|
+
copy2 = left3;
|
|
10656
12977
|
}
|
|
10657
|
-
if (
|
|
12978
|
+
if (copy2 === 0) {
|
|
10658
12979
|
break inf_leave;
|
|
10659
12980
|
}
|
|
10660
|
-
output.set(input.subarray(next, next +
|
|
10661
|
-
have -=
|
|
10662
|
-
next +=
|
|
10663
|
-
left3 -=
|
|
10664
|
-
put +=
|
|
10665
|
-
state.length -=
|
|
12981
|
+
output.set(input.subarray(next, next + copy2), put);
|
|
12982
|
+
have -= copy2;
|
|
12983
|
+
next += copy2;
|
|
12984
|
+
left3 -= copy2;
|
|
12985
|
+
put += copy2;
|
|
12986
|
+
state.length -= copy2;
|
|
10666
12987
|
break;
|
|
10667
12988
|
}
|
|
10668
12989
|
state.mode = TYPE;
|
|
@@ -10763,7 +13084,7 @@ var inflate$2 = (strm, flush) => {
|
|
|
10763
13084
|
break;
|
|
10764
13085
|
}
|
|
10765
13086
|
len = state.lens[state.have - 1];
|
|
10766
|
-
|
|
13087
|
+
copy2 = 3 + (hold & 3);
|
|
10767
13088
|
hold >>>= 2;
|
|
10768
13089
|
bits -= 2;
|
|
10769
13090
|
} else if (here_val === 17) {
|
|
@@ -10779,7 +13100,7 @@ var inflate$2 = (strm, flush) => {
|
|
|
10779
13100
|
hold >>>= here_bits;
|
|
10780
13101
|
bits -= here_bits;
|
|
10781
13102
|
len = 0;
|
|
10782
|
-
|
|
13103
|
+
copy2 = 3 + (hold & 7);
|
|
10783
13104
|
hold >>>= 3;
|
|
10784
13105
|
bits -= 3;
|
|
10785
13106
|
} else {
|
|
@@ -10795,16 +13116,16 @@ var inflate$2 = (strm, flush) => {
|
|
|
10795
13116
|
hold >>>= here_bits;
|
|
10796
13117
|
bits -= here_bits;
|
|
10797
13118
|
len = 0;
|
|
10798
|
-
|
|
13119
|
+
copy2 = 11 + (hold & 127);
|
|
10799
13120
|
hold >>>= 7;
|
|
10800
13121
|
bits -= 7;
|
|
10801
13122
|
}
|
|
10802
|
-
if (state.have +
|
|
13123
|
+
if (state.have + copy2 > state.nlen + state.ndist) {
|
|
10803
13124
|
strm.msg = "invalid bit length repeat";
|
|
10804
13125
|
state.mode = BAD;
|
|
10805
13126
|
break;
|
|
10806
13127
|
}
|
|
10807
|
-
while (
|
|
13128
|
+
while (copy2--) {
|
|
10808
13129
|
state.lens[state.have++] = len;
|
|
10809
13130
|
}
|
|
10810
13131
|
}
|
|
@@ -11023,39 +13344,39 @@ var inflate$2 = (strm, flush) => {
|
|
|
11023
13344
|
if (left3 === 0) {
|
|
11024
13345
|
break inf_leave;
|
|
11025
13346
|
}
|
|
11026
|
-
|
|
11027
|
-
if (state.offset >
|
|
11028
|
-
|
|
11029
|
-
if (
|
|
13347
|
+
copy2 = _out - left3;
|
|
13348
|
+
if (state.offset > copy2) {
|
|
13349
|
+
copy2 = state.offset - copy2;
|
|
13350
|
+
if (copy2 > state.whave) {
|
|
11030
13351
|
if (state.sane) {
|
|
11031
13352
|
strm.msg = "invalid distance too far back";
|
|
11032
13353
|
state.mode = BAD;
|
|
11033
13354
|
break;
|
|
11034
13355
|
}
|
|
11035
13356
|
}
|
|
11036
|
-
if (
|
|
11037
|
-
|
|
11038
|
-
from = state.wsize -
|
|
13357
|
+
if (copy2 > state.wnext) {
|
|
13358
|
+
copy2 -= state.wnext;
|
|
13359
|
+
from = state.wsize - copy2;
|
|
11039
13360
|
} else {
|
|
11040
|
-
from = state.wnext -
|
|
13361
|
+
from = state.wnext - copy2;
|
|
11041
13362
|
}
|
|
11042
|
-
if (
|
|
11043
|
-
|
|
13363
|
+
if (copy2 > state.length) {
|
|
13364
|
+
copy2 = state.length;
|
|
11044
13365
|
}
|
|
11045
13366
|
from_source = state.window;
|
|
11046
13367
|
} else {
|
|
11047
13368
|
from_source = output;
|
|
11048
13369
|
from = put - state.offset;
|
|
11049
|
-
|
|
13370
|
+
copy2 = state.length;
|
|
11050
13371
|
}
|
|
11051
|
-
if (
|
|
11052
|
-
|
|
13372
|
+
if (copy2 > left3) {
|
|
13373
|
+
copy2 = left3;
|
|
11053
13374
|
}
|
|
11054
|
-
left3 -=
|
|
11055
|
-
state.length -=
|
|
13375
|
+
left3 -= copy2;
|
|
13376
|
+
state.length -= copy2;
|
|
11056
13377
|
do {
|
|
11057
13378
|
output[put++] = from_source[from++];
|
|
11058
|
-
} while (--
|
|
13379
|
+
} while (--copy2);
|
|
11059
13380
|
if (state.length === 0) {
|
|
11060
13381
|
state.mode = LEN;
|
|
11061
13382
|
}
|
|
@@ -11165,7 +13486,7 @@ var inflateEnd = (strm) => {
|
|
|
11165
13486
|
strm.state = null;
|
|
11166
13487
|
return Z_OK$1;
|
|
11167
13488
|
};
|
|
11168
|
-
var inflateGetHeader = (strm,
|
|
13489
|
+
var inflateGetHeader = (strm, head3) => {
|
|
11169
13490
|
if (inflateStateCheck(strm)) {
|
|
11170
13491
|
return Z_STREAM_ERROR$1;
|
|
11171
13492
|
}
|
|
@@ -11173,8 +13494,8 @@ var inflateGetHeader = (strm, head2) => {
|
|
|
11173
13494
|
if ((state.wrap & 2) === 0) {
|
|
11174
13495
|
return Z_STREAM_ERROR$1;
|
|
11175
13496
|
}
|
|
11176
|
-
state.head =
|
|
11177
|
-
|
|
13497
|
+
state.head = head3;
|
|
13498
|
+
head3.done = false;
|
|
11178
13499
|
return Z_OK$1;
|
|
11179
13500
|
};
|
|
11180
13501
|
var inflateSetDictionary = (strm, dictionary) => {
|
|
@@ -11412,7 +13733,7 @@ var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
|
|
|
11412
13733
|
var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
11413
13734
|
var deflate_1 = deflate;
|
|
11414
13735
|
|
|
11415
|
-
// src/
|
|
13736
|
+
// src/core/LayerGraph.ts
|
|
11416
13737
|
var UnableToProduceLayerGraphError = class {
|
|
11417
13738
|
constructor(message, node) {
|
|
11418
13739
|
this.message = message;
|
|
@@ -11420,250 +13741,419 @@ var UnableToProduceLayerGraphError = class {
|
|
|
11420
13741
|
}
|
|
11421
13742
|
_tag = "@effect/language-service/UnableToProduceLayerGraphError";
|
|
11422
13743
|
};
|
|
11423
|
-
var
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
13744
|
+
var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
13745
|
+
const ts = yield* service(TypeScriptApi);
|
|
13746
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
13747
|
+
const typeParser = yield* service(TypeParser);
|
|
13748
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
13749
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
13750
|
+
const sourceFile = tsUtils.getSourceFileOfNode(node);
|
|
13751
|
+
const layerModuleName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Layer") || "Layer";
|
|
13752
|
+
const visitedNodes = /* @__PURE__ */ new WeakSet();
|
|
13753
|
+
const nodeInPipeContext = /* @__PURE__ */ new WeakSet();
|
|
13754
|
+
const nodeToGraph = /* @__PURE__ */ new WeakMap();
|
|
13755
|
+
const nodeToVisit = [node];
|
|
13756
|
+
const appendNodeToVisit = (node2) => {
|
|
13757
|
+
nodeToVisit.push(node2);
|
|
13758
|
+
return void 0;
|
|
13759
|
+
};
|
|
13760
|
+
const mutableGraph = beginMutation3(directed());
|
|
13761
|
+
const extractNodeInfo = fn("extractNodeInfo")(function* (node2) {
|
|
13762
|
+
let provides = [];
|
|
13763
|
+
let requires = [];
|
|
13764
|
+
let layerType = void 0;
|
|
13765
|
+
let layerTypes = void 0;
|
|
13766
|
+
if (nodeInPipeContext.has(node2)) {
|
|
13767
|
+
if (ts.isExpression(node2)) {
|
|
13768
|
+
const contextualType = typeChecker.getContextualType(node2);
|
|
13769
|
+
if (contextualType) {
|
|
13770
|
+
const callSignatures = typeChecker.getSignaturesOfType(contextualType, ts.SignatureKind.Call);
|
|
13771
|
+
if (callSignatures.length === 1) {
|
|
13772
|
+
layerType = typeChecker.getReturnTypeOfSignature(callSignatures[0]);
|
|
13773
|
+
}
|
|
13774
|
+
}
|
|
11454
13775
|
}
|
|
11455
|
-
|
|
13776
|
+
} else {
|
|
13777
|
+
layerType = typeChecker.getTypeAtLocation(node2);
|
|
11456
13778
|
}
|
|
11457
|
-
if (
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
13779
|
+
if (layerType) {
|
|
13780
|
+
layerTypes = yield* pipe(typeParser.layerType(layerType, node2), orElse2(() => void_));
|
|
13781
|
+
}
|
|
13782
|
+
if (!layerTypes) layerType = void 0;
|
|
13783
|
+
if (layerTypes) {
|
|
13784
|
+
provides = typeCheckerUtils.unrollUnionMembers(layerTypes.ROut).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13785
|
+
requires = typeCheckerUtils.unrollUnionMembers(layerTypes.RIn).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13786
|
+
}
|
|
13787
|
+
return { node: node2, layerType, layerTypes, provides, requires };
|
|
13788
|
+
});
|
|
13789
|
+
const addNode2 = fn("addNode")(function* (node2, nodeInfo) {
|
|
13790
|
+
const graphNode = addNode(mutableGraph, nodeInfo ? nodeInfo : yield* extractNodeInfo(node2));
|
|
13791
|
+
nodeToGraph.set(node2, graphNode);
|
|
13792
|
+
return graphNode;
|
|
13793
|
+
});
|
|
13794
|
+
while (nodeToVisit.length > 0) {
|
|
13795
|
+
const node2 = nodeToVisit.pop();
|
|
13796
|
+
const pipeArgs = yield* pipe(typeParser.pipeCall(node2), orElse2(() => void_));
|
|
13797
|
+
if (pipeArgs) {
|
|
13798
|
+
if (!visitedNodes.has(node2)) {
|
|
13799
|
+
appendNodeToVisit(node2);
|
|
13800
|
+
appendNodeToVisit(pipeArgs.subject);
|
|
13801
|
+
pipeArgs.args.forEach(appendNodeToVisit);
|
|
13802
|
+
pipeArgs.args.forEach((_) => nodeInPipeContext.add(_));
|
|
13803
|
+
visitedNodes.add(node2);
|
|
13804
|
+
} else {
|
|
13805
|
+
const childNodes = [pipeArgs.subject, ...pipeArgs.args].map((_) => nodeToGraph.get(_)).filter(
|
|
13806
|
+
isNumber
|
|
13807
|
+
).filter(
|
|
13808
|
+
(_) => hasNode(mutableGraph, _)
|
|
11463
13809
|
);
|
|
11464
|
-
if (
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
argNodes.value,
|
|
11479
|
-
outTypes,
|
|
11480
|
-
inTypes
|
|
11481
|
-
);
|
|
13810
|
+
if (childNodes.length === pipeArgs.args.length + 1) {
|
|
13811
|
+
let lastNode = null;
|
|
13812
|
+
for (const childNode of childNodes) {
|
|
13813
|
+
if (lastNode !== null) addEdge(mutableGraph, childNode, lastNode, { relationship: "pipe" });
|
|
13814
|
+
lastNode = childNode;
|
|
13815
|
+
}
|
|
13816
|
+
if (lastNode !== null) {
|
|
13817
|
+
const graphNode = yield* addNode2(node2);
|
|
13818
|
+
addEdge(mutableGraph, graphNode, lastNode, { relationship: "pipe" });
|
|
13819
|
+
}
|
|
13820
|
+
} else {
|
|
13821
|
+
childNodes.forEach((_) => removeNode(mutableGraph, _));
|
|
13822
|
+
const nodeInfo = yield* extractNodeInfo(node2);
|
|
13823
|
+
if (nodeInfo.layerTypes) yield* addNode2(node2, nodeInfo);
|
|
11482
13824
|
}
|
|
11483
13825
|
}
|
|
13826
|
+
continue;
|
|
11484
13827
|
}
|
|
11485
|
-
if (
|
|
11486
|
-
|
|
11487
|
-
if (
|
|
11488
|
-
const
|
|
11489
|
-
if (
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
)
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
13828
|
+
if (ts.isCallExpression(node2)) {
|
|
13829
|
+
let shouldExplode = !opts.explodeOnlyLayerCalls;
|
|
13830
|
+
if (opts.explodeOnlyLayerCalls) {
|
|
13831
|
+
const isLayerCall = ts.isPropertyAccessExpression(node2.expression) && ts.isIdentifier(node2.expression.expression) && ts.idText(node2.expression.expression) === layerModuleName;
|
|
13832
|
+
if (isLayerCall) shouldExplode = true;
|
|
13833
|
+
}
|
|
13834
|
+
if (shouldExplode) {
|
|
13835
|
+
if (!visitedNodes.has(node2)) {
|
|
13836
|
+
appendNodeToVisit(node2);
|
|
13837
|
+
node2.arguments.forEach(appendNodeToVisit);
|
|
13838
|
+
visitedNodes.add(node2);
|
|
13839
|
+
} else {
|
|
13840
|
+
const childNodes = node2.arguments.map((_) => nodeToGraph.get(_)).filter(isNumber).filter(
|
|
13841
|
+
(_) => hasNode(mutableGraph, _)
|
|
13842
|
+
);
|
|
13843
|
+
if (childNodes.length === node2.arguments.length) {
|
|
13844
|
+
const graphNode = yield* addNode2(node2);
|
|
13845
|
+
childNodes.forEach(
|
|
13846
|
+
(_, argumentIndex) => addEdge(mutableGraph, graphNode, _, { relationship: "call", argumentIndex })
|
|
11503
13847
|
);
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
11509
|
-
return new GraphNodeCompoundTransform(
|
|
11510
|
-
ctx.nextId(),
|
|
11511
|
-
node,
|
|
11512
|
-
[pipedInGraphNode, ...argNodes.value],
|
|
11513
|
-
outTypes,
|
|
11514
|
-
inTypes
|
|
11515
|
-
);
|
|
11516
|
-
}
|
|
11517
|
-
}
|
|
11518
|
-
const argNode = yield* option(processLayerGraphNode(ctx, node, void 0));
|
|
11519
|
-
if (isSome2(argNode)) {
|
|
11520
|
-
return new GraphNodeCompoundTransform(
|
|
11521
|
-
ctx.nextId(),
|
|
11522
|
-
node,
|
|
11523
|
-
[pipedInGraphNode, argNode.value],
|
|
11524
|
-
outTypes,
|
|
11525
|
-
inTypes
|
|
11526
|
-
);
|
|
11527
|
-
} else {
|
|
11528
|
-
return new GraphNodeCompoundTransform(
|
|
11529
|
-
ctx.nextId(),
|
|
11530
|
-
node,
|
|
11531
|
-
[pipedInGraphNode],
|
|
11532
|
-
outTypes,
|
|
11533
|
-
inTypes
|
|
11534
|
-
);
|
|
11535
|
-
}
|
|
13848
|
+
} else {
|
|
13849
|
+
childNodes.forEach((_) => removeNode(mutableGraph, _));
|
|
13850
|
+
const nodeInfo = yield* extractNodeInfo(node2);
|
|
13851
|
+
if (nodeInfo.layerTypes) yield* addNode2(node2, nodeInfo);
|
|
11536
13852
|
}
|
|
11537
13853
|
}
|
|
13854
|
+
continue;
|
|
11538
13855
|
}
|
|
11539
13856
|
}
|
|
11540
|
-
if (ts.
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
);
|
|
11549
|
-
const { allIndexes: inTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
11550
|
-
ctx.services,
|
|
11551
|
-
maybeLayer.value.RIn,
|
|
11552
|
-
excludeNever
|
|
13857
|
+
if (opts.arrayLiteralAsMerge && ts.isArrayLiteralExpression(node2)) {
|
|
13858
|
+
if (!visitedNodes.has(node2)) {
|
|
13859
|
+
appendNodeToVisit(node2);
|
|
13860
|
+
node2.elements.forEach(appendNodeToVisit);
|
|
13861
|
+
visitedNodes.add(node2);
|
|
13862
|
+
} else {
|
|
13863
|
+
const childNodes = node2.elements.map((_) => nodeToGraph.get(_)).filter(isNumber).filter(
|
|
13864
|
+
(_) => hasNode(mutableGraph, _)
|
|
11553
13865
|
);
|
|
11554
|
-
|
|
13866
|
+
if (childNodes.length > 0) {
|
|
13867
|
+
const graphNode = yield* addNode2(node2);
|
|
13868
|
+
childNodes.forEach(
|
|
13869
|
+
(_, index) => addEdge(mutableGraph, graphNode, _, { relationship: "arrayLiteral", index })
|
|
13870
|
+
);
|
|
13871
|
+
}
|
|
11555
13872
|
}
|
|
13873
|
+
continue;
|
|
11556
13874
|
}
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
switch (graph._tag) {
|
|
11563
|
-
case "GraphNodeLeaf":
|
|
11564
|
-
return graph[kind].indexOf(key) > -1 ? [graph] : [];
|
|
11565
|
-
case "GraphNodeCompoundTransform": {
|
|
11566
|
-
if (graph[kind].indexOf(key) > -1) {
|
|
11567
|
-
let result = [];
|
|
11568
|
-
for (const child of graph.args) {
|
|
11569
|
-
result = result.concat(findInnermostGraphEdge(child, kind, key));
|
|
11570
|
-
}
|
|
11571
|
-
if (result.length > 0) return result;
|
|
11572
|
-
return [graph];
|
|
13875
|
+
if (ts.isExpression(node2)) {
|
|
13876
|
+
const nodeInfo = yield* extractNodeInfo(node2);
|
|
13877
|
+
if (nodeInfo.layerTypes) {
|
|
13878
|
+
yield* addNode2(node2, nodeInfo);
|
|
13879
|
+
continue;
|
|
11573
13880
|
}
|
|
11574
|
-
return [];
|
|
11575
13881
|
}
|
|
13882
|
+
return yield* fail(new UnableToProduceLayerGraphError("Unable to produce layer graph for node", node2));
|
|
11576
13883
|
}
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
13884
|
+
return endMutation2(mutableGraph);
|
|
13885
|
+
});
|
|
13886
|
+
var formatLayerGraph = fn("formatLayerGraph")(function* (layerGraph) {
|
|
13887
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
13888
|
+
return toMermaid(layerGraph, {
|
|
13889
|
+
edgeLabel: (edge) => JSON.stringify(edge),
|
|
13890
|
+
nodeLabel: (graphNode) => {
|
|
13891
|
+
const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
|
|
13892
|
+
return sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
|
|
13893
|
+
}
|
|
13894
|
+
});
|
|
13895
|
+
});
|
|
13896
|
+
var formatNestedLayerGraph = fn("formatNestedLayerGraph")(function* (layerGraph) {
|
|
13897
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
13898
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
13899
|
+
const ts = yield* service(TypeScriptApi);
|
|
13900
|
+
const mermaidSafe = (value) => value.replace(/\n/g, " ").replace(
|
|
13901
|
+
/\s+/g,
|
|
13902
|
+
" "
|
|
13903
|
+
).substring(0, 50).replace(/"/g, "#quot;").replace(/</mg, "#lt;").replace(/>/mg, "#gt;").trim();
|
|
13904
|
+
const typeNameCache = /* @__PURE__ */ new Map();
|
|
13905
|
+
const typeName = (type) => {
|
|
13906
|
+
if (typeNameCache.has(type)) return typeNameCache.get(type);
|
|
13907
|
+
const name = typeChecker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
13908
|
+
typeNameCache.set(type, name);
|
|
13909
|
+
return name;
|
|
13910
|
+
};
|
|
13911
|
+
let result = [];
|
|
13912
|
+
for (const [graphNodeIndex, graphNode] of entries(nodes(layerGraph))) {
|
|
11585
13913
|
let subgraphDefs = [];
|
|
11586
|
-
|
|
11587
|
-
const
|
|
11588
|
-
for (
|
|
11589
|
-
|
|
11590
|
-
const typeString = typeChecker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
11591
|
-
subgraphsIn.push("subgraph " + graph.id + "_rin_" + serviceId + ' ["`' + escapeMermaid(typeString) + '`"]');
|
|
11592
|
-
subgraphsIn.push("end");
|
|
11593
|
-
}
|
|
11594
|
-
const subgraphsOut = [];
|
|
11595
|
-
for (const serviceId of graph.rout) {
|
|
11596
|
-
const type = ctxL.services.get(serviceId);
|
|
11597
|
-
const typeString = typeChecker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
11598
|
-
subgraphsOut.push("subgraph " + graph.id + "_rout_" + serviceId + ' ["`' + escapeMermaid(typeString) + '`"]');
|
|
11599
|
-
subgraphsOut.push("end");
|
|
11600
|
-
}
|
|
11601
|
-
const sourceFile = graph.node.getSourceFile();
|
|
11602
|
-
const nodePosition = graph.node.getStart(sourceFile, false);
|
|
11603
|
-
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
11604
|
-
if (subgraphsIn.length > 0) {
|
|
11605
|
-
subgraphDefs = [
|
|
11606
|
-
...subgraphDefs,
|
|
11607
|
-
"subgraph " + graph.id + "_rin [Requires]",
|
|
11608
|
-
...subgraphsIn,
|
|
11609
|
-
"end",
|
|
11610
|
-
"style " + graph.id + "_rin stroke:none"
|
|
11611
|
-
];
|
|
13914
|
+
for (const kind of ["requires", "provides"]) {
|
|
13915
|
+
const typesMermaidNodes = [];
|
|
13916
|
+
for (let i = 0; i < graphNode[kind].length; i++) {
|
|
13917
|
+
typesMermaidNodes.push(`${graphNodeIndex}_${kind}_${i}["${mermaidSafe(typeName(graphNode[kind][i]))}"]`);
|
|
11612
13918
|
}
|
|
11613
|
-
if (
|
|
13919
|
+
if (typesMermaidNodes.length > 0) {
|
|
11614
13920
|
subgraphDefs = [
|
|
11615
13921
|
...subgraphDefs,
|
|
11616
|
-
|
|
11617
|
-
...
|
|
11618
|
-
|
|
11619
|
-
|
|
13922
|
+
`subgraph ${graphNodeIndex}_${kind} [${kind === "provides" ? "Provides" : "Requires"}]`,
|
|
13923
|
+
...typesMermaidNodes.map((_) => ` ${_}`),
|
|
13924
|
+
`end`,
|
|
13925
|
+
`style ${graphNodeIndex}_${kind} stroke:none`
|
|
11620
13926
|
];
|
|
11621
13927
|
}
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
13928
|
+
}
|
|
13929
|
+
subgraphDefs = [
|
|
13930
|
+
`subgraph ${graphNodeIndex}_wrap[" "]`,
|
|
13931
|
+
...subgraphDefs.map((_) => ` ${_}`),
|
|
13932
|
+
`end`,
|
|
13933
|
+
`style ${graphNodeIndex}_wrap fill:transparent`,
|
|
13934
|
+
`style ${graphNodeIndex}_wrap stroke:none`
|
|
13935
|
+
];
|
|
13936
|
+
const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
|
|
13937
|
+
const nodePosition = graphNode.node.getStart(sourceFile, false);
|
|
13938
|
+
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
13939
|
+
const nodeText = sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
|
|
13940
|
+
result = [
|
|
13941
|
+
...result,
|
|
13942
|
+
`subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}<br/>_at ln ${line + 1} col ${character}_\`"]`,
|
|
13943
|
+
...subgraphDefs.map((_) => ` ${_}`),
|
|
13944
|
+
`end`,
|
|
13945
|
+
`style ${graphNodeIndex} fill:transparent`
|
|
13946
|
+
];
|
|
13947
|
+
}
|
|
13948
|
+
for (const edgeInfo of values2(edges(layerGraph))) {
|
|
13949
|
+
const sourceData = layerGraph.nodes.get(edgeInfo.source);
|
|
13950
|
+
const targetData = layerGraph.nodes.get(edgeInfo.target);
|
|
13951
|
+
let connected = false;
|
|
13952
|
+
for (const kind of ["requires", "provides"]) {
|
|
13953
|
+
for (let i = 0; i < sourceData[kind].length; i++) {
|
|
13954
|
+
const targetIdx = targetData[kind].indexOf(sourceData[kind][i]);
|
|
13955
|
+
if (targetIdx > -1) {
|
|
13956
|
+
result.push(`${edgeInfo.source}_${kind}_${i} -.-> ${edgeInfo.target}_${kind}_${targetIdx}`);
|
|
13957
|
+
connected = true;
|
|
11647
13958
|
}
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
if (!connected) {
|
|
13962
|
+
result.push(`${edgeInfo.source} -.-x ${edgeInfo.target}`);
|
|
13963
|
+
}
|
|
13964
|
+
}
|
|
13965
|
+
return [
|
|
13966
|
+
`flowchart TB`,
|
|
13967
|
+
...result.map((_) => ` ${_}`)
|
|
13968
|
+
].join("\n");
|
|
13969
|
+
});
|
|
13970
|
+
var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
13971
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
13972
|
+
const mutableGraph = beginMutation3(directed());
|
|
13973
|
+
const providers = /* @__PURE__ */ new WeakMap();
|
|
13974
|
+
const knownSymbols = /* @__PURE__ */ new WeakSet();
|
|
13975
|
+
const leafNodes = values2(externals(layerGraph, { direction: "outgoing" }));
|
|
13976
|
+
const dedupedLeafNodes = [];
|
|
13977
|
+
for (const leafNode of leafNodes) {
|
|
13978
|
+
const symbol3 = typeChecker.getSymbolAtLocation(leafNode.node);
|
|
13979
|
+
if (!symbol3) {
|
|
13980
|
+
dedupedLeafNodes.push(leafNode);
|
|
13981
|
+
} else if (symbol3 && !knownSymbols.has(symbol3)) {
|
|
13982
|
+
dedupedLeafNodes.push(leafNode);
|
|
13983
|
+
knownSymbols.add(symbol3);
|
|
13984
|
+
}
|
|
13985
|
+
}
|
|
13986
|
+
for (const leafNode of dedupedLeafNodes) {
|
|
13987
|
+
const nodeIndex = addNode(mutableGraph, {
|
|
13988
|
+
node: leafNode.node,
|
|
13989
|
+
requires: leafNode.requires,
|
|
13990
|
+
provides: leafNode.provides
|
|
13991
|
+
});
|
|
13992
|
+
for (const providedType of leafNode.provides) {
|
|
13993
|
+
if (leafNode.requires.indexOf(providedType) > -1) continue;
|
|
13994
|
+
const previousProviders = providers.get(providedType) || [];
|
|
13995
|
+
providers.set(providedType, [...previousProviders, nodeIndex]);
|
|
13996
|
+
}
|
|
13997
|
+
}
|
|
13998
|
+
for (const [nodeIndex, nodeInfo] of entries(nodes(mutableGraph))) {
|
|
13999
|
+
for (const requiredType of nodeInfo.requires) {
|
|
14000
|
+
for (const providerNodeIndex of providers.get(requiredType) || []) {
|
|
14001
|
+
addEdge(mutableGraph, nodeIndex, providerNodeIndex, {});
|
|
14002
|
+
}
|
|
14003
|
+
}
|
|
14004
|
+
}
|
|
14005
|
+
return endMutation2(mutableGraph);
|
|
14006
|
+
});
|
|
14007
|
+
var formatLayerOutlineGraph = fn("formatLayerOutlineGraph")(
|
|
14008
|
+
function* (layerOutlineGraph) {
|
|
14009
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
14010
|
+
return toMermaid(layerOutlineGraph, {
|
|
14011
|
+
edgeLabel: () => "",
|
|
14012
|
+
nodeLabel: (graphNode) => {
|
|
14013
|
+
const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
|
|
14014
|
+
return sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
|
|
14015
|
+
}
|
|
14016
|
+
});
|
|
14017
|
+
}
|
|
14018
|
+
);
|
|
14019
|
+
var convertOutlineGraphToLayerMagic = fn("convertOutlineGraphToLayerMagic")(
|
|
14020
|
+
function* (outlineGraph, targetOutput) {
|
|
14021
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
14022
|
+
const ts = yield* service(TypeScriptApi);
|
|
14023
|
+
const result = [];
|
|
14024
|
+
const missingOutputTypes = new Set(typeCheckerUtils.unrollUnionMembers(targetOutput));
|
|
14025
|
+
const currentRequiredTypes = /* @__PURE__ */ new Set();
|
|
14026
|
+
const reversedGraph = mutate2(outlineGraph, reverse3);
|
|
14027
|
+
const rootIndexes = fromIterable(indices(externals(reversedGraph, { direction: "incoming" })));
|
|
14028
|
+
const allNodes = fromIterable(values2(dfsPostOrder(reversedGraph, { start: rootIndexes })));
|
|
14029
|
+
for (const nodeInfo of allNodes) {
|
|
14030
|
+
if (!ts.isExpression(nodeInfo.node)) continue;
|
|
14031
|
+
const reallyProvidedTypes = nodeInfo.provides.filter((_) => nodeInfo.requires.indexOf(_) === -1);
|
|
14032
|
+
const shouldMerge = reallyProvidedTypes.some((_) => missingOutputTypes.has(_));
|
|
14033
|
+
if (shouldMerge) {
|
|
14034
|
+
reallyProvidedTypes.forEach((_) => missingOutputTypes.delete(_));
|
|
14035
|
+
}
|
|
14036
|
+
nodeInfo.provides.forEach((_) => currentRequiredTypes.delete(_));
|
|
14037
|
+
nodeInfo.requires.forEach((_) => currentRequiredTypes.add(_));
|
|
14038
|
+
result.push({
|
|
14039
|
+
merges: shouldMerge,
|
|
14040
|
+
provides: true,
|
|
14041
|
+
layerExpression: nodeInfo.node
|
|
14042
|
+
});
|
|
14043
|
+
}
|
|
14044
|
+
return {
|
|
14045
|
+
layerMagicNodes: result,
|
|
14046
|
+
missingOutputTypes
|
|
14047
|
+
};
|
|
14048
|
+
}
|
|
14049
|
+
);
|
|
14050
|
+
var walkLeavesMatching = (graph, predicate, config = {}) => {
|
|
14051
|
+
const start = config.start ?? [];
|
|
14052
|
+
const direction = config.direction ?? "outgoing";
|
|
14053
|
+
return new Walker((f) => ({
|
|
14054
|
+
[Symbol.iterator]: () => {
|
|
14055
|
+
let queue = [...start];
|
|
14056
|
+
const discovered = /* @__PURE__ */ new Set();
|
|
14057
|
+
const nextMapped = () => {
|
|
14058
|
+
while (queue.length > 0) {
|
|
14059
|
+
const current = queue.shift();
|
|
14060
|
+
if (discovered.has(current)) continue;
|
|
14061
|
+
discovered.add(current);
|
|
14062
|
+
const neighbors = neighborsDirected(graph, current, direction);
|
|
14063
|
+
const neighborsMatching = [];
|
|
14064
|
+
for (const neighbor of neighbors) {
|
|
14065
|
+
const neighborNode = getNode(graph, neighbor);
|
|
14066
|
+
if (isSome2(neighborNode) && predicate(neighborNode.value)) {
|
|
14067
|
+
neighborsMatching.push(neighbor);
|
|
14068
|
+
}
|
|
11655
14069
|
}
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
14070
|
+
if (neighborsMatching.length > 0) {
|
|
14071
|
+
queue = [...queue, ...neighborsMatching];
|
|
14072
|
+
} else {
|
|
14073
|
+
const nodeData = getNode(graph, current);
|
|
14074
|
+
if (isSome2(nodeData) && predicate(nodeData.value)) {
|
|
14075
|
+
return { done: false, value: f(current, nodeData.value) };
|
|
14076
|
+
}
|
|
11660
14077
|
}
|
|
11661
14078
|
}
|
|
11662
|
-
return
|
|
14079
|
+
return { done: true, value: void 0 };
|
|
14080
|
+
};
|
|
14081
|
+
return { next: nextMapped };
|
|
14082
|
+
}
|
|
14083
|
+
}));
|
|
14084
|
+
};
|
|
14085
|
+
var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
14086
|
+
function* (layerGraph) {
|
|
14087
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
14088
|
+
const rootWalker = externals(layerGraph, { direction: "outgoing" });
|
|
14089
|
+
const rootNodes = fromIterable(values2(rootWalker));
|
|
14090
|
+
const rootNodeIndexes = fromIterable(indices(rootWalker));
|
|
14091
|
+
const result = [];
|
|
14092
|
+
const walkTypes = (rootTypes, kind) => {
|
|
14093
|
+
const sortedTypes = pipe(fromIterable(rootTypes), sort(typeCheckerUtils.deterministicTypeOrder));
|
|
14094
|
+
for (const layerType of sortedTypes) {
|
|
14095
|
+
const tsNodes = [];
|
|
14096
|
+
for (const layerNode of values2(
|
|
14097
|
+
walkLeavesMatching(
|
|
14098
|
+
layerGraph,
|
|
14099
|
+
(_) => (kind === "provided" ? _.provides : _.requires).indexOf(layerType) > -1,
|
|
14100
|
+
{ start: rootNodeIndexes }
|
|
14101
|
+
)
|
|
14102
|
+
)) {
|
|
14103
|
+
tsNodes.push(layerNode.node);
|
|
14104
|
+
}
|
|
14105
|
+
result.push({
|
|
14106
|
+
kind,
|
|
14107
|
+
type: layerType,
|
|
14108
|
+
nodes: tsNodes
|
|
14109
|
+
});
|
|
14110
|
+
}
|
|
14111
|
+
};
|
|
14112
|
+
walkTypes(new Set(rootNodes.flatMap((_) => _.provides)), "provided");
|
|
14113
|
+
walkTypes(new Set(rootNodes.flatMap((_) => _.requires)), "required");
|
|
14114
|
+
return result;
|
|
14115
|
+
}
|
|
14116
|
+
);
|
|
14117
|
+
var formatLayerProvidersAndRequirersInfo = fn("formatLayerProvidersAndRequirersInfo")(
|
|
14118
|
+
function* (info) {
|
|
14119
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
14120
|
+
const ts = yield* service(TypeScriptApi);
|
|
14121
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
14122
|
+
if (info.length === 0) return "";
|
|
14123
|
+
const textualExplanation = [];
|
|
14124
|
+
const appendInfo = (infoNode) => {
|
|
14125
|
+
const typeString = typeChecker.typeToString(
|
|
14126
|
+
infoNode.type,
|
|
14127
|
+
void 0,
|
|
14128
|
+
ts.TypeFormatFlags.NoTruncation
|
|
14129
|
+
);
|
|
14130
|
+
const positions = infoNode.nodes.map((_) => {
|
|
14131
|
+
const sourceFile = tsUtils.getSourceFileOfNode(_);
|
|
14132
|
+
const nodePosition = ts.getTokenPosOfNode(_, sourceFile);
|
|
14133
|
+
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
14134
|
+
const nodeText = sourceFile.text.substring(_.pos, _.end).trim().replace(/\n/g, " ").substr(0, 50);
|
|
14135
|
+
return `ln ${line + 1} col ${character} by \`${nodeText}\``;
|
|
14136
|
+
});
|
|
14137
|
+
textualExplanation.push(`- ${typeString} ${infoNode.kind} at ${positions.join(", ")}`);
|
|
14138
|
+
};
|
|
14139
|
+
const providedItems = info.filter((_) => _.kind === "provided");
|
|
14140
|
+
const requiredItems = info.filter((_) => _.kind === "required");
|
|
14141
|
+
if (providedItems.length > 0) {
|
|
14142
|
+
for (const item of providedItems) {
|
|
14143
|
+
appendInfo(item);
|
|
11663
14144
|
}
|
|
14145
|
+
if (textualExplanation.length > 0 && requiredItems.length > 0) textualExplanation.push("");
|
|
11664
14146
|
}
|
|
11665
|
-
|
|
11666
|
-
|
|
14147
|
+
if (requiredItems.length > 0) {
|
|
14148
|
+
for (const item of requiredItems) {
|
|
14149
|
+
appendInfo(item);
|
|
14150
|
+
}
|
|
14151
|
+
}
|
|
14152
|
+
return "/**\n" + textualExplanation.map((l) => " * " + l).join("\n") + "\n */";
|
|
14153
|
+
}
|
|
14154
|
+
);
|
|
14155
|
+
|
|
14156
|
+
// src/quickinfo/layerInfo.ts
|
|
11667
14157
|
function generateMarmaidUri(code) {
|
|
11668
14158
|
return gen(function* () {
|
|
11669
14159
|
const state = JSON.stringify({ code });
|
|
@@ -11695,61 +14185,32 @@ function getAdjustedNode(sourceFile, position) {
|
|
|
11695
14185
|
return { node, layerNode };
|
|
11696
14186
|
});
|
|
11697
14187
|
}
|
|
11698
|
-
function parseLayerGraph(
|
|
14188
|
+
function parseLayerGraph(layerNode) {
|
|
11699
14189
|
return gen(function* () {
|
|
11700
|
-
const
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
const
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
};
|
|
11712
|
-
const mermaidLines = yield* processNodeMermaid(rootNode, ctx, graphCtx);
|
|
11713
|
-
const mermaidCode = "flowchart TB\n" + mermaidLines.join("\n");
|
|
11714
|
-
const textualExplanation = [];
|
|
11715
|
-
const appendInfo = (providesNode, type, kindText) => {
|
|
11716
|
-
const typeString = typeChecker.typeToString(
|
|
11717
|
-
type,
|
|
11718
|
-
void 0,
|
|
11719
|
-
ts.TypeFormatFlags.NoTruncation
|
|
11720
|
-
);
|
|
11721
|
-
const positions = providesNode.map((_) => {
|
|
11722
|
-
const nodePosition = _.node.getStart(sourceFile, false);
|
|
11723
|
-
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
11724
|
-
const nodeText = _.node.getText().trim().replace(/\n/g, " ").substr(0, 50);
|
|
11725
|
-
return "ln " + (line + 1) + " col " + character + " by `" + nodeText + "`";
|
|
11726
|
-
});
|
|
11727
|
-
textualExplanation.push("- " + typeString + " " + kindText + " at " + positions.join(", "));
|
|
11728
|
-
};
|
|
11729
|
-
for (const providesKey of rootNode.rout) {
|
|
11730
|
-
const providesNode = findInnermostGraphEdge(rootNode, "rout", providesKey);
|
|
11731
|
-
appendInfo(providesNode, graphCtx.services.get(providesKey), "provided");
|
|
11732
|
-
}
|
|
11733
|
-
if (textualExplanation.length > 0) textualExplanation.push("");
|
|
11734
|
-
for (const requiresKey of rootNode.rin) {
|
|
11735
|
-
const requiresNode = findInnermostGraphEdge(rootNode, "rin", requiresKey);
|
|
11736
|
-
appendInfo(requiresNode, graphCtx.services.get(requiresKey), "required");
|
|
11737
|
-
}
|
|
11738
|
-
return { mermaidCode, textualExplanation };
|
|
14190
|
+
const layerGraph = yield* extractLayerGraph(layerNode, {
|
|
14191
|
+
arrayLiteralAsMerge: false,
|
|
14192
|
+
explodeOnlyLayerCalls: false
|
|
14193
|
+
});
|
|
14194
|
+
const nestedGraphMermaid = yield* formatNestedLayerGraph(layerGraph);
|
|
14195
|
+
const outlineGraph = yield* extractOutlineGraph(layerGraph);
|
|
14196
|
+
const outlineGraphMermaid = yield* formatLayerOutlineGraph(outlineGraph);
|
|
14197
|
+
const providersAndRequirers = yield* extractProvidersAndRequirers(layerGraph);
|
|
14198
|
+
const providersAndRequirersTextualExplanation = yield* formatLayerProvidersAndRequirersInfo(
|
|
14199
|
+
providersAndRequirers
|
|
14200
|
+
);
|
|
14201
|
+
return { nestedGraphMermaid, outlineGraphMermaid, providersAndRequirersTextualExplanation };
|
|
11739
14202
|
});
|
|
11740
14203
|
}
|
|
11741
14204
|
function effectApiGetLayerGraph(sourceFile, line, character) {
|
|
11742
|
-
return
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
})
|
|
11752
|
-
);
|
|
14205
|
+
return gen(function* () {
|
|
14206
|
+
const ts = yield* service(TypeScriptApi);
|
|
14207
|
+
const position = ts.getPositionOfLineAndCharacter(sourceFile, line, character);
|
|
14208
|
+
const maybeNodes = yield* getAdjustedNode(sourceFile, position);
|
|
14209
|
+
if (!maybeNodes) return yield* fail(new UnableToProduceLayerGraphError("No node found"));
|
|
14210
|
+
const { layerNode, node } = maybeNodes;
|
|
14211
|
+
const { nestedGraphMermaid } = yield* parseLayerGraph(layerNode);
|
|
14212
|
+
return { start: node.pos, end: node.end, mermaidCode: nestedGraphMermaid };
|
|
14213
|
+
});
|
|
11753
14214
|
}
|
|
11754
14215
|
function layerInfo(sourceFile, position, quickInfo2) {
|
|
11755
14216
|
return pipe(
|
|
@@ -11760,35 +14221,36 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
11760
14221
|
if (!maybeNodes) return quickInfo2;
|
|
11761
14222
|
const { layerNode, node } = maybeNodes;
|
|
11762
14223
|
const layerInfoDisplayParts = yield* pipe(
|
|
11763
|
-
parseLayerGraph(
|
|
14224
|
+
parseLayerGraph(layerNode),
|
|
11764
14225
|
flatMap2(
|
|
11765
|
-
({
|
|
14226
|
+
({ nestedGraphMermaid, outlineGraphMermaid, providersAndRequirersTextualExplanation }) => gen(function* () {
|
|
11766
14227
|
const linkParts = [];
|
|
11767
14228
|
if (!options.noExternal) {
|
|
11768
|
-
const mermaidUri = yield* generateMarmaidUri(
|
|
14229
|
+
const mermaidUri = yield* generateMarmaidUri(nestedGraphMermaid);
|
|
14230
|
+
const outlineMermaidUri = yield* generateMarmaidUri(outlineGraphMermaid);
|
|
11769
14231
|
linkParts.push({ kind: "space", text: "\n" });
|
|
11770
14232
|
linkParts.push({ kind: "link", text: "{@link " });
|
|
11771
14233
|
linkParts.push({ kind: "linkText", text: mermaidUri + " Show full Layer graph" });
|
|
11772
14234
|
linkParts.push({ kind: "link", text: "}" });
|
|
14235
|
+
linkParts.push({ kind: "text", text: " - " });
|
|
14236
|
+
linkParts.push({ kind: "link", text: "{@link " });
|
|
14237
|
+
linkParts.push({ kind: "linkText", text: outlineMermaidUri + " Show Layer outline" });
|
|
14238
|
+
linkParts.push({ kind: "link", text: "}" });
|
|
11773
14239
|
linkParts.push({ kind: "space", text: "\n" });
|
|
11774
14240
|
}
|
|
11775
|
-
if (
|
|
14241
|
+
if (providersAndRequirersTextualExplanation.length === 0) return linkParts;
|
|
11776
14242
|
return [
|
|
11777
14243
|
{
|
|
11778
14244
|
kind: "text",
|
|
11779
|
-
text: "```\n
|
|
14245
|
+
text: "```\n" + providersAndRequirersTextualExplanation + "\n```\n"
|
|
11780
14246
|
},
|
|
11781
14247
|
...linkParts
|
|
11782
14248
|
];
|
|
11783
14249
|
})
|
|
11784
14250
|
),
|
|
11785
|
-
orElse2(
|
|
11786
|
-
(e) => succeed([{
|
|
11787
|
-
kind: "text",
|
|
11788
|
-
text: "```\n/** layer graph not created: " + e.message + " */\n```\n"
|
|
11789
|
-
}])
|
|
11790
|
-
)
|
|
14251
|
+
orElse2(() => succeed([]))
|
|
11791
14252
|
);
|
|
14253
|
+
if (layerInfoDisplayParts.length === 0) return quickInfo2;
|
|
11792
14254
|
if (!quickInfo2) {
|
|
11793
14255
|
const start = ts.getTokenPosOfNode(node, sourceFile);
|
|
11794
14256
|
const end = node.end;
|
|
@@ -12304,71 +14766,6 @@ var functionToArrow = createRefactor({
|
|
|
12304
14766
|
});
|
|
12305
14767
|
|
|
12306
14768
|
// src/refactors/layerMagic.ts
|
|
12307
|
-
function sortDependencies(nodes) {
|
|
12308
|
-
const result = [];
|
|
12309
|
-
const visited = /* @__PURE__ */ new Set();
|
|
12310
|
-
const visiting = /* @__PURE__ */ new Set();
|
|
12311
|
-
const cycles = [];
|
|
12312
|
-
const providesMap = /* @__PURE__ */ new Map();
|
|
12313
|
-
Object.entries(nodes).forEach(([nodeId, node]) => {
|
|
12314
|
-
node.provides.forEach((service2) => {
|
|
12315
|
-
if (!providesMap.has(service2)) {
|
|
12316
|
-
providesMap.set(service2, []);
|
|
12317
|
-
}
|
|
12318
|
-
providesMap.get(service2).push(nodeId);
|
|
12319
|
-
});
|
|
12320
|
-
});
|
|
12321
|
-
providesMap.forEach((nodeIds) => {
|
|
12322
|
-
nodeIds.sort((a, b) => {
|
|
12323
|
-
const nodeA = nodes[a];
|
|
12324
|
-
const nodeB = nodes[b];
|
|
12325
|
-
return nodeA.requires.length - nodeB.requires.length;
|
|
12326
|
-
});
|
|
12327
|
-
});
|
|
12328
|
-
const visit = (nodeId, path) => {
|
|
12329
|
-
if (visited.has(nodeId)) {
|
|
12330
|
-
return;
|
|
12331
|
-
}
|
|
12332
|
-
if (visiting.has(nodeId)) {
|
|
12333
|
-
const cycleStart = path.indexOf(nodeId);
|
|
12334
|
-
const cycle = path.slice(cycleStart).concat([nodeId]);
|
|
12335
|
-
const cycleServices = cycle.map((id) => {
|
|
12336
|
-
const node2 = nodes[id];
|
|
12337
|
-
return `${node2.provides.join(", ")} (requires: ${node2.requires.join(", ")})`;
|
|
12338
|
-
});
|
|
12339
|
-
cycles.push(cycleServices);
|
|
12340
|
-
return;
|
|
12341
|
-
}
|
|
12342
|
-
visiting.add(nodeId);
|
|
12343
|
-
const currentPath = [...path, nodeId];
|
|
12344
|
-
const dependencies = /* @__PURE__ */ new Set();
|
|
12345
|
-
const node = nodes[nodeId];
|
|
12346
|
-
node.requires.forEach((requiredService) => {
|
|
12347
|
-
const providers = providesMap.get(requiredService) || [];
|
|
12348
|
-
providers.forEach((providerId) => {
|
|
12349
|
-
if (providerId !== nodeId) {
|
|
12350
|
-
dependencies.add(providerId);
|
|
12351
|
-
}
|
|
12352
|
-
});
|
|
12353
|
-
});
|
|
12354
|
-
dependencies.forEach((depId) => {
|
|
12355
|
-
visit(depId, currentPath);
|
|
12356
|
-
});
|
|
12357
|
-
visiting.delete(nodeId);
|
|
12358
|
-
visited.add(nodeId);
|
|
12359
|
-
result.push(node);
|
|
12360
|
-
};
|
|
12361
|
-
Object.keys(nodes).forEach((nodeId) => {
|
|
12362
|
-
if (!visited.has(nodeId)) {
|
|
12363
|
-
visit(nodeId, []);
|
|
12364
|
-
}
|
|
12365
|
-
});
|
|
12366
|
-
return {
|
|
12367
|
-
sorted: result,
|
|
12368
|
-
cycles,
|
|
12369
|
-
hasCycles: cycles.length > 0
|
|
12370
|
-
};
|
|
12371
|
-
}
|
|
12372
14769
|
var layerMagic = createRefactor({
|
|
12373
14770
|
name: "layerMagic",
|
|
12374
14771
|
description: "Layer Magic",
|
|
@@ -12383,56 +14780,6 @@ var layerMagic = createRefactor({
|
|
|
12383
14780
|
"effect",
|
|
12384
14781
|
"Layer"
|
|
12385
14782
|
) || "Layer";
|
|
12386
|
-
const extractArrayLiteral = (node) => {
|
|
12387
|
-
if (ts.isArrayLiteralExpression(node)) {
|
|
12388
|
-
return pipe(
|
|
12389
|
-
all(...node.elements.map((element) => extractLayers(element, false))),
|
|
12390
|
-
map5(flatten)
|
|
12391
|
-
);
|
|
12392
|
-
}
|
|
12393
|
-
return TypeParserIssue.issue;
|
|
12394
|
-
};
|
|
12395
|
-
const extractLayerExpression = (node) => {
|
|
12396
|
-
if (ts.isExpression(node)) {
|
|
12397
|
-
return pipe(
|
|
12398
|
-
typeParser.layerType(typeChecker.getTypeAtLocation(node), node),
|
|
12399
|
-
map5((_) => [{ node, ..._ }])
|
|
12400
|
-
);
|
|
12401
|
-
}
|
|
12402
|
-
return TypeParserIssue.issue;
|
|
12403
|
-
};
|
|
12404
|
-
const extractLayerApi = (node) => {
|
|
12405
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && ts.idText(node.expression.expression) === layerIdentifier && ts.isIdentifier(node.expression.name) && ["provide", "provideMerge", "merge", "mergeAll"].map((_) => _.toLowerCase()).indexOf(
|
|
12406
|
-
ts.idText(node.expression.name).toLowerCase()
|
|
12407
|
-
) > -1) {
|
|
12408
|
-
return pipe(
|
|
12409
|
-
all(...node.arguments.map((element) => extractLayers(element, false))),
|
|
12410
|
-
map5(flatten)
|
|
12411
|
-
);
|
|
12412
|
-
}
|
|
12413
|
-
return TypeParserIssue.issue;
|
|
12414
|
-
};
|
|
12415
|
-
const extractPipeSequencing = (node) => {
|
|
12416
|
-
return pipe(
|
|
12417
|
-
typeParser.pipeCall(node),
|
|
12418
|
-
flatMap2((_) => {
|
|
12419
|
-
return all(...[_.subject, ..._.args].map((element) => extractLayers(element, true)));
|
|
12420
|
-
}),
|
|
12421
|
-
map5(flatten)
|
|
12422
|
-
);
|
|
12423
|
-
};
|
|
12424
|
-
const extractLayers = cachedBy(
|
|
12425
|
-
fn("layerMagic.apply.extractLayerArray")(function* (node, _inPipeContext) {
|
|
12426
|
-
return yield* pipe(
|
|
12427
|
-
extractArrayLiteral(node),
|
|
12428
|
-
orElse2(() => extractLayerApi(node)),
|
|
12429
|
-
_inPipeContext ? (x) => x : orElse2(() => extractPipeSequencing(node)),
|
|
12430
|
-
orElse2(() => extractLayerExpression(node))
|
|
12431
|
-
);
|
|
12432
|
-
}),
|
|
12433
|
-
"layerMagic.apply.extractLayerArray",
|
|
12434
|
-
(node) => node
|
|
12435
|
-
);
|
|
12436
14783
|
const adjustedNode = (node) => {
|
|
12437
14784
|
if (node.parent && (ts.isVariableDeclaration(node.parent) || ts.isPropertyDeclaration(node.parent)) && ts.isIdentifier(node) && node.parent.initializer && node.parent.name === node) {
|
|
12438
14785
|
return node.parent.initializer;
|
|
@@ -12442,9 +14789,13 @@ var layerMagic = createRefactor({
|
|
|
12442
14789
|
const computeAsAnyAsLayerRefactor = (node) => {
|
|
12443
14790
|
const atLocation = adjustedNode(node);
|
|
12444
14791
|
return pipe(
|
|
12445
|
-
|
|
14792
|
+
extractLayerGraph(atLocation, {
|
|
14793
|
+
arrayLiteralAsMerge: true,
|
|
14794
|
+
explodeOnlyLayerCalls: true
|
|
14795
|
+
}),
|
|
14796
|
+
flatMap2(extractOutlineGraph),
|
|
12446
14797
|
flatMap2(
|
|
12447
|
-
(extractedLayer) => extractedLayer
|
|
14798
|
+
(extractedLayer) => nodeCount(extractedLayer) <= 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12448
14799
|
),
|
|
12449
14800
|
map5((extractedLayers) => ({
|
|
12450
14801
|
kind: "refactor.rewrite.effect.layerMagicPrepare",
|
|
@@ -12452,21 +14803,27 @@ var layerMagic = createRefactor({
|
|
|
12452
14803
|
apply: pipe(
|
|
12453
14804
|
gen(function* () {
|
|
12454
14805
|
const changeTracker = yield* service(ChangeTracker);
|
|
12455
|
-
const
|
|
12456
|
-
for (const layer of extractedLayers) {
|
|
12457
|
-
|
|
12458
|
-
memory,
|
|
12459
|
-
layer.ROut,
|
|
12460
|
-
(_) => succeed((_.flags & ts.TypeFlags.Never) !== 0)
|
|
12461
|
-
);
|
|
14806
|
+
const layerOutputTypes = /* @__PURE__ */ new Set();
|
|
14807
|
+
for (const layer of values2(nodes(extractedLayers))) {
|
|
14808
|
+
layer.provides.forEach((_) => layerOutputTypes.add(_));
|
|
12462
14809
|
}
|
|
14810
|
+
const layerNodes = pipe(
|
|
14811
|
+
values2(nodes(extractedLayers)),
|
|
14812
|
+
fromIterable,
|
|
14813
|
+
map4((_) => _.node),
|
|
14814
|
+
filter(ts.isExpression),
|
|
14815
|
+
sort(mapInput(
|
|
14816
|
+
number2,
|
|
14817
|
+
(_) => _.pos
|
|
14818
|
+
))
|
|
14819
|
+
);
|
|
12463
14820
|
const previouslyProvided = yield* pipe(
|
|
12464
14821
|
typeParser.layerType(typeChecker.getTypeAtLocation(atLocation), atLocation),
|
|
12465
14822
|
map5((_) => _.ROut),
|
|
12466
14823
|
option
|
|
12467
14824
|
);
|
|
12468
14825
|
const [existingBefore, newlyIntroduced] = pipe(
|
|
12469
|
-
fromIterable(
|
|
14826
|
+
fromIterable(layerOutputTypes),
|
|
12470
14827
|
sort(typeCheckerUtils.deterministicTypeOrder),
|
|
12471
14828
|
partition(
|
|
12472
14829
|
(_) => isNone2(previouslyProvided) || typeChecker.isTypeAssignableTo(_, previouslyProvided.value)
|
|
@@ -12491,7 +14848,7 @@ var layerMagic = createRefactor({
|
|
|
12491
14848
|
);
|
|
12492
14849
|
const newDeclaration = ts.factory.createAsExpression(
|
|
12493
14850
|
ts.factory.createAsExpression(
|
|
12494
|
-
ts.factory.createArrayLiteralExpression(
|
|
14851
|
+
ts.factory.createArrayLiteralExpression(layerNodes),
|
|
12495
14852
|
ts.factory.createTypeReferenceNode("any")
|
|
12496
14853
|
),
|
|
12497
14854
|
ts.factory.createTypeReferenceNode(
|
|
@@ -12513,8 +14870,9 @@ var layerMagic = createRefactor({
|
|
|
12513
14870
|
if (ts.isAsExpression(node) && ts.isTypeReferenceNode(node.type)) {
|
|
12514
14871
|
const expression = node.expression;
|
|
12515
14872
|
if (ts.isAsExpression(expression) && expression.type.kind === ts.SyntaxKind.AnyKeyword) {
|
|
14873
|
+
const type = typeChecker.getTypeAtLocation(node.type);
|
|
12516
14874
|
return pipe(
|
|
12517
|
-
typeParser.layerType(
|
|
14875
|
+
typeParser.layerType(type, node.type),
|
|
12518
14876
|
map5((_) => ({ node, ..._, castedStructure: expression.expression }))
|
|
12519
14877
|
);
|
|
12520
14878
|
}
|
|
@@ -12527,80 +14885,49 @@ var layerMagic = createRefactor({
|
|
|
12527
14885
|
parseAsAnyAsLayer(atLocation),
|
|
12528
14886
|
flatMap2(
|
|
12529
14887
|
(_targetLayer) => pipe(
|
|
12530
|
-
|
|
12531
|
-
|
|
14888
|
+
extractLayerGraph(_targetLayer.castedStructure, {
|
|
14889
|
+
arrayLiteralAsMerge: true,
|
|
14890
|
+
explodeOnlyLayerCalls: true
|
|
14891
|
+
}),
|
|
14892
|
+
flatMap2(extractOutlineGraph),
|
|
12532
14893
|
flatMap2(
|
|
12533
|
-
(extractedLayer) => extractedLayer
|
|
14894
|
+
(extractedLayer) => nodeCount(extractedLayer) <= 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12534
14895
|
),
|
|
12535
14896
|
map5((extractedLayers) => ({
|
|
12536
14897
|
kind: "refactor.rewrite.effect.layerMagicBuild",
|
|
12537
14898
|
description: "Compose layers automatically with target output services",
|
|
12538
14899
|
apply: gen(function* () {
|
|
12539
14900
|
const changeTracker = yield* service(ChangeTracker);
|
|
12540
|
-
const
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
14901
|
+
const { layerMagicNodes, missingOutputTypes } = yield* pipe(
|
|
14902
|
+
convertOutlineGraphToLayerMagic(
|
|
14903
|
+
extractedLayers,
|
|
14904
|
+
_targetLayer.ROut
|
|
14905
|
+
),
|
|
14906
|
+
provideService(TypeCheckerApi, typeChecker),
|
|
14907
|
+
provideService(TypeCheckerUtils, typeCheckerUtils),
|
|
14908
|
+
provideService(TypeScriptApi, ts)
|
|
12545
14909
|
);
|
|
12546
|
-
const nodes = {};
|
|
12547
|
-
for (let i = 0; i < extractedLayers.length; i++) {
|
|
12548
|
-
const layer = extractedLayers[i];
|
|
12549
|
-
const { allIndexes: providedIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
12550
|
-
memory,
|
|
12551
|
-
layer.ROut,
|
|
12552
|
-
(_) => succeed((_.flags & ts.TypeFlags.Never) !== 0)
|
|
12553
|
-
);
|
|
12554
|
-
const { allIndexes: requiredIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
12555
|
-
memory,
|
|
12556
|
-
layer.RIn,
|
|
12557
|
-
(_) => succeed((_.flags & ts.TypeFlags.Never) !== 0)
|
|
12558
|
-
);
|
|
12559
|
-
nodes[`node_${i}`] = {
|
|
12560
|
-
provides: providedIndexes.filter((_) => requiredIndexes.indexOf(_) === -1),
|
|
12561
|
-
// only provide indexes that are not required
|
|
12562
|
-
requires: requiredIndexes,
|
|
12563
|
-
node: layer.node
|
|
12564
|
-
};
|
|
12565
|
-
}
|
|
12566
|
-
const sortResult = sortDependencies(nodes);
|
|
12567
|
-
const sortedNodes = sortResult.sorted.reverse();
|
|
12568
|
-
const missingOutput = new Set(outputIndexes);
|
|
12569
|
-
const missingInternal = /* @__PURE__ */ new Set();
|
|
12570
|
-
const outputEntry = [];
|
|
12571
|
-
for (let i = 0; i < sortedNodes.length; i++) {
|
|
12572
|
-
const graphNode = sortedNodes[i];
|
|
12573
|
-
const mergeOutput = graphNode.provides.filter((_) => missingOutput.has(_));
|
|
12574
|
-
const provideInternal = graphNode.provides.filter((_) => missingInternal.has(_));
|
|
12575
|
-
graphNode.requires.forEach((_) => missingInternal.add(_));
|
|
12576
|
-
mergeOutput.forEach((_) => missingOutput.delete(_));
|
|
12577
|
-
outputEntry.push({
|
|
12578
|
-
merges: mergeOutput.length > 0,
|
|
12579
|
-
provides: provideInternal.length > 0,
|
|
12580
|
-
node: graphNode.node
|
|
12581
|
-
});
|
|
12582
|
-
}
|
|
12583
14910
|
const newDeclaration = ts.factory.createCallExpression(
|
|
12584
14911
|
ts.factory.createPropertyAccessExpression(
|
|
12585
|
-
|
|
14912
|
+
layerMagicNodes[0].layerExpression,
|
|
12586
14913
|
"pipe"
|
|
12587
14914
|
),
|
|
12588
14915
|
[],
|
|
12589
|
-
|
|
14916
|
+
layerMagicNodes.slice(1).map(
|
|
12590
14917
|
(_) => ts.factory.createCallExpression(
|
|
12591
14918
|
ts.factory.createPropertyAccessExpression(
|
|
12592
14919
|
ts.factory.createIdentifier(layerIdentifier),
|
|
12593
14920
|
_.merges && _.provides ? "provideMerge" : _.merges ? "merge" : "provide"
|
|
12594
14921
|
),
|
|
12595
14922
|
[],
|
|
12596
|
-
[_.
|
|
14923
|
+
[_.layerExpression]
|
|
12597
14924
|
)
|
|
12598
14925
|
)
|
|
12599
14926
|
);
|
|
12600
|
-
const newDeclarationWithComment =
|
|
14927
|
+
const newDeclarationWithComment = missingOutputTypes.size > 0 ? ts.addSyntheticTrailingComment(
|
|
12601
14928
|
newDeclaration,
|
|
12602
14929
|
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
12603
|
-
" Unable to find " + fromIterable(
|
|
14930
|
+
" Unable to find " + fromIterable(missingOutputTypes.values()).map(
|
|
12604
14931
|
(_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)
|
|
12605
14932
|
).join(", ") + " in the provided layers. ",
|
|
12606
14933
|
false
|