@valbuild/server 0.155.0 → 0.156.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/browser/dist/valbuild-server-browser.cjs.dev.js +2 -2
  3. package/browser/dist/valbuild-server-browser.cjs.prod.js +2 -2
  4. package/browser/dist/valbuild-server-browser.esm.js +2 -2
  5. package/dist/{ValOpsMemory-f000531b.cjs.prod.js → ValOpsMemory-073f9526.cjs.prod.js} +1 -1
  6. package/dist/{ValOpsMemory-6e829758.cjs.dev.js → ValOpsMemory-3ce3e9e8.cjs.dev.js} +1 -1
  7. package/dist/{ValOpsMemory-1a0bc2dc.esm.js → ValOpsMemory-ecc15827.esm.js} +1 -1
  8. package/dist/{createPrettierFormatter-5d830bdf.cjs.dev.js → createPrettierFormatter-8e60f596.cjs.prod.js} +1 -1
  9. package/dist/{createPrettierFormatter-b31bfbe5.cjs.prod.js → createPrettierFormatter-a9109288.cjs.dev.js} +1 -1
  10. package/dist/{createPrettierFormatter-ce478de1.esm.js → createPrettierFormatter-fb68e363.esm.js} +1 -1
  11. package/dist/{createValRuntime-f55300a0.esm.js → createValRuntime-02197b93.esm.js} +6 -4
  12. package/dist/{createValRuntime-a519939b.cjs.prod.js → createValRuntime-42622f8f.cjs.prod.js} +6 -4
  13. package/dist/{createValRuntime-1c7d891e.cjs.dev.js → createValRuntime-b55d14f0.cjs.dev.js} +6 -4
  14. package/dist/declarations/src/internal/index.d.ts +14 -0
  15. package/dist/declarations/src/proposalMerge/foldContent.d.ts +45 -0
  16. package/dist/declarations/src/proposalMerge/project.d.ts +124 -0
  17. package/dist/declarations/src/proposalMerge/threeWay.d.ts +51 -0
  18. package/dist/declarations/src/proposalMerge/validate.d.ts +16 -0
  19. package/dist/foldContent-2c218a30.cjs.dev.js +216 -0
  20. package/dist/foldContent-54f2c87c.cjs.prod.js +216 -0
  21. package/dist/foldContent-f065c19f.esm.js +214 -0
  22. package/dist/{inTabFetch-3d8ceb84.cjs.prod.js → inTabFetch-46ad6b87.cjs.prod.js} +1 -1
  23. package/dist/{inTabFetch-dae5dd87.esm.js → inTabFetch-6dacc8a1.esm.js} +1 -1
  24. package/dist/{inTabFetch-75753a09.cjs.dev.js → inTabFetch-85b1aef4.cjs.dev.js} +1 -1
  25. package/dist/{proposalJsonEntries-2cd6f6fe.esm.js → jsonValuesModule-12fc4bb0.esm.js} +2 -128
  26. package/dist/{proposalJsonEntries-d21900d4.cjs.dev.js → jsonValuesModule-6cf73937.cjs.prod.js} +2 -130
  27. package/dist/{proposalJsonEntries-d4623810.cjs.prod.js → jsonValuesModule-ed68a9de.cjs.dev.js} +2 -130
  28. package/dist/merge-5a8fc685.cjs.prod.js +1596 -0
  29. package/dist/merge-a21a9c78.cjs.dev.js +1596 -0
  30. package/dist/merge-eca8ec38.esm.js +1566 -0
  31. package/dist/proposalJsonEntries-4fcfab08.cjs.prod.js +135 -0
  32. package/dist/proposalJsonEntries-878ad5b6.cjs.dev.js +135 -0
  33. package/dist/proposalJsonEntries-e1b07915.esm.js +128 -0
  34. package/dist/{publishKit-395b92e5.cjs.prod.js → publishKit-70276aed.cjs.prod.js} +19 -22
  35. package/dist/{publishKit-04b6d255.esm.js → publishKit-a732e3c3.esm.js} +11 -14
  36. package/dist/{publishKit-de4baed6.cjs.dev.js → publishKit-f7a77be5.cjs.dev.js} +19 -22
  37. package/dist/{valRuntime-7fd12e16.esm.js → valRuntime-407399c1.esm.js} +11 -982
  38. package/dist/{valRuntime-d3cc6e0d.cjs.dev.js → valRuntime-7a4bbb5d.cjs.dev.js} +21 -995
  39. package/dist/{valRuntime-e922e372.cjs.prod.js → valRuntime-8585d3ce.cjs.prod.js} +21 -995
  40. package/dist/valbuild-server.cjs.dev.js +45 -462
  41. package/dist/valbuild-server.cjs.prod.js +45 -462
  42. package/dist/valbuild-server.esm.js +15 -431
  43. package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +2 -2
  44. package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +2 -2
  45. package/internal/browser/dist/valbuild-server-internal-browser.esm.js +2 -2
  46. package/internal/dist/valbuild-server-internal.cjs.dev.js +20 -2
  47. package/internal/dist/valbuild-server-internal.cjs.prod.js +20 -2
  48. package/internal/dist/valbuild-server-internal.esm.js +20 -3
  49. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @valbuild/server
