@valbuild/server 0.150.10 → 0.150.12

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,46 @@
1
1
  # @valbuild/server
2
2
 
3
+ ## 0.150.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#977](https://github.com/valbuild/val/pull/977) [`55f565e`](https://github.com/valbuild/val/commit/55f565eefe470d1a7cda436d628aec2f7ad61969) Thanks [@freekh](https://github.com/freekh)! - The Studio now shows which versions of Val it runs. Open the Account panel (the button at the foot of the left rail) and click the grey line at the bottom, for example `TanStack · Val 0.150.8`, to see:
8
+
9
+ - what your app's server runs: `@valbuild/next` or `@valbuild/tanstack`, `@valbuild/core` and `@valbuild/server`
10
+ - what the Studio in your browser loaded: `@valbuild/ui`, and the `@valbuild/core` bundled into it
11
+
12
+ **Copy all** puts the list on the clipboard, ready to paste into a bug report. The server's half comes from a new `GET /api/val/versions` route, which needs the same sign-in as the rest of the Studio. If your server's Val is older than the Studio, the list says so and still shows the Studio's half.
13
+
14
+ - Updated dependencies [[`e39a373`](https://github.com/valbuild/val/commit/e39a3730624cbf3a5434d4fb0d13be26f44280db), [`d47537a`](https://github.com/valbuild/val/commit/d47537a40ca7ca0c6a5e7b80f1dfb18791fc5bc1), [`55f565e`](https://github.com/valbuild/val/commit/55f565eefe470d1a7cda436d628aec2f7ad61969)]:
15
+ - @valbuild/ui@0.150.12
16
+ - @valbuild/shared@0.150.12
17
+
18
+ ## 0.150.11
19
+
20
+ ### Patch Changes
21
+
22
+ - [#976](https://github.com/valbuild/val/pull/976) [`9abd5ef`](https://github.com/valbuild/val/commit/9abd5efea0c1adc7e7ff2d05b2ea38b76af73b38) Thanks [@freekh](https://github.com/freekh)! - Images the assistant adds now show up in remote storage, which is where every image in a hosted project lives: in a remote gallery (`s.imagedir(...).remote()`), in a remote image field (`s.image().remote()`) and inline in rich text whose images are remote. They used to be saved under a plain `/public/...` path while their bytes were stored as a remote file, so the Studio looked for a local file that did not exist and showed a broken image, and a published site would have named a file nothing serves. They are now saved under a remote ref, the same as an image uploaded with the Studio's own Upload button.
23
+
24
+ The image is still moved from the chat to the change rather than copied: the content service points the change at the image it already holds, and nothing is downloaded or uploaded again. The content service now says what the image's bytes hash to, which is what a remote ref is named by; against one that does not yet, the Studio downloads the image once to hash it.
25
+
26
+ The assistant can also now put an image into an empty rich text by writing the whole value; that used to be refused.
27
+
28
+ - [#974](https://github.com/valbuild/val/pull/974) [`9c6bc8d`](https://github.com/valbuild/val/commit/9c6bc8d25f40427a6fb9eec6ff5506996b718a78) Thanks [@freekh](https://github.com/freekh)! - The design tab no longer makes you wait.
29
+
30
+ - **Quick preview.** A change to components, layout or styles is shown in seconds, without a build: the proposal's browser code is bundled in the tab and the page in the preview runs it. What runs on the server (loaders, server functions, the page's first render) stays the last build's, and the tab says so, with a button to build. The assistant has it too (`quick_preview`).
31
+ - **Cancel and Try again.** A build can be cancelled from the tab, and a build that stops making progress for three minutes is stopped, saying at which step, so it never spins until a reload. The assistant waits for a build with `wait` instead of holding its turn, and has `build_status` and `cancel_build`.
32
+ - **Each step of a build is timed**, and the Build check lists where the time went.
33
+ - **A new build fades in where you were**, at the same page and scroll, instead of the preview going blank and starting over at the top.
34
+ - **`read_page`** lets the assistant check its change on the page: the headings, text, links, images and inputs in order, and one element's computed styles and how many lines it wraps to, at desktop, tablet or phone width.
35
+ - **On a phone**, the design tab shows the preview, the assistant and the changes one at a time, as tabs. Picking is Select, then a tap, and a pick takes you to the assistant with it. On Safari and on an iPhone, where the tab cannot bundle code itself, the quick preview is prepared in a builder tab, as a build already is.
36
+ - **Queue messages in the assistant's chat.** Write while it answers: what you write waits and is sent when the answer is done, one at a time. A queued message can be taken back to edit, moved up or removed, and Stop or a failed answer holds the queue until you go on.
37
+
38
+ The quick preview and `read_page` run in the proposal's own page, through the canvas bridge in `@valbuild/next` and `@valbuild/tanstack`, so a site needs those packages at this version for them. The quick preview is served by a service worker on the proposal's address (`/api/val/quick-preview-sw.js`), which takes code only from the site's own design tab.
39
+
40
+ - Updated dependencies [[`9abd5ef`](https://github.com/valbuild/val/commit/9abd5efea0c1adc7e7ff2d05b2ea38b76af73b38), [`9c6bc8d`](https://github.com/valbuild/val/commit/9c6bc8d25f40427a6fb9eec6ff5506996b718a78)]:
41
+ - @valbuild/ui@0.150.11
42
+ - @valbuild/shared@0.150.11
43
+
3
44
  ## 0.150.10
4
45
 
5
46
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
- var ValRouterCore = require('../../dist/ValRouterCore-d151b850.cjs.dev.js');
6
+ var ValRouterCore = require('../../dist/ValRouterCore-bee6f858.cjs.dev.js');
7
7
  require('@valbuild/shared/internal');
8
8
  require('zod');
9
9
  require('zod-validation-error');
@@ -92,7 +92,10 @@ function createInTabValFetch(valModules, options) {
92
92
  patchStore: options.patchStore,
93
93
  unsafelyAllowUnauthenticated: true,
94
94
  valContentUrl: core.DEFAULT_CONTENT_HOST,
95
- config: options.config
95
+ config: options.config,
96
+ ...(options.framework !== undefined ? {
97
+ framework: options.framework
98
+ } : {})
96
99
  };
97
100
  const server = ValRouterCore.ValServer(valModules, serverConfig, {
98
101
  // Draft content is the only content a demo has.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
- var ValRouterCore = require('../../dist/ValRouterCore-3ca4d25e.cjs.prod.js');
6
+ var ValRouterCore = require('../../dist/ValRouterCore-85341829.cjs.prod.js');
7
7
  require('@valbuild/shared/internal');
8
8
  require('zod');
9
9
  require('zod-validation-error');
@@ -92,7 +92,10 @@ function createInTabValFetch(valModules, options) {
92
92
  patchStore: options.patchStore,
93
93
  unsafelyAllowUnauthenticated: true,
94
94
  valContentUrl: core.DEFAULT_CONTENT_HOST,
95
- config: options.config
95
+ config: options.config,
96
+ ...(options.framework !== undefined ? {
97
+ framework: options.framework
98
+ } : {})
96
99
  };
97
100
  const server = ValRouterCore.ValServer(valModules, serverConfig, {
98
101
  // Draft content is the only content a demo has.
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_CONTENT_HOST } from '@valbuild/core';
2
- import { j as ValOpsMemory, E as bytesToBase64, y as ValServer, z as createValRequestHandler } from '../../dist/ValRouterCore-4e292ec5.esm.js';
2
+ import { j as ValOpsMemory, E as bytesToBase64, y as ValServer, z as createValRequestHandler } from '../../dist/ValRouterCore-4d920904.esm.js';
3
3
  import '@valbuild/shared/internal';
4
4
  import 'zod';
5
5
  import 'zod-validation-error';
@@ -88,7 +88,10 @@ function createInTabValFetch(valModules, options) {
88
88
  patchStore: options.patchStore,
89
89
  unsafelyAllowUnauthenticated: true,
90
90
  valContentUrl: DEFAULT_CONTENT_HOST,
91
- config: options.config
91
+ config: options.config,
92
+ ...(options.framework !== undefined ? {
93
+ framework: options.framework
94
+ } : {})
92
95
  };
93
96
  const server = ValServer(valModules, serverConfig, {
94
97
  // Draft content is the only content a demo has.
@@ -1,5 +1,5 @@
1
1
  import { Internal, VAL_EXTENSION, extractValModules, computeValModuleShas, ImageSchema, DEFAULT_CONTENT_HOST, hasRemoteFileSchema } from '@valbuild/core';
2
- import { isSchemaSourceFixError, resolveSchemaSourceFixForError, SerializedSchema, AnalyticsBeacon, VAL_ENABLE_COOKIE_NAME, VAL_STATE_COOKIE, VAL_SESSION_COOKIE, newestCommitSha, parseJob, VAL_STUDIO_HEADER, AIToolCallSummaries, getErrorMessageFromUnknownJson, Api } from '@valbuild/shared/internal';
2
+ import { isSchemaSourceFixError, resolveSchemaSourceFixForError, SerializedSchema, AnalyticsBeacon, VAL_ENABLE_COOKIE_NAME, VAL_STATE_COOKIE, VAL_SESSION_COOKIE, newestCommitSha, parseJob, VAL_STUDIO_HEADER, AIToolCallSummaries, getErrorMessageFromUnknownJson, QUICK_PREVIEW_SERVICE_WORKER_PATH, QUICK_PREVIEW_SERVICE_WORKER_SOURCE, Api } from '@valbuild/shared/internal';
3
3
  import { z } from 'zod';
4
4
  import { fromError } from 'zod-validation-error';
5
5
  import { result, array } from '@valbuild/core/fp';
@@ -5469,6 +5469,78 @@ function mapStatus(status) {
5469
5469
  return 500;
5470
5470
  }
5471
5471
 
5472
+ var packageJson = {
5473
+ name: "@valbuild/server",
5474
+ "private": false,
5475
+ description: "Val - integrated server",
5476
+ repository: {
5477
+ type: "git",
5478
+ url: "git+https://github.com/valbuild/val.git"
5479
+ },
5480
+ main: "dist/valbuild-server.cjs.js",
5481
+ module: "dist/valbuild-server.esm.js",
5482
+ exports: {
5483
+ ".": {
5484
+ module: "./dist/valbuild-server.esm.js",
5485
+ "default": "./dist/valbuild-server.cjs.js"
5486
+ },
5487
+ "./browser": {
5488
+ module: "./browser/dist/valbuild-server-browser.esm.js",
5489
+ "default": "./browser/dist/valbuild-server-browser.cjs.js"
5490
+ },
5491
+ "./package.json": "./package.json"
5492
+ },
5493
+ types: "dist/valbuild-server.cjs.d.ts",
5494
+ preconstruct: {
5495
+ entrypoints: [
5496
+ "./index.ts",
5497
+ "./browser/index.ts"
5498
+ ],
5499
+ exports: true
5500
+ },
5501
+ version: "0.150.12",
5502
+ scripts: {
5503
+ typecheck: "tsc --noEmit",
5504
+ test: "jest",
5505
+ "test:watch": "jest --watch"
5506
+ },
5507
+ devDependencies: {
5508
+ "@prettier/sync": "^0.6.1",
5509
+ "@types/jest": "^30.0.0",
5510
+ prettier: "~3.8.5"
5511
+ },
5512
+ dependencies: {
5513
+ "@valbuild/core": "workspace:*",
5514
+ "@valbuild/shared": "workspace:*",
5515
+ "@valbuild/ui": "workspace:*",
5516
+ chokidar: "^5.0.0",
5517
+ "image-size": "^2.0.2",
5518
+ minimatch: "^10.2.6",
5519
+ sucrase: "^3.35.1",
5520
+ typescript: "^6.0.3",
5521
+ zod: "^4.4.3",
5522
+ "zod-validation-error": "^5.0.0"
5523
+ },
5524
+ engines: {
5525
+ node: "^20.19.0 || >=22"
5526
+ },
5527
+ files: [
5528
+ "CHANGELOG.md",
5529
+ "dist",
5530
+ "browser"
5531
+ ]
5532
+ };
5533
+
5534
+ /**
5535
+ * This package's version, inlined at build time.
5536
+ *
5537
+ * The same static JSON import `@valbuild/next` and `@valbuild/tanstack` use,
5538
+ * for the reason theirs gives: `require` does not exist in an ESM bundle, and
5539
+ * preconstruct inlines the import. Read by the Studio's version list
5540
+ * (`/versions`), which is the only place it is shown.
5541
+ */
5542
+ const VERSION = packageJson.version;
5543
+
5472
5544
  /** What {@link ValServerOptions.publishOverride} is given. */
5473
5545
 
5474
5546
  /** What a publish reports back, in either shape. */
@@ -6372,6 +6444,41 @@ const ValServer = (valModules, options, callbacks, platform) => {
6372
6444
  };
6373
6445
  }
6374
6446
  },
6447
+ /*
6448
+ * The versions of Val's packages on the server, for the list at the foot
6449
+ * of the Studio's account panel. Behind the same sign-in as everything
6450
+ * else: a version is a small thing to give away, but it says which
6451
+ * advisories a site is open to.
6452
+ */
6453
+ "/versions": {
6454
+ GET: async req => {
6455
+ const auth = getAuth(req.cookies);
6456
+ if (auth.error) {
6457
+ return {
6458
+ status: 401,
6459
+ json: {
6460
+ message: auth.error
6461
+ }
6462
+ };
6463
+ }
6464
+ if (isHttpOps(serverOps) && !("id" in auth)) {
6465
+ return {
6466
+ status: 401,
6467
+ json: {
6468
+ message: "Unauthorized"
6469
+ }
6470
+ };
6471
+ }
6472
+ return {
6473
+ status: 200,
6474
+ json: {
6475
+ framework: options.framework ?? null,
6476
+ core: Internal.VERSION.core,
6477
+ server: VERSION
6478
+ }
6479
+ };
6480
+ }
6481
+ },
6375
6482
  //#region stat
6376
6483
  "/stat": {
6377
6484
  POST: async req => {
@@ -8806,7 +8913,8 @@ const ValServer = (valModules, options, callbacks, platform) => {
8806
8913
  width: z.number(),
8807
8914
  height: z.number(),
8808
8915
  mimeType: z.string()
8809
- })
8916
+ }),
8917
+ sha256: z.string().optional()
8810
8918
  }))
8811
8919
  });
8812
8920
  const json = UpstreamResponse.safeParse(rawUpstreamJson);
@@ -8831,6 +8939,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
8831
8939
  // has. A local store without local binary files (ValOpsMemory, which
8832
8940
  // uses Val's remote files) skips it, and the draft image is served
8833
8941
  // from the content host rather than mirrored.
8942
+ // The hash a remote ref names, where the content service did not
8943
+ // say: the fs branch below has the bytes in hand, so it is free.
8944
+ const sha256ByFilePath = new Map();
8834
8945
  if (isFsOps(serverOps)) {
8835
8946
  // Mirror the binaries from the content host into local patch
8836
8947
  // storage so /files?patch_id=... can serve them. Match upstream
@@ -8873,6 +8984,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
8873
8984
  // act was to unwrap it again - ceremony to satisfy a convention
8874
8985
  // that no longer exists.
8875
8986
  const bytes = new Uint8Array(await binaryRes.arrayBuffer());
8987
+ sha256ByFilePath.set(file.filePath, Internal.getSHA256Hash(bytes));
8876
8988
  const type = file.metadata.mimeType.startsWith("image/") ? "image" : "file";
8877
8989
  const saveRes = await serverOps.saveBinaryFileFromPatch(file.filePath, req.body.parentRef, req.body.patchId, bytes, file.metadata.mimeType, type, file.metadata);
8878
8990
  if (saveRes.error) {
@@ -8889,7 +9001,13 @@ const ValServer = (valModules, options, callbacks, platform) => {
8889
9001
  status: 200,
8890
9002
  json: {
8891
9003
  patchId: req.body.patchId,
8892
- files: json.data.files
9004
+ files: json.data.files.map(file => {
9005
+ const sha256 = file.sha256 ?? sha256ByFilePath.get(file.filePath);
9006
+ return sha256 !== undefined ? {
9007
+ ...file,
9008
+ sha256
9009
+ } : file;
9010
+ })
8893
9011
  }
8894
9012
  };
8895
9013
  } catch (err) {
@@ -9118,7 +9236,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
9118
9236
  // TypeScript compiler. See `patch/ts/publishKit.ts`.
9119
9237
  const {
9120
9238
  getJsonEntryAtCommit
9121
- } = await import('./getJsonEntryAtCommit-75d72adc.esm.js');
9239
+ } = await import('./getJsonEntryAtCommit-35916800.esm.js');
9122
9240
  const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
9123
9241
  if (result.isErr(res)) {
9124
9242
  return historyErrorResponse(res.error);
@@ -10534,6 +10652,24 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
10534
10652
  });
10535
10653
  }
10536
10654
  const path = url.pathname.slice(route.length);
10655
+ if (path === QUICK_PREVIEW_SERVICE_WORKER_PATH) {
10656
+ /*
10657
+ * The design tab's quick preview worker (`quickPreview.ts` in
10658
+ * `@valbuild/shared`). `Service-Worker-Allowed: /` lets a script at
10659
+ * this path control the whole origin, which it needs: it serves the
10660
+ * page's `/_app/` files. It serves them only to a page opened as a
10661
+ * quick preview, and the bridge stores them only for the site.
10662
+ */
10663
+ return convert({
10664
+ status: 200,
10665
+ headers: {
10666
+ "Content-Type": "text/javascript; charset=utf-8",
10667
+ "Service-Worker-Allowed": "/",
10668
+ "Cache-Control": "no-cache"
10669
+ },
10670
+ body: QUICK_PREVIEW_SERVICE_WORKER_SOURCE
10671
+ });
10672
+ }
10537
10673
  const groupQueryParams = arr => {
10538
10674
  const map = {};
10539
10675
  for (const [key, value] of arr) {
@@ -5475,6 +5475,78 @@ function mapStatus(status) {
5475
5475
  return 500;
5476
5476
  }
5477
5477
 
5478
+ var packageJson = {
5479
+ name: "@valbuild/server",
5480
+ "private": false,
5481
+ description: "Val - integrated server",
5482
+ repository: {
5483
+ type: "git",
5484
+ url: "git+https://github.com/valbuild/val.git"
5485
+ },
5486
+ main: "dist/valbuild-server.cjs.js",
5487
+ module: "dist/valbuild-server.esm.js",
5488
+ exports: {
5489
+ ".": {
5490
+ module: "./dist/valbuild-server.esm.js",
5491
+ "default": "./dist/valbuild-server.cjs.js"
5492
+ },
5493
+ "./browser": {
5494
+ module: "./browser/dist/valbuild-server-browser.esm.js",
5495
+ "default": "./browser/dist/valbuild-server-browser.cjs.js"
5496
+ },
5497
+ "./package.json": "./package.json"
5498
+ },
5499
+ types: "dist/valbuild-server.cjs.d.ts",
5500
+ preconstruct: {
5501
+ entrypoints: [
5502
+ "./index.ts",
5503
+ "./browser/index.ts"
5504
+ ],
5505
+ exports: true
5506
+ },
5507
+ version: "0.150.12",
5508
+ scripts: {
5509
+ typecheck: "tsc --noEmit",
5510
+ test: "jest",
5511
+ "test:watch": "jest --watch"
5512
+ },
5513
+ devDependencies: {
5514
+ "@prettier/sync": "^0.6.1",
5515
+ "@types/jest": "^30.0.0",
5516
+ prettier: "~3.8.5"
5517
+ },
5518
+ dependencies: {
5519
+ "@valbuild/core": "workspace:*",
5520
+ "@valbuild/shared": "workspace:*",
5521
+ "@valbuild/ui": "workspace:*",
5522
+ chokidar: "^5.0.0",
5523
+ "image-size": "^2.0.2",
5524
+ minimatch: "^10.2.6",
5525
+ sucrase: "^3.35.1",
5526
+ typescript: "^6.0.3",
5527
+ zod: "^4.4.3",
5528
+ "zod-validation-error": "^5.0.0"
5529
+ },
5530
+ engines: {
5531
+ node: "^20.19.0 || >=22"
5532
+ },
5533
+ files: [
5534
+ "CHANGELOG.md",
5535
+ "dist",
5536
+ "browser"
5537
+ ]
5538
+ };
5539
+
5540
+ /**
5541
+ * This package's version, inlined at build time.
5542
+ *
5543
+ * The same static JSON import `@valbuild/next` and `@valbuild/tanstack` use,
5544
+ * for the reason theirs gives: `require` does not exist in an ESM bundle, and
5545
+ * preconstruct inlines the import. Read by the Studio's version list
5546
+ * (`/versions`), which is the only place it is shown.
5547
+ */
5548
+ const VERSION = packageJson.version;
5549
+
5478
5550
  /** What {@link ValServerOptions.publishOverride} is given. */
5479
5551
 
5480
5552
  /** What a publish reports back, in either shape. */
@@ -6378,6 +6450,41 @@ const ValServer = (valModules, options, callbacks, platform) => {
6378
6450
  };
6379
6451
  }
6380
6452
  },
6453
+ /*
6454
+ * The versions of Val's packages on the server, for the list at the foot
6455
+ * of the Studio's account panel. Behind the same sign-in as everything
6456
+ * else: a version is a small thing to give away, but it says which
6457
+ * advisories a site is open to.
6458
+ */
6459
+ "/versions": {
6460
+ GET: async req => {
6461
+ const auth = getAuth(req.cookies);
6462
+ if (auth.error) {
6463
+ return {
6464
+ status: 401,
6465
+ json: {
6466
+ message: auth.error
6467
+ }
6468
+ };
6469
+ }
6470
+ if (isHttpOps(serverOps) && !("id" in auth)) {
6471
+ return {
6472
+ status: 401,
6473
+ json: {
6474
+ message: "Unauthorized"
6475
+ }
6476
+ };
6477
+ }
6478
+ return {
6479
+ status: 200,
6480
+ json: {
6481
+ framework: options.framework ?? null,
6482
+ core: core.Internal.VERSION.core,
6483
+ server: VERSION
6484
+ }
6485
+ };
6486
+ }
6487
+ },
6381
6488
  //#region stat
6382
6489
  "/stat": {
6383
6490
  POST: async req => {
@@ -8812,7 +8919,8 @@ const ValServer = (valModules, options, callbacks, platform) => {
8812
8919
  width: z.z.number(),
8813
8920
  height: z.z.number(),
8814
8921
  mimeType: z.z.string()
8815
- })
8922
+ }),
8923
+ sha256: z.z.string().optional()
8816
8924
  }))
