@valbuild/core 0.103.0 → 0.105.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.
Files changed (31) hide show
  1. package/dist/declarations/src/extractValModules.d.ts +54 -0
  2. package/dist/declarations/src/index.d.ts +3 -2
  3. package/dist/declarations/src/preview.d.ts +98 -0
  4. package/dist/declarations/src/render.d.ts +29 -91
  5. package/dist/declarations/src/schema/array.d.ts +22 -23
  6. package/dist/declarations/src/schema/boolean.d.ts +2 -2
  7. package/dist/declarations/src/schema/color.d.ts +2 -2
  8. package/dist/declarations/src/schema/date.d.ts +2 -2
  9. package/dist/declarations/src/schema/datetime.d.ts +2 -2
  10. package/dist/declarations/src/schema/file.d.ts +2 -2
  11. package/dist/declarations/src/schema/image.d.ts +2 -2
  12. package/dist/declarations/src/schema/index.d.ts +6 -6
  13. package/dist/declarations/src/schema/keyOf.d.ts +2 -2
  14. package/dist/declarations/src/schema/literal.d.ts +2 -2
  15. package/dist/declarations/src/schema/number.d.ts +2 -2
  16. package/dist/declarations/src/schema/object.d.ts +2 -2
  17. package/dist/declarations/src/schema/record.d.ts +19 -29
  18. package/dist/declarations/src/schema/richtext.d.ts +2 -2
  19. package/dist/declarations/src/schema/route.d.ts +2 -2
  20. package/dist/declarations/src/schema/string.d.ts +28 -17
  21. package/dist/declarations/src/schema/union.d.ts +2 -2
  22. package/dist/{index-267a8e9c.esm.js → index-005f51a5.esm.js} +277 -177
  23. package/dist/{index-3572060f.cjs.prod.js → index-4013c9f8.cjs.prod.js} +279 -177
  24. package/dist/{index-2e40f2ae.cjs.dev.js → index-baa3109b.cjs.dev.js} +279 -177
  25. package/dist/valbuild-core.cjs.dev.js +4 -2
  26. package/dist/valbuild-core.cjs.prod.js +4 -2
  27. package/dist/valbuild-core.esm.js +1 -1
  28. package/package.json +1 -1
  29. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  30. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  31. package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -1,8 +1,7 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
- import { RenderSelector, ReifiedRender, RenderScope } from "../render.js";
2
+ import { PreviewItem, PreviewSelector, ReifiedPreview, PreviewScope } from "../preview.js";
3
3
  import { ValRouter } from "../router.js";
4
4
  import { SelectorSource } from "../selector/index.js";
5
- import { ImageSource } from "../source/media.js";
6
5
  import { JsonOf, JsonSource } from "../source/json.js";
7
6
  import { ModuleFilePath, SourcePath } from "../val/index.js";
