@valbuild/next 0.133.0 → 0.134.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/client/dist/valbuild-next-client.cjs.dev.js +23 -14
- package/client/dist/valbuild-next-client.cjs.prod.js +23 -14
- package/client/dist/valbuild-next-client.esm.js +23 -14
- package/dist/declarations/src/client/initValClient.d.ts +8 -9
- package/dist/declarations/src/rsc/initValRsc.d.ts +6 -8
- package/dist/valbuild-next.cjs.dev.js +1 -1
- package/dist/valbuild-next.cjs.prod.js +1 -1
- package/dist/valbuild-next.esm.js +1 -1
- package/dist/{version-b027675f.esm.js → version-28baa77f.esm.js} +1 -1
- package/dist/{version-3721f88f.cjs.dev.js → version-a3e5a2df.cjs.prod.js} +1 -1
- package/dist/{version-bf666fd9.cjs.prod.js → version-ddff5d6a.cjs.dev.js} +1 -1
- package/package.json +8 -8
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +38 -29
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +38 -29
- package/rsc/dist/valbuild-next-rsc.esm.js +38 -29
- package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-next-server.esm.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @valbuild/next
|
|
2
2
|
|
|
3
|
+
## 0.134.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`821e789`](https://github.com/valbuild/val/commit/821e789c1af47510af5d23eb96384ff78ddd7646)]:
|
|
8
|
+
- @valbuild/shared@0.134.1
|
|
9
|
+
- @valbuild/language-server@0.134.1
|
|
10
|
+
- @valbuild/mcp@0.134.1
|
|
11
|
+
- @valbuild/react@0.134.1
|
|
12
|
+
- @valbuild/server@0.134.1
|
|
13
|
+
- @valbuild/ui@0.134.0
|
|
14
|
+
|
|
15
|
+
## 0.134.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#690](https://github.com/valbuild/val/pull/690) [`16c49ea`](https://github.com/valbuild/val/commit/16c49ea6dd97c7a96bbfdf211af9bab5884579e2) Thanks [@freekh](https://github.com/freekh)! - Read a view with `useVal` / `fetchVal`.
|
|
20
|
+
|
|
21
|
+
A `s.view()` field reads as a pointer with no properties on it. It can now be handed to a reader, which resolves it to the module it names:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
const page = useVal(pageVal);
|
|
25
|
+
const header = useVal(page.header); // the header module's content, typed
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The point is single source of truth rather than a new capability: the page declares which module it shows, and a component follows that declaration instead of importing the target a second time. Change `s.view(headerVal)` to `s.view(navVal)` and the reader follows; an import would have kept reading the header.
|
|
29
|
+
|
|
30
|
+
The readers that take a MODULE rather than a value follow the same rule — `useValKey`, `useValRoute`, `useValRouteUrl` and the `fetchVal*` counterparts, in both the Next and TanStack packages:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
const page = useVal(pageVal);
|
|
34
|
+
const note = useValRoute(page.notes, params); // the router module the view names
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Works in draft mode, including when the page itself has a pending edit. Two things to know:
|
|
38
|
+
|
|
39
|
+
- **Resolve a handle in the component that read the module containing it.** A handle carries the module it points at, and that cannot survive serialization — so one passed from a server component to a client component as a prop arrives empty. It throws with an explanation rather than handing back the pointer. This is why it throws rather than returning nothing: every one of the route and key readers already uses `null` / `undefined` to mean "no such entry", so a quiet answer would be indistinguishable from a 404.
|
|
40
|
+
- **`ValView<Source>` is now a member of `SelectorSource`**, since a reader accepts one.
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [[`be78a9b`](https://github.com/valbuild/val/commit/be78a9b51678439f7ecb1c7f3887f9e8e1261a13), [`1c31dcc`](https://github.com/valbuild/val/commit/1c31dcca7f1bb0199350567fd579de29f48bb26d), [`688b9e3`](https://github.com/valbuild/val/commit/688b9e36b821323cda6870cdff03dd36ec3e782f), [`16c49ea`](https://github.com/valbuild/val/commit/16c49ea6dd97c7a96bbfdf211af9bab5884579e2), [`eaa265e`](https://github.com/valbuild/val/commit/eaa265e78d9f6d2a1b685c38901612b8a3704eed)]:
|
|
45
|
+
- @valbuild/server@0.134.0
|
|
46
|
+
- @valbuild/ui@0.134.0
|
|
47
|
+
- @valbuild/core@0.134.0
|
|
48
|
+
- @valbuild/react@0.134.0
|
|
49
|
+
- @valbuild/shared@0.134.0
|
|
50
|
+
- @valbuild/language-server@0.134.0
|
|
51
|
+
- @valbuild/mcp@0.134.0
|
|
52
|
+
|
|
3
53
|
## 0.133.0
|
|
4
54
|
|
|
5
55
|
### Patch Changes
|
|
@@ -19,6 +19,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
19
19
|
|
|
20
20
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
21
21
|
|
|
22
|
+
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
23
|
+
|
|
22
24
|
function useValStega(selector) {
|
|
23
25
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
24
26
|
var moduleIds = React__default["default"].useMemo(function () {
|
|
@@ -144,8 +146,6 @@ function draftJsonEntry(draftSource, key) {
|
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
// The (loosened) content type a single `.jsonValues()` entry resolves to.
|
|
148
|
-
|
|
149
149
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
150
150
|
// stable promise across renders (keyed by module path + entry key).
|
|
151
151
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -162,7 +162,10 @@ var jsonEntryPromiseCache = new Map();
|
|
|
162
162
|
*/
|
|
163
163
|
function useValKeyStega(selector, key) {
|
|
164
164
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
165
|
-
|
|
165
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
166
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
167
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
168
|
+
var moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
166
169
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
167
170
|
var draft = draftJsonEntry(draftSource, key);
|
|
168
171
|
if (draft.status === "absent") {
|
|
@@ -172,11 +175,11 @@ function useValKeyStega(selector, key) {
|
|
|
172
175
|
}
|
|
173
176
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
174
177
|
if (content === undefined) {
|
|
175
|
-
content = readCommittedJsonEntry(
|
|
178
|
+
content = readCommittedJsonEntry(valModule, key);
|
|
176
179
|
}
|
|
177
180
|
return stega.stegaEncode(content, {
|
|
178
181
|
disabled: !valOverlayContext.draftMode,
|
|
179
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
182
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
185
|
|
|
@@ -227,22 +230,25 @@ function resolveParams(params) {
|
|
|
227
230
|
}
|
|
228
231
|
function useValRouteStega(selector, params) {
|
|
229
232
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
233
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
234
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
235
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
230
236
|
// Both called unconditionally to keep hook order stable. For a `.jsonValues()`
|
|
231
237
|
// router `val` is unused (we resolve a single entry below instead); for any
|
|
232
238
|
// other router `draftSource` is.
|
|
233
|
-
var val = useValStega(
|
|
234
|
-
var draftSource = useDraftModuleSource(
|
|
239
|
+
var val = useValStega(valModule);
|
|
240
|
+
var draftSource = useDraftModuleSource(valModule && core.Internal.getValPath(valModule) || undefined);
|
|
235
241
|
var resolvedParams = resolveParams(params);
|
|
236
242
|
// Careful: null means there was an error - undefined means no params
|
|
237
243
|
if (resolvedParams === null) {
|
|
238
244
|
return null;
|
|
239
245
|
}
|
|
240
|
-
var path =
|
|
241
|
-
var schema =
|
|
246
|
+
var path = valModule && core.Internal.getValPath(valModule);
|
|
247
|
+
var schema = valModule && core.Internal.getSchema(valModule);
|
|
242
248
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
243
249
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
244
250
|
if (routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
245
|
-
var source =
|
|
251
|
+
var source = valModule && core.Internal.getSource(valModule);
|
|
246
252
|
var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
247
253
|
if (!url) {
|
|
248
254
|
return null;
|
|
@@ -254,27 +260,30 @@ function useValRouteStega(selector, params) {
|
|
|
254
260
|
}
|
|
255
261
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
256
262
|
if (content === undefined) {
|
|
257
|
-
content = readCommittedJsonEntry(
|
|
263
|
+
content = readCommittedJsonEntry(valModule, url);
|
|
258
264
|
}
|
|
259
265
|
if (content === undefined) {
|
|
260
266
|
return null;
|
|
261
267
|
}
|
|
262
268
|
return stega.stegaEncode(content, {
|
|
263
269
|
disabled: !valOverlayContext.draftMode,
|
|
264
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
270
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
265
271
|
});
|
|
266
272
|
}
|
|
267
273
|
var route = routeFromVal.initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
|
|
268
274
|
return route;
|
|
269
275
|
}
|
|
270
276
|
function useValRouteUrl(selector, params) {
|
|
271
|
-
|
|
277
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
278
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
279
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
280
|
+
var val = useValStega(valModule);
|
|
272
281
|
var resolvedParams = params === undefined ? undefined : resolveParams(params);
|
|
273
282
|
// Careful: null means there was an error - undefined means no params
|
|
274
283
|
if (resolvedParams === null) {
|
|
275
284
|
return null;
|
|
276
285
|
}
|
|
277
|
-
var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl",
|
|
286
|
+
var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && core.Internal.getValPath(valModule), valModule && core.Internal.getSchema(valModule), val);
|
|
278
287
|
return route;
|
|
279
288
|
}
|
|
280
289
|
|
|
@@ -19,6 +19,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
19
19
|
|
|
20
20
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
21
21
|
|
|
22
|
+
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
23
|
+
|
|
22
24
|
function useValStega(selector) {
|
|
23
25
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
24
26
|
var moduleIds = React__default["default"].useMemo(function () {
|
|
@@ -144,8 +146,6 @@ function draftJsonEntry(draftSource, key) {
|
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
// The (loosened) content type a single `.jsonValues()` entry resolves to.
|
|
148
|
-
|
|
149
149
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
150
150
|
// stable promise across renders (keyed by module path + entry key).
|
|
151
151
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -162,7 +162,10 @@ var jsonEntryPromiseCache = new Map();
|
|
|
162
162
|
*/
|
|
163
163
|
function useValKeyStega(selector, key) {
|
|
164
164
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
165
|
-
|
|
165
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
166
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
167
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
168
|
+
var moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
166
169
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
167
170
|
var draft = draftJsonEntry(draftSource, key);
|
|
168
171
|
if (draft.status === "absent") {
|
|
@@ -172,11 +175,11 @@ function useValKeyStega(selector, key) {
|
|
|
172
175
|
}
|
|
173
176
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
174
177
|
if (content === undefined) {
|
|
175
|
-
content = readCommittedJsonEntry(
|
|
178
|
+
content = readCommittedJsonEntry(valModule, key);
|
|
176
179
|
}
|
|
177
180
|
return stega.stegaEncode(content, {
|
|
178
181
|
disabled: !valOverlayContext.draftMode,
|
|
179
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
182
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
185
|
|
|
@@ -227,22 +230,25 @@ function resolveParams(params) {
|
|
|
227
230
|
}
|
|
228
231
|
function useValRouteStega(selector, params) {
|
|
229
232
|
var valOverlayContext = ValOverlayContext.useValOverlayContext();
|
|
233
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
234
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
235
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
230
236
|
// Both called unconditionally to keep hook order stable. For a `.jsonValues()`
|
|
231
237
|
// router `val` is unused (we resolve a single entry below instead); for any
|
|
232
238
|
// other router `draftSource` is.
|
|
233
|
-
var val = useValStega(
|
|
234
|
-
var draftSource = useDraftModuleSource(
|
|
239
|
+
var val = useValStega(valModule);
|
|
240
|
+
var draftSource = useDraftModuleSource(valModule && core.Internal.getValPath(valModule) || undefined);
|
|
235
241
|
var resolvedParams = resolveParams(params);
|
|
236
242
|
// Careful: null means there was an error - undefined means no params
|
|
237
243
|
if (resolvedParams === null) {
|
|
238
244
|
return null;
|
|
239
245
|
}
|
|
240
|
-
var path =
|
|
241
|
-
var schema =
|
|
246
|
+
var path = valModule && core.Internal.getValPath(valModule);
|
|
247
|
+
var schema = valModule && core.Internal.getSchema(valModule);
|
|
242
248
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
243
249
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
244
250
|
if (routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
245
|
-
var source =
|
|
251
|
+
var source = valModule && core.Internal.getSource(valModule);
|
|
246
252
|
var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
247
253
|
if (!url) {
|
|
248
254
|
return null;
|
|
@@ -254,27 +260,30 @@ function useValRouteStega(selector, params) {
|
|
|
254
260
|
}
|
|
255
261
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
256
262
|
if (content === undefined) {
|
|
257
|
-
content = readCommittedJsonEntry(
|
|
263
|
+
content = readCommittedJsonEntry(valModule, url);
|
|
258
264
|
}
|
|
259
265
|
if (content === undefined) {
|
|
260
266
|
return null;
|
|
261
267
|
}
|
|
262
268
|
return stega.stegaEncode(content, {
|
|
263
269
|
disabled: !valOverlayContext.draftMode,
|
|
264
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
270
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
265
271
|
});
|
|
266
272
|
}
|
|
267
273
|
var route = routeFromVal.initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
|
|
268
274
|
return route;
|
|
269
275
|
}
|
|
270
276
|
function useValRouteUrl(selector, params) {
|
|
271
|
-
|
|
277
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
278
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
279
|
+
var valModule = core.Internal.resolveViewedModule(selector);
|
|
280
|
+
var val = useValStega(valModule);
|
|
272
281
|
var resolvedParams = params === undefined ? undefined : resolveParams(params);
|
|
273
282
|
// Careful: null means there was an error - undefined means no params
|
|
274
283
|
if (resolvedParams === null) {
|
|
275
284
|
return null;
|
|
276
285
|
}
|
|
277
|
-
var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl",
|
|
286
|
+
var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && core.Internal.getValPath(valModule), valModule && core.Internal.getSchema(valModule), val);
|
|
278
287
|
return route;
|
|
279
288
|
}
|
|
280
289
|
|
|
@@ -11,6 +11,8 @@ import '../../dist/defineProperty-cca5affa.esm.js';
|
|
|
11
11
|
import '../../dist/slicedToArray-aa291011.esm.js';
|
|
12
12
|
import '@valbuild/shared/client';
|
|
13
13
|
|
|
14
|
+
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
15
|
+
|
|
14
16
|
function useValStega(selector) {
|
|
15
17
|
var valOverlayContext = useValOverlayContext();
|
|
16
18
|
var moduleIds = React.useMemo(function () {
|
|
@@ -136,8 +138,6 @@ function draftJsonEntry(draftSource, key) {
|
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
140
|
|
|
139
|
-
// The (loosened) content type a single `.jsonValues()` entry resolves to.
|
|
140
|
-
|
|
141
141
|
// Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
|
|
142
142
|
// stable promise across renders (keyed by module path + entry key).
|
|
143
143
|
var jsonEntryPromiseCache = new Map();
|
|
@@ -154,7 +154,10 @@ var jsonEntryPromiseCache = new Map();
|
|
|
154
154
|
*/
|
|
155
155
|
function useValKeyStega(selector, key) {
|
|
156
156
|
var valOverlayContext = useValOverlayContext();
|
|
157
|
-
|
|
157
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
158
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
159
|
+
var valModule = Internal.resolveViewedModule(selector);
|
|
160
|
+
var moduleFilePath = valModule && Internal.getValPath(valModule);
|
|
158
161
|
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
159
162
|
var draft = draftJsonEntry(draftSource, key);
|
|
160
163
|
if (draft.status === "absent") {
|
|
@@ -164,11 +167,11 @@ function useValKeyStega(selector, key) {
|
|
|
164
167
|
}
|
|
165
168
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
166
169
|
if (content === undefined) {
|
|
167
|
-
content = readCommittedJsonEntry(
|
|
170
|
+
content = readCommittedJsonEntry(valModule, key);
|
|
168
171
|
}
|
|
169
172
|
return stegaEncode(content, {
|
|
170
173
|
disabled: !valOverlayContext.draftMode,
|
|
171
|
-
root: getJsonEntryStegaRoot(
|
|
174
|
+
root: getJsonEntryStegaRoot(valModule, key)
|
|
172
175
|
});
|
|
173
176
|
}
|
|
174
177
|
|
|
@@ -219,22 +222,25 @@ function resolveParams(params) {
|
|
|
219
222
|
}
|
|
220
223
|
function useValRouteStega(selector, params) {
|
|
221
224
|
var valOverlayContext = useValOverlayContext();
|
|
225
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
226
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
227
|
+
var valModule = Internal.resolveViewedModule(selector);
|
|
222
228
|
// Both called unconditionally to keep hook order stable. For a `.jsonValues()`
|
|
223
229
|
// router `val` is unused (we resolve a single entry below instead); for any
|
|
224
230
|
// other router `draftSource` is.
|
|
225
|
-
var val = useValStega(
|
|
226
|
-
var draftSource = useDraftModuleSource(
|
|
231
|
+
var val = useValStega(valModule);
|
|
232
|
+
var draftSource = useDraftModuleSource(valModule && Internal.getValPath(valModule) || undefined);
|
|
227
233
|
var resolvedParams = resolveParams(params);
|
|
228
234
|
// Careful: null means there was an error - undefined means no params
|
|
229
235
|
if (resolvedParams === null) {
|
|
230
236
|
return null;
|
|
231
237
|
}
|
|
232
|
-
var path =
|
|
233
|
-
var schema =
|
|
238
|
+
var path = valModule && Internal.getValPath(valModule);
|
|
239
|
+
var schema = valModule && Internal.getSchema(valModule);
|
|
234
240
|
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
235
241
|
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
236
242
|
if (isJsonValuesRecordSchema(schema)) {
|
|
237
|
-
var source =
|
|
243
|
+
var source = valModule && Internal.getSource(valModule);
|
|
238
244
|
var url = getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
239
245
|
if (!url) {
|
|
240
246
|
return null;
|
|
@@ -246,27 +252,30 @@ function useValRouteStega(selector, params) {
|
|
|
246
252
|
}
|
|
247
253
|
var content = draft.status === "content" ? draft.content : undefined;
|
|
248
254
|
if (content === undefined) {
|
|
249
|
-
content = readCommittedJsonEntry(
|
|
255
|
+
content = readCommittedJsonEntry(valModule, url);
|
|
250
256
|
}
|
|
251
257
|
if (content === undefined) {
|
|
252
258
|
return null;
|
|
253
259
|
}
|
|
254
260
|
return stegaEncode(content, {
|
|
255
261
|
disabled: !valOverlayContext.draftMode,
|
|
256
|
-
root: getJsonEntryStegaRoot(
|
|
262
|
+
root: getJsonEntryStegaRoot(valModule, url)
|
|
257
263
|
});
|
|
258
264
|
}
|
|
259
265
|
var route = initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
|
|
260
266
|
return route;
|
|
261
267
|
}
|
|
262
268
|
function useValRouteUrl(selector, params) {
|
|
263
|
-
|
|
269
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
270
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
271
|
+
var valModule = Internal.resolveViewedModule(selector);
|
|
272
|
+
var val = useValStega(valModule);
|
|
264
273
|
var resolvedParams = params === undefined ? undefined : resolveParams(params);
|
|
265
274
|
// Careful: null means there was an error - undefined means no params
|
|
266
275
|
if (resolvedParams === null) {
|
|
267
276
|
return null;
|
|
268
277
|
}
|
|
269
|
-
var route = getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl",
|
|
278
|
+
var route = getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && Internal.getValPath(valModule), valModule && Internal.getSchema(valModule), val);
|
|
270
279
|
return route;
|
|
271
280
|
}
|
|
272
281
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type ResolvableModule, SelectorSource } from "@valbuild/core";
|
|
2
|
+
import { type JsonEntryContentOf, type Resolvable, type ResolvedVal, type RouteValueOf } from "@valbuild/react/stega";
|
|
3
3
|
import { ValConfig } from "@valbuild/core";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
5
|
+
export type UseValType<T extends SelectorSource> = ResolvedVal<T>;
|
|
6
|
+
declare function useValStega<T extends Resolvable>(selector: T): UseValType<T>;
|
|
7
7
|
/**
|
|
8
8
|
* Client counterpart to `fetchValKey`: resolves a SINGLE `.jsonValues()` entry
|
|
9
9
|
* by key, loading only that entry's backing `*.val.json` (one dynamic import).
|
|
@@ -14,10 +14,9 @@ type JsonEntryContentOf<T extends ValModule<GenericSelector<SourceObject>>> = T
|
|
|
14
14
|
* overlay; in production — and whenever there is no draft view — it resolves the
|
|
15
15
|
* entry's lazy import thunk from the local module.
|
|
16
16
|
*/
|
|
17
|
-
declare function useValKeyStega<T extends
|
|
18
|
-
|
|
19
|
-
declare function
|
|
20
|
-
declare function useValRouteUrl<T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params?: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): string | null;
|
|
17
|
+
declare function useValKeyStega<T extends ResolvableModule>(selector: T, key: string): JsonEntryContentOf<T> | undefined;
|
|
18
|
+
declare function useValRouteStega<T extends ResolvableModule>(selector: T, params: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): RouteValueOf<T>;
|
|
19
|
+
declare function useValRouteUrl<T extends ResolvableModule>(selector: T, params?: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): string | null;
|
|
21
20
|
export declare function initValClient(config: ValConfig): {
|
|
22
21
|
useValStega: typeof useValStega;
|
|
23
22
|
useValKeyStega: typeof useValKeyStega;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
1
|
+
import { type JsonEntryContentOf, type Resolvable, type ResolvedVal, type RouteValueOf } from "@valbuild/react/stega";
|
|
2
|
+
import { ValConfig, ValModules, type ResolvableModule } 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<{
|
|
@@ -9,8 +9,7 @@ declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, va
|
|
|
9
9
|
name: string;
|
|
10
10
|
value: string;
|
|
11
11
|
} | undefined;
|
|
12
|
-
}>) => <T extends
|
|
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;
|
|
12
|
+
}>) => <T extends Resolvable>(selector: T) => Promise<ResolvedVal<T>>;
|
|
14
13
|
declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
15
14
|
get(name: string): string | null;
|
|
16
15
|
}>, getCookies: () => Promise<{
|
|
@@ -18,7 +17,7 @@ declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: strin
|
|
|
18
17
|
name: string;
|
|
19
18
|
value: string;
|
|
20
19
|
} | undefined;
|
|
21
|
-
}>) => <T extends
|
|
20
|
+
}>) => <T extends ResolvableModule>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<RouteValueOf<T>>;
|
|
22
21
|
/**
|
|
23
22
|
* Loads a single `.jsonValues()` entry's DRAFT content via the in-process
|
|
24
23
|
* `/json` endpoint (which replays pending patches). Returns `undefined` when the
|
|
@@ -59,7 +58,6 @@ export type DraftJsonEntry = {
|
|
|
59
58
|
* a null/undefined result.
|
|
60
59
|
*/
|
|
61
60
|
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
61
|
/**
|
|
64
62
|
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
65
63
|
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
@@ -76,7 +74,7 @@ export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryV
|
|
|
76
74
|
name: string;
|
|
77
75
|
value: string;
|
|
78
76
|
} | undefined;
|
|
79
|
-
}>) => <T extends
|
|
77
|
+
}>) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
|
|
80
78
|
declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
|
|
81
79
|
get(name: string): string | null;
|
|
82
80
|
}>, getCookies: () => Promise<{
|
|
@@ -84,7 +82,7 @@ declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string,
|
|
|
84
82
|
name: string;
|
|
85
83
|
value: string;
|
|
86
84
|
} | undefined;
|
|
87
|
-
}>) => <T extends
|
|
85
|
+
}>) => <T extends ResolvableModule>(selector: T, params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<string | null>;
|
|
88
86
|
type ValNextRscConfig = {
|
|
89
87
|
draftMode: typeof draftMode;
|
|
90
88
|
headers: typeof headers;
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-294e5b53.cjs.dev.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-ddff5d6a.cjs.dev.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
17
17
|
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
18
18
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-ab8a96fd.cjs.prod.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-a3e5a2df.cjs.prod.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
17
17
|
require('./defineProperty-8951f469.cjs.prod.js');
|
|
18
18
|
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
@@ -11,7 +11,7 @@ import NextImage from 'next/image';
|
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
export { ValApp } from './ValApp-3a70afe1.esm.js';
|
|
13
13
|
export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
|
|
14
|
-
import { V as VERSION } from './version-
|
|
14
|
+
import { V as VERSION } from './version-28baa77f.esm.js';
|
|
15
15
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
|
|
16
16
|
import './defineProperty-cca5affa.esm.js';
|
|
17
17
|
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.134.1",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -47,13 +47,13 @@
|
|
|
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/mcp": "0.
|
|
53
|
-
"@valbuild/
|
|
54
|
-
"@valbuild/
|
|
55
|
-
"@valbuild/shared": "0.
|
|
56
|
-
"@valbuild/ui": "0.
|
|
50
|
+
"@valbuild/core": "0.134.0",
|
|
51
|
+
"@valbuild/language-server": "0.134.1",
|
|
52
|
+
"@valbuild/mcp": "0.134.1",
|
|
53
|
+
"@valbuild/server": "0.134.1",
|
|
54
|
+
"@valbuild/react": "0.134.1",
|
|
55
|
+
"@valbuild/shared": "0.134.1",
|
|
56
|
+
"@valbuild/ui": "0.134.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/react": "^16.3.3",
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-ddff5d6a.cjs.dev.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
17
17
|
require('../../dist/slicedToArray-44036a76.cjs.dev.js');
|
|
@@ -199,7 +199,7 @@ function getHost(headers) {
|
|
|
199
199
|
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
200
200
|
return /*#__PURE__*/function () {
|
|
201
201
|
var _ref2 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee2(selector, params) {
|
|
202
|
-
var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
202
|
+
var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
203
203
|
return asyncToGenerator._regenerator().w(function (_context2) {
|
|
204
204
|
while (1) switch (_context2.p = _context2.n) {
|
|
205
205
|
case 0:
|
|
@@ -207,15 +207,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
207
207
|
return Promise.resolve(params);
|
|
208
208
|
case 1:
|
|
209
209
|
resolvedParams = _context2.v;
|
|
210
|
-
path
|
|
211
|
-
|
|
210
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
211
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
212
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
213
|
+
path = valModule && core.Internal.getValPath(valModule);
|
|
214
|
+
schema = valModule && core.Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
212
215
|
// entry's backing `*.val.json`, instead of eagerly resolving the whole
|
|
213
216
|
// record via `fetchVal`.
|
|
214
217
|
if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
215
218
|
_context2.n = 11;
|
|
216
219
|
break;
|
|
217
220
|
}
|
|
218
|
-
source =
|
|
221
|
+
source = valModule && core.Internal.getSource(valModule);
|
|
219
222
|
url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
|
|
220
223
|
if (url) {
|
|
221
224
|
_context2.n = 2;
|
|
@@ -262,17 +265,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
262
265
|
case 10:
|
|
263
266
|
return _context2.a(2, stega.stegaEncode(content, {
|
|
264
267
|
disabled: !enabled,
|
|
265
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
268
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
266
269
|
}));
|
|
267
270
|
case 11:
|
|
268
271
|
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
|
|
269
|
-
_t5 =
|
|
272
|
+
_t5 = valModule;
|
|
270
273
|
if (!_t5) {
|
|
271
274
|
_context2.n = 13;
|
|
272
275
|
break;
|
|
273
276
|
}
|
|
274
277
|
_context2.n = 12;
|
|
275
|
-
return fetchVal(
|
|
278
|
+
return fetchVal(valModule);
|
|
276
279
|
case 12:
|
|
277
280
|
_t5 = _context2.v;
|
|
278
281
|
case 13:
|
|
@@ -389,7 +392,18 @@ function _resolveDraftOrCommittedEntry() {
|
|
|
389
392
|
}
|
|
390
393
|
function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
|
|
391
394
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
392
|
-
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
398
|
+
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
399
|
+
*
|
|
400
|
+
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
401
|
+
* locally-bundled module. One dynamic import, no server round-trip.
|
|
402
|
+
*
|
|
403
|
+
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
404
|
+
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
405
|
+
* the draft read yields nothing.
|
|
406
|
+
*/
|
|
393
407
|
function _loadDraftJsonEntry() {
|
|
394
408
|
_loadDraftJsonEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee19(valServerPromise, getCookies, moduleFilePath, key) {
|
|
395
409
|
var _cookies3;
|
|
@@ -474,21 +488,10 @@ function _loadDraftJsonEntry() {
|
|
|
474
488
|
}));
|
|
475
489
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
476
490
|
}
|
|
477
|
-
/**
|
|
478
|
-
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
479
|
-
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
480
|
-
*
|
|
481
|
-
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
482
|
-
* locally-bundled module. One dynamic import, no server round-trip.
|
|
483
|
-
*
|
|
484
|
-
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
485
|
-
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
486
|
-
* the draft read yields nothing.
|
|
487
|
-
*/
|
|
488
491
|
var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
|
|
489
492
|
return /*#__PURE__*/function () {
|
|
490
493
|
var _ref3 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee3(selector, key) {
|
|
491
|
-
var enabled, source, moduleFilePath, draft, content;
|
|
494
|
+
var enabled, valModule, source, moduleFilePath, draft, content;
|
|
492
495
|
return asyncToGenerator._regenerator().w(function (_context3) {
|
|
493
496
|
while (1) switch (_context3.p = _context3.n) {
|
|
494
497
|
case 0:
|
|
@@ -504,8 +507,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
504
507
|
_context3.p = 3;
|
|
505
508
|
_context3.v;
|
|
506
509
|
case 4:
|
|
507
|
-
|
|
508
|
-
|
|
510
|
+
// A view is a pointer: everything below reads a path and a source off this,
|
|
511
|
+
// and a pointer has neither. See `resolveViewedModule`.
|
|
512
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
513
|
+
source = valModule && core.Internal.getSource(valModule);
|
|
514
|
+
moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
509
515
|
draft = {
|
|
510
516
|
status: "unavailable"
|
|
511
517
|
};
|
|
@@ -533,7 +539,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
533
539
|
case 8:
|
|
534
540
|
return _context3.a(2, stega.stegaEncode(content, {
|
|
535
541
|
disabled: !enabled,
|
|
536
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
542
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
|
|
537
543
|
}));
|
|
538
544
|
}
|
|
539
545
|
}, _callee3, null, [[1, 3]]);
|
|
@@ -546,7 +552,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
546
552
|
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
547
553
|
return /*#__PURE__*/function () {
|
|
548
554
|
var _ref4 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee4(selector, params) {
|
|
549
|
-
var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
|
|
555
|
+
var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
|
|
550
556
|
return asyncToGenerator._regenerator().w(function (_context4) {
|
|
551
557
|
while (1) switch (_context4.n) {
|
|
552
558
|
case 0:
|
|
@@ -565,15 +571,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
|
|
|
565
571
|
_t7 = _context4.v;
|
|
566
572
|
case 3:
|
|
567
573
|
resolvedParams = _t7;
|
|
568
|
-
path
|
|
569
|
-
|
|
570
|
-
|
|
574
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
575
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
576
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
577
|
+
path = valModule && core.Internal.getValPath(valModule);
|
|
578
|
+
schema = valModule && core.Internal.getSchema(valModule);
|
|
579
|
+
_t8 = valModule;
|
|
571
580
|
if (!_t8) {
|
|
572
581
|
_context4.n = 5;
|
|
573
582
|
break;
|
|
574
583
|
}
|
|
575
584
|
_context4.n = 4;
|
|
576
|
-
return fetchVal(
|
|
585
|
+
return fetchVal(valModule);
|
|
577
586
|
case 4:
|
|
578
587
|
_t8 = _context4.v;
|
|
579
588
|
case 5:
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-a3e5a2df.cjs.prod.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
17
17
|
require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
|
|
@@ -199,7 +199,7 @@ function getHost(headers) {
|
|
|
199
199
|
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
200
200
|
return /*#__PURE__*/function () {
|
|
201
201
|
var _ref2 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee2(selector, params) {
|
|
202
|
-
var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
202
|
+
var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
203
203
|
return asyncToGenerator._regenerator().w(function (_context2) {
|
|
204
204
|
while (1) switch (_context2.p = _context2.n) {
|
|
205
205
|
case 0:
|
|
@@ -207,15 +207,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
207
207
|
return Promise.resolve(params);
|
|
208
208
|
case 1:
|
|
209
209
|
resolvedParams = _context2.v;
|
|
210
|
-
path
|
|
211
|
-
|
|
210
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
211
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
212
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
213
|
+
path = valModule && core.Internal.getValPath(valModule);
|
|
214
|
+
schema = valModule && core.Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
212
215
|
// entry's backing `*.val.json`, instead of eagerly resolving the whole
|
|
213
216
|
// record via `fetchVal`.
|
|
214
217
|
if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
|
|
215
218
|
_context2.n = 11;
|
|
216
219
|
break;
|
|
217
220
|
}
|
|
218
|
-
source =
|
|
221
|
+
source = valModule && core.Internal.getSource(valModule);
|
|
219
222
|
url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
|
|
220
223
|
if (url) {
|
|
221
224
|
_context2.n = 2;
|
|
@@ -262,17 +265,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
262
265
|
case 10:
|
|
263
266
|
return _context2.a(2, stega.stegaEncode(content, {
|
|
264
267
|
disabled: !enabled,
|
|
265
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
268
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
|
|
266
269
|
}));
|
|
267
270
|
case 11:
|
|
268
271
|
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
|
|
269
|
-
_t5 =
|
|
272
|
+
_t5 = valModule;
|
|
270
273
|
if (!_t5) {
|
|
271
274
|
_context2.n = 13;
|
|
272
275
|
break;
|
|
273
276
|
}
|
|
274
277
|
_context2.n = 12;
|
|
275
|
-
return fetchVal(
|
|
278
|
+
return fetchVal(valModule);
|
|
276
279
|
case 12:
|
|
277
280
|
_t5 = _context2.v;
|
|
278
281
|
case 13:
|
|
@@ -389,7 +392,18 @@ function _resolveDraftOrCommittedEntry() {
|
|
|
389
392
|
}
|
|
390
393
|
function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
|
|
391
394
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
392
|
-
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
398
|
+
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
399
|
+
*
|
|
400
|
+
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
401
|
+
* locally-bundled module. One dynamic import, no server round-trip.
|
|
402
|
+
*
|
|
403
|
+
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
404
|
+
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
405
|
+
* the draft read yields nothing.
|
|
406
|
+
*/
|
|
393
407
|
function _loadDraftJsonEntry() {
|
|
394
408
|
_loadDraftJsonEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee19(valServerPromise, getCookies, moduleFilePath, key) {
|
|
395
409
|
var _cookies3;
|
|
@@ -474,21 +488,10 @@ function _loadDraftJsonEntry() {
|
|
|
474
488
|
}));
|
|
475
489
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
476
490
|
}
|
|
477
|
-
/**
|
|
478
|
-
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
479
|
-
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
480
|
-
*
|
|
481
|
-
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
482
|
-
* locally-bundled module. One dynamic import, no server round-trip.
|
|
483
|
-
*
|
|
484
|
-
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
485
|
-
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
486
|
-
* the draft read yields nothing.
|
|
487
|
-
*/
|
|
488
491
|
var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
|
|
489
492
|
return /*#__PURE__*/function () {
|
|
490
493
|
var _ref3 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee3(selector, key) {
|
|
491
|
-
var enabled, source, moduleFilePath, draft, content;
|
|
494
|
+
var enabled, valModule, source, moduleFilePath, draft, content;
|
|
492
495
|
return asyncToGenerator._regenerator().w(function (_context3) {
|
|
493
496
|
while (1) switch (_context3.p = _context3.n) {
|
|
494
497
|
case 0:
|
|
@@ -504,8 +507,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
504
507
|
_context3.p = 3;
|
|
505
508
|
_context3.v;
|
|
506
509
|
case 4:
|
|
507
|
-
|
|
508
|
-
|
|
510
|
+
// A view is a pointer: everything below reads a path and a source off this,
|
|
511
|
+
// and a pointer has neither. See `resolveViewedModule`.
|
|
512
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
513
|
+
source = valModule && core.Internal.getSource(valModule);
|
|
514
|
+
moduleFilePath = valModule && core.Internal.getValPath(valModule);
|
|
509
515
|
draft = {
|
|
510
516
|
status: "unavailable"
|
|
511
517
|
};
|
|
@@ -533,7 +539,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
533
539
|
case 8:
|
|
534
540
|
return _context3.a(2, stega.stegaEncode(content, {
|
|
535
541
|
disabled: !enabled,
|
|
536
|
-
root: routeFromVal.getJsonEntryStegaRoot(
|
|
542
|
+
root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
|
|
537
543
|
}));
|
|
538
544
|
}
|
|
539
545
|
}, _callee3, null, [[1, 3]]);
|
|
@@ -546,7 +552,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
546
552
|
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
547
553
|
return /*#__PURE__*/function () {
|
|
548
554
|
var _ref4 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee4(selector, params) {
|
|
549
|
-
var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
|
|
555
|
+
var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
|
|
550
556
|
return asyncToGenerator._regenerator().w(function (_context4) {
|
|
551
557
|
while (1) switch (_context4.n) {
|
|
552
558
|
case 0:
|
|
@@ -565,15 +571,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
|
|
|
565
571
|
_t7 = _context4.v;
|
|
566
572
|
case 3:
|
|
567
573
|
resolvedParams = _t7;
|
|
568
|
-
path
|
|
569
|
-
|
|
570
|
-
|
|
574
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
575
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
576
|
+
valModule = core.Internal.resolveViewedModule(selector);
|
|
577
|
+
path = valModule && core.Internal.getValPath(valModule);
|
|
578
|
+
schema = valModule && core.Internal.getSchema(valModule);
|
|
579
|
+
_t8 = valModule;
|
|
571
580
|
if (!_t8) {
|
|
572
581
|
_context4.n = 5;
|
|
573
582
|
break;
|
|
574
583
|
}
|
|
575
584
|
_context4.n = 4;
|
|
576
|
-
return fetchVal(
|
|
585
|
+
return fetchVal(valModule);
|
|
577
586
|
case 4:
|
|
578
587
|
_t8 = _context4.v;
|
|
579
588
|
case 5:
|
|
@@ -7,7 +7,7 @@ import { SET_RSC, stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/
|
|
|
7
7
|
import { Internal } from '@valbuild/core';
|
|
8
8
|
import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
9
9
|
import { createValServer } from '@valbuild/server';
|
|
10
|
-
import { V as VERSION } from '../../dist/version-
|
|
10
|
+
import { V as VERSION } from '../../dist/version-28baa77f.esm.js';
|
|
11
11
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
12
12
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
13
13
|
import '../../dist/slicedToArray-aa291011.esm.js';
|
|
@@ -195,7 +195,7 @@ function getHost(headers) {
|
|
|
195
195
|
var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
196
196
|
return /*#__PURE__*/function () {
|
|
197
197
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(selector, params) {
|
|
198
|
-
var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
198
|
+
var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
|
|
199
199
|
return _regenerator().w(function (_context2) {
|
|
200
200
|
while (1) switch (_context2.p = _context2.n) {
|
|
201
201
|
case 0:
|
|
@@ -203,15 +203,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
203
203
|
return Promise.resolve(params);
|
|
204
204
|
case 1:
|
|
205
205
|
resolvedParams = _context2.v;
|
|
206
|
-
path
|
|
207
|
-
|
|
206
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
207
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
208
|
+
valModule = Internal.resolveViewedModule(selector);
|
|
209
|
+
path = valModule && Internal.getValPath(valModule);
|
|
210
|
+
schema = valModule && Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
208
211
|
// entry's backing `*.val.json`, instead of eagerly resolving the whole
|
|
209
212
|
// record via `fetchVal`.
|
|
210
213
|
if (!isJsonValuesRecordSchema(schema)) {
|
|
211
214
|
_context2.n = 11;
|
|
212
215
|
break;
|
|
213
216
|
}
|
|
214
|
-
source =
|
|
217
|
+
source = valModule && Internal.getSource(valModule);
|
|
215
218
|
url = getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
|
|
216
219
|
if (url) {
|
|
217
220
|
_context2.n = 2;
|
|
@@ -258,17 +261,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
258
261
|
case 10:
|
|
259
262
|
return _context2.a(2, stegaEncode(content, {
|
|
260
263
|
disabled: !enabled,
|
|
261
|
-
root: getJsonEntryStegaRoot(
|
|
264
|
+
root: getJsonEntryStegaRoot(valModule, url)
|
|
262
265
|
}));
|
|
263
266
|
case 11:
|
|
264
267
|
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
|
|
265
|
-
_t5 =
|
|
268
|
+
_t5 = valModule;
|
|
266
269
|
if (!_t5) {
|
|
267
270
|
_context2.n = 13;
|
|
268
271
|
break;
|
|
269
272
|
}
|
|
270
273
|
_context2.n = 12;
|
|
271
|
-
return fetchVal(
|
|
274
|
+
return fetchVal(valModule);
|
|
272
275
|
case 12:
|
|
273
276
|
_t5 = _context2.v;
|
|
274
277
|
case 13:
|
|
@@ -385,7 +388,18 @@ function _resolveDraftOrCommittedEntry() {
|
|
|
385
388
|
}
|
|
386
389
|
function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
|
|
387
390
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
388
|
-
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
394
|
+
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
395
|
+
*
|
|
396
|
+
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
397
|
+
* locally-bundled module. One dynamic import, no server round-trip.
|
|
398
|
+
*
|
|
399
|
+
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
400
|
+
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
401
|
+
* the draft read yields nothing.
|
|
402
|
+
*/
|
|
389
403
|
function _loadDraftJsonEntry() {
|
|
390
404
|
_loadDraftJsonEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(valServerPromise, getCookies, moduleFilePath, key) {
|
|
391
405
|
var _cookies3;
|
|
@@ -470,21 +484,10 @@ function _loadDraftJsonEntry() {
|
|
|
470
484
|
}));
|
|
471
485
|
return _loadDraftJsonEntry.apply(this, arguments);
|
|
472
486
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
|
|
475
|
-
* the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
|
|
476
|
-
*
|
|
477
|
-
* Production (Val disabled): resolves the entry's lazy import thunk from the
|
|
478
|
-
* locally-bundled module. One dynamic import, no server round-trip.
|
|
479
|
-
*
|
|
480
|
-
* Enabled (draft mode): reads the entry through `/json`, which replays pending
|
|
481
|
-
* patches, so uncommitted Studio edits show up. Falls back to the local thunk if
|
|
482
|
-
* the draft read yields nothing.
|
|
483
|
-
*/
|
|
484
487
|
var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
|
|
485
488
|
return /*#__PURE__*/function () {
|
|
486
489
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(selector, key) {
|
|
487
|
-
var enabled, source, moduleFilePath, draft, content;
|
|
490
|
+
var enabled, valModule, source, moduleFilePath, draft, content;
|
|
488
491
|
return _regenerator().w(function (_context3) {
|
|
489
492
|
while (1) switch (_context3.p = _context3.n) {
|
|
490
493
|
case 0:
|
|
@@ -500,8 +503,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
500
503
|
_context3.p = 3;
|
|
501
504
|
_context3.v;
|
|
502
505
|
case 4:
|
|
503
|
-
|
|
504
|
-
|
|
506
|
+
// A view is a pointer: everything below reads a path and a source off this,
|
|
507
|
+
// and a pointer has neither. See `resolveViewedModule`.
|
|
508
|
+
valModule = Internal.resolveViewedModule(selector);
|
|
509
|
+
source = valModule && Internal.getSource(valModule);
|
|
510
|
+
moduleFilePath = valModule && Internal.getValPath(valModule);
|
|
505
511
|
draft = {
|
|
506
512
|
status: "unavailable"
|
|
507
513
|
};
|
|
@@ -529,7 +535,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
529
535
|
case 8:
|
|
530
536
|
return _context3.a(2, stegaEncode(content, {
|
|
531
537
|
disabled: !enabled,
|
|
532
|
-
root: getJsonEntryStegaRoot(
|
|
538
|
+
root: getJsonEntryStegaRoot(valModule, key)
|
|
533
539
|
}));
|
|
534
540
|
}
|
|
535
541
|
}, _callee3, null, [[1, 3]]);
|
|
@@ -542,7 +548,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
|
|
|
542
548
|
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
543
549
|
return /*#__PURE__*/function () {
|
|
544
550
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(selector, params) {
|
|
545
|
-
var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
|
|
551
|
+
var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
|
|
546
552
|
return _regenerator().w(function (_context4) {
|
|
547
553
|
while (1) switch (_context4.n) {
|
|
548
554
|
case 0:
|
|
@@ -561,15 +567,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
|
|
|
561
567
|
_t7 = _context4.v;
|
|
562
568
|
case 3:
|
|
563
569
|
resolvedParams = _t7;
|
|
564
|
-
path
|
|
565
|
-
|
|
566
|
-
|
|
570
|
+
// A view is a pointer: everything below reads a path, a schema and a source
|
|
571
|
+
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
572
|
+
valModule = Internal.resolveViewedModule(selector);
|
|
573
|
+
path = valModule && Internal.getValPath(valModule);
|
|
574
|
+
schema = valModule && Internal.getSchema(valModule);
|
|
575
|
+
_t8 = valModule;
|
|
567
576
|
if (!_t8) {
|
|
568
577
|
_context4.n = 5;
|
|
569
578
|
break;
|
|
570
579
|
}
|
|
571
580
|
_context4.n = 4;
|
|
572
|
-
return fetchVal(
|
|
581
|
+
return fetchVal(valModule);
|
|
573
582
|
case 4:
|
|
574
583
|
_t8 = _context4.v;
|
|
575
584
|
case 5:
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-58024783.cjs.dev.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-ddff5d6a.cjs.dev.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
15
15
|
require('../../dist/defineProperty-f90345d7.cjs.dev.js');
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-a3e5a2df.cjs.prod.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
15
15
|
require('../../dist/defineProperty-8951f469.cjs.prod.js');
|
|
@@ -5,7 +5,7 @@ import { _ as _objectSpread2 } from '../../dist/objectSpread2-60d1bd93.esm.js';
|
|
|
5
5
|
import { Internal } from '@valbuild/core';
|
|
6
6
|
import { createValApiRouter, createValServer } from '@valbuild/server';
|
|
7
7
|
import { NextResponse } from 'next/server';
|
|
8
|
-
import { V as VERSION } from '../../dist/version-
|
|
8
|
+
import { V as VERSION } from '../../dist/version-28baa77f.esm.js';
|
|
9
9
|
import { initValMcp as initValMcp$1 } from '@valbuild/mcp';
|
|
10
10
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
11
11
|
import '../../dist/defineProperty-cca5affa.esm.js';
|