8817
8925
  });
8818
8926
  const json = UpstreamResponse.safeParse(rawUpstreamJson);
@@ -8837,6 +8945,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
8837
8945
  // has. A local store without local binary files (ValOpsMemory, which
8838
8946
  // uses Val's remote files) skips it, and the draft image is served
8839
8947
  // from the content host rather than mirrored.
8948
+ // The hash a remote ref names, where the content service did not
8949
+ // say: the fs branch below has the bytes in hand, so it is free.
8950
+ const sha256ByFilePath = new Map();
8840
8951
  if (isFsOps(serverOps)) {
8841
8952
  // Mirror the binaries from the content host into local patch
8842
8953
  // storage so /files?patch_id=... can serve them. Match upstream
@@ -8879,6 +8990,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
8879
8990
  // act was to unwrap it again - ceremony to satisfy a convention
8880
8991
  // that no longer exists.
8881
8992
  const bytes = new Uint8Array(await binaryRes.arrayBuffer());
8993
+ sha256ByFilePath.set(file.filePath, core.Internal.getSHA256Hash(bytes));
8882
8994
  const type = file.metadata.mimeType.startsWith("image/") ? "image" : "file";
8883
8995
  const saveRes = await serverOps.saveBinaryFileFromPatch(file.filePath, req.body.parentRef, req.body.patchId, bytes, file.metadata.mimeType, type, file.metadata);
8884
8996
  if (saveRes.error) {
@@ -8895,7 +9007,13 @@ const ValServer = (valModules, options, callbacks, platform) => {
8895
9007
  status: 200,
8896
9008
  json: {
8897
9009
  patchId: req.body.patchId,
8898
- files: json.data.files
9010
+ files: json.data.files.map(file => {
9011
+ const sha256 = file.sha256 ?? sha256ByFilePath.get(file.filePath);
9012
+ return sha256 !== undefined ? {
9013
+ ...file,
9014
+ sha256
9015
+ } : file;
9016
+ })
8899
9017
  }
8900
9018
  };
8901
9019
  } catch (err) {
@@ -9124,7 +9242,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
9124
9242
  // TypeScript compiler. See `patch/ts/publishKit.ts`.
9125
9243
  const {
9126
9244
  getJsonEntryAtCommit
9127
- } = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-bd52eb31.cjs.prod.js'); });
9245
+ } = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-cb4ac1a5.cjs.prod.js'); });
9128
9246
  const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
9129
9247
  if (fp.result.isErr(res)) {
9130
9248
  return historyErrorResponse(res.error);
@@ -10540,6 +10658,24 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
10540
10658
  });