8
7
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
@@ -18,8 +17,8 @@ export type SerializedRecordSchema = {
18
17
  item: SerializedSchema;
19
18
  key?: SerializedSchema;
20
19
  opt: boolean;
21
- /** Set when this schema declares a `render`. See `SerializedArraySchema`. */
22
- render?: true;
20
+ /** Set when this schema declares a `preview`. See `SerializedArraySchema`. */
21
+ preview?: true;
23
22
  router?: string;
24
23
  customValidate?: boolean;
25
24
  mediaType?: "files" | "images";
@@ -46,17 +45,10 @@ export type SerializedRecordSchema = {
46
45
  * authoring.
47
46
  */
48
47
  export type JsonValuesRecordSrc<T extends Schema<SelectorSource>, K extends Schema<string>> = Record<SelectorOfSchema<K>, JsonSource<JsonOf<SelectorOfSchema<T>>> | SelectorOfSchema<T>>;
49
- type RecordRenderInput<T extends Schema<SelectorSource>> = {
50
- layout: "list";
51
- select: (input: {
52
- key: string;
53
- val: RenderSelector<T>;
54
- }) => {
55
- title: string;
56
- subtitle?: string | null;
57
- image?: ImageSource | null;
58
- };
59
- };
48
+ type RecordPreviewInput<T extends Schema<SelectorSource>> = (input: {
49
+ key: string;
50
+ val: PreviewSelector<T>;
51
+ }) => PreviewItem;
60
52
  export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Schema<string>, Src extends Record<SelectorOfSchema<K>, SelectorOfSchema<T>> | JsonValuesRecordSrc<T, K> | null> extends Schema<Src> {
61
53
  private readonly item;
62
54
  private readonly opt;
@@ -69,10 +61,10 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Sc
69
61
  private readonly description?;
70
62
  /** When true, entry values are lazily loaded {@link JsonSource} thunks. */
71
63
  private readonly isJsonValues;
72
- private readonly renderInput;
64
+ private readonly previewInput;
73
65
  constructor(item: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], currentRouter?: ValRouter | null, keySchema?: Schema<string> | null, mediaOptions?: MediaOptions | undefined, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
74
66
  /** When true, entry values are lazily loaded {@link JsonSource} thunks. */
75
- isJsonValues?: boolean, renderInput?: RecordRenderInput<T> | null);
67
+ isJsonValues?: boolean, previewInput?: RecordPreviewInput<T> | null);
76
68
  describe(description: string | null): RecordSchema<T, K, Src>;
77
69
  validate(validationFunction: (src: Src) => false | string): RecordSchema<T, K, Src>;
78
70
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -113,18 +105,16 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Sc
113
105
  * defers).
114
106
  */
115
107
  validateJsonEntryContent(path: SourcePath, content: SelectorSource): ValidationErrors;
116
- protected executeRender(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: RenderScope): ReifiedRender;
117
- render(input: {
118
- as: "list";
119
- select: (input: {
120
- key: string;
121
- val: RenderSelector<T>;
122
- }) => {
123
- title: string;
124
- subtitle?: string | null;
125
- image?: ImageSource | null;
126
- };
127
- }): RecordSchema<T, K, Src>;
108
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
109
+ /**
110
+ * What the editor shows for each ENTRY of this record: a title, and optionally
111
+ * a subtitle and an image.
112
+ *
113
+ * `select` is your own code over the entry's key and source, so it is run on
114
+ * demand for the entries that are actually being looked at — see
115
+ * `PreviewScope`.
116
+ */
117
+ preview(select: RecordPreviewInput<T>): RecordSchema<T, K, Src>;
128
118
  }
129
119
  export declare function record<K extends Schema<string>, S extends Schema<SelectorSource>>(key: K, schema: S): RecordSchema<S, K, Record<SelectorOfSchema<K>, SelectorOfSchema<S>>>;
130
120
  export declare function record<S extends Schema<SelectorSource>>(schema: S): RecordSchema<S, Schema<string>, Record<string, SelectorOfSchema<S>>>;
@@ -1,5 +1,5 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedRender } from "../render.js";
2
+ import { ReifiedPreview } from "../preview.js";
3
3
  import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
4
4
  import { SourcePath } from "../val/index.js";
5
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
@@ -37,7 +37,7 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
37
37
  hidden(): RichTextSchema<O, Src>;
38
38
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
39
39
  protected executeSerialize(): SerializedSchema;
40
- protected executeRender(): ReifiedRender;
40
+ protected executePreview(): ReifiedPreview;
41
41
  }
42
42
  export declare const richtext: <O extends RichTextOptions>(options?: O) => RichTextSchema<O, RichTextSource<O>>;
43
43
  export {};
@@ -1,6 +1,6 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
- import { ReifiedRender } from "../render.js";
3
+ import { ReifiedPreview } from "../preview.js";
4
4
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
5
5
  type RouteOptions = {
6
6
  include?: RegExp;
@@ -68,7 +68,7 @@ export declare class RouteSchema<Src extends string | null> extends Schema<Src>
68
68
  hidden(): RouteSchema<Src>;
69
69
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
70
70
  protected executeSerialize(): SerializedSchema;
71
- protected executeRender(): ReifiedRender;
71
+ protected executePreview(): ReifiedPreview;
72
72
  }
