@valbuild/tanstack 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 CHANGED
@@ -1,5 +1,118 @@
1
1
  # @valbuild/tanstack
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
+ - [#708](https://github.com/valbuild/val/pull/708) [`be78a9b`](https://github.com/valbuild/val/commit/be78a9b51678439f7ecb1c7f3887f9e8e1261a13) Thanks [@freekh](https://github.com/freekh)! - Fix `gitCommit` and `gitBranch` in `val.config.ts` never reaching the server,
45
+ and make them the one way to say it.
46
+
47
+ `val.config.ts` has had `gitCommit` and `gitBranch` for as long as it has had
48
+ anything, and a deployed app that set them resolved to no repository at all.
49
+ Nothing failed and nothing was logged: the commit was simply never sent, and
50
+ every patch the project saved recorded none.
51
+
52
+ ```ts
53
+ // val.config.ts — the normal Vercel shape, and it did nothing
54
+ initVal({
55
+ project: "org/project",
56
+ gitCommit: process.env.VERCEL_GIT_COMMIT_SHA,
57
+ gitBranch: process.env.VERCEL_GIT_COMMIT_REF,
58
+ });
59
+ ```
60
+
61
+ The two halves never met. The server wanted a nested
62
+ `git: { commit, branch }`, `val.config.ts` offered two flat keys, and nothing
63
+ mapped one onto the other — so the only thing that worked was
64
+ `VAL_GIT_COMMIT` / `VAL_GIT_BRANCH` in the environment.
65
+
66
+ Rather than teach the server to read both, the nested option is gone:
67
+ `ValApiOptions` and TanStack's `ValHttpMode` now take `gitCommit` and
68
+ `gitBranch`, the same two names `ValConfig` uses. There is one name for this
69
+ now, wherever it is set. The framework bindings already hand the server
70
+ `{ versions, ...config }`, so a project's config keys arrive with nothing to
71
+ map, and a host passing them directly is saying the same thing in the same
72
+ words.
73
+
74
+ Flat because of where these values come from. A platform supplies them as
75
+ `process.env.VERCEL_GIT_COMMIT_SHA` and friends, typed `string | undefined`,
76
+ and two optional strings take that as it comes — a nested object makes every
77
+ caller write the ternary that turns two maybe-strings into one maybe-object.
78
+
79
+ **Breaking for a host that passed `git` itself**, which is the nested option on
80
+ `ValApiOptions` and on TanStack's `http` mode. An app that only configures
81
+ `val.config.ts` or the environment is unaffected.
82
+
83
+ ```ts
84
+ // before
85
+ initValServer(valModules, config, {
86
+ http: { apiKey, valSecret, git: { commit, branch } },
87
+ });
88
+
89
+ // after
90
+ initValServer(valModules, config, {
91
+ http: { apiKey, valSecret, gitCommit: commit, gitBranch: branch },
92
+ });
93
+ ```
94
+
95
+ **What a commit is for**, and why its absence is worth a release rather than a
96
+ shrug: publishing turns pending patches into new `.val.ts` text, and to patch a
97
+ file you must first read it — at a commit. A project with none is a project
98
+ whose publishes read whatever the content service last had, rather than the
99
+ revision the deployed code was built from.
100
+
101
+ **One more behaviour change.** A commit and a branch have always been taken
102
+ together or not at all, and that check now sees config-supplied values too. A
103
+ project that sets exactly one of `gitCommit` and `gitBranch` used to have both
104
+ quietly ignored and will now be refused at startup, naming the missing half.
105
+ That is the configuration that would otherwise fail later, at a publish.
106
+
107
+ - 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)]:
108
+ - @valbuild/server@0.134.0
109
+ - @valbuild/ui@0.134.0
110
+ - @valbuild/core@0.134.0
111
+ - @valbuild/react@0.134.0
112
+ - @valbuild/shared@0.134.0
113
+ - @valbuild/language-server@0.134.0
114
+ - @valbuild/mcp@0.134.0
115
+
3
116
  ## 0.133.0
4
117
 
5
118
  ### Minor Changes
@@ -16,6 +16,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
16
16
 
17
17
  var React__default = /*#__PURE__*/_interopDefault(React);
18
18
 
19
+ /** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
20
+
19
21
  function useValStega(selector) {
20
22
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
21
23
  var moduleIds = React__default["default"].useMemo(function () {
@@ -141,8 +143,6 @@ function draftJsonEntry(draftSource, key) {
141
143
  };
142
144
  }
143
145
 
144
- // The (loosened) content type a single `.jsonValues()` entry resolves to.
145
-
146
146
  // Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
147
147
  // stable promise across renders (keyed by module path + entry key).
148
148
  var jsonEntryPromiseCache = new Map();
@@ -159,7 +159,10 @@ var jsonEntryPromiseCache = new Map();
159
159
  */