10541
10659
  }
10542
10660
  const path = url.pathname.slice(route.length);
10661
+ if (path === internal.QUICK_PREVIEW_SERVICE_WORKER_PATH) {
10662
+ /*
10663
+ * The design tab's quick preview worker (`quickPreview.ts` in
10664
+ * `@valbuild/shared`). `Service-Worker-Allowed: /` lets a script at
10665
+ * this path control the whole origin, which it needs: it serves the
10666
+ * page's `/_app/` files. It serves them only to a page opened as a
10667
+ * quick preview, and the bridge stores them only for the site.
10668
+ */
10669
+ return convert({
10670
+ status: 200,
10671
+ headers: {
10672
+ "Content-Type": "text/javascript; charset=utf-8",
10673
+ "Service-Worker-Allowed": "/",
10674
+ "Cache-Control": "no-cache"
10675
+ },
10676
+ body: internal.QUICK_PREVIEW_SERVICE_WORKER_SOURCE
10677
+ });
10678
+ }
10543
10679
  const groupQueryParams = arr => {
10544
10680
  const map = {};
10545
10681
  for (const [key, value] of arr) {
@@ -5475,6 +5475,78 @@ function mapStatus(status) {
5475
5475
  return 500;
5476
5476
  }
5477
5477
 
5478
+ var packageJson = {
5479
+ name: "@valbuild/server",
5480
+ "private": false,
5481
+ description: "Val - integrated server",
5482
+ repository: {
5483
+ type: "git",
5484
+ url: "git+https://github.com/valbuild/val.git"
5485
+ },
5486
+ main: "dist/valbuild-server.cjs.js",
5487
+ module: "dist/valbuild-server.esm.js",
5488
+ exports: {
5489
+ ".": {
5490
+ module: "./dist/valbuild-server.esm.js",
5491
+ "default": "./dist/valbuild-server.cjs.js"
5492
+ },
5493
+ "./browser": {
5494
+ module: "./browser/dist/valbuild-server-browser.esm.js",
5495
+ "default": "./browser/dist/valbuild-server-browser.cjs.js"
5496
+ },
5497
+ "./package.json": "./package.json"
5498
+ },
5499
+ types: "dist/valbuild-server.cjs.d.ts",
5500
+ preconstruct: {
5501
+ entrypoints: [
5502
+ "./index.ts",
5503
+ "./browser/index.ts"
5504
+ ],
5505
+ exports: true
5506
+ },
5507
+ version: "0.150.12",
5508
+ scripts: {
5509
+ typecheck: "tsc --noEmit",
5510
+ test: "jest",
5511
+ "test:watch": "jest --watch"
5512
+ },
5513
+ devDependencies: {
5514
+ "@prettier/sync": "^0.6.1",
5515
+ "@types/jest": "^30.0.0",
5516
+ prettier: "~3.8.5"
5517
+ },
5518
+ dependencies: {
5519
+ "@valbuild/core": "workspace:*",
5520
+ "@valbuild/shared": "workspace:*",
5521
+ "@valbuild/ui": "workspace:*",
5522
+ chokidar: "^5.0.0",
5523
+ "image-size": "^2.0.2",
5524
+ minimatch: "^10.2.6",
5525
+ sucrase: "^3.35.1",
5526
+ typescript: "^6.0.3",
5527
+ zod: "^4.4.3",
5528
+ "zod-validation-error": "^5.0.0"
5529
+ },
5530
+ engines: {
5531
+ node: "^20.19.0 || >=22"
5532
+ },
5533
+ files: [
5534
+ "CHANGELOG.md",
5535
+ "dist",
5536
+ "browser"
5537
+ ]
5538
+ };
5539
+
5540
+ /**
5541
+ * This package's version, inlined at build time.
5542
+ *
5543
+ * The same static JSON import `@valbuild/next` and `@valbuild/tanstack` use,
5544
+ * for the reason theirs gives: `require` does not exist in an ESM bundle, and
5545
+ * preconstruct inlines the import. Read by the Studio's version list
5546
+ * (`/versions`), which is the only place it is shown.
5547
+ */
5548
+ const VERSION = packageJson.version;
5549
+
5478
5550
  /** What {@link ValServerOptions.publishOverride} is given. */
5479
5551
 
5480
5552
  /** What a publish reports back, in either shape. */
@@ -6378,6 +6450,41 @@ const ValServer = (valModules, options, callbacks, platform) => {
6378
6450
  };
6379
6451
  }
6380
6452
  },
