@valbuild/tanstack 0.130.0 → 0.132.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,128 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.132.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#689](https://github.com/valbuild/val/pull/689) [`c1c93c1`](https://github.com/valbuild/val/commit/c1c93c1431072b37b4098bcdc49ebe207e3a28d5) Thanks [@freekh](https://github.com/freekh)! - `initValContent` takes an `http` option, so the content readers can be put in
8
+ http mode.
9
+
10
+ They build a Val server of their own — they resolve content by asking it, not by
11
+ calling the API over HTTP — so the mode question is put to them separately.
12
+ `initValServer` has had `http` for a while; these readers did not, which meant a
13
+ host could configure its API for http mode and leave the half of Val that
14
+ renders its pages inferring a mode instead. Where the credentials are handed to
15
+ Val in code rather than through the environment there is nothing to infer from,
16
+ because `process.env.VAL_API_KEY` is undefined in a bundle built separately from
17
+ its dependencies.
18
+
19
+ Pass the same object both halves get. `gitCommit` is the field that is silently
20
+ wrong rather than loudly missing: every read in this mode fetches the module's
21
+ path from the content service at that commit, so readers given a different one
22
+ from the API resolve a different version of the same file — a draft render
23
+ showing content that is neither the draft nor what the site serves, with nothing
24
+ failing anywhere.
25
+
26
+ ### Patch Changes
27
+
28
+ - [#689](https://github.com/valbuild/val/pull/689) [`d0d684b`](https://github.com/valbuild/val/commit/d0d684bdd62d2d9a2cddff38beadf9175f55bf91) Thanks [@freekh](https://github.com/freekh)! - A probe for the seams a host that BUILDS rather than deploys depends on.
29
+
30
+ `examples/tanstack/scripts/hostPublishProbe.ts` configures both halves of Val in
31
+ `http` mode and drives a publish through `publishOverride`, against
32
+ `e2e/mock-content-host`. Nothing exercised those two together: `e2e/http/` drives
33
+ the Studio, and `publishOverride` has no UI to drive it from.
34
+
35
+ What it pins is the ordering. A host whose publish is a build must commit
36
+ _first_ — building first hands its builder content the content service does not
37
+ have yet, so every read in the new build resolves the commit from before the
38
+ save, and the site shows pre-save content with the edits already consumed, with
39
+ nothing failing to say so.
40
+
41
+ No product code changed.
42
+
43
+ - Updated dependencies [[`72cc676`](https://github.com/valbuild/val/commit/72cc6765e92a6e72b5c09ddd9eed8efa7ce899f2)]:
44
+ - @valbuild/server@0.132.0
45
+ - @valbuild/language-server@0.132.0
46
+ - @valbuild/mcp@0.132.0
47
+
48
+ ## 0.131.0
49
+
50
+ ### Minor Changes
51
+
52
+ - [#686](https://github.com/valbuild/val/pull/686) [`0d5857b`](https://github.com/valbuild/val/commit/0d5857b731e11f7e6a011f79297df6485908c31f) Thanks [@freekh](https://github.com/freekh)! - Say `VAL_MODE=memory` where there is no disk, and get a sentence instead of an `EPERM`
53
+
54
+ Memory mode — the one for a host that holds the project's source itself — is
55
+ selected by passing `sourceFiles`, and it has to be: nothing in an environment
56
+ can supply a project's source, so a mode that an env var could switch on would
57
+ be a server with no content in it.
58
+
59
+ The cost was the failure when a host forgot. Val inferred `fs` mode, `fs` mode
60
+ went looking for a working tree, and in a Worker isolate the first thing to
61
+ touch the disk failed:
62
+
63
+ ```
64
+ patch-error /bundle/.val/patches.lock: EPERM
65
+ ```
66
+
67
+ That names a path two layers below the decision that caused it, and nobody
68
+ reading it would guess "your server was configured for the wrong mode".
69
+
70
+ So an environment can now DECLARE that it has no disk:
71
+
72
+ ```
73
+ VAL_MODE=memory
74
+ ```
75
+
76
+ It does not turn memory mode on. It says the host is supposed to be supplying
77
+ `sourceFiles`, so if none arrive, Val refuses at configuration time and says
78
+ where to pass them. `VAL_MODE=` counts as unset, the way a shell means it; any
79
+ other value is refused rather than ignored, since leaving you in `fs` mode is
80
+ the exact failure this is meant to catch.
81
+
82
+ **`initValContent` takes the same options, and this is the release that
83
+ noticed.** It builds a Val server of its own — these readers resolve content by
84
+ asking it, not by calling the API over HTTP — so configuring `initValServer`
85
+ alone left them inferring `fs` mode. On a host with no filesystem that is a
86
+ reader looking for a working tree that is not there; it went unnoticed because
87
+ published reads still worked.
88
+
89
+ ```ts
90
+ const patchStore = new InMemoryPatchStore(); // now exported from this package
91
+
92
+ const { valApiHandler, draftMode } = initValServer(valModules, config, {
93
+ sourceFiles: FILES,
94
+ patchStore,
95
+ unsafelyAllowUnauthenticated: true,
96
+ });
97
+
98
+ const { fetchValStega } = initValContent(config, valModules, {
99
+ draftMode,
100
+ // The same three. Two patch stores are two sets of pending edits, and a
101
+ // reader that checks a session the host never issues answers itself 401 and
102
+ // falls back to published content — a draft render showing the live site.
103
+ sourceFiles: FILES,
104
+ patchStore,
105
+ unsafelyAllowUnauthenticated: true,
106
+ });
107
+ ```
108
+
109
+ All three are optional. Left out, this reader gets its own store and its own
110
+ answer about authentication, which is right for published content.
111
+
112
+ `@valbuild/next` has no memory mode: its `initValServer` takes neither option,
113
+ so for a Next app `VAL_MODE=memory` names an environment Val cannot serve from,
114
+ and the error says so.
115
+
116
+ Nothing changes for an app that sets none of this: `http` when `VAL_API_KEY`
117
+ and `VAL_SECRET` are both present, `fs` otherwise, as before.
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [[`0d5857b`](https://github.com/valbuild/val/commit/0d5857b731e11f7e6a011f79297df6485908c31f)]:
122
+ - @valbuild/server@0.131.0
123
+ - @valbuild/language-server@0.131.0
124
+ - @valbuild/mcp@0.131.0
125
+
3
126
  ## 0.130.0
4
127
 
5
128
  ### Minor Changes
@@ -1,4 +1,5 @@
1
1
  export { initValServer } from "./initValServer.js";
2
+ export { InMemoryPatchStore, type ValPatchStore } from "@valbuild/server";
2
3
  export type { ValHttpMode } from "./initValServer.js";
3
4
  export { initValContent } from "./initValContent.js";
4
5
  export { valDraftMode, hasValEnableCookieOnServer, VAL_DRAFT_MODE_COOKIE, type ValDraftMode, } from "./valDraftMode.js";
@@ -1,7 +1,8 @@
1
1
  import { type StegaOfSource } from "@valbuild/react/stega";
2
2
  import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject, JsonSource } from "@valbuild/core";
3
- import { ValServer } from "@valbuild/server";
3
+ import { ValServer, type ValPatchStore } from "@valbuild/server";
4
4
  import { type ValDraftMode } from "./valDraftMode.js";
5
+ import type { ValHttpMode } from "./initValServer.js";
5
6
  declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
6
7
  get(name: string): string | null;
7
8
  }>, getCookies: () => Promise<{
@@ -113,6 +114,57 @@ export declare function initValContent(config: ValConfig, valModules: ValModules
113
114
  * the API turns preview on and these readers are what has to notice.
114
115
  */
115
116
  draftMode?: ValDraftMode;
117
+ /**
118
+ * The project's source, for a host that holds it rather than having it on
119
+ * a disk. Pass the SAME record `initValServer` got.
120
+ *
121
+ * These readers have a Val server of their own -- they resolve content by
122
+ * asking it, not by calling the API over HTTP -- so the mode question is
123
+ * put to them separately, and answering it only for `initValServer` left
124
+ * the readers inferring `fs` mode. On a host with no filesystem that is
125
+ * a reader looking for a working tree that is not there.
126
+ */
127
+ sourceFiles?: Record<string, string>;
128
+ /**
129
+ * Where pending patches live, with {@link sourceFiles}. Pass the SAME
130
+ * store `initValServer` got.
131
+ *
132
+ * Two stores are two sets of pending edits: the API would write a patch
133
+ * into one and a draft render would read the other and show none of it.
134
+ * Left out, this reader gets its own, which is correct for published
135
+ * content and empty for drafts.
136
+ */
137
+ patchStore?: ValPatchStore;
138
+ /**
139
+ * Serve memory mode without authenticating. Pass the SAME value
140
+ * `initValServer` got.
141
+ *
142
+ * This reader's server checks a session like the API's does, so a host
143
+ * that authenticates outside Val -- and therefore sends no Val session
144
+ * cookie -- gets 401 from its own reader and silently falls back to
145
+ * PUBLISHED content. A draft render that shows the live site is the
146
+ * hardest kind of wrong to notice.
147
+ */
148
+ unsafelyAllowUnauthenticated?: boolean;
149
+ /**
150
+ * Put these readers in `http` mode. Pass the SAME object `initValServer`
151
+ * got.
152
+ *
153
+ * Separate for the same reason {@link sourceFiles} is: these readers have
154
+ * a Val server of their own, so the mode question is put to them
155
+ * independently. Answering it only for `initValServer` leaves them
156
+ * inferring -- and on a host that hands Val its credentials in code rather
157
+ * than through the environment, there is nothing to infer FROM, since
158
+ * `process.env.VAL_API_KEY` is undefined in a bundle built separately from
159
+ * its dependencies.
160
+ *
161
+ * `gitCommit` is what makes this more than bookkeeping here: every read
162
+ * fetches the module's path from the content service AT THAT COMMIT, so
163
+ * these readers and the API have to be given the same one or a draft
164
+ * render resolves a different version of the file than the site is
165
+ * running.
166
+ */
167
+ http?: ValHttpMode;
116
168
  }): {
117
169
  fetchValStega: ReturnType<typeof initFetchValStega>;
118
170
  fetchValKeyStega: ReturnType<typeof initFetchValKeyStega>;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-f2ffc76f.cjs.dev.js');
5
+ var version = require('./version-c38b1075.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-68d92818.cjs.prod.js');
5
+ var version = require('./version-d6540d28.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-d388ee0d.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-61d23009.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.130.0",
213
+ version: "0.132.0",
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.130.0",
215
+ version: "0.132.0",
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.130.0",
215
+ version: "0.132.0",
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.130.0",
17
+ "version": "0.132.0",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -43,10 +43,10 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@valbuild/core": "0.130.0",
46
- "@valbuild/language-server": "0.130.0",
47
- "@valbuild/mcp": "0.130.0",
46
+ "@valbuild/language-server": "0.132.0",
47
+ "@valbuild/mcp": "0.132.0",
48
48
  "@valbuild/react": "0.130.0",
49
- "@valbuild/server": "0.130.0",
49
+ "@valbuild/server": "0.132.0",
50
50
  "@valbuild/shared": "0.130.0",
51
51
  "@valbuild/ui": "0.130.0"
52
52
  },
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-f2ffc76f.cjs.dev.js');
5
+ var version = require('../../dist/version-c38b1075.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');
@@ -993,13 +993,19 @@ function initValContent(config, valModules, opts) {
993
993
  var isEnabled = function isEnabled() {
994
994
  return draftMode.isEnabled();
995
995
  };
996
- var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2({
996
+ var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
997
997
  versions: {
998
998
  // `next` is the field name in the wire contract; see initValServer.
999
999
  next: tanstackVersion,
1000
1000
  core: coreVersion
1001
1001
  }
1002
- }, config), config, {
1002
+ }, config), (opts === null || opts === void 0 ? void 0 : opts.sourceFiles) !== undefined ? {
1003
+ sourceFiles: opts.sourceFiles
1004
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.patchStore) !== undefined ? {
1005
+ patchStore: opts.patchStore
1006
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated) !== undefined ? {
1007
+ unsafelyAllowUnauthenticated: opts.unsafelyAllowUnauthenticated
1008
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.http) !== undefined ? opts.http : {}), config, {
1003
1009
  isEnabled: isEnabled,
1004
1010
  onEnable: function onEnable() {
1005
1011
  return draftMode.enable();
@@ -1049,6 +1055,10 @@ version.setValEnableCookieReader(hasValEnableCookieOnServer);
1049
1055
  // Re-exported so an app that mounts the MCP endpoint through this package does
1050
1056
  // not also have to depend on `@valbuild/mcp` for the types it hands back.
1051
1057
 
1058
+ Object.defineProperty(exports, 'InMemoryPatchStore', {
1059
+ enumerable: true,
1060
+ get: function () { return server.InMemoryPatchStore; }
1061
+ });
1052
1062
  exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
1053
1063
  exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
1054
1064
  exports.initValContent = initValContent;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-68d92818.cjs.prod.js');
5
+ var version = require('../../dist/version-d6540d28.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');
@@ -993,13 +993,19 @@ function initValContent(config, valModules, opts) {
993
993
  var isEnabled = function isEnabled() {
994
994
  return draftMode.isEnabled();
995
995
  };
996
- var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2({
996
+ var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
997
997
  versions: {
998
998
  // `next` is the field name in the wire contract; see initValServer.
999
999
  next: tanstackVersion,
1000
1000
  core: coreVersion
1001
1001
  }
1002
- }, config), config, {
1002
+ }, config), (opts === null || opts === void 0 ? void 0 : opts.sourceFiles) !== undefined ? {
1003
+ sourceFiles: opts.sourceFiles
1004
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.patchStore) !== undefined ? {
1005
+ patchStore: opts.patchStore
1006
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated) !== undefined ? {
1007
+ unsafelyAllowUnauthenticated: opts.unsafelyAllowUnauthenticated
1008
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.http) !== undefined ? opts.http : {}), config, {
1003
1009
  isEnabled: isEnabled,
1004
1010
  onEnable: function onEnable() {
1005
1011
  return draftMode.enable();
@@ -1049,6 +1055,10 @@ version.setValEnableCookieReader(hasValEnableCookieOnServer);
1049
1055
  // Re-exported so an app that mounts the MCP endpoint through this package does
1050
1056
  // not also have to depend on `@valbuild/mcp` for the types it hands back.
1051
1057
 
1058
+ Object.defineProperty(exports, 'InMemoryPatchStore', {
1059
+ enumerable: true,
1060
+ get: function () { return server.InMemoryPatchStore; }
1061
+ });
1052
1062
  exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
1053
1063
  exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
1054
1064
  exports.initValContent = initValContent;
@@ -1,7 +1,8 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-d388ee0d.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-61d23009.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';
5
+ export { InMemoryPatchStore } from '@valbuild/server';
5
6
  import { b as initValRouteFromVal, g as getJsonEntryStegaRoot, i as isJsonValuesRecordSchema, a as getValRouteUrlFromVal, _ as _typeof } from '../../dist/routeFromVal-728295a0.esm.js';
6
7
  import { stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
7
8
  import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
@@ -971,13 +972,19 @@ function initValContent(config, valModules, opts) {
971
972
  var isEnabled = function isEnabled() {
972
973
  return draftMode.isEnabled();
973
974
  };
974
- var valServerPromise = createValServer(valModules, valApiEndpoints, _objectSpread2({
975
+ var valServerPromise = createValServer(valModules, valApiEndpoints, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
975
976
  versions: {
976
977
  // `next` is the field name in the wire contract; see initValServer.
977
978
  next: tanstackVersion,
978
979
  core: coreVersion
979
980
  }
980
- }, config), config, {
981
+ }, config), (opts === null || opts === void 0 ? void 0 : opts.sourceFiles) !== undefined ? {
982
+ sourceFiles: opts.sourceFiles
983
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.patchStore) !== undefined ? {
984
+ patchStore: opts.patchStore
985
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated) !== undefined ? {
986
+ unsafelyAllowUnauthenticated: opts.unsafelyAllowUnauthenticated
987
+ } : {}), (opts === null || opts === void 0 ? void 0 : opts.http) !== undefined ? opts.http : {}), config, {
981
988
  isEnabled: isEnabled,
982
989
  onEnable: function onEnable() {
983
990
  return draftMode.enable();