@valbuild/shared 0.150.8 → 0.150.11

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/client/dist/valbuild-shared-client.cjs.dev.js +16 -2
  3. package/client/dist/valbuild-shared-client.cjs.prod.js +16 -2
  4. package/client/dist/valbuild-shared-client.esm.js +2 -2
  5. package/dist/{acquireTypes-dd976839.cjs.prod.js → acquireTypes-6250a305.cjs.prod.js} +46 -46
  6. package/dist/{acquireTypes-6e2f7961.esm.js → acquireTypes-c2227b23.esm.js} +2 -2
  7. package/dist/{acquireTypes-84a4077a.cjs.dev.js → acquireTypes-c9e757a1.cjs.dev.js} +46 -46
  8. package/dist/{slicedToArray-22567815.esm.js → createForOfIteratorHelper-9b80f1a2.esm.js} +136 -106
  9. package/dist/{slicedToArray-d99b4e2e.cjs.prod.js → createForOfIteratorHelper-9ca2078d.cjs.prod.js} +142 -111
  10. package/dist/{slicedToArray-c8a29f6b.cjs.dev.js → createForOfIteratorHelper-f2d7ac6d.cjs.dev.js} +142 -111
  11. package/dist/declarations/src/client/index.d.ts +2 -0
  12. package/dist/declarations/src/internal/ApiRoutes.d.ts +23 -0
  13. package/dist/declarations/src/internal/index.d.ts +2 -0
  14. package/dist/declarations/src/internal/pageInspection.d.ts +117 -0
  15. package/dist/declarations/src/internal/quickPreview.d.ts +91 -0
  16. package/dist/declarations/src/internal/valCanvasProtocol.d.ts +53 -0
  17. package/dist/declarations/src/publish/buildProposal.d.ts +16 -1
  18. package/dist/declarations/src/publish/buildQuickPreview.d.ts +46 -0
  19. package/dist/declarations/src/publish/index.d.ts +3 -2
  20. package/dist/declarations/src/publish/runStudioDeploy.d.ts +10 -0
  21. package/dist/getSitemapTree-5354ce90.cjs.prod.js +1421 -0
  22. package/dist/getSitemapTree-97b3166f.esm.js +1381 -0
  23. package/dist/getSitemapTree-d934ff9c.cjs.dev.js +1421 -0
  24. package/dist/{proposalProject-689c24cc.esm.js → proposalProject-5da177d5.esm.js} +1 -2
  25. package/dist/{proposalProject-926f2c68.cjs.dev.js → proposalProject-76caa377.cjs.prod.js} +2 -3
  26. package/dist/{proposalProject-fab0c026.cjs.prod.js → proposalProject-81fee08f.cjs.dev.js} +2 -3
  27. package/dist/{protocol-7ddc1a71.esm.js → protocol-55cfa3cf.esm.js} +1 -1
  28. package/dist/{protocol-4e2a455b.cjs.prod.js → protocol-b1055ef0.cjs.prod.js} +6 -6
  29. package/dist/{protocol-ac1c3ec7.cjs.dev.js → protocol-d0efb8cd.cjs.dev.js} +6 -6
  30. package/dist/wrapNativeSuper-639b12b7.esm.js +107 -0
  31. package/dist/wrapNativeSuper-8673414f.cjs.prod.js +113 -0
  32. package/dist/wrapNativeSuper-933f991e.cjs.dev.js +113 -0
  33. package/internal/dist/valbuild-shared-internal.cjs.dev.js +72 -34
  34. package/internal/dist/valbuild-shared-internal.cjs.prod.js +72 -34
  35. package/internal/dist/valbuild-shared-internal.esm.js +30 -7
  36. package/package.json +2 -2
  37. package/publish/dist/valbuild-shared-publish.cjs.dev.js +589 -237
  38. package/publish/dist/valbuild-shared-publish.cjs.prod.js +589 -237
  39. package/publish/dist/valbuild-shared-publish.esm.js +504 -155
  40. package/typecheck/dist/valbuild-shared-typecheck.cjs.dev.js +34 -34
  41. package/typecheck/dist/valbuild-shared-typecheck.cjs.prod.js +34 -34
  42. package/typecheck/dist/valbuild-shared-typecheck.esm.js +5 -5
  43. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.dev.js +7 -7
  44. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.prod.js +7 -7
  45. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.esm.js +3 -3
  46. package/dist/createForOfIteratorHelper-666a6d17.esm.js +0 -137
  47. package/dist/createForOfIteratorHelper-87a33eff.cjs.dev.js +0 -145
  48. package/dist/createForOfIteratorHelper-fef4fa7d.cjs.prod.js +0 -145
  49. package/dist/getSitemapTree-873f7266.cjs.prod.js +0 -743
  50. package/dist/getSitemapTree-b6161fd8.esm.js +0 -717
  51. package/dist/getSitemapTree-be70d9fc.cjs.dev.js +0 -743
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var slicedToArray = require('../../dist/slicedToArray-d99b4e2e.cjs.prod.js');
6
- var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-fef4fa7d.cjs.prod.js');
7
- var protocol = require('../../dist/protocol-4e2a455b.cjs.prod.js');
5
+ var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-9ca2078d.cjs.prod.js');
6
+ var wrapNativeSuper = require('../../dist/wrapNativeSuper-8673414f.cjs.prod.js');
7
+ var protocol = require('../../dist/protocol-b1055ef0.cjs.prod.js');
8
8
  var zod = require('zod');
9
- var proposalProject = require('../../dist/proposalProject-fab0c026.cjs.prod.js');
9
+ var proposalProject = require('../../dist/proposalProject-76caa377.cjs.prod.js');
10
10
  require('zod-validation-error');
11
11
 
12
12
  /*
@@ -30,8 +30,8 @@ function onPublishRefusal(listener) {
30
30
  var StudioPublishError = /*#__PURE__*/function (_Error) {
31
31
  function StudioPublishError(statusCode, message, body) {
32
32
  var _this;
33
- slicedToArray._classCallCheck(this, StudioPublishError);
34
- _this = slicedToArray._callSuper(this, StudioPublishError, [message]);
33
+ wrapNativeSuper._classCallCheck(this, StudioPublishError);
34
+ _this = wrapNativeSuper._callSuper(this, StudioPublishError, [message]);
35
35
  createForOfIteratorHelper._defineProperty(_this, "statusCode", void 0);
36
36
  createForOfIteratorHelper._defineProperty(_this, "body", void 0);
37
37
  _this.name = "StudioPublishError";
@@ -39,9 +39,9 @@ var StudioPublishError = /*#__PURE__*/function (_Error) {
39
39
  _this.body = body;
40
40
  return _this;
41
41
  }
42
- slicedToArray._inherits(StudioPublishError, _Error);
43
- return slicedToArray._createClass(StudioPublishError);
44
- }(/*#__PURE__*/slicedToArray._wrapNativeSuper(Error));
42
+ wrapNativeSuper._inherits(StudioPublishError, _Error);
43
+ return wrapNativeSuper._createClass(StudioPublishError);
44
+ }(/*#__PURE__*/wrapNativeSuper._wrapNativeSuper(Error));
45
45
 
