@valbuild/core 0.65.3 → 0.67.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 +0 -2
- package/dist/declarations/src/initSchema.d.ts +18 -0
- package/dist/declarations/src/initVal.d.ts +2 -7
- package/dist/declarations/src/schema/image.d.ts +1 -0
- package/dist/declarations/src/selector/index.d.ts +2 -2
- package/dist/declarations/src/source/image.d.ts +14 -2
- package/dist/declarations/src/source/richtext.d.ts +0 -7
- package/dist/{index-e38a9dcf.esm.js → index-062f9388.esm.js} +58 -260
- package/dist/{index-4145963f.cjs.dev.js → index-38cd75f9.cjs.dev.js} +59 -282
- package/dist/{index-09f6e387.cjs.prod.js → index-55eeef93.cjs.prod.js} +59 -282
- package/dist/valbuild-core.cjs.dev.js +1 -4
- package/dist/valbuild-core.cjs.prod.js +1 -4
- package/dist/valbuild-core.esm.js +1 -3
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -3
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -3
- package/expr/dist/valbuild-core-expr.esm.js +1 -3
- package/package.json +1 -2
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -3
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -3
- package/patch/dist/valbuild-core-patch.esm.js +2 -4
- package/dist/declarations/src/source/link.d.ts +0 -9
@@ -4,13 +4,11 @@ export type { InitVal, ValConfig, ValConstructor, ContentConstructor, } from "./
|
|
4
4
|
export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
|
5
5
|
export type { ImageMetadata } from "./schema/image.js";
|
6
6
|
export type { FileMetadata } from "./schema/file.js";
|
7
|
-
export type { LinkSource } from "./source/link.js";
|
8
7
|
export type { ValModule, SerializedModule, InferValModuleType } from "./module.js";
|
9
8
|
export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
|
10
9
|
export type { FileSource } from "./source/file.js";
|
11
10
|
export type { RawString } from "./schema/string.js";
|
12
11
|
export type { ImageSource } from "./source/image.js";
|
13
|
-
export { RT_IMAGE_TAG } from "./source/richtext.js";
|
14
12
|
export type { AllRichTextOptions, Bold, Styles, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichTextNode, RichTextOptions, RichTextSource, BlockNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
|
15
13
|
export { type Val, type SerializedVal, type ModuleFilePath, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
|
16
14
|
export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
|
@@ -19,6 +19,24 @@ export type InitSchema = {
|
|
19
19
|
readonly number: typeof number;
|
20
20
|
readonly union: typeof union;
|
21
21
|
readonly richtext: typeof richtext;
|
22
|
+
/**
|
23
|
+
* Define a image source.
|
24
|
+
*
|
25
|
+
* Use c.image to create an image source.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* const schema = s.image();
|
29
|
+
* export default c.define("/example.val.ts", schema, c.image("/public/val/example.png", {
|
30
|
+
* width: 100,
|
31
|
+
* height: 100,
|
32
|
+
* mimeType: "image/png",
|
33
|
+
* hotspot: {
|
34
|
+
* x: 0.5,
|
35
|
+
* y: 0.5
|
36
|
+
* }
|
37
|
+
* }));
|
38
|
+
*
|
39
|
+
*/
|
22
40
|
readonly image: typeof image;
|
23
41
|
readonly literal: typeof literal;
|
24
42
|
readonly keyOf: typeof keyOf;
|
@@ -2,16 +2,11 @@ import { define } from "./module.js";
|
|
2
2
|
import { InitSchema } from "./initSchema.js";
|
3
3
|
import { getValPath as getPath } from "./val/index.js";
|
4
4
|
import { initFile } from "./source/file.js";
|
5
|
-
import {
|
6
|
-
import { link } from "./source/link.js";
|
5
|
+
import { initImage } from "./source/image.js";
|
7
6
|
export type ContentConstructor = {
|
8
7
|
define: typeof define;
|
9
8
|
file: ReturnType<typeof initFile>;
|
10
|
-
|
11
|
-
image: ReturnType<typeof initFile>;
|
12
|
-
link: typeof link;
|
13
|
-
};
|
14
|
-
richtext: typeof richtext;
|
9
|
+
image: ReturnType<typeof initImage>;
|
15
10
|
};
|
16
11
|
export type ValConstructor = {
|
17
12
|
unstable_getPath: typeof getPath;
|
@@ -11,10 +11,10 @@ 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 { AllRichTextOptions, RichTextSource } from "../source/richtext.js";
|
14
|
-
import { ImageMetadata } from "../schema/image.js";
|
15
14
|
import { ImageSelector } from "./image.js";
|
16
15
|
import { RichTextSelector } from "./richtext.js";
|
17
|
-
|
16
|
+
import { ImageSource } from "../source/image.js";
|
17
|
+
export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends ImageSource ? ImageSelector : T extends FileSource<infer M> ? FileSelector<M> : T extends RichTextSource<infer O> ? RichTextSelector<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;
|
18
18
|
export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
|
19
19
|
[key: string]: SelectorSource;
|
20
20
|
} | FileSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
|
@@ -1,7 +1,19 @@
|
|
1
|
+
import { VAL_EXTENSION } from "./index.js";
|
2
|
+
import { ValConfig } from "../initVal.js";
|
1
3
|
import { ImageMetadata } from "../schema/image.js";
|
2
|
-
import {
|
4
|
+
import { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./file.js";
|
3
5
|
/**
|
4
6
|
* A image source represents the path to a (local) image.
|
5
7
|
*
|
6
8
|
*/
|
7
|
-
export type ImageSource<Metadata extends ImageMetadata | undefined = ImageMetadata> =
|
9
|
+
export type ImageSource<Metadata extends ImageMetadata | undefined = ImageMetadata | undefined> = {
|
10
|
+
readonly [FILE_REF_PROP]: string;
|
11
|
+
readonly [VAL_EXTENSION]: "file";
|
12
|
+
readonly [FILE_REF_SUBTYPE_TAG]: "image";
|
13
|
+
readonly metadata?: Metadata;
|
14
|
+
readonly patch_id?: string;
|
15
|
+
};
|
16
|
+
export declare const initImage: (config?: ValConfig) => {
|
17
|
+
(ref: `${`/public/${string}`}/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
|
18
|
+
(ref: `${`/public/${string}`}/${string}`, metadata?: undefined): ImageSource<undefined>;
|
19
|
+
};
|
@@ -1,7 +1,4 @@
|
|
1
|
-
import { LinkSource } from "./link.js";
|
2
1
|
import { ImageSource } from "./image.js";
|
3
|
-
import { ImageMetadata } from "../schema/image.js";
|
4
|
-
import { FileSource } from "./file.js";
|
5
2
|
export type RichTextOptions = Partial<{
|
6
3
|
style: Partial<{
|
7
4
|
bold: boolean;
|
@@ -103,8 +100,4 @@ export type BlockNode<O extends RichTextOptions> = HeadingNode<O> | ParagraphNod
|
|
103
100
|
* RichText as defined in a ValModule
|
104
101
|
**/
|
105
102
|
export type RichTextSource<O extends RichTextOptions> = BlockNode<O>[];
|
106
|
-
export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (ImageSource | LinkSource)[]): RichTextSource<{}>;
|
107
|
-
export declare const RT_IMAGE_TAG = "rt_image";
|
108
|
-
export type RTImageMetadata = ImageMetadata;
|
109
|
-
export declare function image(ref: `/public/${string}`, metadata?: RTImageMetadata): FileSource<RTImageMetadata>;
|
110
103
|
export {};
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import { _ as _unsupportedIterableToArray, a as _arrayLikeToArray, i as isErr, e as err, o as ok, b as isOk, c as _createForOfIteratorHelper } from './result-168dfc1d.esm.js';
|
2
|
-
import * as marked from 'marked';
|
3
|
-
import { VAL_EXTENSION as VAL_EXTENSION$1, FILE_REF_SUBTYPE_TAG as FILE_REF_SUBTYPE_TAG$1 } from '@valbuild/core';
|
4
2
|
|
5
3
|
function _arrayWithHoles(r) {
|
6
4
|
if (Array.isArray(r)) return r;
|
@@ -1057,7 +1055,7 @@ var ParserError = /*#__PURE__*/_createClass(function ParserError(message, span)
|
|
1057
1055
|
this.message = message;
|
1058
1056
|
this.span = span;
|
1059
1057
|
});
|
1060
|
-
function parseTokens
|
1058
|
+
function parseTokens(inputTokens) {
|
1061
1059
|
var tokens = inputTokens.slice();
|
1062
1060
|
function slurpCall(first, isAnon) {
|
1063
1061
|
var _tokens$, _tokens$2, _tokens$3, _tokens$7, _tokens$8, _args$slice$0$span;
|
@@ -1193,7 +1191,7 @@ function parse(input) {
|
|
1193
1191
|
_tokenize2 = _slicedToArray(_tokenize, 2),
|
1194
1192
|
tokens = _tokenize2[0];
|
1195
1193
|
_tokenize2[1]; // TODO: we can use cursor to improve error messages / spans
|
1196
|
-
return parseTokens
|
1194
|
+
return parseTokens(tokens);
|
1197
1195
|
}
|
1198
1196
|
|
1199
1197
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
@@ -2260,7 +2258,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2260
2258
|
}
|
2261
2259
|
}]);
|
2262
2260
|
}(Schema);
|
2263
|
-
var richtext
|
2261
|
+
var richtext = function richtext(options) {
|
2264
2262
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
2265
2263
|
};
|
2266
2264
|
|
@@ -2431,7 +2429,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2431
2429
|
}
|
2432
2430
|
}]);
|
2433
2431
|
}(Schema);
|
2434
|
-
var image
|
2432
|
+
var image = function image(options) {
|
2435
2433
|
return new ImageSchema(options);
|
2436
2434
|
};
|
2437
2435
|
|
@@ -3399,8 +3397,8 @@ function initSchema() {
|
|
3399
3397
|
number: number,
|
3400
3398
|
union: union,
|
3401
3399
|
// oneOf,
|
3402
|
-
richtext: richtext
|
3403
|
-
image: image
|
3400
|
+
richtext: richtext,
|
3401
|
+
image: image,
|
3404
3402
|
literal: literal,
|
3405
3403
|
keyOf: keyOf,
|
3406
3404
|
record: record,
|
@@ -3410,257 +3408,61 @@ function initSchema() {
|
|
3410
3408
|
};
|
3411
3409
|
}
|
3412
3410
|
|
3413
|
-
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
var insideList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
3418
|
-
var children = [];
|
3419
|
-
function merge(token, clazz) {
|
3420
|
-
var parsedTokens = parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0);
|
3421
|
-
children.push({
|
3422
|
-
tag: "span",
|
3423
|
-
styles: [clazz].concat(parsedTokens.children.flatMap(function (child) {
|
3424
|
-
return typeof child === "string" ? [] : child.styles;
|
3425
|
-
})),
|
3426
|
-
children: parsedTokens.children.flatMap(function (child) {
|
3427
|
-
return typeof child === "string" ? child : child.children;
|
3428
|
-
})
|
3429
|
-
});
|
3430
|
-
}
|
3431
|
-
var _loop = function _loop() {
|
3432
|
-
var token = tokens[cursor];
|
3433
|
-
if (token.type === "heading") {
|
3434
|
-
children.push({
|
3435
|
-
tag: "h".concat(token.depth),
|
3436
|
-
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
3437
|
-
});
|
3438
|
-
} else if (token.type === "paragraph") {
|
3439
|
-
children.push({
|
3440
|
-
tag: "p",
|
3441
|
-
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
3442
|
-
});
|
3443
|
-
} else if (token.type === "strong") {
|
3444
|
-
merge(token, "bold");
|
3445
|
-
} else if (token.type === "em") {
|
3446
|
-
merge(token, "italic");
|
3447
|
-
} else if (token.type === "del") {
|
3448
|
-
merge(token, "line-through");
|
3449
|
-
} else if (token.type === "text") {
|
3450
|
-
if ("tokens" in token && Array.isArray(token.tokens)) {
|
3451
|
-
children.push.apply(children, _toConsumableArray(parseTokens(token.tokens, sourceNodes, cursor, insideList).children));
|
3452
|
-
} else {
|
3453
|
-
if (insideList && typeof token.raw === "string") {
|
3454
|
-
var lines = token.raw.split("\n");
|
3455
|
-
var tags = lines.flatMap(function (line, i) {
|
3456
|
-
if (i === lines.length - 1) return [line];
|
3457
|
-
if (i === lines.length - 1 && line === "") return [];
|
3458
|
-
if (line === "") return [{
|
3459
|
-
tag: "p",
|
3460
|
-
children: [{
|
3461
|
-
tag: "br"
|
3462
|
-
}]
|
3463
|
-
}];
|
3464
|
-
return [line, {
|
3465
|
-
tag: "p",
|
3466
|
-
children: [{
|
3467
|
-
tag: "br"
|
3468
|
-
}]
|
3469
|
-
}];
|
3470
|
-
});
|
3471
|
-
children.push.apply(children, _toConsumableArray(tags));
|
3472
|
-
} else {
|
3473
|
-
children.push(token.raw);
|
3474
|
-
}
|
3475
|
-
}
|
3476
|
-
} else if (token.type === "list") {
|
3477
|
-
children.push({
|
3478
|
-
tag: token.ordered ? "ol" : "ul",
|
3479
|
-
children: parseTokens(token.items, sourceNodes, 0).children
|
3480
|
-
});
|
3481
|
-
} else if (token.type === "list_item") {
|
3482
|
-
children.push({
|
3483
|
-
tag: "li",
|
3484
|
-
children: [{
|
3485
|
-
tag: "p",
|
3486
|
-
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0, true).children
|
3487
|
-
}]
|
3488
|
-
});
|
3489
|
-
} else if (token.type === "space") ; else if (token.type === "html") {
|
3490
|
-
if (token.text === VAL_END_TAG) {
|
3491
|
-
return {
|
3492
|
-
v: {
|
3493
|
-
children: children,
|
3494
|
-
cursor: cursor
|
3495
|
-
}
|
3496
|
-
};
|
3497
|
-
}
|
3498
|
-
var suffixIndex = token.text.indexOf(VAL_START_TAG_SUFFIX);
|
3499
|
-
if (token.text.startsWith(VAL_START_TAG_PREFIX) && suffixIndex > -1) {
|
3500
|
-
var number = Number(token.text.slice(VAL_START_TAG_PREFIX.length, suffixIndex));
|
3501
|
-
if (Number.isNaN(number)) {
|
3502
|
-
throw Error("Illegal val intermediate node: ".concat(JSON.stringify(token)));
|
3503
|
-
}
|
3504
|
-
var _parseTokens = parseTokens(tokens.map(function (token) {
|
3505
|
-
if (token.type === "link" || token.type === "list") {
|
3506
|
-
return {
|
3507
|
-
type: "text",
|
3508
|
-
raw: token.raw,
|
3509
|
-
text: token.raw
|
3510
|
-
};
|
3511
|
-
}
|
3512
|
-
return token;
|
3513
|
-
}), sourceNodes, cursor + 1),
|
3514
|
-
subChildren = _parseTokens.children,
|
3515
|
-
subCursor = _parseTokens.cursor;
|
3516
|
-
var sourceNode = sourceNodes[number];
|
3517
|
-
if (sourceNode._type === "link") {
|
3518
|
-
children.push({
|
3519
|
-
tag: "a",
|
3520
|
-
href: sourceNode.href,
|
3521
|
-
children: subChildren
|
3522
|
-
});
|
3523
|
-
} else if (sourceNode._type === "file") {
|
3524
|
-
// @ts-expect-error We are transitioning from markdown to structured objects, with structured objects we no longer want c.rt.image
|
3525
|
-
delete sourceNode[FILE_REF_SUBTYPE_TAG$1];
|
3526
|
-
children.push({
|
3527
|
-
tag: "img",
|
3528
|
-
src: sourceNode
|
3529
|
-
});
|
3530
|
-
}
|
3531
|
-
cursor = subCursor;
|
3532
|
-
}
|
3533
|
-
var br_html_regex = /<br\s*\/?>/gi; // matches <br>, <br/>, <br />; case insensitive
|
3534
|
-
if (token.text.trim().match(br_html_regex)) {
|
3535
|
-
var _tokens;
|
3536
|
-
children.push({
|
3537
|
-
tag: "p",
|
3538
|
-
children: [{
|
3539
|
-
tag: "br"
|
3540
|
-
}]
|
3541
|
-
});
|
3542
|
-
if (((_tokens = tokens[cursor + 1]) === null || _tokens === void 0 ? void 0 : _tokens.raw.trim()) === "") {
|
3543
|
-
// if next token is a new line or white-spaces, skip it
|
3544
|
-
// this typically means we have a <br> AND a new line, which, semantically, is just a <br>
|
3545
|
-
cursor++;
|
3546
|
-
}
|
3547
|
-
}
|
3548
|
-
} else if (token.type === "link") {
|
3549
|
-
if (token.raw === token.href) {
|
3550
|
-
// avoid auto-linking (provided by github flavoured markdown, but we want strikethrough so keep it enabled)
|
3551
|
-
children.push(token.raw);
|
3552
|
-
} else {
|
3553
|
-
children.push({
|
3554
|
-
tag: "a",
|
3555
|
-
href: token.href,
|
3556
|
-
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
3557
|
-
});
|
3558
|
-
}
|
3559
|
-
} else if (token.type === "br") {
|
3560
|
-
children.push({
|
3561
|
-
tag: "p",
|
3562
|
-
children: [{
|
3563
|
-
tag: "br"
|
3564
|
-
}]
|
3565
|
-
});
|
3566
|
-
} else {
|
3567
|
-
console.error("Could not parse markdown: unsupported token type: ".concat(token.type, ". Found: ").concat(token.raw));
|
3568
|
-
}
|
3569
|
-
cursor++;
|
3570
|
-
},
|
3571
|
-
_ret;
|
3572
|
-
while (cursor < tokens.length) {
|
3573
|
-
_ret = _loop();
|
3574
|
-
if (_ret) return _ret.v;
|
3575
|
-
}
|
3576
|
-
return {
|
3577
|
-
children: children,
|
3578
|
-
cursor: cursor
|
3579
|
-
};
|
3580
|
-
}
|
3581
|
-
function parseRichTextSource(_ref) {
|
3582
|
-
var templateStrings = _ref.templateStrings,
|
3583
|
-
nodes = _ref.exprs;
|
3584
|
-
// TODO: validate that templateStrings does not contain VAL_NODE_PREFIX
|
3585
|
-
var inputText = templateStrings.flatMap(function (templateString, i) {
|
3586
|
-
var node = nodes[i];
|
3587
|
-
if (node) {
|
3588
|
-
if (node[VAL_EXTENSION$1] === "link") {
|
3589
|
-
return templateString.concat("".concat(VAL_START_TAG_PREFIX).concat(i).concat(VAL_START_TAG_SUFFIX).concat(node.children[0]).concat(VAL_END_TAG));
|
3590
|
-
} else {
|
3591
|
-
return templateString.concat("".concat(VAL_START_TAG_PREFIX).concat(i).concat(VAL_START_TAG_SUFFIX).concat(VAL_END_TAG));
|
3592
|
-
}
|
3593
|
-
}
|
3594
|
-
return templateString;
|
3595
|
-
}).join("");
|
3596
|
-
var tokenList = marked.lexer(inputText, {
|
3597
|
-
gfm: true
|
3598
|
-
});
|
3599
|
-
var _parseTokens2 = parseTokens(tokenList, nodes, 0),
|
3600
|
-
children = _parseTokens2.children,
|
3601
|
-
cursor = _parseTokens2.cursor;
|
3602
|
-
if (cursor !== tokenList.length) {
|
3603
|
-
throw Error("Unexpectedly terminated markdown parsing. Possible reason: unclosed html tag?");
|
3604
|
-
}
|
3605
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
3606
|
-
children.markdownish = true; // Markdown is an intermediate format - we are planning on replacing it with a structured object format
|
3607
|
-
return children;
|
3608
|
-
}
|
3609
|
-
|
3610
|
-
//#region Classes
|
3611
|
-
|
3612
|
-
//#region Paragraph
|
3613
|
-
|
3614
|
-
//#region Break
|
3615
|
-
|
3616
|
-
//#region Span
|
3617
|
-
|
3618
|
-
//#region Image
|
3619
|
-
|
3620
|
-
//#region Link
|
3621
|
-
|
3622
|
-
//#region List
|
3623
|
-
|
3624
|
-
//#region Heading
|
3625
|
-
|
3626
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3627
|
-
|
3628
|
-
// export type CustomInlineNode<O extends RichTextOptions> = NonNullable<
|
3629
|
-
// NonNullable<O["inline"]>["custom"]
|
3630
|
-
// >[keyof NonNullable<NonNullable<O["inline"]>["custom"]>] extends Schema<
|
3631
|
-
// infer Src
|
3632
|
-
// >
|
3633
|
-
// ? ReplaceRawStringWithString<Src>
|
3634
|
-
// : never;
|
3635
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3411
|
+
/**
|
3412
|
+
* A image source represents the path to a (local) image.
|
3413
|
+
*
|
3414
|
+
*/
|
3636
3415
|
|
3637
|
-
|
3416
|
+
var initImage = function initImage(config) {
|
3417
|
+
var _config$files$directo, _config$files;
|
3418
|
+
(_config$files$directo = config === null || config === void 0 || (_config$files = config.files) === null || _config$files === void 0 ? void 0 : _config$files.directory) !== null && _config$files$directo !== void 0 ? _config$files$directo : "/public/val";
|
3638
3419
|
|
3639
|
-
|
3420
|
+
/**
|
3421
|
+
* Define the source of an image file.
|
3422
|
+
*
|
3423
|
+
* @example
|
3424
|
+
* c.image("/public/val/example.png", {
|
3425
|
+
* width: 944,
|
3426
|
+
* height: 944,
|
3427
|
+
* mimeType: "image/png",
|
3428
|
+
*})
|
3429
|
+
*
|
3430
|
+
* @param ref /public/val/example.png
|
3431
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3432
|
+
*/
|
3640
3433
|
|
3641
|
-
/**
|
3642
|
-
|
3643
|
-
|
3434
|
+
/**
|
3435
|
+
* Define the source of an image file.
|
3436
|
+
*
|
3437
|
+
* NOTE: this will **not** validate since metadata has not been defined.
|
3438
|
+
*
|
3439
|
+
* Run `npx -p @valbuild/cli val validate --fix` to automatically add metadata.
|
3440
|
+
*
|
3441
|
+
* @example
|
3442
|
+
* c.image("/public/val/example.png")
|
3443
|
+
*
|
3444
|
+
* @param ref /public/val/example.png
|
3445
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3446
|
+
*/
|
3644
3447
|
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3448
|
+
/**
|
3449
|
+
* Define the source of an image file.
|
3450
|
+
*
|
3451
|
+
* @example
|
3452
|
+
* c.image("/public/val/example.png", {
|
3453
|
+
* width: 944,
|
3454
|
+
* height: 944,
|
3455
|
+
* mimeType: "image/png",
|
3456
|
+
*})
|
3457
|
+
*
|
3458
|
+
* @param ref /public/val/example.png
|
3459
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3460
|
+
*/
|
3461
|
+
function image(ref, metadata) {
|
3462
|
+
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), FILE_REF_SUBTYPE_TAG, "image"), "metadata", metadata);
|
3648
3463
|
}
|
3649
|
-
return
|
3650
|
-
|
3651
|
-
exprs: nodes
|
3652
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
3653
|
-
});
|
3654
|
-
}
|
3655
|
-
var RT_IMAGE_TAG = "rt_image";
|
3656
|
-
function image(ref, metadata) {
|
3657
|
-
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), FILE_REF_SUBTYPE_TAG, RT_IMAGE_TAG), VAL_EXTENSION, "file"), "metadata", metadata);
|
3658
|
-
}
|
3659
|
-
|
3660
|
-
function link(text, _ref) {
|
3661
|
-
var href = _ref.href;
|
3662
|
-
return _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "link"), "href", href), "children", [text]);
|
3663
|
-
}
|
3464
|
+
return image;
|
3465
|
+
};
|
3664
3466
|
|
3665
3467
|
/* eslint-disable @typescript-eslint/ban-types */
|
3666
3468
|
// import { i18n, I18n } from "./source/future/i18n";
|
@@ -3701,11 +3503,7 @@ var initVal = function initVal(config) {
|
|
3701
3503
|
define: define,
|
3702
3504
|
// remote,
|
3703
3505
|
file: initFile(config),
|
3704
|
-
|
3705
|
-
rt: {
|
3706
|
-
image: image,
|
3707
|
-
link: link
|
3708
|
-
}
|
3506
|
+
image: initImage(config)
|
3709
3507
|
},
|
3710
3508
|
s: s,
|
3711
3509
|
config: config
|
@@ -5187,4 +4985,4 @@ function tryJsonParse(str) {
|
|
5187
4985
|
}
|
5188
4986
|
}
|
5189
4987
|
|
5190
|
-
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NilSym as N, ObjectSchema as O, PatchError as P,
|
4988
|
+
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NilSym as N, ObjectSchema as O, PatchError as P, RecordSchema as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, StringSchema as o, parse as p, NumberSchema as q, ImageSchema as r, splitModuleFilePathAndModulePath as s, FileSchema as t, RichTextSchema as u, deserializeSchema as v };
|