2
2
 
3
+ ## 0.156.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1106](https://github.com/valbuild/val/pull/1106) [`332c386`](https://github.com/valbuild/val/commit/332c386621f3aab44412307352319e176824160d) Thanks [@freekh](https://github.com/freekh)! - A site's pages no longer load the TypeScript compiler
8
+
9
+ `foldContent`, new in `@valbuild/server/internal`, was exported in a way that loaded the TypeScript compiler with that entry, which is also what a site's pages read their content through. It is now loaded only when it is called, so a page a visitor opens evaluates none of it again.
10
+
11
+ - [#1063](https://github.com/valbuild/val/pull/1063) [`27b87f6`](https://github.com/valbuild/val/commit/27b87f6fadb27ccb9d67c0a07ac560772d4e3ae4) Thanks [@freekh](https://github.com/freekh)! - `@valbuild/server/internal` exports `foldContent`, which writes each module's recorded content back into a project's `.val.ts` files (and a `.jsonValues()` record's `.val.json` entries) the way a save writes them, then checks that every module reads back exactly as recorded. It is what Val Build needs to connect a project it hosts to a repository. A content change Val cannot write into the code that builds it is refused by name.
12
+
13
+ Also: a merge whose content cannot be written into a file now says why, instead of `[object Object]`, and a project loaded for a merge whose `tsconfig.json` names its inputs by `include` glob now loads.
14
+
15
+ - Updated dependencies [[`3955b0e`](https://github.com/valbuild/val/commit/3955b0ec25a2c0759f8323efd88529e6867f17e2), [`0cf24ba`](https://github.com/valbuild/val/commit/0cf24ba78e5e0a86ed594b58ff7f7fb5e7fcc440), [`7c47276`](https://github.com/valbuild/val/commit/7c472766183a425ef022e84d341e666c48a6bc3b)]:
16
+ - @valbuild/shared@0.156.0
17
+ - @valbuild/ui@0.156.0
18
+
3
19
  ## 0.155.0
4
20
 
5
21
  ### Patch Changes
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var inTabFetch = require('../../dist/inTabFetch-75753a09.cjs.dev.js');
5
+ var inTabFetch = require('../../dist/inTabFetch-85b1aef4.cjs.dev.js');
6
6
  require('@valbuild/core');
7
- require('../../dist/ValOpsMemory-6e829758.cjs.dev.js');
7
+ require('../../dist/ValOpsMemory-3ce3e9e8.cjs.dev.js');
8
8
  require('zod');
9
9
  require('@valbuild/shared/internal');
10
10
  require('../../dist/jsonValuesPatch-88bc661d.cjs.dev.js');
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var inTabFetch = require('../../dist/inTabFetch-3d8ceb84.cjs.prod.js');
5
+ var inTabFetch = require('../../dist/inTabFetch-46ad6b87.cjs.prod.js');
6
6
  require('@valbuild/core');
7
- require('../../dist/ValOpsMemory-f000531b.cjs.prod.js');
7
+ require('../../dist/ValOpsMemory-073f9526.cjs.prod.js');
8
8
  require('zod');
9
9
  require('@valbuild/shared/internal');
10
10
  require('../../dist/jsonValuesPatch-92798812.cjs.prod.js');
@@ -1,6 +1,6 @@
1
- export { c as createInTabValFetch } from '../../dist/inTabFetch-dae5dd87.esm.js';
1
+ export { c as createInTabValFetch } from '../../dist/inTabFetch-6dacc8a1.esm.js';
2
2
  import '@valbuild/core';
3
- import '../../dist/ValOpsMemory-1a0bc2dc.esm.js';
3
+ import '../../dist/ValOpsMemory-ecc15827.esm.js';
4
4
  import 'zod';
5
5
  import '@valbuild/shared/internal';
6
6
  import '../../dist/jsonValuesPatch-13acc674.esm.js';
@@ -5124,7 +5124,7 @@ var packageJson = {
5124
5124
  ],
5125
5125
  exports: true
5126
5126
  },
5127
- version: "0.155.0",
5127
+ version: "0.156.0",
5128
5128
  scripts: {
5129
5129
  typecheck: "tsc --noEmit",
5130
5130
  test: "jest",
@@ -5124,7 +5124,7 @@ var packageJson = {
5124
5124
  ],
5125
5125
  exports: true
5126
5126
  },
5127
- version: "0.155.0",
5127
+ version: "0.156.0",
5128
5128
  scripts: {
5129
5129
  typecheck: "tsc --noEmit",
5130
5130
  test: "jest",
@@ -5118,7 +5118,7 @@ var packageJson = {
5118
5118
  ],
5119
5119
  exports: true
5120
5120
  },
5121
- version: "0.155.0",
5121
+ version: "0.156.0",
5122
5122
  scripts: {
5123
5123
  typecheck: "tsc --noEmit",
5124
5124
  test: "jest",
@@ -415,7 +415,7 @@ async function readerSnapshot(proposal, projectSource) {
415
415
  }
416
416
  const {
417
417
  proposalSnapshotForReaders
418
- } = await Promise.resolve().then(function () { return require('./proposalJsonEntries-d21900d4.cjs.dev.js'); }).then(function (n) { return n.proposalJsonEntries$1; });
418
+ } = await Promise.resolve().then(function () { return require('./proposalJsonEntries-4fcfab08.cjs.prod.js'); });
419
419
  return proposalSnapshotForReaders(proposal, projectSource);
420
420
  }
421
421
 
@@ -415,7 +415,7 @@ async function readerSnapshot(proposal, projectSource) {
415
415
  }
416
416
  const {
417
417
  proposalSnapshotForReaders
418
- } = await Promise.resolve().then(function () { return require('./proposalJsonEntries-d4623810.cjs.prod.js'); }).then(function (n) { return n.proposalJsonEntries$1; });
418
+ } = await Promise.resolve().then(function () { return require('./proposalJsonEntries-878ad5b6.cjs.dev.js'); });
419
419
  return proposalSnapshotForReaders(proposal, projectSource);