46
46
  /**
47
47
  * Was this a failure that asking again could get past?
@@ -64,9 +64,9 @@ function callJson(_x, _x2, _x3, _x4) {
64
64
  return _callJson.apply(this, arguments);
65
65
  }
66
66
  function _callJson() {
67
- _callJson = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(fetchImpl, url, method, body) {
67
+ _callJson = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(fetchImpl, url, method, body) {
68
68
  var res, text, parsed, _refusalListener, message;
69
- return slicedToArray._regenerator().w(function (_context) {
69
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
70
70
  while (1) switch (_context.n) {
71
71
  case 0:
72
72
  _context.n = 1;
@@ -116,8 +116,8 @@ function _callJson() {
116
116
  var StudioUploadError = /*#__PURE__*/function (_Error) {
117
117
  function StudioUploadError(statusCode, key, message) {
118
118
  var _this;
119
- slicedToArray._classCallCheck(this, StudioUploadError);
120
- _this = slicedToArray._callSuper(this, StudioUploadError, [message]);
119
+ wrapNativeSuper._classCallCheck(this, StudioUploadError);
120
+ _this = wrapNativeSuper._callSuper(this, StudioUploadError, [message]);
121
121
  createForOfIteratorHelper._defineProperty(_this, "statusCode", void 0);
122
122
  createForOfIteratorHelper._defineProperty(_this, "key", void 0);
123
123
  _this.name = "StudioUploadError";
@@ -125,9 +125,9 @@ var StudioUploadError = /*#__PURE__*/function (_Error) {
125
125
  _this.key = key;
126
126
  return _this;
127
127
  }
128
- slicedToArray._inherits(StudioUploadError, _Error);
129
- return slicedToArray._createClass(StudioUploadError);
130
- }(/*#__PURE__*/slicedToArray._wrapNativeSuper(Error));
128
+ wrapNativeSuper._inherits(StudioUploadError, _Error);
129
+ return wrapNativeSuper._createClass(StudioUploadError);
130
+ }(/*#__PURE__*/wrapNativeSuper._wrapNativeSuper(Error));
131
131
  /**
132
132
  * A slot's permission to write has run out.
133
133
  *
@@ -168,9 +168,9 @@ function createStudioPublishClient(options) {
168
168
  };
169
169
  return {
170
170
  buildTarget: function () {
171
- var _buildTarget = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee() {
171
+ var _buildTarget = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee() {
172
172
  var _t;
173
- return slicedToArray._regenerator().w(function (_context) {
173
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
174
174
  while (1) switch (_context.n) {
175
175
  case 0:
176
176
  _t = protocol.parseBuildTarget;
@@ -187,8 +187,8 @@ function createStudioPublishClient(options) {
187
187
  return buildTarget;
188
188
  }(),
189
189
  projectSource: function () {
190
- var _projectSource = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2() {
191
- return slicedToArray._regenerator().w(function (_context2) {
190
+ var _projectSource = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2() {
191
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
192
192
  while (1) switch (_context2.n) {
193
193
  case 0:
194
194
  _context2.n = 1;
@@ -204,9 +204,9 @@ function createStudioPublishClient(options) {
204
204
  return projectSource;
205
205
  }(),
206
206
  publicFiles: function () {
207
- var _publicFiles = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3() {
207
+ var _publicFiles = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3() {
208
208
  var _yield$readSource, publicFiles, publicPaths;
209
- return slicedToArray._regenerator().w(function (_context3) {
209
+ return createForOfIteratorHelper._regenerator().w(function (_context3) {
210
210
  while (1) switch (_context3.n) {
211
211
  case 0:
212
212
  _context3.n = 1;
@@ -241,9 +241,9 @@ function createStudioPublishClient(options) {
241
241
  return publicFiles;
242
242
  }(),
243
243
  declare: function () {
244
- var _declare = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee4(body) {
244
+ var _declare = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee4(body) {
245
245
  var _t2;
246
- return slicedToArray._regenerator().w(function (_context4) {
246
+ return createForOfIteratorHelper._regenerator().w(function (_context4) {
247
247
  while (1) switch (_context4.n) {
248
248
  case 0:
249
249
  _t2 = protocol.parseDeclare;
@@ -260,9 +260,9 @@ function createStudioPublishClient(options) {
260
260
  return declare;
261
261
  }(),
262
262
  confirmArtifacts: function () {
263
- var _confirmArtifacts = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee5(publishId) {
263
+ var _confirmArtifacts = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee5(publishId) {
264
264
  var _t3;
265
- return slicedToArray._regenerator().w(function (_context5) {
265
+ return createForOfIteratorHelper._regenerator().w(function (_context5) {
266
266
  while (1) switch (_context5.n) {
267
267
  case 0:
268
268
  _t3 = protocol.parseArtifacts;
@@ -279,9 +279,9 @@ function createStudioPublishClient(options) {
279
279
  return confirmArtifacts;
280
280
  }(),
281
281
  verify: function () {
282
- var _verify = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee6(publishId) {
282
+ var _verify = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee6(publishId) {
283
283
  var _t4;
284
- return slicedToArray._regenerator().w(function (_context6) {
284
+ return createForOfIteratorHelper._regenerator().w(function (_context6) {
285
285
  while (1) switch (_context6.n) {
286
286
  case 0:
287
287
  _t4 = protocol.parseVerify;
@@ -298,9 +298,9 @@ function createStudioPublishClient(options) {
298
298
  return verify;
299
299
  }(),
300
300
  promote: function () {
301
- var _promote = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee7(publishId) {
301
+ var _promote = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee7(publishId) {
302
302
  var _t5;
303
- return slicedToArray._regenerator().w(function (_context7) {
303
+ return createForOfIteratorHelper._regenerator().w(function (_context7) {
304
304
  while (1) switch (_context7.n) {
305
305
  case 0:
306
306
  _t5 = protocol.parsePromote;
@@ -317,9 +317,9 @@ function createStudioPublishClient(options) {
317
317
  return promote;
318
318
  }(),
319
319
  status: function () {
320
- var _status = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee8(publishId) {
320
+ var _status = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee8(publishId) {
321
321
  var _t6;
322
- return slicedToArray._regenerator().w(function (_context8) {
322
+ return createForOfIteratorHelper._regenerator().w(function (_context8) {
323
323
  while (1) switch (_context8.n) {
324
324
  case 0:
325
325
  _t6 = protocol.parseStatus;
@@ -336,9 +336,9 @@ function createStudioPublishClient(options) {
336
336
  return status;
337
337
  }(),
338
338
  upload: function () {
339
- var _upload = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee9(slot, body) {
339
+ var _upload = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee9(slot, body) {
340
340
  var res, _t7;
341
- return slicedToArray._regenerator().w(function (_context9) {
341
+ return createForOfIteratorHelper._regenerator().w(function (_context9) {
342
342
  while (1) switch (_context9.p = _context9.n) {
343
343
  case 0:
344
344
  _context9.p = 0;
@@ -400,9 +400,9 @@ function runStudioPublish(_x) {
400
400
 
401
401
  /** The problems a refusal carries, or none when its body names none. */