6453
+ /*
6454
+ * The versions of Val's packages on the server, for the list at the foot
6455
+ * of the Studio's account panel. Behind the same sign-in as everything
6456
+ * else: a version is a small thing to give away, but it says which
6457
+ * advisories a site is open to.
6458
+ */
6459
+ "/versions": {
6460
+ GET: async req => {
6461
+ const auth = getAuth(req.cookies);
6462
+ if (auth.error) {
6463
+ return {
6464
+ status: 401,
6465
+ json: {
6466
+ message: auth.error
6467
+ }
6468
+ };
6469
+ }
6470
+ if (isHttpOps(serverOps) && !("id" in auth)) {
6471
+ return {
6472
+ status: 401,
6473
+ json: {
6474
+ message: "Unauthorized"
6475
+ }
6476
+ };
6477
+ }
6478
+ return {
6479
+ status: 200,
6480
+ json: {
6481
+ framework: options.framework ?? null,
6482
+ core: core.Internal.VERSION.core,
6483
+ server: VERSION
6484
+ }
6485
+ };
6486
+ }
6487
+ },
6381
6488
  //#region stat
6382
6489
  "/stat": {
6383
6490
  POST: async req => {
@@ -8812,7 +8919,8 @@ const ValServer = (valModules, options, callbacks, platform) => {
8812
8919
  width: z.z.number(),
8813
8920
  height: z.z.number(),
8814
8921
  mimeType: z.z.string()
8815
- })
8922
+ }),
8923
+ sha256: z.z.string().optional()
8816
8924
  }))