420
420
  }
421
421
 
@@ -409,7 +409,7 @@ async function readerSnapshot(proposal, projectSource) {
409
409
  }
410
410
  const {
411
411
  proposalSnapshotForReaders
412
- } = await import('./proposalJsonEntries-2cd6f6fe.esm.js').then(function (n) { return n.l; });
412
+ } = await import('./proposalJsonEntries-e1b07915.esm.js');
413
413
  return proposalSnapshotForReaders(proposal, projectSource);
414
414
  }
415
415
 
@@ -1,6 +1,6 @@
1
- import { i as initHandlerOptions, v as valRuntime } from './valRuntime-7fd12e16.esm.js';
1
+ import { i as initHandlerOptions, v as valRuntime } from './valRuntime-407399c1.esm.js';
2
2
  import '@valbuild/core';
3
- import './ValOpsMemory-1a0bc2dc.esm.js';
3
+ import './ValOpsMemory-ecc15827.esm.js';
4
4
  import 'zod';
5
5
  import '@valbuild/shared/internal';
6
6
  import './jsonValuesPatch-13acc674.esm.js';
@@ -12,11 +12,13 @@ import 'image-size';
12
12
  import 'path';
13
13
  import 'typescript';
14
14
  import 'fs';
15
- import './proposalJsonEntries-2cd6f6fe.esm.js';
16
- import './createPrettierFormatter-ce478de1.esm.js';
15
+ import './jsonValuesModule-12fc4bb0.esm.js';
17
16
  import 'os';
