@valbuild/tanstack 0.130.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,83 @@
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
+
3
81
  ## 0.130.0
4
82
 
5
83
  ### 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,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>;
@@ -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-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');
@@ -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-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');
@@ -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-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';
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.130.0",
215
+ version: "0.131.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.131.0",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -210,7 +210,7 @@ var packageJson = {
210
210
  "tanstack-router",
211
211
  "react"
212
212
  ],
213
- version: "0.130.0",
213
+ version: "0.131.0",
214
214
  scripts: {
215
215
  typecheck: "tsc --noEmit",
216
216
  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.131.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",
48
46
  "@valbuild/react": "0.130.0",
49
- "@valbuild/server": "0.130.0",
47
+ "@valbuild/server": "0.131.0",
48
+ "@valbuild/mcp": "0.131.0",
49
+ "@valbuild/language-server": "0.131.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-4c4e9ed0.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({
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
+ } : {}), 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-022ed31c.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({
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
+ } : {}), 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-b5c8e13d.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({
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
+ } : {}), config, {
981
988
  isEnabled: isEnabled,
982
989
  onEnable: function onEnable() {
983
990
  return draftMode.enable();