160
160
  function useValKeyStega(selector, key) {
161
161
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
162
- var moduleFilePath = selector && core.Internal.getValPath(selector);
162
+ // A view is a pointer: everything below reads a path, a schema and a source
163
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
164
+ var valModule = core.Internal.resolveViewedModule(selector);
165
+ var moduleFilePath = valModule && core.Internal.getValPath(valModule);
163
166
  var draftSource = useDraftModuleSource(moduleFilePath || undefined);
164
167
  var draft = draftJsonEntry(draftSource, key);
165
168
  if (draft.status === "absent") {
@@ -169,11 +172,11 @@ function useValKeyStega(selector, key) {
169
172
  }
170
173
  var content = draft.status === "content" ? draft.content : undefined;
171
174
  if (content === undefined) {
172
- content = readCommittedJsonEntry(selector, key);
175
+ content = readCommittedJsonEntry(valModule, key);
173
176
  }
174
177
  return stega.stegaEncode(content, {
175
178
  disabled: !valOverlayContext.draftMode,
176
- root: routeFromVal.getJsonEntryStegaRoot(selector, key)
179
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
177
180
  });
178
181
  }
179
182
 
@@ -224,22 +227,25 @@ function resolveParams(params) {
224
227
  }
225
228
  function useValRouteStega(selector, params) {
226
229
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
230
+ // A view is a pointer: everything below reads a path, a schema and a source
231
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
232
+ var valModule = core.Internal.resolveViewedModule(selector);
227
233
  // Both called unconditionally to keep hook order stable. For a `.jsonValues()`
228
234
  // router `val` is unused (we resolve a single entry below instead); for any
229
235
  // other router `draftSource` is.
230
- var val = useValStega(selector);
231
- var draftSource = useDraftModuleSource(selector && core.Internal.getValPath(selector) || undefined);
236
+ var val = useValStega(valModule);
237
+ var draftSource = useDraftModuleSource(valModule && core.Internal.getValPath(valModule) || undefined);
232
238
  var resolvedParams = resolveParams(params);
233
239
  // Careful: null means there was an error - undefined means no params
234
240
  if (resolvedParams === null) {
235
241
  return null;
236
242
  }
237
- var path = selector && core.Internal.getValPath(selector);
238
- var schema = selector && core.Internal.getSchema(selector);
243
+ var path = valModule && core.Internal.getValPath(valModule);
244
+ var schema = valModule && core.Internal.getSchema(valModule);
239
245
  // `.jsonValues()` router: map params → the entry key and load ONLY that
240
246
  // entry's backing `*.val.json` (one dynamic import), like `useValKey`.
241
247
  if (routeFromVal.isJsonValuesRecordSchema(schema)) {
242
- var source = selector && core.Internal.getSource(selector);
248
+ var source = valModule && core.Internal.getSource(valModule);
243
249
  var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
244
250
  if (!url) {
245
251
  return null;
@@ -251,27 +257,30 @@ function useValRouteStega(selector, params) {
251
257
  }
252
258
  var content = draft.status === "content" ? draft.content : undefined;
253
259
  if (content === undefined) {
254
- content = readCommittedJsonEntry(selector, url);
260
+ content = readCommittedJsonEntry(valModule, url);
255
261
  }
256
262
  if (content === undefined) {
257
263
  return null;
258
264
  }
259
265
  return stega.stegaEncode(content, {
260
266
  disabled: !valOverlayContext.draftMode,
261
- root: routeFromVal.getJsonEntryStegaRoot(selector, url)
267
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
262
268
  });
263
269
  }
264
270
  var route = routeFromVal.initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
265
271
  return route;
266
272
  }
267
273
  function useValRouteUrl(selector, params) {
268
- var val = useValStega(selector);
274
+ // A view is a pointer: everything below reads a path, a schema and a source
275
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
276
+ var valModule = core.Internal.resolveViewedModule(selector);
277
+ var val = useValStega(valModule);
269
278
  var resolvedParams = params === undefined ? undefined : resolveParams(params);
270
279
  // Careful: null means there was an error - undefined means no params
271
280
  if (resolvedParams === null) {
272
281
  return null;
273
282
  }
274
- var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", selector && core.Internal.getValPath(selector), selector && core.Internal.getSchema(selector), val);
283
+ var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && core.Internal.getValPath(valModule), valModule && core.Internal.getSchema(valModule), val);
275
284
  return route;
276
285
  }
277
286
 
@@ -16,6 +16,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
16
16
 
17
17
  var React__default = /*#__PURE__*/_interopDefault(React);
18
18
 
19
+ /** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
20
+
19
21
  function useValStega(selector) {
20
22
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
21
23
  var moduleIds = React__default["default"].useMemo(function () {
@@ -141,8 +143,6 @@ function draftJsonEntry(draftSource, key) {
141
143
  };
142
144
  }
143
145
 
144
- // The (loosened) content type a single `.jsonValues()` entry resolves to.
145
-
146
146
  // Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
147
147
  // stable promise across renders (keyed by module path + entry key).
148
148
  var jsonEntryPromiseCache = new Map();
@@ -159,7 +159,10 @@ var jsonEntryPromiseCache = new Map();
159
159
  */
160
160
  function useValKeyStega(selector, key) {
161
161
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
162
- var moduleFilePath = selector && core.Internal.getValPath(selector);
162
+ // A view is a pointer: everything below reads a path, a schema and a source
163
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
164
+ var valModule = core.Internal.resolveViewedModule(selector);
165
+ var moduleFilePath = valModule && core.Internal.getValPath(valModule);
163
166
  var draftSource = useDraftModuleSource(moduleFilePath || undefined);
164
167
  var draft = draftJsonEntry(draftSource, key);
165
168
  if (draft.status === "absent") {
@@ -169,11 +172,11 @@ function useValKeyStega(selector, key) {
169
172
  }
170
173
  var content = draft.status === "content" ? draft.content : undefined;
171
174
  if (content === undefined) {
172
- content = readCommittedJsonEntry(selector, key);
175
+ content = readCommittedJsonEntry(valModule, key);
173
176
  }
174
177
  return stega.stegaEncode(content, {
175
178
  disabled: !valOverlayContext.draftMode,
176
- root: routeFromVal.getJsonEntryStegaRoot(selector, key)
179
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
177
180
  });
178
181
  }
179
182
 
@@ -224,22 +227,25 @@ function resolveParams(params) {
224
227
  }
225
228
  function useValRouteStega(selector, params) {
226
229
  var valOverlayContext = ValOverlayContext.useValOverlayContext();
230
+ // A view is a pointer: everything below reads a path, a schema and a source
231
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
232
+ var valModule = core.Internal.resolveViewedModule(selector);
227
233
  // Both called unconditionally to keep hook order stable. For a `.jsonValues()`
228
234
  // router `val` is unused (we resolve a single entry below instead); for any
229
235
  // other router `draftSource` is.
230
- var val = useValStega(selector);
231
- var draftSource = useDraftModuleSource(selector && core.Internal.getValPath(selector) || undefined);
236
+ var val = useValStega(valModule);
237
+ var draftSource = useDraftModuleSource(valModule && core.Internal.getValPath(valModule) || undefined);
232
238
  var resolvedParams = resolveParams(params);
233
239
  // Careful: null means there was an error - undefined means no params
234
240
  if (resolvedParams === null) {
235
241
  return null;
236
242
  }
237
- var path = selector && core.Internal.getValPath(selector);
238
- var schema = selector && core.Internal.getSchema(selector);
243
+ var path = valModule && core.Internal.getValPath(valModule);
244
+ var schema = valModule && core.Internal.getSchema(valModule);
239
245
  // `.jsonValues()` router: map params → the entry key and load ONLY that
240
246
  // entry's backing `*.val.json` (one dynamic import), like `useValKey`.
241
247
  if (routeFromVal.isJsonValuesRecordSchema(schema)) {
242
- var source = selector && core.Internal.getSource(selector);
248
+ var source = valModule && core.Internal.getSource(valModule);
243
249
  var url = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
244
250
  if (!url) {
245
251
  return null;
@@ -251,27 +257,30 @@ function useValRouteStega(selector, params) {
251
257
  }
252
258
  var content = draft.status === "content" ? draft.content : undefined;
253
259
  if (content === undefined) {
254
- content = readCommittedJsonEntry(selector, url);
260
+ content = readCommittedJsonEntry(valModule, url);
255
261
  }
256
262
  if (content === undefined) {
257
263
  return null;
258
264
  }
259
265
  return stega.stegaEncode(content, {
260
266
  disabled: !valOverlayContext.draftMode,
261
- root: routeFromVal.getJsonEntryStegaRoot(selector, url)
267
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
262
268
  });
263
269
  }
264
270
  var route = routeFromVal.initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
265
271
  return route;
266
272
  }
267
273
  function useValRouteUrl(selector, params) {
268
- var val = useValStega(selector);
274
+ // A view is a pointer: everything below reads a path, a schema and a source
275
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
276
+ var valModule = core.Internal.resolveViewedModule(selector);
277
+ var val = useValStega(valModule);
269
278
  var resolvedParams = params === undefined ? undefined : resolveParams(params);
270
279
  // Careful: null means there was an error - undefined means no params
271
280
  if (resolvedParams === null) {
272
281
  return null;
273
282
  }
274
- var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", selector && core.Internal.getValPath(selector), selector && core.Internal.getSchema(selector), val);
283
+ var route = routeFromVal.getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && core.Internal.getValPath(valModule), valModule && core.Internal.getSchema(valModule), val);
275
284
  return route;
276
285
  }
277
286
 
@@ -8,6 +8,8 @@ import '@valbuild/shared/client';
8
8
  import '@valbuild/core/patch';
9
9
  import 'react/jsx-runtime';
10
10
 
11
+ /** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
12
+
11
13
  function useValStega(selector) {
12
14
  var valOverlayContext = useValOverlayContext();
13
15
  var moduleIds = React.useMemo(function () {
@@ -133,8 +135,6 @@ function draftJsonEntry(draftSource, key) {
133
135
  };
134
136
  }
135
137
 
136
- // The (loosened) content type a single `.jsonValues()` entry resolves to.
137
-
138
138
  // Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
139
139
  // stable promise across renders (keyed by module path + entry key).
140
140
  var jsonEntryPromiseCache = new Map();
@@ -151,7 +151,10 @@ var jsonEntryPromiseCache = new Map();
151
151
  */
152
152
  function useValKeyStega(selector, key) {
153
153
  var valOverlayContext = useValOverlayContext();
154
- var moduleFilePath = selector && Internal.getValPath(selector);
154
+ // A view is a pointer: everything below reads a path, a schema and a source
155
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
156
+ var valModule = Internal.resolveViewedModule(selector);
157
+ var moduleFilePath = valModule && Internal.getValPath(valModule);
155
158
  var draftSource = useDraftModuleSource(moduleFilePath || undefined);
156
159
  var draft = draftJsonEntry(draftSource, key);
157
160
  if (draft.status === "absent") {
@@ -161,11 +164,11 @@ function useValKeyStega(selector, key) {
161
164
  }
162
165
  var content = draft.status === "content" ? draft.content : undefined;
163
166
  if (content === undefined) {
164
- content = readCommittedJsonEntry(selector, key);
167
+ content = readCommittedJsonEntry(valModule, key);
165
168
  }
166
169
  return stegaEncode(content, {
167
170
  disabled: !valOverlayContext.draftMode,
168
- root: getJsonEntryStegaRoot(selector, key)
171
+ root: getJsonEntryStegaRoot(valModule, key)
169
172
  });
170
173
  }
171
174
 
@@ -216,22 +219,25 @@ function resolveParams(params) {
216
219
  }
217
220
  function useValRouteStega(selector, params) {
218
221
  var valOverlayContext = useValOverlayContext();
222
+ // A view is a pointer: everything below reads a path, a schema and a source
223
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
224
+ var valModule = Internal.resolveViewedModule(selector);
219
225
  // Both called unconditionally to keep hook order stable. For a `.jsonValues()`
220
226
  // router `val` is unused (we resolve a single entry below instead); for any
221
227
  // other router `draftSource` is.
222
- var val = useValStega(selector);
223
- var draftSource = useDraftModuleSource(selector && Internal.getValPath(selector) || undefined);
228
+ var val = useValStega(valModule);
229
+ var draftSource = useDraftModuleSource(valModule && Internal.getValPath(valModule) || undefined);
224
230
  var resolvedParams = resolveParams(params);
225
231
  // Careful: null means there was an error - undefined means no params
226
232
  if (resolvedParams === null) {
227
233
  return null;
228
234
  }
229
- var path = selector && Internal.getValPath(selector);
230
- var schema = selector && Internal.getSchema(selector);
235
+ var path = valModule && Internal.getValPath(valModule);
236
+ var schema = valModule && Internal.getSchema(valModule);
231
237
  // `.jsonValues()` router: map params → the entry key and load ONLY that
232
238
  // entry's backing `*.val.json` (one dynamic import), like `useValKey`.
233
239
  if (isJsonValuesRecordSchema(schema)) {
234
- var source = selector && Internal.getSource(selector);
240
+ var source = valModule && Internal.getSource(valModule);
235
241
  var url = getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
236
242
  if (!url) {
237
243
  return null;
@@ -243,27 +249,30 @@ function useValRouteStega(selector, params) {
243
249
  }
244
250
  var content = draft.status === "content" ? draft.content : undefined;
245
251
  if (content === undefined) {
246
- content = readCommittedJsonEntry(selector, url);
252
+ content = readCommittedJsonEntry(valModule, url);
247
253
  }
248
254
  if (content === undefined) {
249
255
  return null;
250
256
  }
251
257
  return stegaEncode(content, {
252
258
  disabled: !valOverlayContext.draftMode,
253
- root: getJsonEntryStegaRoot(selector, url)
259
+ root: getJsonEntryStegaRoot(valModule, url)
254
260
  });
255
261
  }
256
262
  var route = initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
257
263
  return route;
258
264
  }
259
265
  function useValRouteUrl(selector, params) {
260
- var val = useValStega(selector);
266
+ // A view is a pointer: everything below reads a path, a schema and a source
267
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
268
+ var valModule = Internal.resolveViewedModule(selector);
269
+ var val = useValStega(valModule);
261
270
  var resolvedParams = params === undefined ? undefined : resolveParams(params);
262
271
  // Careful: null means there was an error - undefined means no params
263
272
  if (resolvedParams === null) {
264
273
  return null;
265
274
  }
266
- var route = getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", selector && Internal.getValPath(selector), selector && Internal.getSchema(selector), val);
275
+ var route = getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && Internal.getValPath(valModule), valModule && Internal.getSchema(valModule), val);
267
276
  return route;
268
277
  }
269
278
 
@@ -1,9 +1,9 @@
1
- import { GenericSelector, JsonSource, SelectorOf, SelectorSource, SourceObject, ValModule } from "@valbuild/core";
2
- import { StegaOfSource } from "@valbuild/react/stega";
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
- export type UseValType<T extends SelectorSource> = SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never;
5
- declare function useValStega<T extends SelectorSource>(selector: T): UseValType<T>;
6
- 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;
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 ValModule<GenericSelector<SourceObject>>>(selector: T, key: string): JsonEntryContentOf<T> | undefined;
18
- type UseValRouteReturnType<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;
19
- declare function useValRouteStega<T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): UseValRouteReturnType<T>;
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 StegaOfSource } from "@valbuild/react/stega";
2
- import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject, JsonSource } from "@valbuild/core";
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 { ValServer, type ValPatchStore } from "@valbuild/server";
4
4
  import { type ValDraftMode } from "./valDraftMode.js";