18
17
  import 'crypto';
19
18
  import 'buffer';
19
+ import './proposalJsonEntries-e1b07915.esm.js';
20
+ import './createPrettierFormatter-fb68e363.esm.js';
21
+ import './merge-eca8ec38.esm.js';
20
22
  import 'node:vm';
21
23
  import 'node:module';
22
24
 
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var valRuntime = require('./valRuntime-e922e372.cjs.prod.js');
3
+ var valRuntime = require('./valRuntime-8585d3ce.cjs.prod.js');
4
4
  require('@valbuild/core');
5
- require('./ValOpsMemory-f000531b.cjs.prod.js');
5
+ require('./ValOpsMemory-073f9526.cjs.prod.js');
6
6
  require('zod');
7
7
  require('@valbuild/shared/internal');
8
8
  require('./jsonValuesPatch-92798812.cjs.prod.js');
@@ -14,11 +14,13 @@ require('image-size');
14
14
  require('path');
15
15
  require('typescript');
16
16
  require('fs');
17
- require('./proposalJsonEntries-d4623810.cjs.prod.js');
18
- require('./createPrettierFormatter-b31bfbe5.cjs.prod.js');
17
+ require('./jsonValuesModule-6cf73937.cjs.prod.js');
19
18
  require('os');
20
19
  require('crypto');
21
20
  require('buffer');
21
+ require('./proposalJsonEntries-4fcfab08.cjs.prod.js');
22
+ require('./createPrettierFormatter-8e60f596.cjs.prod.js');
23
+ require('./merge-5a8fc685.cjs.prod.js');
22
24
  require('node:vm');
23
25
  require('node:module');
24
26
 
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var valRuntime = require('./valRuntime-d3cc6e0d.cjs.dev.js');
3
+ var valRuntime = require('./valRuntime-7a4bbb5d.cjs.dev.js');
4
4
  require('@valbuild/core');
5
- require('./ValOpsMemory-6e829758.cjs.dev.js');
5
+ require('./ValOpsMemory-3ce3e9e8.cjs.dev.js');
6
6
  require('zod');
7
7
  require('@valbuild/shared/internal');
8
8
  require('./jsonValuesPatch-88bc661d.cjs.dev.js');
@@ -14,11 +14,13 @@ require('image-size');
14
14
  require('path');
15
15
  require('typescript');
16
16
  require('fs');
17
- require('./proposalJsonEntries-d21900d4.cjs.dev.js');
18
- require('./createPrettierFormatter-5d830bdf.cjs.dev.js');
17
+ require('./jsonValuesModule-ed68a9de.cjs.dev.js');
19
18
  require('os');
20
19
  require('crypto');
21
20
  require('buffer');
21
+ require('./proposalJsonEntries-878ad5b6.cjs.dev.js');
22
+ require('./createPrettierFormatter-a9109288.cjs.dev.js');
23
+ require('./merge-a21a9c78.cjs.dev.js');
22
24
  require('node:vm');
23
25
  require('node:module');
24
26
 
@@ -35,3 +35,17 @@ export { serverCanStartLazily } from "../serverMode.js";
35
35
  export { InMemoryPatchStore, type StoredFile, type StoredPatch, type ValPatchStore, } from "../ValPatchStore.js";
36
36
  export { createPrettierFormatter, type PrettierLike, type PrettierLoader, type ValFormatter, } from "../createPrettierFormatter.js";
37
37
  export { ValHead, headWork, HEAD_BUDGET_BYTES, HEAD_VERSIONS_PER_MODULE, type Draft, type HeadChain, type HeadEntries, type HeadModule, type HeadTree, type ModuleAnswer, } from "../head.js";
