@valbuild/tanstack 0.141.1 → 0.142.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 +13 -0
- package/client/dist/valbuild-tanstack-client.cjs.dev.js +16 -4
- package/client/dist/valbuild-tanstack-client.cjs.prod.js +16 -4
- package/client/dist/valbuild-tanstack-client.esm.js +16 -4
- package/dist/{ValOverlayContext-2739cc60.cjs.prod.js → ValOverlayContext-3e2c48a6.cjs.prod.js} +3 -1
- package/dist/{ValOverlayContext-bafe3de9.cjs.dev.js → ValOverlayContext-3f080cce.cjs.dev.js} +3 -1
- package/dist/{ValOverlayContext-28101df3.esm.js → ValOverlayContext-59a0b19f.esm.js} +3 -1
- package/dist/declarations/src/ValDraft.d.ts +13 -0
- package/dist/declarations/src/server/initValContent.d.ts +15 -5
- package/dist/declarations/src/server/initValServer.d.ts +9 -1
- package/dist/valbuild-tanstack.cjs.dev.js +15 -7
- package/dist/valbuild-tanstack.cjs.prod.js +15 -7
- package/dist/valbuild-tanstack.esm.js +15 -7
- package/dist/{version-2cca9e77.esm.js → version-0588f50c.esm.js} +1 -1
- package/dist/{version-e04493d5.cjs.dev.js → version-4ba1e52e.cjs.dev.js} +1 -1
- package/dist/{version-1205910c.cjs.prod.js → version-b550a2c2.cjs.prod.js} +1 -1
- package/package.json +7 -7
- package/server/dist/valbuild-tanstack-server.cjs.dev.js +74 -53
- package/server/dist/valbuild-tanstack-server.cjs.prod.js +74 -53
- package/server/dist/valbuild-tanstack-server.esm.js +75 -54
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('../../dist/version-
|
|
5
|
+
var version = require('../../dist/version-4ba1e52e.cjs.dev.js');
|
|
6
6
|
var core = require('@valbuild/core');
|
|
7
7
|
var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-4497beef.cjs.dev.js');
|
|
8
8
|
var server = require('@valbuild/server');
|
|
@@ -504,7 +504,7 @@ function _loadDraftSources() {
|
|
|
504
504
|
}));
|
|
505
505
|
return _loadDraftSources.apply(this, arguments);
|
|
506
506
|
}
|
|
507
|
-
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
507
|
+
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
508
508
|
return function (selector) {
|
|
509
509
|
var exec = /*#__PURE__*/function () {
|
|
510
510
|
var _ref2 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee2() {
|
|
@@ -601,12 +601,17 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
601
601
|
if (module) {
|
|
602
602
|
return module.source;
|
|
603
603
|
}
|
|
604
|
+
return snapshot === null || snapshot === void 0 ? void 0 : snapshot[path];
|
|
604
605
|
}
|
|
605
606
|
}));
|
|
606
607
|
case 15:
|
|
607
|
-
return _context2.a(2, stega.stegaEncode(selector, {
|
|
608
|
+
return _context2.a(2, stega.stegaEncode(selector, createForOfIteratorHelper._objectSpread2({
|
|
608
609
|
disabled: !enabled
|
|
609
|
-
}
|
|
610
|
+
}, snapshot !== undefined ? {
|
|
611
|
+
getModule: function getModule(path) {
|
|
612
|
+
return snapshot[path];
|
|
613
|
+
}
|
|
614
|
+
} : {})));
|
|
610
615
|
}
|
|
611
616
|
}, _callee2, null, [[9, 11], [5, 8], [1, 3]]);
|
|
612
617
|
}));
|
|
@@ -616,11 +621,17 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
616
621
|
}();
|
|
617
622
|
return exec()["catch"](function (err) {
|
|
618
623
|
console.error("Val: failed to fetch ", err);
|
|
619
|
-
return stega.stegaEncode(selector, {}
|
|
624
|
+
return stega.stegaEncode(selector, createForOfIteratorHelper._objectSpread2({}, snapshot !== undefined ? {
|
|
625
|
+
getModule: function getModule(path) {
|
|
626
|
+
return snapshot[path];
|
|
627
|
+
}
|
|
628
|
+
} : {}));
|
|
620
629
|
});
|
|
621
630
|
};
|
|
622
631
|
};
|
|
623
632
|
|
|
633
|
+
/** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
|
|
634
|
+
|
|
624
635
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
625
636
|
|
|
626
637
|
/**
|
|
@@ -635,98 +646,107 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
635
646
|
* a draft page was rendered as the published site and only then replaced, in
|
|
636
647
|
* the browser, by what the editor holds -- old text first on every load.
|
|
637
648
|
*/
|
|
638
|
-
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope) {
|
|
649
|
+
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot) {
|
|
639
650
|
return /*#__PURE__*/version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3() {
|
|
640
|
-
var _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
651
|
+
var onlySnapshot, _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
641
652
|
return version._regenerator().w(function (_context3) {
|
|
642
653
|
while (1) switch (_context3.p = _context3.n) {
|
|
643
654
|
case 0:
|
|
644
|
-
|
|
645
|
-
|
|
655
|
+
// At a proposal's address the page needs the snapshot whatever draft mode
|
|
656
|
+
// says, so a reviewer who is not editing sees the proposal too.
|
|
657
|
+
onlySnapshot = snapshot !== undefined ? {
|
|
658
|
+
sources: {},
|
|
659
|
+
snapshot: snapshot,
|
|
660
|
+
draftMode: false
|
|
661
|
+
} : null;
|
|
662
|
+
_context3.p = 1;
|
|
663
|
+
_context3.n = 2;
|
|
646
664
|
return isEnabled();
|
|
647
|
-
case
|
|
665
|
+
case 2:
|
|
648
666
|
if (_context3.v) {
|
|
649
|
-
_context3.n =
|
|
667
|
+
_context3.n = 3;
|
|
650
668
|
break;
|
|
651
669
|
}
|
|
652
|
-
return _context3.a(2,
|
|
653
|
-
case 2:
|
|
654
|
-
_context3.n = 3;
|
|
655
|
-
return getCookies();
|
|
670
|
+
return _context3.a(2, onlySnapshot);
|
|
656
671
|
case 3:
|
|
672
|
+
_context3.n = 4;
|
|
673
|
+
return getCookies();
|
|
674
|
+
case 4:
|
|
657
675
|
_t7 = _yield$getCookies$get = _context3.v.get(internal.VAL_SESSION_COOKIE);
|
|
658
676
|
_t6 = _t7 === null;
|
|
659
677
|
if (_t6) {
|
|
660
|
-
_context3.n =
|
|
678
|
+
_context3.n = 5;
|
|
661
679
|
break;
|
|
662
680
|
}
|
|
663
681
|
_t6 = _yield$getCookies$get === void 0;
|
|
664
|
-
case
|
|
682
|
+
case 5:
|
|
665
683
|
if (!_t6) {
|
|
666
|
-
_context3.n =
|
|
684
|
+
_context3.n = 6;
|
|
667
685
|
break;
|
|
668
686
|
}
|
|
669
687
|
_t8 = void 0;
|
|
670
|
-
_context3.n =
|
|
688
|
+
_context3.n = 7;
|
|
671
689
|
break;
|
|
672
|
-
case 5:
|
|
673
|
-
_t8 = _yield$getCookies$get.value;
|
|
674
690
|
case 6:
|
|
691
|
+
_t8 = _yield$getCookies$get.value;
|
|
692
|
+
case 7:
|
|
675
693
|
sessionCookie = _t8;
|
|
676
694
|
_t9 = internal.memoizePerRequest;
|
|
677
|
-
_context3.n = 7;
|
|
678
|
-
return getDraftSourcesScope();
|
|
679
|
-
case 7:
|
|
680
695
|
_context3.n = 8;
|
|
696
|
+
return getDraftSourcesScope();
|
|
697
|
+
case 8:
|
|
698
|
+
_context3.n = 9;
|
|
681
699
|
return _t9(_context3.v, sessionCookie !== null && sessionCookie !== void 0 ? sessionCookie : "", function () {
|
|
682
700
|
return loadDraftSources(valServerPromise, sessionCookie);
|
|
683
701
|
});
|
|
684
|
-
case
|
|
702
|
+
case 9:
|
|
685
703
|
modules = _context3.v;
|
|
686
704
|
if (modules) {
|
|
687
|
-
_context3.n =
|
|
705
|
+
_context3.n = 10;
|
|
688
706
|
break;
|
|
689
707
|
}
|
|
690
|
-
return _context3.a(2,
|
|
691
|
-
case
|
|
708
|
+
return _context3.a(2, onlySnapshot);
|
|
709
|
+
case 10:
|
|
692
710
|
sources = {};
|
|
693
711
|
_i = 0, _Object$entries = Object.entries(modules);
|
|
694
|
-
case
|
|
712
|
+
case 11:
|
|
695
713
|
if (!(_i < _Object$entries.length)) {
|
|
696
|
-
_context3.n =
|
|
714
|
+
_context3.n = 15;
|
|
697
715
|
break;
|
|
698
716
|
}
|
|
699
717
|
_Object$entries$_i = createForOfIteratorHelper._slicedToArray(_Object$entries[_i], 2), path = _Object$entries$_i[0], module = _Object$entries$_i[1];
|
|
700
718
|
if (!(module.patches === undefined)) {
|
|
701
|
-
_context3.n =
|
|
719
|
+
_context3.n = 12;
|
|
702
720
|
break;
|
|
703
721
|
}
|
|
704
|
-
return _context3.a(3,
|
|
705
|
-
case 11:
|
|
706
|
-
_context3.n = 12;
|
|
707
|
-
return withDraftJsonEntries(valServerPromise, sessionCookie, path, module.source, module.patches.applied);
|
|
722
|
+
return _context3.a(3, 14);
|
|
708
723
|
case 12:
|
|
724
|
+
_context3.n = 13;
|
|
725
|
+
return withDraftJsonEntries(valServerPromise, sessionCookie, path, module.source, module.patches.applied);
|
|
726
|
+
case 13:
|
|
709
727
|
source = _context3.v;
|
|
710
728
|
if (source !== undefined) {
|
|
711
729
|
sources[path] = source;
|
|
712
730
|
}
|
|
713
|
-
case
|
|
731
|
+
case 14:
|
|
714
732
|
_i++;
|
|
715
|
-
_context3.n =
|
|
733
|
+
_context3.n = 11;
|
|
716
734
|
break;
|
|
717
|
-
case 14:
|
|
718
|
-
return _context3.a(2, {
|
|
719
|
-
sources: sources
|
|
720
|
-
});
|
|
721
735
|
case 15:
|
|
722
|
-
_context3.
|
|
736
|
+
return _context3.a(2, createForOfIteratorHelper._objectSpread2({
|
|
737
|
+
sources: sources
|
|
738
|
+
}, snapshot !== undefined ? {
|
|
739
|
+
snapshot: snapshot
|
|
740
|
+
} : {}));
|
|
741
|
+
case 16:
|
|
742
|
+
_context3.p = 16;
|
|
723
743
|
_t0 = _context3.v;
|
|
724
744
|
// Published content, as before this existed: a draft page that renders
|
|
725
745
|
// the site is a degraded preview, one that fails to render is an outage.
|
|
726
746
|
console.error("Val: could not read the draft", _t0);
|
|
727
|
-
return _context3.a(2,
|
|
747
|
+
return _context3.a(2, onlySnapshot);
|
|
728
748
|
}
|
|
729
|
-
}, _callee3, null, [[
|
|
749
|
+
}, _callee3, null, [[1, 16]]);
|
|
730
750
|
}));
|
|
731
751
|
};
|
|
732
752
|
|
|
@@ -969,7 +989,7 @@ function getHost(headers) {
|
|
|
969
989
|
// }
|
|
970
990
|
// }
|
|
971
991
|
|
|
972
|
-
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
992
|
+
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
973
993
|
return /*#__PURE__*/function () {
|
|
974
994
|
var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, params) {
|
|
975
995
|
var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t10;
|
|
@@ -1041,7 +1061,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
1041
1061
|
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
1042
1062
|
}));
|
|
1043
1063
|
case 11:
|
|
1044
|
-
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
|
|
1064
|
+
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot);
|
|
1045
1065
|
_t10 = valModule;
|
|
1046
1066
|
if (!_t10) {
|
|
1047
1067
|
_context4.n = 13;
|
|
@@ -1322,14 +1342,14 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
1322
1342
|
};
|
|
1323
1343
|
}();
|
|
1324
1344
|
};
|
|
1325
|
-
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
1345
|
+
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
1326
1346
|
return /*#__PURE__*/function () {
|
|
1327
1347
|
var _ref6 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee6(selector, params) {
|
|
1328
1348
|
var fetchVal, resolvedParams, valModule, path, schema, val, route, _t12, _t13;
|
|
1329
1349
|
return version._regenerator().w(function (_context6) {
|
|
1330
1350
|
while (1) switch (_context6.n) {
|
|
1331
1351
|
case 0:
|
|
1332
|
-
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
|
|
1352
|
+
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot);
|
|
1333
1353
|
if (!(params === undefined)) {
|
|
1334
1354
|
_context6.n = 1;
|
|
1335
1355
|
break;
|
|
@@ -1455,7 +1475,7 @@ function _requestCookies() {
|
|
|
1455
1475
|
return _requestCookies.apply(this, arguments);
|
|
1456
1476
|
}
|
|
1457
1477
|
function initValContent(config, valModules, opts) {
|
|
1458
|
-
var _opts$draftMode;
|
|
1478
|
+
var _opts$http, _opts$draftMode;
|
|
1459
1479
|
var coreVersion = core.Internal.VERSION.core;
|
|
1460
1480
|
if (!coreVersion) {
|
|
1461
1481
|
throw new Error("Could not get @valbuild/core package version");
|
|
@@ -1465,6 +1485,7 @@ function initValContent(config, valModules, opts) {
|
|
|
1465
1485
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
1466
1486
|
}
|
|
1467
1487
|
var draftSourcesScope = createTanStackRequestScope();
|
|
1488
|
+
var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? server.proposalSnapshot(opts.http.proposal) : undefined;
|
|
1468
1489
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
1469
1490
|
var isEnabled = function isEnabled() {
|
|
1470
1491
|
return draftMode.isEnabled();
|
|
@@ -1493,11 +1514,11 @@ function initValContent(config, valModules, opts) {
|
|
|
1493
1514
|
return {
|
|
1494
1515
|
fetchValStega: initFetchValStega(config, valApiEndpoints,
|
|
1495
1516
|
// TODO: get from config
|
|
1496
|
-
valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1517
|
+
valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1497
1518
|
fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
|
|
1498
|
-
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1499
|
-
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1500
|
-
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope)
|
|
1519
|
+
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1520
|
+
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1521
|
+
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
|
|
1501
1522
|
};
|
|
1502
1523
|
}
|
|
1503
1524
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('../../dist/version-
|
|
5
|
+
var version = require('../../dist/version-b550a2c2.cjs.prod.js');
|
|
6
6
|
var core = require('@valbuild/core');
|
|
7
7
|
var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-9afd7d2d.cjs.prod.js');
|
|
8
8
|
var server = require('@valbuild/server');
|
|
@@ -504,7 +504,7 @@ function _loadDraftSources() {
|
|
|
504
504
|
}));
|
|
505
505
|
return _loadDraftSources.apply(this, arguments);
|
|
506
506
|
}
|
|
507
|
-
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
507
|
+
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
508
508
|
return function (selector) {
|
|
509
509
|
var exec = /*#__PURE__*/function () {
|
|
510
510
|
var _ref2 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee2() {
|
|
@@ -601,12 +601,17 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
601
601
|
if (module) {
|
|
602
602
|
return module.source;
|
|
603
603
|
}
|
|
604
|
+
return snapshot === null || snapshot === void 0 ? void 0 : snapshot[path];
|
|
604
605
|
}
|
|
605
606
|
}));
|
|
606
607
|
case 15:
|
|
607
|
-
return _context2.a(2, stega.stegaEncode(selector, {
|
|
608
|
+
return _context2.a(2, stega.stegaEncode(selector, createForOfIteratorHelper._objectSpread2({
|
|
608
609
|
disabled: !enabled
|
|
609
|
-
}
|
|
610
|
+
}, snapshot !== undefined ? {
|
|
611
|
+
getModule: function getModule(path) {
|
|
612
|
+
return snapshot[path];
|
|
613
|
+
}
|
|
614
|
+
} : {})));
|
|
610
615
|
}
|
|
611
616
|
}, _callee2, null, [[9, 11], [5, 8], [1, 3]]);
|
|
612
617
|
}));
|
|
@@ -616,11 +621,17 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
616
621
|
}();
|
|
617
622
|
return exec()["catch"](function (err) {
|
|
618
623
|
console.error("Val: failed to fetch ", err);
|
|
619
|
-
return stega.stegaEncode(selector, {}
|
|
624
|
+
return stega.stegaEncode(selector, createForOfIteratorHelper._objectSpread2({}, snapshot !== undefined ? {
|
|
625
|
+
getModule: function getModule(path) {
|
|
626
|
+
return snapshot[path];
|
|
627
|
+
}
|
|
628
|
+
} : {}));
|
|
620
629
|
});
|
|
621
630
|
};
|
|
622
631
|
};
|
|
623
632
|
|
|
633
|
+
/** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
|
|
634
|
+
|
|
624
635
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
625
636
|
|
|
626
637
|
/**
|
|
@@ -635,98 +646,107 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
635
646
|
* a draft page was rendered as the published site and only then replaced, in
|
|
636
647
|
* the browser, by what the editor holds -- old text first on every load.
|
|
637
648
|
*/
|
|
638
|
-
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope) {
|
|
649
|
+
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot) {
|
|
639
650
|
return /*#__PURE__*/version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3() {
|
|
640
|
-
var _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
651
|
+
var onlySnapshot, _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
641
652
|
return version._regenerator().w(function (_context3) {
|
|
642
653
|
while (1) switch (_context3.p = _context3.n) {
|
|
643
654
|
case 0:
|
|
644
|
-
|
|
645
|
-
|
|
655
|
+
// At a proposal's address the page needs the snapshot whatever draft mode
|
|
656
|
+
// says, so a reviewer who is not editing sees the proposal too.
|
|
657
|
+
onlySnapshot = snapshot !== undefined ? {
|
|
658
|
+
sources: {},
|
|
659
|
+
snapshot: snapshot,
|
|
660
|
+
draftMode: false
|
|
661
|
+
} : null;
|
|
662
|
+
_context3.p = 1;
|
|
663
|
+
_context3.n = 2;
|
|
646
664
|
return isEnabled();
|
|
647
|
-
case
|
|
665
|
+
case 2:
|
|
648
666
|
if (_context3.v) {
|
|
649
|
-
_context3.n =
|
|
667
|
+
_context3.n = 3;
|
|
650
668
|
break;
|
|
651
669
|
}
|
|
652
|
-
return _context3.a(2,
|
|
653
|
-
case 2:
|
|
654
|
-
_context3.n = 3;
|
|
655
|
-
return getCookies();
|
|
670
|
+
return _context3.a(2, onlySnapshot);
|
|
656
671
|
case 3:
|
|
672
|
+
_context3.n = 4;
|
|
673
|
+
return getCookies();
|
|
674
|
+
case 4:
|
|
657
675
|
_t7 = _yield$getCookies$get = _context3.v.get(internal.VAL_SESSION_COOKIE);
|
|
658
676
|
_t6 = _t7 === null;
|
|
659
677
|
if (_t6) {
|
|
660
|
-
_context3.n =
|
|
678
|
+
_context3.n = 5;
|
|
661
679
|
break;
|
|
662
680
|
}
|
|
663
681
|
_t6 = _yield$getCookies$get === void 0;
|
|
664
|
-
case
|
|
682
|
+
case 5:
|
|
665
683
|
if (!_t6) {
|
|
666
|
-
_context3.n =
|
|
684
|
+
_context3.n = 6;
|
|
667
685
|
break;
|
|
668
686
|
}
|
|
669
687
|
_t8 = void 0;
|
|
670
|
-
_context3.n =
|
|
688
|
+
_context3.n = 7;
|
|
671
689
|
break;
|
|
672
|
-
case 5:
|
|
673
|
-
_t8 = _yield$getCookies$get.value;
|
|
674
690
|
case 6:
|
|
691
|
+
_t8 = _yield$getCookies$get.value;
|
|
692
|
+
case 7:
|
|
675
693
|
sessionCookie = _t8;
|
|
676
694
|
_t9 = internal.memoizePerRequest;
|
|
677
|
-
_context3.n = 7;
|
|
678
|
-
return getDraftSourcesScope();
|
|
679
|
-
case 7:
|
|
680
695
|
_context3.n = 8;
|
|
696
|
+
return getDraftSourcesScope();
|
|
697
|
+
case 8:
|
|
698
|
+
_context3.n = 9;
|
|
681
699
|
return _t9(_context3.v, sessionCookie !== null && sessionCookie !== void 0 ? sessionCookie : "", function () {
|
|
682
700
|
return loadDraftSources(valServerPromise, sessionCookie);
|
|
683
701
|
});
|
|
684
|
-
case
|
|
702
|
+
case 9:
|
|
685
703
|
modules = _context3.v;
|
|
686
704
|
if (modules) {
|
|
687
|
-
_context3.n =
|
|
705
|
+
_context3.n = 10;
|
|
688
706
|
break;
|
|
689
707
|
}
|
|
690
|
-
return _context3.a(2,
|
|
691
|
-
case
|
|
708
|
+
return _context3.a(2, onlySnapshot);
|
|
709
|
+
case 10:
|
|
692
710
|
sources = {};
|
|
693
711
|
_i = 0, _Object$entries = Object.entries(modules);
|
|
694
|
-
case
|
|
712
|
+
case 11:
|
|
695
713
|
if (!(_i < _Object$entries.length)) {
|
|
696
|
-
_context3.n =
|
|
714
|
+
_context3.n = 15;
|
|
697
715
|
break;
|
|
698
716
|
}
|
|
699
717
|
_Object$entries$_i = createForOfIteratorHelper._slicedToArray(_Object$entries[_i], 2), path = _Object$entries$_i[0], module = _Object$entries$_i[1];
|
|
700
718
|
if (!(module.patches === undefined)) {
|
|
701
|
-
_context3.n =
|
|
719
|
+
_context3.n = 12;
|
|
702
720
|
break;
|
|
703
721
|
}
|
|
704
|
-
return _context3.a(3,
|
|
705
|
-
case 11:
|
|
706
|
-
_context3.n = 12;
|
|
707
|
-
return withDraftJsonEntries(valServerPromise, sessionCookie, path, module.source, module.patches.applied);
|
|
722
|
+
return _context3.a(3, 14);
|
|
708
723
|
case 12:
|
|
724
|
+
_context3.n = 13;
|
|
725
|
+
return withDraftJsonEntries(valServerPromise, sessionCookie, path, module.source, module.patches.applied);
|
|
726
|
+
case 13:
|
|
709
727
|
source = _context3.v;
|
|
710
728
|
if (source !== undefined) {
|
|
711
729
|
sources[path] = source;
|
|
712
730
|
}
|
|
713
|
-
case
|
|
731
|
+
case 14:
|
|
714
732
|
_i++;
|
|
715
|
-
_context3.n =
|
|
733
|
+
_context3.n = 11;
|
|
716
734
|
break;
|
|
717
|
-
case 14:
|
|
718
|
-
return _context3.a(2, {
|
|
719
|
-
sources: sources
|
|
720
|
-
});
|
|
721
735
|
case 15:
|
|
722
|
-
_context3.
|
|
736
|
+
return _context3.a(2, createForOfIteratorHelper._objectSpread2({
|
|
737
|
+
sources: sources
|
|
738
|
+
}, snapshot !== undefined ? {
|
|
739
|
+
snapshot: snapshot
|
|
740
|
+
} : {}));
|
|
741
|
+
case 16:
|
|
742
|
+
_context3.p = 16;
|
|
723
743
|
_t0 = _context3.v;
|
|
724
744
|
// Published content, as before this existed: a draft page that renders
|
|
725
745
|
// the site is a degraded preview, one that fails to render is an outage.
|
|
726
746
|
console.error("Val: could not read the draft", _t0);
|
|
727
|
-
return _context3.a(2,
|
|
747
|
+
return _context3.a(2, onlySnapshot);
|
|
728
748
|
}
|
|
729
|
-
}, _callee3, null, [[
|
|
749
|
+
}, _callee3, null, [[1, 16]]);
|
|
730
750
|
}));
|
|
731
751
|
};
|
|
732
752
|
|
|
@@ -969,7 +989,7 @@ function getHost(headers) {
|
|
|
969
989
|
// }
|
|
970
990
|
// }
|
|
971
991
|
|
|
972
|
-
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
992
|
+
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
973
993
|
return /*#__PURE__*/function () {
|
|
974
994
|
var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, params) {
|
|
975
995
|
var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t10;
|
|
@@ -1041,7 +1061,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
1041
1061
|
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
1042
1062
|
}));
|
|
1043
1063
|
case 11:
|
|
1044
|
-
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
|
|
1064
|
+
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot);
|
|
1045
1065
|
_t10 = valModule;
|
|
1046
1066
|
if (!_t10) {
|
|
1047
1067
|
_context4.n = 13;
|
|
@@ -1322,14 +1342,14 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
1322
1342
|
};
|
|
1323
1343
|
}();
|
|
1324
1344
|
};
|
|
1325
|
-
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
|
|
1345
|
+
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot) {
|
|
1326
1346
|
return /*#__PURE__*/function () {
|
|
1327
1347
|
var _ref6 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee6(selector, params) {
|
|
1328
1348
|
var fetchVal, resolvedParams, valModule, path, schema, val, route, _t12, _t13;
|
|
1329
1349
|
return version._regenerator().w(function (_context6) {
|
|
1330
1350
|
while (1) switch (_context6.n) {
|
|
1331
1351
|
case 0:
|
|
1332
|
-
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
|
|
1352
|
+
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope, snapshot);
|
|
1333
1353
|
if (!(params === undefined)) {
|
|
1334
1354
|
_context6.n = 1;
|
|
1335
1355
|
break;
|
|
@@ -1455,7 +1475,7 @@ function _requestCookies() {
|
|
|
1455
1475
|
return _requestCookies.apply(this, arguments);
|
|
1456
1476
|
}
|
|
1457
1477
|
function initValContent(config, valModules, opts) {
|
|
1458
|
-
var _opts$draftMode;
|
|
1478
|
+
var _opts$http, _opts$draftMode;
|
|
1459
1479
|
var coreVersion = core.Internal.VERSION.core;
|
|
1460
1480
|
if (!coreVersion) {
|
|
1461
1481
|
throw new Error("Could not get @valbuild/core package version");
|
|
@@ -1465,6 +1485,7 @@ function initValContent(config, valModules, opts) {
|
|
|
1465
1485
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
1466
1486
|
}
|
|
1467
1487
|
var draftSourcesScope = createTanStackRequestScope();
|
|
1488
|
+
var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? server.proposalSnapshot(opts.http.proposal) : undefined;
|
|
1468
1489
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
1469
1490
|
var isEnabled = function isEnabled() {
|
|
1470
1491
|
return draftMode.isEnabled();
|
|
@@ -1493,11 +1514,11 @@ function initValContent(config, valModules, opts) {
|
|
|
1493
1514
|
return {
|
|
1494
1515
|
fetchValStega: initFetchValStega(config, valApiEndpoints,
|
|
1495
1516
|
// TODO: get from config
|
|
1496
|
-
valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1517
|
+
valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1497
1518
|
fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
|
|
1498
|
-
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1499
|
-
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
|
|
1500
|
-
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope)
|
|
1519
|
+
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1520
|
+
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1521
|
+
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
|
|
1501
1522
|
};
|
|
1502
1523
|
}
|
|
1503
1524
|
|