5
5
  import type { ValHttpMode } from "./initValServer.js";
@@ -10,8 +10,7 @@ declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, va
10
10
  name: string;
11
11
  value: string;
12
12
  } | undefined;
13
- }>) => <T extends SelectorSource>(selector: T) => Promise<SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never>;
14
- 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;
13
+ }>) => <T extends Resolvable>(selector: T) => Promise<ResolvedVal<T>>;
15
14
  declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
16
15
  get(name: string): string | null;
17
16
  }>, getCookies: () => Promise<{
@@ -19,7 +18,7 @@ declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: strin
19
18
  name: string;
20
19
  value: string;
21
20
  } | undefined;
22
- }>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<FetchValRouteReturnType<T>>;
21
+ }>) => <T extends ResolvableModule>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<RouteValueOf<T>>;
23
22
  /**
24
23
  * Loads a single `.jsonValues()` entry's DRAFT content via the in-process
25
24
  * `/json` endpoint (which replays pending patches). Returns `undefined` when the
@@ -60,7 +59,6 @@ export type DraftJsonEntry = {
60
59
  * a null/undefined result.
61
60
  */
62
61
  export declare function resolveDraftOrCommittedEntry(draft: DraftJsonEntry, loadCommitted: () => Promise<unknown | undefined>): Promise<unknown | undefined>;