38
+ export type { FoldResult, FoldRefusal } from "../proposalMerge/foldContent.js";
39
+ export type { Files as ProjectFiles } from "../proposalMerge/project.js";
40
+ /**
41
+ * Content written back into a project's files, for connecting a project Val
42
+ * Build hosts to a repository (valbuild/home,
43
+ * docs/plans/connect-with-history.md, phase 6a). See
44
+ * `proposalMerge/foldContent.ts`.
45
+ *
46
+ * Loaded when it is called, never with this entry: it brings the TypeScript
47
+ * compiler, and this entry is also what a site's page reads content through,
48
+ * which must evaluate none of it (`servingPath.test.ts` in
49
+ * `@valbuild/tanstack`).
50
+ */
51
+ export declare function foldContent(...args: Parameters<typeof import("../proposalMerge/foldContent.js").foldContent>): ReturnType<typeof import("../proposalMerge/foldContent.js").foldContent>;
@@ -0,0 +1,45 @@
1
+ import type { ModuleFilePath } from "@valbuild/core";
2
+ import type { JSONValue } from "@valbuild/core/patch";
3
+ import { type Files } from "./project.js";
4
+ /**
5
+ * Content written back into a project's files: each module's content as it is
6
+ * recorded, written into its `.val.ts` (and a `.jsonValues()` record's
7
+ * `.val.json` entries) the way a save writes them.
8
+ *
9
+ * What connecting a project that has history needs (valbuild/home,
10
+ * `docs/plans/connect-with-history.md`, phase 6a). A project Val Build hosts
11
+ * keeps its content as each module's Source, never as file text: its
12
+ * `.val.ts` files still hold what the project was made with. Before its code
13
+ * can go into a repository, the content has to be in the files.
14
+ *
15
+ * The same writer a merge uses (`writeContent`, `writeEntries`): the smallest
16
+ * patch, through the AST operations a save uses, so the code around the
17
+ * content -- imports, comments, formatting, the schema -- is left exactly as
18
+ * it was. Then the project is loaded again, and every module must read back
19
+ * as exactly what was recorded, key order too. A module whose targeted write
20
+ * does not read back is written whole; one that still does not -- content its
21
+ * code computes rather than holds, say -- is refused by name. Nothing is
22
+ * guessed.
23
+ */
24
+ export type FoldRefusal = {
25
+ /** The module, or `null` when the written project as a whole would not load. */
26
+ module: ModuleFilePath | null;
27
+ /** Why, in a developer's words. */
28
+ reason: string;
29
+ };
30
+ export type FoldResult = {
31
+ status: "folded";
32
+ /** The whole project, with the content written in. */
33
+ files: Files;
34
+ /** The files that changed, by path; a removed `.val.json` entry too. */
35
+ changed: string[];
36
+ } | {
37
+ status: "refused";
38
+ refusals: FoldRefusal[];
39
+ };
40
+ export declare function foldContent(input: {
41
+ /** The project's files: its code, as the live build has it. */
42
+ files: Files;
43
+ /** Each module's content as recorded. A module left out is not touched. */
44
+ content: Record<ModuleFilePath, JSONValue>;
45
+ }): Promise<FoldResult>;
@@ -0,0 +1,124 @@
1
+ import { type ModuleFilePath, type SerializedSchema, type ValModule } from "@valbuild/core";
2
+ import { type JSONValue } from "@valbuild/core/patch";
3
+ import { loadValModules } from "../loadValModules.js";
4
+ import type { Value } from "./threeWay.js";
5
+ import { type SchemaError } from "./validate.js";
6
+ /**
7
+ * A project as git holds it: every file's text, by path from the project
8
+ * root. A commit in the world is one of these -- `.val.ts` files, the
9
+ * components that render them, `val.modules.ts` -- and nothing else, the same
10
+ * way a commit on content's line is.
11
+ */
12
+ export type Files = Record<string, string | null>;
13
+ /**
14
+ * A module, as the merge needs it: data, so whoever evaluated the project's
15
+ * schemas can hand it over -- Val's loader here and in `val validate`, the
16
+ * builder tab with rolldown -- and the merge itself never runs project code.
17
+ */
18
+ export type ProjectModule = {
19
+ /**
20
+ * Its content, as the files hold it -- a `.jsonValues()` record's entries
21
+ * read from their `.val.json` files, so it is merged and validated as one
22
+ * record.
23
+ */
24
+ source: JSONValue;
25
+ /**
26
+ * The content its file's text holds, when that is not `source`: a build's
27
+ * `.val.ts` keeps the content of when it was built, while `source` is
28
+ * content's index. The merge is written into the text from this. Absent:
29
+ * the text holds `source`.
30
+ */
31
+ written?: JSONValue;
32
+ schema: SerializedSchema;
33
+ /**
34
+ * For a `.jsonValues()` record: each entry's file, by key, from the project
35
+ * root. `null` for any other module.
36
+ */
37
+ entries: Record<string, string> | null;
38
+ /**
39
+ * The evaluated schema's own validation, custom rules too. Without it, the
40
+ * serialized schema's rules are used (`validateModule`).
41
+ */
42
+ validate?: (source: Value) => SchemaError[];
43
+ /**
44
+ * The errors of `source` under this schema, where they were found where the
45
+ * schema was evaluated (the builder tab) and only the result crossed over.
46
+ * What the schema check reads first.
47
+ */
48
+ errors?: SchemaError[];
49
+ };
50
+ /** A project at one commit: its files, and its modules as data. */
51
+ export type Project = {
52
+ files: Files;
53
+ modules: Record<ModuleFilePath, ProjectModule>;
54
+ };
55
+ /** A loaded project, as the merge takes it. */
56
+ export declare function projectOf(files: Files, loaded: LoadedProject): Project;
57
+ /** A module as the project defines it, read by Val's own loader. */
58
+ export type LoadedModule = {
59
+ module: ValModule<any>;
60
+ /**
61
+ * Its content, as the files hold it -- a `.jsonValues()` record's entries
62
+ * read from their `.val.json` files, so it can be merged and validated as
63
+ * one record.
64
+ */
65
+ source: JSONValue;
66
+ /**
67
+ * For a `.jsonValues()` record: each entry's file, by key, from the project
68
+ * root. `null` for any other module.
69
+ */
70
+ entries: Record<string, string> | null;
71
+ };
72
+ export type LoadedProject = {
73
+ valModules: ReturnType<typeof loadValModules>;
74
+ modules: Record<ModuleFilePath, LoadedModule>;
75
+ /** The `.val.ts` files and `.jsonValues()` entries, as `ValOpsMemory` takes them. */
76
+ sourceFiles: Record<string, string>;
77
+ };
78
+ /**
79
+ * Loads the project at a commit the way `val validate` does: `val.modules.ts`
80
+ * and every `.val.ts` it imports, transpiled and evaluated
81
+ * (`loadValModules`). So a schema a proposal changed is the schema it changed
82
+ * to, read from the text it wrote.
83
+ */
84
+ export declare function loadProject(files: Files): Promise<LoadedProject>;
85
+ /**
86
+ * A `.jsonValues()` record's entry files, by key, read out of its `.val.ts`
87
+ * (the loaded marker does not carry the path). `null` when it has none.
88
+ */
89
+ export declare function entryFilesOf(moduleFilePath: ModuleFilePath, text: string): Record<string, string> | null;
90
+ /** Every project's first two files, as `npm create @valbuild` writes them. */
91
+ export declare function scaffold(moduleFiles: string[]): Files;
92
+ /** `val.modules.ts` naming these modules: what adding a page changes. */
93
+ export declare function valModulesFile(moduleFiles: string[]): string;
94
+ /**
95
+ * A `.val.ts` file: `c.define` with a schema written as code and its content.
96
+ * The text is the file; a proposal that changes the schema writes another
97
+ * one.
98
+ */
99
+ export declare function valFile(file: string, schema: string, content: unknown): string;
100
+ /** A page of the world: its `.val.ts`, as the site starts with it. */
101
+ export type Page = {
102
+ file: string;
103
+ moduleFilePath: ModuleFilePath;
104
+ text: string;
105
+ /** Files the page's content lives in besides its `.val.ts`: `.jsonValues()` entries. */
106
+ files: Files;
107
+ /** The same file with another schema: what a proposal stages to change it. */
108
+ withSchema(schema: string, content: unknown): string;
109
+ };
110
+ export declare function page(file: string, schema: string, content: unknown): Page;
111
+ /**
112
+ * A `.jsonValues()` record: each entry in a `.val.json` of its own, next to the
113
+ * module in a directory named after it, as the Studio writes new ones.
114
+ */
115
+ export declare function jsonValuesPage(file: string, itemSchema: string, entries: Record<string, unknown>): Page;
116
+ /**
117
+ * A file's code: for a `.val.ts`, everything but `c.define`'s content
118
+ * argument, which Val reads at request time (step 2) and so is no part of a
119
+ * build; a `.val.json` entry is no code at all. Every other file is code
120
+ * whole.
121
+ */
122
+ export declare function codeOf(file: string, text: string): string;
123
+ /** A build's name: the hash of the code it is made of (step 3). */
124
+ export declare function buildName(files: Files): string;
@@ -0,0 +1,51 @@
1
+ import { type JSONValue, type Operation } from "@valbuild/core/patch";
2
+ /**
3
+ * The three-way merge of a module's content: where both sides started
4
+ * (`base`), and each side's version. Pure JSON -- the schema decides nothing
5
+ * here, and is checked afterwards (the schema check in `merge.ts`).
6
+ *
7
+ * The rules (valbuild/home `docs/hosted-publishing.md` step 8.2):
8
+ *
9
+ * - Changed on one side: that side's.
10
+ * - Changed on both: a conflict -- even to the same value, which is an easy
11
+ * conflict to resolve but still one somebody decides.
12
+ * - An object (a page, a record) merges key by key, so two keys changed on
13
+ * two sides combine.
14
+ * - A list merges item by item only when neither side changed its shape: no
15
+ * item added, removed or moved. Otherwise positions mean different items on
16
+ * the two sides, and the whole list is the conflict.
17
+ */
18
+ export type Value = JSONValue | undefined;
19
+ export type ValueConflict = {
20
+ path: string[];
21
+ base: Value;
22
+ site: Value;
23
+ proposal: Value;
24
+ };
25
+ export type Merged = {
26
+ /**
27
+ * Both sides combined. At a conflict it holds the site's value, until a
28
+ * resolution replaces it.
29
+ */
30
+ value: Value;
31
+ conflicts: ValueConflict[];
32
+ };
33
+ /**
34
+ * Did this side add, remove or move an item? Lengths differ, or an item now
35
+ * sits where it was not, while it is still what used to be somewhere else.
36
+ */
37
+ export declare function reshaped(base: JSONValue[], side: JSONValue[]): boolean;
38
+ /**
39
+ * Where a value is one value, though it is an object: a media value (its path
40
+ * and what describes that file) or rich text. The schema says; see `merge.ts`.
41
+ */
42
+ export type IsAtomic = (path: string[]) => boolean;
43
+ export declare function mergeValues(base: Value, site: Value, proposal: Value, atomic?: IsAtomic, path?: string[]): Merged;
44
+ /** `doc` with `value` at `path`; `undefined` removes it. `doc` is not changed. */
45
+ export declare function setAt(doc: Value, path: string[], value: Value): Value;
46
+ export declare function valueAt(doc: Value, path: string[]): Value;
47
+ /**
48
+ * The Val patch that turns `from` into `to`, as small as it can be: what
49
+ * writes a merge into a `.val.ts` without rewriting what did not change.
50
+ */
51
+ export declare function diffOps(from: Value, to: Value, path?: string[]): Operation[];
@@ -0,0 +1,16 @@
1
+ import { type ModuleFilePath, type Schema, type SelectorSource } from "@valbuild/core";
2
+ import { type SchemaError } from "@valbuild/shared/internal";
3
+ import type { ProjectModule } from "./project.js";
4
+ import type { Value } from "./threeWay.js";
5
+ export type { SchemaError } from "@valbuild/shared/internal";
6
+ /** What a schema reports about this content: see `schemaErrorsOf`. */
7
+ export declare const validateWith: (schema: Schema<SelectorSource>, moduleFilePath: ModuleFilePath, source: Value) => SchemaError[];
8
+ /**
9
+ * A module's errors for this content: its own `validate` where the schema was
10
+ * evaluated, custom rules and all; otherwise what its serialized schema says,
11
+ * which is every rule but a custom `.validate(...)` (a closure does not
12
+ * serialize).
13
+ */
14
+ export declare function validateModule(moduleFilePath: ModuleFilePath, module: ProjectModule, source: Value): SchemaError[];
15
+ /** The errors of a module's own Source: as evaluated where they were, else found here. */
16
+ export declare function errorsOfSource(moduleFilePath: ModuleFilePath, module: ProjectModule): SchemaError[];