@valbuild/tanstack 0.139.2 → 0.140.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +51 -4
  3. package/client/dist/valbuild-tanstack-client.cjs.dev.js +53 -6
  4. package/client/dist/valbuild-tanstack-client.cjs.prod.js +53 -6
  5. package/client/dist/valbuild-tanstack-client.esm.js +53 -6
  6. package/dist/{ValOverlayContext-5f1d8da4.cjs.prod.js → ValOverlayContext-2739cc60.cjs.prod.js} +4 -2
  7. package/dist/{ValOverlayContext-5bc3830f.esm.js → ValOverlayContext-28101df3.esm.js} +4 -2
  8. package/dist/{ValOverlayContext-3ec15518.cjs.dev.js → ValOverlayContext-bafe3de9.cjs.dev.js} +4 -2
  9. package/dist/{createForOfIteratorHelper-e75681d7.cjs.dev.js → createForOfIteratorHelper-4497beef.cjs.dev.js} +2 -0
  10. package/dist/{createForOfIteratorHelper-485c2ce1.esm.js → createForOfIteratorHelper-93a62170.esm.js} +1 -1
  11. package/dist/{createForOfIteratorHelper-0324e063.cjs.prod.js → createForOfIteratorHelper-9afd7d2d.cjs.prod.js} +2 -0
  12. package/dist/declarations/src/ValDraft.d.ts +21 -0
  13. package/dist/declarations/src/ValProvider.d.ts +1 -0
  14. package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +1 -0
  15. package/dist/declarations/src/server/index.d.ts +1 -0
  16. package/dist/declarations/src/server/initValContent.d.ts +30 -0
  17. package/dist/{routeFromVal-6693e037.cjs.prod.js → routeFromVal-0b39e8e3.cjs.prod.js} +1 -1
  18. package/dist/{routeFromVal-728295a0.esm.js → routeFromVal-1221e70d.esm.js} +1 -1
  19. package/dist/{routeFromVal-a9147ceb.cjs.dev.js → routeFromVal-97111bfd.cjs.dev.js} +1 -1
  20. package/dist/valbuild-tanstack.cjs.dev.js +50 -12
  21. package/dist/valbuild-tanstack.cjs.prod.js +50 -12
  22. package/dist/valbuild-tanstack.esm.js +50 -12
  23. package/dist/{version-f6f044c2.cjs.prod.js → version-0cfddc38.cjs.dev.js} +1 -1
  24. package/dist/{version-4cc54e05.cjs.dev.js → version-24675097.cjs.prod.js} +1 -1
  25. package/dist/{version-d0b1c2c5.esm.js → version-e61be600.esm.js} +1 -1
  26. package/package.json +7 -7
  27. package/server/dist/valbuild-tanstack-server.cjs.dev.js +478 -152
  28. package/server/dist/valbuild-tanstack-server.cjs.prod.js +478 -152
  29. package/server/dist/valbuild-tanstack-server.esm.js +479 -153
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-4cc54e05.cjs.dev.js');
5
+ var version = require('../../dist/version-0cfddc38.cjs.dev.js');
6
6
  var core = require('@valbuild/core');
7
- var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-e75681d7.cjs.dev.js');
7
+ var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-4497beef.cjs.dev.js');
8
8
  var server = require('@valbuild/server');
9
- var routeFromVal = require('../../dist/routeFromVal-a9147ceb.cjs.dev.js');
9
+ var routeFromVal = require('../../dist/routeFromVal-97111bfd.cjs.dev.js');
10
10
  var stega = require('@valbuild/react/stega');
11
11
  var internal = require('@valbuild/shared/internal');
12
12
  var mcp = require('@valbuild/mcp');
@@ -317,6 +317,22 @@ function initValServer(valModules, config, opts) {
317
317
  };
318
318
  }
319
319
 
