@valbuild/next 0.150.23 → 0.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -0
- package/README.md +82 -1
- package/client/dist/valbuild-next-client.cjs.dev.js +123 -256
- package/client/dist/valbuild-next-client.cjs.prod.js +123 -256
- package/client/dist/valbuild-next-client.esm.js +122 -255
- package/dist/{ValApp-a88a9ded.esm.js → ValApp-69cd599c.esm.js} +3 -3
- package/dist/{ValApp-c718d1a6.cjs.dev.js → ValApp-826dca6c.cjs.dev.js} +3 -3
- package/dist/ValApp-866089f6.cjs.js +7 -0
- package/dist/{ValApp-6c3da222.cjs.prod.js → ValApp-866089f6.cjs.prod.js} +3 -3
- package/dist/{ValCanvasBridge-9d221d32.cjs.dev.js → ValCanvasBridge-4b81f653.cjs.dev.js} +46 -13
- package/dist/ValCanvasBridge-6f568f1d.cjs.js +7 -0
- package/dist/{ValCanvasBridge-134c3ae1.cjs.prod.js → ValCanvasBridge-6f568f1d.cjs.prod.js} +46 -13
- package/dist/{ValCanvasBridge-4a5ef73c.esm.js → ValCanvasBridge-badc186b.esm.js} +46 -13
- package/dist/ValNextProvider-41d622a7.cjs.js +7 -0
- package/dist/{ValNextProvider-35d0b521.cjs.prod.js → ValNextProvider-41d622a7.cjs.prod.js} +124 -234
- package/dist/{ValNextProvider-a85a1d33.cjs.dev.js → ValNextProvider-4b9bcfc0.cjs.dev.js} +124 -234
- package/dist/{ValNextProvider-df6f351e.esm.js → ValNextProvider-745ed99e.esm.js} +124 -234
- package/dist/ValOverlayContext-0c29b6a7.cjs.dev.js +51 -0
- package/dist/ValOverlayContext-0f51d111.cjs.js +7 -0
- package/dist/ValOverlayContext-0f51d111.cjs.prod.js +51 -0
- package/dist/ValOverlayContext-178db68e.esm.js +37 -0
- package/dist/ValVideo-02f43a7c.cjs.js +7 -0
- package/dist/{ValVideo-dcd2b9f8.cjs.prod.js → ValVideo-02f43a7c.cjs.prod.js} +1 -2
- package/dist/{ValVideo-6e410ad8.cjs.dev.js → ValVideo-15e5c4fa.cjs.dev.js} +1 -2
- package/dist/{ValVideo-d377f06e.esm.js → ValVideo-8acf31b6.esm.js} +1 -2
- package/dist/{createForOfIteratorHelper-d4afcad8.cjs.prod.js → createForOfIteratorHelper-8459fbc7.cjs.prod.js} +1 -1
- package/dist/{createForOfIteratorHelper-5758a730.esm.js → createForOfIteratorHelper-9209e9dd.esm.js} +1 -1
- package/dist/{createForOfIteratorHelper-0445603c.cjs.dev.js → createForOfIteratorHelper-9c6aa3c7.cjs.dev.js} +1 -1
- package/dist/declarations/src/ValProvider.d.ts +1 -0
- package/dist/declarations/src/client/initValClient.d.ts +25 -3
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +1 -0
- package/dist/declarations/src/rsc/index.d.ts +1 -0
- package/dist/declarations/src/rsc/initValRsc.d.ts +56 -118
- package/dist/{fallbackColors-149dfbc9.esm.js → fallbackColors-0d915c59.esm.js} +1 -1
- package/dist/{fallbackColors-080c1bbc.cjs.dev.js → fallbackColors-38f01ad2.cjs.dev.js} +1 -1
- package/dist/{fallbackColors-e1d73b36.cjs.prod.js → fallbackColors-d9a7b81e.cjs.prod.js} +1 -1
- package/dist/{objectSpread2-13f847a9.cjs.prod.js → objectSpread2-469273e9.cjs.prod.js} +25 -2
- package/dist/{objectSpread2-58024783.cjs.dev.js → objectSpread2-58726b14.cjs.dev.js} +25 -2
- package/dist/{objectSpread2-60d1bd93.esm.js → objectSpread2-f1f0d77a.esm.js} +24 -1
- package/dist/{routeFromVal-64cba2a6.esm.js → routeFromVal-80976677.esm.js} +5 -155
- package/dist/{routeFromVal-4df1157a.cjs.dev.js → routeFromVal-a1e0a8be.cjs.dev.js} +3 -159
- package/dist/{routeFromVal-812be6ea.cjs.prod.js → routeFromVal-c4dace91.cjs.prod.js} +3 -159
- package/dist/{slicedToArray-ce613de6.cjs.prod.js → slicedToArray-0fc63719.cjs.prod.js} +1 -1
- package/dist/{slicedToArray-aa291011.esm.js → slicedToArray-5ff32315.esm.js} +1 -1
- package/dist/{slicedToArray-44036a76.cjs.dev.js → slicedToArray-ed812733.cjs.dev.js} +1 -1
- package/dist/{unsupportedIterableToArray-c8ab77c9.cjs.dev.js → unsupportedIterableToArray-1aadf9fb.cjs.prod.js} +1 -0
- package/dist/{unsupportedIterableToArray-0d2087a2.cjs.prod.js → unsupportedIterableToArray-20a9209f.cjs.dev.js} +1 -0
- package/dist/{unsupportedIterableToArray-5baabfdc.esm.js → unsupportedIterableToArray-f57eb659.esm.js} +1 -1
- package/dist/useHydrated-8e90c7fa.cjs.js +7 -0
- package/dist/useHydrated-8e90c7fa.cjs.prod.js +34 -0
- package/dist/useHydrated-afcdbb66.esm.js +26 -0
- package/dist/useHydrated-ff733777.cjs.dev.js +34 -0
- package/dist/valbuild-next.cjs.dev.js +7 -8
- package/dist/valbuild-next.cjs.prod.js +7 -8
- package/dist/valbuild-next.esm.js +7 -8
- package/dist/{version-b292025f.cjs.dev.js → version-284ab1bc.cjs.prod.js} +1 -1
- package/dist/{version-8bac9fbe.esm.js → version-41472ee7.esm.js} +1 -1
- package/dist/{version-bfb6bbc0.cjs.prod.js → version-bab8ec07.cjs.dev.js} +1 -1
- package/package.json +8 -8
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +243 -872
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +243 -872
- package/rsc/dist/valbuild-next-rsc.esm.js +243 -872
- package/server/dist/valbuild-next-server.cjs.dev.js +4 -5
- package/server/dist/valbuild-next-server.cjs.prod.js +4 -5
- package/server/dist/valbuild-next-server.esm.js +4 -5
- package/dist/ValApp-6c3da222.cjs.js +0 -7
- package/dist/ValCanvasBridge-134c3ae1.cjs.js +0 -7
- package/dist/ValNextProvider-35d0b521.cjs.js +0 -7
- package/dist/ValOverlayContext-1a45e03d.esm.js +0 -290
- package/dist/ValOverlayContext-262899b3.cjs.dev.js +0 -301
- package/dist/ValOverlayContext-405ca70c.cjs.js +0 -7
- package/dist/ValOverlayContext-405ca70c.cjs.prod.js +0 -301
- package/dist/ValVideo-dcd2b9f8.cjs.js +0 -7
- package/dist/defineProperty-8951f469.cjs.prod.js +0 -29
- package/dist/defineProperty-cca5affa.esm.js +0 -26
- package/dist/defineProperty-f90345d7.cjs.dev.js +0 -29
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var objectSpread2 = require('./objectSpread2-
|
|
6
|
+
var objectSpread2 = require('./objectSpread2-58726b14.cjs.dev.js');
|
|
7
7
|
var objectWithoutProperties = require('./objectWithoutProperties-8f93848f.cjs.dev.js');
|
|
8
8
|
var core = require('@valbuild/core');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var stega = require('@valbuild/react/stega');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
13
12
|
|
|
14
13
|
var _excluded = ["src", "hls", "disableHotspot", "disableCaptions", "style", "width", "height"];
|
|
15
14
|
/**
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { _ as _objectSpread2 } from './objectSpread2-
|
|
2
|
+
import { _ as _objectSpread2 } from './objectSpread2-f1f0d77a.esm.js';
|
|
3
3
|
import { _ as _objectWithoutProperties, d as decodeValPathsOfString } from './objectWithoutProperties-2daec22c.esm.js';
|
|
4
4
|
import { Internal } from '@valbuild/core';
|
|
5
5
|
import { useRef, useEffect } from 'react';
|
|
6
6
|
import { raw } from '@valbuild/react/stega';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import './defineProperty-cca5affa.esm.js';
|
|
9
8
|
|
|
10
9
|
var _excluded = ["src", "hls", "disableHotspot", "disableCaptions", "style", "width", "height"];
|
|
11
10
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var unsupportedIterableToArray = require('./unsupportedIterableToArray-
|
|
3
|
+
var unsupportedIterableToArray = require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
4
4
|
|
|
5
5
|
function _createForOfIteratorHelper(r, e) {
|
|
6
6
|
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
package/dist/{createForOfIteratorHelper-5758a730.esm.js → createForOfIteratorHelper-9209e9dd.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-
|
|
1
|
+
import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-f57eb659.esm.js';
|
|
2
2
|
|
|
3
3
|
function _createForOfIteratorHelper(r, e) {
|
|
4
4
|
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var unsupportedIterableToArray = require('./unsupportedIterableToArray-
|
|
3
|
+
var unsupportedIterableToArray = require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
4
4
|
|
|
5
5
|
function _createForOfIteratorHelper(r, e) {
|
|
6
6
|
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { type ResolvableModule, SelectorSource } from "@valbuild/core";
|
|
1
|
+
import { type ResolvableModule, SelectorSource, type ValModule } from "@valbuild/core";
|
|
2
2
|
import { type JsonEntryContentOf, type Resolvable, type ResolvedVal, type RouteValueOf } from "@valbuild/react/stega";
|
|
3
|
+
import { type ReadEnv, type Resolution, type ValExternalStore } from "@valbuild/react/internal";
|
|
3
4
|
import { ValConfig } from "@valbuild/core";
|
|
5
|
+
/** What the provider tells the hooks: `ValOverlayContext`'s value. */
|
|
6
|
+
export type PageReadState = {
|
|
7
|
+
store?: ValExternalStore;
|
|
8
|
+
draftMode: boolean | null;
|
|
9
|
+
suspend: boolean;
|
|
10
|
+
draftModeReady?: Promise<void>;
|
|
11
|
+
draftSourcesSynced?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Where this page's hooks read from, in order: what the Studio sent (the
|
|
15
|
+
* overlay, which starts from the server-read draft when the page has one),
|
|
16
|
+
* then -- added by every read -- the bundle. Edit tags in draft mode, unless
|
|
17
|
+
* `encode` says otherwise (see `useEncodesEditTags`). A plain function of the
|
|
18
|
+
* provider's state, as `@valbuild/tanstack`'s is (which the scenario world
|
|
19
|
+
* reads a page with).
|
|
20
|
+
*/
|
|
21
|
+
export declare function pageReadEnv(state: PageReadState, encode?: boolean): ReadEnv;
|
|
4
22
|
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
5
23
|
export type UseValType<T extends SelectorSource> = ResolvedVal<T>;
|
|
6
24
|
declare function useValStega<T extends Resolvable>(selector: T): UseValType<T>;
|
|
@@ -11,10 +29,14 @@ declare function useValStega<T extends Resolvable>(selector: T): UseValType<T>;
|
|
|
11
29
|
* inside a `<Suspense>` boundary.
|
|
12
30
|
*
|
|
13
31
|
* In draft mode it renders the editor's unpublished content, taken from the
|
|
14
|
-
* overlay;
|
|
15
|
-
* entry's lazy import thunk from the local module.
|
|
32
|
+
* overlay; an entry the draft deleted is `undefined`, never the bundled one.
|
|
16
33
|
*/
|
|
17
34
|
declare function useValKeyStega<T extends ResolvableModule>(selector: T, key: string): JsonEntryContentOf<T> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* {@link routeRead}, for a module (a view resolved). A plain function, so the
|
|
37
|
+
* scenario world (`scenarios/`) reads a route as the hook does.
|
|
38
|
+
*/
|
|
39
|
+
export declare function moduleRouteRead<V>(valModule: ValModule<SelectorSource>, params: Record<string, string | string[]>, env: ReadEnv, settled?: ReadonlySet<Promise<void>>): Resolution<V | null>;
|
|
18
40
|
declare function useValRouteStega<T extends ResolvableModule>(selector: T, params: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): RouteValueOf<T>;
|
|
19
41
|
declare function useValRouteUrl<T extends ResolvableModule>(selector: T, params?: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): string | null;
|
|
20
42
|
export declare function initValClient(config: ValConfig): {
|
|
@@ -15,6 +15,7 @@ export { type SelectorSource, type SelectorOf, GenericSelector, } from "@valbuil
|
|
|
15
15
|
export { ValRichText } from "@valbuild/react/internal";
|
|
16
16
|
export { type ValEncodedString, type File, type Image, type Video, type RichText, } from "@valbuild/react/stega";
|
|
17
17
|
export { ValProvider } from "./ValProvider.js";
|
|
18
|
+
export type { ValDraft } from "@valbuild/react/internal";
|
|
18
19
|
export { ValImage, type ValImageProps } from "./ValImage.js";
|
|
19
20
|
export { ValVideo, type ValVideoProps } from "./ValVideo.js";
|
|
20
21
|
export { ValApp } from "./ValApp.js";
|
|
@@ -1,134 +1,61 @@
|
|
|
1
1
|
import { type JsonEntryContentOf, type Resolvable, type ResolvedVal, type RouteValueOf } from "@valbuild/react/stega";
|
|
2
|
+
import { type ValDraft } from "@valbuild/react/internal";
|
|
2
3
|
import { ValConfig, ValModules, type ResolvableModule } from "@valbuild/core";
|
|
3
4
|
import { cookies, draftMode, headers } from "next/headers";
|
|
4
|
-
import { type
|
|
5
|
-
import { ValServer } from "@valbuild/server";
|
|
5
|
+
import { type ValRuntime } from "@valbuild/server/internal";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* drift from what `/sources/~` actually returns.
|
|
11
|
-
*/
|
|
12
|
-
export type DraftSources = Extract<Awaited<ReturnType<ValServer["/sources/~"]["PUT"]>>, {
|
|
13
|
-
status: 200;
|
|
14
|
-
}>["json"]["modules"];
|
|
15
|
-
/**
|
|
16
|
-
* The slice of `ValServer` the draft-sources reader uses.
|
|
17
|
-
*
|
|
18
|
-
* Narrower than `ValServer` for the same reason `JsonEntryValServer` below is:
|
|
19
|
-
* it says what the dependency IS, and it lets a test drive the reader with a
|
|
20
|
-
* one-route fake instead of casting a partial object to the whole server type.
|
|
21
|
-
*/
|
|
22
|
-
export type DraftSourcesValServer = Pick<ValServer, "/sources/~">;
|
|
23
|
-
/** What the route readers need: the tree, plus the single-entry route. */
|
|
24
|
-
export type RouteReaderValServer = Pick<ValServer, "/sources/~" | "/json">;
|
|
25
|
-
/**
|
|
26
|
-
* Where the reader gets its per-request memo box.
|
|
27
|
-
*
|
|
28
|
-
* Injected rather than reached for, so that "this reader needs a request to
|
|
29
|
-
* scope its cache to" is part of its contract and a test can supply a scope it
|
|
30
|
-
* controls — in jest, React's non-`react-server` build makes `cache` a
|
|
31
|
-
* pass-through, so the real wiring memoises nothing there.
|
|
32
|
-
*/
|
|
33
|
-
export type GetDraftSourcesScope = () => Promise<RequestScopedMemo<DraftSources | null> | null>;
|
|
34
|
-
/**
|
|
35
|
-
* A per-request memo box, from React's request memoisation.
|
|
36
|
-
*
|
|
37
|
-
* `cache()` is what makes this safe: in an RSC render React hands back the SAME
|
|
38
|
-
* object for the length of one request and a fresh one for the next. Outside
|
|
39
|
-
* that — a route handler, a test, the non-`react-server` build of React —
|
|
40
|
-
* `cache` is a pass-through, so every call gets its own object, the memo misses,
|
|
41
|
-
* and the reader does exactly what it did before. Ineffective, never shared.
|
|
42
|
-
* See `memoizePerRequest`. `fetchVal` is an RSC API (`SET_RSC(true)` above, and
|
|
43
|
-
* its own error messages say so), so the effective case is the normal one.
|
|
44
|
-
*
|
|
45
|
-
* Built PER `initValRsc` rather than once for the module, because the box is
|
|
46
|
-
* only as specific as the `cache()` it came from: two Val servers in one
|
|
47
|
-
* process sharing one would answer each other's reads within a request, and
|
|
48
|
-
* they hold different content.
|
|
7
|
+
* What the readers read: this process's runtime for the app's `val.modules`
|
|
8
|
+
* (`createValRuntime`), the same one the API route's server is built on.
|
|
9
|
+
* Its head is the draft, read with the request's session.
|
|
49
10
|
*/
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
value: string;
|
|
65
|
-
} | undefined;
|
|
66
|
-
}>, getDraftSourcesScope: GetDraftSourcesScope) => <T extends ResolvableModule>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<RouteValueOf<T>>;
|
|
67
|
-
/**
|
|
68
|
-
* Loads a single `.jsonValues()` entry's DRAFT content via the in-process
|
|
69
|
-
* `/json` endpoint (which replays pending patches). Returns `undefined` when the
|
|
70
|
-
* entry has no draft content to serve — the caller then falls back to the
|
|
71
|
-
* locally-bundled committed content.
|
|
72
|
-
*/
|
|
73
|
-
/**
|
|
74
|
-
* What the draft state says about an entry.
|
|
75
|
-
*
|
|
76
|
-
* The three cases have to stay distinct: `absent` is an ANSWER — the entry is not
|
|
77
|
-
* there in the draft state, e.g. a pending patch removed it — while `unavailable`
|
|
78
|
-
* means we could not ask. Collapsing them into `undefined` is what made a
|
|
79
|
-
* draft-deleted entry keep rendering its committed content: the caller could not
|
|
80
|
-
* tell "it is gone" from "ask the committed source instead".
|
|
81
|
-
*/
|
|
82
|
-
/**
|
|
83
|
-
* The slice of `ValServer` the single-entry readers actually use. Narrower than
|
|
84
|
-
* `ValServer` on purpose: it says what the dependency IS, and it lets a test
|
|
85
|
-
* drive these readers with a one-route fake instead of casting a partial object
|
|
86
|
-
* to the whole server type.
|
|
87
|
-
*/
|
|
88
|
-
export type JsonEntryValServer = Pick<ValServer, "/json">;
|
|
89
|
-
export type DraftJsonEntry = {
|
|
90
|
-
status: "content";
|
|
91
|
-
content: unknown;
|
|
92
|
-
} | {
|
|
93
|
-
status: "absent";
|
|
94
|
-
} | {
|
|
95
|
-
status: "unavailable";
|
|
11
|
+
export type ReaderRuntime = Promise<ValRuntime>;
|
|
12
|
+
/** What a reader needs from the app and the request. */
|
|
13
|
+
export type ReaderDeps = {
|
|
14
|
+
runtime: ReaderRuntime;
|
|
15
|
+
isEnabled: () => Promise<boolean>;
|
|
16
|
+
getHeaders: () => Promise<{
|
|
17
|
+
get(name: string): string | null;
|
|
18
|
+
}>;
|
|
19
|
+
getCookies: () => Promise<{
|
|
20
|
+
get(name: string): {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
}>;
|
|
96
25
|
};
|
|
26
|
+
export declare const initFetchValStega: (deps: ReaderDeps) => <T extends Resolvable>(selector: T) => Promise<ResolvedVal<T>>;
|
|
27
|
+
declare const initFetchValRouteStega: (deps: ReaderDeps) => <T extends ResolvableModule>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<RouteValueOf<T>>;
|
|
97
28
|
/**
|
|
98
|
-
*
|
|
29
|
+
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
30
|
+
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
31
|
+
*
|
|
32
|
+
* Production (Val disabled): the entry's lazy import from the bundle. One
|
|
33
|
+
* dynamic import, no server round-trip.
|
|
99
34
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* ask). Returning `undefined` means "render nothing"; both callers turn that into
|
|
104
|
-
* a null/undefined result.
|
|
35
|
+
* Draft mode: the entry from the runtime's head, with the pending patches the
|
|
36
|
+
* draft holds for it, so uncommitted Studio edits show up; an entry the draft
|
|
37
|
+
* deleted is not there. An entry of a record no patch touched is the bundle's.
|
|
105
38
|
*/
|
|
106
|
-
export declare
|
|
39
|
+
export declare const initFetchValKeyStega: (deps: Omit<ReaderDeps, "getHeaders">) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
|
|
40
|
+
declare const initFetchValRouteUrl: (deps: ReaderDeps) => <T extends ResolvableModule>(selector: T, params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<string | null>;
|
|
107
41
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
42
|
+
* The draft a page in this request should start from, or `null` for none:
|
|
43
|
+
* what `<ValProvider draft>` takes. See `ValDraft`.
|
|
110
44
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
45
|
+
* `null` -- and no read at all -- unless the request is in draft mode: a
|
|
46
|
+
* visitor pays one `draftMode()` lookup, which does not make a static route
|
|
47
|
+
* dynamic. In draft mode it is the source of every module the editor's draft
|
|
48
|
+
* changes, from the runtime's head -- the one every `fetchVal` reads -- so
|
|
49
|
+
* the server renders the draft and the browser hydrates the same thing, with
|
|
50
|
+
* the version of each, so the page compares versions with what the Studio
|
|
51
|
+
* relays rather than content. Also `null` when the session is not one Val
|
|
52
|
+
* accepts, or the draft could not be read (logged): the published page.
|
|
113
53
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* the
|
|
54
|
+
* The read is `readDraftChanges` in `@valbuild/server`, which
|
|
55
|
+
* `@valbuild/tanstack/server`'s `fetchValDraft` is too; only where draft mode
|
|
56
|
+
* and the cookies come from is Next's.
|
|
117
57
|
*/
|
|
118
|
-
export declare const
|
|
119
|
-
get(name: string): {
|
|
120
|
-
name: string;
|
|
121
|
-
value: string;
|
|
122
|
-
} | undefined;
|
|
123
|
-
}>) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
|
|
124
|
-
declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<RouteReaderValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
125
|
-
get(name: string): string | null;
|
|
126
|
-
}>, getCookies: () => Promise<{
|
|
127
|
-
get(name: string): {
|
|
128
|
-
name: string;
|
|
129
|
-
value: string;
|
|
130
|
-
} | undefined;
|
|
131
|
-
}>, getDraftSourcesScope: GetDraftSourcesScope) => <T extends ResolvableModule>(selector: T, params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<string | null>;
|
|
58
|
+
export declare const initFetchValDraft: (deps: Omit<ReaderDeps, "getHeaders">) => () => Promise<ValDraft | null>;
|
|
132
59
|
type ValNextRscConfig = {
|
|
133
60
|
draftMode: typeof draftMode;
|
|
134
61
|
headers: typeof headers;
|
|
@@ -139,5 +66,16 @@ export declare function initValRsc(config: ValConfig, valModules: ValModules, rs
|
|
|
139
66
|
fetchValKeyStega: ReturnType<typeof initFetchValKeyStega>;
|
|
140
67
|
fetchValRouteStega: ReturnType<typeof initFetchValRouteStega>;
|
|
141
68
|
fetchValRouteUrl: ReturnType<typeof initFetchValRouteUrl>;
|
|
69
|
+
/**
|
|
70
|
+
* The draft for `<ValProvider draft>`, or `null` outside draft mode. Call
|
|
71
|
+
* it in the root layout (a Server Component) and pass what it returns:
|
|
72
|
+
*
|
|
73
|
+
* ```tsx
|
|
74
|
+
* <ValProvider config={config} draft={await fetchValDraft()}>
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* See "The `draft` prop" in the README, and `ValDraft`.
|
|
78
|
+
*/
|
|
79
|
+
fetchValDraft: ReturnType<typeof initFetchValDraft>;
|
|
142
80
|
};
|
|
143
81
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VAL_CONFIG_SESSION_STORAGE_KEY } from '@valbuild/shared/client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-5ff32315.esm.js';
|
|
4
4
|
import { Internal } from '@valbuild/core';
|
|
5
5
|
import { VERSION } from '@valbuild/ui';
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var client = require('@valbuild/shared/client');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var slicedToArray = require('./slicedToArray-
|
|
5
|
+
var slicedToArray = require('./slicedToArray-ed812733.cjs.dev.js');
|
|
6
6
|
var core = require('@valbuild/core');
|
|
7
7
|
var ui = require('@valbuild/ui');
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var client = require('@valbuild/shared/client');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var slicedToArray = require('./slicedToArray-
|
|
5
|
+
var slicedToArray = require('./slicedToArray-0fc63719.cjs.prod.js');
|
|
6
6
|
var core = require('@valbuild/core');
|
|
7
7
|
var ui = require('@valbuild/ui');
|
|
8
8
|
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function _toPrimitive(t, r) {
|
|
4
|
+
if ("object" != typeof t || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != typeof i) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _toPropertyKey(t) {
|
|
15
|
+
var i = _toPrimitive(t, "string");
|
|
16
|
+
return "symbol" == typeof i ? i : i + "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _defineProperty(e, r, t) {
|
|
20
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
21
|
+
value: t,
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
configurable: !0,
|
|
24
|
+
writable: !0
|
|
25
|
+
}) : e[r] = t, e;
|
|
26
|
+
}
|
|
4
27
|
|
|
5
28
|
function ownKeys(e, r) {
|
|
6
29
|
var t = Object.keys(e);
|
|
@@ -16,7 +39,7 @@ function _objectSpread2(e) {
|
|
|
16
39
|
for (var r = 1; r < arguments.length; r++) {
|
|
17
40
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
18
41
|
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
19
|
-
|
|
42
|
+
_defineProperty(e, r, t[r]);
|
|
20
43
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
21
44
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
22
45
|
});
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function _toPrimitive(t, r) {
|
|
4
|
+
if ("object" != typeof t || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != typeof i) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _toPropertyKey(t) {
|
|
15
|
+
var i = _toPrimitive(t, "string");
|
|
16
|
+
return "symbol" == typeof i ? i : i + "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _defineProperty(e, r, t) {
|
|
20
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
21
|
+
value: t,
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
configurable: !0,
|
|
24
|
+
writable: !0
|
|
25
|
+
}) : e[r] = t, e;
|
|
26
|
+
}
|
|
4
27
|
|
|
5
28
|
function ownKeys(e, r) {
|
|
6
29
|
var t = Object.keys(e);
|
|
@@ -16,7 +39,7 @@ function _objectSpread2(e) {
|
|
|
16
39
|
for (var r = 1; r < arguments.length; r++) {
|
|
17
40
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
18
41
|
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
19
|
-
|
|
42
|
+
_defineProperty(e, r, t[r]);
|
|
20
43
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
21
44
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
22
45
|
});
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
function _toPrimitive(t, r) {
|
|
2
|
+
if ("object" != typeof t || !t) return t;
|
|
3
|
+
var e = t[Symbol.toPrimitive];
|
|
4
|
+
if (void 0 !== e) {
|
|
5
|
+
var i = e.call(t, r || "default");
|
|
6
|
+
if ("object" != typeof i) return i;
|
|
7
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
8
|
+
}
|
|
9
|
+
return ("string" === r ? String : Number)(t);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _toPropertyKey(t) {
|
|
13
|
+
var i = _toPrimitive(t, "string");
|
|
14
|
+
return "symbol" == typeof i ? i : i + "";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _defineProperty(e, r, t) {
|
|
18
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
19
|
+
value: t,
|
|
20
|
+
enumerable: !0,
|
|
21
|
+
configurable: !0,
|
|
22
|
+
writable: !0
|
|
23
|
+
}) : e[r] = t, e;
|
|
24
|
+
}
|
|
2
25
|
|
|
3
26
|
function ownKeys(e, r) {
|
|
4
27
|
var t = Object.keys(e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-
|
|
2
|
-
import { _ as _objectSpread2 } from './objectSpread2-
|
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
|
4
|
-
import {
|
|
1
|
+
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-9209e9dd.esm.js';
|
|
2
|
+
import { _ as _objectSpread2 } from './objectSpread2-f1f0d77a.esm.js';
|
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-5ff32315.esm.js';
|
|
4
|
+
import { Internal, RecordSchema } from '@valbuild/core';
|
|
5
5
|
import { getNextAppRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern } from '@valbuild/shared/client';
|
|
6
6
|
|
|
7
7
|
function _typeof(o) {
|
|
@@ -14,156 +14,6 @@ function _typeof(o) {
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
19
|
-
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
20
|
-
* route helpers to load ONLY the matched entry instead of the whole record.
|
|
21
|
-
*/
|
|
22
|
-
function isJsonValuesRecordSchema(schema) {
|
|
23
|
-
return schema instanceof RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A whole `.jsonValues()` record, as `useVal` and `fetchVal` read it: with
|
|
28
|
-
* every entry's content. In the record's own source each entry is a lazy
|
|
29
|
-
* `c.json(() => import(...))` marker, so a reader that encodes that source
|
|
30
|
-
* renders every entry empty. (`useValKey` and `fetchValKey` read one entry,
|
|
31
|
-
* and load only that one.)
|
|
32
|
-
*
|
|
33
|
-
* `sourcesOf(modulePath)` are what the reader has before the bundle, the first
|
|
34
|
-
* that has the record winning: a draft view, then a snapshot (a proposal's saves, or the
|
|
35
|
-
* content version the site serves). An entry that is still a marker there is
|
|
36
|
-
* taken from a later source that has its content; the rest are named in
|
|
37
|
-
* `load`, for the reader to load from the bundle by key and hand to
|
|
38
|
-
* {@link fillJsonValuesRecord}.
|
|
39
|
-
*
|
|
40
|
-
* `null` when the selector is not a `.jsonValues()` module, or its record is
|
|
41
|
-
* not an object (a nullable record that is null): there is nothing to fill.
|
|
42
|
-
*/
|
|
43
|
-
function jsonValuesRecordToFill(
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
selector, sourcesOf) {
|
|
46
|
-
// Untyped, as `getJsonEntryStegaRoot`'s selector is: a module or a view of
|
|
47
|
-
// one, whichever source type it was defined with.
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
var module = Internal.resolveViewedModule(selector);
|
|
50
|
-
if (!module || !isJsonValuesRecordSchema(Internal.getSchema(module))) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
var modulePath = Internal.getValPath(module);
|
|
54
|
-
if (!modulePath) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
var sources = sourcesOf(modulePath);
|
|
58
|
-
var isRecord = function isRecord(value) {
|
|
59
|
-
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
60
|
-
};
|
|
61
|
-
var chosen = sources.find(function (source) {
|
|
62
|
-
return source !== undefined;
|
|
63
|
-
});
|
|
64
|
-
var base = chosen !== undefined ? chosen : Internal.getSource(module);
|
|
65
|
-
if (!isRecord(base)) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
var record = {};
|
|
69
|
-
var load = [];
|
|
70
|
-
var _loop = function _loop() {
|
|
71
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
72
|
-
key = _Object$entries$_i[0],
|
|
73
|
-
entry = _Object$entries$_i[1];
|
|
74
|
-
if (!Internal.isJson(entry)) {
|
|
75
|
-
record[key] = entry;
|
|
76
|
-
return 1; // continue
|
|
77
|
-
}
|
|
78
|
-
var later = sources.slice(sources.indexOf(chosen) + 1).map(function (source) {
|
|
79
|
-
return isRecord(source) && Object.prototype.hasOwnProperty.call(source, key) ? source[key] : undefined;
|
|
80
|
-
}).find(function (content) {
|
|
81
|
-
return content !== undefined && !Internal.isJson(content);
|
|
82
|
-
});
|
|
83
|
-
if (later !== undefined) {
|
|
84
|
-
record[key] = later;
|
|
85
|
-
} else {
|
|
86
|
-
// Left as the marker until it is loaded: see `fillJsonValuesRecord`.
|
|
87
|
-
record[key] = entry;
|
|
88
|
-
load.push(key);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
for (var _i = 0, _Object$entries = Object.entries(base); _i < _Object$entries.length; _i++) {
|
|
92
|
-
if (_loop()) continue;
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
modulePath: modulePath,
|
|
96
|
-
module: module,
|
|
97
|
-
record: record,
|
|
98
|
-
load: load
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The record from {@link jsonValuesRecordToFill}, with the entries it named in
|
|
104
|
-
* `load` put in: `loaded[key]`, as the bundle's import of that entry gave it.
|
|
105
|
-
* An entry the bundle has no import for keeps its marker.
|
|
106
|
-
*/
|
|
107
|
-
function fillJsonValuesRecord(record, loaded) {
|
|
108
|
-
var filled = _objectSpread2({}, record);
|
|
109
|
-
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
110
|
-
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
111
|
-
key = _Object$entries2$_i[0],
|
|
112
|
-
content = _Object$entries2$_i[1];
|
|
113
|
-
if (content !== undefined) {
|
|
114
|
-
filled[key] = content;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return filled;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The bundle's import of one `.jsonValues()` entry, started: `undefined` when
|
|
122
|
-
* the module's own source has no marker for `key` to import from.
|
|
123
|
-
*/
|
|
124
|
-
function bundledJsonEntryImport(
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
-
module, key) {
|
|
127
|
-
var _Internal$getJsonImpo;
|
|
128
|
-
var source = module && Internal.getSource(module);
|
|
129
|
-
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
130
|
-
if (!Internal.isJson(marker)) {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
return (_Internal$getJsonImpo = Internal.getJsonImport(marker)) !== null && _Internal$getJsonImpo !== void 0 ? _Internal$getJsonImpo : undefined;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
138
|
-
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
139
|
-
* identity transform (the content carries no selector path/schema).
|
|
140
|
-
*
|
|
141
|
-
* Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
|
|
142
|
-
* field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
|
|
143
|
-
* `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
|
|
144
|
-
*/
|
|
145
|
-
function getJsonEntryStegaRoot(
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
|
-
selector, key
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
-
) {
|
|
150
|
-
var modulePath = selector && Internal.getValPath(selector);
|
|
151
|
-
if (!modulePath) {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
var schema = selector && Internal.getSchema(selector);
|
|
155
|
-
if (!(schema instanceof RecordSchema)) {
|
|
156
|
-
return undefined;
|
|
157
|
-
}
|
|
158
|
-
var path = Internal.createValPathOfItem(modulePath, key);
|
|
159
|
-
if (!path) {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
path: path,
|
|
164
|
-
schema: schema["executeSerialize"]().item
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
17
|
function getValRouteUrlFromVal(resolvedParams, methodName,
|
|
168
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
19
|
path,
|
|
@@ -307,4 +157,4 @@ val) {
|
|
|
307
157
|
return actualRoute;
|
|
308
158
|
}
|
|
309
159
|
|
|
310
|
-
export {
|
|
160
|
+
export { getValRouteUrlFromVal as g, initValRouteFromVal as i };
|