@valbuild/tanstack 0.128.0 → 0.130.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 +166 -0
- package/dist/declarations/src/server/index.d.ts +1 -0
- package/dist/declarations/src/server/initValServer.d.ts +109 -0
- package/dist/valbuild-tanstack.cjs.dev.js +34 -23
- package/dist/valbuild-tanstack.cjs.prod.js +34 -23
- package/dist/valbuild-tanstack.esm.js +35 -24
- package/dist/{version-2d63db20.cjs.dev.js → version-68d92818.cjs.prod.js} +63 -1
- package/dist/{version-09f11ef9.esm.js → version-d388ee0d.esm.js} +62 -2
- package/dist/{version-b642af81.cjs.prod.js → version-f2ffc76f.cjs.dev.js} +63 -1
- package/package.json +8 -8
- package/server/dist/valbuild-tanstack-server.cjs.dev.js +32 -7
- package/server/dist/valbuild-tanstack-server.cjs.prod.js +32 -7
- package/server/dist/valbuild-tanstack-server.esm.js +32 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,171 @@
|
|
|
1
1
|
# @valbuild/tanstack
|
|
2
2
|
|
|
3
|
+
## 0.130.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
EXPERIMENTAL. `fs` mode assumes a working tree it can watch and write; `http`
|
|
10
|
+
mode assumes Val's content service owns the patch chain and that a commit is a
|
|
11
|
+
git commit. A host that builds and publishes its own output is neither: it holds
|
|
12
|
+
the source already, it has nowhere to watch, and its "commit" is a new build.
|
|
13
|
+
|
|
14
|
+
Forcing such a host into `fs` mode cost three things, all now fixed: `/stat`
|
|
15
|
+
long-polled against watchers that could never fire, burning CPU for the whole
|
|
16
|
+
hold to learn nothing;
|
|
17
|
+
`/api/val/enable` 500'd; and every read of a `.val.ts` went through a shimmed
|
|
18
|
+
filesystem when the host could simply hand the source over.
|
|
19
|
+
|
|
20
|
+
`ValOpsMemory` takes the source as `sourceFiles`, refuses the local binary
|
|
21
|
+
members by name — this configuration uses Val's remote files — and answers the
|
|
22
|
+
history members with the same closed `not-supported-in-fs-mode` error `ValOpsFS`
|
|
23
|
+
gives, so the History UI degrades the way it already knows how rather than
|
|
24
|
+
inventing a commit list.
|
|
25
|
+
|
|
26
|
+
`getStat` still long-polls -- the hold is what paces the client, and an earlier
|
|
27
|
+
version that answered immediately turned a 20-second poll into a request every
|
|
28
|
+
6ms -- but it parks on a SIGNAL rather than a timer. This mode owns its store,
|
|
29
|
+
so it is told when something changes: no timers while parked, and a patch
|
|
30
|
+
written by another tab is seen at once rather than up to 250ms later.
|
|
31
|
+
|
|
32
|
+
Two seams come with it. `commitPrepared` lets a host take what a save produced
|
|
33
|
+
instead of a git commit, and `publishOverride` lets a publish be something other
|
|
34
|
+
than a push. Both are opt-in; an app that sets neither behaves exactly as before.
|
|
35
|
+
|
|
36
|
+
The in-memory patch store is explicitly **not durable**. It is behind
|
|
37
|
+
`ValPatchStore`, so a durable implementation is a swap rather than a rewrite,
|
|
38
|
+
but as shipped a restart loses unpublished patches.
|
|
39
|
+
|
|
40
|
+
**Memory mode authenticates.** `ValOps` gained `requiresAuth` alongside
|
|
41
|
+
`patchesAreLocal`, because one flag was answering two questions: whether a store
|
|
42
|
+
auto-saves or publishes (behaviour, reported as `mode` and keyed off by the UI),
|
|
43
|
+
and whether an unauthenticated request may write (security). With two
|
|
44
|
+
implementations the answers coincided — `fs` is a developer's own machine where
|
|
45
|
+
no credential exists, `http` is remote — so `getAuth` was written against
|
|
46
|
+
`patchesAreLocal` and returned anonymous _success_ for a missing cookie, an
|
|
47
|
+
invalid JWT, an unparseable payload, or no configured secret.
|
|
48
|
+
|
|
49
|
+
Memory mode splits them: its store is local, and it runs deployed. It therefore
|
|
50
|
+
requires a verified session, like `http` mode. A host that authorises requests
|
|
51
|
+
before Val sees them can opt out with `unsafelyAllowUnauthenticated`, which is
|
|
52
|
+
spelled that way on purpose and warns at startup. `fs` mode is unchanged.
|
|
53
|
+
|
|
54
|
+
Val's own MCP endpoint refuses memory mode outright. It has the same absence fs
|
|
55
|
+
mode has — no credential, no backend, every permission check on the far side of
|
|
56
|
+
one — and unlike fs mode it is meant to run deployed, so the existing
|
|
57
|
+
"development only" and loopback guards refuse nothing. A host in this mode owns
|
|
58
|
+
its own trust boundary and can offer the tools through it.
|
|
59
|
+
|
|
60
|
+
Internally, the routes' `instanceof ValOpsFS` checks meant "is this a local
|
|
61
|
+
store" — correct with two implementations and silently wrong with three. They are
|
|
62
|
+
now `ValOps.patchesAreLocal` at all 17 policy sites.
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- [#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
|
|
67
|
+
|
|
68
|
+
The root entry — the one every client component imports — reached TanStack
|
|
69
|
+
Start's server module from inside `isValEnabled`:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const { getCookie } = await import("@tanstack/react-start/server");
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
At runtime that is already correct anywhere but a server: the import fails, the
|
|
76
|
+
`catch` returns `false`, which is what the function's documentation says it does.
|
|
77
|
+
Under Vite the dynamic form also keeps it out of the client bundle.
|
|
78
|
+
|
|
79
|
+
It does not everywhere. A host that bundles this package ahead of time and audits
|
|
80
|
+
what each chunk imports sees a dynamically imported chunk as a chunk like any
|
|
81
|
+
other — and this one reaches Start's SSR path and lands on `node:stream`. The
|
|
82
|
+
package could not be built for a browser or a Cloudflare Worker at all, which
|
|
83
|
+
made every component importing it unusable there.
|
|
84
|
+
|
|
85
|
+
The edge is now inverted. The root entry holds a slot, `@valbuild/tanstack/server`
|
|
86
|
+
fills it on import with the implementation that was already there, and the root
|
|
87
|
+
entry no longer names TanStack's server module. Nothing changes for an app that
|
|
88
|
+
imports `/server`, which is every app with a Val API. An `isValEnabled()` call
|
|
89
|
+
before `/server` is first imported returns `false` — the same answer the old
|
|
90
|
+
implementation's `catch` gave in that situation.
|
|
91
|
+
|
|
92
|
+
- 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)]:
|
|
93
|
+
- @valbuild/ui@0.130.0
|
|
94
|
+
- @valbuild/server@0.130.0
|
|
95
|
+
- @valbuild/mcp@0.130.0
|
|
96
|
+
- @valbuild/core@0.130.0
|
|
97
|
+
- @valbuild/react@0.130.0
|
|
98
|
+
- @valbuild/language-server@0.130.0
|
|
99
|
+
- @valbuild/shared@0.130.0
|
|
100
|
+
|
|
101
|
+
## 0.129.0
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- [#655](https://github.com/valbuild/val/pull/655) [`7d34ecc`](https://github.com/valbuild/val/commit/7d34ecce787a0709025ae7b4764cb6c3ad1f766b) Thanks [@freekh](https://github.com/freekh)! - A project can now make Val Studio look like its own.
|
|
106
|
+
|
|
107
|
+
`s.settings()` has a new `theme` section, edited under **Settings → Appearance**
|
|
108
|
+
in the Studio. It is content like everything else: edited as a draft, shown in
|
|
109
|
+
the publish diff, and the same for everyone working on the project.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
export default c.define("/settings.val.ts", s.settings(), {
|
|
113
|
+
theme: {
|
|
114
|
+
accent: "#2563eb",
|
|
115
|
+
radius: "tight",
|
|
116
|
+
mode: "light",
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**`accent` is one hex, and it restyles the whole chrome** — Publish, the active
|
|
122
|
+
rail item, focus rings, switches, the caret in a rich text field, and the
|
|
123
|
+
outlines the canvas draws around editable elements on your own page. Any colour
|
|
124
|
+
is allowed, not a list of approved ones, because what the accent replaces is a
|
|
125
|
+
ten-step ramp that is _generated_ from it: each step keeps the lightness of the
|
|
126
|
+
step it replaces and changes only the hue. WCAG contrast is almost entirely a
|
|
127
|
+
function of lightness, so every foreground/background pair the chrome renders
|
|
128
|
+
stays at AA — which is asserted across the hue circle, pure black and a
|
|
129
|
+
saturated yellow included, rather than argued for. One value drives both light
|
|
130
|
+
and dark mode, since the semantic tokens pick different steps of the ramp in
|
|
131
|
+
each.
|
|
132
|
+
|
|
133
|
+
**`radius`** is `square`, `tight`, `default` or `soft`, and moves every corner
|
|
134
|
+
in the Studio.
|
|
135
|
+
|
|
136
|
+
The accent also moves the outlines the canvas draws around editable elements on
|
|
137
|
+
your own page. Those are drawn inside your document, which has none of Val's
|
|
138
|
+
stylesheet, so the colour is sent to the page over the canvas protocol — which
|
|
139
|
+
means a project on an older `@valbuild/next` or `@valbuild/tanstack` than its
|
|
140
|
+
Studio keeps Val's green there until it upgrades, rather than breaking.
|
|
141
|
+
|
|
142
|
+
**`mode`** is the mode the Studio opens in for an editor who has never picked
|
|
143
|
+
one. It never overrides an editor who has — that choice stays theirs, per
|
|
144
|
+
person and per browser, behind the account button.
|
|
145
|
+
|
|
146
|
+
Every field is optional, and unset means Val's own look, so an existing
|
|
147
|
+
settings module needs no change.
|
|
148
|
+
|
|
149
|
+
Two smaller fixes that came with it:
|
|
150
|
+
|
|
151
|
+
- **A settings change is its own entry in the publish diff.** Editing the
|
|
152
|
+
assistant's tone used to collapse the entire settings module into one change
|
|
153
|
+
card labelled "Settings", because the patch that writes a settings field is
|
|
154
|
+
an `add`, and `PatchSets` had no case for a settings section — so it gave up
|
|
155
|
+
and grouped the whole module. Two unrelated settings edits now show as two
|
|
156
|
+
changes, each under the name the panel gives it.
|
|
157
|
+
- **The Val mark keeps its green.** It named a step of the brand ramp, so it
|
|
158
|
+
would have recoloured along with a project's accent. It has its own token now.
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [[`e20f6fb`](https://github.com/valbuild/val/commit/e20f6fbcc215c310eef49a44c1a592c1e2081613), [`7d34ecc`](https://github.com/valbuild/val/commit/7d34ecce787a0709025ae7b4764cb6c3ad1f766b), [`0c351c4`](https://github.com/valbuild/val/commit/0c351c4f97ae7f09772eab0e856ae69821b803b7), [`41a0d76`](https://github.com/valbuild/val/commit/41a0d76636a2dce3f1e506d93170d97e46041d98), [`9e0ebb0`](https://github.com/valbuild/val/commit/9e0ebb00430f05ef92dff031309f73b8075a7d99)]:
|
|
161
|
+
- @valbuild/ui@0.129.0
|
|
162
|
+
- @valbuild/core@0.129.0
|
|
163
|
+
- @valbuild/shared@0.129.0
|
|
164
|
+
- @valbuild/react@0.129.0
|
|
165
|
+
- @valbuild/server@0.129.0
|
|
166
|
+
- @valbuild/language-server@0.129.0
|
|
167
|
+
- @valbuild/mcp@0.129.0
|
|
168
|
+
|
|
3
169
|
## 0.128.0
|
|
4
170
|
|
|
5
171
|
### Patch Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { initValServer } from "./initValServer.js";
|
|
2
|
+
export type { ValHttpMode } from "./initValServer.js";
|
|
2
3
|
export { initValContent } from "./initValContent.js";
|
|
3
4
|
export { valDraftMode, hasValEnableCookieOnServer, VAL_DRAFT_MODE_COOKIE, type ValDraftMode, } from "./valDraftMode.js";
|
|
4
5
|
export { initValMcp } from "./initValMcp.js";
|
|
@@ -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-
|
|
5
|
+
var version = require('./version-f2ffc76f.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.
|
|
70
|
+
while (1) switch (_context.n) {
|
|
72
71
|
case 0:
|
|
73
|
-
_context.
|
|
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
|
|
74
|
+
}, _callee);
|
|
86
75
|
}));
|
|
87
76
|
return _isValEnabled.apply(this, arguments);
|
|
88
77
|
}
|
|
@@ -243,8 +232,10 @@ var floatDarkBg = "#131316";
|
|
|
243
232
|
/** `--bg-float`, light. */
|
|
244
233
|
var floatLightBg = "#fcfcfc";
|
|
245
234
|
|
|
246
|
-
var
|
|
247
|
-
|
|
235
|
+
var DEFAULT_SELECTION = {
|
|
236
|
+
selection: client.DEFAULT_CANVAS_SELECTION,
|
|
237
|
+
selectionSoft: client.DEFAULT_CANVAS_SELECTION_SOFT
|
|
238
|
+
};
|
|
248
239
|
|
|
249
240
|
/**
|
|
250
241
|
* How often the page is re-measured even when nothing said it changed.
|
|
@@ -273,10 +264,23 @@ function ValCanvasBridge(_ref) {
|
|
|
273
264
|
_React$useState2 = createForOfIteratorHelper._slicedToArray(_React$useState, 2),
|
|
274
265
|
picking = _React$useState2[0],
|
|
275
266
|
setPicking = _React$useState2[1];
|
|
276
|
-
|
|
267
|
+
/**
|
|
268
|
+
* The outline colours, as the studio last said.
|
|
269
|
+
*
|
|
270
|
+
* State rather than a prop, because it arrives over the protocol after mount:
|
|
271
|
+
* the studio sends it when the frame reports ready and again whenever the
|
|
272
|
+
* project's accent changes. Starts at Val's green so a page that is never
|
|
273
|
+
* told — an older studio, or a message that never arrives — still outlines
|
|
274
|
+
* its content.
|
|
275
|
+
*/
|
|
276
|
+
var _React$useState3 = React__default["default"].useState(DEFAULT_SELECTION),
|
|
277
277
|
_React$useState4 = createForOfIteratorHelper._slicedToArray(_React$useState3, 2),
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
selectionColors = _React$useState4[0],
|
|
279
|
+
setSelectionColors = _React$useState4[1];
|
|
280
|
+
var _React$useState5 = React__default["default"].useState(null),
|
|
281
|
+
_React$useState6 = createForOfIteratorHelper._slicedToArray(_React$useState5, 2),
|
|
282
|
+
highlighted = _React$useState6[0],
|
|
283
|
+
setHighlighted = _React$useState6[1];
|
|
280
284
|
// Kept in a ref as well, because the capture-phase click listener below is
|
|
281
285
|
// installed once and would otherwise close over the first value forever.
|
|
282
286
|
var pickingRef = React__default["default"].useRef(false);
|
|
@@ -485,6 +489,13 @@ function ValCanvasBridge(_ref) {
|
|
|
485
489
|
setPicking(message.picking);
|
|
486
490
|
return;
|
|
487
491
|
}
|
|
492
|
+
if (message.type === "theme") {
|
|
493
|
+
setSelectionColors({
|
|
494
|
+
selection: message.selection,
|
|
495
|
+
selectionSoft: message.selectionSoft
|
|
496
|
+
});
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
488
499
|
if (message.type === "sourceUpdate") {
|
|
489
500
|
/**
|
|
490
501
|
* Handed straight to the listener the page already has.
|
|
@@ -700,7 +711,7 @@ function ValCanvasBridge(_ref) {
|
|
|
700
711
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
701
712
|
// close the selector early.
|
|
702
713
|
dangerouslySetInnerHTML: {
|
|
703
|
-
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(
|
|
714
|
+
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n[data-val-path]:hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "", highlighted ? highlightRule(highlighted, selectionColors.selection) : ""].filter(Boolean).join("\n")
|
|
704
715
|
}
|
|
705
716
|
});
|
|
706
717
|
}
|
|
@@ -718,13 +729,13 @@ function ValCanvasBridge(_ref) {
|
|
|
718
729
|
* and one in the middle. Between them they match the path as a complete list
|
|
719
730
|
* item and nothing else.
|
|
720
731
|
*/
|
|
721
|
-
function highlightRule(path) {
|
|
732
|
+
function highlightRule(path, selection) {
|
|
722
733
|
var value = JSON.stringify(path);
|
|
723
734
|
var inner = JSON.stringify(",".concat(path, ","));
|
|
724
735
|
var first = JSON.stringify("".concat(path, ","));
|
|
725
736
|
var last = JSON.stringify(",".concat(path));
|
|
726
737
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
727
|
-
return "".concat(selectors, " { outline: 2px solid ").concat(
|
|
738
|
+
return "".concat(selectors, " { outline: 2px solid ").concat(selection, "; outline-offset: 1px; }");
|
|
728
739
|
}
|
|
729
740
|
|
|
730
741
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('./version-
|
|
5
|
+
var version = require('./version-68d92818.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.
|
|
70
|
+
while (1) switch (_context.n) {
|
|
72
71
|
case 0:
|
|
73
|
-
_context.
|
|
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
|
|
74
|
+
}, _callee);
|
|
86
75
|
}));
|
|
87
76
|
return _isValEnabled.apply(this, arguments);
|
|
88
77
|
}
|
|
@@ -243,8 +232,10 @@ var floatDarkBg = "#131316";
|
|
|
243
232
|
/** `--bg-float`, light. */
|
|
244
233
|
var floatLightBg = "#fcfcfc";
|
|
245
234
|
|
|
246
|
-
var
|
|
247
|
-
|
|
235
|
+
var DEFAULT_SELECTION = {
|
|
236
|
+
selection: client.DEFAULT_CANVAS_SELECTION,
|
|
237
|
+
selectionSoft: client.DEFAULT_CANVAS_SELECTION_SOFT
|
|
238
|
+
};
|
|
248
239
|
|
|
249
240
|
/**
|
|
250
241
|
* How often the page is re-measured even when nothing said it changed.
|
|
@@ -273,10 +264,23 @@ function ValCanvasBridge(_ref) {
|
|
|
273
264
|
_React$useState2 = createForOfIteratorHelper._slicedToArray(_React$useState, 2),
|
|
274
265
|
picking = _React$useState2[0],
|
|
275
266
|
setPicking = _React$useState2[1];
|
|
276
|
-
|
|
267
|
+
/**
|
|
268
|
+
* The outline colours, as the studio last said.
|
|
269
|
+
*
|
|
270
|
+
* State rather than a prop, because it arrives over the protocol after mount:
|
|
271
|
+
* the studio sends it when the frame reports ready and again whenever the
|
|
272
|
+
* project's accent changes. Starts at Val's green so a page that is never
|
|
273
|
+
* told — an older studio, or a message that never arrives — still outlines
|
|
274
|
+
* its content.
|
|
275
|
+
*/
|
|
276
|
+
var _React$useState3 = React__default["default"].useState(DEFAULT_SELECTION),
|
|
277
277
|
_React$useState4 = createForOfIteratorHelper._slicedToArray(_React$useState3, 2),
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
selectionColors = _React$useState4[0],
|
|
279
|
+
setSelectionColors = _React$useState4[1];
|
|
280
|
+
var _React$useState5 = React__default["default"].useState(null),
|
|
281
|
+
_React$useState6 = createForOfIteratorHelper._slicedToArray(_React$useState5, 2),
|
|
282
|
+
highlighted = _React$useState6[0],
|
|
283
|
+
setHighlighted = _React$useState6[1];
|
|
280
284
|
// Kept in a ref as well, because the capture-phase click listener below is
|
|
281
285
|
// installed once and would otherwise close over the first value forever.
|
|
282
286
|
var pickingRef = React__default["default"].useRef(false);
|
|
@@ -485,6 +489,13 @@ function ValCanvasBridge(_ref) {
|
|
|
485
489
|
setPicking(message.picking);
|
|
486
490
|
return;
|
|
487
491
|
}
|
|
492
|
+
if (message.type === "theme") {
|
|
493
|
+
setSelectionColors({
|
|
494
|
+
selection: message.selection,
|
|
495
|
+
selectionSoft: message.selectionSoft
|
|
496
|
+
});
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
488
499
|
if (message.type === "sourceUpdate") {
|
|
489
500
|
/**
|
|
490
501
|
* Handed straight to the listener the page already has.
|
|
@@ -700,7 +711,7 @@ function ValCanvasBridge(_ref) {
|
|
|
700
711
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
701
712
|
// close the selector early.
|
|
702
713
|
dangerouslySetInnerHTML: {
|
|
703
|
-
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(
|
|
714
|
+
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n[data-val-path]:hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "", highlighted ? highlightRule(highlighted, selectionColors.selection) : ""].filter(Boolean).join("\n")
|
|
704
715
|
}
|
|
705
716
|
});
|
|
706
717
|
}
|
|
@@ -718,13 +729,13 @@ function ValCanvasBridge(_ref) {
|
|
|
718
729
|
* and one in the middle. Between them they match the path as a complete list
|
|
719
730
|
* item and nothing else.
|
|
720
731
|
*/
|
|
721
|
-
function highlightRule(path) {
|
|
732
|
+
function highlightRule(path, selection) {
|
|
722
733
|
var value = JSON.stringify(path);
|
|
723
734
|
var inner = JSON.stringify(",".concat(path, ","));
|
|
724
735
|
var first = JSON.stringify("".concat(path, ","));
|
|
725
736
|
var last = JSON.stringify(",".concat(path));
|
|
726
737
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
727
|
-
return "".concat(selectors, " { outline: 2px solid ").concat(
|
|
738
|
+
return "".concat(selectors, " { outline: 2px solid ").concat(selection, "; outline-offset: 1px; }");
|
|
728
739
|
}
|
|
729
740
|
|
|
730
741
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _asyncToGenerator, a as _regenerator, V as VERSION$1 } from './version-
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-d388ee0d.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';
|
|
@@ -10,7 +10,7 @@ import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID, VAL_APP_ID } from '@valbuild/ui'
|
|
|
10
10
|
import { useRouter, useRouterState } from '@tanstack/react-router';
|
|
11
11
|
import React, { useEffect, useState, useRef } from 'react';
|
|
12
12
|
import { V as ValExternalStore, a as ValOverlayProvider } from './ValOverlayContext-5bc3830f.esm.js';
|
|
13
|
-
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, isValCanvasStudioMessage, isValCanvasFrame } from '@valbuild/shared/client';
|
|
13
|
+
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, isValCanvasFrame } from '@valbuild/shared/client';
|
|
14
14
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
15
|
import '@valbuild/core/patch';
|
|
16
16
|
|
|
@@ -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.
|
|
46
|
+
while (1) switch (_context.n) {
|
|
48
47
|
case 0:
|
|
49
|
-
_context.
|
|
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
|
|
50
|
+
}, _callee);
|
|
62
51
|
}));
|
|
63
52
|
return _isValEnabled.apply(this, arguments);
|
|
64
53
|
}
|
|
@@ -219,8 +208,10 @@ var floatDarkBg = "#131316";
|
|
|
219
208
|
/** `--bg-float`, light. */
|
|
220
209
|
var floatLightBg = "#fcfcfc";
|
|
221
210
|
|
|
222
|
-
var
|
|
223
|
-
|
|
211
|
+
var DEFAULT_SELECTION = {
|
|
212
|
+
selection: DEFAULT_CANVAS_SELECTION,
|
|
213
|
+
selectionSoft: DEFAULT_CANVAS_SELECTION_SOFT
|
|
214
|
+
};
|
|
224
215
|
|
|
225
216
|
/**
|
|
226
217
|
* How often the page is re-measured even when nothing said it changed.
|
|
@@ -249,10 +240,23 @@ function ValCanvasBridge(_ref) {
|
|
|
249
240
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
250
241
|
picking = _React$useState2[0],
|
|
251
242
|
setPicking = _React$useState2[1];
|
|
252
|
-
|
|
243
|
+
/**
|
|
244
|
+
* The outline colours, as the studio last said.
|
|
245
|
+
*
|
|
246
|
+
* State rather than a prop, because it arrives over the protocol after mount:
|
|
247
|
+
* the studio sends it when the frame reports ready and again whenever the
|
|
248
|
+
* project's accent changes. Starts at Val's green so a page that is never
|
|
249
|
+
* told — an older studio, or a message that never arrives — still outlines
|
|
250
|
+
* its content.
|
|
251
|
+
*/
|
|
252
|
+
var _React$useState3 = React.useState(DEFAULT_SELECTION),
|
|
253
253
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
selectionColors = _React$useState4[0],
|
|
255
|
+
setSelectionColors = _React$useState4[1];
|
|
256
|
+
var _React$useState5 = React.useState(null),
|
|
257
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
258
|
+
highlighted = _React$useState6[0],
|
|
259
|
+
setHighlighted = _React$useState6[1];
|
|
256
260
|
// Kept in a ref as well, because the capture-phase click listener below is
|
|
257
261
|
// installed once and would otherwise close over the first value forever.
|
|
258
262
|
var pickingRef = React.useRef(false);
|
|
@@ -461,6 +465,13 @@ function ValCanvasBridge(_ref) {
|
|
|
461
465
|
setPicking(message.picking);
|
|
462
466
|
return;
|
|
463
467
|
}
|
|
468
|
+
if (message.type === "theme") {
|
|
469
|
+
setSelectionColors({
|
|
470
|
+
selection: message.selection,
|
|
471
|
+
selectionSoft: message.selectionSoft
|
|
472
|
+
});
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
464
475
|
if (message.type === "sourceUpdate") {
|
|
465
476
|
/**
|
|
466
477
|
* Handed straight to the listener the page already has.
|
|
@@ -676,7 +687,7 @@ function ValCanvasBridge(_ref) {
|
|
|
676
687
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
677
688
|
// close the selector early.
|
|
678
689
|
dangerouslySetInnerHTML: {
|
|
679
|
-
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(
|
|
690
|
+
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n[data-val-path]:hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "", highlighted ? highlightRule(highlighted, selectionColors.selection) : ""].filter(Boolean).join("\n")
|
|
680
691
|
}
|
|
681
692
|
});
|
|
682
693
|
}
|
|
@@ -694,13 +705,13 @@ function ValCanvasBridge(_ref) {
|
|
|
694
705
|
* and one in the middle. Between them they match the path as a complete list
|
|
695
706
|
* item and nothing else.
|
|
696
707
|
*/
|
|
697
|
-
function highlightRule(path) {
|
|
708
|
+
function highlightRule(path, selection) {
|
|
698
709
|
var value = JSON.stringify(path);
|
|
699
710
|
var inner = JSON.stringify(",".concat(path, ","));
|
|
700
711
|
var first = JSON.stringify("".concat(path, ","));
|
|
701
712
|
var last = JSON.stringify(",".concat(path));
|
|
702
713
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
703
|
-
return "".concat(selectors, " { outline: 2px solid ").concat(
|
|
714
|
+
return "".concat(selectors, " { outline: 2px solid ").concat(selection, "; outline-offset: 1px; }");
|
|
704
715
|
}
|
|
705
716
|
|
|
706
717
|
/**
|
|
@@ -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.
|
|
215
|
+
version: "0.130.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.
|
|
213
|
+
version: "0.130.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 };
|
|
@@ -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.
|
|
215
|
+
version: "0.130.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;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"tanstack-router",
|
|
15
15
|
"react"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.130.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.
|
|
46
|
-
"@valbuild/language-server": "0.
|
|
47
|
-
"@valbuild/mcp": "0.
|
|
48
|
-
"@valbuild/react": "0.
|
|
49
|
-
"@valbuild/server": "0.
|
|
50
|
-
"@valbuild/shared": "0.
|
|
51
|
-
"@valbuild/ui": "0.
|
|
45
|
+
"@valbuild/core": "0.130.0",
|
|
46
|
+
"@valbuild/language-server": "0.130.0",
|
|
47
|
+
"@valbuild/mcp": "0.130.0",
|
|
48
|
+
"@valbuild/react": "0.130.0",
|
|
49
|
+
"@valbuild/server": "0.130.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
|
|
5
|
+
var version = require('../../dist/version-f2ffc76f.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-2d63db20.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),
|
|
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
|
}
|
|
@@ -1024,6 +1042,13 @@ function initValMcp(valModules, config, opts) {
|
|
|
1024
1042
|
}));
|
|
1025
1043
|
}
|
|
1026
1044
|
|
|
1045
|
+
// Fills the slot the root entry holds, so `initVal().isValEnabled()` works
|
|
1046
|
+
// without the root entry importing TanStack's server module. See
|
|
1047
|
+
// valEnableCookieBridge.ts.
|
|
1048
|
+
version.setValEnableCookieReader(hasValEnableCookieOnServer);
|
|
1049
|
+
// Re-exported so an app that mounts the MCP endpoint through this package does
|
|
1050
|
+
// not also have to depend on `@valbuild/mcp` for the types it hands back.
|
|
1051
|
+
|
|
1027
1052
|
exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
|
|
1028
1053
|
exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
|
|
1029
1054
|
exports.initValContent = initValContent;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var version = require('../../dist/version-68d92818.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-b642af81.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),
|
|
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
|
}
|
|
@@ -1024,6 +1042,13 @@ function initValMcp(valModules, config, opts) {
|
|
|
1024
1042
|
}));
|
|
1025
1043
|
}
|
|
1026
1044
|
|
|
1045
|
+
// Fills the slot the root entry holds, so `initVal().isValEnabled()` works
|
|
1046
|
+
// without the root entry importing TanStack's server module. See
|
|
1047
|
+
// valEnableCookieBridge.ts.
|
|
1048
|
+
version.setValEnableCookieReader(hasValEnableCookieOnServer);
|
|
1049
|
+
// Re-exported so an app that mounts the MCP endpoint through this package does
|
|
1050
|
+
// not also have to depend on `@valbuild/mcp` for the types it hands back.
|
|
1051
|
+
|
|
1027
1052
|
exports.VAL_DRAFT_MODE_COOKIE = VAL_DRAFT_MODE_COOKIE;
|
|
1028
1053
|
exports.hasValEnableCookieOnServer = hasValEnableCookieOnServer;
|
|
1029
1054
|
exports.initValContent = initValContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-d388ee0d.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-09f11ef9.esm.js';
|
|
5
5
|
import { b as initValRouteFromVal, g as getJsonEntryStegaRoot, i as isJsonValuesRecordSchema, a as getValRouteUrlFromVal, _ as _typeof } from '../../dist/routeFromVal-728295a0.esm.js';
|
|
6
6
|
import { stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
|
|
7
7
|
import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
@@ -156,6 +156,14 @@ function _hasValEnableCookieOnServer() {
|
|
|
156
156
|
return _hasValEnableCookieOnServer.apply(this, arguments);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* What `http` mode needs, as one object.
|
|
161
|
+
*
|
|
162
|
+
* A publish there is a commit on the project's repository, so this is the
|
|
163
|
+
* shape of "Val's content service holds my patches and my repo holds my
|
|
164
|
+
* content".
|
|
165
|
+
*/
|
|
166
|
+
|
|
159
167
|
/**
|
|
160
168
|
* The Val API, as a handler you can mount on a TanStack Start server route.
|
|
161
169
|
*
|
|
@@ -164,7 +172,7 @@ function _hasValEnableCookieOnServer() {
|
|
|
164
172
|
* the conversion to a `Response`, which for Next needed `NextResponse` and here
|
|
165
173
|
* does not need anything.
|
|
166
174
|
*/
|
|
167
|
-
var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter) {
|
|
175
|
+
var initValApiHandler = function initValApiHandler(valModules, config, draftMode, formatter, commitPrepared, sourceFiles, patchStore, unsafelyAllowUnauthenticated, apiKey, publishOverride, http, valContentUrl) {
|
|
168
176
|
var route = "/api/val"; // TODO: get from config
|
|
169
177
|
var coreVersion = Internal.VERSION.core;
|
|
170
178
|
if (!coreVersion) {
|
|
@@ -174,7 +182,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
|
|
|
174
182
|
if (!tanstackVersion) {
|
|
175
183
|
throw new Error("Could not get @valbuild/tanstack package version");
|
|
176
184
|
}
|
|
177
|
-
return createValApiRouter(route, createValServer(valModules, route, _objectSpread2({
|
|
185
|
+
return createValApiRouter(route, createValServer(valModules, route, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
178
186
|
versions: {
|
|
179
187
|
/*
|
|
180
188
|
* Reported as `next` because that is the field the wire contract has.
|
|
@@ -188,7 +196,17 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
|
|
|
188
196
|
next: tanstackVersion,
|
|
189
197
|
core: coreVersion
|
|
190
198
|
}
|
|
191
|
-
}, config),
|
|
199
|
+
}, config), sourceFiles !== undefined ? {
|
|
200
|
+
sourceFiles: sourceFiles
|
|
201
|
+
} : {}), patchStore !== undefined ? {
|
|
202
|
+
patchStore: patchStore
|
|
203
|
+
} : {}), unsafelyAllowUnauthenticated !== undefined ? {
|
|
204
|
+
unsafelyAllowUnauthenticated: unsafelyAllowUnauthenticated
|
|
205
|
+
} : {}), apiKey !== undefined ? {
|
|
206
|
+
apiKey: apiKey
|
|
207
|
+
} : {}), http !== undefined ? http : {}), valContentUrl !== undefined ? {
|
|
208
|
+
valContentUrl: valContentUrl
|
|
209
|
+
} : {}), config, {
|
|
192
210
|
isEnabled: function isEnabled() {
|
|
193
211
|
return draftMode.isEnabled();
|
|
194
212
|
},
|
|
@@ -198,7 +216,7 @@ var initValApiHandler = function initValApiHandler(valModules, config, draftMode
|
|
|
198
216
|
onDisable: function onDisable() {
|
|
199
217
|
return draftMode.disable();
|
|
200
218
|
}
|
|
201
|
-
}, formatter), function (valRes) {
|
|
219
|
+
}, formatter, commitPrepared, publishOverride), function (valRes) {
|
|
202
220
|
var headers = new Headers();
|
|
203
221
|
var valResHeaders = "headers" in valRes && valRes.headers || {};
|
|
204
222
|
for (var key in valResHeaders) {
|
|
@@ -272,7 +290,7 @@ function initValServer(valModules, config, opts) {
|
|
|
272
290
|
var _opts$draftMode;
|
|
273
291
|
var draftMode = (_opts$draftMode = opts === null || opts === void 0 ? void 0 : opts.draftMode) !== null && _opts$draftMode !== void 0 ? _opts$draftMode : valDraftMode();
|
|
274
292
|
return {
|
|
275
|
-
valApiHandler: initValApiHandler(valModules, config, draftMode, opts === null || opts === void 0 ? void 0 : opts.formatter),
|
|
293
|
+
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
294
|
draftMode: draftMode
|
|
277
295
|
};
|
|
278
296
|
}
|
|
@@ -1002,4 +1020,11 @@ function initValMcp(valModules, config, opts) {
|
|
|
1002
1020
|
}));
|
|
1003
1021
|
}
|
|
1004
1022
|
|
|
1023
|
+
// Fills the slot the root entry holds, so `initVal().isValEnabled()` works
|
|
1024
|
+
// without the root entry importing TanStack's server module. See
|
|
1025
|
+
// valEnableCookieBridge.ts.
|
|
1026
|
+
setValEnableCookieReader(hasValEnableCookieOnServer);
|
|
1027
|
+
// Re-exported so an app that mounts the MCP endpoint through this package does
|
|
1028
|
+
// not also have to depend on `@valbuild/mcp` for the types it hands back.
|
|
1029
|
+
|
|
1005
1030
|
export { VAL_DRAFT_MODE_COOKIE, hasValEnableCookieOnServer, initValContent, initValMcp, initValServer, valDraftMode };
|