@valbuild/core 0.44.0 → 0.45.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/dist/declarations/src/index.d.ts +3 -4
- package/dist/declarations/src/initSchema.d.ts +1 -1
- package/dist/declarations/src/module.d.ts +3 -1
- package/dist/declarations/src/schema/file.d.ts +10 -0
- package/dist/declarations/src/schema/image.d.ts +11 -7
- package/dist/declarations/src/selector/file.d.ts +6 -2
- package/dist/declarations/src/selector/image.d.ts +3 -0
- package/dist/declarations/src/selector/index.d.ts +3 -1
- package/dist/declarations/src/source/file.d.ts +8 -9
- package/dist/declarations/src/source/image.d.ts +7 -0
- package/dist/declarations/src/source/richtext.d.ts +4 -4
- package/dist/{index-6deb169d.cjs.dev.js → index-00276955.cjs.dev.js} +1 -1
- package/dist/{index-c83918b8.esm.js → index-5750c299.esm.js} +3 -81
- package/dist/{index-4f821892.esm.js → index-799bcf49.esm.js} +1 -1
- package/dist/{index-5bdaa229.cjs.prod.js → index-7b467ee6.cjs.prod.js} +2 -82
- package/dist/{index-a5295001.cjs.dev.js → index-d23e237a.cjs.dev.js} +2 -82
- package/dist/{index-216627d7.cjs.prod.js → index-db60fc1d.cjs.prod.js} +1 -1
- package/dist/{ops-899d8bef.esm.js → ops-117cb796.esm.js} +81 -2
- package/dist/{ops-5bd1bd7a.cjs.prod.js → ops-18aded72.cjs.prod.js} +82 -2
- package/dist/{ops-422169e5.cjs.dev.js → ops-453cddfc.cjs.dev.js} +82 -2
- package/dist/valbuild-core.cjs.dev.js +4 -4
- package/dist/valbuild-core.cjs.prod.js +4 -4
- package/dist/valbuild-core.esm.js +4 -4
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -2
- package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -2
- package/patch/dist/valbuild-core-patch.esm.js +3 -3
@@ -7,6 +7,7 @@ export type { ValModule, SerializedModule, InferValModuleType } from "./module.j
|
|
7
7
|
export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
|
8
8
|
export type { FileSource } from "./source/file.js";
|
9
9
|
export type { RawString } from "./schema/string.js";
|
10
|
+
export type { ImageSource } from "./source/image.js";
|
10
11
|
export type { AnyRichTextOptions, Bold, Classes, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichText, RichTextNode, RichTextOptions, RichTextSource, RootNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
|
11
12
|
export { type Val, type SerializedVal, type ModuleId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
|
12
13
|
export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
|
@@ -21,6 +22,7 @@ export { type SelectorSource, type SelectorOf, GenericSelector, } from "./select
|
|
21
22
|
import { getSource, resolvePath, splitModuleIdAndModulePath } from "./module.js";
|
22
23
|
import { getSchema } from "./selector/index.js";
|
23
24
|
import { ModuleId, ModulePath, getValPath, isVal } from "./val/index.js";
|
25
|
+
import { convertFileSource } from "./schema/file.js";
|
24
26
|
import { createValPathOfItem } from "./selector/SelectorProxy.js";
|
25
27
|
import { getVal } from "./future/fetchVal.js";
|
26
28
|
import type { Json } from "./Json.js";
|
@@ -80,10 +82,7 @@ export type ApiGetPatchResponse = Record<ModuleId, {
|
|
80
82
|
}[]>;
|
81
83
|
export type ApiPostPatchResponse = Record<ModuleId, string[]>;
|
82
84
|
declare const Internal: {
|
83
|
-
convertFileSource:
|
84
|
-
url: string;
|
85
|
-
metadata?: import("./schema/image.js").ImageMetadata;
|
86
|
-
};
|
85
|
+
convertFileSource: typeof convertFileSource;
|
87
86
|
getSchema: typeof getSchema;
|
88
87
|
getValPath: typeof getValPath;
|
89
88
|
getVal: typeof getVal;
|
@@ -48,7 +48,7 @@ export declare function initSchema(): {
|
|
48
48
|
valPath?: undefined;
|
49
49
|
} & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T_1) => import("./schema/index.js").Schema<T_1 extends import("./schema/index.js").Schema<infer S_1 extends import("./selector/index.js").SelectorSource>[] ? S_1 extends import("./selector/index.js").SelectorSource ? S_1 | (Key extends import("./schema/index.js").Schema<infer K extends import("./selector/index.js").SelectorSource> ? K : never) : never : never>;
|
50
50
|
richtext: <O extends import("./index.js").RichTextOptions>(options?: O | undefined) => import("./schema/index.js").Schema<import("./index.js").RichTextSource<O>>;
|
51
|
-
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").
|
51
|
+
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").ImageSource>;
|
52
52
|
literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
|
53
53
|
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly any[] ? number : S_2 extends import("./source/index.js").SourceObject ? keyof S_2 : S_2 extends Record<string, any> ? string : never : never>;
|
54
54
|
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
@@ -4,13 +4,15 @@ import { Source } from "./source/index.js";
|
|
4
4
|
import { ModuleId, ModulePath, SourcePath } from "./val/index.js";
|
5
5
|
import { Json } from "./Json.js";
|
6
6
|
import { RawString } from "./schema/string.js";
|
7
|
+
import { ImageSelector } from "./selector/image.js";
|
8
|
+
import { ImageSource } from "./source/image.js";
|
7
9
|
declare const brand: unique symbol;
|
8
10
|
export type ValModule<T extends SelectorSource> = SelectorOf<T> & ValModuleBrand;
|
9
11
|
export type ValModuleBrand = {
|
10
12
|
[brand]: "ValModule";
|
11
13
|
};
|
12
14
|
export type InferValModuleType<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
|
13
|
-
type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends {
|
15
|
+
type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends ImageSelector ? ImageSource : T extends {
|
14
16
|
[key in string]: SelectorSource;
|
15
17
|
} ? {
|
16
18
|
[key in keyof T]: ReplaceRawStringWithString<T[key]>;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Json } from "../Json.js";
|
2
|
+
import { FileSource } from "../source/file.js";
|
3
|
+
export declare function convertFileSource<Metadata extends {
|
4
|
+
readonly [key: string]: Json;
|
5
|
+
} | undefined = {
|
6
|
+
readonly [key: string]: Json;
|
7
|
+
} | undefined>(src: FileSource<Metadata>): {
|
8
|
+
url: string;
|
9
|
+
metadata?: Metadata;
|
10
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Schema, SerializedSchema } from "./index.js";
|
2
2
|
import { FileSource } from "../source/file.js";
|
3
|
+
import { ImageSource } from "../source/image.js";
|
3
4
|
import { SourcePath } from "../val/index.js";
|
4
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
5
6
|
export type ImageOptions = {
|
@@ -16,8 +17,15 @@ export type ImageMetadata = {
|
|
16
17
|
width: number;
|
17
18
|
height: number;
|
18
19
|
sha256: string;
|
19
|
-
|
20
|
-
|
20
|
+
mimeType: string;
|
21
|
+
hotspot?: {
|
22
|
+
x: number;
|
23
|
+
y: number;
|
24
|
+
height: number;
|
25
|
+
width: number;
|
26
|
+
};
|
27
|
+
};
|
28
|
+
export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefined> | null> extends Schema<Src> {
|
21
29
|
readonly options?: ImageOptions | undefined;
|
22
30
|
readonly opt: boolean;
|
23
31
|
constructor(options?: ImageOptions | undefined, opt?: boolean);
|
@@ -26,8 +34,4 @@ export declare class ImageSchema<Src extends FileSource<ImageMetadata> | null> e
|
|
26
34
|
optional(): Schema<Src | null>;
|
27
35
|
serialize(): SerializedSchema;
|
28
36
|
}
|
29
|
-
export declare const image: (options?: ImageOptions) => Schema<
|
30
|
-
export declare const convertFileSource: (src: FileSource<ImageMetadata>) => {
|
31
|
-
url: string;
|
32
|
-
metadata?: ImageMetadata;
|
33
|
-
};
|
37
|
+
export declare const image: (options?: ImageOptions) => Schema<ImageSource>;
|
@@ -1,6 +1,10 @@
|
|
1
|
+
import { Source } from "../source/index.js";
|
2
|
+
import { FileMetadata } from "../source/file.js";
|
1
3
|
import { Selector as UnknownSelector, GenericSelector } from "./index.js";
|
2
|
-
export type FileSelector = GenericSelector<{
|
4
|
+
export type FileSelector<Metadata extends FileMetadata | undefined> = GenericSelector<{
|
3
5
|
url: string;
|
4
6
|
}> & {
|
5
7
|
readonly url: UnknownSelector<string>;
|
6
|
-
}
|
8
|
+
} & Metadata extends undefined ? {} : Metadata extends Source ? {
|
9
|
+
readonly metadata: UnknownSelector<Metadata>;
|
10
|
+
} : {};
|
@@ -11,7 +11,9 @@ import { Schema } from "../schema/index.js";
|
|
11
11
|
import type { A } from "ts-toolbelt";
|
12
12
|
import { FileSource } from "../source/file.js";
|
13
13
|
import { RichText, RichTextOptions, RichTextSource } from "../source/richtext.js";
|
14
|
-
|
14
|
+
import { ImageMetadata } from "../schema/image.js";
|
15
|
+
import { ImageSelector } from "./image.js";
|
16
|
+
export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends FileSource<infer M> ? M extends ImageMetadata ? ImageSelector : FileSelector<M> : T extends RichTextSource<infer O> ? RichText<O> : T extends SourceObject ? ObjectSelector<T> : T extends SourceArray ? ArraySelector<T> : T extends string ? StringSelector<T> : T extends number ? NumberSelector<T> : T extends boolean ? BooleanSelector<T> : T extends null ? PrimitiveSelector<null> : never;
|
15
17
|
export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
|
16
18
|
[key: string]: SelectorSource;
|
17
19
|
} | FileSource | RichTextSource<RichTextOptions> | GenericSelector<Source>;
|
@@ -1,23 +1,22 @@
|
|
1
1
|
import { VAL_EXTENSION } from "./index.js";
|
2
|
-
import {
|
2
|
+
import { Json } from "../Json.js";
|
3
3
|
export declare const FILE_REF_PROP: "_ref";
|
4
|
+
export type FileMetadata = {
|
5
|
+
readonly [key: string]: Json;
|
6
|
+
};
|
4
7
|
/**
|
5
8
|
* A file source represents the path to a (local) file.
|
6
9
|
*
|
7
10
|
* It will be resolved into a Asset object.
|
8
11
|
*
|
9
12
|
*/
|
10
|
-
export type FileSource<Metadata extends {
|
11
|
-
readonly [key: string]: JsonPrimitive;
|
12
|
-
} | undefined = {
|
13
|
-
readonly [key: string]: JsonPrimitive;
|
14
|
-
} | undefined> = {
|
13
|
+
export type FileSource<Metadata extends FileMetadata | undefined = FileMetadata | undefined> = {
|
15
14
|
readonly [FILE_REF_PROP]: string;
|
16
15
|
readonly [VAL_EXTENSION]: "file";
|
17
16
|
readonly metadata?: Metadata;
|
18
17
|
};
|
19
18
|
export declare function file<Metadata extends {
|
20
|
-
readonly [key: string]:
|
21
|
-
}>(ref: string
|
22
|
-
export declare function file(ref: string
|
19
|
+
readonly [key: string]: Json;
|
20
|
+
}>(ref: `/public/${string}`, metadata: Metadata): FileSource<Metadata>;
|
21
|
+
export declare function file(ref: `/public/${string}`, metadata?: undefined): FileSource<undefined>;
|
23
22
|
export declare function isFile(obj: unknown): obj is FileSource;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ImageMetadata } from "../schema/image.js";
|
2
|
+
import { FileSource } from "./file.js";
|
3
|
+
/**
|
4
|
+
* A image source represents the path to a (local) image.
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
export type ImageSource<Metadata extends ImageMetadata | undefined = ImageMetadata> = FileSource<Metadata>;
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { FileSource } from "./file.js";
|
2
1
|
import { VAL_EXTENSION } from "./index.js";
|
3
2
|
import { LinkSource } from "./link.js";
|
4
|
-
import {
|
3
|
+
import { ImageSource } from "./image.js";
|
5
4
|
export type RichTextOptions = {
|
6
5
|
headings?: ("h1" | "h2" | "h3" | "h4" | "h5" | "h6")[];
|
7
6
|
img?: boolean;
|
@@ -44,6 +43,7 @@ type ImageTagNode = {
|
|
44
43
|
src: string;
|
45
44
|
height?: number;
|
46
45
|
width?: number;
|
46
|
+
mimeType?: string;
|
47
47
|
children: [];
|
48
48
|
};
|
49
49
|
export type ImageNode<O extends RichTextOptions> = O["img"] extends true ? ImageTagNode : never;
|
@@ -79,7 +79,7 @@ export type RootNode<O extends RichTextOptions> = HeadingNode<O> | ParagraphNode
|
|
79
79
|
export type RichTextSource<O extends RichTextOptions> = {
|
80
80
|
[VAL_EXTENSION]: "richtext";
|
81
81
|
templateStrings: string[];
|
82
|
-
exprs: ((O["img"] extends true ?
|
82
|
+
exprs: ((O["img"] extends true ? ImageSource : never) | (O["a"] extends true ? LinkSource : never))[];
|
83
83
|
};
|
84
84
|
/**
|
85
85
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
@@ -89,5 +89,5 @@ export type RichText<O extends RichTextOptions> = {
|
|
89
89
|
[VAL_EXTENSION]: "richtext";
|
90
90
|
children: RootNode<O>[];
|
91
91
|
};
|
92
|
-
export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (
|
92
|
+
export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (ImageSource | LinkSource)[]): RichTextSource<O>;
|
93
93
|
export {};
|
@@ -427,85 +427,7 @@ function isFile(obj) {
|
|
427
427
|
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
|
428
428
|
}
|
429
429
|
|
430
|
-
|
431
|
-
_inherits(ImageSchema, _Schema);
|
432
|
-
var _super = _createSuper(ImageSchema);
|
433
|
-
function ImageSchema(options) {
|
434
|
-
var _this;
|
435
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
436
|
-
_classCallCheck(this, ImageSchema);
|
437
|
-
_this = _super.call(this);
|
438
|
-
_this.options = options;
|
439
|
-
_this.opt = opt;
|
440
|
-
return _this;
|
441
|
-
}
|
442
|
-
_createClass(ImageSchema, [{
|
443
|
-
key: "validate",
|
444
|
-
value: function validate(path, src) {
|
445
|
-
if (this.opt && (src === null || src === undefined)) {
|
446
|
-
return false;
|
447
|
-
}
|
448
|
-
if (src === null || src === undefined) {
|
449
|
-
return _defineProperty({}, path, [{
|
450
|
-
message: "Non-optional image was null or undefined.",
|
451
|
-
value: src
|
452
|
-
}]);
|
453
|
-
}
|
454
|
-
if (typeof src[FILE_REF_PROP] !== "string") {
|
455
|
-
return _defineProperty({}, path, [{
|
456
|
-
message: "Image did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
457
|
-
value: src
|
458
|
-
}]);
|
459
|
-
}
|
460
|
-
if (src[VAL_EXTENSION] !== "file") {
|
461
|
-
return _defineProperty({}, path, [{
|
462
|
-
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
463
|
-
value: src
|
464
|
-
}]);
|
465
|
-
}
|
466
|
-
if (src.metadata) {
|
467
|
-
return _defineProperty({}, path, [{
|
468
|
-
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
469
|
-
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
470
|
-
value: src,
|
471
|
-
fixes: ["image:replace-metadata"]
|
472
|
-
}]);
|
473
|
-
}
|
474
|
-
return _defineProperty({}, path, [{
|
475
|
-
message: "Could not validate Image metadata.",
|
476
|
-
value: src,
|
477
|
-
fixes: ["image:add-metadata"]
|
478
|
-
}]);
|
479
|
-
}
|
480
|
-
}, {
|
481
|
-
key: "assert",
|
482
|
-
value: function assert(src) {
|
483
|
-
if (this.opt && (src === null || src === undefined)) {
|
484
|
-
return true;
|
485
|
-
}
|
486
|
-
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
487
|
-
}
|
488
|
-
}, {
|
489
|
-
key: "optional",
|
490
|
-
value: function optional() {
|
491
|
-
return new ImageSchema(this.options, true);
|
492
|
-
}
|
493
|
-
}, {
|
494
|
-
key: "serialize",
|
495
|
-
value: function serialize() {
|
496
|
-
return {
|
497
|
-
type: "image",
|
498
|
-
options: this.options,
|
499
|
-
opt: this.opt
|
500
|
-
};
|
501
|
-
}
|
502
|
-
}]);
|
503
|
-
return ImageSchema;
|
504
|
-
}(Schema);
|
505
|
-
var image = function image(options) {
|
506
|
-
return new ImageSchema(options);
|
507
|
-
};
|
508
|
-
var convertFileSource = function convertFileSource(src) {
|
430
|
+
function convertFileSource(src) {
|
509
431
|
var _src$metadata2;
|
510
432
|
// TODO: /public should be configurable
|
511
433
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
@@ -519,7 +441,7 @@ var convertFileSource = function convertFileSource(src) {
|
|
519
441
|
url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
|
520
442
|
metadata: src.metadata
|
521
443
|
};
|
522
|
-
}
|
444
|
+
}
|
523
445
|
|
524
446
|
function isSerializedVal(val) {
|
525
447
|
return _typeof(val) === "object" && val !== null && val !== undefined && ("val" in val || "valPath" in val);
|
@@ -553,4 +475,4 @@ function getValPath(valOrSelector) {
|
|
553
475
|
return valOrSelector[Path];
|
554
476
|
}
|
555
477
|
|
556
|
-
export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G,
|
478
|
+
export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _createSuper as a, _classCallCheck as b, _createClass as c, _defineProperty as d, _typeof as e, file as f, getValPath as g, _slicedToArray as h, isFile as i, GetSource as j, isSerializedVal as k, convertFileSource as l, getSchema as m, isVal as n, GenericSelector as o, _objectSpread2 as p, Sym as q, StringLiteral as r, StringTemplate as s, _toConsumableArray as t };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { p as _objectSpread2, h as _slicedToArray, c as _createClass, b as _classCallCheck, q as Sym, C as Call, r as StringLiteral, s as StringTemplate, e as _typeof, k as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, l as convertFileSource, d as _defineProperty, E as Expr, S as Schema, t as _toConsumableArray, N as NilSym } from './index-5750c299.esm.js';
|
2
2
|
import { i as isErr, e as err, o as ok, a as isOk } from './result-b96df128.esm.js';
|
3
3
|
|
4
4
|
var WHITE_SPACE = ["\n", "\r", "\t", " "];
|
@@ -429,85 +429,7 @@ function isFile(obj) {
|
|
429
429
|
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
|
430
430
|
}
|
431
431
|
|
432
|
-
|
433
|
-
_inherits(ImageSchema, _Schema);
|
434
|
-
var _super = _createSuper(ImageSchema);
|
435
|
-
function ImageSchema(options) {
|
436
|
-
var _this;
|
437
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
438
|
-
_classCallCheck(this, ImageSchema);
|
439
|
-
_this = _super.call(this);
|
440
|
-
_this.options = options;
|
441
|
-
_this.opt = opt;
|
442
|
-
return _this;
|
443
|
-
}
|
444
|
-
_createClass(ImageSchema, [{
|
445
|
-
key: "validate",
|
446
|
-
value: function validate(path, src) {
|
447
|
-
if (this.opt && (src === null || src === undefined)) {
|
448
|
-
return false;
|
449
|
-
}
|
450
|
-
if (src === null || src === undefined) {
|
451
|
-
return _defineProperty({}, path, [{
|
452
|
-
message: "Non-optional image was null or undefined.",
|
453
|
-
value: src
|
454
|
-
}]);
|
455
|
-
}
|
456
|
-
if (typeof src[FILE_REF_PROP] !== "string") {
|
457
|
-
return _defineProperty({}, path, [{
|
458
|
-
message: "Image did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
459
|
-
value: src
|
460
|
-
}]);
|
461
|
-
}
|
462
|
-
if (src[VAL_EXTENSION] !== "file") {
|
463
|
-
return _defineProperty({}, path, [{
|
464
|
-
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
465
|
-
value: src
|
466
|
-
}]);
|
467
|
-
}
|
468
|
-
if (src.metadata) {
|
469
|
-
return _defineProperty({}, path, [{
|
470
|
-
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
471
|
-
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
472
|
-
value: src,
|
473
|
-
fixes: ["image:replace-metadata"]
|
474
|
-
}]);
|
475
|
-
}
|
476
|
-
return _defineProperty({}, path, [{
|
477
|
-
message: "Could not validate Image metadata.",
|
478
|
-
value: src,
|
479
|
-
fixes: ["image:add-metadata"]
|
480
|
-
}]);
|
481
|
-
}
|
482
|
-
}, {
|
483
|
-
key: "assert",
|
484
|
-
value: function assert(src) {
|
485
|
-
if (this.opt && (src === null || src === undefined)) {
|
486
|
-
return true;
|
487
|
-
}
|
488
|
-
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
489
|
-
}
|
490
|
-
}, {
|
491
|
-
key: "optional",
|
492
|
-
value: function optional() {
|
493
|
-
return new ImageSchema(this.options, true);
|
494
|
-
}
|
495
|
-
}, {
|
496
|
-
key: "serialize",
|
497
|
-
value: function serialize() {
|
498
|
-
return {
|
499
|
-
type: "image",
|
500
|
-
options: this.options,
|
501
|
-
opt: this.opt
|
502
|
-
};
|
503
|
-
}
|
504
|
-
}]);
|
505
|
-
return ImageSchema;
|
506
|
-
}(Schema);
|
507
|
-
var image = function image(options) {
|
508
|
-
return new ImageSchema(options);
|
509
|
-
};
|
510
|
-
var convertFileSource = function convertFileSource(src) {
|
432
|
+
function convertFileSource(src) {
|
511
433
|
var _src$metadata2;
|
512
434
|
// TODO: /public should be configurable
|
513
435
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
@@ -521,7 +443,7 @@ var convertFileSource = function convertFileSource(src) {
|
|
521
443
|
url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
|
522
444
|
metadata: src.metadata
|
523
445
|
};
|
524
|
-
}
|
446
|
+
}
|
525
447
|
|
526
448
|
function isSerializedVal(val) {
|
527
449
|
return _typeof(val) === "object" && val !== null && val !== undefined && ("val" in val || "valPath" in val);
|
@@ -561,7 +483,6 @@ exports.FILE_REF_PROP = FILE_REF_PROP;
|
|
561
483
|
exports.GenericSelector = GenericSelector;
|
562
484
|
exports.GetSchema = GetSchema;
|
563
485
|
exports.GetSource = GetSource;
|
564
|
-
exports.ImageSchema = ImageSchema;
|
565
486
|
exports.NilSym = NilSym;
|
566
487
|
exports.Path = Path;
|
567
488
|
exports.Schema = Schema;
|
@@ -582,7 +503,6 @@ exports.convertFileSource = convertFileSource;
|
|
582
503
|
exports.file = file;
|
583
504
|
exports.getSchema = getSchema;
|
584
505
|
exports.getValPath = getValPath;
|
585
|
-
exports.image = image;
|
586
506
|
exports.isFile = isFile;
|
587
507
|
exports.isSerializedVal = isSerializedVal;
|
588
508
|
exports.isVal = isVal;
|
@@ -429,85 +429,7 @@ function isFile(obj) {
|
|
429
429
|
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
|
430
430
|
}
|
431
431
|
|
432
|
-
|
433
|
-
_inherits(ImageSchema, _Schema);
|
434
|
-
var _super = _createSuper(ImageSchema);
|
435
|
-
function ImageSchema(options) {
|
436
|
-
var _this;
|
437
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
438
|
-
_classCallCheck(this, ImageSchema);
|
439
|
-
_this = _super.call(this);
|
440
|
-
_this.options = options;
|
441
|
-
_this.opt = opt;
|
442
|
-
return _this;
|
443
|
-
}
|
444
|
-
_createClass(ImageSchema, [{
|
445
|
-
key: "validate",
|
446
|
-
value: function validate(path, src) {
|
447
|
-
if (this.opt && (src === null || src === undefined)) {
|
448
|
-
return false;
|
449
|
-
}
|
450
|
-
if (src === null || src === undefined) {
|
451
|
-
return _defineProperty({}, path, [{
|
452
|
-
message: "Non-optional image was null or undefined.",
|
453
|
-
value: src
|
454
|
-
}]);
|
455
|
-
}
|
456
|
-
if (typeof src[FILE_REF_PROP] !== "string") {
|
457
|
-
return _defineProperty({}, path, [{
|
458
|
-
message: "Image did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
459
|
-
value: src
|
460
|
-
}]);
|
461
|
-
}
|
462
|
-
if (src[VAL_EXTENSION] !== "file") {
|
463
|
-
return _defineProperty({}, path, [{
|
464
|
-
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
465
|
-
value: src
|
466
|
-
}]);
|
467
|
-
}
|
468
|
-
if (src.metadata) {
|
469
|
-
return _defineProperty({}, path, [{
|
470
|
-
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
471
|
-
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
472
|
-
value: src,
|
473
|
-
fixes: ["image:replace-metadata"]
|
474
|
-
}]);
|
475
|
-
}
|
476
|
-
return _defineProperty({}, path, [{
|
477
|
-
message: "Could not validate Image metadata.",
|
478
|
-
value: src,
|
479
|
-
fixes: ["image:add-metadata"]
|
480
|
-
}]);
|
481
|
-
}
|
482
|
-
}, {
|
483
|
-
key: "assert",
|
484
|
-
value: function assert(src) {
|
485
|
-
if (this.opt && (src === null || src === undefined)) {
|
486
|
-
return true;
|
487
|
-
}
|
488
|
-
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
489
|
-
}
|
490
|
-
}, {
|
491
|
-
key: "optional",
|
492
|
-
value: function optional() {
|
493
|
-
return new ImageSchema(this.options, true);
|
494
|
-
}
|
495
|
-
}, {
|
496
|
-
key: "serialize",
|
497
|
-
value: function serialize() {
|
498
|
-
return {
|
499
|
-
type: "image",
|
500
|
-
options: this.options,
|
501
|
-
opt: this.opt
|
502
|
-
};
|
503
|
-
}
|
504
|
-
}]);
|
505
|
-
return ImageSchema;
|
506
|
-
}(Schema);
|
507
|
-
var image = function image(options) {
|
508
|
-
return new ImageSchema(options);
|
509
|
-
};
|
510
|
-
var convertFileSource = function convertFileSource(src) {
|
432
|
+
function convertFileSource(src) {
|
511
433
|
var _src$metadata2;
|
512
434
|
// TODO: /public should be configurable
|
513
435
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
@@ -521,7 +443,7 @@ var convertFileSource = function convertFileSource(src) {
|
|
521
443
|
url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
|
522
444
|
metadata: src.metadata
|
523
445
|
};
|
524
|
-
}
|
446
|
+
}
|
525
447
|
|
526
448
|
function isSerializedVal(val) {
|
527
449
|
return _typeof(val) === "object" && val !== null && val !== undefined && ("val" in val || "valPath" in val);
|
@@ -561,7 +483,6 @@ exports.FILE_REF_PROP = FILE_REF_PROP;
|
|
561
483
|
exports.GenericSelector = GenericSelector;
|
562
484
|
exports.GetSchema = GetSchema;
|
563
485
|
exports.GetSource = GetSource;
|
564
|
-
exports.ImageSchema = ImageSchema;
|
565
486
|
exports.NilSym = NilSym;
|
566
487
|
exports.Path = Path;
|
567
488
|
exports.Schema = Schema;
|
@@ -582,7 +503,6 @@ exports.convertFileSource = convertFileSource;
|
|
582
503
|
exports.file = file;
|
583
504
|
exports.getSchema = getSchema;
|
584
505
|
exports.getValPath = getValPath;
|
585
|
-
exports.image = image;
|
586
506
|
exports.isFile = isFile;
|
587
507
|
exports.isSerializedVal = isSerializedVal;
|
588
508
|
exports.isVal = isVal;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { e as _typeof,
|
1
|
+
import { e as _typeof, k as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, l as convertFileSource, d as _defineProperty, G as GetSchema, j as GetSource, E as Expr, P as Path, S as Schema, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, h as _slicedToArray, p as _objectSpread2, t as _toConsumableArray } from './index-5750c299.esm.js';
|
2
2
|
import { _ as _createForOfIteratorHelper } from './result-b96df128.esm.js';
|
3
3
|
|
4
4
|
function hasOwn(obj, prop) {
|
@@ -626,6 +626,85 @@ var richtext = function richtext(options) {
|
|
626
626
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
627
627
|
};
|
628
628
|
|
629
|
+
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
630
|
+
_inherits(ImageSchema, _Schema);
|
631
|
+
var _super = _createSuper(ImageSchema);
|
632
|
+
function ImageSchema(options) {
|
633
|
+
var _this;
|
634
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
635
|
+
_classCallCheck(this, ImageSchema);
|
636
|
+
_this = _super.call(this);
|
637
|
+
_this.options = options;
|
638
|
+
_this.opt = opt;
|
639
|
+
return _this;
|
640
|
+
}
|
641
|
+
_createClass(ImageSchema, [{
|
642
|
+
key: "validate",
|
643
|
+
value: function validate(path, src) {
|
644
|
+
if (this.opt && (src === null || src === undefined)) {
|
645
|
+
return false;
|
646
|
+
}
|
647
|
+
if (src === null || src === undefined) {
|
648
|
+
return _defineProperty({}, path, [{
|
649
|
+
message: "Non-optional image was null or undefined.",
|
650
|
+
value: src
|
651
|
+
}]);
|
652
|
+
}
|
653
|
+
if (typeof src[FILE_REF_PROP] !== "string") {
|
654
|
+
return _defineProperty({}, path, [{
|
655
|
+
message: "Image did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
656
|
+
value: src
|
657
|
+
}]);
|
658
|
+
}
|
659
|
+
if (src[VAL_EXTENSION] !== "file") {
|
660
|
+
return _defineProperty({}, path, [{
|
661
|
+
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
662
|
+
value: src
|
663
|
+
}]);
|
664
|
+
}
|
665
|
+
if (src.metadata) {
|
666
|
+
return _defineProperty({}, path, [{
|
667
|
+
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
668
|
+
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
669
|
+
value: src,
|
670
|
+
fixes: ["image:replace-metadata"]
|
671
|
+
}]);
|
672
|
+
}
|
673
|
+
return _defineProperty({}, path, [{
|
674
|
+
message: "Could not validate Image metadata.",
|
675
|
+
value: src,
|
676
|
+
fixes: ["image:add-metadata"]
|
677
|
+
}]);
|
678
|
+
}
|
679
|
+
}, {
|
680
|
+
key: "assert",
|
681
|
+
value: function assert(src) {
|
682
|
+
if (this.opt && (src === null || src === undefined)) {
|
683
|
+
return true;
|
684
|
+
}
|
685
|
+
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
686
|
+
}
|
687
|
+
}, {
|
688
|
+
key: "optional",
|
689
|
+
value: function optional() {
|
690
|
+
return new ImageSchema(this.options, true);
|
691
|
+
}
|
692
|
+
}, {
|
693
|
+
key: "serialize",
|
694
|
+
value: function serialize() {
|
695
|
+
return {
|
696
|
+
type: "image",
|
697
|
+
options: this.options,
|
698
|
+
opt: this.opt
|
699
|
+
};
|
700
|
+
}
|
701
|
+
}]);
|
702
|
+
return ImageSchema;
|
703
|
+
}(Schema);
|
704
|
+
var image = function image(options) {
|
705
|
+
return new ImageSchema(options);
|
706
|
+
};
|
707
|
+
|
629
708
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
630
709
|
_inherits(RecordSchema, _Schema);
|
631
710
|
var _super = _createSuper(RecordSchema);
|
@@ -966,4 +1045,4 @@ var PatchError = /*#__PURE__*/_createClass(function PatchError(message) {
|
|
966
1045
|
* NOTE: MAY mutate the input document.
|
967
1046
|
*/
|
968
1047
|
|
969
|
-
export { PatchError as P, array as a, record as b, content as c, createValPathOfItem as d,
|
1048
|
+
export { PatchError as P, array as a, record as b, content as c, createValPathOfItem as d, isSelector as e, resolvePath as f, getSource as g, image as i, literal as l, newSelectorProxy as n, object as o, richtext as r, splitModuleIdAndModulePath as s, union as u };
|
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var index = require('./index-
|
3
|
+
var index = require('./index-7b467ee6.cjs.prod.js');
|
4
4
|
var result = require('./result-26f67b40.cjs.prod.js');
|
5
5
|
|
6
6
|
function hasOwn(obj, prop) {
|
@@ -628,6 +628,85 @@ var richtext = function richtext(options) {
|
|
628
628
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
629
629
|
};
|
630
630
|
|
631
|
+
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
632
|
+
index._inherits(ImageSchema, _Schema);
|
633
|
+
var _super = index._createSuper(ImageSchema);
|
634
|
+
function ImageSchema(options) {
|
635
|
+
var _this;
|
636
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
637
|
+
index._classCallCheck(this, ImageSchema);
|
638
|
+
_this = _super.call(this);
|
639
|
+
_this.options = options;
|
640
|
+
_this.opt = opt;
|
641
|
+
return _this;
|
642
|
+
}
|
643
|
+
index._createClass(ImageSchema, [{
|
644
|
+
key: "validate",
|
645
|
+
value: function validate(path, src) {
|
646
|
+
if (this.opt && (src === null || src === undefined)) {
|
647
|
+
return false;
|
648
|
+
}
|
649
|
+
if (src === null || src === undefined) {
|
650
|
+
return index._defineProperty({}, path, [{
|
651
|
+
message: "Non-optional image was null or undefined.",
|
652
|
+
value: src
|
653
|
+
}]);
|
654
|
+
}
|
655
|
+
if (typeof src[index.FILE_REF_PROP] !== "string") {
|
656
|
+
return index._defineProperty({}, path, [{
|
657
|
+
message: "Image did not have a file reference string. Got: ".concat(index._typeof(src[index.FILE_REF_PROP])),
|
658
|
+
value: src
|
659
|
+
}]);
|
660
|
+
}
|
661
|
+
if (src[index.VAL_EXTENSION] !== "file") {
|
662
|
+
return index._defineProperty({}, path, [{
|
663
|
+
message: "Image did not have the valid file extension type. Got: ".concat(src[index.VAL_EXTENSION]),
|
664
|
+
value: src
|
665
|
+
}]);
|
666
|
+
}
|
667
|
+
if (src.metadata) {
|
668
|
+
return index._defineProperty({}, path, [{
|
669
|
+
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
670
|
+
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
671
|
+
value: src,
|
672
|
+
fixes: ["image:replace-metadata"]
|
673
|
+
}]);
|
674
|
+
}
|
675
|
+
return index._defineProperty({}, path, [{
|
676
|
+
message: "Could not validate Image metadata.",
|
677
|
+
value: src,
|
678
|
+
fixes: ["image:add-metadata"]
|
679
|
+
}]);
|
680
|
+
}
|
681
|
+
}, {
|
682
|
+
key: "assert",
|
683
|
+
value: function assert(src) {
|
684
|
+
if (this.opt && (src === null || src === undefined)) {
|
685
|
+
return true;
|
686
|
+
}
|
687
|
+
return (src === null || src === void 0 ? void 0 : src[index.FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[index.VAL_EXTENSION]) === "file";
|
688
|
+
}
|
689
|
+
}, {
|
690
|
+
key: "optional",
|
691
|
+
value: function optional() {
|
692
|
+
return new ImageSchema(this.options, true);
|
693
|
+
}
|
694
|
+
}, {
|
695
|
+
key: "serialize",
|
696
|
+
value: function serialize() {
|
697
|
+
return {
|
698
|
+
type: "image",
|
699
|
+
options: this.options,
|
700
|
+
opt: this.opt
|
701
|
+
};
|
702
|
+
}
|
703
|
+
}]);
|
704
|
+
return ImageSchema;
|
705
|
+
}(index.Schema);
|
706
|
+
var image = function image(options) {
|
707
|
+
return new ImageSchema(options);
|
708
|
+
};
|
709
|
+
|
631
710
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
632
711
|
index._inherits(RecordSchema, _Schema);
|
633
712
|
var _super = index._createSuper(RecordSchema);
|
@@ -768,7 +847,7 @@ function isRichTextSchema(schema) {
|
|
768
847
|
return schema instanceof RichTextSchema || index._typeof(schema) === "object" && "type" in schema && schema.type === "richtext";
|
769
848
|
}
|
770
849
|
function isImageSchema(schema) {
|
771
|
-
return schema instanceof
|
850
|
+
return schema instanceof ImageSchema || index._typeof(schema) === "object" && "type" in schema && schema.type === "image";
|
772
851
|
}
|
773
852
|
|
774
853
|
// function isOneOfSchema(
|
@@ -973,6 +1052,7 @@ exports.array = array;
|
|
973
1052
|
exports.content = content;
|
974
1053
|
exports.createValPathOfItem = createValPathOfItem;
|
975
1054
|
exports.getSource = getSource;
|
1055
|
+
exports.image = image;
|
976
1056
|
exports.isSelector = isSelector;
|
977
1057
|
exports.literal = literal;
|
978
1058
|
exports.newSelectorProxy = newSelectorProxy;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var index = require('./index-
|
3
|
+
var index = require('./index-d23e237a.cjs.dev.js');
|
4
4
|
var result = require('./result-48320acd.cjs.dev.js');
|
5
5
|
|
6
6
|
function hasOwn(obj, prop) {
|
@@ -628,6 +628,85 @@ var richtext = function richtext(options) {
|
|
628
628
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
629
629
|
};
|
630
630
|
|
631
|
+
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
632
|
+
index._inherits(ImageSchema, _Schema);
|
633
|
+
var _super = index._createSuper(ImageSchema);
|
634
|
+
function ImageSchema(options) {
|
635
|
+
var _this;
|
636
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
637
|
+
index._classCallCheck(this, ImageSchema);
|
638
|
+
_this = _super.call(this);
|
639
|
+
_this.options = options;
|
640
|
+
_this.opt = opt;
|
641
|
+
return _this;
|
642
|
+
}
|
643
|
+
index._createClass(ImageSchema, [{
|
644
|
+
key: "validate",
|
645
|
+
value: function validate(path, src) {
|
646
|
+
if (this.opt && (src === null || src === undefined)) {
|
647
|
+
return false;
|
648
|
+
}
|
649
|
+
if (src === null || src === undefined) {
|
650
|
+
return index._defineProperty({}, path, [{
|
651
|
+
message: "Non-optional image was null or undefined.",
|
652
|
+
value: src
|
653
|
+
}]);
|
654
|
+
}
|
655
|
+
if (typeof src[index.FILE_REF_PROP] !== "string") {
|
656
|
+
return index._defineProperty({}, path, [{
|
657
|
+
message: "Image did not have a file reference string. Got: ".concat(index._typeof(src[index.FILE_REF_PROP])),
|
658
|
+
value: src
|
659
|
+
}]);
|
660
|
+
}
|
661
|
+
if (src[index.VAL_EXTENSION] !== "file") {
|
662
|
+
return index._defineProperty({}, path, [{
|
663
|
+
message: "Image did not have the valid file extension type. Got: ".concat(src[index.VAL_EXTENSION]),
|
664
|
+
value: src
|
665
|
+
}]);
|
666
|
+
}
|
667
|
+
if (src.metadata) {
|
668
|
+
return index._defineProperty({}, path, [{
|
669
|
+
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
670
|
+
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
671
|
+
value: src,
|
672
|
+
fixes: ["image:replace-metadata"]
|
673
|
+
}]);
|
674
|
+
}
|
675
|
+
return index._defineProperty({}, path, [{
|
676
|
+
message: "Could not validate Image metadata.",
|
677
|
+
value: src,
|
678
|
+
fixes: ["image:add-metadata"]
|
679
|
+
}]);
|
680
|
+
}
|
681
|
+
}, {
|
682
|
+
key: "assert",
|
683
|
+
value: function assert(src) {
|
684
|
+
if (this.opt && (src === null || src === undefined)) {
|
685
|
+
return true;
|
686
|
+
}
|
687
|
+
return (src === null || src === void 0 ? void 0 : src[index.FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[index.VAL_EXTENSION]) === "file";
|
688
|
+
}
|
689
|
+
}, {
|
690
|
+
key: "optional",
|
691
|
+
value: function optional() {
|
692
|
+
return new ImageSchema(this.options, true);
|
693
|
+
}
|
694
|
+
}, {
|
695
|
+
key: "serialize",
|
696
|
+
value: function serialize() {
|
697
|
+
return {
|
698
|
+
type: "image",
|
699
|
+
options: this.options,
|
700
|
+
opt: this.opt
|
701
|
+
};
|
702
|
+
}
|
703
|
+
}]);
|
704
|
+
return ImageSchema;
|
705
|
+
}(index.Schema);
|
706
|
+
var image = function image(options) {
|
707
|
+
return new ImageSchema(options);
|
708
|
+
};
|
709
|
+
|
631
710
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
632
711
|
index._inherits(RecordSchema, _Schema);
|
633
712
|
var _super = index._createSuper(RecordSchema);
|
@@ -768,7 +847,7 @@ function isRichTextSchema(schema) {
|
|
768
847
|
return schema instanceof RichTextSchema || index._typeof(schema) === "object" && "type" in schema && schema.type === "richtext";
|
769
848
|
}
|
770
849
|
function isImageSchema(schema) {
|
771
|
-
return schema instanceof
|
850
|
+
return schema instanceof ImageSchema || index._typeof(schema) === "object" && "type" in schema && schema.type === "image";
|
772
851
|
}
|
773
852
|
|
774
853
|
// function isOneOfSchema(
|
@@ -973,6 +1052,7 @@ exports.array = array;
|
|
973
1052
|
exports.content = content;
|
974
1053
|
exports.createValPathOfItem = createValPathOfItem;
|
975
1054
|
exports.getSource = getSource;
|
1055
|
+
exports.image = image;
|
976
1056
|
exports.isSelector = isSelector;
|
977
1057
|
exports.literal = literal;
|
978
1058
|
exports.newSelectorProxy = newSelectorProxy;
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var ops = require('./ops-
|
6
|
-
var index = require('./index-
|
7
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var ops = require('./ops-453cddfc.cjs.dev.js');
|
6
|
+
var index = require('./index-d23e237a.cjs.dev.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-00276955.cjs.dev.js');
|
8
8
|
var result = require('./result-48320acd.cjs.dev.js');
|
9
9
|
|
10
10
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -341,7 +341,7 @@ function initSchema() {
|
|
341
341
|
union: ops.union,
|
342
342
|
// oneOf,
|
343
343
|
richtext: ops.richtext,
|
344
|
-
image:
|
344
|
+
image: ops.image,
|
345
345
|
literal: ops.literal,
|
346
346
|
keyOf: keyOf,
|
347
347
|
record: ops.record
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var ops = require('./ops-
|
6
|
-
var index = require('./index-
|
7
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var ops = require('./ops-18aded72.cjs.prod.js');
|
6
|
+
var index = require('./index-7b467ee6.cjs.prod.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-db60fc1d.cjs.prod.js');
|
8
8
|
var result = require('./result-26f67b40.cjs.prod.js');
|
9
9
|
|
10
10
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -341,7 +341,7 @@ function initSchema() {
|
|
341
341
|
union: ops.union,
|
342
342
|
// oneOf,
|
343
343
|
richtext: ops.richtext,
|
344
|
-
image:
|
344
|
+
image: ops.image,
|
345
345
|
literal: ops.literal,
|
346
346
|
keyOf: keyOf,
|
347
347
|
record: ops.record
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { a as array, o as object, u as union, r as richtext$1, l as literal, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem,
|
2
|
-
import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath,
|
3
|
-
export { F as FILE_REF_PROP,
|
4
|
-
export { i as expr } from './index-
|
1
|
+
import { a as array, o as object, u as union, r as richtext$1, i as image, l as literal, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem, e as isSelector, g as getSource, f as resolvePath, s as splitModuleIdAndModulePath } from './ops-117cb796.esm.js';
|
2
|
+
import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, V as VAL_EXTENSION, f as file, h as _slicedToArray, i as isFile, F as FILE_REF_PROP, P as Path, j as GetSource, k as isSerializedVal, l as convertFileSource, m as getSchema, n as isVal } from './index-5750c299.esm.js';
|
3
|
+
export { F as FILE_REF_PROP, o as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-5750c299.esm.js';
|
4
|
+
export { i as expr } from './index-799bcf49.esm.js';
|
5
5
|
import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok, r as result } from './result-b96df128.esm.js';
|
6
6
|
|
7
7
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
6
|
-
var index = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-00276955.cjs.dev.js');
|
6
|
+
var index = require('../../dist/index-d23e237a.cjs.dev.js');
|
7
7
|
require('../../dist/result-48320acd.cjs.dev.js');
|
8
8
|
|
9
9
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
6
|
-
var index = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-db60fc1d.cjs.prod.js');
|
6
|
+
var index = require('../../dist/index-7b467ee6.cjs.prod.js');
|
7
7
|
require('../../dist/result-26f67b40.cjs.prod.js');
|
8
8
|
|
9
9
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { e as evaluate, p as parse } from '../../dist/index-
|
2
|
-
export { C as Call, E as Expr, N as NilSym,
|
1
|
+
export { e as evaluate, p as parse } from '../../dist/index-799bcf49.esm.js';
|
2
|
+
export { C as Call, E as Expr, N as NilSym, r as StringLiteral, s as StringTemplate, q as Sym } from '../../dist/index-5750c299.esm.js';
|
3
3
|
import '../../dist/result-b96df128.esm.js';
|
package/package.json
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('../../dist/index-
|
5
|
+
var index = require('../../dist/index-d23e237a.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-48320acd.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
|
-
var ops = require('../../dist/ops-
|
8
|
+
var ops = require('../../dist/ops-453cddfc.cjs.dev.js');
|
9
9
|
|
10
10
|
function isNotRoot(path) {
|
11
11
|
return result.isNonEmpty(path);
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('../../dist/index-
|
5
|
+
var index = require('../../dist/index-7b467ee6.cjs.prod.js');
|
6
6
|
var result = require('../../dist/result-26f67b40.cjs.prod.js');
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
8
|
-
var ops = require('../../dist/ops-
|
8
|
+
var ops = require('../../dist/ops-18aded72.cjs.prod.js');
|
9
9
|
|
10
10
|
function isNotRoot(path) {
|
11
11
|
return result.isNonEmpty(path);
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { e as _typeof, h as _slicedToArray, c as _createClass, b as _classCallCheck,
|
1
|
+
import { e as _typeof, h as _slicedToArray, c as _createClass, b as _classCallCheck, t as _toConsumableArray } from '../../dist/index-5750c299.esm.js';
|
2
2
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-b96df128.esm.js';
|
3
3
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
4
|
-
import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-
|
5
|
-
export { P as PatchError } from '../../dist/ops-
|
4
|
+
import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-117cb796.esm.js';
|
5
|
+
export { P as PatchError } from '../../dist/ops-117cb796.esm.js';
|
6
6
|
|
7
7
|
function isNotRoot(path) {
|
8
8
|
return isNonEmpty(path);
|