@valbuild/tanstack 0.129.0 → 0.131.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,181 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.131.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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`
8
+
9
+ Memory mode — the one for a host that holds the project's source itself — is
10
+ selected by passing `sourceFiles`, and it has to be: nothing in an environment
11
+ can supply a project's source, so a mode that an env var could switch on would
12
+ be a server with no content in it.
13
+
14
+ The cost was the failure when a host forgot. Val inferred `fs` mode, `fs` mode
15
+ went looking for a working tree, and in a Worker isolate the first thing to
16
+ touch the disk failed:
17
+
18
+ ```
19
+ patch-error /bundle/.val/patches.lock: EPERM
20
+ ```
21
+
22
+ That names a path two layers below the decision that caused it, and nobody
23
+ reading it would guess "your server was configured for the wrong mode".
24
+
25
+ So an environment can now DECLARE that it has no disk:
26
+
27
+ ```
28
+ VAL_MODE=memory
29
+ ```
30
+
31
+ It does not turn memory mode on. It says the host is supposed to be supplying
32
+ `sourceFiles`, so if none arrive, Val refuses at configuration time and says
33
+ where to pass them. `VAL_MODE=` counts as unset, the way a shell means it; any
34
+ other value is refused rather than ignored, since leaving you in `fs` mode is
35
+ the exact failure this is meant to catch.
36
+
37
+ **`initValContent` takes the same options, and this is the release that
38
+ noticed.** It builds a Val server of its own — these readers resolve content by
39
+ asking it, not by calling the API over HTTP — so configuring `initValServer`
40
+ alone left them inferring `fs` mode. On a host with no filesystem that is a
41
+ reader looking for a working tree that is not there; it went unnoticed because
42
+ published reads still worked.
43
+
44
+ ```ts
45
+ const patchStore = new InMemoryPatchStore(); // now exported from this package
46
+
47
+ const { valApiHandler, draftMode } = initValServer(valModules, config, {
48
+ sourceFiles: FILES,
49
+ patchStore,
50
+ unsafelyAllowUnauthenticated: true,
51
+ });
52
+
53
+ const { fetchValStega } = initValContent(config, valModules, {
54
+ draftMode,
55
+ // The same three. Two patch stores are two sets of pending edits, and a
56
+ // reader that checks a session the host never issues answers itself 401 and
57
+ // falls back to published content — a draft render showing the live site.
58
+ sourceFiles: FILES,
59
+ patchStore,
60
+ unsafelyAllowUnauthenticated: true,
61
+ });
62
+ ```
63
+
64
+ All three are optional. Left out, this reader gets its own store and its own
65
+ answer about authentication, which is right for published content.
66
+
67
+ `@valbuild/next` has no memory mode: its `initValServer` takes neither option,
68
+ so for a Next app `VAL_MODE=memory` names an environment Val cannot serve from,
69
+ and the error says so.
70
+
71
+ Nothing changes for an app that sets none of this: `http` when `VAL_API_KEY`
72
+ and `VAL_SECRET` are both present, `fs` otherwise, as before.
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [[`0d5857b`](https://github.com/valbuild/val/commit/0d5857b731e11f7e6a011f79297df6485908c31f)]:
77
+ - @valbuild/server@0.131.0
78
+ - @valbuild/language-server@0.131.0
79
+ - @valbuild/mcp@0.131.0
80
+
81
+ ## 0.130.0
82
+
83
+ ### Minor Changes
84
+
85
+ - [#684](https://github.com/valbuild/val/pull/684) [`cab4098`](https://github.com/valbuild/val/commit/cab4098969585977b8d7574e86d66fcb01cb1d75) Thanks [@freekh](https://github.com/freekh)! - A third ValOps mode, for a host that already holds its own source
86
+
87
+ EXPERIMENTAL. `fs` mode assumes a working tree it can watch and write; `http`
88
+ mode assumes Val's content service owns the patch chain and that a commit is a
89
+ git commit. A host that builds and publishes its own output is neither: it holds
90
+ the source already, it has nowhere to watch, and its "commit" is a new build.
91
+
92
+ Forcing such a host into `fs` mode cost three things, all now fixed: `/stat`
93
+ long-polled against watchers that could never fire, burning CPU for the whole
94
+ hold to learn nothing;
95
+ `/api/val/enable` 500'd; and every read of a `.val.ts` went through a shimmed
96
+ filesystem when the host could simply hand the source over.
97
+
98
+ `ValOpsMemory` takes the source as `sourceFiles`, refuses the local binary
99
+ members by name — this configuration uses Val's remote files — and answers the
100
+ history members with the same closed `not-supported-in-fs-mode` error `ValOpsFS`
101
+ gives, so the History UI degrades the way it already knows how rather than
102
+ inventing a commit list.
103
+
104
+ `getStat` still long-polls -- the hold is what paces the client, and an earlier
105
+ version that answered immediately turned a 20-second poll into a request every
106
+ 6ms -- but it parks on a SIGNAL rather than a timer. This mode owns its store,
107
+ so it is told when something changes: no timers while parked, and a patch
108
+ written by another tab is seen at once rather than up to 250ms later.
109
+
110
+ Two seams come with it. `commitPrepared` lets a host take what a save produced
111
+ instead of a git commit, and `publishOverride` lets a publish be something other
112
+ than a push. Both are opt-in; an app that sets neither behaves exactly as before.
113
+
114
+ The in-memory patch store is explicitly **not durable**. It is behind
115
+ `ValPatchStore`, so a durable implementation is a swap rather than a rewrite,
116
+ but as shipped a restart loses unpublished patches.
117
+
118
+ **Memory mode authenticates.** `ValOps` gained `requiresAuth` alongside
119
+ `patchesAreLocal`, because one flag was answering two questions: whether a store
120
+ auto-saves or publishes (behaviour, reported as `mode` and keyed off by the UI),
121
+ and whether an unauthenticated request may write (security). With two
122
+ implementations the answers coincided — `fs` is a developer's own machine where
123
+ no credential exists, `http` is remote — so `getAuth` was written against
124
+ `patchesAreLocal` and returned anonymous _success_ for a missing cookie, an
125
+ invalid JWT, an unparseable payload, or no configured secret.
126
+
127
+ Memory mode splits them: its store is local, and it runs deployed. It therefore
128
+ requires a verified session, like `http` mode. A host that authorises requests
129
+ before Val sees them can opt out with `unsafelyAllowUnauthenticated`, which is
130
+ spelled that way on purpose and warns at startup. `fs` mode is unchanged.
131
+
132
+ Val's own MCP endpoint refuses memory mode outright. It has the same absence fs
133
+ mode has — no credential, no backend, every permission check on the far side of
134
+ one — and unlike fs mode it is meant to run deployed, so the existing
135
+ "development only" and loopback guards refuse nothing. A host in this mode owns
136
+ its own trust boundary and can offer the tools through it.
137
+
138
+ Internally, the routes' `instanceof ValOpsFS` checks meant "is this a local
139
+ store" — correct with two implementations and silently wrong with three. They are
140
+ now `ValOps.patchesAreLocal` at all 17 policy sites.
141
+
142
+ ### Patch Changes
143
+
144
+ - [#684](https://github.com/valbuild/val/pull/684) [`cab4098`](https://github.com/valbuild/val/commit/cab4098969585977b8d7574e86d66fcb01cb1d75) Thanks [@freekh](https://github.com/freekh)! - `@valbuild/tanstack` can be bundled for a browser again
145
+
146
+ The root entry — the one every client component imports — reached TanStack
147
+ Start's server module from inside `isValEnabled`:
148
+
149
+ ```js
150
+ const { getCookie } = await import("@tanstack/react-start/server");
151
+ ```
152
+
153
+ At runtime that is already correct anywhere but a server: the import fails, the
154
+ `catch` returns `false`, which is what the function's documentation says it does.
155
+ Under Vite the dynamic form also keeps it out of the client bundle.
156
+
157
+ It does not everywhere. A host that bundles this package ahead of time and audits
158
+ what each chunk imports sees a dynamically imported chunk as a chunk like any
159
+ other — and this one reaches Start's SSR path and lands on `node:stream`. The
160
+ package could not be built for a browser or a Cloudflare Worker at all, which
161
+ made every component importing it unusable there.
162
+
163
+ The edge is now inverted. The root entry holds a slot, `@valbuild/tanstack/server`
164
+ fills it on import with the implementation that was already there, and the root
165
+ entry no longer names TanStack's server module. Nothing changes for an app that
166
+ imports `/server`, which is every app with a Val API. An `isValEnabled()` call
167
+ before `/server` is first imported returns `false` — the same answer the old
168
+ implementation's `catch` gave in that situation.
169
+
170
+ - Updated dependencies [[`be1e8be`](https://github.com/valbuild/val/commit/be1e8bee673207596b3eb3d9a9886b8ade9b332f), [`cab4098`](https://github.com/valbuild/val/commit/cab4098969585977b8d7574e86d66fcb01cb1d75), [`8425378`](https://github.com/valbuild/val/commit/8425378c315ea46b5d822f1130b633e0449ff1b0), [`7d13dbc`](https://github.com/valbuild/val/commit/7d13dbced9ea49d8243b6b6cf9854cd1a259501f), [`cab4098`](https://github.com/valbuild/val/commit/cab4098969585977b8d7574e86d66fcb01cb1d75), [`07db94c`](https://github.com/valbuild/val/commit/07db94c23b73c8c0b2b50a30a89926823c2da1d6), [`473a185`](https://github.com/valbuild/val/commit/473a185f70351b44388f3bc1852649e2c1dbe001), [`64f0de3`](https://github.com/valbuild/val/commit/64f0de339b8621cb5a6c422dfe55cae5b2bbe2a0), [`cab4098`](https://github.com/valbuild/val/commit/cab4098969585977b8d7574e86d66fcb01cb1d75)]:
171
+ - @valbuild/ui@0.130.0
172
+ - @valbuild/server@0.130.0
173
+ - @valbuild/mcp@0.130.0
174
+ - @valbuild/core@0.130.0
175
+ - @valbuild/react@0.130.0
176
+ - @valbuild/language-server@0.130.0
177
+ - @valbuild/shared@0.130.0
178
+
3
179
  ## 0.129.0
4
180
 
5
181
  ### Patch Changes
@@ -1,4 +1,6 @@
1
1
  export { initValServer } from "./initValServer.js";
2
+ export { InMemoryPatchStore, type ValPatchStore } from "@valbuild/server";
3
+ export type { ValHttpMode } from "./initValServer.js";
2
4
  export { initValContent } from "./initValContent.js";
3
5
  export { valDraftMode, hasValEnableCookieOnServer, VAL_DRAFT_MODE_COOKIE, type ValDraftMode, } from "./valDraftMode.js";
4
6
  export { initValMcp } from "./initValMcp.js";
@@ -1,6 +1,6 @@
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
5
  declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
6
6
  get(name: string): string | null;
@@ -113,6 +113,38 @@ export declare function initValContent(config: ValConfig, valModules: ValModules
113
113
  * the API turns preview on and these readers are what has to notice.
114
114
  */
115
115
  draftMode?: ValDraftMode;
116
+ /**
117
+ * The project's source, for a host that holds it rather than having it on
118
+ * a disk. Pass the SAME record `initValServer` got.
119
+ *
120
+ * These readers have a Val server of their own -- they resolve content by
121
+ * asking it, not by calling the API over HTTP -- so the mode question is
122
+ * put to them separately, and answering it only for `initValServer` left
123
+ * the readers inferring `fs` mode. On a host with no filesystem that is
124
+ * a reader looking for a working tree that is not there.
125
+ */
126
+ sourceFiles?: Record<string, string>;
127
+ /**
128
+ * Where pending patches live, with {@link sourceFiles}. Pass the SAME
129
+ * store `initValServer` got.
130
+ *
131
+ * Two stores are two sets of pending edits: the API would write a patch
132
+ * into one and a draft render would read the other and show none of it.
133
+ * Left out, this reader gets its own, which is correct for published
134
+ * content and empty for drafts.
135
+ */
136
+ patchStore?: ValPatchStore;
137
+ /**
138
+ * Serve memory mode without authenticating. Pass the SAME value
139
+ * `initValServer` got.
140
+ *
141
+ * This reader's server checks a session like the API's does, so a host
142
+ * that authenticates outside Val -- and therefore sends no Val session
143
+ * cookie -- gets 401 from its own reader and silently falls back to
144
+ * PUBLISHED content. A draft render that shows the live site is the
145
+ * hardest kind of wrong to notice.
146
+ */
147
+ unsafelyAllowUnauthenticated?: boolean;
116
148
  }): {
117
149
  fetchValStega: ReturnType<typeof initFetchValStega>;
118
150
  fetchValKeyStega: ReturnType<typeof initFetchValKeyStega>;
@@ -1,5 +1,37 @@
1
1
  import { ValConfig, ValModules } from "@valbuild/core";
2
+ import { type CommitContext, type CommitResult, type ValPatchStore } from "@valbuild/server";
2
3
  import { type ValDraftMode } from "./valDraftMode.js";
4
+ /**
5
+ * What `http` mode needs, as one object.
6
+ *
7
+ * A publish there is a commit on the project's repository, so this is the
8
+ * shape of "Val's content service holds my patches and my repo holds my
9
+ * content".
10
+ */
11
+ export type ValHttpMode = {
12
+ /** Names the PROJECT to the content service. */
13
+ apiKey: string;
14
+ /** Signs the session cookie. Any sufficiently random string. */
15
+ valSecret: string;
16
+ /** The commit the running code was built from. See the note at the use. */
17
+ gitCommit: string;
18
+ /** The branch a publish commits to. */
19
+ gitBranch: string;
20
+ /**
21
+ * Val's content service, when it is not the real one.
22
+ *
23
+ * For pointing at a local stand-in — `e2e/mock-content-host` in the Val
24
+ * repository, which implements the patch, commit and file routes without a
25
+ * git repository behind them.
26
+ *
27
+ * NOTE this does not redirect everything. `getSettings`, which remote files
28
+ * use, reads `process.env.VAL_CONTENT_URL` at module scope inside
29
+ * `@valbuild/server`; a host that bundles its dependencies separately cannot
30
+ * set that, so remote FILES still address the real host even when patches and
31
+ * commits go here.
32
+ */
33
+ valContentUrl?: string;
34
+ };
3
35
  export declare function initValServer(valModules: ValModules, config: ValConfig & {
4
36
  disableCache?: boolean;
5
37
  }, opts?: {
@@ -13,6 +45,83 @@ export declare function initValServer(valModules: ValModules, config: ValConfig
13
45
  * get, or the API will enable a preview the loaders cannot see.
14
46
  */
15
47
  draftMode?: ValDraftMode;
48
+ /**
49
+ * Called after a save has applied its patches, with the files it produced.
50
+ *
51
+ * EXPERIMENTAL — see VAL_PROMPT.md. For a host where "commit" is not
52
+ * "write to the working tree and let git take it from here": the files are
53
+ * `path -> content` (null = delete), which is what such a host publishes.
54
+ * It runs in addition to the save, not instead of it.
55
+ */
56
+ commitPrepared?: (commit: {
57
+ patchedSourceFiles: Record<string, string | null>;
58
+ }) => Promise<void>;
59
+ /**
60
+ * The project's source, by path — and, by being present, the choice of an
61
+ * in-memory store over the local filesystem.
62
+ *
63
+ * EXPERIMENTAL — see VAL_PROMPT.md. For a host that HOLDS the source rather
64
+ * than having it on a disk: `fs` mode wants a working tree it can watch and
65
+ * write, and giving such a host a shimmed filesystem to read through is
66
+ * what produced a `/stat` long-polling watchers that cannot fire. Here it
67
+ * simply hands the source over, and `commitPrepared` is where the publish
68
+ * goes.
69
+ */
70
+ /**
71
+ * Val's api key, for a host that cannot give the server one through the
72
+ * environment.
73
+ *
74
+ * `@valbuild/server` normally reads `VAL_API_KEY` itself. That works where
75
+ * it and the app are built together; it does not where the app is bundled
76
+ * separately from its dependencies — the build inlines env vars into the
77
+ * APP and leaves the dependency chunks alone, so Val's own
78
+ * `process.env.VAL_API_KEY` is undefined however the host sets it. The app
79
+ * can see it, so the app passes it.
80
+ *
81
+ * Only needed for REMOTE files, which upload to Val's content host at
82
+ * publish.
83
+ */
84
+ apiKey?: string;
85
+ /**
86
+ * Val's content service, when it is not the real one.
87
+ *
88
+ * Needed by REMOTE files in any mode: the bytes are pushed there at
89
+ * publish. In `http` mode the patches go there too, and
90
+ * {@link ValHttpMode.valContentUrl} says the same thing — pass either.
91
+ */
92
+ valContentUrl?: string;
93
+ /**
94
+ * What a publish DOES, when Val's content service holds the patches.
95
+ *
96
+ * EXPERIMENTAL — see `ValServerOptions.publishOverride`. By default a
97
+ * publish in that mode is a git commit; a host that publishes by building
98
+ * says so here. It is handed the default as `commitToGit`, so it can
99
+ * replace the commit or also perform it.
100
+ */
101
+ publishOverride?: (context: CommitContext) => Promise<CommitResult>;
102
+ /**
103
+ * Put this server in `http` mode: Val's content service owns the patches.
104
+ *
105
+ * Everything here is required together — `initHandlerOptions` throws for a
106
+ * proxy config missing any of them — which is why it is one option and not
107
+ * four.
108
+ */
109
+ http?: ValHttpMode;
110
+ sourceFiles?: Record<string, string>;
111
+ /**
112
+ * Where pending patches live, with {@link sourceFiles}. Defaults to memory,
113
+ * which dies with the process — see `ValPatchStore` for the durable swap.
114
+ */
115
+ patchStore?: ValPatchStore;
116
+ /**
117
+ * Serve without authenticating any request. Off by default.
118
+ *
119
+ * Only correct when this app authorises every request before Val sees it.
120
+ * Unlike local `fs` mode, {@link sourceFiles} is for a DEPLOYED host, so
121
+ * without this a session is required as in proxy mode -- otherwise anyone
122
+ * who can reach the route can create patches and trigger a publish.
123
+ */
124
+ unsafelyAllowUnauthenticated?: boolean;
16
125
  }): {
17
126
  /**
18
127
  * The Val API. Mount it on `/api/val/$` for every method:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-8aeb5ebd.cjs.dev.js');
5
+ var version = require('./version-4c4e9ed0.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');
@@ -66,23 +66,12 @@ function isValEnabled() {
66
66
  }
67
67
  function _isValEnabled() {
68
68
  _isValEnabled = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee() {
69
- var _yield$import, getCookie;
70
69
  return version._regenerator().w(function (_context) {
71
- while (1) switch (_context.p = _context.n) {
70
+ while (1) switch (_context.n) {
72
71
  case 0:
73
- _context.p = 0;
74
- _context.n = 1;
75
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@tanstack/react-start/server')); });
76
- case 1:
77
- _yield$import = _context.v;
78
- getCookie = _yield$import.getCookie;
79
- return _context.a(2, getCookie(core.Internal.VAL_ENABLE_COOKIE_NAME) === "true");
80
- case 2:
81
- _context.p = 2;
82
- _context.v;
83
- return _context.a(2, false);
72
+ return _context.a(2, version.readValEnableCookie());
84
73
  }
85
- }, _callee, null, [[0, 2]]);
74
+ }, _callee);
86
75
  }));
87
76
  return _isValEnabled.apply(this, arguments);
88
77
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-ecfd83cc.cjs.prod.js');
5
+ var version = require('./version-022ed31c.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');
@@ -66,23 +66,12 @@ function isValEnabled() {
66
66
  }
67
67
  function _isValEnabled() {
68
68
  _isValEnabled = version._asyncToGenerator(/*#__PURE__*/version._regenerator().m(function _callee() {
69
- var _yield$import, getCookie;
70
69
  return version._regenerator().w(function (_context) {
71
- while (1) switch (_context.p = _context.n) {
70
+ while (1) switch (_context.n) {
72
71
  case 0:
73
- _context.p = 0;
74
- _context.n = 1;
75
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@tanstack/react-start/server')); });
76
- case 1:
77
- _yield$import = _context.v;
78
- getCookie = _yield$import.getCookie;
79
- return _context.a(2, getCookie(core.Internal.VAL_ENABLE_COOKIE_NAME) === "true");
80
- case 2:
81
- _context.p = 2;
82
- _context.v;
83
- return _context.a(2, false);
72
+ return _context.a(2, version.readValEnableCookie());
84
73
  }
85
- }, _callee, null, [[0, 2]]);
74
+ }, _callee);
86
75
  }));
87
76
  return _isValEnabled.apply(this, arguments);
88
77
  }
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION$1 } from './version-a2bd1bca.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-b5c8e13d.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';
@@ -42,23 +42,12 @@ function isValEnabled() {
42
42
  }
43
43
  function _isValEnabled() {
44
44
  _isValEnabled = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
45
- var _yield$import, getCookie;
46
45
  return _regenerator().w(function (_context) {
47
- while (1) switch (_context.p = _context.n) {
46
+ while (1) switch (_context.n) {
48
47
  case 0:
49
- _context.p = 0;
50
- _context.n = 1;
51
- return import('@tanstack/react-start/server');
52
- case 1:
53
- _yield$import = _context.v;
54
- getCookie = _yield$import.getCookie;
55
- return _context.a(2, getCookie(Internal$1.VAL_ENABLE_COOKIE_NAME) === "true");
56
- case 2:
57
- _context.p = 2;
58
- _context.v;
59
- return _context.a(2, false);
48
+ return _context.a(2, readValEnableCookie());
60
49
  }
61
- }, _callee, null, [[0, 2]]);
50
+ }, _callee);
62
51
  }));
63
52
  return _isValEnabled.apply(this, arguments);
64
53
  }
@@ -136,6 +136,66 @@ function _asyncToGenerator(n) {
136
136
  };
137
137
  }
138
138
 
139
+ /**
140
+ * How `initVal().isValEnabled()` reaches the server without importing it.
141
+ *
142
+ * EXPERIMENTAL — see VAL_PROMPT.md.
143
+ *
144
+ * The cookie can only be read through `@tanstack/react-start/server`, and that
145
+ * module is reachable from this package's ROOT entry, which every client
146
+ * component imports. `initVal.ts` used `await import()` for exactly that reason,
147
+ * and under Vite the dynamic form does keep it out of the client bundle.
148
+ *
149
+ * It does not everywhere. A host that bundles this package ahead of time and
150
+ * audits what each chunk imports sees a dynamically imported chunk as a chunk
151
+ * like any other, and this one reaches TanStack's SSR path and lands on
152
+ * `node:stream/web`. That is why `@valbuild/tanstack` could not be built for a
153
+ * Cloudflare Worker at all.
154
+ *
155
+ * So the edge is inverted. The root entry holds a slot; `@valbuild/tanstack/server`
156
+ * fills it on import with the implementation that was already there,
157
+ * `hasValEnableCookieOnServer`. Nothing about the behaviour changes for an app
158
+ * that imports `/server` — which every app with a Val API does — and the root
159
+ * entry no longer names TanStack's server module at all.
160
+ *
161
+ * Ordering: the slot is filled when `/server` is first imported. An
162
+ * `isValEnabled()` call that somehow happens before that returns false, which
163
+ * is what the old implementation's `catch` returned in the same situation.
164
+ */
165
+
166
+ var reader = null;
167
+ function setValEnableCookieReader(read) {
168
+ reader = read;
169
+ }
170
+ function readValEnableCookie() {
171
+ return _readValEnableCookie.apply(this, arguments);
172
+ }
173
+ function _readValEnableCookie() {
174
+ _readValEnableCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
175
+ return _regenerator().w(function (_context) {
176
+ while (1) switch (_context.p = _context.n) {
177
+ case 0:
178
+ if (reader) {
179
+ _context.n = 1;
180
+ break;
181
+ }
182
+ return _context.a(2, false);
183
+ case 1:
184
+ _context.p = 1;
185
+ _context.n = 2;
186
+ return reader();
187
+ case 2:
188
+ return _context.a(2, _context.v);
189
+ case 3:
190
+ _context.p = 3;
191
+ _context.v;
192
+ return _context.a(2, false);
193
+ }
194
+ }, _callee, null, [[1, 3]]);
195
+ }));
196
+ return _readValEnableCookie.apply(this, arguments);
197
+ }
198
+
139
199
  var packageJson = {
140
200
  name: "@valbuild/tanstack",
141
201
  description: "Val for TanStack Start: hard-coded content - super-charged",
@@ -152,7 +212,7 @@ var packageJson = {
152
212
  "tanstack-router",
153
213
  "react"
154
214
  ],
155
- version: "0.129.0",
215
+ version: "0.131.0",
156
216
  scripts: {
157
217
  typecheck: "tsc --noEmit",
158
218
  test: "jest"
@@ -227,3 +287,5 @@ var VERSION = (_packageJson$version = packageJson.version) !== null && _packageJ
227
287
  exports.VERSION = VERSION;
228
288
  exports._asyncToGenerator = _asyncToGenerator;
229
289
  exports._regenerator = _regenerator;
290
+ exports.readValEnableCookie = readValEnableCookie;
291
+ exports.setValEnableCookieReader = setValEnableCookieReader;
@@ -136,6 +136,66 @@ function _asyncToGenerator(n) {
136
136
  };
137
137
  }
138
138
 
139
+ /**
140
+ * How `initVal().isValEnabled()` reaches the server without importing it.
141
+ *
142
+ * EXPERIMENTAL — see VAL_PROMPT.md.
143
+ *
144
+ * The cookie can only be read through `@tanstack/react-start/server`, and that
145
+ * module is reachable from this package's ROOT entry, which every client
146
+ * component imports. `initVal.ts` used `await import()` for exactly that reason,
147
+ * and under Vite the dynamic form does keep it out of the client bundle.
148
+ *
149
+ * It does not everywhere. A host that bundles this package ahead of time and
150
+ * audits what each chunk imports sees a dynamically imported chunk as a chunk
151
+ * like any other, and this one reaches TanStack's SSR path and lands on
152
+ * `node:stream/web`. That is why `@valbuild/tanstack` could not be built for a
153
+ * Cloudflare Worker at all.
154
+ *
155
+ * So the edge is inverted. The root entry holds a slot; `@valbuild/tanstack/server`
156
+ * fills it on import with the implementation that was already there,
157
+ * `hasValEnableCookieOnServer`. Nothing about the behaviour changes for an app
158
+ * that imports `/server` — which every app with a Val API does — and the root
159
+ * entry no longer names TanStack's server module at all.
160
+ *
161
+ * Ordering: the slot is filled when `/server` is first imported. An
162
+ * `isValEnabled()` call that somehow happens before that returns false, which
163
+ * is what the old implementation's `catch` returned in the same situation.
164
+ */
165
+
166
+ var reader = null;
167
+ function setValEnableCookieReader(read) {
168
+ reader = read;
169
+ }
170
+ function readValEnableCookie() {
171
+ return _readValEnableCookie.apply(this, arguments);
172
+ }
173
+ function _readValEnableCookie() {
174
+ _readValEnableCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
175
+ return _regenerator().w(function (_context) {
176
+ while (1) switch (_context.p = _context.n) {
177
+ case 0:
178
+ if (reader) {
179
+ _context.n = 1;
180
+ break;
181
+ }
182
+ return _context.a(2, false);
183
+ case 1:
184
+ _context.p = 1;
185
+ _context.n = 2;
186
+ return reader();
187
+ case 2:
188
+ return _context.a(2, _context.v);
189
+ case 3:
190
+ _context.p = 3;
191
+ _context.v;
192
+ return _context.a(2, false);
193
+ }
194
+ }, _callee, null, [[1, 3]]);
195
+ }));
196
+ return _readValEnableCookie.apply(this, arguments);
197
+ }
198
+
139
199
  var packageJson = {
140
200
  name: "@valbuild/tanstack",
141
201
  description: "Val for TanStack Start: hard-coded content - super-charged",
@@ -152,7 +212,7 @@ var packageJson = {
152
212
  "tanstack-router",
153
213
  "react"
154
214
  ],
155
- version: "0.129.0",
215
+ version: "0.131.0",
156
216
  scripts: {
157
217
  typecheck: "tsc --noEmit",
158
218
  test: "jest"
@@ -227,3 +287,5 @@ var VERSION = (_packageJson$version = packageJson.version) !== null && _packageJ
227
287
  exports.VERSION = VERSION;
228
288
  exports._asyncToGenerator = _asyncToGenerator;
229
289
  exports._regenerator = _regenerator;
290
+ exports.readValEnableCookie = readValEnableCookie;
291
+ exports.setValEnableCookieReader = setValEnableCookieReader;
@@ -134,6 +134,66 @@ function _asyncToGenerator(n) {
134
134
  };
135
135
  }
136
136
 
137
+ /**
138
+ * How `initVal().isValEnabled()` reaches the server without importing it.
139
+ *
140
+ * EXPERIMENTAL — see VAL_PROMPT.md.
141
+ *
142
+ * The cookie can only be read through `@tanstack/react-start/server`, and that
143
+ * module is reachable from this package's ROOT entry, which every client
144
+ * component imports. `initVal.ts` used `await import()` for exactly that reason,
145
+ * and under Vite the dynamic form does keep it out of the client bundle.
146
+ *
147
+ * It does not everywhere. A host that bundles this package ahead of time and
148
+ * audits what each chunk imports sees a dynamically imported chunk as a chunk
149
+ * like any other, and this one reaches TanStack's SSR path and lands on
150
+ * `node:stream/web`. That is why `@valbuild/tanstack` could not be built for a
151
+ * Cloudflare Worker at all.
152
+ *
153
+ * So the edge is inverted. The root entry holds a slot; `@valbuild/tanstack/server`
154
+ * fills it on import with the implementation that was already there,
155
+ * `hasValEnableCookieOnServer`. Nothing about the behaviour changes for an app
156
+ * that imports `/server` — which every app with a Val API does — and the root
157
+ * entry no longer names TanStack's server module at all.
158
+ *
159
+ * Ordering: the slot is filled when `/server` is first imported. An
160
+ * `isValEnabled()` call that somehow happens before that returns false, which
161
+ * is what the old implementation's `catch` returned in the same situation.
162
+ */
163
+
164
+ var reader = null;
165
+ function setValEnableCookieReader(read) {
166
+ reader = read;
167
+ }
168
+ function readValEnableCookie() {
169
+ return _readValEnableCookie.apply(this, arguments);
170
+ }
171
+ function _readValEnableCookie() {
172
+ _readValEnableCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
173
+ return _regenerator().w(function (_context) {
174
+ while (1) switch (_context.p = _context.n) {
175
+ case 0:
176
+ if (reader) {
177
+ _context.n = 1;
178
+ break;
179
+ }
180
+ return _context.a(2, false);
181
+ case 1:
182
+ _context.p = 1;
183
+ _context.n = 2;
184
+ return reader();
185
+ case 2:
186
+ return _context.a(2, _context.v);
187
+ case 3:
188
+ _context.p = 3;
189
+ _context.v;
190
+ return _context.a(2, false);
191
+ }
192
+ }, _callee, null, [[1, 3]]);
193
+ }));
194
+ return _readValEnableCookie.apply(this, arguments);
195
+ }
196
+
137
197
  var packageJson = {
138
198
  name: "@valbuild/tanstack",
139
199
  description: "Val for TanStack Start: hard-coded content - super-charged",
@@ -150,7 +210,7 @@ var packageJson = {
150
210
  "tanstack-router",
151
211
  "react"
152
212
  ],
153
- version: "0.129.0",
213
+ version: "0.131.0",
154
214
  scripts: {
155
215
  typecheck: "tsc --noEmit",
156
216
  test: "jest"
@@ -222,4 +282,4 @@ var packageJson = {
222
282
  var _packageJson$version;
223
283
  var VERSION = (_packageJson$version = packageJson.version) !== null && _packageJson$version !== void 0 ? _packageJson$version : null;
224
284
 
225
- export { VERSION as V, _asyncToGenerator as _, _regenerator as a };
285
+ export { VERSION as V, _asyncToGenerator as _, _regenerator as a, readValEnableCookie as r, setValEnableCookieReader as s };
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "tanstack-router",
15
15
  "react"
16
16
  ],
17
- "version": "0.129.0",
17
+ "version": "0.131.0",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -42,13 +42,13 @@
42
42
  "exports": true
43
43
  },
44
44
  "dependencies": {
45
- "@valbuild/core": "0.129.0",
46
- "@valbuild/language-server": "0.129.0",
47
- "@valbuild/mcp": "0.129.0",
48
- "@valbuild/react": "0.129.0",
49
- "@valbuild/server": "0.129.0",
50
- "@valbuild/ui": "0.129.0",
51
- "@valbuild/shared": "0.129.0"
45
+ "@valbuild/core": "0.130.0",
46
+ "@valbuild/react": "0.130.0",
47
+ "@valbuild/server": "0.131.0",
48
+ "@valbuild/mcp": "0.131.0",
49
+ "@valbuild/language-server": "0.131.0",
50
+ "@valbuild/shared": "0.130.0",
51
+ "@valbuild/ui": "0.130.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@tanstack/react-router": "^1.170.33",
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-e75681d7.cjs.dev.js');
5
+ var version = require('../../dist/version-4c4e9ed0.cjs.dev.js');
6
6
  var core = require('@valbuild/core');
7
+ var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-e75681d7.cjs.dev.js');
7
8
  var server = require('@valbuild/server');
8
- var version = require('../../dist/version-8aeb5ebd.cjs.dev.js');
9
9
  var routeFromVal = require('../../dist/routeFromVal-a9147ceb.cjs.dev.js');
10
10
  var stega = require('@valbuild/react/stega');
11
11
  var internal = require('@valbuild/shared/internal');
@@ -178,6 +178,14 @@ function _hasValEnableCookieOnServer() {
178
178
  return _hasValEnableCookieOnServer.apply(this, arguments);
179
179
  }
180
180
 
181
+ /**
182
+ * What `http` mode needs, as one object.
183
+ *
184
+ * A publish there is a commit on the project's repository, so this is the
185
+ * shape of "Val's content service holds my patches and my repo holds my
186
+ * content".
187
+ */
188
+
181
189
  /**
182
190
  * The Val API, as a handler you can mount on a TanStack Start server route.
183
191
  *
@@ -186,7 +194,7 @@ function _hasValEnableCookieOnServer() {
186
194
  * the conversion to a `Response`, which for Next needed `NextResponse` and here
187
195
  * does not need anything.
188
196
  */
189
- var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter) {
197
+ var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter, commitPrepared, sourceFiles, patchStore, unsafelyAllowUnauthenticated, apiKey, publishOverride, http, valContentUrl) {
190
198
  var route = "/api/val"; // TODO: get from config
191
199
  var coreVersion = core.Internal.VERSION.core;
192
200
  if (!coreVersion) {
@@ -196,7 +204,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
196
204
  if (!tanstackVersion) {
197
205
  throw new Error("Could not get @valbuild/tanstack package version");
198
206
  }
199
- return server.createValApiRouter(route, server.createValServer(valModules, route, createForOfIteratorHelper._objectSpread2({
207
+ return server.createValApiRouter(route, server.createValServer(valModules, route, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
200
208
  versions: {
201
209
  /*
202
210
  * Reported as `next` because that is the field the wire contract has.
@@ -210,7 +218,17 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
210
218
  next: tanstackVersion,
211
219
  core: coreVersion
212
220
  }
213
- }, config), config, {
221
+ }, config), sourceFiles !== undefined ? {
222
+ sourceFiles: sourceFiles
223
+ } : {}), patchStore !== undefined ? {
224
+ patchStore: patchStore
225
+ } : {}), unsafelyAllowUnauthenticated !== undefined ? {
226
+ unsafelyAllowUnauthenticated: unsafelyAllowUnauthenticated
227
+ } : {}), apiKey !== undefined ? {
228
+ apiKey: apiKey
229
+ } : {}), http !== undefined ? http : {}), valContentUrl !== undefined ? {
230
+ valContentUrl: valContentUrl
231
+ } : {}), config, {
214
232
  isEnabled: function isEnabled() {
215
233
  return draftMode.isEnabled();
216
234
  },
@@ -220,7 +238,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
220
238
  onDisable: function onDisable() {
221
239
  return draftMode.disable();
222
240
  }
223
- }, formatter), function (valRes) {
241
+ }, formatter, commitPrepared, publishOverride), function (valRes) {
224
242
  var headers = new Headers();
225
243
  var valResHeaders = "headers" in valRes && valRes.headers || {};
226
244
  for (var key in valResHeaders) {
@@ -294,7 +312,7 @@ function initValServer(valModules, config, opts) {
294
312
  var _opts$draftMode;
295
313
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
296
314
  return {
297
- valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter),
315
+ valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter, opts === null || opts === void 0 ? void 0 : opts.commitPrepared, opts === null || opts === void 0 ? void 0 : opts.sourceFiles, opts === null || opts === void 0 ? void 0 : opts.patchStore, opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated, opts === null || opts === void 0 ? void 0 : opts.apiKey, opts === null || opts === void 0 ? void 0 : opts.publishOverride, opts === null || opts === void 0 ? void 0 : opts.http, opts === null || opts === void 0 ? void 0 : opts.valContentUrl),
298
316
  draftMode: draftMode
299
317
  };
300
318
  }
@@ -975,13 +993,19 @@ function initValContent(config, valModules, opts) {
975
993
  var isEnabled = function isEnabled() {
976
994
  return draftMode.isEnabled();
977
995
  };
978
- var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2({
996
+ var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
979
997
  versions: {
980
998
  // `next` is the field name in the wire contract; see initValServer.
981
999
  next: tanstackVersion,
982
1000
  core: coreVersion
983
1001
  }
984
- }, 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
+ } : {}), config, {
985
1009
  isEnabled: isEnabled,
986
1010
  onEnable: function onEnable() {
987
1011
  return draftMode.enable();
@@ -1024,6 +1048,17 @@ function initValMcp(valModules, config, opts) {
1024
1048
  }));
1025
1049
  }
1026
1050
 
1051
+ // Fills the slot the root entry holds, so `initVal().isValEnabled()` works
1052
+ // without the root entry importing TanStack's server module. See
1053
+ // valEnableCookieBridge.ts.
1054
+ version.setValEnableCookieReader(hasValEnableCookieOnServer);
1055
+ // Re-exported so an app that mounts the MCP endpoint through this package does
1056
+ // not also have to depend on `@valbuild/mcp` for the types it hands back.
1057
+
1058
+ Object.defineProperty(exports, 'InMemoryPatchStore', {
1059
+ enumerable: true,
1060
+ get: function () { return server.InMemoryPatchStore; }
1061
+ });
1027
1062
  exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
1028
1063
  exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
1029
1064
  exports.initValContent = initValContent;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-0324e063.cjs.prod.js');
5
+ var version = require('../../dist/version-022ed31c.cjs.prod.js');
6
6
  var core = require('@valbuild/core');
7
+ var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-0324e063.cjs.prod.js');
7
8
  var server = require('@valbuild/server');
8
- var version = require('../../dist/version-ecfd83cc.cjs.prod.js');
9
9
  var routeFromVal = require('../../dist/routeFromVal-6693e037.cjs.prod.js');
10
10
  var stega = require('@valbuild/react/stega');
11
11
  var internal = require('@valbuild/shared/internal');
@@ -178,6 +178,14 @@ function _hasValEnableCookieOnServer() {
178
178
  return _hasValEnableCookieOnServer.apply(this, arguments);
179
179
  }
180
180
 
181
+ /**
182
+ * What `http` mode needs, as one object.
183
+ *
184
+ * A publish there is a commit on the project's repository, so this is the
185
+ * shape of "Val's content service holds my patches and my repo holds my
186
+ * content".
187
+ */
188
+
181
189
  /**
182
190
  * The Val API, as a handler you can mount on a TanStack Start server route.
183
191
  *
@@ -186,7 +194,7 @@ function _hasValEnableCookieOnServer() {
186
194
  * the conversion to a `Response`, which for Next needed `NextResponse` and here
187
195
  * does not need anything.
188
196
  */
189
- var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter) {
197
+ var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter, commitPrepared, sourceFiles, patchStore, unsafelyAllowUnauthenticated, apiKey, publishOverride, http, valContentUrl) {
190
198
  var route = "/api/val"; // TODO: get from config
191
199
  var coreVersion = core.Internal.VERSION.core;
192
200
  if (!coreVersion) {
@@ -196,7 +204,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
196
204
  if (!tanstackVersion) {
197
205
  throw new Error("Could not get @valbuild/tanstack package version");
198
206
  }
199
- return server.createValApiRouter(route, server.createValServer(valModules, route, createForOfIteratorHelper._objectSpread2({
207
+ return server.createValApiRouter(route, server.createValServer(valModules, route, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
200
208
  versions: {
201
209
  /*
202
210
  * Reported as `next` because that is the field the wire contract has.
@@ -210,7 +218,17 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
210
218
  next: tanstackVersion,
211
219
  core: coreVersion
212
220
  }
213
- }, config), config, {
221
+ }, config), sourceFiles !== undefined ? {
222
+ sourceFiles: sourceFiles
223
+ } : {}), patchStore !== undefined ? {
224
+ patchStore: patchStore
225
+ } : {}), unsafelyAllowUnauthenticated !== undefined ? {
226
+ unsafelyAllowUnauthenticated: unsafelyAllowUnauthenticated
227
+ } : {}), apiKey !== undefined ? {
228
+ apiKey: apiKey
229
+ } : {}), http !== undefined ? http : {}), valContentUrl !== undefined ? {
230
+ valContentUrl: valContentUrl
231
+ } : {}), config, {
214
232
  isEnabled: function isEnabled() {
215
233
  return draftMode.isEnabled();
216
234
  },
@@ -220,7 +238,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
220
238
  onDisable: function onDisable() {
221
239
  return draftMode.disable();
222
240
  }
223
- }, formatter), function (valRes) {
241
+ }, formatter, commitPrepared, publishOverride), function (valRes) {
224
242
  var headers = new Headers();
225
243
  var valResHeaders = "headers" in valRes && valRes.headers || {};
226
244
  for (var key in valResHeaders) {
@@ -294,7 +312,7 @@ function initValServer(valModules, config, opts) {
294
312
  var _opts$draftMode;
295
313
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
296
314
  return {
297
- valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter),
315
+ valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter, opts === null || opts === void 0 ? void 0 : opts.commitPrepared, opts === null || opts === void 0 ? void 0 : opts.sourceFiles, opts === null || opts === void 0 ? void 0 : opts.patchStore, opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated, opts === null || opts === void 0 ? void 0 : opts.apiKey, opts === null || opts === void 0 ? void 0 : opts.publishOverride, opts === null || opts === void 0 ? void 0 : opts.http, opts === null || opts === void 0 ? void 0 : opts.valContentUrl),
298
316
  draftMode: draftMode
299
317
  };
300
318
  }
@@ -975,13 +993,19 @@ function initValContent(config, valModules, opts) {
975
993
  var isEnabled = function isEnabled() {
976
994
  return draftMode.isEnabled();
977
995
  };
978
- var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2({
996
+ var valServerPromise = server.createValServer(valModules, valApiEndpoints, createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2(createForOfIteratorHelper._objectSpread2({
979
997
  versions: {
980
998
  // `next` is the field name in the wire contract; see initValServer.
981
999
  next: tanstackVersion,
982
1000
  core: coreVersion
983
1001
  }
984
- }, 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
+ } : {}), config, {
985
1009
  isEnabled: isEnabled,
986
1010
  onEnable: function onEnable() {
987
1011
  return draftMode.enable();
@@ -1024,6 +1048,17 @@ function initValMcp(valModules, config, opts) {
1024
1048
  }));
1025
1049
  }
1026
1050
 
1051
+ // Fills the slot the root entry holds, so `initVal().isValEnabled()` works
1052
+ // without the root entry importing TanStack's server module. See
1053
+ // valEnableCookieBridge.ts.
1054
+ version.setValEnableCookieReader(hasValEnableCookieOnServer);
1055
+ // Re-exported so an app that mounts the MCP endpoint through this package does
1056
+ // not also have to depend on `@valbuild/mcp` for the types it hands back.
1057
+
1058
+ Object.defineProperty(exports, 'InMemoryPatchStore', {
1059
+ enumerable: true,
1060
+ get: function () { return server.InMemoryPatchStore; }
1061
+ });
1027
1062
  exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
1028
1063
  exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
1029
1064
  exports.initValContent = initValContent;
@@ -1,7 +1,8 @@
1
- import { _ as _objectSpread2, a as _slicedToArray, d as _defineProperty } from '../../dist/createForOfIteratorHelper-485c2ce1.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-b5c8e13d.esm.js';
2
2
  import { Internal } from '@valbuild/core';
3
+ import { _ as _objectSpread2, a as _slicedToArray, d as _defineProperty } from '../../dist/createForOfIteratorHelper-485c2ce1.esm.js';
3
4
  import { createValApiRouter, createValServer } from '@valbuild/server';
4
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION } from '../../dist/version-a2bd1bca.esm.js';
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';
@@ -156,6 +157,14 @@ function _hasValEnableCookieOnServer() {
156
157
  return _hasValEnableCookieOnServer.apply(this, arguments);
157
158
  }
158
159
 
160
+ /**
161
+ * What `http` mode needs, as one object.
162
+ *
163
+ * A publish there is a commit on the project's repository, so this is the
164
+ * shape of "Val's content service holds my patches and my repo holds my
165
+ * content".
166
+ */
167
+
159
168
  /**
160
169
  * The Val API, as a handler you can mount on a TanStack Start server route.
161
170
  *
@@ -164,7 +173,7 @@ function _hasValEnableCookieOnServer() {
164
173
  * the conversion to a `Response`, which for Next needed `NextResponse` and here
165
174
  * does not need anything.
166
175
  */
167
- var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter) {
176
+ var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter, commitPrepared, sourceFiles, patchStore, unsafelyAllowUnauthenticated, apiKey, publishOverride, http, valContentUrl) {
168
177
  var route = "/api/val"; // TODO: get from config
169
178
  var coreVersion = Internal.VERSION.core;
170
179
  if (!coreVersion) {
@@ -174,7 +183,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
174
183
  if (!tanstackVersion) {
175
184
  throw new Error("Could not get @valbuild/tanstack package version");
176
185
  }
177
- return createValApiRouter(route, createValServer(valModules, route, _objectSpread2({
186
+ return createValApiRouter(route, createValServer(valModules, route, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
178
187
  versions: {
179
188
  /*
180
189
  * Reported as `next` because that is the field the wire contract has.
@@ -188,7 +197,17 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
188
197
  next: tanstackVersion,
189
198
  core: coreVersion
190
199
  }
191
- }, config), config, {
200
+ }, config), sourceFiles !== undefined ? {
201
+ sourceFiles: sourceFiles
202
+ } : {}), patchStore !== undefined ? {
203
+ patchStore: patchStore
204
+ } : {}), unsafelyAllowUnauthenticated !== undefined ? {
205
+ unsafelyAllowUnauthenticated: unsafelyAllowUnauthenticated
206
+ } : {}), apiKey !== undefined ? {
207
+ apiKey: apiKey
208
+ } : {}), http !== undefined ? http : {}), valContentUrl !== undefined ? {
209
+ valContentUrl: valContentUrl
210
+ } : {}), config, {
192
211
  isEnabled: function isEnabled() {
193
212
  return draftMode.isEnabled();
194
213
  },
@@ -198,7 +217,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
198
217
  onDisable: function onDisable() {
199
218
  return draftMode.disable();
200
219
  }
201
- }, formatter), function (valRes) {
220
+ }, formatter, commitPrepared, publishOverride), function (valRes) {
202
221
  var headers = new Headers();
203
222
  var valResHeaders = "headers" in valRes && valRes.headers || {};
204
223
  for (var key in valResHeaders) {
@@ -272,7 +291,7 @@ function initValServer(valModules, config, opts) {
272
291
  var _opts$draftMode;
273
292
  var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
274
293
  return {
275
- valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter),
294
+ valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter, opts === null || opts === void 0 ? void 0 : opts.commitPrepared, opts === null || opts === void 0 ? void 0 : opts.sourceFiles, opts === null || opts === void 0 ? void 0 : opts.patchStore, opts === null || opts === void 0 ? void 0 : opts.unsafelyAllowUnauthenticated, opts === null || opts === void 0 ? void 0 : opts.apiKey, opts === null || opts === void 0 ? void 0 : opts.publishOverride, opts === null || opts === void 0 ? void 0 : opts.http, opts === null || opts === void 0 ? void 0 : opts.valContentUrl),
276
295
  draftMode: draftMode
277
296
  };
278
297
  }
@@ -953,13 +972,19 @@ function initValContent(config, valModules, opts) {
953
972
  var isEnabled = function isEnabled() {
954
973
  return draftMode.isEnabled();
955
974
  };
956
- var valServerPromise = createValServer(valModules, valApiEndpoints, _objectSpread2({
975
+ var valServerPromise = createValServer(valModules, valApiEndpoints, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
957
976
  versions: {
958
977
  // `next` is the field name in the wire contract; see initValServer.
959
978
  next: tanstackVersion,
960
979
  core: coreVersion
961
980
  }
962
- }, 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
+ } : {}), config, {
963
988
  isEnabled: isEnabled,
964
989
  onEnable: function onEnable() {
965
990
  return draftMode.enable();
@@ -1002,4 +1027,11 @@ function initValMcp(valModules, config, opts) {
1002
1027
  }));
1003
1028
  }
1004
1029
 
1030
+ // Fills the slot the root entry holds, so `initVal().isValEnabled()` works
1031
+ // without the root entry importing TanStack's server module. See
1032
+ // valEnableCookieBridge.ts.
1033
+ setValEnableCookieReader(hasValEnableCookieOnServer);
1034
+ // Re-exported so an app that mounts the MCP endpoint through this package does
1035
+ // not also have to depend on `@valbuild/mcp` for the types it hands back.
1036
+
1005
1037
  export { VAL_DRAFT_MODE_COOKIE, hasValEnableCookieOnServer, initValContent, initValMcp, initValServer, valDraftMode };