8817
8925
  });
8818
8926
  const json = UpstreamResponse.safeParse(rawUpstreamJson);
@@ -8837,6 +8945,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
8837
8945
  // has. A local store without local binary files (ValOpsMemory, which
8838
8946
  // uses Val's remote files) skips it, and the draft image is served
8839
8947
  // from the content host rather than mirrored.
8948
+ // The hash a remote ref names, where the content service did not
8949
+ // say: the fs branch below has the bytes in hand, so it is free.
8950
+ const sha256ByFilePath = new Map();
8840
8951
  if (isFsOps(serverOps)) {
8841
8952
  // Mirror the binaries from the content host into local patch
8842
8953
  // storage so /files?patch_id=... can serve them. Match upstream
@@ -8879,6 +8990,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
8879
8990
  // act was to unwrap it again - ceremony to satisfy a convention
8880
8991
  // that no longer exists.
8881
8992
  const bytes = new Uint8Array(await binaryRes.arrayBuffer());
8993
+ sha256ByFilePath.set(file.filePath, core.Internal.getSHA256Hash(bytes));
8882
8994
  const type = file.metadata.mimeType.startsWith("image/") ? "image" : "file";
8883
8995
  const saveRes = await serverOps.saveBinaryFileFromPatch(file.filePath, req.body.parentRef, req.body.patchId, bytes, file.metadata.mimeType, type, file.metadata);
8884
8996
  if (saveRes.error) {
@@ -8895,7 +9007,13 @@ const ValServer = (valModules, options, callbacks, platform) => {
8895
9007
  status: 200,
8896
9008
  json: {
8897
9009
  patchId: req.body.patchId,
8898
- files: json.data.files
9010
+ files: json.data.files.map(file => {
9011
+ const sha256 = file.sha256 ?? sha256ByFilePath.get(file.filePath);
9012
+ return sha256 !== undefined ? {
9013
+ ...file,
9014
+ sha256
9015
+ } : file;
9016
+ })
8899
9017
  }
8900
9018
  };
8901
9019
  } catch (err) {
@@ -9124,7 +9242,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
9124
9242
  // TypeScript compiler. See `patch/ts/publishKit.ts`.
9125
9243
  const {
9126
9244
  getJsonEntryAtCommit
9127
- } = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-3d5b22a9.cjs.dev.js'); });
9245
+ } = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-d8f4fdc7.cjs.dev.js'); });
9128
9246
  const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
9129
9247
  if (fp.result.isErr(res)) {
9130
9248
  return historyErrorResponse(res.error);
@@ -10540,6 +10658,24 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
10540
10658
  });
