@valbuild/tanstack 0.144.0 → 0.144.2

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,37 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.144.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#832](https://github.com/valbuild/val/pull/832) [`ab0ea20`](https://github.com/valbuild/val/commit/ab0ea2046e3872c4955f34b363881f76d48d1b1e) Thanks [@freekh](https://github.com/freekh)! - A site served by Val's platform can now be given its content separately from its build. When the platform hands a TanStack app a content version (`VAL_CONTENT`) that differs from what the build bundles, Val renders that content, in the Studio and in draft mode too. It reads it the way it already reads a proposal's saved content.
8
+
9
+ Nothing changes for an app that is not given one, and nothing hands one over yet. This is the reading side of publishing content without rebuilding the site.
10
+
11
+ A version too large for one environment variable can name others under `refs` (`"env://VAL_CONTENT_1"`), each holding one module's Source or one file's text. Only `refs` is resolved, never a string inside your content, and only variables named `VAL_CONTENT_<n>` are read.
12
+
13
+ At a proposal's address, a proposal's saved content is shown over the content version the site serves, so modules the proposal did not change show what the site shows rather than what the build bundles.
14
+
15
+ When Val's platform puts a publish live without building the site, because it changed only content, the Studio shows it being checked and going live instead of "Building".
16
+
17
+ - Updated dependencies [[`ab0ea20`](https://github.com/valbuild/val/commit/ab0ea2046e3872c4955f34b363881f76d48d1b1e), [`44a5636`](https://github.com/valbuild/val/commit/44a5636955e005a40f2e6c8544e5cf4378fd0fdf)]:
18
+ - @valbuild/server@0.144.2
19
+ - @valbuild/shared@0.144.2
20
+ - @valbuild/ui@0.144.2
21
+ - @valbuild/language-server@0.144.2
22
+ - @valbuild/mcp@0.144.2
23
+ - @valbuild/react@0.144.2
24
+
25
+ ## 0.144.1
26
+
27
+ ### Patch Changes
28
+
29
+ - [#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.
30
+ - Updated dependencies [[`a641bb0`](https://github.com/valbuild/val/commit/a641bb0286756339252c53e9230d766c23fcccc6)]:
31
+ - @valbuild/server@0.144.1
32
+ - @valbuild/language-server@0.144.1
33
+ - @valbuild/mcp@0.144.1
34
+
3
35
  ## 0.144.0
4
36
 
5
37
  ### 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
@@ -63,6 +63,25 @@ export declare const initFetchValStega: (config: ValConfig, valApiEndpoints: str
63
63
  snapshot?: Snapshot) => <T extends Resolvable>(selector: T) => Promise<ResolvedVal<T>>;
64
64
  /** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
65
65
  type Snapshot = Record<ModuleFilePath, Json>;
66
+ /**
67
+ * What the readers render over the bundle: a proposal's saves over the
68
+ * content version the site serves (`layeredSnapshot` in @valbuild/server),
69
+ * either alone, or nothing.
70
+ */
71
+ export declare function snapshotForReaders(http: Pick<ValHttpMode, "proposal" | "contentVersion" | "projectSource"> | undefined): Snapshot | undefined;
72
+ /**
73
+ * Where an isolate says which content version it applied, for the platform
74
+ * serving it to read back after a render (valbuild/home: the loader answers it
75
+ * as a header). A Val that predates content versions never sets it, which is
76
+ * how the platform tells that an app cannot be served a version its build does
77
+ * not bundle -- an unknown option is otherwise ignored, silently.
78
+ */
79
+ export declare const CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
80
+ /**
81
+ * Name the content version this isolate renders, when it renders one -- at a
82
+ * proposal's address too, where it is under the proposal's saves.
83
+ */
84
+ export declare function markContentApplied(http: Pick<ValHttpMode, "proposal" | "contentVersion"> | undefined): void;
66
85
  /** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
67
86
  export type DraftValServer = {
68
87
  "/sources/~": ValServer["/sources/~"];
@@ -138,6 +157,17 @@ export type DraftJsonEntry = {
138
157
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
139
158
  * a null/undefined result.
140
159
  */
160
+ /**
161
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
162
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
163
+ * a proposal, or an entry the proposal did not save, which is the build's.
164
+ *
165
+ * The snapshot carries saved entries as content in place of their markers
166
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
167
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
168
+ * agree.
169
+ */
170
+ export declare function snapshotJsonEntry(snapshot: Snapshot | undefined, moduleFilePath: ModuleFilePath, key: string): DraftJsonEntry;
141
171
  export declare function resolveDraftOrCommittedEntry(draft: DraftJsonEntry, loadCommitted: () => Promise<unknown | undefined>): Promise<unknown | undefined>;
142
172
  /**
143
173
  * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
@@ -155,7 +185,9 @@ export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryV
155
185
  name: string;
156
186
  value: string;
157
187
  } | undefined;
158
- }>) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
188
+ }>,
189
+ /** A proposal's saved Source; see `ValDraft.snapshot`. */
190
+ snapshot?: Snapshot) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
159
191
  declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<RouteReaderValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
160
192
  get(name: string): string | null;
161
193
  }>, getCookies: () => Promise<{
@@ -1,5 +1,5 @@
1
1
  import { ValConfig, ValModules } from "@valbuild/core";
2
- import { type CommitContext, type CommitResult, type ValPatchStore, type ValProposal } from "@valbuild/server";
2
+ import { type CommitContext, type CommitResult, type ValPatchStore, type ValContentVersion, type ValProposal } from "@valbuild/server";
3
3
  import { type ValDraftMode } from "./valDraftMode.js";
4
4
  /**
5
5
  * What `http` mode needs, as one object.
@@ -80,6 +80,14 @@ export type ValHttpMode = {
80
80
  * should set it.
81
81
  */
82
82
  proposal?: ValProposal;
83
+ /**
84
+ * The content version the site serves, when the platform says it differs
85
+ * from the one this build bundles (`VAL_CONTENT`; read it with
86
+ * `contentFromEnv`). Its Source replaces the bundle's for what it holds, on
87
+ * every read, and its publish is this server's position. Ignored at a
88
+ * proposal's address. Nothing else should set it.
89
+ */
90
+ contentVersion?: ValContentVersion;
83
91
  };
84
92
  export declare function initValServer(valModules: ValModules, config: ValConfig & {
85
93
  disableCache?: boolean;
@@ -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-c4d88129.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-277910e9.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-f6399796.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';
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.144.0",
215
+ version: "0.144.2",
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.2",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -210,7 +210,7 @@ var packageJson = {
210
210
  "tanstack-router",
211
211
  "react"
212
212
  ],
213
- version: "0.144.0",
213
+ version: "0.144.2",
214
214
  scripts: {
215
215
  typecheck: "tsc --noEmit",
216
216
  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.2",
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",
49
- "@valbuild/react": "0.144.0",
50
- "@valbuild/shared": "0.144.0",
51
- "@valbuild/ui": "0.144.0"
46
+ "@valbuild/language-server": "0.144.2",
47
+ "@valbuild/mcp": "0.144.2",
48
+ "@valbuild/react": "0.144.2",
49
+ "@valbuild/server": "0.144.2",
50
+ "@valbuild/shared": "0.144.2",
51
+ "@valbuild/ui": "0.144.2"
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-c4d88129.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');
@@ -632,6 +632,36 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
632
632
 
633
633
  /** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
634
634
 
635
+ /**
636
+ * What the readers render over the bundle: a proposal's saves over the
637
+ * content version the site serves (`layeredSnapshot` in @valbuild/server),
638
+ * either alone, or nothing.
639
+ */
640
+ function snapshotForReaders(http) {
641
+ var source = server.layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
642
+ return source !== undefined ? server.proposalSnapshotForReaders(source, http === null || http === void 0 ? void 0 : http.projectSource) : undefined;
643
+ }
644
+
645
+ /**
646
+ * Where an isolate says which content version it applied, for the platform
647
+ * serving it to read back after a render (valbuild/home: the loader answers it
648
+ * as a header). A Val that predates content versions never sets it, which is
649
+ * how the platform tells that an app cannot be served a version its build does
650
+ * not bundle -- an unknown option is otherwise ignored, silently.
651
+ */
652
+ var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
653
+
654
+ /**
655
+ * Name the content version this isolate renders, when it renders one -- at a
656
+ * proposal's address too, where it is under the proposal's saves.
657
+ */
658
+ function markContentApplied(http) {
659
+ if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
660
+ return;
661
+ }
662
+ Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
663
+ }
664
+
635
665
  /** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
636
666
 
637
667
  /**
@@ -1045,7 +1075,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1045
1075
  draft = _context4.v;
1046
1076
  case 8:
1047
1077
  _context4.n = 9;
1048
- return resolveDraftOrCommittedEntry(draft, function () {
1078
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1049
1079
  return loadJsonEntryContent(source, url);
1050
1080
  });
1051
1081
  case 9:
@@ -1157,6 +1187,46 @@ function _loadJsonEntryContent() {
1157
1187
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1158
1188
  * a null/undefined result.
1159
1189
  */
1190
+ /**
1191
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1192
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1193
+ * a proposal, or an entry the proposal did not save, which is the build's.
1194
+ *
1195
+ * The snapshot carries saved entries as content in place of their markers
1196
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1197
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1198
+ * agree.
1199
+ */
1200
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1201
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1202
+ if (source === null) {
1203
+ // A nullable record the proposal saved as null: it has no entries.
1204
+ return {
1205
+ status: "absent"
1206
+ };
1207
+ }
1208
+ if (source === undefined || routeFromVal._typeof(source) !== "object" || Array.isArray(source)) {
1209
+ return {
1210
+ status: "unavailable"
1211
+ };
1212
+ }
1213
+ // Own keys only: an entry may be named `toString`.
1214
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1215
+ return {
1216
+ status: "absent"
1217
+ };
1218
+ }
1219
+ var entry = source[key];
1220
+ if (core.Internal.isJson(entry)) {
1221
+ return {
1222
+ status: "unavailable"
1223
+ };
1224
+ }
1225
+ return {
1226
+ status: "content",
1227
+ content: entry
1228
+ };
1229
+ }
1160
1230
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1161
1231
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1162
1232
  }
@@ -1281,7 +1351,7 @@ function _loadDraftJsonEntry() {
1281
1351
  }));
