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