@valbuild/tanstack 0.144.0 → 0.144.1

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.144.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#824](https://github.com/valbuild/val/pull/824) [`a641bb0`](https://github.com/valbuild/val/commit/a641bb0286756339252c53e9230d766c23fcccc6) Thanks [@freekh](https://github.com/freekh)! - `.jsonValues()` entries saved in a proposal now show at the proposal's address. Before, the page kept showing the entry as it was when the site was last built, and the Studio there showed every entry of a saved `.jsonValues()` module as empty.
8
+ - Updated dependencies [[`a641bb0`](https://github.com/valbuild/val/commit/a641bb0286756339252c53e9230d766c23fcccc6)]:
9
+ - @valbuild/server@0.144.1
10
+ - @valbuild/language-server@0.144.1
11
+ - @valbuild/mcp@0.144.1
12
+
3
13
  ## 0.144.0
4
14
 
5
15
  ### Patch Changes
@@ -174,18 +174,25 @@ function useDraftModuleSource(moduleFilePath) {
174
174
  * bundled content is used only when there is no draft view.
175
175
  */
176
176
  function draftJsonEntry(draftSource, key) {
177
- if (draftSource === undefined || draftSource === null || routeFromVal._typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
177
+ if (draftSource === null) {
178
+ // A nullable record that is null in the draft view: it has no entries.
179
+ return {
180
+ status: "absent"
181
+ };
182
+ }
183
+ if (draftSource === undefined || routeFromVal._typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
178
184
  return {
179
185
  status: "unavailable"
180
186
  };
181
187
  }
182
- var entry = draftSource[key];
183
- if (entry === undefined) {
188
+ // Own keys only: an entry may be named `toString`.
189
+ if (!Object.prototype.hasOwnProperty.call(draftSource, key)) {
184
190
  // The module IS in the draft view and this key is not: it was deleted.
185
191
  return {
186
192
  status: "absent"
187
193
  };
188
194
  }
195
+ var entry = draftSource[key];
189
196
  if (core.Internal.isJson(entry)) {
190
197
  // An un-loaded marker: the Studio has not fetched this entry's content, so
191
198
  // the draft view cannot answer. (The engine asks for entries that pending
@@ -174,18 +174,25 @@ function useDraftModuleSource(moduleFilePath) {
174
174
  * bundled content is used only when there is no draft view.
175
175
  */
176
176
  function draftJsonEntry(draftSource, key) {
177
- if (draftSource === undefined || draftSource === null || routeFromVal._typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
177
+ if (draftSource === null) {
178
+ // A nullable record that is null in the draft view: it has no entries.
179
+ return {
180
+ status: "absent"
181
+ };
182
+ }
183
+ if (draftSource === undefined || routeFromVal._typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
178
184
  return {
179
185
  status: "unavailable"
180
186
  };
181
187
  }
182
- var entry = draftSource[key];
183
- if (entry === undefined) {
188
+ // Own keys only: an entry may be named `toString`.
189
+ if (!Object.prototype.hasOwnProperty.call(draftSource, key)) {
184
190
  // The module IS in the draft view and this key is not: it was deleted.
185
191
  return {
186
192
  status: "absent"
187
193
  };
188
194
  }
195
+ var entry = draftSource[key];
189
196
  if (core.Internal.isJson(entry)) {
190
197
  // An un-loaded marker: the Studio has not fetched this entry's content, so
191
198
  // the draft view cannot answer. (The engine asks for entries that pending
@@ -166,18 +166,25 @@ function useDraftModuleSource(moduleFilePath) {
166
166
  * bundled content is used only when there is no draft view.
167
167
  */
168
168
  function draftJsonEntry(draftSource, key) {
169
- if (draftSource === undefined || draftSource === null || _typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
169
+ if (draftSource === null) {
170
+ // A nullable record that is null in the draft view: it has no entries.
171
+ return {
172
+ status: "absent"
173
+ };
174
+ }
175
+ if (draftSource === undefined || _typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
170
176
  return {
171
177
  status: "unavailable"
172
178
  };
173
179
  }
174
- var entry = draftSource[key];
175
- if (entry === undefined) {
180
+ // Own keys only: an entry may be named `toString`.
181
+ if (!Object.prototype.hasOwnProperty.call(draftSource, key)) {
176
182
  // The module IS in the draft view and this key is not: it was deleted.
177
183
  return {
178
184
  status: "absent"
179
185
  };
180
186
  }
187
+ var entry = draftSource[key];
181
188
  if (Internal.isJson(entry)) {
182
189
  // An un-loaded marker: the Studio has not fetched this entry's content, so
183
190
  // the draft view cannot answer. (The engine asks for entries that pending
@@ -138,6 +138,17 @@ export type DraftJsonEntry = {
138
138
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
139
139
  * a null/undefined result.
140
140
  */
141
+ /**
142
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
143
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
144
+ * a proposal, or an entry the proposal did not save, which is the build's.
145
+ *
146
+ * The snapshot carries saved entries as content in place of their markers
147
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
148
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
149
+ * agree.
150
+ */
151
+ export declare function snapshotJsonEntry(snapshot: Snapshot | undefined, moduleFilePath: ModuleFilePath, key: string): DraftJsonEntry;
141
152
  export declare function resolveDraftOrCommittedEntry(draft: DraftJsonEntry, loadCommitted: () => Promise<unknown | undefined>): Promise<unknown | undefined>;
142
153
  /**
143
154
  * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
@@ -155,7 +166,9 @@ export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryV
155
166
  name: string;
156
167
  value: string;
157
168
  } | undefined;
158
- }>) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
169
+ }>,
170
+ /** A proposal's saved Source; see `ValDraft.snapshot`. */
171
+ snapshot?: Snapshot) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
159
172
  declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<RouteReaderValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
160
173
  get(name: string): string | null;
161
174
  }>, getCookies: () => Promise<{
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-46ae2355.cjs.dev.js');
5
+ var version = require('./version-aa10b04d.cjs.dev.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-4497beef.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-94d1191d.cjs.prod.js');
5
+ var version = require('./version-664d3be8.cjs.prod.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-9afd7d2d.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-4f8a63a0.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-62df289a.esm.js';
2
2
  import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper } from './createForOfIteratorHelper-93a62170.esm.js';
3
3
  import { Internal as Internal$1, initVal as initVal$1, DEFAULT_CONTENT_HOST } from '@valbuild/core';
4
4
  import * as core from '@valbuild/core';
@@ -210,7 +210,7 @@ var packageJson = {
210
210
  "tanstack-router",
211
211
  "react"
212
212
  ],
213
- version: "0.144.0",
213
+ version: "0.144.1",
214
214
  scripts: {
215
215
  typecheck: "tsc --noEmit",
216
216
  test: "jest"
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.144.0",
215
+ version: "0.144.1",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.144.0",
215
+ version: "0.144.1",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "tanstack-router",
15
15
  "react"
16
16
  ],
17
- "version": "0.144.0",
17
+ "version": "0.144.1",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -42,13 +42,13 @@
42
42
  "exports": true
43
43
  },
44
44
  "dependencies": {
45
- "@valbuild/language-server": "0.144.0",
46
45
  "@valbuild/core": "0.144.0",
47
- "@valbuild/mcp": "0.144.0",
48
- "@valbuild/server": "0.144.0",
46
+ "@valbuild/language-server": "0.144.1",
47
+ "@valbuild/mcp": "0.144.1",
49
48
  "@valbuild/react": "0.144.0",
49
+ "@valbuild/ui": "0.144.0",
50
50
  "@valbuild/shared": "0.144.0",
51
- "@valbuild/ui": "0.144.0"
51
+ "@valbuild/server": "0.144.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@tanstack/react-router": "^1.170.41",
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-46ae2355.cjs.dev.js');
5
+ var version = require('../../dist/version-aa10b04d.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');
@@ -1045,7 +1045,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1045
1045
  draft = _context4.v;
1046
1046
  case 8:
1047
1047
  _context4.n = 9;
1048
- return resolveDraftOrCommittedEntry(draft, function () {
1048
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1049
1049
  return loadJsonEntryContent(source, url);
1050
1050
  });
1051
1051
  case 9:
@@ -1157,6 +1157,46 @@ function _loadJsonEntryContent() {
1157
1157
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1158
1158
  * a null/undefined result.
1159
1159
  */
1160
+ /**
1161
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1162
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1163
+ * a proposal, or an entry the proposal did not save, which is the build's.
1164
+ *
1165
+ * The snapshot carries saved entries as content in place of their markers
1166
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1167
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1168
+ * agree.
1169
+ */
1170
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1171
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1172
+ if (source === null) {
1173
+ // A nullable record the proposal saved as null: it has no entries.
1174
+ return {
1175
+ status: "absent"
1176
+ };
1177
+ }
1178
+ if (source === undefined || routeFromVal._typeof(source) !== "object" || Array.isArray(source)) {
1179
+ return {
1180
+ status: "unavailable"
1181
+ };
1182
+ }
1183
+ // Own keys only: an entry may be named `toString`.
1184
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1185
+ return {
1186
+ status: "absent"
1187
+ };
1188
+ }
1189
+ var entry = source[key];
1190
+ if (core.Internal.isJson(entry)) {
1191
+ return {
1192
+ status: "unavailable"
1193
+ };
1194
+ }
1195
+ return {
1196
+ status: "content",
1197
+ content: entry
1198
+ };
1199
+ }
1160
1200
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1161
1201
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1162
1202
  }
@@ -1281,7 +1321,7 @@ function _loadDraftJsonEntry() {
1281
1321
  }));
1282
1322
  return _loadDraftJsonEntry.apply(this, arguments);
1283
1323
  }
1284
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1324
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1285
1325
  return /*#__PURE__*/function () {
1286
1326
  var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, key) {
1287
1327
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1319,7 +1359,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1319
1359
  draft = _context5.v;
1320
1360
  case 6:
1321
1361
  _context5.n = 7;
1322
- return resolveDraftOrCommittedEntry(draft, function () {
1362
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1323
1363
  return loadJsonEntryContent(source, key);
1324
1364
  });
1325
1365
  case 7:
@@ -1485,7 +1525,7 @@ function initValContent(config, valModules, opts) {
1485
1525
  throw new Error("Could not get @valbuild/tanstack package version");
1486
1526
  }
1487
1527
  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;
1528
+ var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? server.proposalSnapshotForReaders(opts.http.proposal, opts.http.projectSource) : undefined;
1489
1529
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1490
1530
  var isEnabled = function isEnabled() {
1491
1531
  return draftMode.isEnabled();
@@ -1515,7 +1555,7 @@ function initValContent(config, valModules, opts) {
1515
1555
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1516
1556
  // TODO: get from config
1517
1557
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1518
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1558
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1519
1559
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1520
1560
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1521
1561
  fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-94d1191d.cjs.prod.js');
5
+ var version = require('../../dist/version-664d3be8.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');
@@ -1045,7 +1045,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1045
1045
  draft = _context4.v;
1046
1046
  case 8:
1047
1047
  _context4.n = 9;
1048
- return resolveDraftOrCommittedEntry(draft, function () {
1048
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1049
1049
  return loadJsonEntryContent(source, url);
1050
1050
  });
1051
1051
  case 9:
@@ -1157,6 +1157,46 @@ function _loadJsonEntryContent() {
1157
1157
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1158
1158
  * a null/undefined result.
1159
1159
  */
1160
+ /**
1161
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1162
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1163
+ * a proposal, or an entry the proposal did not save, which is the build's.
1164
+ *
1165
+ * The snapshot carries saved entries as content in place of their markers
1166
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1167
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1168
+ * agree.
1169
+ */
1170
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1171
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1172
+ if (source === null) {
1173
+ // A nullable record the proposal saved as null: it has no entries.
1174
+ return {
1175
+ status: "absent"
1176
+ };
1177
+ }
1178
+ if (source === undefined || routeFromVal._typeof(source) !== "object" || Array.isArray(source)) {
1179
+ return {
1180
+ status: "unavailable"
1181
+ };
1182
+ }
1183
+ // Own keys only: an entry may be named `toString`.
1184
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1185
+ return {
1186
+ status: "absent"
1187
+ };
1188
+ }
1189
+ var entry = source[key];
1190
+ if (core.Internal.isJson(entry)) {
1191
+ return {
1192
+ status: "unavailable"
1193
+ };
1194
+ }
1195
+ return {
1196
+ status: "content",
1197
+ content: entry
1198
+ };
1199
+ }
1160
1200
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1161
1201
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1162
1202
  }
@@ -1281,7 +1321,7 @@ function _loadDraftJsonEntry() {
1281
1321
  }));
1282
1322
  return _loadDraftJsonEntry.apply(this, arguments);
1283
1323
  }
1284
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1324
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1285
1325
  return /*#__PURE__*/function () {
1286
1326
  var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, key) {
1287
1327
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1319,7 +1359,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1319
1359
  draft = _context5.v;
1320
1360
  case 6:
1321
1361
  _context5.n = 7;
1322
- return resolveDraftOrCommittedEntry(draft, function () {
1362
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1323
1363
  return loadJsonEntryContent(source, key);
1324
1364
  });
1325
1365
  case 7:
@@ -1485,7 +1525,7 @@ function initValContent(config, valModules, opts) {
1485
1525
  throw new Error("Could not get @valbuild/tanstack package version");
1486
1526
  }
1487
1527
  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;
1528
+ var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? server.proposalSnapshotForReaders(opts.http.proposal, opts.http.projectSource) : undefined;
1489
1529
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1490
1530
  var isEnabled = function isEnabled() {
1491
1531
  return draftMode.isEnabled();
@@ -1515,7 +1555,7 @@ function initValContent(config, valModules, opts) {
1515
1555
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1516
1556
  // TODO: get from config
1517
1557
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1518
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1558
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1519
1559
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1520
1560
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1521
1561
  fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
@@ -1,7 +1,7 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-4f8a63a0.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-62df289a.esm.js';
2
2
  import { Internal } from '@valbuild/core';
3
3
  import { _ as _objectSpread2, a as _slicedToArray, e as _arrayLikeToArray, f as _unsupportedIterableToArray, b as _createForOfIteratorHelper, d as _defineProperty } from '../../dist/createForOfIteratorHelper-93a62170.esm.js';
4
- import { createValApiRouter, createValServer, proposalSnapshot } from '@valbuild/server';
4
+ import { createValApiRouter, createValServer, proposalSnapshotForReaders } from '@valbuild/server';
5
5
  export { InMemoryPatchStore, createPrettierFormatter } from '@valbuild/server';
6
6
  import { _ as _typeof, b as initValRouteFromVal, g as getJsonEntryStegaRoot, i as isJsonValuesRecordSchema, a as getValRouteUrlFromVal } from '../../dist/routeFromVal-1221e70d.esm.js';
7
7
  import { stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
@@ -1024,7 +1024,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1024
1024
  draft = _context4.v;
1025
1025
  case 8:
1026
1026
  _context4.n = 9;
1027
- return resolveDraftOrCommittedEntry(draft, function () {
1027
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1028
1028
  return loadJsonEntryContent(source, url);
1029
1029
  });
1030
1030
  case 9:
@@ -1136,6 +1136,46 @@ function _loadJsonEntryContent() {
1136
1136
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1137
1137
  * a null/undefined result.
1138
1138
  */
1139
+ /**
1140
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1141
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1142
+ * a proposal, or an entry the proposal did not save, which is the build's.
1143
+ *
1144
+ * The snapshot carries saved entries as content in place of their markers
1145
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1146
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1147
+ * agree.
1148
+ */
1149
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1150
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1151
+ if (source === null) {
1152
+ // A nullable record the proposal saved as null: it has no entries.
1153
+ return {
1154
+ status: "absent"
1155
+ };
1156
+ }
1157
+ if (source === undefined || _typeof(source) !== "object" || Array.isArray(source)) {
1158
+ return {
1159
+ status: "unavailable"
1160
+ };
1161
+ }
1162
+ // Own keys only: an entry may be named `toString`.
1163
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1164
+ return {
1165
+ status: "absent"
1166
+ };
1167
+ }
1168
+ var entry = source[key];
1169
+ if (Internal.isJson(entry)) {
1170
+ return {
1171
+ status: "unavailable"
1172
+ };
1173
+ }
1174
+ return {
1175
+ status: "content",
1176
+ content: entry
1177
+ };
1178
+ }
1139
1179
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1140
1180
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1141
1181
  }
@@ -1260,7 +1300,7 @@ function _loadDraftJsonEntry() {
1260
1300
  }));
1261
1301
  return _loadDraftJsonEntry.apply(this, arguments);
1262
1302
  }
1263
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1303
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1264
1304
  return /*#__PURE__*/function () {
1265
1305
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(selector, key) {
1266
1306
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1298,7 +1338,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1298
1338
  draft = _context5.v;
1299
1339
  case 6:
1300
1340
  _context5.n = 7;
1301
- return resolveDraftOrCommittedEntry(draft, function () {
1341
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1302
1342
  return loadJsonEntryContent(source, key);
1303
1343
  });
1304
1344
  case 7:
@@ -1464,7 +1504,7 @@ function initValContent(config, valModules, opts) {
1464
1504
  throw new Error("Could not get @valbuild/tanstack package version");
1465
1505
  }
1466
1506
  var draftSourcesScope = createTanStackRequestScope();
1467
- var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? proposalSnapshot(opts.http.proposal) : undefined;
1507
+ var snapshot = (opts === null || opts === void 0 || (_opts$http = opts.http) === null || _opts$http === void 0 ? void 0 : _opts$http.proposal) !== undefined ? proposalSnapshotForReaders(opts.http.proposal, opts.http.projectSource) : undefined;
1468
1508
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1469
1509
  var isEnabled = function isEnabled() {
1470
1510
  return draftMode.isEnabled();
@@ -1494,7 +1534,7 @@ function initValContent(config, valModules, opts) {
1494
1534
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1495
1535
  // TODO: get from config
1496
1536
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1497
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1537
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1498
1538
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1499
1539
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1500
1540
  fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)