@valbuild/shared 0.150.1 → 0.150.2
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/CHANGELOG.md +12 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +3 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +19 -10
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +19 -10
- package/internal/dist/valbuild-shared-internal.esm.js +19 -10
- package/package.json +2 -2
- package/typecheck/dist/valbuild-shared-typecheck.cjs.dev.js +172 -93
- package/typecheck/dist/valbuild-shared-typecheck.cjs.prod.js +172 -93
- package/typecheck/dist/valbuild-shared-typecheck.esm.js +172 -93
|
@@ -822,6 +822,7 @@ function sourceErrorOf(error, what) {
|
|
|
822
822
|
function getJson(_x, _x2, _x3) {
|
|
823
823
|
return _getJson.apply(this, arguments);
|
|
824
824
|
}
|
|
825
|
+
/** `fetch` as the caller's global has it, when no other is given. */
|
|
825
826
|
function _getJson() {
|
|
826
827
|
_getJson = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee4(fetchImpl, url, init) {
|
|
827
828
|
var res, text, parsed, message;
|
|
@@ -856,11 +857,21 @@ function _getJson() {
|
|
|
856
857
|
}));
|
|
857
858
|
return _getJson.apply(this, arguments);
|
|
858
859
|
}
|
|
860
|
+
var defaultFetch = function defaultFetch() {
|
|
861
|
+
return fetch.apply(void 0, arguments);
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Compilers already fetched, by the `fetch` that fetched them and their URL.
|
|
866
|
+
* A worker that checks a proposal and then the site asks for the same 13 MB
|
|
867
|
+
* twice, with a new `adeptSources` for each check, and a version's compiler
|
|
868
|
+
* is the same every time. A fetch that failed is not kept, so asking again
|
|
869
|
+
* asks again.
|
|
870
|
+
*/
|
|
871
|
+
var compilers = new WeakMap();
|
|
859
872
|
function adeptSources(options) {
|
|
860
873
|
var _options$fetch, _options$credentials;
|
|
861
|
-
var fetchImpl = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch :
|
|
862
|
-
return fetch.apply(void 0, arguments);
|
|
863
|
-
};
|
|
874
|
+
var fetchImpl = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch : defaultFetch;
|
|
864
875
|
var init = createForOfIteratorHelper._objectSpread2({
|
|
865
876
|
credentials: (_options$credentials = options.credentials) !== null && _options$credentials !== void 0 ? _options$credentials : "same-origin"
|
|
866
877
|
}, options.headers ? {
|
|
@@ -890,71 +901,93 @@ function adeptSources(options) {
|
|
|
890
901
|
return _ref.apply(this, arguments);
|
|
891
902
|
};
|
|
892
903
|
}();
|
|
904
|
+
var fetchCompiler = /*#__PURE__*/function () {
|
|
905
|
+
var _ref2 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(url, version) {
|
|
906
|
+
var what, answer;
|
|
907
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
908
|
+
while (1) switch (_context2.n) {
|
|
909
|
+
case 0:
|
|
910
|
+
what = "TypeScript ".concat(version);
|
|
911
|
+
_context2.n = 1;
|
|
912
|
+
return get(url, what);
|
|
913
|
+
case 1:
|
|
914
|
+
answer = _context2.v;
|
|
915
|
+
if (!(!isRecord(answer) || !isTextFiles(answer["files"]))) {
|
|
916
|
+
_context2.n = 2;
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
throw new acquireTypes.SourceError("".concat(what, ": adept answered without the compiler's files."), "unexpected-answer", false);
|
|
920
|
+
case 2:
|
|
921
|
+
return _context2.a(2, {
|
|
922
|
+
version: typeof answer["version"] === "string" ? answer["version"] : version,
|
|
923
|
+
files: answer["files"]
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}, _callee2);
|
|
927
|
+
}));
|
|
928
|
+
return function fetchCompiler(_x6, _x7) {
|
|
929
|
+
return _ref2.apply(this, arguments);
|
|
930
|
+
};
|
|
931
|
+
}();
|
|
893
932
|
return {
|
|
894
933
|
types: function types(pkg) {
|
|
895
|
-
return slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function
|
|
934
|
+
return slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3() {
|
|
896
935
|
var what, query, answer, stubs;
|
|
897
|
-
return slicedToArray._regenerator().w(function (
|
|
898
|
-
while (1) switch (
|
|
936
|
+
return slicedToArray._regenerator().w(function (_context3) {
|
|
937
|
+
while (1) switch (_context3.n) {
|
|
899
938
|
case 0:
|
|
900
939
|
what = "The types of ".concat(pkg.name, "@").concat(pkg.version);
|
|
901
940
|
query = pkg.integrity ? "?integrity=".concat(encodeURIComponent(pkg.integrity)) : "";
|
|
902
|
-
|
|
941
|
+
_context3.n = 1;
|
|
903
942
|
return get("".concat(options.base, "/types/public/").concat(pkg.name, "@").concat(pkg.version).concat(query), what);
|
|
904
943
|
case 1:
|
|
905
|
-
answer =
|
|
944
|
+
answer = _context3.v;
|
|
906
945
|
if (!(!isRecord(answer) || !isTextFiles(answer["files"]))) {
|
|
907
|
-
|
|
946
|
+
_context3.n = 2;
|
|
908
947
|
break;
|
|
909
948
|
}
|
|
910
949
|
throw new acquireTypes.SourceError("".concat(what, ": adept answered without a bundle."), "unexpected-answer", false);
|
|
911
950
|
case 2:
|
|
912
951
|
stubs = answer["stubs"];
|
|
913
|
-
return
|
|
952
|
+
return _context3.a(2, {
|
|
914
953
|
files: answer["files"],
|
|
915
954
|
stubs: Array.isArray(stubs) ? stubs.filter(function (stub) {
|
|
916
955
|
return typeof stub === "string";
|
|
917
956
|
}) : []
|
|
918
957
|
});
|
|
919
958
|
}
|
|
920
|
-
},
|
|
959
|
+
}, _callee3);
|
|
921
960
|
}))();
|
|
922
961
|
},
|
|
923
962
|
compiler: function compiler(version) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
break;
|
|
937
|
-
}
|
|
938
|
-
throw new acquireTypes.SourceError("".concat(what, ": adept answered without the compiler's files."), "unexpected-answer", false);
|
|
939
|
-
case 2:
|
|
940
|
-
return _context3.a(2, {
|
|
941
|
-
version: typeof answer["version"] === "string" ? answer["version"] : version,
|
|
942
|
-
files: answer["files"]
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
}, _callee3);
|
|
946
|
-
}))();
|
|
963
|
+
var _compilers$get;
|
|
964
|
+
var url = "".concat(options.base, "/compiler/").concat(version);
|
|
965
|
+
var kept = (_compilers$get = compilers.get(fetchImpl)) !== null && _compilers$get !== void 0 ? _compilers$get : new Map();
|
|
966
|
+
compilers.set(fetchImpl, kept);
|
|
967
|
+
var held = kept.get(url);
|
|
968
|
+
if (held !== undefined) return held;
|
|
969
|
+
var fetching = fetchCompiler(url, version);
|
|
970
|
+
kept.set(url, fetching);
|
|
971
|
+
fetching["catch"](function () {
|
|
972
|
+
if (kept.get(url) === fetching) kept["delete"](url);
|
|
973
|
+
});
|
|
974
|
+
return fetching;
|
|
947
975
|
}
|
|
948
976
|
};
|
|
949
977
|
}
|
|
950
978
|
|
|
951
979
|
/*
|
|
952
980
|
* The typecheck of a proposal whose dependencies are its own (valbuild/home
|
|
953
|
-
* `docs/adept.md`, decision 20): the
|
|
954
|
-
*
|
|
955
|
-
* would be after `pnpm install`, in the browser.
|
|
956
|
-
* does not have count, and content is told them: a
|
|
957
|
-
* of its own is not published until a typecheck
|
|
981
|
+
* `docs/adept.md`, decision 20): the proposal's code with its lockfile and,
|
|
982
|
+
* only when that has errors, the site's code with the site's lockfile -- the
|
|
983
|
+
* base -- each checked as it would be after `pnpm install`, in the browser.
|
|
984
|
+
* Only the errors the base does not have count, and content is told them: a
|
|
985
|
+
* proposal with dependencies of its own is not published until a typecheck
|
|
986
|
+
* of what it stages has none.
|
|
987
|
+
*
|
|
988
|
+
* The proposal goes first because a proposal without errors adds none,
|
|
989
|
+
* whatever the base has, and that is most of them: the base is checked only
|
|
990
|
+
* to tell the errors the site already had from the ones the proposal adds.
|
|
958
991
|
*/
|
|
959
992
|
|
|
960
993
|
/** At most this many of the new errors are sent; the count says how many. */
|
|
@@ -1002,78 +1035,95 @@ function runProposalTypecheck(_x) {
|
|
|
1002
1035
|
|
|
1003
1036
|
/** New errors by file, each file's in order: how the dialog lists them. */
|
|
1004
1037
|
function _runProposalTypecheck() {
|
|
1005
|
-
_runProposalTypecheck = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function
|
|
1006
|
-
var _deps$onStep, _yield$deps$siteSourc,
|
|
1007
|
-
var read, inputs, site, recorded,
|
|
1008
|
-
return slicedToArray._regenerator().w(function (
|
|
1009
|
-
while (1) switch (
|
|
1038
|
+
_runProposalTypecheck = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(deps) {
|
|
1039
|
+
var _deps$onStep, _yield$deps$siteSourc, _ref7, _recorded$WORKSPACE, _project$LOCKFILE, _project$WORKSPACE, _base$errors;
|
|
1040
|
+
var read, inputs, site, recorded, computed, baseLockfile, baseWorkspace, withoutLockfile, project, checkOne, next, base, errors, typecheck, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
1041
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
1042
|
+
while (1) switch (_context2.n) {
|
|
1010
1043
|
case 0:
|
|
1011
1044
|
(_deps$onStep = deps.onStep) === null || _deps$onStep === void 0 || _deps$onStep.call(deps, {
|
|
1012
1045
|
step: "reading"
|
|
1013
1046
|
});
|
|
1014
|
-
|
|
1047
|
+
_context2.n = 1;
|
|
1015
1048
|
return deps.client.files(deps.name);
|
|
1016
1049
|
case 1:
|
|
1017
|
-
read =
|
|
1050
|
+
read = _context2.v;
|
|
1018
1051
|
inputs = read.staged.inputs;
|
|
1019
1052
|
if (!(inputs === null)) {
|
|
1020
|
-
|
|
1053
|
+
_context2.n = 2;
|
|
1021
1054
|
break;
|
|
1022
1055
|
}
|
|
1023
|
-
return
|
|
1056
|
+
return _context2.a(2, {
|
|
1024
1057
|
status: "nothing-staged"
|
|
1025
1058
|
});
|
|
1026
1059
|
case 2:
|
|
1027
|
-
|
|
1060
|
+
_context2.n = 3;
|
|
1028
1061
|
return deps.siteSource();
|
|
1029
1062
|
case 3:
|
|
1030
|
-
_t2 = _yield$deps$siteSourc =
|
|
1063
|
+
_t2 = _yield$deps$siteSourc = _context2.v;
|
|
1031
1064
|
_t = _t2 !== null;
|
|
1032
1065
|
if (!_t) {
|
|
1033
|
-
|
|
1066
|
+
_context2.n = 4;
|
|
1034
1067
|
break;
|
|
1035
1068
|
}
|
|
1036
1069
|
_t = _yield$deps$siteSourc !== void 0;
|
|
1037
1070
|
case 4:
|
|
1038
1071
|
if (!_t) {
|
|
1039
|
-
|
|
1072
|
+
_context2.n = 5;
|
|
1040
1073
|
break;
|
|
1041
1074
|
}
|
|
1042
1075
|
_t3 = _yield$deps$siteSourc;
|
|
1043
|
-
|
|
1076
|
+
_context2.n = 6;
|
|
1044
1077
|
break;
|
|
1045
1078
|
case 5:
|
|
1046
1079
|
_t3 = {};
|
|
1047
1080
|
case 6:
|
|
1048
1081
|
site = _t3;
|
|
1049
|
-
|
|
1082
|
+
_context2.n = 7;
|
|
1050
1083
|
return deps.siteDependencyFiles();
|
|
1051
1084
|
case 7:
|
|
1052
|
-
recorded =
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1085
|
+
recorded = _context2.v;
|
|
1086
|
+
computed = null;
|
|
1087
|
+
baseLockfile = /*#__PURE__*/function () {
|
|
1088
|
+
var _ref5 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee() {
|
|
1089
|
+
var _ref6, _recorded$LOCKFILE, _deps$onStep2;
|
|
1090
|
+
var lockfile, packageJson;
|
|
1091
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1092
|
+
while (1) switch (_context.n) {
|
|
1093
|
+
case 0:
|
|
1094
|
+
lockfile = (_ref6 = (_recorded$LOCKFILE = recorded[LOCKFILE]) !== null && _recorded$LOCKFILE !== void 0 ? _recorded$LOCKFILE : site[LOCKFILE]) !== null && _ref6 !== void 0 ? _ref6 : computed;
|
|
1095
|
+
if (!(lockfile !== null)) {
|
|
1096
|
+
_context.n = 1;
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
return _context.a(2, lockfile);
|
|
1100
|
+
case 1:
|
|
1101
|
+
// A site made before proposals carried dependencies has no lockfile on
|
|
1102
|
+
// record: the base is checked against one computed from its package.json,
|
|
1103
|
+
// as `pnpm install` would make it.
|
|
1104
|
+
packageJson = site["package.json"];
|
|
1105
|
+
if (!(packageJson === undefined)) {
|
|
1106
|
+
_context.n = 2;
|
|
1107
|
+
break;
|
|
1108
|
+
}
|
|
1109
|
+
throw new Error("The site has no package.json, so there is nothing to check the proposal against.");
|
|
1110
|
+
case 2:
|
|
1111
|
+
(_deps$onStep2 = deps.onStep) === null || _deps$onStep2 === void 0 || _deps$onStep2.call(deps, {
|
|
1112
|
+
step: "lockfile"
|
|
1113
|
+
});
|
|
1114
|
+
_context.n = 3;
|
|
1115
|
+
return deps.computeLockfile(packageJson, deps.signal);
|
|
1116
|
+
case 3:
|
|
1117
|
+
computed = _context.v;
|
|
1118
|
+
return _context.a(2, computed);
|
|
1119
|
+
}
|
|
1120
|
+
}, _callee);
|
|
1121
|
+
}));
|
|
1122
|
+
return function baseLockfile() {
|
|
1123
|
+
return _ref5.apply(this, arguments);
|
|
1124
|
+
};
|
|
1125
|
+
}();
|
|
1126
|
+
baseWorkspace = (_ref7 = (_recorded$WORKSPACE = recorded[WORKSPACE]) !== null && _recorded$WORKSPACE !== void 0 ? _recorded$WORKSPACE : site[WORKSPACE]) !== null && _ref7 !== void 0 ? _ref7 : null;
|
|
1077
1127
|
withoutLockfile = function withoutLockfile(files) {
|
|
1078
1128
|
var out = createForOfIteratorHelper._objectSpread2({}, files);
|
|
1079
1129
|
delete out[LOCKFILE];
|
|
@@ -1096,34 +1146,63 @@ function _runProposalTypecheck() {
|
|
|
1096
1146
|
});
|
|
1097
1147
|
}
|
|
1098
1148
|
});
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1149
|
+
};
|
|
1150
|
+
_t4 = checkOne;
|
|
1151
|
+
_t5 = project;
|
|
1152
|
+
if (!((_project$LOCKFILE = project[LOCKFILE]) !== null && _project$LOCKFILE !== void 0)) {
|
|
1153
|
+
_context2.n = 8;
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
_t6 = _project$LOCKFILE;
|
|
1157
|
+
_context2.n = 10;
|
|
1158
|
+
break;
|
|
1159
|
+
case 8:
|
|
1160
|
+
_context2.n = 9;
|
|
1161
|
+
return baseLockfile();
|
|
1162
|
+
case 9:
|
|
1163
|
+
_t6 = _context2.v;
|
|
1164
|
+
case 10:
|
|
1165
|
+
_context2.n = 11;
|
|
1166
|
+
return _t4("proposal", _t5, _t6, (_project$WORKSPACE = project[WORKSPACE]) !== null && _project$WORKSPACE !== void 0 ? _project$WORKSPACE : baseWorkspace);
|
|
1103
1167
|
case 11:
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1168
|
+
next = _context2.v;
|
|
1169
|
+
if (!(next.errors.length === 0)) {
|
|
1170
|
+
_context2.n = 12;
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
_t7 = null;
|
|
1174
|
+
_context2.n = 15;
|
|
1175
|
+
break;
|
|
1107
1176
|
case 12:
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1177
|
+
_t8 = checkOne;
|
|
1178
|
+
_t9 = site;
|
|
1179
|
+
_context2.n = 13;
|
|
1180
|
+
return baseLockfile();
|
|
1181
|
+
case 13:
|
|
1182
|
+
_context2.n = 14;
|
|
1183
|
+
return _t8("site", _t9, _context2.v, baseWorkspace);
|
|
1184
|
+
case 14:
|
|
1185
|
+
_t7 = _context2.v;
|
|
1186
|
+
case 15:
|
|
1187
|
+
base = _t7;
|
|
1188
|
+
errors = newErrors((_base$errors = base === null || base === void 0 ? void 0 : base.errors) !== null && _base$errors !== void 0 ? _base$errors : [], next.errors).map(reportedError);
|
|
1189
|
+
_context2.n = 16;
|
|
1111
1190
|
return deps.client.reportTypecheck(deps.name, createForOfIteratorHelper._objectSpread2({
|
|
1112
1191
|
inputs: inputs,
|
|
1113
1192
|
newErrors: errors.slice(0, MAX_REPORTED_ERRORS)
|
|
1114
1193
|
}, errors.length > MAX_REPORTED_ERRORS ? {
|
|
1115
1194
|
count: errors.length
|
|
1116
1195
|
} : {}));
|
|
1117
|
-
case
|
|
1118
|
-
typecheck =
|
|
1119
|
-
return
|
|
1196
|
+
case 16:
|
|
1197
|
+
typecheck = _context2.v;
|
|
1198
|
+
return _context2.a(2, {
|
|
1120
1199
|
status: "checked",
|
|
1121
1200
|
inputs: inputs,
|
|
1122
1201
|
errors: errors,
|
|
1123
1202
|
typecheck: typecheck
|
|
1124
1203
|
});
|
|
1125
1204
|
}
|
|
1126
|
-
},
|
|
1205
|
+
}, _callee2);
|
|
1127
1206
|
}));
|
|
1128
1207
|
return _runProposalTypecheck.apply(this, arguments);
|
|
1129
1208
|
}
|