402
402
  function _runStudioPublish() {
403
- _runStudioPublish = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(args) {
403
+ _runStudioPublish = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(args) {
404
404
  var client, artifacts, onPhase, bodyOf, publishId, confirmed, round, declared, slots, expired, _iterator, _step, _step$value, index, slot, body, confirmation, verified, promoted, _t, _t2, _t3;
405
- return slicedToArray._regenerator().w(function (_context) {
405
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
406
406
  while (1) switch (_context.p = _context.n) {
407
407
  case 0:
408
408
  client = args.client, artifacts = args.artifacts, onPhase = args.onPhase;
@@ -455,7 +455,7 @@ function _runStudioPublish() {
455
455
  _context.n = 13;
456
456
  break;
457
457
  }
458
- _step$value = slicedToArray._slicedToArray(_step.value, 2), index = _step$value[0], slot = _step$value[1];
458
+ _step$value = createForOfIteratorHelper._slicedToArray(_step.value, 2), index = _step$value[0], slot = _step$value[1];
459
459
  onPhase({
460
460
  kind: "uploading",
461
461
  done: index,
@@ -679,12 +679,12 @@ function readLiveLayer() {
679
679
  * tell what it loaded on, or cannot tell now, publishes as before.
680
680
  */
681
681
  function _readLiveLayer() {
682
- _readLiveLayer = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee() {
682
+ _readLiveLayer = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee() {
683
683
  var fetchImpl,
684
684
  res,
685
685
  body,
686
686
  _args = arguments;
687
- return slicedToArray._regenerator().w(function (_context) {
687
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
688
688
  while (1) switch (_context.p = _context.n) {
689
689
  case 0:
690
690
  fetchImpl = _args.length > 0 && _args[0] !== undefined ? _args[0] : fetch;
@@ -752,13 +752,13 @@ function siteMovedSinceLoad() {
752
752
 
753
753
  /** The code a deploy refuses with when this page is out of date. */
754
754
  function _siteMovedSinceLoad() {
755
- _siteMovedSinceLoad = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2() {
755
+ _siteMovedSinceLoad = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2() {
756
756
  var fetchImpl,
757
757
  before,
758
758
  _args2 = arguments,
759
759
  _t2,
760
760
  _t3;
761
- return slicedToArray._regenerator().w(function (_context2) {
761
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
762
762
  while (1) switch (_context2.n) {
763
763
  case 0:
764
764
  fetchImpl = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : fetch;
@@ -837,7 +837,7 @@ function resetLoadedLayerForTests() {
837
837
  * constant is four characters and the guard that says so is worth more. See
838
838
  * `onlyBuilderRoot.test.ts`.
839
839
  */
840
- var ROUTES_PREFIX = "src/routes/";
840
+ var ROUTES_PREFIX$1 = "src/routes/";
841
841
 
842
842
  /**
843
843
  * Where a project's served-as-is files live, and the artifact prefix they are
@@ -867,10 +867,10 @@ function runStudioDeploy(_x) {
867
867
  * old file and publish the new one beside it.
868
868
  */
869
869
  function _runStudioDeploy() {
870
- _runStudioDeploy = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(options) {
870
+ _runStudioDeploy = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2(options) {
871
871
  var _options$committedFil3, _git$commit, _git, _git$branch, _git2;
872
- var client, onPhase, failed, publishByName, builder, target, source, carried, refetched, _options$target, _options$committedBin, _options$committedBin2, _options$committedFil, _yield$Promise$all, _yield$Promise$all2, readTarget, readSource, readPublic, unread, _options$committedFil2, build, git, wiredSource, _ref8, _options$branch, _yield$builder$bakedG, _options$committedBin3, _options$committedBin4, branch, wired, fileBased, generateRouteTree, binaries, extraInputs, input, name, held, live, artifacts, _live, declared, published, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21;
873
- return slicedToArray._regenerator().w(function (_context2) {
872
+ var client, onPhase, failed, stopped, publishByName, builder, _stopped, target, source, carried, refetched, _options$target, _options$committedBin, _options$committedBin2, _options$committedFil, stoppedNow, _yield$Promise$all, _yield$Promise$all2, readTarget, readSource, readPublic, unread, _options$committedFil2, _stopped2, build, git, wiredSource, _ref8, _options$branch, _yield$builder$bakedG, _options$committedBin3, _options$committedBin4, _stoppedNow, branch, wired, fileBased, generateRouteTree, binaries, extraInputs, input, name, held, _stoppedNow2, live, _stopped3, artifacts, _stoppedNow3, _stopped4, stoppedAfterBuild, _live, declared, published, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21;
873
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
874
874
  while (1) switch (_context2.p = _context2.n) {
875
875
  case 0:
876
876
  client = options.client, onPhase = options.onPhase;
@@ -881,6 +881,11 @@ function _runStudioDeploy() {
881
881
  problems: []
882
882
  };
883
883
  };
884
+ /** The deploy was stopped: `null` while it was not. */
885
+ stopped = function stopped() {
886
+ var _options$signal;
887
+ return (_options$signal = options.signal) !== null && _options$signal !== void 0 && _options$signal.aborted ? failed(DEPLOY_STOPPED_MESSAGE) : null;
888
+ };
884
889
  /*
885
890
  * The build content already holds under this name, published as any build
886
891
  * is -- or `null` when content holds none, or cannot be asked by name (one
@@ -892,10 +897,10 @@ function _runStudioDeploy() {
892
897
  * Building it again would not change it.
893
898
  */
894
899
  publishByName = /*#__PURE__*/function () {
895
- var _ref7 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(name, at) {
900
+ var _ref7 = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(name, at) {
896
901
  var _at$git$commit, _at$git, _at$git$branch, _at$git2;
897
902
  var published;
898
- return slicedToArray._regenerator().w(function (_context) {
903
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
899
904
  while (1) switch (_context.n) {
900
905
  case 0:
901
906
  _context.n = 1;
@@ -945,9 +950,16 @@ function _runStudioDeploy() {
945
950
  case 3:
946
951
  _context2.p = 3;
947
952
  _t = _context2.v;
948
- return _context2.a(2, failed(messageOf$2(_t)));
953
+ return _context2.a(2, (_stopped = stopped()) !== null && _stopped !== void 0 ? _stopped : failed(messageOf$2(_t)));
949
954
  case 4:
950
955
  _context2.p = 4;
956
+ stoppedNow = stopped();
957
+ if (!(stoppedNow !== null)) {
958
+ _context2.n = 5;
959
+ break;
960
+ }
961
+ return _context2.a(2, stoppedNow);
962
+ case 5:
951
963
  onPhase({
952
964
  kind: "reading"
953
965
  });
@@ -955,28 +967,28 @@ function _runStudioDeploy() {
955
967
  * Together, because they are one answer with two halves and neither is
956
968
  * useful alone -- and because the round trip is the cost, not the work.
957
969
  */
958
- _context2.n = 5;
970
+ _context2.n = 6;
959
971
  return Promise.all([(_options$target = options.target) !== null && _options$target !== void 0 ? _options$target : client.buildTarget(), client.projectSource(), client.publicFiles()]);
960
- case 5:
972
+ case 6:
961
973
  _yield$Promise$all = _context2.v;
962
- _yield$Promise$all2 = slicedToArray._slicedToArray(_yield$Promise$all, 3);
974
+ _yield$Promise$all2 = createForOfIteratorHelper._slicedToArray(_yield$Promise$all, 3);
963
975
  readTarget = _yield$Promise$all2[0];
964
976
  readSource = _yield$Promise$all2[1];
965
977
  readPublic = _yield$Promise$all2[2];
966
978
  if (!(readSource === null)) {
967
- _context2.n = 6;
979
+ _context2.n = 7;
968
980
  break;
969
981
  }
970
982
  return _context2.a(2, failed("This project has no published source to build from. Publish it once " + "from a checkout before editing it here."));
971
- case 6:
983
+ case 7:
972
984
  if (!(readTarget.project.rev === null)) {
973
- _context2.n = 7;
985
+ _context2.n = 8;
974
986
  break;
975
987
  }
976
988
  return _context2.a(2, failed("This project has no dependency layer yet, and one cannot be built " + "from the browser. Publish it once from a checkout, which builds it."));
977
- case 7:
989
+ case 8:
978
990
  if (!(options.target === undefined && layerMoved(options.loadedLayer, readTarget.project.rev))) {
979
- _context2.n = 8;
991
+ _context2.n = 9;
980
992
  break;
981
993
  }
982
994
  return _context2.a(2, {
@@ -987,31 +999,31 @@ function _runStudioDeploy() {
987
999
  message: STUDIO_OUT_OF_DATE_MESSAGE
988
1000
  }]
989
1001
  });
990
- case 8:
1002
+ case 9:
991
1003
  if (!(readPublic === null || "paths" in readPublic && options.fetchPublicFile === undefined)) {
992
- _context2.n = 9;
1004
+ _context2.n = 10;
993
1005
  break;
994
1006
  }
995
1007
  return _context2.a(2, failed("The Studio cannot tell which images and other public files this " + "site serves, so publishing would remove them. Publish it once from " + "a checkout with `val publish`, and the Studio can publish it from " + "then on."));
996
- case 9:
1008
+ case 10:
997
1009
  unread = (_options$committedBin = (_options$committedBin2 = options.committedBinaryFiles) === null || _options$committedBin2 === void 0 ? void 0 : _options$committedBin2.unread) !== null && _options$committedBin !== void 0 ? _options$committedBin : [];
998
1010
  if (!(unread.length > 0)) {
999
- _context2.n = 10;
1011
+ _context2.n = 11;
1000
1012
  break;
1001
1013
  }
1002
1014
  return _context2.a(2, failed("Your changes are saved, but ".concat(unread.join(", "), " could not be read ") + "back to build with, and the site would link a file it does not " + "serve. Try publishing again."));
1003
- case 10:
1015
+ case 11:
1004
1016
  target = readTarget;
1005
1017
  source = withCommittedFiles(readSource, (_options$committedFil = options.committedFiles) !== null && _options$committedFil !== void 0 ? _options$committedFil : null);
1006
1018
  if (!("carried" in readPublic)) {
1007
- _context2.n = 11;
1019
+ _context2.n = 12;
1008
1020
  break;
1009
1021
  }
1010
1022
  carried = readPublic.carried;
1011
1023
  refetched = {};
1012
- _context2.n = 13;
1024
+ _context2.n = 14;
1013
1025
  break;
1014
- case 11:
1026
+ case 12:
1015
1027
  /*
1016
1028
  * Content has no record of the live build -- a project cloned from a
1017
1029
  * template seed -- but the loader knows what it serves, and this page is
@@ -1020,19 +1032,26 @@ function _runStudioDeploy() {
1020
1032
  * carries them without fetching.
1021
1033
  */
1022
1034
  carried = [];
1023
- _context2.n = 12;
1035
+ _context2.n = 13;
1024
1036
  return refetchPublicFiles(readPublic.paths, (_options$committedFil2 = options.committedFiles) !== null && _options$committedFil2 !== void 0 ? _options$committedFil2 : null, options.fetchPublicFile);
1025
- case 12:
1026
- refetched = _context2.v;
1027
1037
  case 13:
1028
- _context2.n = 15;
1029
- break;
1038
+ refetched = _context2.v;
1030
1039
  case 14:
1031
- _context2.p = 14;
1032
- _t2 = _context2.v;
1033
- return _context2.a(2, failed(messageOf$2(_t2)));
1040
+ _context2.n = 16;
1041
+ break;
1034
1042
  case 15:
1035
1043
  _context2.p = 15;
1044
+ _t2 = _context2.v;
1045
+ return _context2.a(2, (_stopped2 = stopped()) !== null && _stopped2 !== void 0 ? _stopped2 : failed(messageOf$2(_t2)));
1046
+ case 16:
1047
+ _context2.p = 16;
1048
+ _stoppedNow = stopped();
1049
+ if (!(_stoppedNow !== null)) {
1050
+ _context2.n = 17;
1051
+ break;
1052
+ }
1053
+ return _context2.a(2, _stoppedNow);
1054
+ case 17:
1036
1055
  onPhase({
1037
1056
  kind: "building"
1038
1057
  });
@@ -1049,66 +1068,66 @@ function _runStudioDeploy() {
1049
1068
  * about which commit this build is wired at.
1050
1069
  */
1051
1070
  if (!((_options$branch = options.branch) !== null && _options$branch !== void 0)) {
1052
- _context2.n = 16;
1071
+ _context2.n = 18;
1053
1072
  break;
1054
1073
  }
1055
1074
  _t4 = _options$branch;
1056
- _context2.n = 21;
1075
+ _context2.n = 23;
1057
1076
  break;
1058
- case 16:
1059
- _context2.n = 17;
1077
+ case 18:
1078
+ _context2.n = 19;
1060
1079
  return builder.bakedGit(source);
1061
- case 17:
1080
+ case 19:
1062
1081
  _t6 = _yield$builder$bakedG = _context2.v;
1063
1082
  _t5 = _t6 === null;
1064
1083
  if (_t5) {
1065
- _context2.n = 18;
1084
+ _context2.n = 20;
1066
1085
  break;
1067
1086
  }
1068
1087
  _t5 = _yield$builder$bakedG === void 0;
1069
- case 18:
1088
+ case 20:
1070
1089
  if (!_t5) {
1071
- _context2.n = 19;
1090
+ _context2.n = 21;
1072
1091
  break;
1073
1092
  }
1074
1093
  _t7 = void 0;
1075
- _context2.n = 20;
1094
+ _context2.n = 22;
1076
1095
  break;
1077
- case 19:
1096
+ case 21:
1078
1097
  _t7 = _yield$builder$bakedG.branch;
1079
- case 20:
1098
+ case 22:
1080
1099
  _t4 = _t7;
1081
- case 21:
1100
+ case 23:
1082
1101
  _t8 = _ref8 = _t4;
1083
1102
  _t3 = _t8 !== null;
1084
1103
  if (!_t3) {
1085
- _context2.n = 22;
1104
+ _context2.n = 24;
1086
1105
  break;
1087
1106
  }
1088
1107
  _t3 = _ref8 !== void 0;
1089
- case 22:
1108
+ case 24:
1090
1109
  if (!_t3) {
1091
- _context2.n = 23;
1110
+ _context2.n = 25;
1092
1111
  break;
1093
1112
  }
1094
1113
  _t9 = _ref8;
1095
- _context2.n = 24;
1114
+ _context2.n = 26;
1096
1115
  break;
1097
- case 23:
1116
+ case 25:
1098
1117
  _t9 = null;
1099
- case 24:
1118
+ case 26:
1100
1119
  branch = _t9;
1101
1120
  git = options.commit === null || branch === null ? null : {
1102
1121
  commit: options.commit,
1103
1122
  branch: branch
1104
1123
  };
1105
- _context2.n = 25;
1124
+ _context2.n = 27;
1106
1125
  return builder.rebakeGit(source, git, options.job);
1107
- case 25:
1126
+ case 27:
1108
1127
  wired = _context2.v;
1109
1128
  wiredSource = wired;
1110
1129
  fileBased = Object.keys(wired).some(function (path) {
1111
- return path.startsWith(ROUTES_PREFIX);
1130
+ return path.startsWith(ROUTES_PREFIX$1);
1112
1131
  });
1113
1132
  /*
1114
1133
  * Read out before the branch, so the guard below and the call are the same
@@ -1116,11 +1135,11 @@ function _runStudioDeploy() {
1116
1135
  */
1117
1136
  generateRouteTree = options.generateRouteTree;
1118
1137
  if (!(fileBased && generateRouteTree === undefined)) {
1119
- _context2.n = 26;
1138
+ _context2.n = 28;
1120
1139
  break;
1121
1140
  }
1122
1141
  return _context2.a(2, failed("This project's pages are files under src/routes, and building those " + "needs a route generator this page was not given. Publish it from a " + "checkout, or mount the Studio in a deployment that supplies one."));
1123
- case 26:
1142
+ case 28:
1124
1143
  binaries = splitBinaryFiles((_options$committedBin3 = (_options$committedBin4 = options.committedBinaryFiles) === null || _options$committedBin4 === void 0 ? void 0 : _options$committedBin4.files) !== null && _options$committedBin3 !== void 0 ? _options$committedBin3 : {});
1125
1144
  /*
1126
1145
  * What this build ships that it is not built from, so the build's name
@@ -1133,18 +1152,18 @@ function _runStudioDeploy() {
1133
1152
  return ["carried:".concat(key), sha256];
1134
1153
  }));
1135
1154
  if (!(fileBased && generateRouteTree !== undefined)) {
1136
- _context2.n = 28;
1155
+ _context2.n = 30;
1137
1156
  break;
1138
1157
  }
1139
- _context2.n = 27;
1158
+ _context2.n = 29;
1140
1159
  return generateRouteTree(wired);
1141
- case 27:
1160
+ case 29:
1142
1161
  _t0 = _context2.v;
1143
- _context2.n = 29;
1162
+ _context2.n = 31;
1144
1163
  break;
1145
- case 28:
1164
+ case 30:
1146
1165
  _t0 = wired;
1147
- case 29:
1166
+ case 31:
1148
1167
  _t1 = _t0;
1149
1168
  _t10 = createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({}, refetched), binaries.publicFiles);
1150
1169
  _t11 = binaries.assets;
@@ -1159,99 +1178,120 @@ function _runStudioDeploy() {
1159
1178
  target: _t13,
1160
1179
  extraInputs: _t14
1161
1180
  };
1162
- _context2.n = 30;
1181
+ _context2.n = 32;
1163
1182
  return builder.buildInputId(input)["catch"](function () {
1164
1183
  return null;
1165
1184
  });
1166
- case 30:
1185
+ case 32:
1167
1186
  name = _context2.v;
1168
1187
  if (!(name !== null)) {
1169
- _context2.n = 33;
1188
+ _context2.n = 36;
1170
1189
  break;
1171
1190
  }
1172
- _context2.n = 31;
1191
+ _context2.n = 33;
1173
1192
  return publishByName(name, {
1174
1193
  git: git,
1175
1194
  layerRev: target.project.rev
1176
1195
  });
1177
- case 31:
1196
+ case 33:
1178
1197
  held = _context2.v;
1179
1198
  if (!(held !== null)) {
1180
- _context2.n = 32;
1199
+ _context2.n = 34;
1181
1200
  break;
1182
1201
  }
1183
1202
  return _context2.a(2, held);
1184
- case 32:
1203
+ case 34:
1204
+ _stoppedNow2 = stopped();
1205
+ if (!(_stoppedNow2 !== null)) {
1206
+ _context2.n = 35;
1207
+ break;
1208
+ }
1209
+ return _context2.a(2, _stoppedNow2);
1210
+ case 35:
1185
1211
  onPhase({
1186
1212
  kind: "building"
1187
1213
  });
1188
- case 33:
1189
- _context2.n = 34;
1214
+ case 36:
1215
+ _context2.n = 37;
1190
1216
  return builder.buildUserApp(input);
1191
- case 34:
1217
+ case 37:
1192
1218
  build = _context2.v;
1193
1219
  if (!(build.cssCode === "" && options.liveStylesheet)) {
1194
- _context2.n = 37;
1220
+ _context2.n = 40;
1195
1221
  break;
1196
1222
  }
1197
- _context2.n = 35;
1223
+ _context2.n = 38;
1198
1224
  return options.liveStylesheet();
1199
- case 35:
1225
+ case 38:
1200
1226
  live = _context2.v;
1201
1227
  if (!(live !== "")) {
1202
- _context2.n = 37;
1228
+ _context2.n = 40;
1203
1229
  break;
1204
1230
  }
1205
1231
  _t15 = createForOfIteratorHelper._objectSpread2;
1206
1232
  _t16 = createForOfIteratorHelper._objectSpread2({}, build);
1207
1233
  _t17 = {};
1208
1234
  _t18 = live;
1209
- _context2.n = 36;
1235
+ _context2.n = 39;
1210
1236
  return builder.buildInputId(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({}, input), {}, {
1211
1237
  extraInputs: createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({}, extraInputs), {}, {
1212
1238
  liveStylesheet: live
1213
1239
  })
1214
1240
  }));
1215
- case 36:
1241
+ case 39:
1216
1242
  _t19 = _context2.v;
1217
1243
  build = _t15(_t16, _t17, {
1218
1244
  cssCode: _t18,
1219
1245
  hash: _t19
1220
1246
  });
1221
- case 37:
1222
- _context2.n = 39;
1247
+ case 40:
1248
+ _context2.n = 42;
1223
1249
  break;
1224
- case 38:
1225
- _context2.p = 38;
1250
+ case 41:
1251
+ _context2.p = 41;
1226
1252
  _t20 = _context2.v;
1227
- return _context2.a(2, failed(messageOf$2(_t20)));
1228
- case 39:
1229
- _context2.p = 39;
1230
- _context2.n = 40;
1253
+ return _context2.a(2, (_stopped3 = stopped()) !== null && _stopped3 !== void 0 ? _stopped3 : failed(messageOf$2(_t20)));
1254
+ case 42:
1255
+ _context2.p = 42;
1256
+ _stoppedNow3 = stopped();
1257
+ if (!(_stoppedNow3 !== null)) {
1258
+ _context2.n = 43;
1259
+ break;
1260
+ }
1261
+ return _context2.a(2, _stoppedNow3);
1262
+ case 43:
1263
+ _context2.n = 44;
1231
1264
  return builder.publishArtifacts(build, {
1232
1265
  projectSource: wiredSource
1233
1266
  });
1234
- case 40:
1267
+ case 44:
1235
1268
  artifacts = _context2.v;
1236
- _context2.n = 42;
1269
+ _context2.n = 46;
1237
1270
  break;
1238
- case 41:
1239
- _context2.p = 41;
1271
+ case 45:
1272
+ _context2.p = 45;
1240
1273
  _t21 = _context2.v;
1241
- return _context2.a(2, failed(messageOf$2(_t21)));
1242
- case 42:
1274
+ return _context2.a(2, (_stopped4 = stopped()) !== null && _stopped4 !== void 0 ? _stopped4 : failed(messageOf$2(_t21)));
1275
+ case 46:
1276
+ stoppedAfterBuild = stopped();
1277
+ if (!(stoppedAfterBuild !== null)) {
1278
+ _context2.n = 47;
1279
+ break;
1280
+ }
1281
+ return _context2.a(2, stoppedAfterBuild);
1282
+ case 47:
1243
1283
  if (!(options.target === undefined && options.liveLayer !== undefined)) {
1244
- _context2.n = 44;
1284
+ _context2.n = 49;
1245
1285
  break;
1246
1286
  }
1247
- _context2.n = 43;
1287
+ _context2.n = 48;
1248
1288
  return options.liveLayer()["catch"](function () {
1249
1289
  return undefined;
1250
1290
  });
1251
- case 43:
1291
+ case 48:
1252
1292
  _live = _context2.v;
1253
1293
  if (!layerMoved(options.loadedLayer, _live)) {
1254
- _context2.n = 44;
1294
+ _context2.n = 49;
1255
1295
  break;
1256
1296
  }
1257
1297
  return _context2.a(2, {
@@ -1262,7 +1302,7 @@ function _runStudioDeploy() {
1262
1302
  message: STUDIO_OUT_OF_DATE_MESSAGE
1263
1303
  }]
1264
1304
  });
1265
- case 44:
1305
+ case 49:
1266
1306
  declared = [].concat(createForOfIteratorHelper._toConsumableArray(artifacts.map(function (_ref0) {
1267
1307
  var key = _ref0.key,
1268
1308
  sha256 = _ref0.sha256,
@@ -1273,7 +1313,7 @@ function _runStudioDeploy() {
1273
1313
  bytes: bytes
1274
1314
  };
1275
1315
  })), createForOfIteratorHelper._toConsumableArray(carriedInto(artifacts, carried, (_options$committedFil3 = options.committedFiles) !== null && _options$committedFil3 !== void 0 ? _options$committedFil3 : null)));
1276
- _context2.n = 45;
1316
+ _context2.n = 50;
1277
1317
  return runStudioPublish(createForOfIteratorHelper._objectSpread2({
1278
1318
  client: client,
1279
1319
  artifacts: artifacts,
@@ -1297,11 +1337,11 @@ function _runStudioDeploy() {
1297
1337
  }, options.until !== undefined ? {
1298
1338
  until: options.until
1299
1339
  } : {}));
1300
- case 45:
1340
+ case 50:
1301
1341
  published = _context2.v;
1302
1342
  return _context2.a(2, asDeployResult(published));
1303
1343
  }
1304
- }, _callee2, null, [[39, 41], [15, 38], [4, 14], [1, 3]]);
1344
+ }, _callee2, null, [[42, 45], [16, 41], [4, 15], [1, 3]]);
1305
1345
  }));
1306
1346
  return _runStudioDeploy.apply(this, arguments);
1307
1347
  }
@@ -1309,7 +1349,7 @@ function withCommittedFiles(source, committed) {
1309
1349
  if (committed === null) return source;
1310
1350
  var out = createForOfIteratorHelper._objectSpread2({}, source);
1311
1351
  for (var _i = 0, _Object$entries = Object.entries(committed); _i < _Object$entries.length; _i++) {
1312
- var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
1352
+ var _Object$entries$_i = createForOfIteratorHelper._slicedToArray(_Object$entries[_i], 2),
1313
1353
  path = _Object$entries$_i[0],
1314
1354
  content = _Object$entries$_i[1];
1315
1355
  var key = path.replace(/^\/+/, "");
@@ -1327,7 +1367,7 @@ function splitBinaryFiles(files) {
1327
1367
  var publicFiles = {};
1328
1368
  var assets = {};
1329
1369
  for (var _i2 = 0, _Object$entries2 = Object.entries(files); _i2 < _Object$entries2.length; _i2++) {
1330
- var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
1370
+ var _Object$entries2$_i = createForOfIteratorHelper._slicedToArray(_Object$entries2[_i2], 2),
1331
1371
  path = _Object$entries2$_i[0],
1332
1372
  base64 = _Object$entries2$_i[1];
1333
1373
  var key = path.replace(/^\/+/, "");
@@ -1359,17 +1399,17 @@ function refetchPublicFiles(_x2, _x3, _x4) {
1359
1399
  * `runStudioPublish` refuses rather than publishing a hole.
1360
1400
  */
1361
1401
  function _refetchPublicFiles() {
1362
- _refetchPublicFiles = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(paths, committed, fetchPublicFile) {
1402
+ _refetchPublicFiles = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3(paths, committed, fetchPublicFile) {
1363
1403
  var deleted, out, _iterator, _step, path, key, _t22, _t23;
1364
- return slicedToArray._regenerator().w(function (_context3) {
1404
+ return createForOfIteratorHelper._regenerator().w(function (_context3) {
1365
1405
  while (1) switch (_context3.p = _context3.n) {
1366
1406
  case 0:
1367
1407
  deleted = new Set(Object.entries(committed !== null && committed !== void 0 ? committed : {}).filter(function (_ref1) {
1368
- var _ref10 = slicedToArray._slicedToArray(_ref1, 2),
1408
+ var _ref10 = createForOfIteratorHelper._slicedToArray(_ref1, 2),
1369
1409
  content = _ref10[1];
1370
1410
  return content === null;
1371
1411
  }).map(function (_ref11) {
1372
- var _ref12 = slicedToArray._slicedToArray(_ref11, 1),
1412
+ var _ref12 = createForOfIteratorHelper._slicedToArray(_ref11, 1),
1373
1413
  path = _ref12[0];
1374
1414
  return path.replace(/^\/+/, "");
1375
1415
  }));
@@ -1436,11 +1476,11 @@ function carriedInto(built, carried, committed) {
1436
1476
  return key;
1437
1477
  }));
1438
1478
  var deleted = new Set(Object.entries(committed !== null && committed !== void 0 ? committed : {}).filter(function (_ref2) {
1439
- var _ref3 = slicedToArray._slicedToArray(_ref2, 2),
1479
+ var _ref3 = createForOfIteratorHelper._slicedToArray(_ref2, 2),
1440
1480
  content = _ref3[1];
1441
1481
  return content === null;
1442
1482
  }).map(function (_ref4) {
1443
- var _ref5 = slicedToArray._slicedToArray(_ref4, 1),
1483
+ var _ref5 = createForOfIteratorHelper._slicedToArray(_ref4, 1),
1444
1484
  path = _ref5[0];
1445
1485
  return path.replace(/^\/+/, "");
1446
1486
  }));
@@ -1449,6 +1489,9 @@ function carriedInto(built, carried, committed) {
1449
1489
  return key.startsWith(PUBLIC_PREFIX) && !produced.has(key) && !deleted.has(key);
1450
1490
  });
1451
1491
  }
1492
+
1493
+ /** What a deploy stopped by its `signal` answers. */
1494
+ var DEPLOY_STOPPED_MESSAGE = "The build was stopped.";
1452
1495
  var asDeployResult = function asDeployResult(published) {
1453
1496
  switch (published.status) {
1454
1497
  case "live":
@@ -1513,9 +1556,9 @@ function createStudioJobClient(options) {
1513
1556
  };
1514
1557
  return {
1515
1558
  press: function () {
1516
- var _press = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(requestId, tab) {
1559
+ var _press = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(requestId, tab) {
1517
1560
  var _t;
1518
- return slicedToArray._regenerator().w(function (_context) {
1561
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
1519
1562
  while (1) switch (_context.n) {
1520
1563
  case 0:
1521
1564
  _t = protocol.parsePress;
@@ -1535,9 +1578,9 @@ function createStudioJobClient(options) {
1535
1578
  return press;
1536
1579
  }(),
1537
1580
  pressMerge: function () {
1538
- var _pressMerge = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(proposal, requestId, tab, anyway) {
1581
+ var _pressMerge = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2(proposal, requestId, tab, anyway) {
1539
1582
  var _t2;
1540
- return slicedToArray._regenerator().w(function (_context2) {
1583
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
1541
1584
  while (1) switch (_context2.n) {
1542
1585
  case 0:
1543
1586
  _t2 = protocol.parsePress;
@@ -1559,9 +1602,9 @@ function createStudioJobClient(options) {
1559
1602
  return pressMerge;
1560
1603
  }(),
1561
1604
  tryAgain: function () {
1562
- var _tryAgain = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(requestId, tab) {
1605
+ var _tryAgain = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3(requestId, tab) {
1563
1606
  var _t3;
1564
- return slicedToArray._regenerator().w(function (_context3) {
1607
+ return createForOfIteratorHelper._regenerator().w(function (_context3) {
1565
1608
  while (1) switch (_context3.n) {
1566
1609
  case 0:
1567
1610
  _t3 = protocol.parsePress;
@@ -1581,9 +1624,9 @@ function createStudioJobClient(options) {
1581
1624
  return tryAgain;
1582
1625
  }(),
1583
1626
  requestStatus: function () {
1584
- var _requestStatus = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee4(requestId) {
1627
+ var _requestStatus = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee4(requestId) {
1585
1628
  var _t4;
1586
- return slicedToArray._regenerator().w(function (_context4) {
1629
+ return createForOfIteratorHelper._regenerator().w(function (_context4) {
1587
1630
  while (1) switch (_context4.n) {
1588
1631
  case 0:
1589
1632
  _t4 = protocol.parseRequestStatus;
@@ -1600,9 +1643,9 @@ function createStudioJobClient(options) {
1600
1643
  return requestStatus;
1601
1644
  }(),
1602
1645
  next: function () {
1603
- var _next = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee5(tab) {
1646
+ var _next = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee5(tab) {
1604
1647
  var _t5;
1605
- return slicedToArray._regenerator().w(function (_context5) {
1648
+ return createForOfIteratorHelper._regenerator().w(function (_context5) {
1606
1649
  while (1) switch (_context5.n) {
1607
1650
  case 0:
1608
1651
  _t5 = protocol.parseJob;
@@ -1621,9 +1664,9 @@ function createStudioJobClient(options) {
1621
1664
  return next;
1622
1665
  }(),
1623
1666
  prepare: function () {
1624
- var _prepare = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee6(tabJob, tab) {
1667
+ var _prepare = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee6(tabJob, tab) {
1625
1668
  var merged, answer, _t6;
1626
- return slicedToArray._regenerator().w(function (_context6) {
1669
+ return createForOfIteratorHelper._regenerator().w(function (_context6) {
1627
1670
  while (1) switch (_context6.n) {
1628
1671
  case 0:
1629
1672
  if (!tabJob.patches.some(isMergeChange)) {
@@ -1672,9 +1715,9 @@ function createStudioJobClient(options) {
1672
1715
  return prepare;
1673
1716
  }(),
1674
1717
  step: function () {
1675
- var _step = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee7(jobId, body) {
1718
+ var _step = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee7(jobId, body) {
1676
1719
  var _t7;
1677
- return slicedToArray._regenerator().w(function (_context7) {
1720
+ return createForOfIteratorHelper._regenerator().w(function (_context7) {
1678
1721
  while (1) switch (_context7.n) {
1679
1722
  case 0:
1680
1723
  _t7 = protocol.parseJob;
@@ -1691,9 +1734,9 @@ function createStudioJobClient(options) {
1691
1734
  return step;
1692
1735
  }(),
1693
1736
  renew: function () {
1694
- var _renew = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee8(jobId, tab) {
1737
+ var _renew = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee8(jobId, tab) {
1695
1738
  var _t8;
1696
- return slicedToArray._regenerator().w(function (_context8) {
1739
+ return createForOfIteratorHelper._regenerator().w(function (_context8) {
1697
1740
  while (1) switch (_context8.n) {
1698
1741
  case 0:
1699
1742
  _t8 = protocol.parseRenew;
@@ -1712,9 +1755,9 @@ function createStudioJobClient(options) {
1712
1755
  return renew;
1713
1756
  }(),
1714
1757
  cancel: function () {
1715
- var _cancel = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee9(jobId) {
1758
+ var _cancel = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee9(jobId) {
1716
1759
  var _t9;
1717
- return slicedToArray._regenerator().w(function (_context9) {
1760
+ return createForOfIteratorHelper._regenerator().w(function (_context9) {
1718
1761
  while (1) switch (_context9.n) {
1719
1762
  case 0:
1720
1763
  _t9 = protocol.parseCancel;
@@ -1731,9 +1774,9 @@ function createStudioJobClient(options) {
1731
1774
  return cancel;
1732
1775
  }(),
1733
1776
  discard: function () {
1734
- var _discard = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee0(jobId) {
1777
+ var _discard = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee0(jobId) {
1735
1778
  var _t0;
1736
- return slicedToArray._regenerator().w(function (_context0) {
1779
+ return createForOfIteratorHelper._regenerator().w(function (_context0) {
1737
1780
  while (1) switch (_context0.n) {
1738
1781
  case 0:
1739
1782
  _t0 = protocol.parseDiscard;
@@ -1750,9 +1793,9 @@ function createStudioJobClient(options) {
1750
1793
  return discard;
1751
1794
  }(),
1752
1795
  newestCiRun: function () {
1753
- var _newestCiRun = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee1() {
1796
+ var _newestCiRun = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee1() {
1754
1797
  var _t1;
1755
- return slicedToArray._regenerator().w(function (_context1) {
1798
+ return createForOfIteratorHelper._regenerator().w(function (_context1) {
1756
1799
  while (1) switch (_context1.n) {
1757
1800
  case 0:
1758
1801
  _t1 = protocol.parseNewestCiRun;
@@ -1843,10 +1886,10 @@ function runStudioJob(_x) {
1843
1886
  return _runStudioJob.apply(this, arguments);
1844
1887
  }
1845
1888
  function _runStudioJob() {
1846
- _runStudioJob = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(options) {
1889
+ _runStudioJob = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(options) {
1847
1890
  var _options$renewEveryMs;
1848
1891
  var client, job, tab, onPhase, lost, renewing, lostResult, _options$canBuild, _options$canBuild2, _options$canBuild3, _options$canBuild4, prepared, message, handed, deployed, _message, built, uploaded, _t;
1849
- return slicedToArray._regenerator().w(function (_context) {
1892
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
1850
1893
  while (1) switch (_context.p = _context.n) {
1851
1894
  case 0:
1852
1895
  client = options.client, job = options.job, tab = options.tab, onPhase = options.onPhase;
@@ -2077,9 +2120,9 @@ function runJobToEnd(_x2) {
2077
2120
  return _runJobToEnd.apply(this, arguments);
2078
2121
  }
2079
2122
  function _runJobToEnd() {
2080
- _runJobToEnd = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(options) {
2123
+ _runJobToEnd = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2(options) {
2081
2124
  var result, runs, again;
2082
- return slicedToArray._regenerator().w(function (_context2) {
2125
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
2083
2126
  while (1) switch (_context2.n) {
2084
2127
  case 0:
2085
2128
  result = {
@@ -2152,6 +2195,53 @@ function messageOf(error) {
2152
2195
 
2153
2196
  /** What a build of the proposal came to. */
2154
2197
 
2198
+ /** What a cancelled build answers. */
2199
+ var BUILD_CANCELLED_MESSAGE = "The build was cancelled.";
2200
+
2201
+ /**
2202
+ * Why a build stopped early, as its outcome: `signal.reason` when it was
2203
+ * stopped with an `Error` of its own -- a watchdog saying where it stalled --
2204
+ * and otherwise a cancel.
2205
+ */
2206
+ function abortedOutcome(signal) {
2207
+ var reason = signal === null || signal === void 0 ? void 0 : signal.reason;
2208
+ return reason instanceof Error && reason.name !== "AbortError" ? {
2209
+ status: "failed",
2210
+ message: reason.message
2211
+ } : {
2212
+ status: "failed",
2213
+ message: BUILD_CANCELLED_MESSAGE,
2214
+ cancelled: true
2215
+ };
2216
+ }
2217
+ var ABORTED = Symbol("aborted");
2218
+
2219
+ /**
2220
+ * `work`, or `ABORTED` as soon as `signal` is: a request that never answers
2221
+ * is not waited for once the build is stopped. The work itself is not
2222
+ * stopped by this -- the caller's `signal` does that where it can -- only no
2223
+ * longer waited for.
2224
+ */
2225
+ function orAborted(work, signal) {
2226
+ if (signal === undefined) return work;
2227
+ if (signal.aborted) return Promise.resolve(ABORTED);
2228
+ return new Promise(function (resolve, reject) {
2229
+ var onAbort = function onAbort() {
2230
+ return resolve(ABORTED);
2231
+ };
2232
+ signal.addEventListener("abort", onAbort, {
2233
+ once: true
2234
+ });
2235
+ work.then(function (value) {
2236
+ signal.removeEventListener("abort", onAbort);
2237
+ resolve(value);
2238
+ }, function (error) {
2239
+ signal.removeEventListener("abort", onAbort);
2240
+ reject(error);
2241
+ });
2242
+ });
2243
+ }
2244
+
2155
2245
  /**
2156
2246
  * Where a build of the proposal is, around the deploy: the deploy's own steps
2157
2247
  * are the Studio's deploy state (`useStudioDeployState`), and these are the
@@ -2177,7 +2267,7 @@ function messageOf(error) {
2177
2267
  var NEVER_SHIPPED = new Set(["pnpm-lock.yaml", "pnpm-workspace.yaml", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "bun.lock", "bun.lockb"]);
2178
2268
  function withoutLockfiles(files) {
2179
2269
  return Object.fromEntries(Object.entries(files).filter(function (_ref) {
2180
- var _ref2 = slicedToArray._slicedToArray(_ref, 1),
2270
+ var _ref2 = createForOfIteratorHelper._slicedToArray(_ref, 1),
2181
2271
  path = _ref2[0];
2182
2272
  return !NEVER_SHIPPED.has(path.slice(path.lastIndexOf("/") + 1));
2183
2273
  }));
@@ -2220,10 +2310,10 @@ function buildProposal(_x) {
2220
2310
  return _buildProposal.apply(this, arguments);
2221
2311
  }
2222
2312
  function _buildProposal() {
2223
- _buildProposal = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(deps) {
2313
+ _buildProposal = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3(deps) {
2224
2314
  var _deps$now, _deps$sleep, _deps$onStep;
2225
- var now, sleep, step, read, _read, files, staged, inputs, target, asked, built, serve, servedNow, builtOf, since, served, _t2, _t3, _t4, _t5, _t6, _t7;
2226
- return slicedToArray._regenerator().w(function (_context3) {
2315
+ var now, sleep, step, signal, read, _read, files, staged, inputs, target, asked, built, serve, servedNow, builtOf, served, since, _served, again, _t2, _t3, _t4, _t5, _t6, _t7;
2316
+ return createForOfIteratorHelper._regenerator().w(function (_context3) {
2227
2317
  while (1) switch (_context3.p = _context3.n) {
2228
2318
  case 0:
2229
2319
  now = (_deps$now = deps.now) !== null && _deps$now !== void 0 ? _deps$now : Date.now;
@@ -2242,12 +2332,13 @@ function _buildProposal() {
2242
2332
  message: "This browser cannot build in this tab. Open the proposal in Chrome, Edge or Firefox and build it there"
2243
2333
  });
2244
2334
  case 1:
2335
+ signal = deps.signal;
2245
2336
  step({
2246
2337
  kind: "reading"
2247
2338
  });
2248
2339
  _context3.p = 2;
2249
2340
  _context3.n = 3;
2250
- return deps.client.files(deps.name);
2341
+ return orAborted(deps.client.files(deps.name), signal);
2251
2342
  case 3:
2252
2343
  read = _context3.v;
2253
2344
  _context3.n = 5;
@@ -2260,64 +2351,88 @@ function _buildProposal() {
2260
2351
  message: messageOf(_t2)
2261
2352
  });
2262
2353
  case 5:
2354
+ if (!(read === ABORTED || signal !== null && signal !== void 0 && signal.aborted)) {
2355
+ _context3.n = 6;
2356
+ break;
2357
+ }
2358
+ return _context3.a(2, abortedOutcome(signal));
2359
+ case 6:
2263
2360
  _read = read, files = _read.files, staged = _read.staged;
2264
2361
  if (!(staged.inputs === null)) {
2265
- _context3.n = 6;
2362
+ _context3.n = 7;
2266
2363
  break;
2267
2364
  }
2268
2365
  return _context3.a(2, {
2269
2366
  status: "nothing-staged"
2270
2367
  });
2271
- case 6:
2368
+ case 7:
2272
2369
  if (staged.buildRequired) {
2273
- _context3.n = 7;
2370
+ _context3.n = 8;
2274
2371
  break;
2275
2372
  }
2276
2373
  return _context3.a(2, {
2277
2374
  status: "already-built",
2278
2375
  hash: null
2279
2376
  });
2280
- case 7:
2377
+ case 8:
2281
2378
  inputs = staged.inputs;
2282
- _context3.p = 8;
2283
- _context3.n = 9;
2284
- return deps.client.buildTarget(deps.name);
2285
- case 9:
2379
+ _context3.p = 9;
2380
+ _context3.n = 10;
2381
+ return orAborted(deps.client.buildTarget(deps.name), signal);
2382
+ case 10:
2286
2383
  asked = _context3.v;
2384
+ if (!(asked === ABORTED)) {
2385
+ _context3.n = 11;
2386
+ break;
2387
+ }
2388
+ return _context3.a(2, abortedOutcome(signal));
2389
+ case 11:
2287
2390
  target = asked.layer === "own" ? asked.target : undefined;
2288
- _context3.n = 11;
2391
+ _context3.n = 13;
2289
2392
  break;
2290
- case 10:
2291
- _context3.p = 10;
2393
+ case 12:
2394
+ _context3.p = 12;
2292
2395
  _t3 = _context3.v;
2293
2396
  if (!(statusOf(_t3) !== 404)) {
2294
- _context3.n = 11;
2397
+ _context3.n = 13;
2295
2398
  break;
2296
2399
  }
2297
2400
  return _context3.a(2, {
2298
2401
  status: "failed",
2299
2402
  message: messageOf(_t3)
2300
2403
  });
2301
- case 11:
2404
+ case 13:
2405
+ if (!(signal !== null && signal !== void 0 && signal.aborted)) {
2406
+ _context3.n = 14;
2407
+ break;
2408
+ }
2409
+ return _context3.a(2, abortedOutcome(signal));
2410
+ case 14:
2302
2411
  step({
2303
2412
  kind: "deploying"
2304
2413
  });
2305
- _context3.n = 12;
2306
- return deps.deploy(withoutLockfiles(files), target);
2307
- case 12:
2414
+ _context3.n = 15;
2415
+ return orAborted(deps.deploy(withoutLockfiles(files), target, signal), signal);
2416
+ case 15:
2308
2417
  built = _context3.v;
2418
+ if (!(built === ABORTED || signal !== null && signal !== void 0 && signal.aborted)) {
2419
+ _context3.n = 16;
2420
+ break;
2421
+ }
2422
+ return _context3.a(2, abortedOutcome(signal));
2423
+ case 16:
2309
2424
  if (!(built.status !== "uploaded")) {
2310
- _context3.n = 13;
2425
+ _context3.n = 17;
2311
2426
  break;
2312
2427
  }
2313
2428
  return _context3.a(2, {
2314
2429
  status: "failed",
2315
2430
  message: built.status === "failed" ? built.message : "The build went live instead of stopping once uploaded."
2316
2431
  });
2317
- case 13:
2432
+ case 17:
2318
2433
  serve = /*#__PURE__*/function () {
2319
- var _ref3 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee() {
2320
- return slicedToArray._regenerator().w(function (_context) {
2434
+ var _ref3 = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee() {
2435
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
2321
2436
  while (1) switch (_context.n) {
2322
2437
  case 0:
2323
2438
  step({
@@ -2336,9 +2451,9 @@ function _buildProposal() {
2336
2451
  };
2337
2452
  }();
2338
2453
  servedNow = /*#__PURE__*/function () {
2339
- var _ref4 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2() {
2454
+ var _ref4 = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2() {
2340
2455
  var _proposal$staged, _proposal$built, proposal;
2341
- return slicedToArray._regenerator().w(function (_context2) {
2456
+ return createForOfIteratorHelper._regenerator().w(function (_context2) {
2342
2457
  while (1) switch (_context2.p = _context2.n) {
2343
2458
  case 0:
2344
2459
  _context2.p = 0;
@@ -2366,70 +2481,305 @@ function _buildProposal() {
2366
2481
  proposal: proposal
2367
2482
  };
2368
2483
  };
2369
- _context3.p = 14;
2370
- _t4 = builtOf;
2371
- _context3.n = 15;
2372
- return serve();
2373
- case 15:
2374
- return _context3.a(2, _t4(_context3.v));
2375
- case 16:
2376
- _context3.p = 16;
2377
- _t5 = _context3.v;
2378
- if (gatewayGaveUp(_t5)) {
2379
- _context3.n = 17;
2484
+ _context3.p = 18;
2485
+ _context3.n = 19;
2486
+ return orAborted(serve(), signal);
2487
+ case 19:
2488
+ served = _context3.v;
2489
+ if (!(served === ABORTED)) {
2490
+ _context3.n = 20;
2491
+ break;
2492
+ }
2493
+ return _context3.a(2, abortedOutcome(signal));
2494
+ case 20:
2495
+ return _context3.a(2, builtOf(served));
2496
+ case 21:
2497
+ _context3.p = 21;
2498
+ _t4 = _context3.v;
2499
+ if (gatewayGaveUp(_t4)) {
2500
+ _context3.n = 22;
2380
2501
  break;
2381
2502
  }
2382
2503
  return _context3.a(2, {
2383
2504
  status: "failed",
2384
- message: messageOf(_t5)
2505
+ message: messageOf(_t4)
2385
2506
  });
2386
- case 17:
2507
+ case 22:
2387
2508
  since = now();
2388
2509
  step({
2389
2510
  kind: "waiting",
2390
2511
  since: since
2391
2512
  });
2392
- case 18:
2513
+ case 23:
2393
2514
  if (!(now() - since < SERVE_WAIT_MS)) {
2394
- _context3.n = 22;
2515
+ _context3.n = 29;
2395
2516
  break;
2396
2517
  }
2397
- _context3.n = 19;
2398
- return sleep(SERVE_POLL_MS);
2399
- case 19:
2400
- _context3.n = 20;
2401
- return servedNow();
2402
- case 20:
2403
- served = _context3.v;
2404
- if (!(served !== null)) {
2405
- _context3.n = 21;
2518
+ _context3.n = 24;
2519
+ return orAborted(sleep(SERVE_POLL_MS), signal);
2520
+ case 24:
2521
+ _t5 = _context3.v;
2522
+ _t6 = ABORTED;
2523
+ if (!(_t5 === _t6)) {
2524
+ _context3.n = 25;
2406
2525
  break;
2407
2526
  }
2408
- return _context3.a(2, builtOf(served));
2409
- case 21:
2410
- _context3.n = 18;
2411
- break;
2412
- case 22:
2413
- _context3.p = 22;
2414
- _t6 = builtOf;
2527
+ return _context3.a(2, abortedOutcome(signal));
2528
+ case 25:
2529
+ _context3.n = 26;
2530
+ return orAborted(servedNow(), signal);
2531
+ case 26:
2532
+ _served = _context3.v;
2533
+ if (!(_served === ABORTED)) {
2534
+ _context3.n = 27;
2535
+ break;
2536
+ }
2537
+ return _context3.a(2, abortedOutcome(signal));
2538
+ case 27:
2539
+ if (!(_served !== null)) {
2540
+ _context3.n = 28;
2541
+ break;
2542
+ }
2543
+ return _context3.a(2, builtOf(_served));
2544
+ case 28:
2415
2545
  _context3.n = 23;
2416
- return serve();
2417
- case 23:
2418
- return _context3.a(2, _t6(_context3.v));
2419
- case 24:
2420
- _context3.p = 24;
2546
+ break;
2547
+ case 29:
2548
+ _context3.p = 29;
2549
+ _context3.n = 30;
2550
+ return orAborted(serve(), signal);
2551
+ case 30:
2552
+ again = _context3.v;
2553
+ if (!(again === ABORTED)) {
2554
+ _context3.n = 31;
2555
+ break;
2556
+ }
2557
+ return _context3.a(2, abortedOutcome(signal));
2558
+ case 31:
2559
+ return _context3.a(2, builtOf(again));
2560
+ case 32:
2561
+ _context3.p = 32;
2421
2562
  _t7 = _context3.v;
2422
2563
  return _context3.a(2, {
2423
2564
  status: "failed",
2424
2565
  message: messageOf(_t7)
2425
2566
  });
2426
2567
  }
2427
- }, _callee3, null, [[22, 24], [14, 16], [8, 10], [2, 4]]);
2568
+ }, _callee3, null, [[29, 32], [18, 21], [9, 12], [2, 4]]);
2428
2569
  }));
2429
2570
  return _buildProposal.apply(this, arguments);
2430
2571
  }
2431
2572
 
2573
+ /*
2574
+ * A quick preview's files: the proposal's app bundled in the tab, for the
2575
+ * browser half only (`quickPreview.ts` in `../internal` says what a quick
2576
+ * preview is and what it cannot show). Nothing is uploaded and nothing is
2577
+ * served: the files go to the page in the preview, whose worker hands them to
2578
+ * a page opened as the preview.
2579
+ */
2580
+
2581
+ /** Where a site's routes live: the generator is needed when there are any. */
2582
+ var ROUTES_PREFIX = "src/routes/";
2583
+ function buildQuickPreview(_x) {
2584
+ return _buildQuickPreview.apply(this, arguments);
2585
+ }
2586
+
2587
+ /**
2588
+ * The browser half of a build, as the worker serves it under `/_app/`. The
2589
+ * stylesheet only when the tab compiled one: an empty one is the case where a
2590
+ * build ships the site's live stylesheet (`liveStylesheet` on
2591
+ * `runStudioDeploy`), and the page already has that.
2592
+ */
2593
+ function _buildQuickPreview() {
2594
+ _buildQuickPreview = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee(deps) {
2595
+ var _deps$onStep;
2596
+ var step, failed, stopped, _yield$Promise$all, _yield$Promise$all2, read, site, asked, target, stoppedNow, builder, project, fileBased, files, stoppedBeforeBuild, build, stoppedAfterBuild, _stopped, _t, _t2;
2597
+ return createForOfIteratorHelper._regenerator().w(function (_context) {
2598
+ while (1) switch (_context.p = _context.n) {
2599
+ case 0:
2600
+ step = (_deps$onStep = deps.onStep) !== null && _deps$onStep !== void 0 ? _deps$onStep : function () {};
2601
+ failed = function failed(message) {
2602
+ return {
2603
+ status: "failed",
2604
+ message: message
2605
+ };
2606
+ };
2607
+ stopped = function stopped() {
2608
+ var _deps$signal;
2609
+ return (_deps$signal = deps.signal) !== null && _deps$signal !== void 0 && _deps$signal.aborted ? failed("The quick preview was cancelled.") : null;
2610
+ };
2611
+ _context.p = 1;
2612
+ step("Reading the proposal");
2613
+ _context.n = 2;
2614
+ return Promise.all([deps.proposals.files(deps.name), deps.siteSource(), deps.proposals.buildTarget(deps.name)["catch"](function () {
2615
+ return null;
2616
+ })]);
2617
+ case 2:
2618
+ _yield$Promise$all = _context.v;
2619
+ _yield$Promise$all2 = createForOfIteratorHelper._slicedToArray(_yield$Promise$all, 3);
2620
+ read = _yield$Promise$all2[0];
2621
+ site = _yield$Promise$all2[1];
2622
+ asked = _yield$Promise$all2[2];
2623
+ if (!(site === null)) {
2624
+ _context.n = 3;
2625
+ break;
2626
+ }
2627
+ return _context.a(2, failed("The site has no published source to build a preview from. Build the proposal instead."));
2628
+ case 3:
2629
+ if (!((asked === null || asked === void 0 ? void 0 : asked.layer) === "own")) {
2630
+ _context.n = 4;
2631
+ break;
2632
+ }
2633
+ return _context.a(2, failed("This proposal changes the site's dependencies, which a quick preview cannot load. Build the proposal to see it."));
2634
+ case 4:
2635
+ _context.n = 5;
2636
+ return deps.siteTarget();
2637
+ case 5:
2638
+ target = _context.v;
2639
+ if (!(target.project.rev === null)) {
2640
+ _context.n = 6;
2641
+ break;
2642
+ }
2643
+ return _context.a(2, failed("The site has no dependency layer yet. Build the proposal to see it."));
2644
+ case 6:
2645
+ stoppedNow = stopped();
2646
+ if (!(stoppedNow !== null)) {
2647
+ _context.n = 7;
2648
+ break;
2649
+ }
2650
+ return _context.a(2, stoppedNow);
2651
+ case 7:
2652
+ step("Loading the builder");
2653
+ _context.n = 8;
2654
+ return deps.loadBuilder();
2655
+ case 8:
2656
+ builder = _context.v;
2657
+ project = withoutLockfiles(proposalProject.proposalProject(site, read.files));
2658
+ fileBased = Object.keys(project).some(function (path) {
2659
+ return path.startsWith(ROUTES_PREFIX);
2660
+ });
2661
+ if (!(fileBased && deps.generateRouteTree === undefined)) {
2662
+ _context.n = 9;
2663
+ break;
2664
+ }
2665
+ return _context.a(2, failed("This page cannot generate the site's route tree, so it cannot build a preview. Build the proposal instead."));
2666
+ case 9:
2667
+ step("Building");
2668
+ if (!(fileBased && deps.generateRouteTree !== undefined)) {
2669
+ _context.n = 11;
2670
+ break;
2671
+ }
2672
+ _context.n = 10;
2673
+ return deps.generateRouteTree(project);
2674
+ case 10:
2675
+ _t = _context.v;
2676
+ _context.n = 12;
2677
+ break;
2678
+ case 11:
2679
+ _t = project;
2680
+ case 12:
2681
+ files = _t;
2682
+ stoppedBeforeBuild = stopped();
2683
+ if (!(stoppedBeforeBuild !== null)) {
2684
+ _context.n = 13;
2685
+ break;
2686
+ }
2687
+ return _context.a(2, stoppedBeforeBuild);
2688
+ case 13:
2689
+ _context.n = 14;
2690
+ return builder.buildUserApp({
2691
+ files: files,
2692
+ publicFiles: {},
2693
+ assets: {},
2694
+ projectSource: project,
2695
+ target: target,
2696
+ extraInputs: {}
2697
+ });
2698
+ case 14:
2699
+ build = _context.v;
2700
+ stoppedAfterBuild = stopped();
2701
+ if (!(stoppedAfterBuild !== null)) {
2702
+ _context.n = 15;
2703
+ break;
2704
+ }
2705
+ return _context.a(2, stoppedAfterBuild);
2706
+ case 15:
2707
+ return _context.a(2, {
2708
+ status: "built",
2709
+ files: clientFilesOf(build),
2710
+ inputs: read.staged.inputs
2711
+ });
2712
+ case 16:
2713
+ _context.p = 16;
2714
+ _t2 = _context.v;
2715
+ return _context.a(2, (_stopped = stopped()) !== null && _stopped !== void 0 ? _stopped : failed(_t2 instanceof Error ? _t2.message : String(_t2)));
2716
+ }
2717
+ }, _callee, null, [[1, 16]]);
2718
+ }));
2719
+ return _buildQuickPreview.apply(this, arguments);
2720
+ }
2721
+ function clientFilesOf(build) {
2722
+ var files = {
2723
+ "app.js": {
2724
+ body: build.clientCode,
2725
+ contentType: JS
2726
+ }
2727
+ };
2728
+ for (var _i = 0, _Object$entries = Object.entries(build.clientChunks); _i < _Object$entries.length; _i++) {
2729
+ var _Object$entries$_i = createForOfIteratorHelper._slicedToArray(_Object$entries[_i], 2),
2730
+ name = _Object$entries$_i[0],
2731
+ code = _Object$entries$_i[1];
2732
+ files[name] = {
2733
+ body: code,
2734
+ contentType: JS
2735
+ };
2736
+ }
2737
+ if (build.cssCode !== "") {
2738
+ files["app.css"] = {
2739
+ body: build.cssCode,
2740
+ contentType: "text/css"
2741
+ };
2742
+ }
2743
+ for (var _i2 = 0, _Object$entries2 = Object.entries(build.assetFiles); _i2 < _Object$entries2.length; _i2++) {
2744
+ var _Object$entries2$_i = createForOfIteratorHelper._slicedToArray(_Object$entries2[_i2], 2),
2745
+ _name = _Object$entries2$_i[0],
2746
+ base64 = _Object$entries2$_i[1];
2747
+ files["a/".concat(_name)] = {
2748
+ body: base64,
2749
+ contentType: contentTypeOf(_name),
2750
+ base64: true
2751
+ };
2752
+ }
2753
+ return files;
2754
+ }
2755
+ var JS = "text/javascript; charset=utf-8";
2756
+ var CONTENT_TYPES = {
2757
+ png: "image/png",
2758
+ jpg: "image/jpeg",
2759
+ jpeg: "image/jpeg",
2760
+ gif: "image/gif",
2761
+ webp: "image/webp",
2762
+ avif: "image/avif",
2763
+ svg: "image/svg+xml",
2764
+ ico: "image/x-icon",
2765
+ woff: "font/woff",
2766
+ woff2: "font/woff2",
2767
+ ttf: "font/ttf",
2768
+ otf: "font/otf",
2769
+ mp4: "video/mp4",
2770
+ webm: "video/webm",
2771
+ json: "application/json",
2772
+ txt: "text/plain"
2773
+ };
2774
+ function contentTypeOf(name) {
2775
+ var _CONTENT_TYPES$extens;
2776
+ var extension = name.slice(name.lastIndexOf(".") + 1).toLowerCase();
2777
+ return (_CONTENT_TYPES$extens = CONTENT_TYPES[extension]) !== null && _CONTENT_TYPES$extens !== void 0 ? _CONTENT_TYPES$extens : "application/octet-stream";
2778
+ }
2779
+
2432
2780
  exports.proposalProject = proposalProject.proposalProject;
2781
+ exports.BUILD_CANCELLED_MESSAGE = BUILD_CANCELLED_MESSAGE;
2782
+ exports.DEPLOY_STOPPED_MESSAGE = DEPLOY_STOPPED_MESSAGE;
2433
2783
  exports.MergePrepareAnswer = MergePrepareAnswer;
2434
2784
  exports.RENEW_EVERY_MS = RENEW_EVERY_MS;
2435
2785
  exports.SERVE_POLL_MS = SERVE_POLL_MS;
@@ -2439,8 +2789,10 @@ exports.STUDIO_OUT_OF_DATE_MESSAGE = STUDIO_OUT_OF_DATE_MESSAGE;
2439
2789
  exports.StudioPublishError = StudioPublishError;
2440
2790
  exports.StudioUploadError = StudioUploadError;
2441
2791
  exports.buildProposal = buildProposal;
2792
+ exports.buildQuickPreview = buildQuickPreview;
2442
2793
  exports.callJson = callJson;
2443
2794
  exports.carriedInto = carriedInto;
2795
+ exports.clientFilesOf = clientFilesOf;
2444
2796
  exports.createStudioJobClient = createStudioJobClient;
2445
2797
  exports.createStudioPublishClient = createStudioPublishClient;
2446
2798
  exports.isExpiredSlot = isExpiredSlot;