10541
10659
  }
10542
10660
  const path = url.pathname.slice(route.length);
10661
+ if (path === internal.QUICK_PREVIEW_SERVICE_WORKER_PATH) {
10662
+ /*
10663
+ * The design tab's quick preview worker (`quickPreview.ts` in
10664
+ * `@valbuild/shared`). `Service-Worker-Allowed: /` lets a script at
10665
+ * this path control the whole origin, which it needs: it serves the
10666
+ * page's `/_app/` files. It serves them only to a page opened as a
10667
+ * quick preview, and the bridge stores them only for the site.
10668
+ */
10669
+ return convert({
10670
+ status: 200,
10671
+ headers: {
10672
+ "Content-Type": "text/javascript; charset=utf-8",
10673
+ "Service-Worker-Allowed": "/",
10674
+ "Cache-Control": "no-cache"
10675
+ },
10676
+ body: internal.QUICK_PREVIEW_SERVICE_WORKER_SOURCE
10677
+ });
10678
+ }
10543
10679
  const groupQueryParams = arr => {
10544
10680
  const map = {};
10545
10681
  for (const [key, value] of arr) {
@@ -4,7 +4,13 @@ import { ValServer, ValServerCallbacks } from "./ValServer.js";
4
4
  type Versions = {
5
5
  versions?: {
6
6
  core?: string;
7
+ /**
8
+ * The framework binding's version, whichever binding it is: the field is
9
+ * named for the first one, and admin.val.build reads it by that name.
10
+ */
7
11
  next?: string;
12
+ /** Which binding `next` is the version of. */
13
+ framework?: "next" | "tanstack";
8
14
  };
9
15
  };
10
16
  import type { ValPatchStore } from "./ValOpsMemory.js";
@@ -16,6 +16,15 @@ export type ValServerOptions = {
16
16
  apiKey?: string;
17
17
  project?: string;
18
18
  config: ValConfig;
19
+ /**
20
+ * The framework binding this server runs under, and its version: shown in
21
+ * the Studio's version list (`/versions`) and nowhere else. Absent where no
22
+ * binding said -- the demo, a test -- and the list then names no framework.
23
+ */
24
+ framework?: {
25
+ name: "next" | "tanstack";
26
+ version: string;
27
+ };
19
28
  /**
20
29
  * Called after a save has applied its patches, with the files it produced.
21
30
  *
@@ -1,4 +1,5 @@
1
1
  import { type ValConfig, type ValModules } from "@valbuild/core";
2
+ import { type ValServerConfig } from "../ValServer.js";
2
3
  import type { ValPatchStore } from "../ValOpsMemory.js";
3
4
  /** A `fetch`, as far as the Studio's client calls one. */
4
5
  export type InTabFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -24,4 +25,6 @@ export declare function createInTabValFetch(valModules: ValModules, options: {
24
25
  patchStore?: ValPatchStore;
25
26
  /** The path the Studio's client calls. */
26
27
  route?: string;
28
+ /** The binding that started it, for the Studio's version list. */
29
+ framework?: ValServerConfig["framework"];
27
30
  }): InTabFetch;
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { F as bytesToUtf8, G as posixPath } from './ValRouterCore-4e292ec5.esm.js';
2
+ import { F as bytesToUtf8, G as posixPath } from './ValRouterCore-4d920904.esm.js';
3
3
  import { result } from '@valbuild/core/fp';
4
4
  import { a as analyzeValModule, c as analyzeJsonValuesEntries } from './jsonValuesModule-427d68c8.esm.js';
5
5
  import '@valbuild/core';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ts = require('typescript');
4
- var ValRouterCore = require('./ValRouterCore-3ca4d25e.cjs.prod.js');
4
+ var ValRouterCore = require('./ValRouterCore-85341829.cjs.prod.js');
5
5
  var fp = require('@valbuild/core/fp');
6
6
  var jsonValuesModule = require('./jsonValuesModule-d1bb8d8f.cjs.prod.js');
7
7
  require('@valbuild/core');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ts = require('typescript');
4
- var ValRouterCore = require('./ValRouterCore-d151b850.cjs.dev.js');
4
+ var ValRouterCore = require('./ValRouterCore-bee6f858.cjs.dev.js');
5
5
  var fp = require('@valbuild/core/fp');
6
6
  var jsonValuesModule = require('./jsonValuesModule-8ae503a8.cjs.dev.js');
7
7
  require('@valbuild/core');
@@ -12,7 +12,7 @@ var path = require('path');
12
12
  var fs = require('fs');
13
13
  var vm = require('node:vm');
14
14
  var node_module = require('node:module');
15
- var ValRouterCore = require('./ValRouterCore-d151b850.cjs.dev.js');
15
+ var ValRouterCore = require('./ValRouterCore-bee6f858.cjs.dev.js');
16
16
  var server = require('@valbuild/ui/server');
17
17
  var z = require('zod');
18
18
  var zodValidationError = require('zod-validation-error');
@@ -13742,11 +13742,18 @@ commitPrepared,
13742
13742
  * `ValServerOptions.publishOverride`.
13743
13743
  */
13744
13744
  publishOverride) {
13745
+ var _opts$versions;
13745
13746
  const valServerConfig = await initHandlerOptions(route, opts, config);
13746
13747
  return ValRouterCore.ValServer(valModules, {
13747
13748
  formatter,
13748
13749
  commitPrepared,
13749
13750
  publishOverride,
13751
+ ...((_opts$versions = opts.versions) !== null && _opts$versions !== void 0 && _opts$versions.framework && opts.versions.next ? {
13752
+ framework: {
13753
+ name: opts.versions.framework,
13754
+ version: opts.versions.next
13755
+ }
13756
+ } : {}),
13750
13757
  ...valServerConfig
13751
13758
  }, callbacks, nodePlatform);
13752
13759
  }
@@ -12,7 +12,7 @@ var path = require('path');
12
12
  var fs = require('fs');
13
13
  var vm = require('node:vm');
14
14
  var node_module = require('node:module');
15
- var ValRouterCore = require('./ValRouterCore-3ca4d25e.cjs.prod.js');
15
+ var ValRouterCore = require('./ValRouterCore-85341829.cjs.prod.js');
16
16
  var server = require('@valbuild/ui/server');
17
17
  var z = require('zod');
18
18
  var zodValidationError = require('zod-validation-error');
@@ -13742,11 +13742,18 @@ commitPrepared,
13742
13742
  * `ValServerOptions.publishOverride`.
13743
13743
  */
13744
13744
  publishOverride) {
13745
+ var _opts$versions;
13745
13746
  const valServerConfig = await initHandlerOptions(route, opts, config);
13746
13747
  return ValRouterCore.ValServer(valModules, {
13747
13748
  formatter,
13748
13749
  commitPrepared,
13749
13750
  publishOverride,
13751
+ ...((_opts$versions = opts.versions) !== null && _opts$versions !== void 0 && _opts$versions.framework && opts.versions.next ? {
13752
+ framework: {
13753
+ name: opts.versions.framework,
13754
+ version: opts.versions.next
13755
+ }
13756
+ } : {}),
13750
13757
  ...valServerConfig
13751
13758
  }, callbacks, nodePlatform);
13752
13759
  }
@@ -10,8 +10,8 @@ import path from 'path';
10
10
  import fs from 'fs';
11
11
  import vm from 'node:vm';
12
12
  import { Module } from 'node:module';
13
- import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, i as isJsonValuesRootOp, a as rebaseContentOp, c as classifyJsonValuesOp, V as ValOps, b as bufferFromDataUrl, g as getFieldsForType, u as uploadRemoteFile, d as getFileExt, e as guessMimeTypeFromPath, h as createMetadataFromBuffer, j as ValOpsMemory, k as isHlsMasterPlaylist, s as sumHlsSegmentDurations, p as parseHlsMasterVariants, l as largestHlsVariant, m as fallbackRefOf, n as mapHlsUris, o as movedRemoteHost, q as needsHostCheck, t as rewriteRefHost, w as fallbackRemoteHost, x as checkRemoteFiles, y as ValServer, z as createValRequestHandler, A as getNewJsonEntryPaths, B as formatPatchSourceError } from './ValRouterCore-4e292ec5.esm.js';
14
- export { I as InMemoryPatchStore, j as ValOpsMemory, C as askOncePerHost, c as classifyJsonValuesOp, B as formatPatchSourceError, d as getFileExt, D as getSettings, a as rebaseContentOp, u as uploadRemoteFile } from './ValRouterCore-4e292ec5.esm.js';
13
+ import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, i as isJsonValuesRootOp, a as rebaseContentOp, c as classifyJsonValuesOp, V as ValOps, b as bufferFromDataUrl, g as getFieldsForType, u as uploadRemoteFile, d as getFileExt, e as guessMimeTypeFromPath, h as createMetadataFromBuffer, j as ValOpsMemory, k as isHlsMasterPlaylist, s as sumHlsSegmentDurations, p as parseHlsMasterVariants, l as largestHlsVariant, m as fallbackRefOf, n as mapHlsUris, o as movedRemoteHost, q as needsHostCheck, t as rewriteRefHost, w as fallbackRemoteHost, x as checkRemoteFiles, y as ValServer, z as createValRequestHandler, A as getNewJsonEntryPaths, B as formatPatchSourceError } from './ValRouterCore-4d920904.esm.js';
14
+ export { I as InMemoryPatchStore, j as ValOpsMemory, C as askOncePerHost, c as classifyJsonValuesOp, B as formatPatchSourceError, d as getFileExt, D as getSettings, a as rebaseContentOp, u as uploadRemoteFile } from './ValRouterCore-4d920904.esm.js';
15
15
  import { createUIRequestHandler } from '@valbuild/ui/server';