73
73
  export declare const route: <T extends string>(options?: Record<string, never>) => RouteSchema<T>;
74
74
  export {};
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { CodeLanguage, ReifiedRender, RenderScope } from "../render.js";
3
- import { ModuleFilePath, SourcePath } from "../val/index.js";
2
+ import { ReifiedPreview } from "../preview.js";
3
+ import { StringRender } from "../render.js";
4
+ import { SourcePath } from "../val/index.js";
4
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
5
6
  type StringOptions = {
6
7
  maxLength?: number;
@@ -10,8 +11,16 @@ type StringOptions = {
10
11
  };
11
12
  export type SerializedStringSchema = {
12
13
  type: "string";
13
- /** Set when this schema declares a `render`. See `SerializedArraySchema`. */
14
- render?: true;
14
+ /**
15
+ * How this field is laid out in the editor, carried WHOLE rather than as a
16
+ * marker.
17
+ *
18
+ * A render is static configuration — no closure, no dependency on source — so
19
+ * unlike a `preview` it serializes in full, and the editor reads it straight
20
+ * off the schema it already has. See `render.ts` for what that assumption
21
+ * buys, and what to do if a render ever needs to stop being static.
22
+ */
23
+ render?: StringRender;
15
24
  options?: {
16
25
  maxLength?: number;
17
26
  minLength?: number;
@@ -42,12 +51,7 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
42
51
  private readonly isReadonly;
43
52
  private readonly isHidden;
44
53
  private readonly description?;
45
- constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], renderInput?: {
46
- as: "textarea";
47
- } | {
48
- as: "code";
49
- language: CodeLanguage;
50
- } | null, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
54
+ constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], renderInput?: StringRender | null, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
51
55
  describe(description: string | null): StringSchema<Src>;
52
56
  /**
53
57
  * @deprecated Use `minLength` instead
@@ -69,13 +73,20 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
69
73
  raw(): StringSchema<Src extends null ? RawString | null : RawString>;
70
74
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
71
75
  protected executeSerialize(): SerializedSchema;
72
- render(input: {
73
- as: "textarea";
74
- } | {
75
- as: "code";
76
- language: CodeLanguage;
77
- }): StringSchema<Src>;
78
- protected executeRender(sourcePath: SourcePath | ModuleFilePath, src: Src, _scope?: RenderScope): ReifiedRender;
76
+ /**
77
+ * How this field is laid out in the editor: a textarea, or a code editor for
78
+ * the given language.
79
+ *
80
+ * Static configuration, not a callback — see `render.ts`. What a CONTAINER
81
+ * shows for its items is a `preview`, which is a different thing entirely.
82
+ */
83
+ render(input: StringRender): StringSchema<Src>;
84
+ /**
85
+ * Nothing: a string has no items, so there is nothing to preview. Its layout
86
+ * is a `render`, which travels in the serialized schema instead of through
87
+ * this pipeline.
88
+ */
89
+ protected executePreview(): ReifiedPreview;
79
90
  }
80
91
  export declare const string: <T extends string>(options?: Record<string, never>) => StringSchema<T>;
81
92
  export {};
@@ -1,5 +1,5 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedRender, RenderScope } from "../render.js";
2
+ import { ReifiedPreview, PreviewScope } from "../preview.js";
3
3
  import { SelectorSource } from "../selector/index.js";
4
4
  import { SourceObject } from "../source/index.js";
5
5
  import { ModuleFilePath, SourcePath } from "../val/index.js";
@@ -57,7 +57,7 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
57
57
  private matchedVariant;
58
58
  protected executeSerialize(): SerializedSchema;
59
59
  constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
60
- protected executeRender(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: RenderScope): ReifiedRender;
60
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
61
61
  }
62
62
  export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => UnionSchema<Key, T, SourceOf<Key, T>>;
63
63
  export {};