63
- 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;
64
62
  /**
65
63
  * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
66
64
  * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
@@ -77,7 +75,7 @@ export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryV
77
75
  name: string;
78
76
  value: string;
79
77
  } | undefined;
80
- }>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
78
+ }>) => <T extends ResolvableModule>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
81
79
  declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
82
80
  get(name: string): string | null;
83
81
  }>, getCookies: () => Promise<{
@@ -85,7 +83,7 @@ declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string,
85
83
  name: string;
86
84
  value: string;
87
85
  } | undefined;
88
- }>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<string | null>;
86
+ }>) => <T extends ResolvableModule>(selector: T, params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<string | null>;
89
87
  /**
90
88
  * Val's content readers for the server side of a TanStack Start app.
91
89
  *
@@ -20,13 +20,19 @@ export type ValHttpMode = {
20
20
  * service is the store of record: it mints its own commit shas and knows the
21
21
  * project's branch, so there is nothing to bake into the build.
22
22
  *
23
- * Where there is one: `commit` is the commit the running code was built
23
+ * Where there is one: `gitCommit` is the commit the running code was built
24
24
  * from, and it is load bearing. See the note at the use.
25
+ *
26
+ * The same two names `val.config.ts` and `ValApiOptions` use, and flat for
27
+ * the same reason: a platform hands these over as
28
+ * `process.env.VERCEL_GIT_COMMIT_SHA` and friends, typed
29
+ * `string | undefined`, and two optional strings take that as it comes
30
+ * rather than making every caller write a ternary to build an object.
31
+ *
32
+ * Taken together or not at all -- one without the other is refused.
25
33
  */
