@effect/language-service 0.41.1 → 0.43.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 +53 -1
- package/effect-lsp-patch-utils.js +144 -3
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +435 -278
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +144 -3
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -717,6 +717,9 @@ var isRight2 = isRight;
|
|
|
717
717
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
718
718
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
719
719
|
|
|
720
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
|
|
721
|
+
var isNonEmptyArray = (self) => self.length > 0;
|
|
722
|
+
|
|
720
723
|
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Order.js
|
|
721
724
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
722
725
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
@@ -732,6 +735,116 @@ var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nu
|
|
|
732
735
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
733
736
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
734
737
|
|
|
738
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
|
|
739
|
+
var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
740
|
+
const out = {
|
|
741
|
+
...self
|
|
742
|
+
};
|
|
743
|
+
for (const key of keys(self)) {
|
|
744
|
+
out[key] = f(self[key], key);
|
|
745
|
+
}
|
|
746
|
+
return out;
|
|
747
|
+
});
|
|
748
|
+
var keys = (self) => Object.keys(self);
|
|
749
|
+
|
|
750
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
|
|
751
|
+
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
752
|
+
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
753
|
+
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
754
|
+
var isArray = Array.isArray;
|
|
755
|
+
var isEmptyArray = (self) => self.length === 0;
|
|
756
|
+
var isEmptyReadonlyArray = isEmptyArray;
|
|
757
|
+
var isNonEmptyReadonlyArray = isNonEmptyArray;
|
|
758
|
+
var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
|
|
759
|
+
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
760
|
+
const i = Math.floor(index);
|
|
761
|
+
return isOutOfBounds(i, self) ? none2() : some2(self[i]);
|
|
762
|
+
});
|
|
763
|
+
var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
764
|
+
const i = Math.floor(index);
|
|
765
|
+
if (isOutOfBounds(i, self)) {
|
|
766
|
+
throw new Error(`Index ${i} out of bounds`);
|
|
767
|
+
}
|
|
768
|
+
return self[i];
|
|
769
|
+
});
|
|
770
|
+
var head = /* @__PURE__ */ get(0);
|
|
771
|
+
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
772
|
+
var tailNonEmpty = (self) => self.slice(1);
|
|
773
|
+
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
774
|
+
const out = Array.from(self);
|
|
775
|
+
out.sort(O);
|
|
776
|
+
return out;
|
|
777
|
+
});
|
|
778
|
+
var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
779
|
+
for (const i of self) {
|
|
780
|
+
if (isEquivalent(a, i)) {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return false;
|
|
785
|
+
});
|
|
786
|
+
var _equivalence = /* @__PURE__ */ equivalence();
|
|
787
|
+
var intersectionWith = (isEquivalent) => {
|
|
788
|
+
const has = containsWith(isEquivalent);
|
|
789
|
+
return dual(2, (self, that) => fromIterable(self).filter((a) => has(that, a)));
|
|
790
|
+
};
|
|
791
|
+
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
792
|
+
var empty = () => [];
|
|
793
|
+
var map4 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
794
|
+
var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
795
|
+
if (isEmptyReadonlyArray(self)) {
|
|
796
|
+
return [];
|
|
797
|
+
}
|
|
798
|
+
const out = [];
|
|
799
|
+
for (let i = 0; i < self.length; i++) {
|
|
800
|
+
const inner = f(self[i], i);
|
|
801
|
+
for (let j = 0; j < inner.length; j++) {
|
|
802
|
+
out.push(inner[j]);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return out;
|
|
806
|
+
});
|
|
807
|
+
var flatten = /* @__PURE__ */ flatMap(identity);
|
|
808
|
+
var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
809
|
+
const as = fromIterable(self);
|
|
810
|
+
const out = [];
|
|
811
|
+
for (let i = 0; i < as.length; i++) {
|
|
812
|
+
if (predicate(as[i], i)) {
|
|
813
|
+
out.push(as[i]);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return out;
|
|
817
|
+
});
|
|
818
|
+
var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
819
|
+
const left3 = [];
|
|
820
|
+
const right3 = [];
|
|
821
|
+
const as = fromIterable(self);
|
|
822
|
+
for (let i = 0; i < as.length; i++) {
|
|
823
|
+
if (predicate(as[i], i)) {
|
|
824
|
+
right3.push(as[i]);
|
|
825
|
+
} else {
|
|
826
|
+
left3.push(as[i]);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return [left3, right3];
|
|
830
|
+
});
|
|
831
|
+
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
832
|
+
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
833
|
+
const input = fromIterable(self);
|
|
834
|
+
if (isNonEmptyReadonlyArray(input)) {
|
|
835
|
+
const out = [headNonEmpty(input)];
|
|
836
|
+
const rest = tailNonEmpty(input);
|
|
837
|
+
for (const r of rest) {
|
|
838
|
+
if (out.every((a) => !isEquivalent(r, a))) {
|
|
839
|
+
out.push(r);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return out;
|
|
843
|
+
}
|
|
844
|
+
return [];
|
|
845
|
+
});
|
|
846
|
+
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
847
|
+
|
|
735
848
|
// src/core/Nano.ts
|
|
736
849
|
var NanoTag = class {
|
|
737
850
|
constructor(key) {
|
|
@@ -903,13 +1016,13 @@ var OnSuccessProto = {
|
|
|
903
1016
|
return this[args];
|
|
904
1017
|
}
|
|
905
1018
|
};
|
|
906
|
-
var
|
|
1019
|
+
var flatMap2 = dual(2, (fa, f) => {
|
|
907
1020
|
const nano = Object.create(OnSuccessProto);
|
|
908
1021
|
nano[args] = fa;
|
|
909
1022
|
nano[contA] = f;
|
|
910
1023
|
return nano;
|
|
911
1024
|
});
|
|
912
|
-
var
|
|
1025
|
+
var map5 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
|
|
913
1026
|
var SyncProto = {
|
|
914
1027
|
...PrimitiveProto,
|
|
915
1028
|
[evaluate](fiber) {
|
|
@@ -1060,6 +1173,78 @@ var all = fn("all")(
|
|
|
1060
1173
|
}
|
|
1061
1174
|
);
|
|
1062
1175
|
|
|
1176
|
+
// src/core/LanguageServicePluginOptions.ts
|
|
1177
|
+
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
1178
|
+
function parseDiagnosticSeverity(config) {
|
|
1179
|
+
if (!isRecord(config)) return {};
|
|
1180
|
+
return Object.fromEntries(
|
|
1181
|
+
pipe(
|
|
1182
|
+
Object.entries(config),
|
|
1183
|
+
filter(([key, value]) => isString(key) && isString(value)),
|
|
1184
|
+
map4(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
|
|
1185
|
+
filter(
|
|
1186
|
+
([_, value]) => value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion"
|
|
1187
|
+
)
|
|
1188
|
+
)
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
var defaults = {
|
|
1192
|
+
refactors: true,
|
|
1193
|
+
diagnostics: true,
|
|
1194
|
+
diagnosticSeverity: {},
|
|
1195
|
+
quickinfo: true,
|
|
1196
|
+
quickinfoEffectParameters: "whentruncated",
|
|
1197
|
+
quickinfoMaximumLength: -1,
|
|
1198
|
+
completions: true,
|
|
1199
|
+
goto: true,
|
|
1200
|
+
inlays: true,
|
|
1201
|
+
allowedDuplicatedPackages: [],
|
|
1202
|
+
namespaceImportPackages: [],
|
|
1203
|
+
topLevelNamedReexports: "ignore",
|
|
1204
|
+
barrelImportPackages: [],
|
|
1205
|
+
importAliases: {},
|
|
1206
|
+
renames: true,
|
|
1207
|
+
noExternal: false,
|
|
1208
|
+
keyPatterns: [{
|
|
1209
|
+
target: "service",
|
|
1210
|
+
pattern: "default",
|
|
1211
|
+
skipLeadingPath: ["src/"]
|
|
1212
|
+
}]
|
|
1213
|
+
};
|
|
1214
|
+
function parseKeyPatterns(patterns) {
|
|
1215
|
+
const result = [];
|
|
1216
|
+
for (const entry of patterns) {
|
|
1217
|
+
if (!isObject(entry)) continue;
|
|
1218
|
+
result.push({
|
|
1219
|
+
target: hasProperty(entry, "target") && isString(entry.target) && ["service", "error"].includes(entry.target.toLowerCase()) ? entry.target.toLowerCase() : "service",
|
|
1220
|
+
pattern: hasProperty(entry, "pattern") && isString(entry.pattern) && ["package-identifier", "default"].includes(entry.pattern.toLowerCase()) ? entry.pattern.toLowerCase() : "default",
|
|
1221
|
+
skipLeadingPath: hasProperty(entry, "skipLeadingPath") && isArray(entry.skipLeadingPath) && entry.skipLeadingPath.every(isString) ? entry.skipLeadingPath : ["src/"]
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
return result;
|
|
1225
|
+
}
|
|
1226
|
+
function parse(config) {
|
|
1227
|
+
return {
|
|
1228
|
+
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1229
|
+
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1230
|
+
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1231
|
+
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1232
|
+
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1233
|
+
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
1234
|
+
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1235
|
+
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1236
|
+
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
1237
|
+
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1238
|
+
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1239
|
+
barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
|
|
1240
|
+
importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map3(config.importAliases, (value) => String(value)) : defaults.importAliases,
|
|
1241
|
+
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
|
|
1242
|
+
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1243
|
+
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
|
|
1244
|
+
keyPatterns: isObject(config) && hasProperty(config, "keyPatterns") && isArray(config.keyPatterns) ? parseKeyPatterns(config.keyPatterns) : defaults.keyPatterns
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1063
1248
|
// src/core/TypeScriptApi.ts
|
|
1064
1249
|
var TypeScriptApi = Tag("TypeScriptApi");
|
|
1065
1250
|
var TypeScriptProgram = Tag("TypeScriptProgram");
|
|
@@ -1127,124 +1312,11 @@ function makeGetEntrypointsFromPackageJsonInfo(ts) {
|
|
|
1127
1312
|
}
|
|
1128
1313
|
}
|
|
1129
1314
|
|
|
1130
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
|
|
1131
|
-
var isNonEmptyArray = (self) => self.length > 0;
|
|
1132
|
-
|
|
1133
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
|
|
1134
|
-
var map4 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
1135
|
-
const out = {
|
|
1136
|
-
...self
|
|
1137
|
-
};
|
|
1138
|
-
for (const key of keys(self)) {
|
|
1139
|
-
out[key] = f(self[key], key);
|
|
1140
|
-
}
|
|
1141
|
-
return out;
|
|
1142
|
-
});
|
|
1143
|
-
var keys = (self) => Object.keys(self);
|
|
1144
|
-
|
|
1145
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
|
|
1146
|
-
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
1147
|
-
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
1148
|
-
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
1149
|
-
var isArray = Array.isArray;
|
|
1150
|
-
var isEmptyArray = (self) => self.length === 0;
|
|
1151
|
-
var isEmptyReadonlyArray = isEmptyArray;
|
|
1152
|
-
var isNonEmptyReadonlyArray = isNonEmptyArray;
|
|
1153
|
-
var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
|
|
1154
|
-
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
1155
|
-
const i = Math.floor(index);
|
|
1156
|
-
return isOutOfBounds(i, self) ? none2() : some2(self[i]);
|
|
1157
|
-
});
|
|
1158
|
-
var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
1159
|
-
const i = Math.floor(index);
|
|
1160
|
-
if (isOutOfBounds(i, self)) {
|
|
1161
|
-
throw new Error(`Index ${i} out of bounds`);
|
|
1162
|
-
}
|
|
1163
|
-
return self[i];
|
|
1164
|
-
});
|
|
1165
|
-
var head = /* @__PURE__ */ get(0);
|
|
1166
|
-
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
1167
|
-
var tailNonEmpty = (self) => self.slice(1);
|
|
1168
|
-
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
1169
|
-
const out = Array.from(self);
|
|
1170
|
-
out.sort(O);
|
|
1171
|
-
return out;
|
|
1172
|
-
});
|
|
1173
|
-
var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
1174
|
-
for (const i of self) {
|
|
1175
|
-
if (isEquivalent(a, i)) {
|
|
1176
|
-
return true;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
return false;
|
|
1180
|
-
});
|
|
1181
|
-
var _equivalence = /* @__PURE__ */ equivalence();
|
|
1182
|
-
var intersectionWith = (isEquivalent) => {
|
|
1183
|
-
const has = containsWith(isEquivalent);
|
|
1184
|
-
return dual(2, (self, that) => fromIterable(self).filter((a) => has(that, a)));
|
|
1185
|
-
};
|
|
1186
|
-
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
1187
|
-
var empty = () => [];
|
|
1188
|
-
var map5 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
1189
|
-
var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
1190
|
-
if (isEmptyReadonlyArray(self)) {
|
|
1191
|
-
return [];
|
|
1192
|
-
}
|
|
1193
|
-
const out = [];
|
|
1194
|
-
for (let i = 0; i < self.length; i++) {
|
|
1195
|
-
const inner = f(self[i], i);
|
|
1196
|
-
for (let j = 0; j < inner.length; j++) {
|
|
1197
|
-
out.push(inner[j]);
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
return out;
|
|
1201
|
-
});
|
|
1202
|
-
var flatten = /* @__PURE__ */ flatMap2(identity);
|
|
1203
|
-
var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
1204
|
-
const as = fromIterable(self);
|
|
1205
|
-
const out = [];
|
|
1206
|
-
for (let i = 0; i < as.length; i++) {
|
|
1207
|
-
if (predicate(as[i], i)) {
|
|
1208
|
-
out.push(as[i]);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
return out;
|
|
1212
|
-
});
|
|
1213
|
-
var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
1214
|
-
const left3 = [];
|
|
1215
|
-
const right3 = [];
|
|
1216
|
-
const as = fromIterable(self);
|
|
1217
|
-
for (let i = 0; i < as.length; i++) {
|
|
1218
|
-
if (predicate(as[i], i)) {
|
|
1219
|
-
right3.push(as[i]);
|
|
1220
|
-
} else {
|
|
1221
|
-
left3.push(as[i]);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return [left3, right3];
|
|
1225
|
-
});
|
|
1226
|
-
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
1227
|
-
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
1228
|
-
const input = fromIterable(self);
|
|
1229
|
-
if (isNonEmptyReadonlyArray(input)) {
|
|
1230
|
-
const out = [headNonEmpty(input)];
|
|
1231
|
-
const rest = tailNonEmpty(input);
|
|
1232
|
-
for (const r of rest) {
|
|
1233
|
-
if (out.every((a) => !isEquivalent(r, a))) {
|
|
1234
|
-
out.push(r);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return out;
|
|
1238
|
-
}
|
|
1239
|
-
return [];
|
|
1240
|
-
});
|
|
1241
|
-
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
1242
|
-
|
|
1243
1315
|
// src/core/TypeScriptUtils.ts
|
|
1244
1316
|
var TypeScriptUtils = Tag("TypeScriptUtils");
|
|
1245
1317
|
var nanoLayer = (fa) => pipe(
|
|
1246
1318
|
service(TypeScriptApi),
|
|
1247
|
-
|
|
1319
|
+
flatMap2((ts) => pipe(fa, provideService(TypeScriptUtils, makeTypeScriptUtils(ts))))
|
|
1248
1320
|
);
|
|
1249
1321
|
function makeTypeScriptUtils(ts) {
|
|
1250
1322
|
const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(ts);
|
|
@@ -1314,7 +1386,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1314
1386
|
return pipe(
|
|
1315
1387
|
referencedPackages.concat(packageJsonScope?.referencedPackages || []),
|
|
1316
1388
|
dedupe,
|
|
1317
|
-
|
|
1389
|
+
map4((packageName) => packageName.toLowerCase()),
|
|
1318
1390
|
filter(
|
|
1319
1391
|
(packageName) => pattern.endsWith("*") && packageName.startsWith(pattern.toLowerCase().substring(0, pattern.length - 1))
|
|
1320
1392
|
)
|
|
@@ -1728,57 +1800,64 @@ function makeTypeScriptUtils(ts) {
|
|
|
1728
1800
|
};
|
|
1729
1801
|
}
|
|
1730
1802
|
|
|
1731
|
-
// src/core/
|
|
1732
|
-
var
|
|
1733
|
-
function
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1803
|
+
// src/core/KeyBuilder.ts
|
|
1804
|
+
var makeKeyBuilder = fn("KeyBuilder")(
|
|
1805
|
+
function* (sourceFile) {
|
|
1806
|
+
const ts = yield* service(TypeScriptApi);
|
|
1807
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
1808
|
+
const program = yield* service(TypeScriptProgram);
|
|
1809
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
1810
|
+
const packageInfo = tsUtils.resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
|
|
1811
|
+
function createString2(classNameText, kind) {
|
|
1812
|
+
if (!packageInfo) return;
|
|
1813
|
+
for (const keyPattern of options.keyPatterns) {
|
|
1814
|
+
if (keyPattern.target !== kind) continue;
|
|
1815
|
+
if (keyPattern.pattern === "package-identifier") {
|
|
1816
|
+
return packageInfo.name + "/" + classNameText;
|
|
1817
|
+
}
|
|
1818
|
+
const dirPath = getDirectoryPath(ts, sourceFile.fileName);
|
|
1819
|
+
if (!dirPath.startsWith(packageInfo.packageDirectory)) return;
|
|
1820
|
+
let subDirectory = dirPath.slice(packageInfo.packageDirectory.length);
|
|
1821
|
+
if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
|
|
1822
|
+
const lastIndex = sourceFile.fileName.lastIndexOf("/");
|
|
1823
|
+
let subModule = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
|
|
1824
|
+
for (const extension of [".ts", ".tsx", ".js", ".jsx"]) {
|
|
1825
|
+
if (subModule.toLowerCase().endsWith(extension)) {
|
|
1826
|
+
subModule = subModule.slice(0, -extension.length);
|
|
1827
|
+
break;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
if (subModule.toLowerCase().endsWith("/index")) subModule = subModule.slice(0, -6);
|
|
1831
|
+
if (subModule.startsWith("/")) subModule = subModule.slice(1);
|
|
1832
|
+
for (const prefix of keyPattern.skipLeadingPath) {
|
|
1833
|
+
if (subDirectory.startsWith(prefix)) {
|
|
1834
|
+
subDirectory = subDirectory.slice(prefix.length);
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
const parts = [packageInfo.name, subDirectory, subModule].concat(
|
|
1839
|
+
subModule.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
|
|
1840
|
+
);
|
|
1841
|
+
return parts.filter((_) => String(_).trim().length > 0).join("/");
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
return {
|
|
1845
|
+
createString: createString2
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
);
|
|
1849
|
+
var keyBuilderCache = /* @__PURE__ */ new Map();
|
|
1850
|
+
var getOrMakeKeyBuilder = fn("getOrMakeKeyBuilder")(function* (sourceFile) {
|
|
1851
|
+
const keyBuilder = keyBuilderCache.get(sourceFile.fileName) || (yield* makeKeyBuilder(sourceFile));
|
|
1852
|
+
keyBuilderCache.set(sourceFile.fileName, keyBuilder);
|
|
1853
|
+
return keyBuilder;
|
|
1854
|
+
});
|
|
1855
|
+
function createString(sourceFile, identifier, kind) {
|
|
1856
|
+
return map5(
|
|
1857
|
+
getOrMakeKeyBuilder(sourceFile),
|
|
1858
|
+
(identifierBuilder) => identifierBuilder.createString(identifier, kind)
|
|
1744
1859
|
);
|
|
1745
1860
|
}
|
|
1746
|
-
var defaults = {
|
|
1747
|
-
refactors: true,
|
|
1748
|
-
diagnostics: true,
|
|
1749
|
-
diagnosticSeverity: {},
|
|
1750
|
-
quickinfo: true,
|
|
1751
|
-
quickinfoEffectParameters: "whentruncated",
|
|
1752
|
-
completions: true,
|
|
1753
|
-
goto: true,
|
|
1754
|
-
inlays: true,
|
|
1755
|
-
allowedDuplicatedPackages: [],
|
|
1756
|
-
namespaceImportPackages: [],
|
|
1757
|
-
topLevelNamedReexports: "ignore",
|
|
1758
|
-
barrelImportPackages: [],
|
|
1759
|
-
importAliases: {},
|
|
1760
|
-
renames: true,
|
|
1761
|
-
noExternal: false
|
|
1762
|
-
};
|
|
1763
|
-
function parse(config) {
|
|
1764
|
-
return {
|
|
1765
|
-
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1766
|
-
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1767
|
-
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1768
|
-
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1769
|
-
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1770
|
-
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1771
|
-
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1772
|
-
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
1773
|
-
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1774
|
-
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1775
|
-
barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
|
|
1776
|
-
importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map4(config.importAliases, (value) => String(value)) : defaults.importAliases,
|
|
1777
|
-
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
|
|
1778
|
-
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1779
|
-
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal
|
|
1780
|
-
};
|
|
1781
|
-
}
|
|
1782
1861
|
|
|
1783
1862
|
// src/core/LSP.ts
|
|
1784
1863
|
var RefactorNotApplicableError = class {
|
|
@@ -1830,7 +1909,7 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
1830
1909
|
for (const refactor of refactors2) {
|
|
1831
1910
|
yield* pipe(
|
|
1832
1911
|
refactor.apply(sourceFile, textRange),
|
|
1833
|
-
|
|
1912
|
+
map5(
|
|
1834
1913
|
(result) => effectRefactors.push({
|
|
1835
1914
|
name: refactorNameToFullyQualifiedName(refactor.name),
|
|
1836
1915
|
description: refactor.description,
|
|
@@ -1940,7 +2019,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1940
2019
|
const fixByDisableNextLine = (node) => ({
|
|
1941
2020
|
fixName: rule.name + "_skipNextLine",
|
|
1942
2021
|
description: "Disable " + rule.name + " for this line",
|
|
1943
|
-
apply:
|
|
2022
|
+
apply: flatMap2(
|
|
1944
2023
|
service(ChangeTracker),
|
|
1945
2024
|
(changeTracker) => gen(function* () {
|
|
1946
2025
|
const disableAtNode = findParentStatementForDisableNextLine(node);
|
|
@@ -1958,7 +2037,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1958
2037
|
const fixByDisableEntireFile = {
|
|
1959
2038
|
fixName: rule.name + "_skipFile",
|
|
1960
2039
|
description: "Disable " + rule.name + " for this entire file",
|
|
1961
|
-
apply:
|
|
2040
|
+
apply: flatMap2(
|
|
1962
2041
|
service(ChangeTracker),
|
|
1963
2042
|
(changeTracker) => sync(
|
|
1964
2043
|
() => changeTracker.insertText(
|
|
@@ -2077,7 +2156,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2077
2156
|
const edit = yield* codegen.apply(sourceFile, range);
|
|
2078
2157
|
const updateHashComment = pipe(
|
|
2079
2158
|
service(ChangeTracker),
|
|
2080
|
-
|
|
2159
|
+
map5((changeTracker) => {
|
|
2081
2160
|
changeTracker.deleteRange(sourceFile, range);
|
|
2082
2161
|
changeTracker.insertText(sourceFile, range.pos, `${codegen.name}:${edit.hash}`);
|
|
2083
2162
|
})
|
|
@@ -2086,7 +2165,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2086
2165
|
...edit,
|
|
2087
2166
|
apply: pipe(
|
|
2088
2167
|
edit.apply,
|
|
2089
|
-
|
|
2168
|
+
flatMap2(() => updateHashComment)
|
|
2090
2169
|
),
|
|
2091
2170
|
ignore: updateHashComment
|
|
2092
2171
|
};
|
|
@@ -2111,10 +2190,11 @@ var contextSelfInClasses = createCompletion({
|
|
|
2111
2190
|
) || "Context";
|
|
2112
2191
|
if (contextIdentifier !== ts.idText(accessedObject)) return [];
|
|
2113
2192
|
const name = ts.idText(className);
|
|
2193
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
2114
2194
|
return [{
|
|
2115
2195
|
name: `Tag("${name}")`,
|
|
2116
2196
|
kind: ts.ScriptElementKind.constElement,
|
|
2117
|
-
insertText: `${contextIdentifier}.Tag("${
|
|
2197
|
+
insertText: `${contextIdentifier}.Tag("${tagKey}")<${name}, ${"${0}"}>(){}`,
|
|
2118
2198
|
replacementSpan,
|
|
2119
2199
|
isSnippet: true
|
|
2120
2200
|
}];
|
|
@@ -2137,8 +2217,8 @@ function makeResolveExternalModuleName(typeChecker) {
|
|
|
2137
2217
|
var TypeCheckerUtils = Tag("TypeCheckerUtils");
|
|
2138
2218
|
var nanoLayer2 = (fa) => pipe(
|
|
2139
2219
|
service(TypeScriptApi),
|
|
2140
|
-
|
|
2141
|
-
(ts) =>
|
|
2220
|
+
flatMap2(
|
|
2221
|
+
(ts) => flatMap2(service(TypeCheckerApi), (typeChecker) => pipe(fa, provideService(TypeCheckerUtils, makeTypeCheckerUtils(ts, typeChecker))))
|
|
2142
2222
|
)
|
|
2143
2223
|
);
|
|
2144
2224
|
function makeTypeCheckerUtils(ts, typeChecker) {
|
|
@@ -2517,7 +2597,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2517
2597
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2518
2598
|
return invariantTypeArgument(propertyType);
|
|
2519
2599
|
};
|
|
2520
|
-
const effectVarianceStruct = (type, atLocation) =>
|
|
2600
|
+
const effectVarianceStruct = (type, atLocation) => map5(
|
|
2521
2601
|
all(
|
|
2522
2602
|
varianceStructCovariantType(type, atLocation, "_A"),
|
|
2523
2603
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2525,7 +2605,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2525
2605
|
),
|
|
2526
2606
|
([A, E, R]) => ({ A, E, R })
|
|
2527
2607
|
);
|
|
2528
|
-
const layerVarianceStruct = (type, atLocation) =>
|
|
2608
|
+
const layerVarianceStruct = (type, atLocation) => map5(
|
|
2529
2609
|
all(
|
|
2530
2610
|
varianceStructContravariantType(type, atLocation, "_ROut"),
|
|
2531
2611
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2748,7 +2828,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2748
2828
|
}
|
|
2749
2829
|
return pipe(
|
|
2750
2830
|
importedEffectModule(propertyAccess.expression),
|
|
2751
|
-
|
|
2831
|
+
map5((effectModule) => ({
|
|
2752
2832
|
node,
|
|
2753
2833
|
effectModule,
|
|
2754
2834
|
generatorFunction,
|
|
@@ -2795,7 +2875,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2795
2875
|
}
|
|
2796
2876
|
return pipe(
|
|
2797
2877
|
importedEffectModule(propertyAccess.expression),
|
|
2798
|
-
|
|
2878
|
+
map5((effectModule) => ({
|
|
2799
2879
|
node,
|
|
2800
2880
|
effectModule,
|
|
2801
2881
|
generatorFunction,
|
|
@@ -2847,7 +2927,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2847
2927
|
}
|
|
2848
2928
|
return pipe(
|
|
2849
2929
|
importedEffectModule(propertyAccess.expression),
|
|
2850
|
-
|
|
2930
|
+
map5((effectModule) => ({
|
|
2851
2931
|
node,
|
|
2852
2932
|
generatorFunction,
|
|
2853
2933
|
effectModule,
|
|
@@ -2920,7 +3000,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2920
3000
|
"TypeParser.unnecessaryEffectGen",
|
|
2921
3001
|
(node) => node
|
|
2922
3002
|
);
|
|
2923
|
-
const effectSchemaVarianceStruct = (type, atLocation) =>
|
|
3003
|
+
const effectSchemaVarianceStruct = (type, atLocation) => map5(
|
|
2924
3004
|
all(
|
|
2925
3005
|
varianceStructInvariantType(type, atLocation, "_A"),
|
|
2926
3006
|
varianceStructInvariantType(type, atLocation, "_I"),
|
|
@@ -2952,7 +3032,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2952
3032
|
"TypeParser.effectSchemaType",
|
|
2953
3033
|
(type) => type
|
|
2954
3034
|
);
|
|
2955
|
-
const contextTagVarianceStruct = (type, atLocation) =>
|
|
3035
|
+
const contextTagVarianceStruct = (type, atLocation) => map5(
|
|
2956
3036
|
all(
|
|
2957
3037
|
varianceStructInvariantType(type, atLocation, "_Identifier"),
|
|
2958
3038
|
varianceStructInvariantType(type, atLocation, "_Service")
|
|
@@ -3084,7 +3164,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3084
3164
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3085
3165
|
const parsedSchemaModule = yield* pipe(
|
|
3086
3166
|
effectSchemaType(expressionType, expression),
|
|
3087
|
-
|
|
3167
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3088
3168
|
option
|
|
3089
3169
|
);
|
|
3090
3170
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3127,7 +3207,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3127
3207
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3128
3208
|
const parsedSchemaModule = yield* pipe(
|
|
3129
3209
|
effectSchemaType(expressionType, expression),
|
|
3130
|
-
|
|
3210
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3131
3211
|
option
|
|
3132
3212
|
);
|
|
3133
3213
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3172,7 +3252,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3172
3252
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3173
3253
|
const parsedSchemaModule = yield* pipe(
|
|
3174
3254
|
effectSchemaType(expressionType, expression),
|
|
3175
|
-
|
|
3255
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3176
3256
|
option
|
|
3177
3257
|
);
|
|
3178
3258
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3293,7 +3373,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3293
3373
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3294
3374
|
const parsedSchemaModule = yield* pipe(
|
|
3295
3375
|
effectSchemaType(expressionType, expression),
|
|
3296
|
-
|
|
3376
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3297
3377
|
option
|
|
3298
3378
|
);
|
|
3299
3379
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3437,7 +3517,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3437
3517
|
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
3438
3518
|
const parsedContextTag = yield* pipe(
|
|
3439
3519
|
importedEffectModule(effectServiceIdentifier.expression),
|
|
3440
|
-
|
|
3520
|
+
flatMap2(() => contextTag(type, atLocation)),
|
|
3441
3521
|
option
|
|
3442
3522
|
);
|
|
3443
3523
|
if (isSome2(parsedContextTag)) {
|
|
@@ -3580,7 +3660,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3580
3660
|
};
|
|
3581
3661
|
const generateReturnType = (type, atLocation2, className2) => pipe(
|
|
3582
3662
|
typeParser.effectType(type, atLocation2),
|
|
3583
|
-
|
|
3663
|
+
flatMap2((returnedEffect) => {
|
|
3584
3664
|
const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(ts.idText(className2)) : ts.factory.createUnionTypeNode(
|
|
3585
3665
|
[
|
|
3586
3666
|
ts.factory.createTypeReferenceNode(ts.idText(className2)),
|
|
@@ -3611,7 +3691,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3611
3691
|
orElse2(
|
|
3612
3692
|
() => pipe(
|
|
3613
3693
|
typeParser.promiseLike(type, atLocation2),
|
|
3614
|
-
|
|
3694
|
+
flatMap2(({ type: type2 }) => {
|
|
3615
3695
|
const successType = typeChecker.typeToTypeNode(
|
|
3616
3696
|
type2,
|
|
3617
3697
|
atLocation2,
|
|
@@ -3679,7 +3759,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3679
3759
|
for (const signature of typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call)) {
|
|
3680
3760
|
yield* pipe(
|
|
3681
3761
|
proxySignature(signature, atLocation, className),
|
|
3682
|
-
|
|
3762
|
+
map5((sig) => {
|
|
3683
3763
|
callSignatures.push(sig);
|
|
3684
3764
|
}),
|
|
3685
3765
|
ignore
|
|
@@ -3712,7 +3792,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
3712
3792
|
if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
|
|
3713
3793
|
const { Service, accessors: accessors2, className } = yield* pipe(
|
|
3714
3794
|
typeParser.extendsEffectService(node),
|
|
3715
|
-
orElse2(() =>
|
|
3795
|
+
orElse2(() => map5(typeParser.extendsEffectTag(node), (_) => ({ accessors: true, ..._ }))),
|
|
3716
3796
|
orElse2(() => fail("not a class extending Effect.Service call"))
|
|
3717
3797
|
);
|
|
3718
3798
|
if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
|
|
@@ -3746,7 +3826,7 @@ var writeTagClassAccessors = createRefactor({
|
|
|
3746
3826
|
const typeParser = yield* service(TypeParser);
|
|
3747
3827
|
const parseNode = (node) => pipe(
|
|
3748
3828
|
parse2(node),
|
|
3749
|
-
|
|
3829
|
+
map5(({ Service, atLocation, className, involvedMembers }) => ({
|
|
3750
3830
|
kind: "refactor.rewrite.effect.writeTagClassAccessors",
|
|
3751
3831
|
description: "Implement Service accessors",
|
|
3752
3832
|
apply: pipe(
|
|
@@ -3779,7 +3859,7 @@ var accessors = createCodegen({
|
|
|
3779
3859
|
if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
|
|
3780
3860
|
return yield* pipe(
|
|
3781
3861
|
parse2(nodeAndCommentRange.node),
|
|
3782
|
-
|
|
3862
|
+
map5(
|
|
3783
3863
|
(_) => ({
|
|
3784
3864
|
hash: _.hash,
|
|
3785
3865
|
description: "Generate accessors for the service",
|
|
@@ -3844,10 +3924,11 @@ var effectDataClasses = createCompletion({
|
|
|
3844
3924
|
) || "Data";
|
|
3845
3925
|
if (effectDataIdentifier !== ts.idText(accessedObject)) return [];
|
|
3846
3926
|
const name = ts.idText(className);
|
|
3927
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
3847
3928
|
return [{
|
|
3848
3929
|
name: `TaggedError("${name}")`,
|
|
3849
3930
|
kind: ts.ScriptElementKind.constElement,
|
|
3850
|
-
insertText: `${effectDataIdentifier}.TaggedError("${
|
|
3931
|
+
insertText: `${effectDataIdentifier}.TaggedError("${errorTagKey}")<{${"${0}"}}>{}`,
|
|
3851
3932
|
replacementSpan,
|
|
3852
3933
|
isSnippet: true
|
|
3853
3934
|
}, {
|
|
@@ -3959,6 +4040,67 @@ var classSelfMismatch = createDiagnostic({
|
|
|
3959
4040
|
})
|
|
3960
4041
|
});
|
|
3961
4042
|
|
|
4043
|
+
// src/diagnostics/deterministicKeys.ts
|
|
4044
|
+
var deterministicKeys = createDiagnostic({
|
|
4045
|
+
name: "deterministicKeys",
|
|
4046
|
+
code: 25,
|
|
4047
|
+
severity: "off",
|
|
4048
|
+
apply: fn("deterministicKeys.apply")(function* (sourceFile, report) {
|
|
4049
|
+
const ts = yield* service(TypeScriptApi);
|
|
4050
|
+
const typeParser = yield* service(TypeParser);
|
|
4051
|
+
const nodeToVisit = [];
|
|
4052
|
+
const appendNodeToVisit = (node) => {
|
|
4053
|
+
nodeToVisit.push(node);
|
|
4054
|
+
return void 0;
|
|
4055
|
+
};
|
|
4056
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4057
|
+
while (nodeToVisit.length > 0) {
|
|
4058
|
+
const node = nodeToVisit.shift();
|
|
4059
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
4060
|
+
const result = yield* pipe(
|
|
4061
|
+
pipe(
|
|
4062
|
+
typeParser.extendsEffectService(node),
|
|
4063
|
+
orElse2(() => typeParser.extendsContextTag(node)),
|
|
4064
|
+
orElse2(() => typeParser.extendsEffectTag(node)),
|
|
4065
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "service" }))
|
|
4066
|
+
),
|
|
4067
|
+
orElse2(
|
|
4068
|
+
() => pipe(
|
|
4069
|
+
typeParser.extendsDataTaggedError(node),
|
|
4070
|
+
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
4071
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "error" }))
|
|
4072
|
+
)
|
|
4073
|
+
),
|
|
4074
|
+
orElse2(() => void_)
|
|
4075
|
+
);
|
|
4076
|
+
if (result && result.keyStringLiteral) {
|
|
4077
|
+
const { className, keyStringLiteral } = result;
|
|
4078
|
+
const classNameText = ts.idText(className);
|
|
4079
|
+
const expectedKey = yield* createString(sourceFile, classNameText, result.target);
|
|
4080
|
+
if (!expectedKey) return;
|
|
4081
|
+
const actualIdentifier = keyStringLiteral.text;
|
|
4082
|
+
if (actualIdentifier !== expectedKey) {
|
|
4083
|
+
report({
|
|
4084
|
+
location: keyStringLiteral,
|
|
4085
|
+
messageText: `Key should be '${expectedKey}'`,
|
|
4086
|
+
fixes: [{
|
|
4087
|
+
fixName: "deterministicKeys_fix",
|
|
4088
|
+
description: `Replace '${actualIdentifier}' with '${expectedKey}'`,
|
|
4089
|
+
apply: gen(function* () {
|
|
4090
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
4091
|
+
const newStringLiteral = ts.factory.createStringLiteral(expectedKey);
|
|
4092
|
+
changeTracker.replaceNode(sourceFile, keyStringLiteral, newStringLiteral);
|
|
4093
|
+
})
|
|
4094
|
+
}]
|
|
4095
|
+
});
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4100
|
+
}
|
|
4101
|
+
})
|
|
4102
|
+
});
|
|
4103
|
+
|
|
3962
4104
|
// src/diagnostics/duplicatePackage.ts
|
|
3963
4105
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
3964
4106
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
@@ -4028,7 +4170,7 @@ var effectGenUsesAdapter = createDiagnostic({
|
|
|
4028
4170
|
if (ts.isCallExpression(node)) {
|
|
4029
4171
|
yield* pipe(
|
|
4030
4172
|
typeParser.effectGen(node),
|
|
4031
|
-
|
|
4173
|
+
map5(({ generatorFunction }) => {
|
|
4032
4174
|
if (generatorFunction.parameters.length > 0) {
|
|
4033
4175
|
const adapter = generatorFunction.parameters[0];
|
|
4034
4176
|
report({
|
|
@@ -4061,7 +4203,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4061
4203
|
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
4062
4204
|
const voidValueTypes = typeCheckerUtils.unrollUnionMembers(realEffect.A);
|
|
4063
4205
|
const voidedEffect = yield* firstSuccessOf(
|
|
4064
|
-
voidValueTypes.map((_) =>
|
|
4206
|
+
voidValueTypes.map((_) => map5(typeParser.strictEffectType(_, node), () => _))
|
|
4065
4207
|
);
|
|
4066
4208
|
return { voidedEffect };
|
|
4067
4209
|
}
|
|
@@ -4077,7 +4219,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4077
4219
|
valueNode,
|
|
4078
4220
|
realType
|
|
4079
4221
|
),
|
|
4080
|
-
|
|
4222
|
+
map5(({ voidedEffect }) => {
|
|
4081
4223
|
report(
|
|
4082
4224
|
{
|
|
4083
4225
|
location: node,
|
|
@@ -4172,7 +4314,7 @@ var genericEffectServices = createDiagnostic({
|
|
|
4172
4314
|
for (const [type, reportAt] of typesToCheck) {
|
|
4173
4315
|
yield* pipe(
|
|
4174
4316
|
typeParser.contextTag(type, node),
|
|
4175
|
-
|
|
4317
|
+
map5(() => {
|
|
4176
4318
|
report({
|
|
4177
4319
|
location: reportAt,
|
|
4178
4320
|
messageText: `Effect Services with type parameters are not supported because they cannot be properly discriminated at runtime, which may cause unexpected behavior.`,
|
|
@@ -4349,7 +4491,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4349
4491
|
let effectContextType = void 0;
|
|
4350
4492
|
yield* pipe(
|
|
4351
4493
|
typeParser.effectType(servicePropertyType, atLocation),
|
|
4352
|
-
|
|
4494
|
+
map5((_) => effectContextType = _.R),
|
|
4353
4495
|
orElse2(() => {
|
|
4354
4496
|
const servicePropertyCallSignatures = typeChecker.getSignaturesOfType(
|
|
4355
4497
|
servicePropertyType,
|
|
@@ -4361,7 +4503,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4361
4503
|
typeChecker.getReturnTypeOfSignature(servicePropertyCallSignatures[0]),
|
|
4362
4504
|
atLocation
|
|
4363
4505
|
),
|
|
4364
|
-
|
|
4506
|
+
map5((_) => {
|
|
4365
4507
|
effectContextType = _.R;
|
|
4366
4508
|
})
|
|
4367
4509
|
);
|
|
@@ -4379,7 +4521,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4379
4521
|
if (type.flags & ts.TypeFlags.Never) return succeed(true);
|
|
4380
4522
|
return pipe(
|
|
4381
4523
|
typeParser.scopeType(type, atLocation),
|
|
4382
|
-
|
|
4524
|
+
map5(() => true),
|
|
4383
4525
|
orElse2(() => succeed(false))
|
|
4384
4526
|
);
|
|
4385
4527
|
}
|
|
@@ -4435,10 +4577,10 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
4435
4577
|
for (const [type, reportAt] of typesToCheck) {
|
|
4436
4578
|
yield* pipe(
|
|
4437
4579
|
typeParser.contextTag(type, node),
|
|
4438
|
-
|
|
4580
|
+
flatMap2(
|
|
4439
4581
|
({ Service }) => pipe(
|
|
4440
4582
|
parseLeakedRequirements(Service, node),
|
|
4441
|
-
|
|
4583
|
+
map5(
|
|
4442
4584
|
(requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
|
|
4443
4585
|
)
|
|
4444
4586
|
)
|
|
@@ -4465,7 +4607,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4465
4607
|
typeParser.effectType(expectedType, node),
|
|
4466
4608
|
typeParser.effectType(realType, valueNode)
|
|
4467
4609
|
),
|
|
4468
|
-
|
|
4610
|
+
map5(
|
|
4469
4611
|
([expectedEffect, realEffect]) => typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4470
4612
|
realEffect.R,
|
|
4471
4613
|
expectedEffect.R
|
|
@@ -4483,7 +4625,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4483
4625
|
valueNode,
|
|
4484
4626
|
realType
|
|
4485
4627
|
),
|
|
4486
|
-
|
|
4628
|
+
map5(
|
|
4487
4629
|
(missingTypes) => missingTypes.length > 0 ? report(
|
|
4488
4630
|
{
|
|
4489
4631
|
location: node,
|
|
@@ -4528,7 +4670,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4528
4670
|
typeParser.effectType(expectedType, node),
|
|
4529
4671
|
typeParser.effectType(realType, valueNode)
|
|
4530
4672
|
),
|
|
4531
|
-
|
|
4673
|
+
map5(
|
|
4532
4674
|
([expectedEffect, realEffect]) => pipe(
|
|
4533
4675
|
typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4534
4676
|
realEffect.E,
|
|
@@ -4549,7 +4691,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4549
4691
|
valueNode,
|
|
4550
4692
|
realType
|
|
4551
4693
|
),
|
|
4552
|
-
|
|
4694
|
+
map5((result) => {
|
|
4553
4695
|
if (result.missingErrorTypes.length === 0) return;
|
|
4554
4696
|
const fixes = [];
|
|
4555
4697
|
if (ts.isExpression(valueNode) && result.expectedErrorType.flags & ts.TypeFlags.Never) {
|
|
@@ -4576,17 +4718,17 @@ var missingEffectError = createDiagnostic({
|
|
|
4576
4718
|
if (ts.isExpression(valueNode)) {
|
|
4577
4719
|
const propertyAssignments = pipe(
|
|
4578
4720
|
result.missingErrorTypes,
|
|
4579
|
-
|
|
4721
|
+
map4((_) => typeChecker.getPropertyOfType(_, "_tag")),
|
|
4580
4722
|
filter((_) => !!_),
|
|
4581
|
-
|
|
4723
|
+
map4((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
|
|
4582
4724
|
filter((_) => !!(_.flags & ts.TypeFlags.Literal)),
|
|
4583
|
-
|
|
4725
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
4584
4726
|
filter((_) => !!_ && ts.isLiteralTypeNode(_)),
|
|
4585
|
-
|
|
4727
|
+
map4((_) => _.literal),
|
|
4586
4728
|
filter((_) => ts.isLiteralExpression(_)),
|
|
4587
|
-
|
|
4729
|
+
map4((_) => _.text),
|
|
4588
4730
|
sort(string2),
|
|
4589
|
-
|
|
4731
|
+
map4(
|
|
4590
4732
|
(_) => ts.factory.createPropertyAssignment(
|
|
4591
4733
|
ts.factory.createIdentifier(_),
|
|
4592
4734
|
ts.factory.createArrowFunction(
|
|
@@ -4823,7 +4965,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
4823
4965
|
typeParser.effectGen(effectGenNode),
|
|
4824
4966
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
4825
4967
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
4826
|
-
|
|
4968
|
+
map5(({ generatorFunction }) => {
|
|
4827
4969
|
if (generatorFunction) {
|
|
4828
4970
|
brokenGenerators.add(ts.getTokenPosOfNode(generatorFunction, tsUtils.getSourceFileOfNode(node)));
|
|
4829
4971
|
}
|
|
@@ -4892,8 +5034,8 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4892
5034
|
const type = typeChecker.getTypeAtLocation(layer);
|
|
4893
5035
|
return pipe(
|
|
4894
5036
|
typeParser.importedEffectModule(node.expression.expression),
|
|
4895
|
-
|
|
4896
|
-
|
|
5037
|
+
flatMap2(() => typeParser.layerType(type, layer)),
|
|
5038
|
+
map5(() => ({ layer, node })),
|
|
4897
5039
|
orElse2(() => void_)
|
|
4898
5040
|
);
|
|
4899
5041
|
}
|
|
@@ -5063,7 +5205,7 @@ var outdatedEffectCodegen = createDiagnostic({
|
|
|
5063
5205
|
for (const { codegen, hash: hash2, range } of codegensWithRanges) {
|
|
5064
5206
|
yield* pipe(
|
|
5065
5207
|
getEditsForCodegen([codegen], sourceFile, range),
|
|
5066
|
-
|
|
5208
|
+
map5((applicable) => {
|
|
5067
5209
|
if (applicable.hash !== hash2) {
|
|
5068
5210
|
_report({
|
|
5069
5211
|
location: range,
|
|
@@ -5123,7 +5265,7 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
5123
5265
|
const typeAtLocation = typeChecker.getTypeAtLocation(type.expression);
|
|
5124
5266
|
const isSchema = yield* pipe(
|
|
5125
5267
|
typeParser.effectSchemaType(typeAtLocation, type.expression),
|
|
5126
|
-
|
|
5268
|
+
map5(() => true),
|
|
5127
5269
|
orElse2(() => succeed(false))
|
|
5128
5270
|
);
|
|
5129
5271
|
if (isSchema) {
|
|
@@ -5194,7 +5336,7 @@ var returnEffectInGen = createDiagnostic({
|
|
|
5194
5336
|
typeParser.effectGen(effectGenNode),
|
|
5195
5337
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5196
5338
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5197
|
-
|
|
5339
|
+
map5(() => {
|
|
5198
5340
|
const fix = node.expression ? [{
|
|
5199
5341
|
fixName: "returnEffectInGen_fix",
|
|
5200
5342
|
description: "Add yield* statement",
|
|
@@ -5257,7 +5399,7 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
5257
5399
|
const entries = typeCheckerUtils.unrollUnionMembers(type);
|
|
5258
5400
|
return pipe(
|
|
5259
5401
|
firstSuccessOf(entries.map((type2) => typeParser.scopeType(type2, node))),
|
|
5260
|
-
|
|
5402
|
+
map5(
|
|
5261
5403
|
() => report({
|
|
5262
5404
|
location: node,
|
|
5263
5405
|
messageText: `Seems like you are constructing a layer with a scope in the requirements.
|
|
@@ -5292,7 +5434,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5292
5434
|
const type = typeChecker.getTypeAtLocation(node);
|
|
5293
5435
|
yield* pipe(
|
|
5294
5436
|
typeParser.layerType(type, node),
|
|
5295
|
-
|
|
5437
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, layerEffectApiCall.methodIdentifier)),
|
|
5296
5438
|
ignore
|
|
5297
5439
|
);
|
|
5298
5440
|
continue;
|
|
@@ -5306,7 +5448,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5306
5448
|
const type = typeChecker.getTypeOfSymbolAtLocation(defaultLayer, node);
|
|
5307
5449
|
yield* pipe(
|
|
5308
5450
|
typeParser.layerType(type, node),
|
|
5309
|
-
|
|
5451
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, void 0)),
|
|
5310
5452
|
ignore
|
|
5311
5453
|
);
|
|
5312
5454
|
continue;
|
|
@@ -5416,7 +5558,7 @@ var tryCatchInEffectGen = createDiagnostic({
|
|
|
5416
5558
|
typeParser.effectGen(effectGenNode),
|
|
5417
5559
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5418
5560
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5419
|
-
|
|
5561
|
+
map5(() => {
|
|
5420
5562
|
report({
|
|
5421
5563
|
location: node,
|
|
5422
5564
|
messageText: "Avoid using try/catch inside Effect generators. Use Effect's error handling mechanisms instead (e.g., Effect.try, Effect.tryPromise, Effect.catchAll, Effect.catchTag).",
|
|
@@ -5451,7 +5593,7 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
5451
5593
|
if (ts.isCallExpression(node)) {
|
|
5452
5594
|
yield* pipe(
|
|
5453
5595
|
typeParser.unnecessaryEffectGen(node),
|
|
5454
|
-
|
|
5596
|
+
map5(
|
|
5455
5597
|
({ replacementNode }) => report({
|
|
5456
5598
|
location: node,
|
|
5457
5599
|
messageText: `This Effect.gen contains a single return statement.`,
|
|
@@ -5494,7 +5636,7 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
5494
5636
|
if (ts.isCallExpression(node)) {
|
|
5495
5637
|
yield* pipe(
|
|
5496
5638
|
typeParser.pipeCall(node),
|
|
5497
|
-
|
|
5639
|
+
map5(({ args: args2, subject }) => {
|
|
5498
5640
|
if (args2.length === 0) {
|
|
5499
5641
|
report({
|
|
5500
5642
|
location: node,
|
|
@@ -5539,10 +5681,10 @@ var unnecessaryPipeChain = createDiagnostic({
|
|
|
5539
5681
|
if (ts.isCallExpression(node)) {
|
|
5540
5682
|
yield* pipe(
|
|
5541
5683
|
typeParser.pipeCall(node),
|
|
5542
|
-
|
|
5543
|
-
(pipeCall) =>
|
|
5684
|
+
flatMap2(
|
|
5685
|
+
(pipeCall) => map5(typeParser.pipeCall(pipeCall.subject), (innerCall) => ({ pipeCall, innerCall }))
|
|
5544
5686
|
),
|
|
5545
|
-
|
|
5687
|
+
map5(({ innerCall, pipeCall }) => {
|
|
5546
5688
|
report({
|
|
5547
5689
|
location: node,
|
|
5548
5690
|
messageText: `Chained pipe calls can be simplified to a single pipe call`,
|
|
@@ -5674,7 +5816,8 @@ var diagnostics = [
|
|
|
5674
5816
|
outdatedEffectCodegen,
|
|
5675
5817
|
overriddenSchemaConstructor,
|
|
5676
5818
|
unsupportedServiceAccessors,
|
|
5677
|
-
nonObjectEffectServiceType
|
|
5819
|
+
nonObjectEffectServiceType,
|
|
5820
|
+
deterministicKeys
|
|
5678
5821
|
];
|
|
5679
5822
|
|
|
5680
5823
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -5726,6 +5869,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5726
5869
|
) || "Schema";
|
|
5727
5870
|
if (schemaIdentifier !== ts.idText(accessedObject)) return [];
|
|
5728
5871
|
const name = ts.idText(className);
|
|
5872
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
5729
5873
|
return [{
|
|
5730
5874
|
name: `Class<${name}>`,
|
|
5731
5875
|
kind: ts.ScriptElementKind.constElement,
|
|
@@ -5735,7 +5879,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5735
5879
|
}, {
|
|
5736
5880
|
name: `TaggedError<${name}>`,
|
|
5737
5881
|
kind: ts.ScriptElementKind.constElement,
|
|
5738
|
-
insertText: `${schemaIdentifier}.TaggedError<${name}>("${
|
|
5882
|
+
insertText: `${schemaIdentifier}.TaggedError<${name}>("${errorTagKey}")("${errorTagKey}", {${"${0}"}}){}`,
|
|
5739
5883
|
replacementSpan,
|
|
5740
5884
|
isSnippet: true
|
|
5741
5885
|
}, {
|
|
@@ -5770,16 +5914,17 @@ var effectSelfInClasses = createCompletion({
|
|
|
5770
5914
|
) || "Effect";
|
|
5771
5915
|
if (effectIdentifier !== ts.idText(accessedObject)) return [];
|
|
5772
5916
|
const name = ts.idText(className);
|
|
5917
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
5773
5918
|
return [{
|
|
5774
5919
|
name: `Service<${name}>`,
|
|
5775
5920
|
kind: ts.ScriptElementKind.constElement,
|
|
5776
|
-
insertText: `${effectIdentifier}.Service<${name}>()("${
|
|
5921
|
+
insertText: `${effectIdentifier}.Service<${name}>()("${tagKey}", {${"${0}"}}){}`,
|
|
5777
5922
|
replacementSpan,
|
|
5778
5923
|
isSnippet: true
|
|
5779
5924
|
}, {
|
|
5780
5925
|
name: `Tag("${name}")`,
|
|
5781
5926
|
kind: ts.ScriptElementKind.constElement,
|
|
5782
|
-
insertText: `${effectIdentifier}.Tag("${
|
|
5927
|
+
insertText: `${effectIdentifier}.Tag("${tagKey}")<${name}, {${"${0}"}}>(){}`,
|
|
5783
5928
|
replacementSpan,
|
|
5784
5929
|
isSnippet: true
|
|
5785
5930
|
}];
|
|
@@ -5805,7 +5950,7 @@ var fnFunctionStar = createCompletion({
|
|
|
5805
5950
|
const maybeFnName = pipe(
|
|
5806
5951
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5807
5952
|
filter(ts.isVariableDeclaration),
|
|
5808
|
-
|
|
5953
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5809
5954
|
filter((_) => _.length > 0),
|
|
5810
5955
|
head,
|
|
5811
5956
|
map2((name) => [
|
|
@@ -5913,7 +6058,7 @@ var schemaBrand = createCompletion({
|
|
|
5913
6058
|
return pipe(
|
|
5914
6059
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5915
6060
|
filter(ts.isVariableDeclaration),
|
|
5916
|
-
|
|
6061
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5917
6062
|
filter((_) => _.length > 0),
|
|
5918
6063
|
head,
|
|
5919
6064
|
map2((name) => [
|
|
@@ -6688,7 +6833,7 @@ var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, pr
|
|
|
6688
6833
|
const possiblyGen = node.parent;
|
|
6689
6834
|
yield* pipe(
|
|
6690
6835
|
parseType(possiblyGen),
|
|
6691
|
-
|
|
6836
|
+
map5((_) => {
|
|
6692
6837
|
const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
6693
6838
|
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.end && inlayHint.position <= _.body.getStart(sourceFile)) {
|
|
6694
6839
|
shouldOmit = true;
|
|
@@ -6729,11 +6874,22 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6729
6874
|
const options = yield* service(LanguageServicePluginOptions);
|
|
6730
6875
|
if (options.quickinfoEffectParameters === "never") return quickInfo2;
|
|
6731
6876
|
function formatTypeForQuickInfo(channelType, channelName) {
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6877
|
+
let stringRepresentation = "";
|
|
6878
|
+
if (options.quickinfoMaximumLength > 0) {
|
|
6879
|
+
const typeNode = typeChecker.typeToTypeNode(
|
|
6880
|
+
channelType,
|
|
6881
|
+
void 0,
|
|
6882
|
+
ts.NodeBuilderFlags.None,
|
|
6883
|
+
// @ts-expect-error
|
|
6884
|
+
void 0,
|
|
6885
|
+
void 0,
|
|
6886
|
+
options.quickinfoMaximumLength
|
|
6887
|
+
);
|
|
6888
|
+
const printer = ts.createPrinter({});
|
|
6889
|
+
stringRepresentation = typeNode ? printer.printNode(ts.EmitHint.Unspecified, typeNode, sourceFile) : "";
|
|
6890
|
+
} else {
|
|
6891
|
+
stringRepresentation = typeChecker.typeToString(channelType, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
6892
|
+
}
|
|
6737
6893
|
return `type ${channelName} = ${stringRepresentation}`;
|
|
6738
6894
|
}
|
|
6739
6895
|
function makeSymbolDisplayParts(title, A, E, R) {
|
|
@@ -6784,7 +6940,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6784
6940
|
type,
|
|
6785
6941
|
atLocation
|
|
6786
6942
|
),
|
|
6787
|
-
|
|
6943
|
+
map5((_) => makeSymbolDisplayParts("Effect Type Parameters", _.A, _.E, _.R)),
|
|
6788
6944
|
orElse2(() => {
|
|
6789
6945
|
const callSignatues = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
6790
6946
|
if (callSignatues.length !== 1) return succeed([]);
|
|
@@ -6794,7 +6950,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6794
6950
|
returnType,
|
|
6795
6951
|
atLocation
|
|
6796
6952
|
),
|
|
6797
|
-
|
|
6953
|
+
map5((_) => makeSymbolDisplayParts("Returned Effect Type Parameters", _.A, _.E, _.R))
|
|
6798
6954
|
);
|
|
6799
6955
|
})
|
|
6800
6956
|
);
|
|
@@ -11346,7 +11502,7 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
11346
11502
|
const { layerNode, node } = maybeNodes;
|
|
11347
11503
|
const layerInfoDisplayParts = yield* pipe(
|
|
11348
11504
|
parseLayerGraph(sourceFile, layerNode),
|
|
11349
|
-
|
|
11505
|
+
flatMap2(
|
|
11350
11506
|
({ mermaidCode, textualExplanation }) => gen(function* () {
|
|
11351
11507
|
const linkParts = [];
|
|
11352
11508
|
if (!options.noExternal) {
|
|
@@ -11778,11 +11934,11 @@ var effectGenToFn = createRefactor({
|
|
|
11778
11934
|
parentNodes,
|
|
11779
11935
|
filter((_) => ts.isVariableDeclaration(_) && _.initializer ? true : false),
|
|
11780
11936
|
filter((_) => tsUtils.isNodeInRange(textRange)(_.name)),
|
|
11781
|
-
|
|
11937
|
+
map4((_) => _.initializer)
|
|
11782
11938
|
);
|
|
11783
11939
|
const maybeNode = yield* pipe(
|
|
11784
11940
|
nodesFromInitializers.concat(parentNodes),
|
|
11785
|
-
|
|
11941
|
+
map4(parseFunctionLikeReturnEffectGen),
|
|
11786
11942
|
firstSuccessOf,
|
|
11787
11943
|
option
|
|
11788
11944
|
);
|
|
@@ -11972,7 +12128,7 @@ var layerMagic = createRefactor({
|
|
|
11972
12128
|
if (ts.isArrayLiteralExpression(node)) {
|
|
11973
12129
|
return pipe(
|
|
11974
12130
|
all(...node.elements.map((element) => extractLayers(element, false))),
|
|
11975
|
-
|
|
12131
|
+
map5(flatten)
|
|
11976
12132
|
);
|
|
11977
12133
|
}
|
|
11978
12134
|
return TypeParserIssue.issue;
|
|
@@ -11981,7 +12137,7 @@ var layerMagic = createRefactor({
|
|
|
11981
12137
|
if (ts.isExpression(node)) {
|
|
11982
12138
|
return pipe(
|
|
11983
12139
|
typeParser.layerType(typeChecker.getTypeAtLocation(node), node),
|
|
11984
|
-
|
|
12140
|
+
map5((_) => [{ node, ..._ }])
|
|
11985
12141
|
);
|
|
11986
12142
|
}
|
|
11987
12143
|
return TypeParserIssue.issue;
|
|
@@ -11992,7 +12148,7 @@ var layerMagic = createRefactor({
|
|
|
11992
12148
|
) > -1) {
|
|
11993
12149
|
return pipe(
|
|
11994
12150
|
all(...node.arguments.map((element) => extractLayers(element, false))),
|
|
11995
|
-
|
|
12151
|
+
map5(flatten)
|
|
11996
12152
|
);
|
|
11997
12153
|
}
|
|
11998
12154
|
return TypeParserIssue.issue;
|
|
@@ -12000,10 +12156,10 @@ var layerMagic = createRefactor({
|
|
|
12000
12156
|
const extractPipeSequencing = (node) => {
|
|
12001
12157
|
return pipe(
|
|
12002
12158
|
typeParser.pipeCall(node),
|
|
12003
|
-
|
|
12159
|
+
flatMap2((_) => {
|
|
12004
12160
|
return all(...[_.subject, ..._.args].map((element) => extractLayers(element, true)));
|
|
12005
12161
|
}),
|
|
12006
|
-
|
|
12162
|
+
map5(flatten)
|
|
12007
12163
|
);
|
|
12008
12164
|
};
|
|
12009
12165
|
const extractLayers = cachedBy(
|
|
@@ -12031,10 +12187,10 @@ var layerMagic = createRefactor({
|
|
|
12031
12187
|
const atLocation = adjustedNode(node);
|
|
12032
12188
|
return pipe(
|
|
12033
12189
|
extractLayers(atLocation, false),
|
|
12034
|
-
|
|
12190
|
+
flatMap2(
|
|
12035
12191
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12036
12192
|
),
|
|
12037
|
-
|
|
12193
|
+
map5((extractedLayers) => ({
|
|
12038
12194
|
kind: "refactor.rewrite.effect.layerMagicPrepare",
|
|
12039
12195
|
description: "Prepare layers for automatic composition",
|
|
12040
12196
|
apply: pipe(
|
|
@@ -12050,7 +12206,7 @@ var layerMagic = createRefactor({
|
|
|
12050
12206
|
}
|
|
12051
12207
|
const previouslyProvided = yield* pipe(
|
|
12052
12208
|
typeParser.layerType(typeChecker.getTypeAtLocation(atLocation), atLocation),
|
|
12053
|
-
|
|
12209
|
+
map5((_) => _.ROut),
|
|
12054
12210
|
option
|
|
12055
12211
|
);
|
|
12056
12212
|
const [existingBefore, newlyIntroduced] = pipe(
|
|
@@ -12062,13 +12218,13 @@ var layerMagic = createRefactor({
|
|
|
12062
12218
|
);
|
|
12063
12219
|
const typeReferences = pipe(
|
|
12064
12220
|
newlyIntroduced,
|
|
12065
|
-
|
|
12221
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
12066
12222
|
filter((_) => !!_)
|
|
12067
12223
|
);
|
|
12068
12224
|
const providesUnion = typeReferences.length === 0 ? ts.factory.createTypeReferenceNode("never") : ts.factory.createUnionTypeNode(typeReferences);
|
|
12069
12225
|
const typeStrings = pipe(
|
|
12070
12226
|
existingBefore,
|
|
12071
|
-
|
|
12227
|
+
map4((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)),
|
|
12072
12228
|
filter((_) => !!_)
|
|
12073
12229
|
);
|
|
12074
12230
|
const unionWithComment = typeStrings.length === 0 ? providesUnion : ts.addSyntheticTrailingComment(
|
|
@@ -12103,7 +12259,7 @@ var layerMagic = createRefactor({
|
|
|
12103
12259
|
if (ts.isAsExpression(expression) && expression.type.kind === ts.SyntaxKind.AnyKeyword) {
|
|
12104
12260
|
return pipe(
|
|
12105
12261
|
typeParser.layerType(typeChecker.getTypeAtLocation(node.type), node.type),
|
|
12106
|
-
|
|
12262
|
+
map5((_) => ({ node, ..._, castedStructure: expression.expression }))
|
|
12107
12263
|
);
|
|
12108
12264
|
}
|
|
12109
12265
|
}
|
|
@@ -12113,14 +12269,14 @@ var layerMagic = createRefactor({
|
|
|
12113
12269
|
const atLocation = adjustedNode(node);
|
|
12114
12270
|
return pipe(
|
|
12115
12271
|
parseAsAnyAsLayer(atLocation),
|
|
12116
|
-
|
|
12272
|
+
flatMap2(
|
|
12117
12273
|
(_targetLayer) => pipe(
|
|
12118
12274
|
extractArrayLiteral(_targetLayer.castedStructure),
|
|
12119
12275
|
orElse2(() => extractLayers(_targetLayer.castedStructure, false)),
|
|
12120
|
-
|
|
12276
|
+
flatMap2(
|
|
12121
12277
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12122
12278
|
),
|
|
12123
|
-
|
|
12279
|
+
map5((extractedLayers) => ({
|
|
12124
12280
|
kind: "refactor.rewrite.effect.layerMagicBuild",
|
|
12125
12281
|
description: "Compose layers automatically with target output services",
|
|
12126
12282
|
apply: gen(function* () {
|
|
@@ -12237,7 +12393,7 @@ var _findSchemaVariableDeclaration = fn(
|
|
|
12237
12393
|
);
|
|
12238
12394
|
return yield* pipe(
|
|
12239
12395
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
12240
|
-
|
|
12396
|
+
map4(findSchema),
|
|
12241
12397
|
firstSuccessOf,
|
|
12242
12398
|
option
|
|
12243
12399
|
);
|
|
@@ -12523,7 +12679,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12523
12679
|
filter(
|
|
12524
12680
|
(node2) => node2.arguments.length > 0
|
|
12525
12681
|
),
|
|
12526
|
-
|
|
12682
|
+
map4((node2) => {
|
|
12527
12683
|
let newNode2 = node2.arguments[0];
|
|
12528
12684
|
let didSomething = false;
|
|
12529
12685
|
for (let i = 1; i < node2.arguments.length; i++) {
|
|
@@ -12550,7 +12706,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12550
12706
|
return didSomething ? some2([node2, newNode2]) : none2();
|
|
12551
12707
|
}),
|
|
12552
12708
|
filter(isSome2),
|
|
12553
|
-
|
|
12709
|
+
map4((_) => _.value),
|
|
12554
12710
|
head
|
|
12555
12711
|
);
|
|
12556
12712
|
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
@@ -12744,7 +12900,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12744
12900
|
description: "Toggle return type annotation",
|
|
12745
12901
|
apply: pipe(
|
|
12746
12902
|
service(ChangeTracker),
|
|
12747
|
-
|
|
12903
|
+
map5((changeTracker) => removeReturnTypeAnnotation(sourceFile, changeTracker, node))
|
|
12748
12904
|
)
|
|
12749
12905
|
};
|
|
12750
12906
|
}
|
|
@@ -12761,7 +12917,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12761
12917
|
description: "Toggle return type annotation",
|
|
12762
12918
|
apply: pipe(
|
|
12763
12919
|
service(ChangeTracker),
|
|
12764
|
-
|
|
12920
|
+
map5(
|
|
12765
12921
|
(changeTracker) => addReturnTypeAnnotation(sourceFile, changeTracker, node, tsUtils.simplifyTypeNode(returnTypeNode))
|
|
12766
12922
|
)
|
|
12767
12923
|
)
|
|
@@ -13356,16 +13512,17 @@ var wrapWithEffectGen = createRefactor({
|
|
|
13356
13512
|
const findEffectToWrap = fn("wrapWithEffectGen.apply.findEffectToWrap")(
|
|
13357
13513
|
function* (node) {
|
|
13358
13514
|
if (!ts.isExpression(node)) return yield* fail("is not an expression");
|
|
13515
|
+
if (node.parent && ts.isHeritageClause(node.parent)) return yield* fail("is in a heritage clause");
|
|
13359
13516
|
const parent = node.parent;
|
|
13360
13517
|
if (parent != null && ts.isVariableDeclaration(parent) && parent.initializer !== node) return yield* fail("is LHS of variable declaration");
|
|
13361
13518
|
const type = typeChecker.getTypeAtLocation(node);
|
|
13362
|
-
yield* typeParser.
|
|
13519
|
+
yield* typeParser.strictEffectType(type, node);
|
|
13363
13520
|
return node;
|
|
13364
13521
|
}
|
|
13365
13522
|
);
|
|
13366
13523
|
const maybeNode = yield* pipe(
|
|
13367
13524
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
13368
|
-
|
|
13525
|
+
map4(findEffectToWrap),
|
|
13369
13526
|
firstSuccessOf,
|
|
13370
13527
|
option
|
|
13371
13528
|
);
|
|
@@ -13450,19 +13607,19 @@ var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _
|
|
|
13450
13607
|
const parentClass = node.parent;
|
|
13451
13608
|
if (ts.isClassDeclaration(parentClass) && parentClass.name === node) {
|
|
13452
13609
|
const baseIdentifier = yield* pipe(
|
|
13453
|
-
|
|
13454
|
-
orElse2(() =>
|
|
13455
|
-
orElse2(() =>
|
|
13610
|
+
map5(typeParser.extendsContextTag(parentClass), (_) => [_.keyStringLiteral]),
|
|
13611
|
+
orElse2(() => map5(typeParser.extendsEffectService(parentClass), (_) => [_.keyStringLiteral])),
|
|
13612
|
+
orElse2(() => map5(typeParser.extendsEffectTag(parentClass), (_) => [_.keyStringLiteral])),
|
|
13456
13613
|
orElse2(
|
|
13457
|
-
() =>
|
|
13614
|
+
() => map5(typeParser.extendsSchemaTaggedClass(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13458
13615
|
),
|
|
13459
13616
|
orElse2(
|
|
13460
|
-
() =>
|
|
13617
|
+
() => map5(typeParser.extendsSchemaTaggedError(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13461
13618
|
),
|
|
13462
|
-
orElse2(() =>
|
|
13463
|
-
orElse2(() =>
|
|
13619
|
+
orElse2(() => map5(typeParser.extendsDataTaggedError(parentClass), (_) => [_.keyStringLiteral])),
|
|
13620
|
+
orElse2(() => map5(typeParser.extendsDataTaggedClass(parentClass), (_) => [_.keyStringLiteral])),
|
|
13464
13621
|
orElse2(
|
|
13465
|
-
() =>
|
|
13622
|
+
() => map5(
|
|
13466
13623
|
typeParser.extendsSchemaTaggedRequest(parentClass),
|
|
13467
13624
|
(_) => [_.keyStringLiteral, _.tagStringLiteral]
|
|
13468
13625
|
)
|
|
@@ -13607,7 +13764,7 @@ var init = (modules) => {
|
|
|
13607
13764
|
}
|
|
13608
13765
|
return effectCodeFixes;
|
|
13609
13766
|
}),
|
|
13610
|
-
|
|
13767
|
+
flatMap2(
|
|
13611
13768
|
(effectCodeFixes) => pipe(
|
|
13612
13769
|
middlewareAutoImportQuickfixes(
|
|
13613
13770
|
sourceFile,
|
|
@@ -13616,7 +13773,7 @@ var init = (modules) => {
|
|
|
13616
13773
|
preferences,
|
|
13617
13774
|
applicableCodeFixes
|
|
13618
13775
|
),
|
|
13619
|
-
|
|
13776
|
+
map5((modifiedCodeFixes) => effectCodeFixes.concat(modifiedCodeFixes))
|
|
13620
13777
|
)
|
|
13621
13778
|
),
|
|
13622
13779
|
runNano(program),
|
|
@@ -13725,7 +13882,7 @@ var init = (modules) => {
|
|
|
13725
13882
|
if (sourceFile) {
|
|
13726
13883
|
return pipe(
|
|
13727
13884
|
appendEffectCompletionEntryData(sourceFile, applicableCompletions),
|
|
13728
|
-
|
|
13885
|
+
flatMap2(
|
|
13729
13886
|
(augmentedCompletions) => pipe(
|
|
13730
13887
|
getCompletionsAtPosition(
|
|
13731
13888
|
completions,
|
|
@@ -13734,7 +13891,7 @@ var init = (modules) => {
|
|
|
13734
13891
|
options,
|
|
13735
13892
|
formattingSettings
|
|
13736
13893
|
),
|
|
13737
|
-
|
|
13894
|
+
map5(
|
|
13738
13895
|
(effectCompletions) => augmentedCompletions ? {
|
|
13739
13896
|
...augmentedCompletions,
|
|
13740
13897
|
entries: effectCompletions.concat(augmentedCompletions.entries)
|
|
@@ -13868,7 +14025,7 @@ var init = (modules) => {
|
|
|
13868
14025
|
if (sourceFile) {
|
|
13869
14026
|
return pipe(
|
|
13870
14027
|
effectApiGetLayerGraph(sourceFile, line, character),
|
|
13871
|
-
|
|
14028
|
+
map5((response) => ({
|
|
13872
14029
|
response: {
|
|
13873
14030
|
success: true,
|
|
13874
14031
|
...response
|