16
16
  import z$1, { z } from 'zod';
17
17
  import { fromError } from 'zod-validation-error';
@@ -13706,11 +13706,18 @@ commitPrepared,
13706
13706
  * `ValServerOptions.publishOverride`.
13707
13707
  */
13708
13708
  publishOverride) {
13709
+ var _opts$versions;
13709
13710
  const valServerConfig = await initHandlerOptions(route, opts, config);
13710
13711
  return ValServer(valModules, {
13711
13712
  formatter,
13712
13713
  commitPrepared,
13713
13714
  publishOverride,
13715
+ ...((_opts$versions = opts.versions) !== null && _opts$versions !== void 0 && _opts$versions.framework && opts.versions.next ? {
13716
+ framework: {
13717
+ name: opts.versions.framework,
13718
+ version: opts.versions.next
13719
+ }
13720
+ } : {}),
13714
13721
  ...valServerConfig
13715
13722
  }, callbacks, nodePlatform);
13716
13723
  }
package/package.json CHANGED
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "exports": true
29
29
  },
30
- "version": "0.150.10",
30
+ "version": "0.150.12",
31
31
  "devDependencies": {
32
32
  "@prettier/sync": "^0.6.1",
33
33
  "@types/jest": "^30.0.0",
@@ -41,9 +41,9 @@
41
41
  "typescript": "^6.0.3",
42
42
  "zod": "^4.4.3",
43
43
  "zod-validation-error": "^5.0.0",
44
- "@valbuild/shared": "0.150.10",
45
44
  "@valbuild/core": "0.150.3",
46
- "@valbuild/ui": "0.150.10"
45
+ "@valbuild/shared": "0.150.12",
46
+ "@valbuild/ui": "0.150.12"
47
47
  },
48
48
  "engines": {
49
49
  "node": "^20.19.0 || >=22"