@valbuild/server 0.152.2 → 0.153.1
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 +44 -0
- package/browser/dist/valbuild-server-browser.cjs.dev.js +2 -2
- package/browser/dist/valbuild-server-browser.cjs.prod.js +2 -2
- package/browser/dist/valbuild-server-browser.esm.js +2 -2
- package/dist/{ValRouter-709cceaa.cjs.prod.js → ValRouter-40bf46a2.cjs.prod.js} +86 -11
- package/dist/{ValRouter-ff659cff.cjs.dev.js → ValRouter-6c633acf.cjs.dev.js} +86 -11
- package/dist/{ValRouter-7e314a55.esm.js → ValRouter-db465719.esm.js} +86 -12
- package/dist/{ValRouterCore-a5f17ad7.cjs.dev.js → ValRouterCore-2d86ff95.cjs.prod.js} +305 -251
- package/dist/{ValRouterCore-4e858bec.cjs.prod.js → ValRouterCore-a4d99115.cjs.dev.js} +305 -251
- package/dist/{ValRouterCore-c729eed3.esm.js → ValRouterCore-b3773130.esm.js} +305 -251
- package/dist/declarations/src/ValOps.d.ts +42 -4
- package/dist/declarations/src/ValOpsFS.d.ts +6 -3
- package/dist/declarations/src/ValOpsHttp.d.ts +5 -2
- package/dist/declarations/src/ValOpsMemory.d.ts +3 -2
- package/dist/declarations/src/ValRouter.d.ts +10 -0
- package/dist/declarations/src/ValServer.d.ts +2 -0
- package/dist/declarations/src/draftReads.d.ts +1 -8
- package/dist/declarations/src/internal/index.d.ts +2 -2
- package/dist/declarations/src/proposal.d.ts +19 -3
- package/dist/{draftReads-05415ff6.cjs.dev.js → draftReads-0dcddf72.cjs.prod.js} +0 -17
- package/dist/{draftReads-5f99edd3.esm.js → draftReads-1f29aedd.esm.js} +2 -18
- package/dist/{draftReads-ea3946e0.cjs.prod.js → draftReads-df44e629.cjs.dev.js} +0 -17
- package/dist/{inTabFetch-fb9ee475.cjs.dev.js → inTabFetch-6382d21a.cjs.dev.js} +1 -1
- package/dist/{inTabFetch-b0a0e42f.esm.js → inTabFetch-80b6b9e8.esm.js} +1 -1
- package/dist/{inTabFetch-9b93a5d8.cjs.prod.js → inTabFetch-95c17bcc.cjs.prod.js} +1 -1
- package/dist/{publishKit-9c0c6880.cjs.dev.js → publishKit-500645fd.cjs.dev.js} +2 -2
- package/dist/{publishKit-ba7ff0e3.cjs.prod.js → publishKit-b4c47ed0.cjs.prod.js} +2 -2
- package/dist/{publishKit-5fe7f248.esm.js → publishKit-c03f3e49.esm.js} +3 -3
- package/dist/valbuild-server.cjs.dev.js +2 -2
- package/dist/valbuild-server.cjs.prod.js +2 -2
- package/dist/valbuild-server.esm.js +4 -4
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +3 -3
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +3 -3
- package/internal/browser/dist/valbuild-server-internal-browser.esm.js +3 -3
- package/internal/dist/valbuild-server-internal.cjs.dev.js +4 -4
- package/internal/dist/valbuild-server-internal.cjs.prod.js +4 -4
- package/internal/dist/valbuild-server-internal.esm.js +3 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @valbuild/server
|
|
2
2
|
|
|
3
|
+
## 0.153.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1031](https://github.com/valbuild/val/pull/1031) [`6ec1a5d`](https://github.com/valbuild/val/commit/6ec1a5d244f0d6e064eca4135f167dfa79744f9a) Thanks [@freekh](https://github.com/freekh)! - A page no longer shows content made for code it does not have yet. When the Studio is ahead of the page (it picked up a code change first, or the browser is still running the previous build), the page keeps showing its own content for the modules whose schema changed, and says "The code changed" with a **Reload** button — in the overlay on your site, and above the page in the Studio. In local development the page usually catches up a moment later by itself, and the notice goes away without a reload.
|
|
8
|
+
- Updated dependencies [[`6ec1a5d`](https://github.com/valbuild/val/commit/6ec1a5d244f0d6e064eca4135f167dfa79744f9a), [`f1048d9`](https://github.com/valbuild/val/commit/f1048d93a76138d031b30d059c444a8f754b484d), [`b14870b`](https://github.com/valbuild/val/commit/b14870bebdc128234bb16e4ea06a0151d18c4771)]:
|
|
9
|
+
- @valbuild/shared@0.153.1
|
|
10
|
+
- @valbuild/ui@0.153.1
|
|
11
|
+
|
|
12
|
+
## 0.153.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#1016](https://github.com/valbuild/val/pull/1016) [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9) Thanks [@freekh](https://github.com/freekh)! - Editing content in a proposal whose code changed, before the proposal is built again:
|
|
17
|
+
|
|
18
|
+
- **A module the proposal adds** can be edited and saved right away. Its content is read from the new file and saved. Before, those edits were dropped. If the module's content is made by code (not written out in the file), the save waits and says to build the proposal first.
|
|
19
|
+
- **A module whose schema moved because a file it imports changed** (for example a shared `src/schemas/*.ts`) is no longer read with the old schema. Pages keep showing the content as built until the proposal is built again.
|
|
20
|
+
- **Edits that no longer fit the schema** can be handed to the assistant. The banner that lists them has a **Have the assistant move it** button for each one. You still discard the held edit yourself afterwards.
|
|
21
|
+
|
|
22
|
+
For this, `@valbuild/tanstack-build` records which files each Val module imports, and the `val.server.ts` it generates passes that to Val as the new optional `moduleDependencies` option of `initValServer` and `initValContent`. You do not need to set it yourself. A site built before this has no `moduleDependencies` and works as before.
|
|
23
|
+
|
|
24
|
+
- [#1016](https://github.com/valbuild/val/pull/1016) [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9) Thanks [@freekh](https://github.com/freekh)! - Removed what 0.151.0 kept only so that a Studio, a page and a server from the release before could still talk to each other during a deploy:
|
|
25
|
+
|
|
26
|
+
- **`PUT /api/val/sources/~`** is gone. Nothing in 0.151.0 asked it: the Studio reads modules through `GET /api/val/manifest` and `GET /api/val/modules/~<path>`, and `fetchVal`, `useVal` and the MCP tools read the server's content in-process. If a script or test of yours read content through it, read one module with `GET /api/val/modules/~<path>` instead. Its answer has the module's `source` and `version`, and an `entries` map holding the `.jsonValues()` entries pending changes touched.
|
|
27
|
+
- **`ValDraft.base`** is gone from the type. It has not been sent or read since 0.151.0, so a `draft` you pass to `ValProvider` is not affected.
|
|
28
|
+
- **A page no longer accepts edits relayed by a Studio from before 0.151.0.** Such a Studio sent each module as a bare `source`. After the upgrade, the Studio and your pages come from the same deploy, so this only matters while an older Studio is still open in a tab during a rollout. Reloading that tab fixes it.
|
|
29
|
+
- **`/api/val/stat`** no longer needs `sourcesSha` and `schemaSha`. The Studio now tells your local server which version it last saw, and the server still sends both fields for a Studio of 0.151.0. They stop being sent in the next release.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#1028](https://github.com/valbuild/val/pull/1028) [`27e51ba`](https://github.com/valbuild/val/commit/27e51baadce61b2cbee2d5ef227aae045ccb2e21) Thanks [@freekh](https://github.com/freekh)! - Another editor's keystroke costs the Studio less. Locally (`pnpm dev`, and
|
|
34
|
+
anywhere `/stat` long-polls), the Studio no longer asks for the manifest or
|
|
35
|
+
the changed module after someone else types: `/stat` now carries what
|
|
36
|
+
`GET /manifest` would have answered, and the module's new version is computed
|
|
37
|
+
from the patch the Studio already fetched. Where neither can be used (an
|
|
38
|
+
older server, a version that does not match), the Studio asks for them as
|
|
39
|
+
before.
|
|
40
|
+
|
|
41
|
+
- [#1016](https://github.com/valbuild/val/pull/1016) [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9) Thanks [@freekh](https://github.com/freekh)! - `/api/val/enable`, `/api/val/disable` and Val's other routes that take `redirect_to` now accept a path on your site, such as `?redirect_to=/blog`, and redirect to it on the same origin. In a Next.js app a path used to answer 500. A value that is neither a path starting with `/` nor an absolute URL is refused with a 400 that says what is accepted.
|
|
42
|
+
- Updated dependencies [[`67145fd`](https://github.com/valbuild/val/commit/67145fd16e35f2e3e0988ca5690fe5a4f84c1a41), [`67145fd`](https://github.com/valbuild/val/commit/67145fd16e35f2e3e0988ca5690fe5a4f84c1a41), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`27e51ba`](https://github.com/valbuild/val/commit/27e51baadce61b2cbee2d5ef227aae045ccb2e21), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9), [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9), [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`2e70d13`](https://github.com/valbuild/val/commit/2e70d13cf7ca25874900c9ea25227df2876727b9), [`67145fd`](https://github.com/valbuild/val/commit/67145fd16e35f2e3e0988ca5690fe5a4f84c1a41), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`efa1f7d`](https://github.com/valbuild/val/commit/efa1f7d810f3c4e4e21502c9cc81ce86da93650c), [`56ab7d5`](https://github.com/valbuild/val/commit/56ab7d5818772a9e310a561ebdb798b27ee704c9)]:
|
|
43
|
+
- @valbuild/ui@0.153.0
|
|
44
|
+
- @valbuild/core@0.153.0
|
|
45
|
+
- @valbuild/shared@0.153.0
|
|
46
|
+
|
|
3
47
|
## 0.152.2
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var inTabFetch = require('../../dist/inTabFetch-
|
|
5
|
+
var inTabFetch = require('../../dist/inTabFetch-6382d21a.cjs.dev.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
|
-
require('../../dist/ValRouterCore-
|
|
7
|
+
require('../../dist/ValRouterCore-a4d99115.cjs.dev.js');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@valbuild/shared/internal');
|
|
10
10
|
require('zod-validation-error');
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var inTabFetch = require('../../dist/inTabFetch-
|
|
5
|
+
var inTabFetch = require('../../dist/inTabFetch-95c17bcc.cjs.prod.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
|
-
require('../../dist/ValRouterCore-
|
|
7
|
+
require('../../dist/ValRouterCore-2d86ff95.cjs.prod.js');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@valbuild/shared/internal');
|
|
10
10
|
require('zod-validation-error');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as createInTabValFetch } from '../../dist/inTabFetch-
|
|
1
|
+
export { c as createInTabValFetch } from '../../dist/inTabFetch-80b6b9e8.esm.js';
|
|
2
2
|
import '@valbuild/core';
|
|
3
|
-
import '../../dist/ValRouterCore-
|
|
3
|
+
import '../../dist/ValRouterCore-b3773130.esm.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@valbuild/shared/internal';
|
|
6
6
|
import 'zod-validation-error';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@valbuild/core');
|
|
4
4
|
var server = require('@valbuild/ui/server');
|
|
5
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
5
|
+
var ValRouterCore = require('./ValRouterCore-2d86ff95.cjs.prod.js');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var ts = require('typescript');
|
|
8
8
|
var z = require('zod');
|
|
@@ -2205,7 +2205,7 @@ function createFsSketchpadStore(rootDir, now = () => new Date()) {
|
|
|
2205
2205
|
* as a bundler does.
|
|
2206
2206
|
*/
|
|
2207
2207
|
function loadTypeScriptKit() {
|
|
2208
|
-
return Promise.resolve().then(function () { return require('./publishKit-
|
|
2208
|
+
return Promise.resolve().then(function () { return require('./publishKit-b4c47ed0.cjs.prod.js'); });
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
2211
|
/** Serializes a schema, or gives up quietly — serialization errors are reported elsewhere. */
|
|
@@ -2424,9 +2424,12 @@ class ValOpsFS extends ValRouterCore.ValOps {
|
|
|
2424
2424
|
const didChange = !params ||
|
|
2425
2425
|
// An entry file changed on disk: nothing else here can see that, since a
|
|
2426
2426
|
// jsonValues module's source is markers.
|
|
2427
|
-
params.jsonEntriesSha !== undefined && currentJsonEntriesSha !== params.jsonEntriesSha || currentBaseSha !== params.baseSha ||
|
|
2428
|
-
//
|
|
2429
|
-
|
|
2427
|
+
params.jsonEntriesSha !== undefined && currentJsonEntriesSha !== params.jsonEntriesSha || currentBaseSha !== params.baseSha || (
|
|
2428
|
+
// Another build: by the version the Studio echoes -- the build the
|
|
2429
|
+
// chain is relative to (`chainBuild`), which every instance on this
|
|
2430
|
+
// store answers with -- or, from a Studio that echoes no version
|
|
2431
|
+
// (the release that shipped the one content model), by the shas.
|
|
2432
|
+
params.version !== undefined ? params.version.build !== (await this.chainBuild()) : currentSourcesSha !== params.sourcesSha || currentSchemaSha !== params.schemaSha) || patches.length !== params.patches.length || patches.some((p, i) => p !== params.patches[i]);
|
|
2430
2433
|
if (didChange) {
|
|
2431
2434
|
return {
|
|
2432
2435
|
type: "did-change",
|
|
@@ -3607,16 +3610,76 @@ class FSOpsHost {
|
|
|
3607
3610
|
* sound: a module's schema can move with a file it imports, so "its own file
|
|
3608
3611
|
* is unchanged" never says its code is in the build.
|
|
3609
3612
|
*/
|
|
3610
|
-
function stagedAfterBuild(proposal) {
|
|
3613
|
+
function stagedAfterBuild(proposal, build) {
|
|
3611
3614
|
const inBuild = proposal.buildInputs === null || proposal.buildInputs === undefined ? null : `${internal.STAGED_SCHEMA_PREFIX}${proposal.buildInputs}`;
|
|
3612
3615
|
const after = {};
|
|
3613
3616
|
for (const [path, version] of Object.entries(proposal.staged ?? {})) {
|
|
3614
3617
|
if (version === inBuild) continue;
|
|
3615
3618
|
after[path] = version;
|
|
3616
3619
|
}
|
|
3620
|
+
if (build === undefined || proposal.files === undefined) return after;
|
|
3621
|
+
/*
|
|
3622
|
+
* Through what a module imports. The overlay names only staged MODULE
|
|
3623
|
+
* files, and a module's schema moves with any file it imports, so a module
|
|
3624
|
+
* whose own file is not staged can still be of code the build was not made
|
|
3625
|
+
* of. What changed since the build is read from text: a file the proposal
|
|
3626
|
+
* holds that is code (not a module file, not an entry's `*.val.json` --
|
|
3627
|
+
* saves write those, stagings write code) and whose text is not what the
|
|
3628
|
+
* build was made of; and every module file staged after the build. A
|
|
3629
|
+
* module that depends on one of those, as the build resolved its imports,
|
|
3630
|
+
* is staged after the build as well.
|
|
3631
|
+
*/
|
|
3632
|
+
const changed = new Set(Object.keys(after).map(path => path.replace(/^\/+/, "")));
|
|
3633
|
+
const changedCode = [];
|
|
3634
|
+
for (const [path, text] of Object.entries(proposal.files)) {
|
|
3635
|
+
if (isModuleOrEntryFile(path)) continue;
|
|
3636
|
+
if (build.source[path] === text) continue;
|
|
3637
|
+
changed.add(path);
|
|
3638
|
+
changedCode.push([path, text]);
|
|
3639
|
+
}
|
|
3640
|
+
if (changed.size === 0) return after;
|
|
3641
|
+
/*
|
|
3642
|
+
* Named after the staging where the overlay names it (every staged
|
|
3643
|
+
* module's version is the same `staged:<inputs>`); where it names none --
|
|
3644
|
+
* only code that is not a module was staged -- after the code that
|
|
3645
|
+
* changed, which is as distinct per staging and is never a build's.
|
|
3646
|
+
*/
|
|
3647
|
+
const named = Object.values(proposal.staged ?? {})[0] ?? `${internal.STAGED_SCHEMA_PREFIX}${hashOfFiles(changedCode)}`;
|
|
3648
|
+
for (const [modulePath, dependencies] of Object.entries(build.moduleDependencies)) {
|
|
3649
|
+
const moduleFilePath = `/${modulePath.replace(/^\/+/, "")}`;
|
|
3650
|
+
if (after[moduleFilePath] !== undefined) continue;
|
|
3651
|
+
if (dependencies.some(dependency => changed.has(dependency))) {
|
|
3652
|
+
after[moduleFilePath] = named;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3617
3655
|
return after;
|
|
3618
3656
|
}
|
|
3619
3657
|
|
|
3658
|
+
/**
|
|
3659
|
+
* What the build serving the address was made of, as the platform builds it
|
|
3660
|
+
* and embeds it: its own source (`platform:project-source`) and, for each
|
|
3661
|
+
* module file, every project file it depends on as the build resolved its
|
|
3662
|
+
* imports (`moduleDependencies`, by path with no leading slash, transitive).
|
|
3663
|
+
* For {@link stagedAfterBuild}.
|
|
3664
|
+
*/
|
|
3665
|
+
|
|
3666
|
+
/** The {@link ServingBuild} a host handed over, or `undefined` when not both. */
|
|
3667
|
+
function servingBuildOf(http) {
|
|
3668
|
+
return http.projectSource !== undefined && http.moduleDependencies !== undefined ? {
|
|
3669
|
+
source: http.projectSource,
|
|
3670
|
+
moduleDependencies: http.moduleDependencies
|
|
3671
|
+
} : undefined;
|
|
3672
|
+
}
|
|
3673
|
+
function isModuleOrEntryFile(path) {
|
|
3674
|
+
return /\.val\.(ts|js|json)$/.test(path);
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
/** A 64-hex name for code that changed: its paths and text, in order. */
|
|
3678
|
+
function hashOfFiles(files) {
|
|
3679
|
+
const sorted = [...files].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
3680
|
+
return core.Internal.getSHA256Hash(new TextEncoder().encode(JSON.stringify(sorted)));
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3620
3683
|
/**
|
|
3621
3684
|
* The proposal a platform describes in its runtime env, or `undefined` when
|
|
3622
3685
|
* this is not a proposal's address.
|
|
@@ -3890,8 +3953,8 @@ function layeredSnapshot(proposal, contentVersion) {
|
|
|
3890
3953
|
* -- until a build of the staging serves the address. The same rule as
|
|
3891
3954
|
* `layered`'s, for the one source that carries no version.
|
|
3892
3955
|
*/
|
|
3893
|
-
function proposalAsBuilt(proposal) {
|
|
3894
|
-
const after = stagedAfterBuild(proposal);
|
|
3956
|
+
function proposalAsBuilt(proposal, build) {
|
|
3957
|
+
const after = stagedAfterBuild(proposal, build);
|
|
3895
3958
|
if (Object.keys(after).length === 0) return proposal;
|
|
3896
3959
|
const modules = {};
|
|
3897
3960
|
for (const [path, source] of Object.entries(proposal.modules)) {
|
|
@@ -4926,7 +4989,7 @@ async function stagedModuleSources(files) {
|
|
|
4926
4989
|
parseValFile,
|
|
4927
4990
|
analyzeValModule,
|
|
4928
4991
|
evaluateModuleSource
|
|
4929
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
4992
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-b4c47ed0.cjs.prod.js'); });
|
|
4930
4993
|
const sources = {};
|
|
4931
4994
|
for (const {
|
|
4932
4995
|
path,
|
|
@@ -5763,7 +5826,7 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
5763
5826
|
* their staged text, versioned as their staging. See `stagedAfterBuild`.
|
|
5764
5827
|
*/
|
|
5765
5828
|
const proposal = options === null || options === void 0 ? void 0 : options.proposal;
|
|
5766
|
-
const staged = proposal !== undefined ? stagedAfterBuild(proposal) : {};
|
|
5829
|
+
const staged = proposal !== undefined ? stagedAfterBuild(proposal, servingBuildOf(options ?? {})) : {};
|
|
5767
5830
|
const stagedPaths = Object.keys(staged);
|
|
5768
5831
|
super(valModules, options && snapshot ? {
|
|
5769
5832
|
...options,
|
|
@@ -5774,8 +5837,12 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
5774
5837
|
stagedAfterBuild: {
|
|
5775
5838
|
versions: staged,
|
|
5776
5839
|
readSources: () => stagedModuleSources(Object.fromEntries(stagedPaths.map(path => {
|
|
5840
|
+
var _options$projectSourc;
|
|
5777
5841
|
const file = path.replace(/^\/+/, "");
|
|
5778
|
-
|
|
5842
|
+
// A module staged after the build through a file
|
|
5843
|
+
// it imports has its own text unstaged: the
|
|
5844
|
+
// build's, unless a save rewrote it.
|
|
5845
|
+
return [file, proposal.files[file] ?? ((_options$projectSourc = options.projectSource) === null || _options$projectSourc === void 0 ? void 0 : _options$projectSourc[file]) ?? null];
|
|
5779
5846
|
})))
|
|
5780
5847
|
}
|
|
5781
5848
|
} : {}),
|
|
@@ -8872,6 +8939,9 @@ async function initHandlerOptions(route, opts, config) {
|
|
|
8872
8939
|
...(opts.projectSource !== undefined ? {
|
|
8873
8940
|
projectSource: opts.projectSource
|
|
8874
8941
|
} : {}),
|
|
8942
|
+
...(opts.moduleDependencies !== undefined ? {
|
|
8943
|
+
moduleDependencies: opts.moduleDependencies
|
|
8944
|
+
} : {}),
|
|
8875
8945
|
...(opts.publishJob !== undefined ? {
|
|
8876
8946
|
publishJob: opts.publishJob
|
|
8877
8947
|
} : {}),
|
|
@@ -8955,6 +9025,9 @@ function createValOps(valModules, options) {
|
|
|
8955
9025
|
...(options.projectSource !== undefined ? {
|
|
8956
9026
|
projectSource: options.projectSource
|
|
8957
9027
|
} : {}),
|
|
9028
|
+
...(options.moduleDependencies !== undefined ? {
|
|
9029
|
+
moduleDependencies: options.moduleDependencies
|
|
9030
|
+
} : {}),
|
|
8958
9031
|
...(options.publishJob !== undefined ? {
|
|
8959
9032
|
publishJob: options.publishJob
|
|
8960
9033
|
} : {}),
|
|
@@ -9462,6 +9535,7 @@ function differences(a, b) {
|
|
|
9462
9535
|
check("git", sameValue(a.git, b.git));
|
|
9463
9536
|
check("root", a.root === b.root);
|
|
9464
9537
|
check("projectSource", sameValue(a.projectSource, b.projectSource));
|
|
9538
|
+
check("moduleDependencies", sameValue(a.moduleDependencies, b.moduleDependencies));
|
|
9465
9539
|
check("publishJob", a.publishJob === b.publishJob);
|
|
9466
9540
|
check("publishBuild", a.publishBuild === b.publishBuild);
|
|
9467
9541
|
check("proposal", sameValue(a.proposal, b.proposal));
|
|
@@ -14431,6 +14505,7 @@ exports.readPatchStore = readPatchStore;
|
|
|
14431
14505
|
exports.removeValJsonEntry = removeValJsonEntry;
|
|
14432
14506
|
exports.resolveRemoteFileAuth = resolveRemoteFileAuth;
|
|
14433
14507
|
exports.safeReadGit = safeReadGit;
|
|
14508
|
+
exports.servingBuildOf = servingBuildOf;
|
|
14434
14509
|
exports.stagedAfterBuild = stagedAfterBuild;
|
|
14435
14510
|
exports.unreadableVideoMetadataMessage = unreadableVideoMetadataMessage;
|
|
14436
14511
|
exports.uploadBytesToRemote = uploadBytesToRemote;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@valbuild/core');
|
|
4
4
|
var server = require('@valbuild/ui/server');
|
|
5
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
5
|
+
var ValRouterCore = require('./ValRouterCore-a4d99115.cjs.dev.js');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var ts = require('typescript');
|
|
8
8
|
var z = require('zod');
|
|
@@ -2205,7 +2205,7 @@ function createFsSketchpadStore(rootDir, now = () => new Date()) {
|
|
|
2205
2205
|
* as a bundler does.
|
|
2206
2206
|
*/
|
|
2207
2207
|
function loadTypeScriptKit() {
|
|
2208
|
-
return Promise.resolve().then(function () { return require('./publishKit-
|
|
2208
|
+
return Promise.resolve().then(function () { return require('./publishKit-500645fd.cjs.dev.js'); });
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
2211
|
/** Serializes a schema, or gives up quietly — serialization errors are reported elsewhere. */
|
|
@@ -2424,9 +2424,12 @@ class ValOpsFS extends ValRouterCore.ValOps {
|
|
|
2424
2424
|
const didChange = !params ||
|
|
2425
2425
|
// An entry file changed on disk: nothing else here can see that, since a
|
|
2426
2426
|
// jsonValues module's source is markers.
|
|
2427
|
-
params.jsonEntriesSha !== undefined && currentJsonEntriesSha !== params.jsonEntriesSha || currentBaseSha !== params.baseSha ||
|
|
2428
|
-
//
|
|
2429
|
-
|
|
2427
|
+
params.jsonEntriesSha !== undefined && currentJsonEntriesSha !== params.jsonEntriesSha || currentBaseSha !== params.baseSha || (
|
|
2428
|
+
// Another build: by the version the Studio echoes -- the build the
|
|
2429
|
+
// chain is relative to (`chainBuild`), which every instance on this
|
|
2430
|
+
// store answers with -- or, from a Studio that echoes no version
|
|
2431
|
+
// (the release that shipped the one content model), by the shas.
|
|
2432
|
+
params.version !== undefined ? params.version.build !== (await this.chainBuild()) : currentSourcesSha !== params.sourcesSha || currentSchemaSha !== params.schemaSha) || patches.length !== params.patches.length || patches.some((p, i) => p !== params.patches[i]);
|
|
2430
2433
|
if (didChange) {
|
|
2431
2434
|
return {
|
|
2432
2435
|
type: "did-change",
|
|
@@ -3607,16 +3610,76 @@ class FSOpsHost {
|
|
|
3607
3610
|
* sound: a module's schema can move with a file it imports, so "its own file
|
|
3608
3611
|
* is unchanged" never says its code is in the build.
|
|
3609
3612
|
*/
|
|
3610
|
-
function stagedAfterBuild(proposal) {
|
|
3613
|
+
function stagedAfterBuild(proposal, build) {
|
|
3611
3614
|
const inBuild = proposal.buildInputs === null || proposal.buildInputs === undefined ? null : `${internal.STAGED_SCHEMA_PREFIX}${proposal.buildInputs}`;
|
|
3612
3615
|
const after = {};
|
|
3613
3616
|
for (const [path, version] of Object.entries(proposal.staged ?? {})) {
|
|
3614
3617
|
if (version === inBuild) continue;
|
|
3615
3618
|
after[path] = version;
|
|
3616
3619
|
}
|
|
3620
|
+
if (build === undefined || proposal.files === undefined) return after;
|
|
3621
|
+
/*
|
|
3622
|
+
* Through what a module imports. The overlay names only staged MODULE
|
|
3623
|
+
* files, and a module's schema moves with any file it imports, so a module
|
|
3624
|
+
* whose own file is not staged can still be of code the build was not made
|
|
3625
|
+
* of. What changed since the build is read from text: a file the proposal
|
|
3626
|
+
* holds that is code (not a module file, not an entry's `*.val.json` --
|
|
3627
|
+
* saves write those, stagings write code) and whose text is not what the
|
|
3628
|
+
* build was made of; and every module file staged after the build. A
|
|
3629
|
+
* module that depends on one of those, as the build resolved its imports,
|
|
3630
|
+
* is staged after the build as well.
|
|
3631
|
+
*/
|
|
3632
|
+
const changed = new Set(Object.keys(after).map(path => path.replace(/^\/+/, "")));
|
|
3633
|
+
const changedCode = [];
|
|
3634
|
+
for (const [path, text] of Object.entries(proposal.files)) {
|
|
3635
|
+
if (isModuleOrEntryFile(path)) continue;
|
|
3636
|
+
if (build.source[path] === text) continue;
|
|
3637
|
+
changed.add(path);
|
|
3638
|
+
changedCode.push([path, text]);
|
|
3639
|
+
}
|
|
3640
|
+
if (changed.size === 0) return after;
|
|
3641
|
+
/*
|
|
3642
|
+
* Named after the staging where the overlay names it (every staged
|
|
3643
|
+
* module's version is the same `staged:<inputs>`); where it names none --
|
|
3644
|
+
* only code that is not a module was staged -- after the code that
|
|
3645
|
+
* changed, which is as distinct per staging and is never a build's.
|
|
3646
|
+
*/
|
|
3647
|
+
const named = Object.values(proposal.staged ?? {})[0] ?? `${internal.STAGED_SCHEMA_PREFIX}${hashOfFiles(changedCode)}`;
|
|
3648
|
+
for (const [modulePath, dependencies] of Object.entries(build.moduleDependencies)) {
|
|
3649
|
+
const moduleFilePath = `/${modulePath.replace(/^\/+/, "")}`;
|
|
3650
|
+
if (after[moduleFilePath] !== undefined) continue;
|
|
3651
|
+
if (dependencies.some(dependency => changed.has(dependency))) {
|
|
3652
|
+
after[moduleFilePath] = named;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3617
3655
|
return after;
|
|
3618
3656
|
}
|
|
3619
3657
|
|
|
3658
|
+
/**
|
|
3659
|
+
* What the build serving the address was made of, as the platform builds it
|
|
3660
|
+
* and embeds it: its own source (`platform:project-source`) and, for each
|
|
3661
|
+
* module file, every project file it depends on as the build resolved its
|
|
3662
|
+
* imports (`moduleDependencies`, by path with no leading slash, transitive).
|
|
3663
|
+
* For {@link stagedAfterBuild}.
|
|
3664
|
+
*/
|
|
3665
|
+
|
|
3666
|
+
/** The {@link ServingBuild} a host handed over, or `undefined` when not both. */
|
|
3667
|
+
function servingBuildOf(http) {
|
|
3668
|
+
return http.projectSource !== undefined && http.moduleDependencies !== undefined ? {
|
|
3669
|
+
source: http.projectSource,
|
|
3670
|
+
moduleDependencies: http.moduleDependencies
|
|
3671
|
+
} : undefined;
|
|
3672
|
+
}
|
|
3673
|
+
function isModuleOrEntryFile(path) {
|
|
3674
|
+
return /\.val\.(ts|js|json)$/.test(path);
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
/** A 64-hex name for code that changed: its paths and text, in order. */
|
|
3678
|
+
function hashOfFiles(files) {
|
|
3679
|
+
const sorted = [...files].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
3680
|
+
return core.Internal.getSHA256Hash(new TextEncoder().encode(JSON.stringify(sorted)));
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3620
3683
|
/**
|
|
3621
3684
|
* The proposal a platform describes in its runtime env, or `undefined` when
|
|
3622
3685
|
* this is not a proposal's address.
|
|
@@ -3890,8 +3953,8 @@ function layeredSnapshot(proposal, contentVersion) {
|
|
|
3890
3953
|
* -- until a build of the staging serves the address. The same rule as
|
|
3891
3954
|
* `layered`'s, for the one source that carries no version.
|
|
3892
3955
|
*/
|
|
3893
|
-
function proposalAsBuilt(proposal) {
|
|
3894
|
-
const after = stagedAfterBuild(proposal);
|
|
3956
|
+
function proposalAsBuilt(proposal, build) {
|
|
3957
|
+
const after = stagedAfterBuild(proposal, build);
|
|
3895
3958
|
if (Object.keys(after).length === 0) return proposal;
|
|
3896
3959
|
const modules = {};
|
|
3897
3960
|
for (const [path, source] of Object.entries(proposal.modules)) {
|
|
@@ -4926,7 +4989,7 @@ async function stagedModuleSources(files) {
|
|
|
4926
4989
|
parseValFile,
|
|
4927
4990
|
analyzeValModule,
|
|
4928
4991
|
evaluateModuleSource
|
|
4929
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
4992
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-500645fd.cjs.dev.js'); });
|
|
4930
4993
|
const sources = {};
|
|
4931
4994
|
for (const {
|
|
4932
4995
|
path,
|
|
@@ -5763,7 +5826,7 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
5763
5826
|
* their staged text, versioned as their staging. See `stagedAfterBuild`.
|
|
5764
5827
|
*/
|
|
5765
5828
|
const proposal = options === null || options === void 0 ? void 0 : options.proposal;
|
|
5766
|
-
const staged = proposal !== undefined ? stagedAfterBuild(proposal) : {};
|
|
5829
|
+
const staged = proposal !== undefined ? stagedAfterBuild(proposal, servingBuildOf(options ?? {})) : {};
|
|
5767
5830
|
const stagedPaths = Object.keys(staged);
|
|
5768
5831
|
super(valModules, options && snapshot ? {
|
|
5769
5832
|
...options,
|
|
@@ -5774,8 +5837,12 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
5774
5837
|
stagedAfterBuild: {
|
|
5775
5838
|
versions: staged,
|
|
5776
5839
|
readSources: () => stagedModuleSources(Object.fromEntries(stagedPaths.map(path => {
|
|
5840
|
+
var _options$projectSourc;
|
|
5777
5841
|
const file = path.replace(/^\/+/, "");
|
|
5778
|
-
|
|
5842
|
+
// A module staged after the build through a file
|
|
5843
|
+
// it imports has its own text unstaged: the
|
|
5844
|
+
// build's, unless a save rewrote it.
|
|
5845
|
+
return [file, proposal.files[file] ?? ((_options$projectSourc = options.projectSource) === null || _options$projectSourc === void 0 ? void 0 : _options$projectSourc[file]) ?? null];
|
|
5779
5846
|
})))
|
|
5780
5847
|
}
|
|
5781
5848
|
} : {}),
|
|
@@ -8872,6 +8939,9 @@ async function initHandlerOptions(route, opts, config) {
|
|
|
8872
8939
|
...(opts.projectSource !== undefined ? {
|
|
8873
8940
|
projectSource: opts.projectSource
|
|
8874
8941
|
} : {}),
|
|
8942
|
+
...(opts.moduleDependencies !== undefined ? {
|
|
8943
|
+
moduleDependencies: opts.moduleDependencies
|
|
8944
|
+
} : {}),
|
|
8875
8945
|
...(opts.publishJob !== undefined ? {
|
|
8876
8946
|
publishJob: opts.publishJob
|
|
8877
8947
|
} : {}),
|
|
@@ -8955,6 +9025,9 @@ function createValOps(valModules, options) {
|
|
|
8955
9025
|
...(options.projectSource !== undefined ? {
|
|
8956
9026
|
projectSource: options.projectSource
|
|
8957
9027
|
} : {}),
|
|
9028
|
+
...(options.moduleDependencies !== undefined ? {
|
|
9029
|
+
moduleDependencies: options.moduleDependencies
|
|
9030
|
+
} : {}),
|
|
8958
9031
|
...(options.publishJob !== undefined ? {
|
|
8959
9032
|
publishJob: options.publishJob
|
|
8960
9033
|
} : {}),
|
|
@@ -9462,6 +9535,7 @@ function differences(a, b) {
|
|
|
9462
9535
|
check("git", sameValue(a.git, b.git));
|
|
9463
9536
|
check("root", a.root === b.root);
|
|
9464
9537
|
check("projectSource", sameValue(a.projectSource, b.projectSource));
|
|
9538
|
+
check("moduleDependencies", sameValue(a.moduleDependencies, b.moduleDependencies));
|
|
9465
9539
|
check("publishJob", a.publishJob === b.publishJob);
|
|
9466
9540
|
check("publishBuild", a.publishBuild === b.publishBuild);
|
|
9467
9541
|
check("proposal", sameValue(a.proposal, b.proposal));
|
|
@@ -14431,6 +14505,7 @@ exports.readPatchStore = readPatchStore;
|
|
|
14431
14505
|
exports.removeValJsonEntry = removeValJsonEntry;
|
|
14432
14506
|
exports.resolveRemoteFileAuth = resolveRemoteFileAuth;
|
|
14433
14507
|
exports.safeReadGit = safeReadGit;
|
|
14508
|
+
exports.servingBuildOf = servingBuildOf;
|
|
14434
14509
|
exports.stagedAfterBuild = stagedAfterBuild;
|
|
14435
14510
|
exports.unreadableVideoMetadataMessage = unreadableVideoMetadataMessage;
|
|
14436
14511
|
exports.uploadBytesToRemote = uploadBytesToRemote;
|