1282
1352
  return _loadDraftJsonEntry.apply(this, arguments);
1283
1353
  }
1284
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1354
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1285
1355
  return /*#__PURE__*/function () {
1286
1356
  var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, key) {
1287
1357
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1319,7 +1389,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1319
1389
  draft = _context5.v;
1320
1390
  case 6:
1321
1391
  _context5.n = 7;
1322
- return resolveDraftOrCommittedEntry(draft, function () {
1392
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1323
1393
  return loadJsonEntryContent(source, key);
1324
1394
  });
1325
1395
  case 7:
@@ -1475,7 +1545,7 @@ function _requestCookies() {
1475
1545
  return _requestCookies.apply(this, arguments);
1476
1546
  }
1477
1547
  function initValContent(config, valModules, opts) {
1478
- var _opts$http, _opts$draftMode;
1548
+ var _opts$draftMode;
1479
1549
  var coreVersion = core.Internal.VERSION.core;
1480
1550
  if (!coreVersion) {
1481
1551
  throw new Error("Could not get @valbuild/core package version");
@@ -1485,7 +1555,8 @@ function initValContent(config, valModules, opts) {
1485
1555
  throw new Error("Could not get @valbuild/tanstack package version");
1486
1556
  }
1487
1557
  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;
1558
+ var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
1559
+ markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
1489
1560
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1490
1561
  var isEnabled = function isEnabled() {
1491
1562
  return draftMode.isEnabled();
@@ -1515,7 +1586,7 @@ function initValContent(config, valModules, opts) {
1515
1586
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1516
1587
  // TODO: get from config
1517
1588
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1518
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1589
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1519
1590
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1520
1591
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1521
1592
  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-277910e9.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');
@@ -632,6 +632,36 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
632
632
 
633
633
  /** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
634
634
 
635
+ /**
636
+ * What the readers render over the bundle: a proposal's saves over the
637
+ * content version the site serves (`layeredSnapshot` in @valbuild/server),
638
+ * either alone, or nothing.
639
+ */
640
+ function snapshotForReaders(http) {
641
+ var source = server.layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
642
+ return source !== undefined ? server.proposalSnapshotForReaders(source, http === null || http === void 0 ? void 0 : http.projectSource) : undefined;
643
+ }
644
+
645
+ /**
646
+ * Where an isolate says which content version it applied, for the platform
647
+ * serving it to read back after a render (valbuild/home: the loader answers it
648
+ * as a header). A Val that predates content versions never sets it, which is
649
+ * how the platform tells that an app cannot be served a version its build does
650
+ * not bundle -- an unknown option is otherwise ignored, silently.
651
+ */
652
+ var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
653
+
654
+ /**
655
+ * Name the content version this isolate renders, when it renders one -- at a
656
+ * proposal's address too, where it is under the proposal's saves.
657
+ */
658
+ function markContentApplied(http) {
659
+ if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
660
+ return;
661
+ }
662
+ Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
663
+ }
664
+
635
665
  /** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
636
666
 
637
667
  /**
@@ -1045,7 +1075,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1045
1075
  draft = _context4.v;
1046
1076
  case 8:
1047
1077
  _context4.n = 9;
1048
- return resolveDraftOrCommittedEntry(draft, function () {
1078
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1049
1079
  return loadJsonEntryContent(source, url);
1050
1080
  });
1051
1081
  case 9:
@@ -1157,6 +1187,46 @@ function _loadJsonEntryContent() {
1157
1187
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1158
1188
  * a null/undefined result.
1159
1189
  */
1190
+ /**
1191
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1192
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1193
+ * a proposal, or an entry the proposal did not save, which is the build's.
1194
+ *
1195
+ * The snapshot carries saved entries as content in place of their markers
1196
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1197
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1198
+ * agree.
1199
+ */
1200
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1201
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1202
+ if (source === null) {
1203
+ // A nullable record the proposal saved as null: it has no entries.
1204
+ return {
1205
+ status: "absent"
1206
+ };
1207
+ }
1208
+ if (source === undefined || routeFromVal._typeof(source) !== "object" || Array.isArray(source)) {
1209
+ return {
1210
+ status: "unavailable"
1211
+ };
1212
+ }
1213
+ // Own keys only: an entry may be named `toString`.
1214
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1215
+ return {
1216
+ status: "absent"
1217
+ };
1218
+ }
1219
+ var entry = source[key];
1220
+ if (core.Internal.isJson(entry)) {
1221
+ return {
1222
+ status: "unavailable"
1223
+ };
1224
+ }
1225
+ return {
1226
+ status: "content",
1227
+ content: entry
1228
+ };
1229
+ }
1160
1230
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1161
1231
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1162
1232
  }
@@ -1281,7 +1351,7 @@ function _loadDraftJsonEntry() {
1281
1351
  }));
