@valbuild/tanstack 0.144.1 → 0.144.3
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 +41 -0
- package/client/dist/valbuild-tanstack-client.cjs.dev.js +18 -3
- package/client/dist/valbuild-tanstack-client.cjs.prod.js +18 -3
- package/client/dist/valbuild-tanstack-client.esm.js +18 -3
- package/dist/declarations/src/ValDraft.d.ts +10 -0
- package/dist/declarations/src/ValModulesClient.d.ts +3 -1
- package/dist/declarations/src/server/initValContent.d.ts +29 -1
- package/dist/declarations/src/server/initValServer.d.ts +9 -1
- package/dist/valbuild-tanstack.cjs.dev.js +11 -1
- package/dist/valbuild-tanstack.cjs.prod.js +11 -1
- package/dist/valbuild-tanstack.esm.js +11 -1
- package/dist/{version-664d3be8.cjs.prod.js → version-c5862191.cjs.dev.js} +1 -1
- package/dist/{version-62df289a.esm.js → version-e43bf6e6.esm.js} +1 -1
- package/dist/{version-aa10b04d.cjs.dev.js → version-efacbb53.cjs.prod.js} +1 -1
- package/package.json +7 -7
- package/server/dist/valbuild-tanstack-server.cjs.dev.js +51 -6
- package/server/dist/valbuild-tanstack-server.cjs.prod.js +51 -6
- package/server/dist/valbuild-tanstack-server.esm.js +52 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @valbuild/tanstack
|
|
2
2
|
|
|
3
|
+
## 0.144.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#833](https://github.com/valbuild/val/pull/833) [`99fcac5`](https://github.com/valbuild/val/commit/99fcac527f2d5ba37c4b132ef08189b955d69e51) Thanks [@freekh](https://github.com/freekh)! - A draft page no longer flips back to the text from before a content-only publish.
|
|
8
|
+
|
|
9
|
+
After content was published without a build, the Studio's overlay on a draft page started from the text compiled into the build, which still held the old content, and handed it to the page. Depending on which arrived first, an editor reloading the page saw the new text, then the old, then the new again, in a freshly opened tab and long after the publish. Visitors were not affected.
|
|
10
|
+
|
|
11
|
+
The page now hands the overlay the content it serves (`ValDraft.base`, from the content version and any proposal's saves), and the overlay starts from that instead of the build's text, so the two never disagree.
|
|
12
|
+
|
|
13
|
+
The same holds for `.jsonValues()` entries: where the overlay has not loaded an entry, `useValKey` and `useValRoute` now fall back to the content version's entry, as the server did, before the build's.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`99fcac5`](https://github.com/valbuild/val/commit/99fcac527f2d5ba37c4b132ef08189b955d69e51), [`0e09e9c`](https://github.com/valbuild/val/commit/0e09e9cdac4918bdfa1c01a92a8968a516f8c0c6)]:
|
|
16
|
+
- @valbuild/ui@0.144.3
|
|
17
|
+
- @valbuild/react@0.144.3
|
|
18
|
+
- @valbuild/server@0.144.3
|
|
19
|
+
- @valbuild/language-server@0.144.3
|
|
20
|
+
- @valbuild/mcp@0.144.3
|
|
21
|
+
|
|
22
|
+
## 0.144.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [#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.
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
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".
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`ab0ea20`](https://github.com/valbuild/val/commit/ab0ea2046e3872c4955f34b363881f76d48d1b1e), [`44a5636`](https://github.com/valbuild/val/commit/44a5636955e005a40f2e6c8544e5cf4378fd0fdf)]:
|
|
37
|
+
- @valbuild/server@0.144.2
|
|
38
|
+
- @valbuild/shared@0.144.2
|
|
39
|
+
- @valbuild/ui@0.144.2
|
|
40
|
+
- @valbuild/language-server@0.144.2
|
|
41
|
+
- @valbuild/mcp@0.144.2
|
|
42
|
+
- @valbuild/react@0.144.2
|
|
43
|
+
|
|
3
44
|
## 0.144.1
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
|
@@ -207,6 +207,18 @@ function draftJsonEntry(draftSource, key) {
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* The draft view's answer for one entry, or -- where it has none, a marker for
|
|
212
|
+
* an entry the Studio has not loaded -- the snapshot's: a proposal's saves over
|
|
213
|
+
* the content version the site serves, with entries filled in. The order the
|
|
214
|
+
* server renders in (`snapshotJsonEntry` in initValContent), so a draft page
|
|
215
|
+
* hydrates to what it was served rather than to the build's older entry.
|
|
216
|
+
*/
|
|
217
|
+
function draftOrSnapshotJsonEntry(draftSource, snapshotSource, key) {
|
|
218
|
+
var draft = draftJsonEntry(draftSource, key);
|
|
219
|
+
return draft.status === "unavailable" ? draftJsonEntry(snapshotSource, key) : draft;
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
211
223
|
// stable promise across renders (keyed by module path + entry key).
|
|
212
224
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -222,6 +234,7 @@ var jsonEntryPromiseCache = new Map();
|
|
|
222
234
|
* entry's lazy import thunk from the local module.
|
|
223
235
|
*/
|
|
224
236
|
function useValKeyStega(selector, key) {
|
|
237
|
+
var _valOverlayContext$sn3;
|
|
225
238
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
226
239
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
227
240
|
// A view is a pointer: everything below reads a path, a schema and a source
|
|
@@ -229,7 +242,7 @@ function useValKeyStega(selector, key) {
|
|
|
229
242
|
var valModule = core.Internal.resolveViewedModule(selector);
|
|
230
243
|
var moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
231
244
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
232
|
-
var draft =
|
|
245
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn3 = valOverlayContext.snapshot) === null || _valOverlayContext$sn3 === void 0 ? void 0 : _valOverlayContext$sn3[moduleFilePath]), key);
|
|
233
246
|
if (draft.status === "absent") {
|
|
234
247
|
// Deleted in the draft state. Falling back to the bundled entry here would
|
|
235
248
|
// render content the editor has just removed.
|
|
@@ -300,7 +313,8 @@ function useValRouteStega(selector, params) {
|
|
|
300
313
|
// other router `draftSource` is.
|
|
301
314
|
var val = useValStega(valModule);
|
|
302
315
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
303
|
-
var
|
|
316
|
+
var moduleFilePath = valModule && core.Internal.getValPath(valModule) || undefined;
|
|
317
|
+
var draftSource = useDraftModuleSource(moduleFilePath);
|
|
304
318
|
var resolvedParams = resolveParams(params);
|
|
305
319
|
// Careful: null means there was an error - undefined means no params
|
|
306
320
|
if (resolvedParams === null) {
|
|
@@ -311,12 +325,13 @@ function useValRouteStega(selector, params) {
|
|
|
311
325
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
312
326
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
313
327
|
if (routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
328
|
+
var _valOverlayContext$sn4;
|
|
314
329
|
var source = valModule && core.Internal.getSource(valModule);
|
|
315
330
|
var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
316
331
|
if (!url) {
|
|
317
332
|
return null;
|
|
318
333
|
}
|
|
319
|
-
var draft =
|
|
334
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn4 = valOverlayContext.snapshot) === null || _valOverlayContext$sn4 === void 0 ? void 0 : _valOverlayContext$sn4[moduleFilePath]), url);
|
|
320
335
|
if (draft.status === "absent") {
|
|
321
336
|
// The draft state says this route is gone — see useValKeyStega.
|
|
322
337
|
return null;
|
|
@@ -207,6 +207,18 @@ function draftJsonEntry(draftSource, key) {
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* The draft view's answer for one entry, or -- where it has none, a marker for
|
|
212
|
+
* an entry the Studio has not loaded -- the snapshot's: a proposal's saves over
|
|
213
|
+
* the content version the site serves, with entries filled in. The order the
|
|
214
|
+
* server renders in (`snapshotJsonEntry` in initValContent), so a draft page
|
|
215
|
+
* hydrates to what it was served rather than to the build's older entry.
|
|
216
|
+
*/
|
|
217
|
+
function draftOrSnapshotJsonEntry(draftSource, snapshotSource, key) {
|
|
218
|
+
var draft = draftJsonEntry(draftSource, key);
|
|
219
|
+
return draft.status === "unavailable" ? draftJsonEntry(snapshotSource, key) : draft;
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
211
223
|
// stable promise across renders (keyed by module path + entry key).
|
|
212
224
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -222,6 +234,7 @@ var jsonEntryPromiseCache = new Map();
|
|
|
222
234
|
* entry's lazy import thunk from the local module.
|
|
223
235
|
*/
|
|
224
236
|
function useValKeyStega(selector, key) {
|
|
237
|
+
var _valOverlayContext$sn3;
|
|
225
238
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
226
239
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
227
240
|
// A view is a pointer: everything below reads a path, a schema and a source
|
|
@@ -229,7 +242,7 @@ function useValKeyStega(selector, key) {
|
|
|
229
242
|
var valModule = core.Internal.resolveViewedModule(selector);
|
|
230
243
|
var moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
231
244
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
232
|
-
var draft =
|
|
245
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn3 = valOverlayContext.snapshot) === null || _valOverlayContext$sn3 === void 0 ? void 0 : _valOverlayContext$sn3[moduleFilePath]), key);
|
|
233
246
|
if (draft.status === "absent") {
|
|
234
247
|
// Deleted in the draft state. Falling back to the bundled entry here would
|
|
235
248
|
// render content the editor has just removed.
|
|
@@ -300,7 +313,8 @@ function useValRouteStega(selector, params) {
|
|
|
300
313
|
// other router `draftSource` is.
|
|
301
314
|
var val = useValStega(valModule);
|
|
302
315
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
303
|
-
var
|
|
316
|
+
var moduleFilePath = valModule && core.Internal.getValPath(valModule) || undefined;
|
|
317
|
+
var draftSource = useDraftModuleSource(moduleFilePath);
|
|
304
318
|
var resolvedParams = resolveParams(params);
|
|
305
319
|
// Careful: null means there was an error - undefined means no params
|
|
306
320
|
if (resolvedParams === null) {
|
|
@@ -311,12 +325,13 @@ function useValRouteStega(selector, params) {
|
|
|
311
325
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
312
326
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
313
327
|
if (routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
328
|
+
var _valOverlayContext$sn4;
|
|
314
329
|
var source = valModule && core.Internal.getSource(valModule);
|
|
315
330
|
var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
316
331
|
if (!url) {
|
|
317
332
|
return null;
|
|
318
333
|
}
|
|
319
|
-
var draft =
|
|
334
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn4 = valOverlayContext.snapshot) === null || _valOverlayContext$sn4 === void 0 ? void 0 : _valOverlayContext$sn4[moduleFilePath]), url);
|
|
320
335
|
if (draft.status === "absent") {
|
|
321
336
|
// The draft state says this route is gone — see useValKeyStega.
|
|
322
337
|
return null;
|
|
@@ -199,6 +199,18 @@ function draftJsonEntry(draftSource, key) {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* The draft view's answer for one entry, or -- where it has none, a marker for
|
|
204
|
+
* an entry the Studio has not loaded -- the snapshot's: a proposal's saves over
|
|
205
|
+
* the content version the site serves, with entries filled in. The order the
|
|
206
|
+
* server renders in (`snapshotJsonEntry` in initValContent), so a draft page
|
|
207
|
+
* hydrates to what it was served rather than to the build's older entry.
|
|
208
|
+
*/
|
|
209
|
+
function draftOrSnapshotJsonEntry(draftSource, snapshotSource, key) {
|
|
210
|
+
var draft = draftJsonEntry(draftSource, key);
|
|
211
|
+
return draft.status === "unavailable" ? draftJsonEntry(snapshotSource, key) : draft;
|
|
212
|
+
}
|
|
213
|
+
|
|
202
214
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
203
215
|
// stable promise across renders (keyed by module path + entry key).
|
|
204
216
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -214,6 +226,7 @@ var jsonEntryPromiseCache = new Map();
|
|
|
214
226
|
* entry's lazy import thunk from the local module.
|
|
215
227
|
*/
|
|
216
228
|
function useValKeyStega(selector, key) {
|
|
229
|
+
var _valOverlayContext$sn3;
|
|
217
230
|
var valOverlayContext = useValOverlayContext();
|
|
218
231
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
219
232
|
// A view is a pointer: everything below reads a path, a schema and a source
|
|
@@ -221,7 +234,7 @@ function useValKeyStega(selector, key) {
|
|
|
221
234
|
var valModule = Internal.resolveViewedModule(selector);
|
|
222
235
|
var moduleFilePath = valModule && Internal.getValPath(valModule);
|
|
223
236
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
224
|
-
var draft =
|
|
237
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn3 = valOverlayContext.snapshot) === null || _valOverlayContext$sn3 === void 0 ? void 0 : _valOverlayContext$sn3[moduleFilePath]), key);
|
|
225
238
|
if (draft.status === "absent") {
|
|
226
239
|
// Deleted in the draft state. Falling back to the bundled entry here would
|
|
227
240
|
// render content the editor has just removed.
|
|
@@ -292,7 +305,8 @@ function useValRouteStega(selector, params) {
|
|
|
292
305
|
// other router `draftSource` is.
|
|
293
306
|
var val = useValStega(valModule);
|
|
294
307
|
var encodes = useEncodesEditTags(valOverlayContext);
|
|
295
|
-
var
|
|
308
|
+
var moduleFilePath = valModule && Internal.getValPath(valModule) || undefined;
|
|
309
|
+
var draftSource = useDraftModuleSource(moduleFilePath);
|
|
296
310
|
var resolvedParams = resolveParams(params);
|
|
297
311
|
// Careful: null means there was an error - undefined means no params
|
|
298
312
|
if (resolvedParams === null) {
|
|
@@ -303,12 +317,13 @@ function useValRouteStega(selector, params) {
|
|
|
303
317
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
304
318
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
305
319
|
if (isJsonValuesRecordSchema(schema)) {
|
|
320
|
+
var _valOverlayContext$sn4;
|
|
306
321
|
var source = valModule && Internal.getSource(valModule);
|
|
307
322
|
var url = getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
308
323
|
if (!url) {
|
|
309
324
|
return null;
|
|
310
325
|
}
|
|
311
|
-
var draft =
|
|
326
|
+
var draft = draftOrSnapshotJsonEntry(draftSource, moduleFilePath && ((_valOverlayContext$sn4 = valOverlayContext.snapshot) === null || _valOverlayContext$sn4 === void 0 ? void 0 : _valOverlayContext$sn4[moduleFilePath]), url);
|
|
312
327
|
if (draft.status === "absent") {
|
|
313
328
|
// The draft state says this route is gone — see useValKeyStega.
|
|
314
329
|
return null;
|
|
@@ -26,6 +26,16 @@ export type ValDraft = {
|
|
|
26
26
|
* looking at the proposal too. A draft, when there is one, applies on top.
|
|
27
27
|
*/
|
|
28
28
|
snapshot?: Record<ModuleFilePath, Json>;
|
|
29
|
+
/**
|
|
30
|
+
* The Source the server's draft starts from where it is not the bundle's: a
|
|
31
|
+
* content version -- content published without a build -- with a
|
|
32
|
+
* proposal's saves over it, as stored (`.jsonValues()` markers and all).
|
|
33
|
+
* The Studio's overlay starts from it, by `window.__VAL_BASE__`: after a
|
|
34
|
+
* content-only publish the bundle still holds the text from before it, and
|
|
35
|
+
* a draft page took that text back whenever the overlay's bundle reached
|
|
36
|
+
* it first. Sent with a draft only -- the overlay runs in draft mode alone.
|
|
37
|
+
*/
|
|
38
|
+
base?: Record<ModuleFilePath, Json>;
|
|
29
39
|
/**
|
|
30
40
|
* `false` when no draft was read -- draft mode is off -- and this carries
|
|
31
41
|
* only the {@link snapshot}. Absent: a draft, as it always was.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ValModules } from "@valbuild/core";
|
|
1
|
+
import type { Json, ModuleFilePath, ValModules } from "@valbuild/core";
|
|
2
2
|
declare global {
|
|
3
3
|
interface Window {
|
|
4
4
|
__VAL_MODULES__?: ValModules;
|
|
5
|
+
/** The Studio overlay's base where it is not the bundle's: `ValDraft.base`. */
|
|
6
|
+
__VAL_BASE__?: Record<ModuleFilePath, Json>;
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
@@ -63,6 +63,32 @@ 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
|
+
* What the server's own draft starts from, where it is not the bundle's: the
|
|
74
|
+
* layers `ValOpsHttp` puts over it (`siteSnapshotSources`, then
|
|
75
|
+
* `snapshotSources`), in the same form, so the Studio that starts from it
|
|
76
|
+
* holds the base the server reports. See `ValDraft.base`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function draftBase(http: Pick<ValHttpMode, "proposal" | "contentVersion"> | undefined): Snapshot | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Where an isolate says which content version it applied, for the platform
|
|
81
|
+
* serving it to read back after a render (valbuild/home: the loader answers it
|
|
82
|
+
* as a header). A Val that predates content versions never sets it, which is
|
|
83
|
+
* how the platform tells that an app cannot be served a version its build does
|
|
84
|
+
* not bundle -- an unknown option is otherwise ignored, silently.
|
|
85
|
+
*/
|
|
86
|
+
export declare const CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
|
|
87
|
+
/**
|
|
88
|
+
* Name the content version this isolate renders, when it renders one -- at a
|
|
89
|
+
* proposal's address too, where it is under the proposal's saves.
|
|
90
|
+
*/
|
|
91
|
+
export declare function markContentApplied(http: Pick<ValHttpMode, "proposal" | "contentVersion"> | undefined): void;
|
|
66
92
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
67
93
|
export type DraftValServer = {
|
|
68
94
|
"/sources/~": ValServer["/sources/~"];
|
|
@@ -88,7 +114,9 @@ export declare const initFetchValDraft: (valServerPromise: Promise<DraftValServe
|
|
|
88
114
|
} | undefined;
|
|
89
115
|
}>, getDraftSourcesScope: GetDraftSourcesScope,
|
|
90
116
|
/** A proposal's saved Source; see `ValDraft.snapshot`. */
|
|
91
|
-
snapshot?: Snapshot
|
|
117
|
+
snapshot?: Snapshot,
|
|
118
|
+
/** What the server's draft starts from; see `ValDraft.base`. */
|
|
119
|
+
base?: Snapshot) => () => Promise<ValDraft | null>;
|
|
92
120
|
declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<RouteReaderValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
93
121
|
get(name: string): string | null;
|
|
94
122
|
}>, 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-
|
|
5
|
+
var version = require('./version-c5862191.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');
|
|
@@ -1005,6 +1005,16 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
|
|
|
1005
1005
|
*/
|
|
1006
1006
|
var hasDraft = initialDraft !== null && initialDraft.draftMode !== false;
|
|
1007
1007
|
var snapshot = initialDraft === null || initialDraft === void 0 ? void 0 : initialDraft.snapshot;
|
|
1008
|
+
/*
|
|
1009
|
+
* The base the Studio's overlay must start from, where it is not the
|
|
1010
|
+
* bundle's (`ValDraft.base`): set while rendering, not in an effect, so it
|
|
1011
|
+
* is in place before the overlay -- loaded after this page hydrates -- takes
|
|
1012
|
+
* its modules in. The same value every render, from a ref, so writing it
|
|
1013
|
+
* again is harmless.
|
|
1014
|
+
*/
|
|
1015
|
+
if (typeof window !== "undefined") {
|
|
1016
|
+
window.__VAL_BASE__ = hasDraft ? initialDraft.base : undefined;
|
|
1017
|
+
}
|
|
1008
1018
|
// TODO: move below into react package
|
|
1009
1019
|
var valStore = React__default["default"].useMemo(function () {
|
|
1010
1020
|
var store = new ValOverlayContext.ValExternalStore();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('./version-
|
|
5
|
+
var version = require('./version-efacbb53.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');
|
|
@@ -1005,6 +1005,16 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
|
|
|
1005
1005
|
*/
|
|
1006
1006
|
var hasDraft = initialDraft !== null && initialDraft.draftMode !== false;
|
|
1007
1007
|
var snapshot = initialDraft === null || initialDraft === void 0 ? void 0 : initialDraft.snapshot;
|
|
1008
|
+
/*
|
|
1009
|
+
* The base the Studio's overlay must start from, where it is not the
|
|
1010
|
+
* bundle's (`ValDraft.base`): set while rendering, not in an effect, so it
|
|
1011
|
+
* is in place before the overlay -- loaded after this page hydrates -- takes
|
|
1012
|
+
* its modules in. The same value every render, from a ref, so writing it
|
|
1013
|
+
* again is harmless.
|
|
1014
|
+
*/
|
|
1015
|
+
if (typeof window !== "undefined") {
|
|
1016
|
+
window.__VAL_BASE__ = hasDraft ? initialDraft.base : undefined;
|
|
1017
|
+
}
|
|
1008
1018
|
// TODO: move below into react package
|
|
1009
1019
|
var valStore = React__default["default"].useMemo(function () {
|
|
1010
1020
|
var store = new ValOverlayContext.ValExternalStore();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-e43bf6e6.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';
|
|
@@ -981,6 +981,16 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
|
|
|
981
981
|
*/
|
|
982
982
|
var hasDraft = initialDraft !== null && initialDraft.draftMode !== false;
|
|
983
983
|
var snapshot = initialDraft === null || initialDraft === void 0 ? void 0 : initialDraft.snapshot;
|
|
984
|
+
/*
|
|
985
|
+
* The base the Studio's overlay must start from, where it is not the
|
|
986
|
+
* bundle's (`ValDraft.base`): set while rendering, not in an effect, so it
|
|
987
|
+
* is in place before the overlay -- loaded after this page hydrates -- takes
|
|
988
|
+
* its modules in. The same value every render, from a ref, so writing it
|
|
989
|
+
* again is harmless.
|
|
990
|
+
*/
|
|
991
|
+
if (typeof window !== "undefined") {
|
|
992
|
+
window.__VAL_BASE__ = hasDraft ? initialDraft.base : undefined;
|
|
993
|
+
}
|
|
984
994
|
// TODO: move below into react package
|
|
985
995
|
var valStore = React.useMemo(function () {
|
|
986
996
|
var store = new ValExternalStore();
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"tanstack-router",
|
|
15
15
|
"react"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.144.
|
|
17
|
+
"version": "0.144.3",
|
|
18
18
|
"main": "dist/valbuild-tanstack.cjs.js",
|
|
19
19
|
"module": "dist/valbuild-tanstack.esm.js",
|
|
20
20
|
"exports": {
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@valbuild/core": "0.144.0",
|
|
46
|
-
"@valbuild/language-server": "0.144.
|
|
47
|
-
"@valbuild/mcp": "0.144.
|
|
48
|
-
"@valbuild/react": "0.144.
|
|
49
|
-
"@valbuild/
|
|
50
|
-
"@valbuild/shared": "0.144.
|
|
51
|
-
"@valbuild/
|
|
46
|
+
"@valbuild/language-server": "0.144.3",
|
|
47
|
+
"@valbuild/mcp": "0.144.3",
|
|
48
|
+
"@valbuild/react": "0.144.3",
|
|
49
|
+
"@valbuild/server": "0.144.3",
|
|
50
|
+
"@valbuild/shared": "0.144.2",
|
|
51
|
+
"@valbuild/ui": "0.144.3"
|
|
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-
|
|
5
|
+
var version = require('../../dist/version-c5862191.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,47 @@ 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
|
+
* What the server's own draft starts from, where it is not the bundle's: the
|
|
647
|
+
* layers `ValOpsHttp` puts over it (`siteSnapshotSources`, then
|
|
648
|
+
* `snapshotSources`), in the same form, so the Studio that starts from it
|
|
649
|
+
* holds the base the server reports. See `ValDraft.base`.
|
|
650
|
+
*/
|
|
651
|
+
function draftBase(http) {
|
|
652
|
+
var layered = server.layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
|
|
653
|
+
return layered !== undefined ? server.proposalSnapshot(layered) : undefined;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Where an isolate says which content version it applied, for the platform
|
|
658
|
+
* serving it to read back after a render (valbuild/home: the loader answers it
|
|
659
|
+
* as a header). A Val that predates content versions never sets it, which is
|
|
660
|
+
* how the platform tells that an app cannot be served a version its build does
|
|
661
|
+
* not bundle -- an unknown option is otherwise ignored, silently.
|
|
662
|
+
*/
|
|
663
|
+
var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Name the content version this isolate renders, when it renders one -- at a
|
|
667
|
+
* proposal's address too, where it is under the proposal's saves.
|
|
668
|
+
*/
|
|
669
|
+
function markContentApplied(http) {
|
|
670
|
+
if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
|
|
674
|
+
}
|
|
675
|
+
|
|
635
676
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
636
677
|
|
|
637
678
|
/**
|
|
@@ -646,7 +687,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
646
687
|
* a draft page was rendered as the published site and only then replaced, in
|
|
647
688
|
* the browser, by what the editor holds -- old text first on every load.
|
|
648
689
|
*/
|
|
649
|
-
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot) {
|
|
690
|
+
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot, base) {
|
|
650
691
|
return /*#__PURE__*/version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3() {
|
|
651
692
|
var onlySnapshot, _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
652
693
|
return version._regenerator().w(function (_context3) {
|
|
@@ -733,10 +774,12 @@ var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled,
|
|
|
733
774
|
_context3.n = 11;
|
|
734
775
|
break;
|
|
735
776
|
case 15:
|
|
736
|
-
return _context3.a(2, createForOfIteratorHelper._objectSpread2({
|
|
777
|
+
return _context3.a(2, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
|
|
737
778
|
sources: sources
|
|
738
779
|
}, snapshot !== undefined ? {
|
|
739
780
|
snapshot: snapshot
|
|
781
|
+
} : {}), base !== undefined ? {
|
|
782
|
+
base: base
|
|
740
783
|
} : {}));
|
|
741
784
|
case 16:
|
|
742
785
|
_context3.p = 16;
|
|
@@ -1515,7 +1558,7 @@ function _requestCookies() {
|
|
|
1515
1558
|
return _requestCookies.apply(this, arguments);
|
|
1516
1559
|
}
|
|
1517
1560
|
function initValContent(config, valModules, opts) {
|
|
1518
|
-
var _opts$
|
|
1561
|
+
var _opts$draftMode;
|
|
1519
1562
|
var coreVersion = core.Internal.VERSION.core;
|
|
1520
1563
|
if (!coreVersion) {
|
|
1521
1564
|
throw new Error("Could not get @valbuild/core package version");
|
|
@@ -1525,7 +1568,9 @@ function initValContent(config, valModules, opts) {
|
|
|
1525
1568
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
1526
1569
|
}
|
|
1527
1570
|
var draftSourcesScope = createTanStackRequestScope();
|
|
1528
|
-
var snapshot = (opts === null || opts === void 0
|
|
1571
|
+
var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1572
|
+
var base = draftBase(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1573
|
+
markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1529
1574
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
1530
1575
|
var isEnabled = function isEnabled() {
|
|
1531
1576
|
return draftMode.isEnabled();
|
|
@@ -1558,7 +1603,7 @@ function initValContent(config, valModules, opts) {
|
|
|
1558
1603
|
fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
|
|
1559
1604
|
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1560
1605
|
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1561
|
-
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
|
|
1606
|
+
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot, base)
|
|
1562
1607
|
};
|
|
1563
1608
|
}
|
|
1564
1609
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('../../dist/version-
|
|
5
|
+
var version = require('../../dist/version-efacbb53.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,47 @@ 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
|
+
* What the server's own draft starts from, where it is not the bundle's: the
|
|
647
|
+
* layers `ValOpsHttp` puts over it (`siteSnapshotSources`, then
|
|
648
|
+
* `snapshotSources`), in the same form, so the Studio that starts from it
|
|
649
|
+
* holds the base the server reports. See `ValDraft.base`.
|
|
650
|
+
*/
|
|
651
|
+
function draftBase(http) {
|
|
652
|
+
var layered = server.layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
|
|
653
|
+
return layered !== undefined ? server.proposalSnapshot(layered) : undefined;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Where an isolate says which content version it applied, for the platform
|
|
658
|
+
* serving it to read back after a render (valbuild/home: the loader answers it
|
|
659
|
+
* as a header). A Val that predates content versions never sets it, which is
|
|
660
|
+
* how the platform tells that an app cannot be served a version its build does
|
|
661
|
+
* not bundle -- an unknown option is otherwise ignored, silently.
|
|
662
|
+
*/
|
|
663
|
+
var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Name the content version this isolate renders, when it renders one -- at a
|
|
667
|
+
* proposal's address too, where it is under the proposal's saves.
|
|
668
|
+
*/
|
|
669
|
+
function markContentApplied(http) {
|
|
670
|
+
if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
|
|
674
|
+
}
|
|
675
|
+
|
|
635
676
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
636
677
|
|
|
637
678
|
/**
|
|
@@ -646,7 +687,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
646
687
|
* a draft page was rendered as the published site and only then replaced, in
|
|
647
688
|
* the browser, by what the editor holds -- old text first on every load.
|
|
648
689
|
*/
|
|
649
|
-
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot) {
|
|
690
|
+
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot, base) {
|
|
650
691
|
return /*#__PURE__*/version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3() {
|
|
651
692
|
var onlySnapshot, _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
652
693
|
return version._regenerator().w(function (_context3) {
|
|
@@ -733,10 +774,12 @@ var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled,
|
|
|
733
774
|
_context3.n = 11;
|
|
734
775
|
break;
|
|
735
776
|
case 15:
|
|
736
|
-
return _context3.a(2, createForOfIteratorHelper._objectSpread2({
|
|
777
|
+
return _context3.a(2, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
|
|
737
778
|
sources: sources
|
|
738
779
|
}, snapshot !== undefined ? {
|
|
739
780
|
snapshot: snapshot
|
|
781
|
+
} : {}), base !== undefined ? {
|
|
782
|
+
base: base
|
|
740
783
|
} : {}));
|
|
741
784
|
case 16:
|
|
742
785
|
_context3.p = 16;
|
|
@@ -1515,7 +1558,7 @@ function _requestCookies() {
|
|
|
1515
1558
|
return _requestCookies.apply(this, arguments);
|
|
1516
1559
|
}
|
|
1517
1560
|
function initValContent(config, valModules, opts) {
|
|
1518
|
-
var _opts$
|
|
1561
|
+
var _opts$draftMode;
|
|
1519
1562
|
var coreVersion = core.Internal.VERSION.core;
|
|
1520
1563
|
if (!coreVersion) {
|
|
1521
1564
|
throw new Error("Could not get @valbuild/core package version");
|
|
@@ -1525,7 +1568,9 @@ function initValContent(config, valModules, opts) {
|
|
|
1525
1568
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
1526
1569
|
}
|
|
1527
1570
|
var draftSourcesScope = createTanStackRequestScope();
|
|
1528
|
-
var snapshot = (opts === null || opts === void 0
|
|
1571
|
+
var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1572
|
+
var base = draftBase(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1573
|
+
markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1529
1574
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
1530
1575
|
var isEnabled = function isEnabled() {
|
|
1531
1576
|
return draftMode.isEnabled();
|
|
@@ -1558,7 +1603,7 @@ function initValContent(config, valModules, opts) {
|
|
|
1558
1603
|
fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
|
|
1559
1604
|
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1560
1605
|
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1561
|
-
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
|
|
1606
|
+
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot, base)
|
|
1562
1607
|
};
|
|
1563
1608
|
}
|
|
1564
1609
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-e43bf6e6.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, proposalSnapshotForReaders } from '@valbuild/server';
|
|
4
|
+
import { createValApiRouter, createValServer, layeredSnapshot, proposalSnapshotForReaders, proposalSnapshot } 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,47 @@ 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
|
+
* What the server's own draft starts from, where it is not the bundle's: the
|
|
626
|
+
* layers `ValOpsHttp` puts over it (`siteSnapshotSources`, then
|
|
627
|
+
* `snapshotSources`), in the same form, so the Studio that starts from it
|
|
628
|
+
* holds the base the server reports. See `ValDraft.base`.
|
|
629
|
+
*/
|
|
630
|
+
function draftBase(http) {
|
|
631
|
+
var layered = layeredSnapshot(http === null || http === void 0 ? void 0 : http.proposal, http === null || http === void 0 ? void 0 : http.contentVersion);
|
|
632
|
+
return layered !== undefined ? proposalSnapshot(layered) : undefined;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Where an isolate says which content version it applied, for the platform
|
|
637
|
+
* serving it to read back after a render (valbuild/home: the loader answers it
|
|
638
|
+
* as a header). A Val that predates content versions never sets it, which is
|
|
639
|
+
* how the platform tells that an app cannot be served a version its build does
|
|
640
|
+
* not bundle -- an unknown option is otherwise ignored, silently.
|
|
641
|
+
*/
|
|
642
|
+
var CONTENT_APPLIED_GLOBAL = "__VAL_CONTENT_APPLIED";
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Name the content version this isolate renders, when it renders one -- at a
|
|
646
|
+
* proposal's address too, where it is under the proposal's saves.
|
|
647
|
+
*/
|
|
648
|
+
function markContentApplied(http) {
|
|
649
|
+
if ((http === null || http === void 0 ? void 0 : http.contentVersion) === undefined) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
Reflect.set(globalThis, CONTENT_APPLIED_GLOBAL, http.contentVersion.id);
|
|
653
|
+
}
|
|
654
|
+
|
|
614
655
|
/** What `fetchValDraft` reads: the tree, the entries, and the patches' ops. */
|
|
615
656
|
|
|
616
657
|
/**
|
|
@@ -625,7 +666,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
625
666
|
* a draft page was rendered as the published site and only then replaced, in
|
|
626
667
|
* the browser, by what the editor holds -- old text first on every load.
|
|
627
668
|
*/
|
|
628
|
-
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot) {
|
|
669
|
+
var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled, getCookies, getDraftSourcesScope, snapshot, base) {
|
|
629
670
|
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
630
671
|
var onlySnapshot, _yield$getCookies$get, sessionCookie, modules, sources, _i, _Object$entries, _Object$entries$_i, path, module, source, _t6, _t7, _t8, _t9, _t0;
|
|
631
672
|
return _regenerator().w(function (_context3) {
|
|
@@ -712,10 +753,12 @@ var initFetchValDraft = function initFetchValDraft(valServerPromise, isEnabled,
|
|
|
712
753
|
_context3.n = 11;
|
|
713
754
|
break;
|
|
714
755
|
case 15:
|
|
715
|
-
return _context3.a(2, _objectSpread2({
|
|
756
|
+
return _context3.a(2, _objectSpread2(_objectSpread2({
|
|
716
757
|
sources: sources
|
|
717
758
|
}, snapshot !== undefined ? {
|
|
718
759
|
snapshot: snapshot
|
|
760
|
+
} : {}), base !== undefined ? {
|
|
761
|
+
base: base
|
|
719
762
|
} : {}));
|
|
720
763
|
case 16:
|
|
721
764
|
_context3.p = 16;
|
|
@@ -1494,7 +1537,7 @@ function _requestCookies() {
|
|
|
1494
1537
|
return _requestCookies.apply(this, arguments);
|
|
1495
1538
|
}
|
|
1496
1539
|
function initValContent(config, valModules, opts) {
|
|
1497
|
-
var _opts$
|
|
1540
|
+
var _opts$draftMode;
|
|
1498
1541
|
var coreVersion = Internal.VERSION.core;
|
|
1499
1542
|
if (!coreVersion) {
|
|
1500
1543
|
throw new Error("Could not get @valbuild/core package version");
|
|
@@ -1504,7 +1547,9 @@ function initValContent(config, valModules, opts) {
|
|
|
1504
1547
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
1505
1548
|
}
|
|
1506
1549
|
var draftSourcesScope = createTanStackRequestScope();
|
|
1507
|
-
var snapshot = (opts === null || opts === void 0
|
|
1550
|
+
var snapshot = snapshotForReaders(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1551
|
+
var base = draftBase(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1552
|
+
markContentApplied(opts === null || opts === void 0 ? void 0 : opts.http);
|
|
1508
1553
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
1509
1554
|
var isEnabled = function isEnabled() {
|
|
1510
1555
|
return draftMode.isEnabled();
|
|
@@ -1537,7 +1582,7 @@ function initValContent(config, valModules, opts) {
|
|
|
1537
1582
|
fetchValKeyStega: initFetchValKeyStega(valServerPromise, isEnabled, requestCookies, snapshot),
|
|
1538
1583
|
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1539
1584
|
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, requestHeaders, requestCookies, draftSourcesScope, snapshot),
|
|
1540
|
-
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot)
|
|
1585
|
+
fetchValDraft: initFetchValDraft(valServerPromise, isEnabled, requestCookies, draftSourcesScope, snapshot, base)
|
|
1541
1586
|
};
|
|
1542
1587
|
}
|
|
1543
1588
|
|