@valbuild/next 0.99.0 → 0.100.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/client/dist/valbuild-next-client.cjs.dev.js +162 -2
- package/client/dist/valbuild-next-client.cjs.prod.js +162 -2
- package/client/dist/valbuild-next-client.esm.js +162 -2
- package/dist/declarations/src/client/initValClient.d.ts +15 -2
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +3 -0
- package/dist/declarations/src/rsc/initValRsc.d.ts +61 -2
- package/dist/{routeFromVal-8855a5cc.esm.js → routeFromVal-263eec96.esm.js} +41 -1
- package/dist/{routeFromVal-13c832b2.cjs.prod.js → routeFromVal-8ac2f984.cjs.prod.js} +43 -0
- package/dist/{routeFromVal-9b610e77.cjs.dev.js → routeFromVal-b48a454a.cjs.dev.js} +43 -0
- package/package.json +7 -7
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +398 -74
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +398 -74
- package/rsc/dist/valbuild-next-rsc.esm.js +398 -74
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StegaOfSource } from "@valbuild/react/stega";
|
|
2
|
-
import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject } from "@valbuild/core";
|
|
2
|
+
import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject, JsonSource } from "@valbuild/core";
|
|
3
3
|
import { cookies, draftMode, headers } from "next/headers";
|
|
4
4
|
import { ValServer } from "@valbuild/server";
|
|
5
5
|
declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
@@ -10,7 +10,7 @@ declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, va
|
|
|
10
10
|
value: string;
|
|
11
11
|
} | undefined;
|
|
12
12
|
}>) => <T extends SelectorSource>(selector: T) => Promise<SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never>;
|
|
13
|
-
type FetchValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? StegaOfSource<NonNullable<S>[string]> | null : never : never;
|
|
13
|
+
type FetchValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? NonNullable<S>[string] extends JsonSource<infer C> ? C | null : StegaOfSource<NonNullable<S>[string]> | null : never : never;
|
|
14
14
|
declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
15
15
|
get(name: string): string | null;
|
|
16
16
|
}>, getCookies: () => Promise<{
|
|
@@ -19,6 +19,64 @@ declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: strin
|
|
|
19
19
|
value: string;
|
|
20
20
|
} | undefined;
|
|
21
21
|
}>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<FetchValRouteReturnType<T>>;
|
|
22
|
+
/**
|
|
23
|
+
* Loads a single `.jsonValues()` entry's DRAFT content via the in-process
|
|
24
|
+
* `/json` endpoint (which replays pending patches). Returns `undefined` when the
|
|
25
|
+
* entry has no draft content to serve — the caller then falls back to the
|
|
26
|
+
* locally-bundled committed content.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* What the draft state says about an entry.
|
|
30
|
+
*
|
|
31
|
+
* The three cases have to stay distinct: `absent` is an ANSWER — the entry is not
|
|
32
|
+
* there in the draft state, e.g. a pending patch removed it — while `unavailable`
|
|
33
|
+
* means we could not ask. Collapsing them into `undefined` is what made a
|
|
34
|
+
* draft-deleted entry keep rendering its committed content: the caller could not
|
|
35
|
+
* tell "it is gone" from "ask the committed source instead".
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* The slice of `ValServer` the single-entry readers actually use. Narrower than
|
|
39
|
+
* `ValServer` on purpose: it says what the dependency IS, and it lets a test
|
|
40
|
+
* drive these readers with a one-route fake instead of casting a partial object
|
|
41
|
+
* to the whole server type.
|
|
42
|
+
*/
|
|
43
|
+
export type JsonEntryValServer = Pick<ValServer, "/json">;
|
|
44
|
+
export type DraftJsonEntry = {
|
|
45
|
+
status: "content";
|
|
46
|
+
content: unknown;
|
|
47
|
+
} | {
|
|
48
|
+
status: "absent";
|
|
49
|
+
} | {
|
|
50
|
+
status: "unavailable";
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Picks the content a draft-aware single-entry read should render.
|
|
54
|
+
*
|
|
55
|
+
* The rule the two callers share: the draft state WINS when it has an answer —
|
|
56
|
+
* including the answer "this entry is gone" — and the committed content is used
|
|
57
|
+
* only when there is no draft answer to be had (Val disabled, or we could not
|
|
58
|
+
* ask). Returning `undefined` means "render nothing"; both callers turn that into
|
|
59
|
+
* a null/undefined result.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveDraftOrCommittedEntry(draft: DraftJsonEntry, loadCommitted: () => Promise<unknown | undefined>): Promise<unknown | undefined>;
|
|
62
|
+
type JsonEntryContentOf<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends Record<string, infer V> ? V extends JsonSource<infer C> ? C : never : never : never;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
65
|
+
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
66
|
+
*
|
|
67
|
+
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
68
|
+
* locally-bundled module. One dynamic import, no server round-trip.
|
|
69
|
+
*
|
|
70
|
+
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
71
|
+
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
72
|
+
* the draft read yields nothing.
|
|
73
|
+
*/
|
|
74
|
+
export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryValServer>, isEnabled: () => Promise<boolean>, getCookies: () => Promise<{
|
|
75
|
+
get(name: string): {
|
|
76
|
+
name: string;
|
|
77
|
+
value: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
}>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
|
|
22
80
|
declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
23
81
|
get(name: string): string | null;
|
|
24
82
|
}>, getCookies: () => Promise<{
|
|
@@ -34,6 +92,7 @@ type ValNextRscConfig = {
|
|
|
34
92
|
};
|
|
35
93
|
export declare function initValRsc(config: ValConfig, valModules: ValModules, rscNextConfig: ValNextRscConfig): {
|
|
36
94
|
fetchValStega: ReturnType<typeof initFetchValStega>;
|
|
95
|
+
fetchValKeyStega: ReturnType<typeof initFetchValKeyStega>;
|
|
37
96
|
fetchValRouteStega: ReturnType<typeof initFetchValRouteStega>;
|
|
38
97
|
fetchValRouteUrl: ReturnType<typeof initFetchValRouteUrl>;
|
|
39
98
|
};
|
|
@@ -14,6 +14,46 @@ 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
|
+
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
28
|
+
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
29
|
+
* identity transform (the content carries no selector path/schema).
|
|
30
|
+
*
|
|
31
|
+
* Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
|
|
32
|
+
* field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
|
|
33
|
+
* `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
|
|
34
|
+
*/
|
|
35
|
+
function getJsonEntryStegaRoot(
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
selector, key
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
) {
|
|
40
|
+
var modulePath = selector && Internal.getValPath(selector);
|
|
41
|
+
if (!modulePath) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
var schema = selector && Internal.getSchema(selector);
|
|
45
|
+
if (!(schema instanceof RecordSchema)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
var path = Internal.createValPathOfItem(modulePath, key);
|
|
49
|
+
if (!path) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
path: path,
|
|
54
|
+
schema: schema["executeSerialize"]().item
|
|
55
|
+
};
|
|
56
|
+
}
|
|
17
57
|
function getValRouteUrlFromVal(resolvedParams, methodName,
|
|
18
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
59
|
path,
|
|
@@ -153,4 +193,4 @@ val) {
|
|
|
153
193
|
return actualRoute;
|
|
154
194
|
}
|
|
155
195
|
|
|
156
|
-
export { getValRouteUrlFromVal as g, initValRouteFromVal as i };
|
|
196
|
+
export { _typeof as _, isJsonValuesRecordSchema as a, getValRouteUrlFromVal as b, getJsonEntryStegaRoot as g, initValRouteFromVal as i };
|
|
@@ -16,6 +16,46 @@ function _typeof(o) {
|
|
|
16
16
|
}, _typeof(o);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
21
|
+
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
22
|
+
* route helpers to load ONLY the matched entry instead of the whole record.
|
|
23
|
+
*/
|
|
24
|
+
function isJsonValuesRecordSchema(schema) {
|
|
25
|
+
return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
30
|
+
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
31
|
+
* identity transform (the content carries no selector path/schema).
|
|
32
|
+
*
|
|
33
|
+
* Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
|
|
34
|
+
* field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
|
|
35
|
+
* `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
|
|
36
|
+
*/
|
|
37
|
+
function getJsonEntryStegaRoot(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
selector, key
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
) {
|
|
42
|
+
var modulePath = selector && core.Internal.getValPath(selector);
|
|
43
|
+
if (!modulePath) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
var schema = selector && core.Internal.getSchema(selector);
|
|
47
|
+
if (!(schema instanceof core.RecordSchema)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
var path = core.Internal.createValPathOfItem(modulePath, key);
|
|
51
|
+
if (!path) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
path: path,
|
|
56
|
+
schema: schema["executeSerialize"]().item
|
|
57
|
+
};
|
|
58
|
+
}
|
|
19
59
|
function getValRouteUrlFromVal(resolvedParams, methodName,
|
|
20
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
61
|
path,
|
|
@@ -155,5 +195,8 @@ val) {
|
|
|
155
195
|
return actualRoute;
|
|
156
196
|
}
|
|
157
197
|
|
|
198
|
+
exports._typeof = _typeof;
|
|
199
|
+
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
158
200
|
exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
|
|
159
201
|
exports.initValRouteFromVal = initValRouteFromVal;
|
|
202
|
+
exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
|
|
@@ -16,6 +16,46 @@ function _typeof(o) {
|
|
|
16
16
|
}, _typeof(o);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
21
|
+
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
22
|
+
* route helpers to load ONLY the matched entry instead of the whole record.
|
|
23
|
+
*/
|
|
24
|
+
function isJsonValuesRecordSchema(schema) {
|
|
25
|
+
return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
30
|
+
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
31
|
+
* identity transform (the content carries no selector path/schema).
|
|
32
|
+
*
|
|
33
|
+
* Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
|
|
34
|
+
* field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
|
|
35
|
+
* `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
|
|
36
|
+
*/
|
|
37
|
+
function getJsonEntryStegaRoot(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
selector, key
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
) {
|
|
42
|
+
var modulePath = selector && core.Internal.getValPath(selector);
|
|
43
|
+
if (!modulePath) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
var schema = selector && core.Internal.getSchema(selector);
|
|
47
|
+
if (!(schema instanceof core.RecordSchema)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
var path = core.Internal.createValPathOfItem(modulePath, key);
|
|
51
|
+
if (!path) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
path: path,
|
|
56
|
+
schema: schema["executeSerialize"]().item
|
|
57
|
+
};
|
|
58
|
+
}
|
|
19
59
|
function getValRouteUrlFromVal(resolvedParams, methodName,
|
|
20
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
61
|
path,
|
|
@@ -155,5 +195,8 @@ val) {
|
|
|
155
195
|
return actualRoute;
|
|
156
196
|
}
|
|
157
197
|
|
|
198
|
+
exports._typeof = _typeof;
|
|
199
|
+
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
158
200
|
exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
|
|
159
201
|
exports.initValRouteFromVal = initValRouteFromVal;
|
|
202
|
+
exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.100.0",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
|
-
"@valbuild/core": "0.
|
|
51
|
-
"@valbuild/language-server": "0.
|
|
52
|
-
"@valbuild/react": "0.
|
|
53
|
-
"@valbuild/server": "0.
|
|
54
|
-
"@valbuild/shared": "0.
|
|
55
|
-
"@valbuild/ui": "0.
|
|
50
|
+
"@valbuild/core": "0.100.0",
|
|
51
|
+
"@valbuild/language-server": "0.100.0",
|
|
52
|
+
"@valbuild/react": "0.100.0",
|
|
53
|
+
"@valbuild/server": "0.100.0",
|
|
54
|
+
"@valbuild/shared": "0.100.0",
|
|
55
|
+
"@valbuild/ui": "0.100.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@testing-library/react": "^14.0.0",
|