@valbuild/shared 0.123.3 → 0.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,136 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.125.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#638](https://github.com/valbuild/val/pull/638) [`c390397`](https://github.com/valbuild/val/commit/c390397cb5e203eb1bedae3a6fab15726e850b90) Thanks [@freekh](https://github.com/freekh)! - Val now runs on TanStack Start.
8
+
9
+ `@valbuild/tanstack` is a new package with everything `@valbuild/next` has: Val
10
+ Studio at `/val`, the on-page overlay and canvas, draft mode, the client hooks,
11
+ server-side content reads, images, and the MCP tools.
12
+
13
+ ```sh
14
+ npm install @valbuild/tanstack
15
+ ```
16
+
17
+ ```ts
18
+ // val.config.ts
19
+ import { initVal } from "@valbuild/tanstack";
20
+ const { s, c, config, tanstackRouter } = initVal({ project: "org/project" });
21
+ ```
22
+
23
+ **Routes are first class.** A Val module for a route is named after the route
24
+ file it sits beside — `src/routes/posts.$postId.tsx` is served content by
25
+ `src/routes/posts.$postId.val.ts` — and its keys are the URLs that route serves:
26
+
27
+ ```ts
28
+ export default c.define(
29
+ "/src/routes/posts.$postId.val.ts",
30
+ s.router(tanstackRouter, s.object({ title: s.string() })),
31
+ { "/posts/hello-world": { title: "Hello world" } },
32
+ );
33
+ ```
34
+
35
+ `.` and `/` both separate segments, `$param` is a parameter, `$` is a splat, and
36
+ `index`, `route`, `(groups)` and `_pathless` layouts add no URL segment — the
37
+ same rules TanStack Router uses for the route file itself. Val validates every
38
+ key against that pattern, and Val Studio shows these modules as a sitemap under
39
+ **Pages**, where an editor can add a page.
40
+
41
+ Point the route generator away from your content files, in `vite.config.ts` and
42
+ `tsr.config.json`:
43
+
44
+ ```ts
45
+ tanstackStart({ router: { routeFileIgnorePattern: "\\.val\\.[tj]sx?$" } });
46
+ ```
47
+
48
+ See the [README](https://github.com/valbuild/val/blob/main/packages/tanstack/README.md)
49
+ for the full wiring, and `examples/tanstack` for a working app.
50
+
51
+ **Also fixed, for everyone:** `Internal.VERSION.core` was `null` in any ESM
52
+ bundle — it was read with `require("../package.json")` inside a `try`, so the
53
+ failure was silent. That version goes into every remote file ref and proxy mode
54
+ refuses to start without it. Every package now reads its version through a
55
+ static JSON import, which is inlined at build time.
56
+
57
+ Two smaller fixes that came out of running the whole toolchain against a
58
+ TanStack project:
59
+
60
+ - `val versions` reports `@valbuild/tanstack`, and `val debug` writes a snapshot
61
+ that names whichever framework package the captured project actually has.
62
+ - `@valbuild/eslint-plugin` reads a `tsconfig.json` that has comments in it. A
63
+ tsconfig is JSONC, and `JSON.parse` is not — so on any project whose tsconfig
64
+ carries a comment (the TanStack starter's does) the
65
+ `module-in-val-modules` rule threw `Expected double-quoted property name in
66
+ JSON` on the first file and took the whole lint run with it.
67
+
68
+ Three fixes found by driving the Studio against a real TanStack app:
69
+
70
+ - **A draft image now loads on the page.** The source the Studio pushes to the
71
+ host page carries `patch_id` for any file whose bytes are still in a patch, so
72
+ the page asks `/api/val/files/...?patch_id=` rather than a `/public` path that
73
+ nothing has written yet. This was silent — the image just did not appear — and
74
+ it affects any page that reads media through the hooks rather than on the
75
+ server, `@valbuild/next` included.
76
+ - **A splat route no longer logs an error on every render.** TanStack returns
77
+ both `_splat` and `*` for the same parameter; Val reported the second as a
78
+ parameter it could not place in the path.
79
+ - The TanStack example and starter render a 404 page instead of throwing
80
+ `notFound()` from a component, which escaped to the error boundary and logged
81
+ `Error in renderToReadableStream` (and, with no not-found component
82
+ configured, aborted the response) on every miss.
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [[`c390397`](https://github.com/valbuild/val/commit/c390397cb5e203eb1bedae3a6fab15726e850b90)]:
87
+ - @valbuild/core@0.125.0
88
+
89
+ ## 0.124.0
90
+
91
+ ### Minor Changes
92
+
93
+ - [#639](https://github.com/valbuild/val/pull/639) [`ad7fff4`](https://github.com/valbuild/val/commit/ad7fff4cc8cea98c506cf7ff9b4e8d6e5ffa4055) Thanks [@freekh](https://github.com/freekh)! - Show `.jsonValues()` entries in the history pane
94
+
95
+ A `.jsonValues()` record keeps each entry's content in its own `*.val.json`
96
+ file; the module's own content is just markers pointing at them. The history
97
+ pane had no way to fetch those files for a past commit, so every entry rendered
98
+ as an **empty field** — which reads as "the author left this blank", about
99
+ content that was simply stored somewhere else.
100
+
101
+ Entries now load in the history pane the same way they load in the Studio: one
102
+ at a time, when you open one. A commit with a thousand support pages costs
103
+ nothing until you look at one of them.
104
+
105
+ An entry that cannot be read says so instead of rendering blank — including the
106
+ case where the key did not exist yet at that commit, which is a real answer
107
+ rather than an error.
108
+
109
+ ### Patch Changes
110
+
111
+ - [#639](https://github.com/valbuild/val/pull/639) [`ad7fff4`](https://github.com/valbuild/val/commit/ad7fff4cc8cea98c506cf7ff9b4e8d6e5ffa4055) Thanks [@freekh](https://github.com/freekh)! - Require a session to read a file from history
112
+
113
+ `GET /api/val/history/files` served a file at a given commit to anyone who
114
+ asked. It followed the reasoning of `/api/val/files`, which is deliberately
115
+ open — and neither half of that reasoning applies to it:
116
+
117
+ - `/files` stands on `patch_id` being an unguessable UUID. A **commit sha is
118
+ published** — `git log`, the GitHub UI, every pull request — so it is no
119
+ substitute for a credential.
120
+ - `/files` also _cannot_ require auth: draft images are fetched by the app's own
121
+ backend during Next image optimisation, with no cookies to send. Nothing
122
+ fetches history files server-side; both callers are the Studio, in a browser
123
+ that already holds the session.
124
+
125
+ So history files now require a session. `/files` is unchanged, and the reason
126
+ the two differ is written down in `architecture/media.md` so it is not "fixed"
127
+ in either direction later.
128
+
129
+ No action needed: the Studio sends its session cookie automatically.
130
+
131
+ - Updated dependencies [[`aa89fc2`](https://github.com/valbuild/val/commit/aa89fc26de7028b3c5a1666b99afc03b39e92769)]:
132
+ - @valbuild/core@0.124.0
133
+
3
134
  ## 0.123.3
4
135
 
5
136
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getSitemapTree = require('../../dist/getSitemapTree-a0c9a0e3.cjs.dev.js');
5
+ var getSitemapTree = require('../../dist/getSitemapTree-d1977d3e.cjs.dev.js');
6
6
  require('@valbuild/core');
7
7
 
8
8
 
@@ -12,9 +12,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
12
12
  exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
13
13
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
14
14
  exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
15
- exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
16
15
  exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
16
+ exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
17
+ exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
17
18
  exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
19
+ exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
20
+ exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
18
21
  exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
19
22
  exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
20
23
  exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getSitemapTree = require('../../dist/getSitemapTree-77b1203a.cjs.prod.js');
5
+ var getSitemapTree = require('../../dist/getSitemapTree-b320d033.cjs.prod.js');
6
6
  require('@valbuild/core');
7
7
 
8
8
 
@@ -12,9 +12,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
12
12
  exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
13
13
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
14
14
  exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
15
- exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
16
15
  exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
16
+ exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
17
+ exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
17
18
  exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
19
+ exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
20
+ exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
18
21
  exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
19
22
  exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
20
23
  exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
@@ -1,2 +1,2 @@
1
- export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSitemapTree, g as getNextAppRouterSourceFolder, j as getPatternFromModuleFilePath, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-d3e98a2e.esm.js';
1
+ export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
2
2
  import '@valbuild/core';
@@ -1329,6 +1329,80 @@ export declare const Api: {
1329
1329
  * actually mounts. A file at a fixed commit cannot change, so the response is
1330
1330
  * immutable and the browser's own cache handles flipping between commits.
1331
1331
  */
1332
+ /**
1333
+ * One `.jsonValues()` entry's content, as it was at a commit.
1334
+ *
1335
+ * The history pane's counterpart to `/json`. A `.jsonValues()` record's
1336
+ * source is only `{_type:"json"}` markers - the content is per entry, fetched
1337
+ * on demand - so without this the commit pane rendered every entry as an
1338
+ * empty field, which is a claim that the author left it blank.
1339
+ *
1340
+ * One entry per request, deliberately: the store fetches an entry when
1341
+ * something reads inside it, so a batch would mean guessing which entries the
1342
+ * pane is about to show. Authenticated for the same reasons as
1343
+ * `/history/files` below.
1344
+ */
1345
+ "/history/json": {
1346
+ GET: {
1347
+ req: {
1348
+ query: {
1349
+ commit_sha: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>;
1350
+ path: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>;
1351
+ key: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>;
1352
+ };
1353
+ cookies: {
1354
+ val_session: z.ZodOptional<z.ZodString>;
1355
+ };
1356
+ };
1357
+ res: z.ZodUnion<readonly [z.ZodObject<{
1358
+ status: z.ZodLiteral<401>;
1359
+ json: z.ZodObject<{
1360
+ message: z.ZodString;
1361
+ }, z.core.$strip>;
1362
+ }, z.core.$strip>, z.ZodObject<{
1363
+ status: z.ZodLiteral<404>;
1364
+ json: z.ZodObject<{
1365
+ message: z.ZodString;
1366
+ }, z.core.$strip>;
1367
+ }, z.core.$strip>, z.ZodObject<{
1368
+ status: z.ZodLiteral<400>;
1369
+ json: z.ZodIntersection<z.ZodObject<{
1370
+ message: z.ZodString;
1371
+ }, z.core.$strip>, z.ZodObject<{
1372
+ kind: z.ZodOptional<z.ZodString>;
1373
+ }, z.core.$strip>>;
1374
+ }, z.core.$strip>, z.ZodObject<{
1375
+ status: z.ZodLiteral<500>;
1376
+ json: z.ZodIntersection<z.ZodObject<{
1377
+ message: z.ZodString;
1378
+ }, z.core.$strip>, z.ZodObject<{
1379
+ kind: z.ZodOptional<z.ZodString>;
1380
+ }, z.core.$strip>>;
1381
+ }, z.core.$strip>, z.ZodObject<{
1382
+ status: z.ZodLiteral<200>;
1383
+ json: z.ZodObject<{
1384
+ path: z.ZodString & z.ZodType<ModuleFilePath, string, z.core.$ZodTypeInternals<ModuleFilePath, string>>;
1385
+ key: z.ZodString;
1386
+ content: z.ZodUnknown;
1387
+ }, z.core.$strip>;
1388
+ }, z.core.$strip>]>;
1389
+ };
1390
+ };
1391
+ /**
1392
+ * A binary file as it was at a commit.
1393
+ *
1394
+ * AUTHENTICATED, unlike `/files` below - and the difference is not an
1395
+ * oversight in either direction. See the comment on `/files`: what makes it
1396
+ * safe to leave open is that a `patch_id` is an unguessable UUID, and what
1397
+ * makes leaving it open NECESSARY is that a draft image is fetched by the
1398
+ * app's own backend during Next image optimisation, with no cookies.
1399
+ *
1400
+ * Neither holds here. A commit sha is published - `git log`, the GitHub UI,
1401
+ * every PR - so it is not a secret to stand in for a credential. And nothing
1402
+ * fetches these server-side: they are read by the Studio, in a browser that
1403
+ * has the session cookie, for the history pane and for staging a restore.
1404
+ * So this one asks.
1405
+ */
1332
1406
  "/history/files": {
1333
1407
  GET: {
1334
1408
  req: {
@@ -1337,6 +1411,9 @@ export declare const Api: {
1337
1411
  path: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>;
1338
1412
  remote: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
1339
1413
  };
1414
+ cookies: {
1415
+ val_session: z.ZodOptional<z.ZodString>;
1416
+ };
1340
1417
  };
1341
1418
  res: z.ZodUnion<readonly [z.ZodObject<{
1342
1419
  status: z.ZodLiteral<401>;
@@ -1,2 +1,26 @@
1
1
  import { ModuleFilePath } from "@valbuild/core";
2
2
  export declare function getNextAppRouterSourceFolder(moduleFilePath: ModuleFilePath): "/app" | "/src/app" | null;
3
+ /**
4
+ * The folder a TanStack Router app keeps its route files in.
5
+ *
6
+ * The same question as above for the other convention: `routes/` at the project
7
+ * root, or under `src/`. A Val module for a route lives beside the route file
8
+ * and is named the same way, so this is the prefix to strip before reading the
9
+ * route pattern out of the rest.
10
+ */
11
+ export declare function getTanStackRouterSourceFolder(moduleFilePath: ModuleFilePath): "/routes" | "/src/routes" | null;
12
+ /**
13
+ * The route folder of whichever page router this module belongs to.
14
+ *
15
+ * The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
16
+ * module file path answers this on its own, which is what the Studio needs: it
17
+ * walks every schema in the project and has no framework to ask.
18
+ */
19
+ export declare function getPageRouterSourceFolder(moduleFilePath: ModuleFilePath): "/app" | "/src/app" | "/routes" | "/src/routes" | null;
20
+ /**
21
+ * Whether a route folder is a TanStack Router one.
22
+ *
23
+ * Exported so the pattern derivation and the source-folder detection cannot
24
+ * drift apart about what `/src/routes` means.
25
+ */
26
+ export declare function isTanStackRoutesFolder(srcFolder: string): boolean;
@@ -23,8 +23,17 @@ export type SitemapNode = {
23
23
  moduleFilePath?: ModuleFilePath;
24
24
  sourcePath?: SourcePath | ModuleFilePath;
25
25
  };
26
- export declare function getNextAppRouterSitemapTree(srcFolder: string, paths: {
26
+ export declare function getPageRouterSitemapTree(srcFolder: string, paths: {
27
27
  urlPath: string;
28
28
  moduleFilePath: string;
29
29
  }[]): SitemapNode;
30
+ /**
31
+ * The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
32
+ *
33
+ * Written in Next's vocabulary for both routers on purpose: the pattern is read
34
+ * by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
35
+ * should have to know which framework the project uses. The TanStack branch
36
+ * translates that framework's conventions into it; see
37
+ * `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
38
+ */
30
39
  export declare function getPatternFromModuleFilePath(moduleFilePath: string, srcFolder: string): string;
@@ -1,4 +1,4 @@
1
- import { Internal } from '@valbuild/core';
1
+ import { Internal, tanStackSegmentsOfRoutePath } from '@valbuild/core';
2
2
 
3
3
  var VAL_CONFIG_SESSION_STORAGE_KEY = "val-config";
4
4
  var VAL_THEME_SESSION_STORAGE_KEY = "val-theme";
@@ -135,6 +135,45 @@ function getNextAppRouterSourceFolder(moduleFilePath) {
135
135
  return null;
136
136
  }
137
137
 
138
+ /**
139
+ * The folder a TanStack Router app keeps its route files in.
140
+ *
141
+ * The same question as above for the other convention: `routes/` at the project
142
+ * root, or under `src/`. A Val module for a route lives beside the route file
143
+ * and is named the same way, so this is the prefix to strip before reading the
144
+ * route pattern out of the rest.
145
+ */
146
+ function getTanStackRouterSourceFolder(moduleFilePath) {
147
+ if (moduleFilePath.startsWith("/routes/")) {
148
+ return "/routes";
149
+ } else if (moduleFilePath.startsWith("/src/routes/")) {
150
+ return "/src/routes";
151
+ }
152
+ return null;
153
+ }
154
+
155
+ /**
156
+ * The route folder of whichever page router this module belongs to.
157
+ *
158
+ * The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
159
+ * module file path answers this on its own, which is what the Studio needs: it
160
+ * walks every schema in the project and has no framework to ask.
161
+ */
162
+ function getPageRouterSourceFolder(moduleFilePath) {
163
+ var _getNextAppRouterSour;
164
+ return (_getNextAppRouterSour = getNextAppRouterSourceFolder(moduleFilePath)) !== null && _getNextAppRouterSour !== void 0 ? _getNextAppRouterSour : getTanStackRouterSourceFolder(moduleFilePath);
165
+ }
166
+
167
+ /**
168
+ * Whether a route folder is a TanStack Router one.
169
+ *
170
+ * Exported so the pattern derivation and the source-folder detection cannot
171
+ * drift apart about what `/src/routes` means.
172
+ */
173
+ function isTanStackRoutesFolder(srcFolder) {
174
+ return srcFolder === "/routes" || srcFolder === "/src/routes";
175
+ }
176
+
138
177
  function _toPrimitive(t, r) {
139
178
  if ("object" != typeof t || !t) return t;
140
179
  var e = t[Symbol.toPrimitive];
@@ -245,8 +284,14 @@ function _createForOfIteratorHelper(r, e) {
245
284
  };
246
285
  }
247
286
 
248
- // Strictly speaking this should be in the next package but it's shared, because we want to use it in the ui package. We want to resolve that somehow
249
- function getNextAppRouterSitemapTree(srcFolder, paths) {
287
+ // Strictly speaking this should be in the framework packages but it's shared,
288
+ // because we want to use it in the ui package. We want to resolve that somehow.
289
+ //
290
+ // It is one function for both page routers because the tree it builds is made
291
+ // of URL paths, which is the same thing in either: only `srcFolder` and the
292
+ // pattern derivation differ, and both of those are arguments (or the one call
293
+ // below).
294
+ function getPageRouterSitemapTree(srcFolder, paths) {
250
295
  var root = {
251
296
  type: "node",
252
297
  name: "/",
@@ -358,7 +403,24 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
358
403
  }
359
404
  return root;
360
405
  }
406
+
407
+ /**
408
+ * The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
409
+ *
410
+ * Written in Next's vocabulary for both routers on purpose: the pattern is read
411
+ * by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
412
+ * should have to know which framework the project uses. The TanStack branch
413
+ * translates that framework's conventions into it; see
414
+ * `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
415
+ */
361
416
  function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
417
+ if (isTanStackRoutesFolder(srcFolder)) {
418
+ var routePath = moduleFilePath.slice(srcFolder.length).replace(/\.val\.[tj]sx?$/, "");
419
+ var segments = tanStackSegmentsOfRoutePath(routePath);
420
+ // "" rather than "/" for the root, so it matches what the Next branch
421
+ // returns for `/app/page.val.ts` — `parseRoutePattern` reads both as [].
422
+ return segments.length === 0 ? "" : "/".concat(segments.join("/"));
423
+ }
362
424
  return moduleFilePath.replace(srcFolder, "")
363
425
  // TODO: hacky!
364
426
  // remove route groups
@@ -366,4 +428,4 @@ function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
366
428
  .replace("/page.val.ts", "").replace("/page.val.js", "");
367
429
  }
368
430
 
369
- export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g, getNextAppRouterSitemapTree as h, isValCanvasPageMessage as i, getPatternFromModuleFilePath as j, _objectSpread2 as k, _arrayLikeToArray as l, _unsupportedIterableToArray as m, _defineProperty as n, _typeof as o, parseRoutePattern as p, withValCanvasParam as w };
431
+ export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g, getTanStackRouterSourceFolder as h, isValCanvasPageMessage as i, getPageRouterSourceFolder as j, isTanStackRoutesFolder as k, getPageRouterSitemapTree as l, getPatternFromModuleFilePath as m, _objectSpread2 as n, _arrayLikeToArray as o, parseRoutePattern as p, _unsupportedIterableToArray as q, _defineProperty as r, _typeof as s, withValCanvasParam as w };
@@ -137,6 +137,45 @@ function getNextAppRouterSourceFolder(moduleFilePath) {
137
137
  return null;
138
138
  }
139
139
 
140
+ /**
141
+ * The folder a TanStack Router app keeps its route files in.
142
+ *
143
+ * The same question as above for the other convention: `routes/` at the project
144
+ * root, or under `src/`. A Val module for a route lives beside the route file
145
+ * and is named the same way, so this is the prefix to strip before reading the
146
+ * route pattern out of the rest.
147
+ */
148
+ function getTanStackRouterSourceFolder(moduleFilePath) {
149
+ if (moduleFilePath.startsWith("/routes/")) {
150
+ return "/routes";
151
+ } else if (moduleFilePath.startsWith("/src/routes/")) {
152
+ return "/src/routes";
153
+ }
154
+ return null;
155
+ }
156
+
157
+ /**
158
+ * The route folder of whichever page router this module belongs to.
159
+ *
160
+ * The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
161
+ * module file path answers this on its own, which is what the Studio needs: it
162
+ * walks every schema in the project and has no framework to ask.
163
+ */
164
+ function getPageRouterSourceFolder(moduleFilePath) {
165
+ var _getNextAppRouterSour;
166
+ return (_getNextAppRouterSour = getNextAppRouterSourceFolder(moduleFilePath)) !== null && _getNextAppRouterSour !== void 0 ? _getNextAppRouterSour : getTanStackRouterSourceFolder(moduleFilePath);
167
+ }
168
+
169
+ /**
170
+ * Whether a route folder is a TanStack Router one.
171
+ *
172
+ * Exported so the pattern derivation and the source-folder detection cannot
173
+ * drift apart about what `/src/routes` means.
174
+ */
175
+ function isTanStackRoutesFolder(srcFolder) {
176
+ return srcFolder === "/routes" || srcFolder === "/src/routes";
177
+ }
178
+
140
179
  function _toPrimitive(t, r) {
141
180
  if ("object" != typeof t || !t) return t;
142
181
  var e = t[Symbol.toPrimitive];
@@ -247,8 +286,14 @@ function _createForOfIteratorHelper(r, e) {
247
286
  };
248
287
  }
249
288
 
250
- // Strictly speaking this should be in the next package but it's shared, because we want to use it in the ui package. We want to resolve that somehow
251
- function getNextAppRouterSitemapTree(srcFolder, paths) {
289
+ // Strictly speaking this should be in the framework packages but it's shared,
290
+ // because we want to use it in the ui package. We want to resolve that somehow.
291
+ //
292
+ // It is one function for both page routers because the tree it builds is made
293
+ // of URL paths, which is the same thing in either: only `srcFolder` and the
294
+ // pattern derivation differ, and both of those are arguments (or the one call
295
+ // below).
296
+ function getPageRouterSitemapTree(srcFolder, paths) {
252
297
  var root = {
253
298
  type: "node",
254
299
  name: "/",
@@ -360,7 +405,24 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
360
405
  }
361
406
  return root;
362
407
  }
408
+
409
+ /**
410
+ * The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
411
+ *
412
+ * Written in Next's vocabulary for both routers on purpose: the pattern is read
413
+ * by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
414
+ * should have to know which framework the project uses. The TanStack branch
415
+ * translates that framework's conventions into it; see
416
+ * `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
417
+ */
363
418
  function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
419
+ if (isTanStackRoutesFolder(srcFolder)) {
420
+ var routePath = moduleFilePath.slice(srcFolder.length).replace(/\.val\.[tj]sx?$/, "");
421
+ var segments = core.tanStackSegmentsOfRoutePath(routePath);
422
+ // "" rather than "/" for the root, so it matches what the Next branch
423
+ // returns for `/app/page.val.ts` — `parseRoutePattern` reads both as [].
424
+ return segments.length === 0 ? "" : "/".concat(segments.join("/"));
425
+ }
364
426
  return moduleFilePath.replace(srcFolder, "")
365
427
  // TODO: hacky!
366
428
  // remove route groups
@@ -379,9 +441,12 @@ exports._defineProperty = _defineProperty;
379
441
  exports._objectSpread2 = _objectSpread2;
380
442
  exports._typeof = _typeof;
381
443
  exports._unsupportedIterableToArray = _unsupportedIterableToArray;
382
- exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
383
444
  exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
445
+ exports.getPageRouterSitemapTree = getPageRouterSitemapTree;
446
+ exports.getPageRouterSourceFolder = getPageRouterSourceFolder;
384
447
  exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
448
+ exports.getTanStackRouterSourceFolder = getTanStackRouterSourceFolder;
449
+ exports.isTanStackRoutesFolder = isTanStackRoutesFolder;
385
450
  exports.isValCanvasFrame = isValCanvasFrame;
386
451
  exports.isValCanvasPageMessage = isValCanvasPageMessage;
387
452
  exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
@@ -137,6 +137,45 @@ function getNextAppRouterSourceFolder(moduleFilePath) {
137
137
  return null;
138
138
  }
139
139
 
140
+ /**
141
+ * The folder a TanStack Router app keeps its route files in.
142
+ *
143
+ * The same question as above for the other convention: `routes/` at the project
144
+ * root, or under `src/`. A Val module for a route lives beside the route file
145
+ * and is named the same way, so this is the prefix to strip before reading the
146
+ * route pattern out of the rest.
147
+ */
148
+ function getTanStackRouterSourceFolder(moduleFilePath) {
149
+ if (moduleFilePath.startsWith("/routes/")) {
150
+ return "/routes";
151
+ } else if (moduleFilePath.startsWith("/src/routes/")) {
152
+ return "/src/routes";
153
+ }
154
+ return null;
155
+ }
156
+
157
+ /**
158
+ * The route folder of whichever page router this module belongs to.
159
+ *
160
+ * The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
161
+ * module file path answers this on its own, which is what the Studio needs: it
162
+ * walks every schema in the project and has no framework to ask.
163
+ */
164
+ function getPageRouterSourceFolder(moduleFilePath) {
165
+ var _getNextAppRouterSour;
166
+ return (_getNextAppRouterSour = getNextAppRouterSourceFolder(moduleFilePath)) !== null && _getNextAppRouterSour !== void 0 ? _getNextAppRouterSour : getTanStackRouterSourceFolder(moduleFilePath);
167
+ }
168
+
169
+ /**
170
+ * Whether a route folder is a TanStack Router one.
171
+ *
172
+ * Exported so the pattern derivation and the source-folder detection cannot
173
+ * drift apart about what `/src/routes` means.
174
+ */
175
+ function isTanStackRoutesFolder(srcFolder) {
176
+ return srcFolder === "/routes" || srcFolder === "/src/routes";
177
+ }
178
+
140
179
  function _toPrimitive(t, r) {
141
180
  if ("object" != typeof t || !t) return t;
142
181
  var e = t[Symbol.toPrimitive];
@@ -247,8 +286,14 @@ function _createForOfIteratorHelper(r, e) {
247
286
  };
248
287
  }
249
288
 
250
- // Strictly speaking this should be in the next package but it's shared, because we want to use it in the ui package. We want to resolve that somehow
251
- function getNextAppRouterSitemapTree(srcFolder, paths) {
289
+ // Strictly speaking this should be in the framework packages but it's shared,
290
+ // because we want to use it in the ui package. We want to resolve that somehow.
291
+ //
292
+ // It is one function for both page routers because the tree it builds is made
293
+ // of URL paths, which is the same thing in either: only `srcFolder` and the
294
+ // pattern derivation differ, and both of those are arguments (or the one call
295
+ // below).
296
+ function getPageRouterSitemapTree(srcFolder, paths) {
252
297
  var root = {
253
298
  type: "node",
254
299
  name: "/",
@@ -360,7 +405,24 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
360
405
  }
361
406
  return root;
362
407
  }
408
+
409
+ /**
410
+ * The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
411
+ *
412
+ * Written in Next's vocabulary for both routers on purpose: the pattern is read
413
+ * by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
414
+ * should have to know which framework the project uses. The TanStack branch
415
+ * translates that framework's conventions into it; see
416
+ * `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
417
+ */
363
418
  function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
419
+ if (isTanStackRoutesFolder(srcFolder)) {
420
+ var routePath = moduleFilePath.slice(srcFolder.length).replace(/\.val\.[tj]sx?$/, "");
421
+ var segments = core.tanStackSegmentsOfRoutePath(routePath);
422
+ // "" rather than "/" for the root, so it matches what the Next branch
423
+ // returns for `/app/page.val.ts` — `parseRoutePattern` reads both as [].
424
+ return segments.length === 0 ? "" : "/".concat(segments.join("/"));
425
+ }
364
426
  return moduleFilePath.replace(srcFolder, "")
365
427
  // TODO: hacky!
366
428
  // remove route groups
@@ -379,9 +441,12 @@ exports._defineProperty = _defineProperty;
379
441
  exports._objectSpread2 = _objectSpread2;
380
442
  exports._typeof = _typeof;
381
443
  exports._unsupportedIterableToArray = _unsupportedIterableToArray;
382
- exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
383
444
  exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
445
+ exports.getPageRouterSitemapTree = getPageRouterSitemapTree;
446
+ exports.getPageRouterSourceFolder = getPageRouterSourceFolder;
384
447
  exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
448
+ exports.getTanStackRouterSourceFolder = getTanStackRouterSourceFolder;
449
+ exports.isTanStackRoutesFolder = isTanStackRoutesFolder;
385
450
  exports.isValCanvasFrame = isValCanvasFrame;
386
451
  exports.isValCanvasPageMessage = isValCanvasPageMessage;
387
452
  exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
- var getSitemapTree = require('../../dist/getSitemapTree-a0c9a0e3.cjs.dev.js');
6
+ var getSitemapTree = require('../../dist/getSitemapTree-d1977d3e.cjs.dev.js');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
9
9
  var FlexSearch = require('flexsearch');
@@ -2463,6 +2463,66 @@ var Api = {
2463
2463
  * actually mounts. A file at a fixed commit cannot change, so the response is
2464
2464
  * immutable and the browser's own cache handles flipping between commits.
2465
2465
  */
2466
+ /**
2467
+ * One `.jsonValues()` entry's content, as it was at a commit.
2468
+ *
2469
+ * The history pane's counterpart to `/json`. A `.jsonValues()` record's
2470
+ * source is only `{_type:"json"}` markers - the content is per entry, fetched
2471
+ * on demand - so without this the commit pane rendered every entry as an
2472
+ * empty field, which is a claim that the author left it blank.
2473
+ *
2474
+ * One entry per request, deliberately: the store fetches an entry when
2475
+ * something reads inside it, so a batch would mean guessing which entries the
2476
+ * pane is about to show. Authenticated for the same reasons as
2477
+ * `/history/files` below.
2478
+ */
2479
+ "/history/json": {
2480
+ GET: {
2481
+ req: {
2482
+ query: {
2483
+ commit_sha: onlyOneStringQueryParam,
2484
+ path: onlyOneStringQueryParam,
2485
+ key: onlyOneStringQueryParam
2486
+ },
2487
+ cookies: {
2488
+ val_session: zod.z.string().optional()
2489
+ }
2490
+ },
2491
+ res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
2492
+ status: zod.z.literal(400),
2493
+ json: GenericError.and(zod.z.object({
2494
+ kind: zod.z.string().optional()
2495
+ }))
2496
+ }), zod.z.object({
2497
+ status: zod.z.literal(500),
2498
+ json: GenericError.and(zod.z.object({
2499
+ kind: zod.z.string().optional()
2500
+ }))
2501
+ }), zod.z.object({
2502
+ status: zod.z.literal(200),
2503
+ json: zod.z.object({
2504
+ path: ModuleFilePath,
2505
+ key: zod.z.string(),
2506
+ content: zod.z.unknown()
2507
+ })
2508
+ })])
2509
+ }
2510
+ },
2511
+ /**
2512
+ * A binary file as it was at a commit.
2513
+ *
2514
+ * AUTHENTICATED, unlike `/files` below - and the difference is not an
2515
+ * oversight in either direction. See the comment on `/files`: what makes it
2516
+ * safe to leave open is that a `patch_id` is an unguessable UUID, and what
2517
+ * makes leaving it open NECESSARY is that a draft image is fetched by the
2518
+ * app's own backend during Next image optimisation, with no cookies.
2519
+ *
2520
+ * Neither holds here. A commit sha is published - `git log`, the GitHub UI,
2521
+ * every PR - so it is not a secret to stand in for a credential. And nothing
2522
+ * fetches these server-side: they are read by the Studio, in a browser that
2523
+ * has the session cookie, for the history pane and for staging a restore.
2524
+ * So this one asks.
2525
+ */
2466
2526
  "/history/files": {
2467
2527
  GET: {
2468
2528
  req: {
@@ -2470,6 +2530,9 @@ var Api = {
2470
2530
  commit_sha: onlyOneStringQueryParam,
2471
2531
  path: onlyOneStringQueryParam,
2472
2532
  remote: onlyOneStringQueryParam.optional()
2533
+ },
2534
+ cookies: {
2535
+ val_session: zod.z.string().optional()
2473
2536
  }
2474
2537
  },
2475
2538
  res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
@@ -5494,9 +5557,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
5494
5557
  exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
5495
5558
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
5496
5559
  exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
5497
- exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
5498
5560
  exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
5561
+ exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
5562
+ exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
5499
5563
  exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
5564
+ exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
5565
+ exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
5500
5566
  exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
5501
5567
  exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
5502
5568
  exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
- var getSitemapTree = require('../../dist/getSitemapTree-77b1203a.cjs.prod.js');
6
+ var getSitemapTree = require('../../dist/getSitemapTree-b320d033.cjs.prod.js');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
9
9
  var FlexSearch = require('flexsearch');
@@ -2463,6 +2463,66 @@ var Api = {
2463
2463
  * actually mounts. A file at a fixed commit cannot change, so the response is
2464
2464
  * immutable and the browser's own cache handles flipping between commits.
2465
2465
  */
2466
+ /**
2467
+ * One `.jsonValues()` entry's content, as it was at a commit.
2468
+ *
2469
+ * The history pane's counterpart to `/json`. A `.jsonValues()` record's
2470
+ * source is only `{_type:"json"}` markers - the content is per entry, fetched
2471
+ * on demand - so without this the commit pane rendered every entry as an
2472
+ * empty field, which is a claim that the author left it blank.
2473
+ *
2474
+ * One entry per request, deliberately: the store fetches an entry when
2475
+ * something reads inside it, so a batch would mean guessing which entries the
2476
+ * pane is about to show. Authenticated for the same reasons as
2477
+ * `/history/files` below.
2478
+ */
2479
+ "/history/json": {
2480
+ GET: {
2481
+ req: {
2482
+ query: {
2483
+ commit_sha: onlyOneStringQueryParam,
2484
+ path: onlyOneStringQueryParam,
2485
+ key: onlyOneStringQueryParam
2486
+ },
2487
+ cookies: {
2488
+ val_session: zod.z.string().optional()
2489
+ }
2490
+ },
2491
+ res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
2492
+ status: zod.z.literal(400),
2493
+ json: GenericError.and(zod.z.object({
2494
+ kind: zod.z.string().optional()
2495
+ }))
2496
+ }), zod.z.object({
2497
+ status: zod.z.literal(500),
2498
+ json: GenericError.and(zod.z.object({
2499
+ kind: zod.z.string().optional()
2500
+ }))
2501
+ }), zod.z.object({
2502
+ status: zod.z.literal(200),
2503
+ json: zod.z.object({
2504
+ path: ModuleFilePath,
2505
+ key: zod.z.string(),
2506
+ content: zod.z.unknown()
2507
+ })
2508
+ })])
2509
+ }
2510
+ },
2511
+ /**
2512
+ * A binary file as it was at a commit.
2513
+ *
2514
+ * AUTHENTICATED, unlike `/files` below - and the difference is not an
2515
+ * oversight in either direction. See the comment on `/files`: what makes it
2516
+ * safe to leave open is that a `patch_id` is an unguessable UUID, and what
2517
+ * makes leaving it open NECESSARY is that a draft image is fetched by the
2518
+ * app's own backend during Next image optimisation, with no cookies.
2519
+ *
2520
+ * Neither holds here. A commit sha is published - `git log`, the GitHub UI,
2521
+ * every PR - so it is not a secret to stand in for a credential. And nothing
2522
+ * fetches these server-side: they are read by the Studio, in a browser that
2523
+ * has the session cookie, for the history pane and for staging a restore.
2524
+ * So this one asks.
2525
+ */
2466
2526
  "/history/files": {
2467
2527
  GET: {
2468
2528
  req: {
@@ -2470,6 +2530,9 @@ var Api = {
2470
2530
  commit_sha: onlyOneStringQueryParam,
2471
2531
  path: onlyOneStringQueryParam,
2472
2532
  remote: onlyOneStringQueryParam.optional()
2533
+ },
2534
+ cookies: {
2535
+ val_session: zod.z.string().optional()
2473
2536
  }
2474
2537
  },
2475
2538
  res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
@@ -5494,9 +5557,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
5494
5557
  exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
5495
5558
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
5496
5559
  exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
5497
- exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
5498
5560
  exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
5561
+ exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
5562
+ exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
5499
5563
  exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
5564
+ exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
5565
+ exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
5500
5566
  exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
5501
5567
  exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
5502
5568
  exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
@@ -1,6 +1,6 @@
1
1
  import { Internal, CODE_LANGUAGES, DEFAULT_COLOR_FORMAT } from '@valbuild/core';
2
- import { _ as _createForOfIteratorHelper, k as _objectSpread2, l as _arrayLikeToArray, m as _unsupportedIterableToArray, n as _defineProperty, o as _typeof } from '../../dist/getSitemapTree-d3e98a2e.esm.js';
3
- export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSitemapTree, g as getNextAppRouterSourceFolder, j as getPatternFromModuleFilePath, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-d3e98a2e.esm.js';
2
+ import { _ as _createForOfIteratorHelper, n as _objectSpread2, o as _arrayLikeToArray, q as _unsupportedIterableToArray, r as _defineProperty, s as _typeof } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
3
+ export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
4
4
  import { z } from 'zod';
5
5
  import { fromError } from 'zod-validation-error';
6
6
  import FlexSearch from 'flexsearch';
@@ -2456,6 +2456,66 @@ var Api = {
2456
2456
  * actually mounts. A file at a fixed commit cannot change, so the response is
2457
2457
  * immutable and the browser's own cache handles flipping between commits.
2458
2458
  */
2459
+ /**
2460
+ * One `.jsonValues()` entry's content, as it was at a commit.
2461
+ *
2462
+ * The history pane's counterpart to `/json`. A `.jsonValues()` record's
2463
+ * source is only `{_type:"json"}` markers - the content is per entry, fetched
2464
+ * on demand - so without this the commit pane rendered every entry as an
2465
+ * empty field, which is a claim that the author left it blank.
2466
+ *
2467
+ * One entry per request, deliberately: the store fetches an entry when
2468
+ * something reads inside it, so a batch would mean guessing which entries the
2469
+ * pane is about to show. Authenticated for the same reasons as
2470
+ * `/history/files` below.
2471
+ */
2472
+ "/history/json": {
2473
+ GET: {
2474
+ req: {
2475
+ query: {
2476
+ commit_sha: onlyOneStringQueryParam,
2477
+ path: onlyOneStringQueryParam,
2478
+ key: onlyOneStringQueryParam
2479
+ },
2480
+ cookies: {
2481
+ val_session: z.string().optional()
2482
+ }
2483
+ },
2484
+ res: z.union([unauthorizedResponse, notFoundResponse, z.object({
2485
+ status: z.literal(400),
2486
+ json: GenericError.and(z.object({
2487
+ kind: z.string().optional()
2488
+ }))
2489
+ }), z.object({
2490
+ status: z.literal(500),
2491
+ json: GenericError.and(z.object({
2492
+ kind: z.string().optional()
2493
+ }))
2494
+ }), z.object({
2495
+ status: z.literal(200),
2496
+ json: z.object({
2497
+ path: ModuleFilePath,
2498
+ key: z.string(),
2499
+ content: z.unknown()
2500
+ })
2501
+ })])
2502
+ }
2503
+ },
2504
+ /**
2505
+ * A binary file as it was at a commit.
2506
+ *
2507
+ * AUTHENTICATED, unlike `/files` below - and the difference is not an
2508
+ * oversight in either direction. See the comment on `/files`: what makes it
2509
+ * safe to leave open is that a `patch_id` is an unguessable UUID, and what
2510
+ * makes leaving it open NECESSARY is that a draft image is fetched by the
2511
+ * app's own backend during Next image optimisation, with no cookies.
2512
+ *
2513
+ * Neither holds here. A commit sha is published - `git log`, the GitHub UI,
2514
+ * every PR - so it is not a secret to stand in for a credential. And nothing
2515
+ * fetches these server-side: they are read by the Studio, in a browser that
2516
+ * has the session cookie, for the history pane and for staging a restore.
2517
+ * So this one asks.
2518
+ */
2459
2519
  "/history/files": {
2460
2520
  GET: {
2461
2521
  req: {
@@ -2463,6 +2523,9 @@ var Api = {
2463
2523
  commit_sha: onlyOneStringQueryParam,
2464
2524
  path: onlyOneStringQueryParam,
2465
2525
  remote: onlyOneStringQueryParam.optional()
2526
+ },
2527
+ cookies: {
2528
+ val_session: z.string().optional()
2466
2529
  }
2467
2530
  },
2468
2531
  res: z.union([unauthorizedResponse, notFoundResponse, z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.123.3",
3
+ "version": "0.125.0",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "flexsearch": "^0.8.212",
38
38
  "zod": "^4.4.3",
39
39
  "zod-validation-error": "^5.0.0",
40
- "@valbuild/core": "0.121.0"
40
+ "@valbuild/core": "0.125.0"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",