320
+ function _arrayWithoutHoles(r) {
321
+ if (Array.isArray(r)) return createForOfIteratorHelper._arrayLikeToArray(r);
322
+ }
323
+
324
+ function _iterableToArray(r) {
325
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
326
+ }
327
+
328
+ function _nonIterableSpread() {
329
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
330
+ }
331
+
332
+ function _toConsumableArray(r) {
333
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || createForOfIteratorHelper._unsupportedIterableToArray(r) || _nonIterableSpread();
334
+ }
335
+
320
336
  /*
321
337
  * NOTE: no `SET_RSC(true)` here, unlike the Next package.
322
338
  *
@@ -428,16 +444,16 @@ function loadDraftSources(_x, _x2) {
428
444
  return _loadDraftSources.apply(this, arguments);
429
445
  }
430
446
  function _loadDraftSources() {
431
- _loadDraftSources = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee6(valServerPromise, sessionCookie) {
447
+ _loadDraftSources = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee7(valServerPromise, sessionCookie) {
432
448
  var valServer, treeRes;
433
- return version._regenerator().w(function (_context6) {
434
- while (1) switch (_context6.n) {
449
+ return version._regenerator().w(function (_context7) {
450
+ while (1) switch (_context7.n) {
435
451
  case 0:
436
- _context6.n = 1;
452
+ _context7.n = 1;
437
453
  return valServerPromise;
438
454
  case 1:
439
- valServer = _context6.v;
440
- _context6.n = 2;
455
+ valServer = _context7.v;
456
+ _context7.n = 2;
441
457
  return valServer["/sources/~"]["PUT"]({
442
458
  path: "/",
443
459
  query: {
@@ -466,25 +482,25 @@ function _loadDraftSources() {
466
482
  cookies: createForOfIteratorHelper._defineProperty({}, internal.VAL_SESSION_COOKIE, sessionCookie)
467
483
  });
468
484
  case 2:
469
- treeRes = _context6.v;
485
+ treeRes = _context7.v;
470
486
  if (!(treeRes.status === 200)) {
471
- _context6.n = 3;
487
+ _context7.n = 3;
472
488
  break;
473
489
  }
474
- return _context6.a(2, treeRes.json.modules);
490
+ return _context7.a(2, treeRes.json.modules);
475
491
  case 3:
476
492
  if (!(treeRes.status === 401)) {
477
- _context6.n = 4;
493
+ _context7.n = 4;
478
494
  break;
479
495
  }
480
496
  console.warn("Val: authentication error: ", treeRes.json.message);
481
- return _context6.a(2, null);
497
+ return _context7.a(2, null);
482
498
  case 4:
483
499
  throw Error(JSON.stringify(treeRes.json, null, 2));
484
500
  case 5:
485
- return _context6.a(2);
501
+ return _context7.a(2);
486
502
  }
487
- }, _callee6);
503
+ }, _callee7);
488
504
  }));
489
505
  return _loadDraftSources.apply(this, arguments);
490
506
  }
@@ -604,6 +620,315 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
604
620
  });
605
621
  };
606
622
  };
623
+
624
+ /** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
625
+
626
+ /**
627
+ * The draft a page in this request should start from, or `null` for none.
628
+ *
629
+ * `null` -- and no read at all -- unless draft mode is on: a visitor pays one
630
+ * cookie lookup. Otherwise the SAME read every
631
+ * `fetchVal` in the request shares (`loadDraftSources`, memoised per request),
632
+ * cut down to the modules the draft changes. See `ValDraft`.
633
+ *
634
+ * Exists because the hooks render on the server too, and had no draft there:
635
+ * a draft page was rendered as the published site and only then replaced, in
636
+ * the browser, by what the editor holds -- old text first on every load.
637
+ */
638
+ var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope) {
639
+ 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;
641
+ return version._regenerator().w(function (_context3) {
642
+ while (1) switch (_context3.p = _context3.n) {
643
+ case 0:
644
+ _context3.p = 0;
645
+ _context3.n = 1;
646
+ return isEnabled();
647
+ case 1:
648
+ if (_context3.v) {
649
+ _context3.n = 2;
650
+ break;
651
+ }
652
+ return _context3.a(2, null);
653
+ case 2:
654
+ _context3.n = 3;
655
+ return getCookies();
656
+ case 3:
657
+ _t7 = _yield$getCookies$get = _context3.v.get(internal.VAL_SESSION_COOKIE);
658
+ _t6 = _t7 === null;
659
+ if (_t6) {
660
+ _context3.n = 4;
661
+ break;
662
+ }
663
+ _t6 = _yield$getCookies$get === void 0;
664
+ case 4:
665
+ if (!_t6) {
666
+ _context3.n = 5;
667
+ break;
668
+ }
669
+ _t8 = void 0;
670
+ _context3.n = 6;
671
+ break;
672
+ case 5:
673
+ _t8 = _yield$getCookies$get.value;
674
+ case 6:
675
+ sessionCookie = _t8;
676
+ _t9 = internal.memoizePerRequest;
677
+ _context3.n = 7;
678
+ return getDraftSourcesScope();
679
+ case 7:
680
+ _context3.n = 8;
681
+ return _t9(_context3.v, sessionCookie !== null && sessionCookie !== void 0 ? sessionCookie : "", function () {
682
+ return loadDraftSources(valServerPromise, sessionCookie);
683
+ });
684
+ case 8:
685
+ modules = _context3.v;
686
+ if (modules) {
687
+ _context3.n = 9;
688
+ break;
689
+ }
690
+ return _context3.a(2, null);
691
+ case 9:
692
+ sources = {};
693
+ _i = 0, _Object$entries = Object.entries(modules);
694
+ case 10:
695
+ if (!(_i < _Object$entries.length)) {
696
+ _context3.n = 14;
697
+ break;
698
+ }
699
+ _Object$entries$_i = createForOfIteratorHelper._slicedToArray(_Object$entries[_i], 2), path = _Object$entries$_i[0], module = _Object$entries$_i[1];
700
+ if (!(module.patches === undefined)) {
701
+ _context3.n = 11;
702
+ break;
703
+ }
704
+ return _context3.a(3, 13);
705
+ case 11:
706
+ _context3.n = 12;
707
+ return withDraftJsonEntries(valServerPromise, sessionCookie, path, module.source, module.patches.applied);
708
+ case 12:
709
+ source = _context3.v;
710
+ if (source !== undefined) {
711
+ sources[path] = source;
712
+ }
713
+ case 13:
714
+ _i++;
715
+ _context3.n = 10;
716
+ break;
717
+ case 14:
718
+ return _context3.a(2, {
719
+ sources: sources
720
+ });
721
+ case 15:
722
+ _context3.p = 15;
723
+ _t0 = _context3.v;
724
+ // Published content, as before this existed: a draft page that renders
725
+ // the site is a degraded preview, one that fails to render is an outage.
726
+ console.error("Val: could not read the draft", _t0);
727
+ return _context3.a(2, null);
728
+ }
729
+ }, _callee3, null, [[0, 15]]);
730
+ }));
731
+ };
732
+
733
+ /**
734
+ * A module's draft source, as the browser would have received it, with the
735
+ * `.jsonValues()` entries the draft edits filled in -- or `undefined` when
736
+ * they could not all be read, so the module is left out of the draft.
737
+ *
738
+ * Two things, both because `/sources/~` keeps each such entry as a MARKER
739
+ * (its content lives in its own file):
740
+ *
741
+ * - Read in-process, a marker still carries its `import()` thunk, which no
742
+ * serializer can send. So the source is put in its wire shape first, the
743
+ * same one the Studio gets over HTTP: a marker without its thunk, which the
744
+ * hooks read as "no draft for this entry" and resolve from the bundle.
745
+ * - An entry edited in the draft is still a marker there, so the page would
746
+ * render the published entry and swap it once the Studio loads it. Those
747
+ * entries -- the ones an applied patch touches, and only those -- are read
748
+ * through `/json` and put in place of their markers, which is the shape
749
+ * the Studio's own store gives them once it has.
750
+ *
751
+ * Leaving the module out is the published render that existed before the
752
+ * draft did: worse than this, and never wrong for long.
753
+ */
754
+ function withDraftJsonEntries(_x3, _x4, _x5, _x6, _x7) {
755
+ return _withDraftJsonEntries.apply(this, arguments);
756
+ }
757
+ function _withDraftJsonEntries() {
758
+ _withDraftJsonEntries = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee8(valServerPromise, sessionCookie, moduleFilePath, source, appliedPatchIds) {
759
+ var wire, valServer, cookies, patchesRes, edited, _iterator, _step, _step$value, path, patch, _iterator3, _step3, op, touched, _i2, _touched, _key, keys, draft, i, res, _iterator2, _step2, _step2$value, key, content, _t14, _t15;
760
+ return version._regenerator().w(function (_context8) {
761
+ while (1) switch (_context8.p = _context8.n) {
762
+ case 0:
763
+ if (!(source === undefined)) {
764
+ _context8.n = 1;
765
+ break;
766
+ }
767
+ return _context8.a(2, undefined);
768
+ case 1:
769
+ wire = JSON.parse(JSON.stringify(source));
770
+ if (!(!isRecordOfJsonMarkers(source) || appliedPatchIds.length === 0)) {
771
+ _context8.n = 2;
772
+ break;
773
+ }
774
+ return _context8.a(2, wire);
775
+ case 2:
776
+ _context8.n = 3;
777
+ return valServerPromise;
778
+ case 3:
779
+ valServer = _context8.v;
780
+ cookies = createForOfIteratorHelper._defineProperty({}, internal.VAL_SESSION_COOKIE, sessionCookie);
781
+ _context8.n = 4;
782
+ return valServer["/patches"]["GET"]({
783
+ query: {
784
+ patch_id: appliedPatchIds,
785
+ exclude_patch_ops: false,
786
+ include_patch_groups: undefined
787
+ },
788
+ cookies: cookies
789
+ });
790
+ case 4:
791
+ patchesRes = _context8.v;
792
+ if (!(patchesRes.status !== 200)) {
793
+ _context8.n = 5;
794
+ break;
795
+ }
796
+ return _context8.a(2, undefined);
797
+ case 5:
798
+ edited = new Set();
799
+ _iterator = createForOfIteratorHelper._createForOfIteratorHelper(patchesRes.json.patches);
800
+ _context8.p = 6;
801
+ _iterator.s();
802
+ case 7:
803
+ if ((_step = _iterator.n()).done) {
804
+ _context8.n = 19;
805
+ break;
806
+ }
807
+ _step$value = _step.value, path = _step$value.path, patch = _step$value.patch;
808
+ if (!(path !== moduleFilePath)) {
809
+ _context8.n = 8;
810
+ break;
811
+ }
812
+ return _context8.a(3, 18);
813
+ case 8:
814
+ _iterator3 = createForOfIteratorHelper._createForOfIteratorHelper(patch !== null && patch !== void 0 ? patch : []);
815
+ _context8.p = 9;
816
+ _iterator3.s();
817
+ case 10:
818
+ if ((_step3 = _iterator3.n()).done) {
819
+ _context8.n = 15;
820
+ break;
821
+ }
822
+ op = _step3.value;
823
+ touched = [op.path[0]];
824
+ if (op.op === "move" || op.op === "copy") {
825
+ touched.push(op.from[0]);
826
+ }
827
+ _i2 = 0, _touched = touched;
828
+ case 11:
829
+ if (!(_i2 < _touched.length)) {
830
+ _context8.n = 14;
831
+ break;
832
+ }
833
+ _key = _touched[_i2];
834
+ if (!(_key === undefined)) {
835
+ _context8.n = 12;
836
+ break;
837
+ }
838
+ return _context8.a(2, undefined);
839
+ case 12:
840
+ if (core.Internal.isJson(source[_key])) {
841
+ edited.add(_key);
842
+ }
843
+ case 13:
844
+ _i2++;
845
+ _context8.n = 11;
846
+ break;
847
+ case 14:
848
+ _context8.n = 10;
849
+ break;
850
+ case 15:
851
+ _context8.n = 17;
852
+ break;
853
+ case 16:
854
+ _context8.p = 16;
855
+ _t14 = _context8.v;
856
+ _iterator3.e(_t14);
857
+ case 17:
858
+ _context8.p = 17;
859
+ _iterator3.f();
860
+ return _context8.f(17);
861
+ case 18:
862
+ _context8.n = 7;
863
+ break;
864
+ case 19:
865
+ _context8.n = 21;
866
+ break;
867
+ case 20:
868
+ _context8.p = 20;
869
+ _t15 = _context8.v;
870
+ _iterator.e(_t15);
871
+ case 21:
872
+ _context8.p = 21;
873
+ _iterator.f();
874
+ return _context8.f(21);
875
+ case 22:
876
+ keys = _toConsumableArray(edited);
877
+ draft = wire;
878
+ i = 0;
879
+ case 23:
880
+ if (!(i < keys.length)) {
881
+ _context8.n = 27;
882
+ break;
883
+ }
884
+ _context8.n = 24;
885
+ return valServer["/json"]["GET"]({
886
+ query: {
887
+ path: moduleFilePath,
888
+ key: undefined,
889
+ keys: keys.slice(i, i + internal.JSON_ENTRIES_BATCH_MAX),
890
+ offset: undefined,
891
+ limit: undefined,
892
+ apply_patches: true,
893
+ own_patch_groups_only: true
894
+ },
895
+ cookies: cookies
896
+ });
897
+ case 24:
898
+ res = _context8.v;
899
+ if (!(res.status !== 200 || !("entries" in res.json) || res.json.errors.length > 0 || res.json.missing.length > 0)) {
900
+ _context8.n = 25;
901
+ break;
902
+ }
903
+ return _context8.a(2, undefined);
904
+ case 25:
905
+ _iterator2 = createForOfIteratorHelper._createForOfIteratorHelper(res.json.entries);
906
+ try {
907
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
908
+ _step2$value = _step2.value, key = _step2$value.key, content = _step2$value.content;
909
+ draft[key] = content;
910
+ }
911
+ } catch (err) {
912
+ _iterator2.e(err);
913
+ } finally {
914
+ _iterator2.f();
915
+ }
916
+ case 26:
917
+ i += internal.JSON_ENTRIES_BATCH_MAX;
918
+ _context8.n = 23;
919
+ break;
920
+ case 27:
921
+ return _context8.a(2, draft);
922
+ }
923
+ }, _callee8, null, [[9, 16, 17, 18], [6, 20, 21, 22]]);
924
+ }));
925
+ return _withDraftJsonEntries.apply(this, arguments);
926
+ }
927
+ function isRecordOfJsonMarkers(source) {
928
+ return routeFromVal._typeof(source) === "object" && source !== null && !Array.isArray(source) && Object.values(source).some(function (value) {
929
+ return core.Internal.isJson(value);
930
+ });
931
+ }
607
932
  function getHost(headers) {
608
933
  var _headers$get;
609
934
  var host = headers === null || headers === void 0 ? void 0 : headers.get("host");
@@ -646,15 +971,15 @@ function getHost(headers) {
646
971
 
647
972
  var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
648
973
  return /*#__PURE__*/function () {
649
- var _ref3 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3(selector, params) {
650
- var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t7;
651
- return version._regenerator().w(function (_context3) {
652
- while (1) switch (_context3.p = _context3.n) {
974
+ var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, params) {
975
+ var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t10;
976
+ return version._regenerator().w(function (_context4) {
977
+ while (1) switch (_context4.p = _context4.n) {
653
978
  case 0:
654
- _context3.n = 1;
979
+ _context4.n = 1;
655
980
  return Promise.resolve(params);
656
981
  case 1:
657
- resolvedParams = _context3.v;
982
+ resolvedParams = _context4.v;
658
983
  // A view is a pointer: everything below reads a path, a schema and a source
659
984
  // off this, and a pointer has none of them. See `resolveViewedModule`.
660
985
  valModule = core.Internal.resolveViewedModule(selector);
@@ -663,78 +988,78 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
663
988
  // entry's backing `*.val.json`, instead of eagerly resolving the whole
664
989
  // record via `fetchVal`.
665
990
  if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
666
- _context3.n = 11;
991
+ _context4.n = 11;
667
992
  break;
668
993
  }
669
994
  source = valModule && core.Internal.getSource(valModule);
670
995
  url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
671
996
  if (url) {
672
- _context3.n = 2;
997
+ _context4.n = 2;
673
998
  break;
674
999
  }
675
- return _context3.a(2, null);
1000
+ return _context4.a(2, null);
676
1001
  case 2:
677
1002
  enabled = false;
678
- _context3.p = 3;
679
- _context3.n = 4;
1003
+ _context4.p = 3;
1004
+ _context4.n = 4;
680
1005
  return isEnabled();
681
1006
  case 4:
682
- enabled = _context3.v;
683
- _context3.n = 6;
1007
+ enabled = _context4.v;
1008
+ _context4.n = 6;
684
1009
  break;
685
1010
  case 5:
686
- _context3.p = 5;
687
- _context3.v;
1011
+ _context4.p = 5;
1012
+ _context4.v;
688
1013
  case 6:
689
1014
  draft = {
690
1015
  status: "unavailable"
691
1016
  };
692
1017
  if (!(enabled && path)) {
693
- _context3.n = 8;
1018
+ _context4.n = 8;
694
1019
  break;
695
1020
  }
696
1021
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
697
- _context3.n = 7;
1022
+ _context4.n = 7;
698
1023
  return loadDraftJsonEntry(valServerPromise, getCookies, path, url);
699
1024
  case 7:
700
- draft = _context3.v;
1025
+ draft = _context4.v;
701
1026
  case 8:
702
- _context3.n = 9;
1027
+ _context4.n = 9;
703
1028
  return resolveDraftOrCommittedEntry(draft, function () {
704
1029
  return loadJsonEntryContent(source, url);
705
1030
  });
706
1031
  case 9:
707
- content = _context3.v;
1032
+ content = _context4.v;
708
1033
  if (!(content === undefined)) {
709
- _context3.n = 10;
1034
+ _context4.n = 10;
710
1035
  break;
711
1036
  }
712
- return _context3.a(2, null);
1037
+ return _context4.a(2, null);
713
1038
  case 10:
714
- return _context3.a(2, stega.stegaEncode(content, {
1039
+ return _context4.a(2, stega.stegaEncode(content, {
715
1040
  disabled: !enabled,
716
1041
  root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
717
1042
  }));
718
1043
  case 11:
719
1044
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
720
- _t7 = valModule;
721
- if (!_t7) {
722
- _context3.n = 13;
1045
+ _t10 = valModule;
1046
+ if (!_t10) {
1047
+ _context4.n = 13;
723
1048
  break;
724
1049
  }
725
- _context3.n = 12;
1050
+ _context4.n = 12;
726
1051
  return fetchVal(valModule);
727
1052
  case 12:
728
- _t7 = _context3.v;
1053
+ _t10 = _context4.v;
729
1054
  case 13:
730
- val = _t7;
1055
+ val = _t10;
731
1056
  route = routeFromVal.initValRouteFromVal(resolvedParams, "fetchValRoute", path, schema, val);
732
- return _context3.a(2, route);
1057
+ return _context4.a(2, route);
733
1058
  }
734
- }, _callee3, null, [[3, 5]]);
1059
+ }, _callee4, null, [[3, 5]]);
735
1060
  }));
736
- return function (_x3, _x4) {
737
- return _ref3.apply(this, arguments);
1061
+ return function (_x8, _x9) {
1062
+ return _ref4.apply(this, arguments);
738
1063
  };
739
1064
  }();
740
1065
  };
@@ -744,7 +1069,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
744
1069
  * source markers (one dynamic import). Returns `undefined` when the key is
745
1070
  * missing or its marker has no runtime thunk (transport marker / draft entry).
746
1071
  */
747
- function loadJsonEntryContent(_x5, _x6) {
1072
+ function loadJsonEntryContent(_x0, _x1) {
748
1073
  return _loadJsonEntryContent.apply(this, arguments);
749
1074
  }
750
1075
  /**
@@ -769,37 +1094,37 @@ function loadJsonEntryContent(_x5, _x6) {
769
1094
  * to the whole server type.
770
1095
  */
771
1096
  function _loadJsonEntryContent() {
772
- _loadJsonEntryContent = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee7(source, key) {
1097
+ _loadJsonEntryContent = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee9(source, key) {
773
1098
  var marker, thunk;
774
- return version._regenerator().w(function (_context7) {
775
- while (1) switch (_context7.n) {
1099
+ return version._regenerator().w(function (_context9) {
1100
+ while (1) switch (_context9.n) {
776
1101
  case 0:
777
1102
  if (!(!source || routeFromVal._typeof(source) !== "object")) {
778
- _context7.n = 1;
1103
+ _context9.n = 1;
779
1104
  break;
780
1105
  }
781
- return _context7.a(2, undefined);
1106
+ return _context9.a(2, undefined);
782
1107
  case 1:
783
1108
  marker = source[key];
784
1109
  if (core.Internal.isJson(marker)) {
785
- _context7.n = 2;
1110
+ _context9.n = 2;
786
1111
  break;
787
1112
  }
788
- return _context7.a(2, undefined);
1113
+ return _context9.a(2, undefined);
789
1114
  case 2:
790
1115
  thunk = core.Internal.getJsonImport(marker);
791
1116
  if (thunk) {
792
- _context7.n = 3;
1117
+ _context9.n = 3;
793
1118
  break;
794
1119
  }
795
- return _context7.a(2, undefined);
1120
+ return _context9.a(2, undefined);
796
1121
  case 3:
797
- _context7.n = 4;
1122
+ _context9.n = 4;
798
1123
  return thunk();
799
1124
  case 4:
800
- return _context7.a(2, _context7.v["default"]);
1125
+ return _context9.a(2, _context9.v["default"]);
801
1126
  }
802
- }, _callee7);
1127
+ }, _callee9);
803
1128
  }));
804
1129
  return _loadJsonEntryContent.apply(this, arguments);
805
1130
  }
@@ -812,33 +1137,33 @@ function _loadJsonEntryContent() {
812
1137
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
813
1138
  * a null/undefined result.
814
1139
  */
815
- function resolveDraftOrCommittedEntry(_x7, _x8) {
1140
+ function resolveDraftOrCommittedEntry(_x10, _x11) {
816
1141
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
817
1142
  }
818
1143
  function _resolveDraftOrCommittedEntry() {
819
- _resolveDraftOrCommittedEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee8(draft, loadCommitted) {
820
- return version._regenerator().w(function (_context8) {
821
- while (1) switch (_context8.n) {
1144
+ _resolveDraftOrCommittedEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee0(draft, loadCommitted) {
1145
+ return version._regenerator().w(function (_context0) {
1146
+ while (1) switch (_context0.n) {
822
1147
  case 0:
823
1148
  if (!(draft.status === "content")) {
824
- _context8.n = 1;
1149
+ _context0.n = 1;
825
1150
  break;
826
1151
  }
827
- return _context8.a(2, draft.content);
1152
+ return _context0.a(2, draft.content);
828
1153
  case 1:
829
1154
  if (!(draft.status === "absent")) {
830
- _context8.n = 2;
1155
+ _context0.n = 2;
831
1156
  break;
832
1157
  }
833
- return _context8.a(2, undefined);
1158
+ return _context0.a(2, undefined);
834
1159
  case 2:
835
- return _context8.a(2, loadCommitted());
1160
+ return _context0.a(2, loadCommitted());
836
1161
  }
837
- }, _callee8);
1162
+ }, _callee0);
838
1163
  }));
839
1164
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
840
1165
  }
841
- function loadDraftJsonEntry(_x9, _x0, _x1, _x10) {
1166
+ function loadDraftJsonEntry(_x12, _x13, _x14, _x15) {
842
1167
  return _loadDraftJsonEntry.apply(this, arguments);
843
1168
  }
844
1169
  /**
@@ -853,31 +1178,31 @@ function loadDraftJsonEntry(_x9, _x0, _x1, _x10) {
853
1178
  * the draft read yields nothing.
854
1179
  */
855
1180
  function _loadDraftJsonEntry() {
856
- _loadDraftJsonEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee9(valServerPromise, getCookies, moduleFilePath, key) {
857
- var _cookies3;
1181
+ _loadDraftJsonEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee1(valServerPromise, getCookies, moduleFilePath, key) {
1182
+ var _cookies4;
858
1183
  var cookies, valServer, res;
859
- return version._regenerator().w(function (_context9) {
860
- while (1) switch (_context9.p = _context9.n) {
1184
+ return version._regenerator().w(function (_context1) {
1185
+ while (1) switch (_context1.p = _context1.n) {
861
1186
  case 0:
862
- _context9.p = 0;
863
- _context9.n = 1;
1187
+ _context1.p = 0;
1188
+ _context1.n = 1;
864
1189
  return getCookies();
865
1190
  case 1:
866
- cookies = _context9.v;
867
- _context9.n = 3;
1191
+ cookies = _context1.v;
1192
+ _context1.n = 3;
868
1193
  break;
869
1194
  case 2:
870
- _context9.p = 2;
871
- _context9.v;
872
- return _context9.a(2, {
1195
+ _context1.p = 2;
1196
+ _context1.v;
1197
+ return _context1.a(2, {
873
1198
  status: "unavailable"
874
1199
  });
875
1200
  case 3:
876
- _context9.n = 4;
1201
+ _context1.n = 4;
877
1202
  return valServerPromise;
878
1203
  case 4:
879
- valServer = _context9.v;
880
- _context9.n = 5;
1204
+ valServer = _context1.v;
1205
+ _context1.n = 5;
881
1206
  return valServer["/json"]["GET"]({
882
1207
  query: {
883
1208
  path: moduleFilePath,
@@ -897,63 +1222,63 @@ function _loadDraftJsonEntry() {
897
1222
  */
898
1223
  own_patch_groups_only: true
899
1224
  },
900
- cookies: createForOfIteratorHelper._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies3 = cookies) === null || _cookies3 === void 0 || (_cookies3 = _cookies3.get(internal.VAL_SESSION_COOKIE)) === null || _cookies3 === void 0 ? void 0 : _cookies3.value)
1225
+ cookies: createForOfIteratorHelper._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies4 = cookies) === null || _cookies4 === void 0 || (_cookies4 = _cookies4.get(internal.VAL_SESSION_COOKIE)) === null || _cookies4 === void 0 ? void 0 : _cookies4.value)
901
1226
  });
902
1227
  case 5:
903
- res = _context9.v;
1228
+ res = _context1.v;
904
1229
  if (!(res.status === 200 && "content" in res.json)) {
905
- _context9.n = 6;
1230
+ _context1.n = 6;
906
1231
  break;
907
1232
  }
908
- return _context9.a(2, {
1233
+ return _context1.a(2, {
909
1234
  status: "content",
910
1235
  content: res.json.content
911
1236
  });
912
1237
  case 6:
913
1238
  if (!(res.status === 401)) {
914
- _context9.n = 7;
1239
+ _context1.n = 7;
915
1240
  break;
916
1241
  }
917
1242
  console.warn("Val: authentication error: ", res.json.message);
918
- return _context9.a(2, {
1243
+ return _context1.a(2, {
919
1244
  status: "unavailable"
920
1245
  });
921
1246
  case 7:
922
1247
  if (!(res.status === 404)) {
923
- _context9.n = 8;
1248
+ _context1.n = 8;
924
1249
  break;
925
1250
  }
926
- return _context9.a(2, {
1251
+ return _context1.a(2, {
927
1252
  status: "absent"
928
1253
  });
929
1254
  case 8:
930
1255
  console.error("Val: could not load draft JSON entry: ", "message" in res.json ? res.json.message : "status ".concat(res.status));
931
- return _context9.a(2, {
1256
+ return _context1.a(2, {
932
1257
  status: "unavailable"
933
1258
  });
934
1259
  }
935
- }, _callee9, null, [[0, 2]]);
1260
+ }, _callee1, null, [[0, 2]]);
936
1261
  }));
937
1262
  return _loadDraftJsonEntry.apply(this, arguments);
938
1263
  }
939
1264
  var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
940
1265
  return /*#__PURE__*/function () {
941
- var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, key) {
1266
+ var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, key) {
942
1267
  var enabled, valModule, source, moduleFilePath, draft, content;
943
- return version._regenerator().w(function (_context4) {
944
- while (1) switch (_context4.p = _context4.n) {
1268
+ return version._regenerator().w(function (_context5) {
1269
+ while (1) switch (_context5.p = _context5.n) {
945
1270
  case 0:
946
1271
  enabled = false;
947
- _context4.p = 1;
948
- _context4.n = 2;
1272
+ _context5.p = 1;
1273
+ _context5.n = 2;
949
1274
  return isEnabled();
950
1275
  case 2:
951
- enabled = _context4.v;
952
- _context4.n = 4;
1276
+ enabled = _context5.v;
1277
+ _context5.n = 4;
953
1278
  break;
954
1279
  case 3:
955
- _context4.p = 3;
956
- _context4.v;
1280
+ _context5.p = 3;
1281
+ _context5.v;
957
1282
  case 4:
958
1283
  // A view is a pointer: everything below reads a path and a source off this,
959
1284
  // and a pointer has neither. See `resolveViewedModule`.
@@ -964,84 +1289,84 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
964
1289
  status: "unavailable"
965
1290
  };
966
1291
  if (!(enabled && moduleFilePath)) {
967
- _context4.n = 6;
1292
+ _context5.n = 6;
968
1293
  break;
969
1294
  }
970
1295
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
971
- _context4.n = 5;
1296
+ _context5.n = 5;
972
1297
  return loadDraftJsonEntry(valServerPromise, getCookies, moduleFilePath, key);
973
1298
  case 5:
974
- draft = _context4.v;
1299
+ draft = _context5.v;
975
1300
  case 6:
976
- _context4.n = 7;
1301
+ _context5.n = 7;
977
1302
  return resolveDraftOrCommittedEntry(draft, function () {
978
1303
  return loadJsonEntryContent(source, key);
979
1304
  });
980
1305
  case 7:
981
- content = _context4.v;
1306
+ content = _context5.v;
982
1307
  if (!(content === undefined)) {
983
- _context4.n = 8;
1308
+ _context5.n = 8;
984
1309
  break;
985
1310
  }
986
- return _context4.a(2, undefined);
1311
+ return _context5.a(2, undefined);
987
1312
  case 8:
988
- return _context4.a(2, stega.stegaEncode(content, {
1313
+ return _context5.a(2, stega.stegaEncode(content, {
989
1314
  disabled: !enabled,
990
1315
  root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
991
1316
  }));
992
1317
  }
993
- }, _callee4, null, [[1, 3]]);
1318
+ }, _callee5, null, [[1, 3]]);
994
1319
  }));
995
- return function (_x11, _x12) {
996
- return _ref4.apply(this, arguments);
1320
+ return function (_x16, _x17) {
1321
+ return _ref5.apply(this, arguments);
997
1322
  };
998
1323
  }();
999
1324
  };
1000
1325
  var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
1001
1326
  return /*#__PURE__*/function () {
1002
- var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, params) {
1003
- var fetchVal, resolvedParams, valModule, path, schema, val, route, _t9, _t0;
1004
- return version._regenerator().w(function (_context5) {
1005
- while (1) switch (_context5.n) {
1327
+ var _ref6 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee6(selector, params) {
1328
+ var fetchVal, resolvedParams, valModule, path, schema, val, route, _t12, _t13;
1329
+ return version._regenerator().w(function (_context6) {
1330
+ while (1) switch (_context6.n) {
1006
1331
  case 0:
1007
1332
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
1008
1333
  if (!(params === undefined)) {
1009
- _context5.n = 1;
1334
+ _context6.n = 1;
1010
1335
  break;
1011
1336
  }
1012
- _t9 = undefined;
1013
- _context5.n = 3;
1337
+ _t12 = undefined;
1338
+ _context6.n = 3;
1014
1339
  break;
1015
1340
  case 1:
1016
- _context5.n = 2;
1341
+ _context6.n = 2;
1017
1342
  return Promise.resolve(params);
1018
1343
  case 2:
1019
- _t9 = _context5.v;
1344
+ _t12 = _context6.v;
1020
1345
  case 3:
1021
- resolvedParams = _t9;
1346
+ resolvedParams = _t12;
1022
1347
  // A view is a pointer: everything below reads a path, a schema and a source
1023
1348
  // off this, and a pointer has none of them. See `resolveViewedModule`.
1024
1349
  valModule = core.Internal.resolveViewedModule(selector);
1025
1350
  path = valModule && core.Internal.getValPath(valModule);
1026
1351
  schema = valModule && core.Internal.getSchema(valModule);
1027
- _t0 = valModule;
1028
- if (!_t0) {
1029
- _context5.n = 5;
1352
+ _t13 = valModule;
1353
+ if (!_t13) {
1354
+ _context6.n = 5;
1030
1355
  break;
1031
1356
  }
1032
- _context5.n = 4;
1357
+ _context6.n = 4;
1033
1358
  return fetchVal(valModule);
1034
1359
  case 4:
1035
- _t0 = _context5.v;
1360
+ _t13 = _context6.v;
1036
1361
  case 5:
1037
- val = _t0;
1362
+ val = _t13;
1038
1363
  route = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRouteUrl", path, schema, val);
1039
- return _context5.a(2, route);
1364
+ return _context6.a(2, route);
1040
1365
  }
1041
- }, _callee5);
1366
+ }, _callee6);
1042
1367
  }));
1043
- return function (_x13, _x14) {
1044
- return _ref5.apply(this, arguments);
1368
+ return function (_x18, _x19) {
1369
+ return _ref6.apply(this, arguments);
1045
1370
  };
1046
1371
  }();
1047
1372
  };
@@ -1059,25 +1384,25 @@ function requestHeaders() {
1059
1384
  }
1060
1385
  /** The request's cookies, in the `{ name, value }` shape the readers want. */
1061
1386
  function _requestHeaders() {
1062
- _requestHeaders = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee0() {
1387
+ _requestHeaders = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee10() {
1063
1388
  var _yield$import2, getRequestHeaders, headers;
1064
- return version._regenerator().w(function (_context0) {
1065
- while (1) switch (_context0.n) {
1389
+ return version._regenerator().w(function (_context10) {
1390
+ while (1) switch (_context10.n) {
1066
1391
  case 0:
1067
- _context0.n = 1;
1392
+ _context10.n = 1;
1068
1393
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@tanstack/react-start/server')); });
1069
1394
  case 1:
1070
- _yield$import2 = _context0.v;
1395
+ _yield$import2 = _context10.v;
1071
1396
  getRequestHeaders = _yield$import2.getRequestHeaders;
1072
1397
  headers = getRequestHeaders();
1073
- return _context0.a(2, {
1398
+ return _context10.a(2, {
1074
1399
  get: function get(name) {
1075
1400
  var _headers$get2;
1076
1401
  return (_headers$get2 = headers.get(name)) !== null && _headers$get2 !== void 0 ? _headers$get2 : null;
1077
1402
  }
1078
1403
  });
1079
1404
  }
1080
- }, _callee0);
1405
+ }, _callee10);
1081
1406
  }));
1082
1407
  return _requestHeaders.apply(this, arguments);
1083
1408
  }
@@ -1105,17 +1430,17 @@ function requestCookies() {
1105
1430
  * } = initValContent(config, valModules);
1106
1431
  */
1107
1432
  function _requestCookies() {
1108
- _requestCookies = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee1() {
1433
+ _requestCookies = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee11() {
1109
1434
  var _yield$import3, getCookie;
1110
- return version._regenerator().w(function (_context1) {
1111
- while (1) switch (_context1.n) {
1435
+ return version._regenerator().w(function (_context11) {
1436
+ while (1) switch (_context11.n) {
1112
1437
  case 0:
1113
- _context1.n = 1;
1438
+ _context11.n = 1;
1114
1439
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@tanstack/react-start/server')); });
1115
1440
  case 1:
1116
- _yield$import3 = _context1.v;
1441
+ _yield$import3 = _context11.v;
1117
1442
  getCookie = _yield$import3.getCookie;
1118
- return _context1.a(2, {
1443
+ return _context11.a(2, {
1119
1444
  get: function get(name) {
1120
1445
  var value = getCookie(name);
1121
1446
  return value === undefined ? undefined : {
@@ -1125,7 +1450,7 @@ function _requestCookies() {
1125
1450
  }
1126
1451
  });
1127
1452
  }
1128
- }, _callee1);
1453
+ }, _callee11);
1129
1454
  }));
1130
1455
  return _requestCookies.apply(this, arguments);
1131
1456
  }
@@ -1171,7 +1496,8 @@ function initValContent(config, valModules, opts) {
1171
1496
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
1172
1497
  fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1173
1498
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
1174
- fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope)
1499
+ fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope),
1500
+ fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope)
1175
1501
  };
1176
1502
  }
1177
1503