1282
1352
  return _loadDraftJsonEntry.apply(this, arguments);
1283
1353
  }
1284
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1354
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1285
1355
  return /*#__PURE__*/function () {
1286
1356
  var _ref5 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee5(selector, key) {
1287
1357
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1319,7 +1389,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1319
1389
  draft = _context5.v;
1320
1390
  case 6:
1321
1391
  _context5.n = 7;
1322
- return resolveDraftOrCommittedEntry(draft, function () {
1392
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1323
1393
  return loadJsonEntryContent(source, key);
1324
1394
  });
1325
1395
  case 7:
@@ -1475,7 +1545,7 @@ function _requestCookies() {
1475
1545
  return _requestCookies.apply(this, arguments);
1476
1546
  }
1477
1547
  function initValContent(config, valModules, opts) {
1478
- var _opts$http, _opts$draftMode;
1548
+ var _opts$draftMode;
1479
1549
  var coreVersion = core.Internal.VERSION.core;
1480
1550
  if (!coreVersion) {
1481
1551
  throw new Error("Could not get @valbuild/core package version");
@@ -1485,7 +1555,8 @@ function initValContent(config, valModules, opts) {
1485
1555
  throw new Error("Could not get @valbuild/tanstack package version");
1486
1556
  }
1487
1557
  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;
1558
+ var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
1559
+ markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
1489
1560
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1490
1561
  var isEnabled = function isEnabled() {
1491
1562
  return draftMode.isEnabled();
@@ -1515,7 +1586,7 @@ function initValContent(config, valModules, opts) {
1515
1586
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1516
1587
  // TODO: get from config
1517
1588
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1518
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1589
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1519
1590
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1520
1591
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1521
1592
  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-f6399796.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, layeredSnapshot, 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';
@@ -611,6 +611,36 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
611
611
 
612
612
  /** A proposal's saved Source, by module: see `ValProposal` in `@valbuild/server`. */
613
613
 
614
+ /**
615
+ * What the readers render over the bundle: a proposal's saves over the
616
+ * content version the site serves (`layeredSnapshot` in @valbuild/server),
617
+ * either alone, or nothing.
618
+ */
619
+ function snapshotForReaders(http) {
620
+ var source = layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
621
+ return source !== undefined ? proposalSnapshotForReaders(source, http === null || http === void 0 ? void 0 : http.projectSource) : undefined;
622
+ }
623
+
624
+ /**
625
+ * Where an isolate says which content version it applied, for the platform
626
+ * serving it to read back after a render (valbuild/home: the loader answers it
627
+ * as a header). A Val that predates content versions never sets it, which is
628
+ * how the platform tells that an app cannot be served a version its build does
629
+ * not bundle -- an unknown option is otherwise ignored, silently.
630
+ */
631
+ var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
632
+
633
+ /**
634
+ * Name the content version this isolate renders, when it renders one -- at a
635
+ * proposal's address too, where it is under the proposal's saves.
636
+ */
637
+ function markContentApplied(http) {
638
+ if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
639
+ return;
640
+ }
641
+ Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
642
+ }
643
+
614
644
  /** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
615
645
 
616
646
  /**
@@ -1024,7 +1054,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
1024
1054
  draft = _context4.v;
1025
1055
  case 8:
1026
1056
  _context4.n = 9;
1027
- return resolveDraftOrCommittedEntry(draft, function () {
1057
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && path ? snapshotJsonEntry(snapshot, path, url) : draft, function () {
1028
1058
  return loadJsonEntryContent(source, url);
1029
1059
  });
1030
1060
  case 9:
@@ -1136,6 +1166,46 @@ function _loadJsonEntryContent() {
1136
1166
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
1137
1167
  * a null/undefined result.
1138
1168
  */
1169
+ /**
1170
+ * What a proposal's snapshot says about one `.jsonValues()` entry: its saved
1171
+ * content, `absent` when the proposal removed it, or `unavailable` -- not at
1172
+ * a proposal, or an entry the proposal did not save, which is the build's.
1173
+ *
1174
+ * The snapshot carries saved entries as content in place of their markers
1175
+ * (`proposalSnapshotForReaders` in @valbuild/server). The same rule as the
1176
+ * browser's `draftJsonEntry`, so the server's render and the hydrated page
1177
+ * agree.
1178
+ */
1179
+ function snapshotJsonEntry(snapshot, moduleFilePath, key) {
1180
+ var source = snapshot === null || snapshot === void 0 ? void 0 : snapshot[moduleFilePath];
1181
+ if (source === null) {
1182
+ // A nullable record the proposal saved as null: it has no entries.
1183
+ return {
1184
+ status: "absent"
1185
+ };
1186
+ }
1187
+ if (source === undefined || _typeof(source) !== "object" || Array.isArray(source)) {
1188
+ return {
1189
+ status: "unavailable"
1190
+ };
1191
+ }
1192
+ // Own keys only: an entry may be named `toString`.
1193
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
1194
+ return {
1195
+ status: "absent"
1196
+ };
1197
+ }
1198
+ var entry = source[key];
1199
+ if (Internal.isJson(entry)) {
1200
+ return {
1201
+ status: "unavailable"
1202
+ };
1203
+ }
1204
+ return {
1205
+ status: "content",
1206
+ content: entry
1207
+ };
1208
+ }
1139
1209
  function resolveDraftOrCommittedEntry(_x10, _x11) {
1140
1210
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
1141
1211
  }
@@ -1260,7 +1330,7 @@ function _loadDraftJsonEntry() {
1260
1330
  }));
1261
1331
  return _loadDraftJsonEntry.apply(this, arguments);
1262
1332
  }
1263
- var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
1333
+ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies, snapshot) {
1264
1334
  return /*#__PURE__*/function () {
1265
1335
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(selector, key) {
1266
1336
  var enabled, valModule, source, moduleFilePath, draft, content;
@@ -1298,7 +1368,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
1298
1368
  draft = _context5.v;
1299
1369
  case 6:
1300
1370
  _context5.n = 7;
1301
- return resolveDraftOrCommittedEntry(draft, function () {
1371
+ return resolveDraftOrCommittedEntry(draft.status === "unavailable" && moduleFilePath ? snapshotJsonEntry(snapshot, moduleFilePath, key) : draft, function () {
1302
1372
  return loadJsonEntryContent(source, key);
1303
1373
  });
1304
1374
  case 7:
@@ -1454,7 +1524,7 @@ function _requestCookies() {
1454
1524
  return _requestCookies.apply(this, arguments);
1455
1525
  }
1456
1526
  function initValContent(config, valModules, opts) {
1457
- var _opts$http, _opts$draftMode;
1527
+ var _opts$draftMode;
1458
1528
  var coreVersion = Internal.VERSION.core;
1459
1529
  if (!coreVersion) {
1460
1530
  throw new Error("Could not get @valbuild/core package version");
@@ -1464,7 +1534,8 @@ function initValContent(config, valModules, opts) {
1464
1534
  throw new Error("Could not get @valbuild/tanstack package version");
1465
1535
  }
1466
1536
  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;
1537
+ var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
1538
+ markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
1468
1539
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
1469
1540
  var isEnabled = function isEnabled() {
1470
1541
  return draftMode.isEnabled();
@@ -1494,7 +1565,7 @@ function initValContent(config, valModules, opts) {
1494
1565
  fetchValStega: initFetchValStega(config, valApiEndpoints,
1495
1566
  // TODO: get from config
1496
1567
  valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1497
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies),
1568
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
1498
1569
  fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1499
1570
  fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
1500
1571
  fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)