26
- git?: {
27
- commit: string;
28
- branch: string;
29
- };
34
+ gitCommit?: string;
35
+ gitBranch?: string;
30
36
  /**
31
37
  * Val's content service, when it is not the real one.
32
38
  *
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-8deeac5f.cjs.dev.js');
5
+ var version = require('./version-dbd88542.cjs.dev.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-e75681d7.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-7d59b1f2.cjs.prod.js');
5
+ var version = require('./version-9bae6ba4.cjs.prod.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-0324e063.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-ed8bd465.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-74f8b5ce.esm.js';
2
2
  import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper } from './createForOfIteratorHelper-485c2ce1.esm.js';
3
3
  import { Internal as Internal$1, initVal as initVal$1, DEFAULT_CONTENT_HOST } from '@valbuild/core';
4
4
  import * as core from '@valbuild/core';
@@ -210,7 +210,7 @@ var packageJson = {
210
210
  "tanstack-router",
211
211
  "react"
212
212
  ],
213
- version: "0.133.0",
213
+ version: "0.134.1",
214
214
  scripts: {
215
215
  typecheck: "tsc --noEmit",
216
216
  test: "jest"
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.133.0",
215
+ version: "0.134.1",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.133.0",
215
+ version: "0.134.1",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "tanstack-router",
15
15
  "react"
16
16
  ],
17
- "version": "0.133.0",
17
+ "version": "0.134.1",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -42,13 +42,13 @@
42
42
  "exports": true
43
43
  },
44
44
  "dependencies": {
45
- "@valbuild/core": "0.130.0",
46
- "@valbuild/language-server": "0.133.0",
47
- "@valbuild/mcp": "0.133.0",
48
- "@valbuild/react": "0.133.0",
49
- "@valbuild/server": "0.133.0",
50
- "@valbuild/shared": "0.133.0",
51
- "@valbuild/ui": "0.133.0"
45
+ "@valbuild/core": "0.134.0",
46
+ "@valbuild/mcp": "0.134.1",
47
+ "@valbuild/react": "0.134.1",
48
+ "@valbuild/server": "0.134.1",
49
+ "@valbuild/language-server": "0.134.1",
50
+ "@valbuild/shared": "0.134.1",
51
+ "@valbuild/ui": "0.134.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@tanstack/react-router": "^1.170.33",
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-8deeac5f.cjs.dev.js');
5
+ var version = require('../../dist/version-dbd88542.cjs.dev.js');
6
6
  var core = require('@valbuild/core');
7
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-e75681d7.cjs.dev.js');
8
8
  var server = require('@valbuild/server');
@@ -506,7 +506,7 @@ function getHost(headers) {
506
506
  var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
507
507
  return /*#__PURE__*/function () {
508
508
  var _ref2 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee2(selector, params) {
509
- var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
509
+ var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
510
510
  return version._regenerator().w(function (_context2) {
511
511
  while (1) switch (_context2.p = _context2.n) {
512
512
  case 0:
@@ -514,15 +514,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
514
514
  return Promise.resolve(params);
515
515
  case 1:
516
516
  resolvedParams = _context2.v;
517
- path = selector && core.Internal.getValPath(selector);
518
- schema = selector && core.Internal.getSchema(selector); // `.jsonValues()` router: map params → the entry key and load ONLY that
517
+ // A view is a pointer: everything below reads a path, a schema and a source
518
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
519
+ valModule = core.Internal.resolveViewedModule(selector);
520
+ path = valModule && core.Internal.getValPath(valModule);
521
+ schema = valModule && core.Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
519
522
  // entry's backing `*.val.json`, instead of eagerly resolving the whole
520
523
  // record via `fetchVal`.
521
524
  if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
522
525
  _context2.n = 11;
523
526
  break;
524
527
  }
525
- source = selector && core.Internal.getSource(selector);
528
+ source = valModule && core.Internal.getSource(valModule);
526
529
  url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
527
530
  if (url) {
528
531
  _context2.n = 2;
@@ -569,17 +572,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
569
572
  case 10:
570
573
  return _context2.a(2, stega.stegaEncode(content, {
571
574
  disabled: !enabled,
572
- root: routeFromVal.getJsonEntryStegaRoot(selector, url)
575
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
573
576
  }));
574
577
  case 11:
575
578
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
576
- _t5 = selector;
579
+ _t5 = valModule;
577
580
  if (!_t5) {
578
581
  _context2.n = 13;
579
582
  break;
580
583
  }
581
584
  _context2.n = 12;
582
- return fetchVal(selector);
585
+ return fetchVal(valModule);
583
586
  case 12:
584
587
  _t5 = _context2.v;
585
588
  case 13:
@@ -696,7 +699,18 @@ function _resolveDraftOrCommittedEntry() {
696
699
  }
697
700
  function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
698
701
  return _loadDraftJsonEntry.apply(this, arguments);
699
- } // The (loosened) content type a single `.jsonValues()` entry resolves to.
702
+ }
703
+ /**
704
+ * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
705
+ * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
706
+ *
707
+ * Production (Val disabled): resolves the entry's lazy import thunk from the
708
+ * locally-bundled module. One dynamic import, no server round-trip.
709
+ *
710
+ * Enabled (draft mode): reads the entry through `/json`, which replays pending
711
+ * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
712
+ * the draft read yields nothing.
713
+ */
700
714
  function _loadDraftJsonEntry() {
701
715
  _loadDraftJsonEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee7(valServerPromise, getCookies, moduleFilePath, key) {
702
716
  var _cookies3;
@@ -781,21 +795,10 @@ function _loadDraftJsonEntry() {
781
795
  }));
782
796
  return _loadDraftJsonEntry.apply(this, arguments);
783
797
  }
784
- /**
785
- * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
786
- * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
787
- *
788
- * Production (Val disabled): resolves the entry's lazy import thunk from the
789
- * locally-bundled module. One dynamic import, no server round-trip.
790
- *
791
- * Enabled (draft mode): reads the entry through `/json`, which replays pending
792
- * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
793
- * the draft read yields nothing.
794
- */
795
798
  var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
796
799
  return /*#__PURE__*/function () {
797
800
  var _ref3 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3(selector, key) {
798
- var enabled, source, moduleFilePath, draft, content;
801
+ var enabled, valModule, source, moduleFilePath, draft, content;
799
802
  return version._regenerator().w(function (_context3) {
800
803
  while (1) switch (_context3.p = _context3.n) {
801
804
  case 0:
@@ -811,8 +814,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
811
814
  _context3.p = 3;
812
815
  _context3.v;
813
816
  case 4:
814
- source = selector && core.Internal.getSource(selector);
815
- moduleFilePath = selector && core.Internal.getValPath(selector);
817
+ // A view is a pointer: everything below reads a path and a source off this,
818
+ // and a pointer has neither. See `resolveViewedModule`.
819
+ valModule = core.Internal.resolveViewedModule(selector);
820
+ source = valModule && core.Internal.getSource(valModule);
821
+ moduleFilePath = valModule && core.Internal.getValPath(valModule);
816
822
  draft = {
817
823
  status: "unavailable"
818
824
  };
@@ -840,7 +846,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
840
846
  case 8:
841
847
  return _context3.a(2, stega.stegaEncode(content, {
842
848
  disabled: !enabled,
843
- root: routeFromVal.getJsonEntryStegaRoot(selector, key)
849
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
844
850
  }));
845
851
  }
846
852
  }, _callee3, null, [[1, 3]]);
@@ -853,7 +859,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
853
859
  var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
854
860
  return /*#__PURE__*/function () {
855
861
  var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, params) {
856
- var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
862
+ var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
857
863
  return version._regenerator().w(function (_context4) {
858
864
  while (1) switch (_context4.n) {
859
865
  case 0:
@@ -872,15 +878,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
872
878
  _t7 = _context4.v;
873
879
  case 3:
874
880
  resolvedParams = _t7;
875
- path = selector && core.Internal.getValPath(selector);
876
- schema = selector && core.Internal.getSchema(selector);
877
- _t8 = selector;
881
+ // A view is a pointer: everything below reads a path, a schema and a source
882
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
883
+ valModule = core.Internal.resolveViewedModule(selector);
884
+ path = valModule && core.Internal.getValPath(valModule);
885
+ schema = valModule && core.Internal.getSchema(valModule);
886
+ _t8 = valModule;
878
887
  if (!_t8) {
879
888
  _context4.n = 5;
880
889
  break;
881
890
  }
882
891
  _context4.n = 4;
883
- return fetchVal(selector);
892
+ return fetchVal(valModule);
884
893
  case 4:
885
894
  _t8 = _context4.v;
886
895
  case 5:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-7d59b1f2.cjs.prod.js');
5
+ var version = require('../../dist/version-9bae6ba4.cjs.prod.js');
6
6
  var core = require('@valbuild/core');
7
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-0324e063.cjs.prod.js');
8
8
  var server = require('@valbuild/server');
@@ -506,7 +506,7 @@ function getHost(headers) {
506
506
  var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
507
507
  return /*#__PURE__*/function () {
508
508
  var _ref2 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee2(selector, params) {
509
- var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
509
+ var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
510
510
  return version._regenerator().w(function (_context2) {
511
511
  while (1) switch (_context2.p = _context2.n) {
512
512
  case 0:
@@ -514,15 +514,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
514
514
  return Promise.resolve(params);
515
515
  case 1:
516
516
  resolvedParams = _context2.v;
517
- path = selector && core.Internal.getValPath(selector);
518
- schema = selector && core.Internal.getSchema(selector); // `.jsonValues()` router: map params → the entry key and load ONLY that
517
+ // A view is a pointer: everything below reads a path, a schema and a source
518
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
519
+ valModule = core.Internal.resolveViewedModule(selector);
520
+ path = valModule && core.Internal.getValPath(valModule);
521
+ schema = valModule && core.Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
519
522
  // entry's backing `*.val.json`, instead of eagerly resolving the whole
520
523
  // record via `fetchVal`.
521
524
  if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
522
525
  _context2.n = 11;
523
526
  break;
524
527
  }
525
- source = selector && core.Internal.getSource(selector);
528
+ source = valModule && core.Internal.getSource(valModule);
526
529
  url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
527
530
  if (url) {
528
531
  _context2.n = 2;
@@ -569,17 +572,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
569
572
  case 10:
570
573
  return _context2.a(2, stega.stegaEncode(content, {
571
574
  disabled: !enabled,
572
- root: routeFromVal.getJsonEntryStegaRoot(selector, url)
575
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
573
576
  }));
574
577
  case 11:
575
578
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
576
- _t5 = selector;
579
+ _t5 = valModule;
577
580
  if (!_t5) {
578
581
  _context2.n = 13;
579
582
  break;
580
583
  }
581
584
  _context2.n = 12;
582
- return fetchVal(selector);
585
+ return fetchVal(valModule);
583
586
  case 12:
584
587
  _t5 = _context2.v;
585
588
  case 13:
@@ -696,7 +699,18 @@ function _resolveDraftOrCommittedEntry() {
696
699
  }
697
700
  function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
698
701
  return _loadDraftJsonEntry.apply(this, arguments);
699
- } // The (loosened) content type a single `.jsonValues()` entry resolves to.
702
+ }
703
+ /**
704
+ * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
705
+ * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
706
+ *
707
+ * Production (Val disabled): resolves the entry's lazy import thunk from the
708
+ * locally-bundled module. One dynamic import, no server round-trip.
709
+ *
710
+ * Enabled (draft mode): reads the entry through `/json`, which replays pending
711
+ * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
712
+ * the draft read yields nothing.
713
+ */
700
714
  function _loadDraftJsonEntry() {
701
715
  _loadDraftJsonEntry = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee7(valServerPromise, getCookies, moduleFilePath, key) {
702
716
  var _cookies3;
@@ -781,21 +795,10 @@ function _loadDraftJsonEntry() {
781
795
  }));
782
796
  return _loadDraftJsonEntry.apply(this, arguments);
783
797
  }
784
- /**
785
- * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
786
- * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
787
- *
788
- * Production (Val disabled): resolves the entry's lazy import thunk from the
789
- * locally-bundled module. One dynamic import, no server round-trip.
790
- *
791
- * Enabled (draft mode): reads the entry through `/json`, which replays pending
792
- * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
793
- * the draft read yields nothing.
794
- */
795
798
  var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
796
799
  return /*#__PURE__*/function () {
797
800
  var _ref3 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee3(selector, key) {
798
- var enabled, source, moduleFilePath, draft, content;
801
+ var enabled, valModule, source, moduleFilePath, draft, content;
799
802
  return version._regenerator().w(function (_context3) {
800
803
  while (1) switch (_context3.p = _context3.n) {
801
804
  case 0:
@@ -811,8 +814,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
811
814
  _context3.p = 3;
812
815
  _context3.v;
813
816
  case 4:
814
- source = selector && core.Internal.getSource(selector);
815
- moduleFilePath = selector && core.Internal.getValPath(selector);
817
+ // A view is a pointer: everything below reads a path and a source off this,
818
+ // and a pointer has neither. See `resolveViewedModule`.
819
+ valModule = core.Internal.resolveViewedModule(selector);
820
+ source = valModule && core.Internal.getSource(valModule);
821
+ moduleFilePath = valModule && core.Internal.getValPath(valModule);
816
822
  draft = {
817
823
  status: "unavailable"
818
824
  };
@@ -840,7 +846,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
840
846
  case 8:
841
847
  return _context3.a(2, stega.stegaEncode(content, {
842
848
  disabled: !enabled,
843
- root: routeFromVal.getJsonEntryStegaRoot(selector, key)
849
+ root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
844
850
  }));
845
851
  }
846
852
  }, _callee3, null, [[1, 3]]);
@@ -853,7 +859,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
853
859
  var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
854
860
  return /*#__PURE__*/function () {
855
861
  var _ref4 = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee4(selector, params) {
856
- var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
862
+ var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
857
863
  return version._regenerator().w(function (_context4) {
858
864
  while (1) switch (_context4.n) {
859
865
  case 0:
@@ -872,15 +878,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
872
878
  _t7 = _context4.v;
873
879
  case 3:
874
880
  resolvedParams = _t7;
875
- path = selector && core.Internal.getValPath(selector);
876
- schema = selector && core.Internal.getSchema(selector);
877
- _t8 = selector;
881
+ // A view is a pointer: everything below reads a path, a schema and a source
882
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
883
+ valModule = core.Internal.resolveViewedModule(selector);
884
+ path = valModule && core.Internal.getValPath(valModule);
885
+ schema = valModule && core.Internal.getSchema(valModule);
886
+ _t8 = valModule;
878
887
  if (!_t8) {
879
888
  _context4.n = 5;
880
889
  break;
881
890
  }
882
891
  _context4.n = 4;
883
- return fetchVal(selector);
892
+ return fetchVal(valModule);
884
893
  case 4:
885
894
  _t8 = _context4.v;
886
895
  case 5:
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-ed8bd465.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-74f8b5ce.esm.js';
2
2
  import { Internal } from '@valbuild/core';
3
3
  import { _ as _objectSpread2, a as _slicedToArray, d as _defineProperty } from '../../dist/createForOfIteratorHelper-485c2ce1.esm.js';
4
4
  import { createValApiRouter, createValServer } from '@valbuild/server';
@@ -485,7 +485,7 @@ function getHost(headers) {
485
485
  var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
486
486
  return /*#__PURE__*/function () {
487
487
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(selector, params) {
488
- var resolvedParams, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
488
+ var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t5;
489
489
  return _regenerator().w(function (_context2) {
490
490
  while (1) switch (_context2.p = _context2.n) {
491
491
  case 0:
@@ -493,15 +493,18 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
493
493
  return Promise.resolve(params);
494
494
  case 1:
495
495
  resolvedParams = _context2.v;
496
- path = selector && Internal.getValPath(selector);
497
- schema = selector && Internal.getSchema(selector); // `.jsonValues()` router: map params → the entry key and load ONLY that
496
+ // A view is a pointer: everything below reads a path, a schema and a source
497
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
498
+ valModule = Internal.resolveViewedModule(selector);
499
+ path = valModule && Internal.getValPath(valModule);
500
+ schema = valModule && Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
498
501
  // entry's backing `*.val.json`, instead of eagerly resolving the whole
499
502
  // record via `fetchVal`.
500
503
  if (!isJsonValuesRecordSchema(schema)) {
501
504
  _context2.n = 11;
502
505
  break;
503
506
  }
504
- source = selector && Internal.getSource(selector);
507
+ source = valModule && Internal.getSource(valModule);
505
508
  url = getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
506
509
  if (url) {
507
510
  _context2.n = 2;
@@ -548,17 +551,17 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
548
551
  case 10:
549
552
  return _context2.a(2, stegaEncode(content, {
550
553
  disabled: !enabled,
551
- root: getJsonEntryStegaRoot(selector, url)
554
+ root: getJsonEntryStegaRoot(valModule, url)
552
555
  }));
553
556
  case 11:
554
557
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
555
- _t5 = selector;
558
+ _t5 = valModule;
556
559
  if (!_t5) {
557
560
  _context2.n = 13;
558
561
  break;
559
562
  }
560
563
  _context2.n = 12;
561
- return fetchVal(selector);
564
+ return fetchVal(valModule);
562
565
  case 12:
563
566
  _t5 = _context2.v;
564
567
  case 13:
@@ -675,7 +678,18 @@ function _resolveDraftOrCommittedEntry() {
675
678
  }
676
679
  function loadDraftJsonEntry(_x7, _x8, _x9, _x0) {
677
680
  return _loadDraftJsonEntry.apply(this, arguments);
678
- } // The (loosened) content type a single `.jsonValues()` entry resolves to.
681
+ }
682
+ /**
683
+ * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
684
+ * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
685
+ *
686
+ * Production (Val disabled): resolves the entry's lazy import thunk from the
687
+ * locally-bundled module. One dynamic import, no server round-trip.
688
+ *
689
+ * Enabled (draft mode): reads the entry through `/json`, which replays pending
690
+ * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
691
+ * the draft read yields nothing.
692
+ */
679
693
  function _loadDraftJsonEntry() {
680
694
  _loadDraftJsonEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(valServerPromise, getCookies, moduleFilePath, key) {
681
695
  var _cookies3;
@@ -760,21 +774,10 @@ function _loadDraftJsonEntry() {
760
774
  }));
761
775
  return _loadDraftJsonEntry.apply(this, arguments);
762
776
  }
763
- /**
764
- * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
765
- * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
766
- *
767
- * Production (Val disabled): resolves the entry's lazy import thunk from the
768
- * locally-bundled module. One dynamic import, no server round-trip.
769
- *
770
- * Enabled (draft mode): reads the entry through `/json`, which replays pending
771
- * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
772
- * the draft read yields nothing.
773
- */
774
777
  var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
775
778
  return /*#__PURE__*/function () {
776
779
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(selector, key) {
777
- var enabled, source, moduleFilePath, draft, content;
780
+ var enabled, valModule, source, moduleFilePath, draft, content;
778
781
  return _regenerator().w(function (_context3) {
779
782
  while (1) switch (_context3.p = _context3.n) {
780
783
  case 0:
@@ -790,8 +793,11 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
790
793
  _context3.p = 3;
791
794
  _context3.v;
792
795
  case 4:
793
- source = selector && Internal.getSource(selector);
794
- moduleFilePath = selector && Internal.getValPath(selector);
796
+ // A view is a pointer: everything below reads a path and a source off this,
797
+ // and a pointer has neither. See `resolveViewedModule`.
798
+ valModule = Internal.resolveViewedModule(selector);
799
+ source = valModule && Internal.getSource(valModule);
800
+ moduleFilePath = valModule && Internal.getValPath(valModule);
795
801
  draft = {
796
802
  status: "unavailable"
797
803
  };
@@ -819,7 +825,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
819
825
  case 8:
820
826
  return _context3.a(2, stegaEncode(content, {
821
827
  disabled: !enabled,
822
- root: getJsonEntryStegaRoot(selector, key)
828
+ root: getJsonEntryStegaRoot(valModule, key)
823
829
  }));
824
830
  }
825
831
  }, _callee3, null, [[1, 3]]);
@@ -832,7 +838,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
832
838
  var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
833
839
  return /*#__PURE__*/function () {
834
840
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(selector, params) {
835
- var fetchVal, resolvedParams, path, schema, val, route, _t7, _t8;
841
+ var fetchVal, resolvedParams, valModule, path, schema, val, route, _t7, _t8;
836
842
  return _regenerator().w(function (_context4) {
837
843
  while (1) switch (_context4.n) {
838
844
  case 0:
@@ -851,15 +857,18 @@ var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints
851
857
  _t7 = _context4.v;
852
858
  case 3:
853
859
  resolvedParams = _t7;
854
- path = selector && Internal.getValPath(selector);
855
- schema = selector && Internal.getSchema(selector);
856
- _t8 = selector;
860
+ // A view is a pointer: everything below reads a path, a schema and a source
861
+ // off this, and a pointer has none of them. See `resolveViewedModule`.
862
+ valModule = Internal.resolveViewedModule(selector);
863
+ path = valModule && Internal.getValPath(valModule);
864
+ schema = valModule && Internal.getSchema(valModule);
865
+ _t8 = valModule;
857
866
  if (!_t8) {
858
867
  _context4.n = 5;
859
868
  break;
860
869
  }
861
870
  _context4.n = 4;
862
- return fetchVal(selector);
871
+ return fetchVal(valModule);
863
872
  case 4:
864
873
  _t8 = _context4.v;
865
874
  case 5: