@valbuild/shared 0.150.20 → 0.152.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/CHANGELOG.md +268 -0
- package/client/dist/valbuild-shared-client.cjs.dev.js +1 -1
- package/client/dist/valbuild-shared-client.cjs.prod.js +1 -1
- package/client/dist/valbuild-shared-client.esm.js +1 -1
- package/dist/declarations/src/internal/ApiRoutes.d.ts +270 -2
- package/dist/declarations/src/internal/aiTools/toolNames.d.ts +1 -1
- package/dist/declarations/src/internal/content/applyChain.d.ts +124 -0
- package/dist/declarations/src/internal/content/buildRegistry.d.ts +36 -0
- package/dist/declarations/src/internal/content/jsonValuesOps.d.ts +110 -0
- package/dist/declarations/src/internal/content/moduleStore.d.ts +119 -0
- package/dist/declarations/src/internal/content/source.d.ts +71 -0
- package/dist/declarations/src/internal/content/version.d.ts +151 -0
- package/dist/declarations/src/internal/index.d.ts +8 -1
- package/dist/declarations/src/internal/publish/projectSource.d.ts +28 -0
- package/dist/declarations/src/internal/search/searchIndex.d.ts +34 -3
- package/dist/declarations/src/internal/server/types.d.ts +9 -1
- package/dist/declarations/src/internal/sketchpad/sketchFormat.d.ts +41 -6
- package/dist/declarations/src/internal/valCanvasProtocol.d.ts +46 -0
- package/dist/declarations/src/internal/valClientHeader.d.ts +36 -0
- package/dist/declarations/src/publish/callJson.d.ts +15 -0
- package/dist/declarations/src/publish/jobClient.d.ts +7 -1
- package/dist/declarations/src/publish/publishClient.d.ts +2 -14
- package/dist/{getSitemapTree-fef55872.esm.js → getSitemapTree-3c1b9e57.esm.js} +18 -2
- package/dist/{getSitemapTree-6dfa2f4e.cjs.dev.js → getSitemapTree-59c5ed5d.cjs.dev.js} +18 -2
- package/dist/{getSitemapTree-8a04f3cf.cjs.prod.js → getSitemapTree-6b9024d1.cjs.prod.js} +18 -2
- package/dist/{protocol-d0efb8cd.cjs.dev.js → projectSource-2a58ef15.cjs.dev.js} +221 -0
- package/dist/{protocol-55cfa3cf.esm.js → projectSource-7f0ee83c.esm.js} +216 -1
- package/dist/{protocol-b1055ef0.cjs.prod.js → projectSource-ed6aec39.cjs.prod.js} +221 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +2521 -192
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +2521 -192
- package/internal/dist/valbuild-shared-internal.esm.js +2463 -175
- package/package.json +3 -3
- package/publish/dist/valbuild-shared-publish.cjs.dev.js +48 -155
- package/publish/dist/valbuild-shared-publish.cjs.prod.js +48 -155
- package/publish/dist/valbuild-shared-publish.esm.js +17 -123
- package/dist/declarations/src/internal/server/requestScopedMemo.d.ts +0 -49
|
@@ -1,110 +1,12 @@
|
|
|
1
|
-
import { b as
|
|
1
|
+
import { p as publishApiOf, a as parseBuildTarget, b as parseDeclare, c as parseArtifacts, d as parseVerify, e as parsePromote, f as parseStatus, g as callJson, h as parseProjectSource, S as StudioPublishError, i as parseProblems, j as parsePress, k as parseRequestStatus, l as parseJob, m as parseRenew, n as parseCancel, o as parseDiscard, q as parseNewestCiRun, _ as _objectWithoutProperties } from '../../dist/projectSource-7f0ee83c.esm.js';
|
|
2
|
+
export { S as StudioPublishError, g as callJson, r as isTransientPublishError, s as onPublishRefusal, p as publishApiOf } from '../../dist/projectSource-7f0ee83c.esm.js';
|
|
3
|
+
import { g as _defineProperty, b as _asyncToGenerator, c as _regenerator, a as _slicedToArray, f as _createForOfIteratorHelper, _ as _typeof, d as _objectSpread2, e as _toConsumableArray } from '../../dist/createForOfIteratorHelper-9b80f1a2.esm.js';
|
|
2
4
|
import { _ as _inherits, a as _createClass, b as _wrapNativeSuper, c as _classCallCheck, d as _callSuper } from '../../dist/wrapNativeSuper-639b12b7.esm.js';
|
|
3
|
-
import { p as parseBuildTarget, a as parseDeclare, b as parseArtifacts, c as parseVerify, d as parsePromote, e as parseStatus, f as parseProjectSource, g as parseProblems, h as parsePress, i as parseRequestStatus, j as parseJob, k as parseRenew, l as parseCancel, m as parseDiscard, n as parseNewestCiRun, _ as _objectWithoutProperties } from '../../dist/protocol-55cfa3cf.esm.js';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
import { p as proposalProject } from '../../dist/proposalProject-5da177d5.esm.js';
|
|
6
7
|
export { p as proposalProject } from '../../dist/proposalProject-5da177d5.esm.js';
|
|
7
8
|
import 'zod-validation-error';
|
|
8
9
|
|
|
9
|
-
/*
|
|
10
|
-
* The one JSON call the Studio makes through its own origin's publish proxy,
|
|
11
|
-
* and the errors it throws. Apart from `publishClient.ts` (which re-exports
|
|
12
|
-
* all three) so that a worker can make the same call without importing the
|
|
13
|
-
* publish client's parsers, and `@valbuild/shared` with them.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Who hears of a refusal's body before it is thrown: the Studio's shell, which
|
|
18
|
-
* says a refusal of the project's plan with the next step (`planRefusal.ts` in
|
|
19
|
-
* `@valbuild/ui`). One listener; setting it again replaces it.
|
|
20
|
-
*/
|
|
21
|
-
var refusalListener = null;
|
|
22
|
-
function onPublishRefusal(listener) {
|
|
23
|
-
refusalListener = listener;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** The publish API refused, and said why. */
|
|
27
|
-
var StudioPublishError = /*#__PURE__*/function (_Error) {
|
|
28
|
-
function StudioPublishError(statusCode, message, body) {
|
|
29
|
-
var _this;
|
|
30
|
-
_classCallCheck(this, StudioPublishError);
|
|
31
|
-
_this = _callSuper(this, StudioPublishError, [message]);
|
|
32
|
-
_defineProperty(_this, "statusCode", void 0);
|
|
33
|
-
_defineProperty(_this, "body", void 0);
|
|
34
|
-
_this.name = "StudioPublishError";
|
|
35
|
-
_this.statusCode = statusCode;
|
|
36
|
-
_this.body = body;
|
|
37
|
-
return _this;
|
|
38
|
-
}
|
|
39
|
-
_inherits(StudioPublishError, _Error);
|
|
40
|
-
return _createClass(StudioPublishError);
|
|
41
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Was this a failure that asking again could get past?
|
|
45
|
-
*
|
|
46
|
-
* No answer at all (the request never got through) and the answers that mean
|
|
47
|
-
* "not now" -- a timeout, too many requests, a server or gateway error. Every
|
|
48
|
-
* other status is content answering, and the same request gets the same
|
|
49
|
-
* answer.
|
|
50
|
-
*/
|
|
51
|
-
function isTransientPublishError(error) {
|
|
52
|
-
if (!(error instanceof StudioPublishError)) return true;
|
|
53
|
-
return error.statusCode >= 500 || error.statusCode === 408 || error.statusCode === 429;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* One JSON call through this origin, with the session cookie: its body, or a
|
|
58
|
-
* `StudioPublishError` carrying the answer's own message.
|
|
59
|
-
*/
|
|
60
|
-
function callJson(_x, _x2, _x3, _x4) {
|
|
61
|
-
return _callJson.apply(this, arguments);
|
|
62
|
-
}
|
|
63
|
-
function _callJson() {
|
|
64
|
-
_callJson = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetchImpl, url, method, body) {
|
|
65
|
-
var res, text, parsed, _refusalListener, message;
|
|
66
|
-
return _regenerator().w(function (_context) {
|
|
67
|
-
while (1) switch (_context.n) {
|
|
68
|
-
case 0:
|
|
69
|
-
_context.n = 1;
|
|
70
|
-
return fetchImpl(url, _objectSpread2({
|
|
71
|
-
method: method,
|
|
72
|
-
// The session cookie is the whole credential this end has.
|
|
73
|
-
credentials: "same-origin"
|
|
74
|
-
}, body === undefined ? {} : {
|
|
75
|
-
headers: {
|
|
76
|
-
"Content-Type": "application/json"
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify(body)
|
|
79
|
-
}));
|
|
80
|
-
case 1:
|
|
81
|
-
res = _context.v;
|
|
82
|
-
_context.n = 2;
|
|
83
|
-
return res.text();
|
|
84
|
-
case 2:
|
|
85
|
-
text = _context.v;
|
|
86
|
-
try {
|
|
87
|
-
parsed = text === "" ? undefined : JSON.parse(text);
|
|
88
|
-
} catch (_unused) {
|
|
89
|
-
parsed = undefined;
|
|
90
|
-
}
|
|
91
|
-
if (res.ok) {
|
|
92
|
-
_context.n = 3;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
// A publish the plan does not allow (a trial's 3 publishes, a trial that
|
|
96
|
-
// ended): the shell says it, with the next step. See `planRefusal`.
|
|
97
|
-
(_refusalListener = refusalListener) === null || _refusalListener === void 0 || _refusalListener(parsed);
|
|
98
|
-
message = _typeof(parsed) === "object" && parsed !== null && "message" in parsed && typeof parsed.message === "string" ? parsed.message : "The publish API answered ".concat(res.status, ".");
|
|
99
|
-
throw new StudioPublishError(res.status, message, parsed);
|
|
100
|
-
case 3:
|
|
101
|
-
return _context.a(2, parsed);
|
|
102
|
-
}
|
|
103
|
-
}, _callee);
|
|
104
|
-
}));
|
|
105
|
-
return _callJson.apply(this, arguments);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
10
|
/** An artifact the live build has and this publish re-declares by hash. */
|
|
109
11
|
|
|
110
12
|
/** See {@link StudioPublishClient.publicFiles}. */
|
|
@@ -142,16 +44,6 @@ var StudioUploadError = /*#__PURE__*/function (_Error) {
|
|
|
142
44
|
function isExpiredSlot(error) {
|
|
143
45
|
return error instanceof StudioUploadError && error.statusCode === 403;
|
|
144
46
|
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Where content's publish API is reached: through Val's proxy on this origin
|
|
148
|
-
* (`api`, the Studio), or directly (`publishApi`, `<content>/v1`: home's
|
|
149
|
-
* upgrade page, whose `fetchImpl` adds the project token).
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
function publishApiOf(at) {
|
|
153
|
-
return "publishApi" in at ? at.publishApi.replace(/\/+$/, "") : "".concat(at.api.replace(/\/+$/, ""), "/publish-api");
|
|
154
|
-
}
|
|
155
47
|
function createStudioPublishClient(options) {
|
|
156
48
|
var _options$fetchImpl;
|
|
157
49
|
var fetchImpl = (_options$fetchImpl = options.fetchImpl) !== null && _options$fetchImpl !== void 0 ? _options$fetchImpl : fetch;
|
|
@@ -1575,25 +1467,27 @@ function createStudioJobClient(options) {
|
|
|
1575
1467
|
return press;
|
|
1576
1468
|
}(),
|
|
1577
1469
|
pressMerge: function () {
|
|
1578
|
-
var _pressMerge = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(proposal, requestId, tab, anyway) {
|
|
1470
|
+
var _pressMerge = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(proposal, requestId, tab, anyway, commitMessage) {
|
|
1579
1471
|
var _t2;
|
|
1580
1472
|
return _regenerator().w(function (_context2) {
|
|
1581
1473
|
while (1) switch (_context2.n) {
|
|
1582
1474
|
case 0:
|
|
1583
1475
|
_t2 = parsePress;
|
|
1584
1476
|
_context2.n = 1;
|
|
1585
|
-
return callJson(fetchImpl, "".concat(proposalsApi, "/").concat(encodeURIComponent(proposal), "/merge"), "POST", _objectSpread2({
|
|
1477
|
+
return callJson(fetchImpl, "".concat(proposalsApi, "/").concat(encodeURIComponent(proposal), "/merge"), "POST", _objectSpread2(_objectSpread2({
|
|
1586
1478
|
requestId: requestId,
|
|
1587
1479
|
tab: tab
|
|
1588
1480
|
}, anyway !== undefined && anyway.length > 0 ? {
|
|
1589
1481
|
anyway: anyway
|
|
1482
|
+
} : {}), commitMessage !== undefined && commitMessage.trim() !== "" ? {
|
|
1483
|
+
commitMessage: commitMessage
|
|
1590
1484
|
} : {}));
|
|
1591
1485
|
case 1:
|
|
1592
1486
|
return _context2.a(2, _t2(_context2.v, "POST /v1/proposals/{name}/merge"));
|
|
1593
1487
|
}
|
|
1594
1488
|
}, _callee2);
|
|
1595
1489
|
}));
|
|
1596
|
-
function pressMerge(_x3, _x4, _x5, _x6) {
|
|
1490
|
+
function pressMerge(_x3, _x4, _x5, _x6, _x7) {
|
|
1597
1491
|
return _pressMerge.apply(this, arguments);
|
|
1598
1492
|
}
|
|
1599
1493
|
return pressMerge;
|
|
@@ -1615,7 +1509,7 @@ function createStudioJobClient(options) {
|
|
|
1615
1509
|
}
|
|
1616
1510
|
}, _callee3);
|
|
1617
1511
|
}));
|
|
1618
|
-
function tryAgain(
|
|
1512
|
+
function tryAgain(_x8, _x9) {
|
|
1619
1513
|
return _tryAgain.apply(this, arguments);
|
|
1620
1514
|
}
|
|
1621
1515
|
return tryAgain;
|
|
@@ -1634,7 +1528,7 @@ function createStudioJobClient(options) {
|
|
|
1634
1528
|
}
|
|
1635
1529
|
}, _callee4);
|
|
1636
1530
|
}));
|
|
1637
|
-
function requestStatus(
|
|
1531
|
+
function requestStatus(_x0) {
|
|
1638
1532
|
return _requestStatus.apply(this, arguments);
|
|
1639
1533
|
}
|
|
1640
1534
|
return requestStatus;
|
|
@@ -1655,7 +1549,7 @@ function createStudioJobClient(options) {
|
|
|
1655
1549
|
}
|
|
1656
1550
|
}, _callee5);
|
|
1657
1551
|
}));
|
|
1658
|
-
function next(
|
|
1552
|
+
function next(_x1) {
|
|
1659
1553
|
return _next.apply(this, arguments);
|
|
1660
1554
|
}
|
|
1661
1555
|
return next;
|
|
@@ -1706,7 +1600,7 @@ function createStudioJobClient(options) {
|
|
|
1706
1600
|
}
|
|
1707
1601
|
}, _callee6);
|
|
1708
1602
|
}));
|
|
1709
|
-
function prepare(
|
|
1603
|
+
function prepare(_x10, _x11) {
|
|
1710
1604
|
return _prepare.apply(this, arguments);
|
|
1711
1605
|
}
|
|
1712
1606
|
return prepare;
|
|
@@ -1725,7 +1619,7 @@ function createStudioJobClient(options) {
|
|
|
1725
1619
|
}
|
|
1726
1620
|
}, _callee7);
|
|
1727
1621
|
}));
|
|
1728
|
-
function step(
|
|
1622
|
+
function step(_x12, _x13) {
|
|
1729
1623
|
return _step.apply(this, arguments);
|
|
1730
1624
|
}
|
|
1731
1625
|
return step;
|
|
@@ -1746,7 +1640,7 @@ function createStudioJobClient(options) {
|
|
|
1746
1640
|
}
|
|
1747
1641
|
}, _callee8);
|
|
1748
1642
|
}));
|
|
1749
|
-
function renew(
|
|
1643
|
+
function renew(_x14, _x15) {
|
|
1750
1644
|
return _renew.apply(this, arguments);
|
|
1751
1645
|
}
|
|
1752
1646
|
return renew;
|
|
@@ -1765,7 +1659,7 @@ function createStudioJobClient(options) {
|
|
|
1765
1659
|
}
|
|
1766
1660
|
}, _callee9);
|
|
1767
1661
|
}));
|
|
1768
|
-
function cancel(
|
|
1662
|
+
function cancel(_x16) {
|
|
1769
1663
|
return _cancel.apply(this, arguments);
|
|
1770
1664
|
}
|
|
1771
1665
|
return cancel;
|
|
@@ -1784,7 +1678,7 @@ function createStudioJobClient(options) {
|
|
|
1784
1678
|
}
|
|
1785
1679
|
}, _callee0);
|
|
1786
1680
|
}));
|
|
1787
|
-
function discard(
|
|
1681
|
+
function discard(_x17) {
|
|
1788
1682
|
return _discard.apply(this, arguments);
|
|
1789
1683
|
}
|
|
1790
1684
|
return discard;
|
|
@@ -3027,4 +2921,4 @@ function contentTypeOf(name) {
|
|
|
3027
2921
|
return (_CONTENT_TYPES$extens = CONTENT_TYPES[extension]) !== null && _CONTENT_TYPES$extens !== void 0 ? _CONTENT_TYPES$extens : "application/octet-stream";
|
|
3028
2922
|
}
|
|
3029
2923
|
|
|
3030
|
-
export { BUILD_CANCELLED_MESSAGE, DEPLOY_STOPPED_MESSAGE, MergePrepareAnswer, RENEW_EVERY_MS, SERVER_BUILDS_OFF, SERVER_BUILD_POLL_MS, SERVER_BUILD_WAIT_MS, SERVE_POLL_MS, SERVE_WAIT_MS, STUDIO_OUT_OF_DATE, STUDIO_OUT_OF_DATE_MESSAGE,
|
|
2924
|
+
export { BUILD_CANCELLED_MESSAGE, DEPLOY_STOPPED_MESSAGE, MergePrepareAnswer, RENEW_EVERY_MS, SERVER_BUILDS_OFF, SERVER_BUILD_POLL_MS, SERVER_BUILD_WAIT_MS, SERVE_POLL_MS, SERVE_WAIT_MS, STUDIO_OUT_OF_DATE, STUDIO_OUT_OF_DATE_MESSAGE, StudioUploadError, buildProposal, buildProposalOnServer, buildQuickPreview, carriedInto, clientFilesOf, createStudioJobClient, createStudioPublishClient, isExpiredSlot, isMergeChange, layerMoved, loadedLayer, markStudioOutOfDate, readLiveLayer, rememberLoadedLayer, resetLoadedLayerForTests, runJobToEnd, runStudioDeploy, runStudioJob, runStudioPublish, siteMovedSinceLoad, splitBinaryFiles, studioOutOfDateRefusals, subscribeStudioOutOfDate, withCommittedFiles, withoutLockfiles };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One value, computed once per REQUEST.
|
|
3
|
-
*
|
|
4
|
-
* `fetchVal` in draft mode reads the whole module tree out of `/sources/~`, and
|
|
5
|
-
* a page that calls it three times used to ask three times — the answer being
|
|
6
|
-
* byte-identical each time, because the query and the session are fixed for the
|
|
7
|
-
* length of a request. This is what makes the second and third call free.
|
|
8
|
-
*
|
|
9
|
-
* ## Why the scope is the REQUEST
|
|
10
|
-
*
|
|
11
|
-
* The memoised response is a DRAFT -- unpublished work, read with the caller's
|
|
12
|
-
* session cookie. Every caller allowed to read drafts gets the same draft (patch
|
|
13
|
-
* groups, which made it per author, are gone), but whether a caller is allowed
|
|
14
|
-
* at all is decided per session. A memo that outlived the request would hand
|
|
15
|
-
* the draft to the next visitor without asking, and it would be invisible: the
|
|
16
|
-
* page would simply render somebody's half-finished sentence. Sharing it across
|
|
17
|
-
* requests is possible now, keyed on the chain's head, and would be its own
|
|
18
|
-
* measured change.
|
|
19
|
-
*
|
|
20
|
-
* So this module holds NO state of its own. The caller supplies the box, and
|
|
21
|
-
* the box has to come from something the framework already scopes to the
|
|
22
|
-
* request — React's `cache()` in an RSC, a `WeakMap` keyed on the `Request` in
|
|
23
|
-
* TanStack Start. `null` means "no request scope available", and that is not an
|
|
24
|
-
* error: it falls back to computing every time, which is what the code did
|
|
25
|
-
* before this existed. Ineffective is a safe failure here; leaking is not.
|
|
26
|
-
*
|
|
27
|
-
* The `key` is the second half of that guarantee. It carries whatever the
|
|
28
|
-
* answer depends on — the session — so a box that somehow outlived its request,
|
|
29
|
-
* or is shared by two sessions, MISSES rather than serving the wrong draft.
|
|
30
|
-
*
|
|
31
|
-
* ## The promise is cached, not the value
|
|
32
|
-
*
|
|
33
|
-
* React renders siblings concurrently, so three `fetchVal` calls in one page
|
|
34
|
-
* are usually in flight at the same time rather than one after another.
|
|
35
|
-
* Caching the resolved value would dedupe none of them; caching the promise
|
|
36
|
-
* dedupes both orderings.
|
|
37
|
-
*/
|
|
38
|
-
export type RequestScopedMemo<T> = {
|
|
39
|
-
key?: string;
|
|
40
|
-
promise?: Promise<T>;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Returns the memoised promise for `key`, computing it only on a miss.
|
|
44
|
-
*
|
|
45
|
-
* A rejection is memoised along with everything else, on purpose: one failed
|
|
46
|
-
* read per request is the same answer for every caller in it, and retrying it
|
|
47
|
-
* two more times only makes a broken draft slower to render.
|
|
48
|
-
*/
|
|
49
|
-
export declare function memoizePerRequest<T>(box: RequestScopedMemo<T> | null, key: string, compute: () => Promise<T>): Promise<T>;
|