@valbuild/core 0.66.0 → 0.67.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/schema/validation/ValidationFix.d.ts +1 -1
- 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-4145963f.cjs.dev.js → index-3d77ee46.cjs.dev.js} +80 -301
- package/dist/{index-e38a9dcf.esm.js → index-439509d7.esm.js} +79 -279
- package/dist/{index-09f6e387.cjs.prod.js → index-b20f2afc.cjs.prod.js} +80 -301
- 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
@@ -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;
|
@@ -449,7 +447,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
449
447
|
if (src[VAL_EXTENSION] !== "file") {
|
450
448
|
return _defineProperty({}, path, [{
|
451
449
|
message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
452
|
-
value: src
|
450
|
+
value: src,
|
451
|
+
fixes: ["file:change-extension", "file:check-metadata"]
|
453
452
|
}]);
|
454
453
|
}
|
455
454
|
var _ref4 = this.options || {},
|
@@ -459,7 +458,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
459
458
|
if (accept && mimeType && !mimeType.includes("/")) {
|
460
459
|
return _defineProperty({}, path, [{
|
461
460
|
message: "Invalid mime type format. Got: ".concat(mimeType),
|
462
|
-
value: src
|
461
|
+
value: src,
|
462
|
+
fixes: ["file:change-extension", "file:check-metadata"]
|
463
463
|
}]);
|
464
464
|
}
|
465
465
|
if (accept && mimeType && mimeType.includes("/")) {
|
@@ -479,7 +479,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
479
479
|
if (!isValidMimeType) {
|
480
480
|
return _defineProperty({}, path, [{
|
481
481
|
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
482
|
-
value: src
|
482
|
+
value: src,
|
483
|
+
fixes: ["file:change-extension", "file:check-metadata"]
|
483
484
|
}]);
|
484
485
|
}
|
485
486
|
}
|
@@ -487,13 +488,15 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
487
488
|
if (!fileMimeType) {
|
488
489
|
return _defineProperty({}, path, [{
|
489
490
|
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
490
|
-
value: src
|
491
|
+
value: src,
|
492
|
+
fixes: ["file:change-extension", "file:check-metadata"]
|
491
493
|
}]);
|
492
494
|
}
|
493
495
|
if (fileMimeType !== mimeType) {
|
494
496
|
return _defineProperty({}, path, [{
|
495
497
|
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
496
|
-
value: src
|
498
|
+
value: src,
|
499
|
+
fixes: ["file:change-extension", "file:check-metadata"]
|
497
500
|
}]);
|
498
501
|
}
|
499
502
|
if (src.metadata) {
|
@@ -1057,7 +1060,7 @@ var ParserError = /*#__PURE__*/_createClass(function ParserError(message, span)
|
|
1057
1060
|
this.message = message;
|
1058
1061
|
this.span = span;
|
1059
1062
|
});
|
1060
|
-
function parseTokens
|
1063
|
+
function parseTokens(inputTokens) {
|
1061
1064
|
var tokens = inputTokens.slice();
|
1062
1065
|
function slurpCall(first, isAnon) {
|
1063
1066
|
var _tokens$, _tokens$2, _tokens$3, _tokens$7, _tokens$8, _args$slice$0$span;
|
@@ -1193,7 +1196,7 @@ function parse(input) {
|
|
1193
1196
|
_tokenize2 = _slicedToArray(_tokenize, 2),
|
1194
1197
|
tokens = _tokenize2[0];
|
1195
1198
|
_tokenize2[1]; // TODO: we can use cursor to improve error messages / spans
|
1196
|
-
return parseTokens
|
1199
|
+
return parseTokens(tokens);
|
1197
1200
|
}
|
1198
1201
|
|
1199
1202
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
@@ -2094,14 +2097,6 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2094
2097
|
return _createClass(RichTextSchema, [{
|
2095
2098
|
key: "validate",
|
2096
2099
|
value: function validate(path, src) {
|
2097
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2098
|
-
if (src !== null && src !== void 0 && src.markdownish) {
|
2099
|
-
return _defineProperty({}, path, [{
|
2100
|
-
message: "Replace markdown with structured format",
|
2101
|
-
value: src,
|
2102
|
-
fixes: ["fix:deprecated-richtext"]
|
2103
|
-
}]);
|
2104
|
-
}
|
2105
2100
|
var assertRes = this.assert(path, src);
|
2106
2101
|
if (!assertRes.success) {
|
2107
2102
|
return _defineProperty({}, path, assertRes.errors[path]);
|
@@ -2260,7 +2255,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2260
2255
|
}
|
2261
2256
|
}]);
|
2262
2257
|
}(Schema);
|
2263
|
-
var richtext
|
2258
|
+
var richtext = function richtext(options) {
|
2264
2259
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
2265
2260
|
};
|
2266
2261
|
|
@@ -2296,7 +2291,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2296
2291
|
if (src[VAL_EXTENSION] !== "file") {
|
2297
2292
|
return _defineProperty({}, path, [{
|
2298
2293
|
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
2299
|
-
value: src
|
2294
|
+
value: src,
|
2295
|
+
fixes: ["image:change-extension", "image:check-metadata"]
|
2300
2296
|
}]);
|
2301
2297
|
}
|
2302
2298
|
var _ref4 = this.options || {},
|
@@ -2306,7 +2302,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2306
2302
|
if (accept && mimeType && !mimeType.includes("/")) {
|
2307
2303
|
return _defineProperty({}, path, [{
|
2308
2304
|
message: "Invalid mime type format. Got: '".concat(mimeType, "'"),
|
2309
|
-
value: src
|
2305
|
+
value: src,
|
2306
|
+
fixes: ["image:check-metadata"]
|
2310
2307
|
}]);
|
2311
2308
|
}
|
2312
2309
|
if (accept && mimeType && mimeType.includes("/")) {
|
@@ -2326,7 +2323,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2326
2323
|
if (!isValidMimeType) {
|
2327
2324
|
return _defineProperty({}, path, [{
|
2328
2325
|
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
2329
|
-
value: src
|
2326
|
+
value: src,
|
2327
|
+
fixes: ["image:check-metadata"]
|
2330
2328
|
}]);
|
2331
2329
|
}
|
2332
2330
|
}
|
@@ -2334,13 +2332,15 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2334
2332
|
if (!fileMimeType) {
|
2335
2333
|
return _defineProperty({}, path, [{
|
2336
2334
|
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
2337
|
-
value: src
|
2335
|
+
value: src,
|
2336
|
+
fixes: ["image:check-metadata"]
|
2338
2337
|
}]);
|
2339
2338
|
}
|
2340
2339
|
if (fileMimeType && mimeType && fileMimeType !== mimeType) {
|
2341
2340
|
return _defineProperty({}, path, [{
|
2342
2341
|
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
2343
|
-
value: src
|
2342
|
+
value: src,
|
2343
|
+
fixes: ["image:check-metadata"]
|
2344
2344
|
}]);
|
2345
2345
|
}
|
2346
2346
|
if (src.metadata) {
|
@@ -2356,7 +2356,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2356
2356
|
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 the mime type.",
|
2357
2357
|
// 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.
|
2358
2358
|
value: src,
|
2359
|
-
fixes: ["image:
|
2359
|
+
fixes: ["image:check-metadata"]
|
2360
2360
|
}]);
|
2361
2361
|
}
|
2362
2362
|
return _defineProperty({}, path, [{
|
@@ -2431,7 +2431,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2431
2431
|
}
|
2432
2432
|
}]);
|
2433
2433
|
}(Schema);
|
2434
|
-
var image
|
2434
|
+
var image = function image(options) {
|
2435
2435
|
return new ImageSchema(options);
|
2436
2436
|
};
|
2437
2437
|
|
@@ -3399,8 +3399,8 @@ function initSchema() {
|
|
3399
3399
|
number: number,
|
3400
3400
|
union: union,
|
3401
3401
|
// oneOf,
|
3402
|
-
richtext: richtext
|
3403
|
-
image: image
|
3402
|
+
richtext: richtext,
|
3403
|
+
image: image,
|
3404
3404
|
literal: literal,
|
3405
3405
|
keyOf: keyOf,
|
3406
3406
|
record: record,
|
@@ -3410,257 +3410,61 @@ function initSchema() {
|
|
3410
3410
|
};
|
3411
3411
|
}
|
3412
3412
|
|
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
|
3413
|
+
/**
|
3414
|
+
* A image source represents the path to a (local) image.
|
3415
|
+
*
|
3416
|
+
*/
|
3636
3417
|
|
3637
|
-
|
3418
|
+
var initImage = function initImage(config) {
|
3419
|
+
var _config$files$directo, _config$files;
|
3420
|
+
(_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
3421
|
|
3639
|
-
|
3422
|
+
/**
|
3423
|
+
* Define the source of an image file.
|
3424
|
+
*
|
3425
|
+
* @example
|
3426
|
+
* c.image("/public/val/example.png", {
|
3427
|
+
* width: 944,
|
3428
|
+
* height: 944,
|
3429
|
+
* mimeType: "image/png",
|
3430
|
+
*})
|
3431
|
+
*
|
3432
|
+
* @param ref /public/val/example.png
|
3433
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3434
|
+
*/
|
3640
3435
|
|
3641
|
-
/**
|
3642
|
-
|
3643
|
-
|
3436
|
+
/**
|
3437
|
+
* Define the source of an image file.
|
3438
|
+
*
|
3439
|
+
* NOTE: this will **not** validate since metadata has not been defined.
|
3440
|
+
*
|
3441
|
+
* Run `npx -p @valbuild/cli val validate --fix` to automatically add metadata.
|
3442
|
+
*
|
3443
|
+
* @example
|
3444
|
+
* c.image("/public/val/example.png")
|
3445
|
+
*
|
3446
|
+
* @param ref /public/val/example.png
|
3447
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3448
|
+
*/
|
3644
3449
|
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3450
|
+
/**
|
3451
|
+
* Define the source of an image file.
|
3452
|
+
*
|
3453
|
+
* @example
|
3454
|
+
* c.image("/public/val/example.png", {
|
3455
|
+
* width: 944,
|
3456
|
+
* height: 944,
|
3457
|
+
* mimeType: "image/png",
|
3458
|
+
*})
|
3459
|
+
*
|
3460
|
+
* @param ref /public/val/example.png
|
3461
|
+
* @param metadata Image metadata: width, height, mimeType and optionally a hotspot.
|
3462
|
+
*/
|
3463
|
+
function image(ref, metadata) {
|
3464
|
+
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), FILE_REF_SUBTYPE_TAG, "image"), "metadata", metadata);
|
3648
3465
|
}
|
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
|
-
}
|
3466
|
+
return image;
|
3467
|
+
};
|
3664
3468
|
|
3665
3469
|
/* eslint-disable @typescript-eslint/ban-types */
|
3666
3470
|
// import { i18n, I18n } from "./source/future/i18n";
|
@@ -3701,11 +3505,7 @@ var initVal = function initVal(config) {
|
|
3701
3505
|
define: define,
|
3702
3506
|
// remote,
|
3703
3507
|
file: initFile(config),
|
3704
|
-
|
3705
|
-
rt: {
|
3706
|
-
image: image,
|
3707
|
-
link: link
|
3708
|
-
}
|
3508
|
+
image: initImage(config)
|
3709
3509
|
},
|
3710
3510
|
s: s,
|
3711
3511
|
config: config
|
@@ -5187,4 +4987,4 @@ function tryJsonParse(str) {
|
|
5187
4987
|
}
|
5188
4988
|
}
|
5189
4989
|
|
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,
|
4990
|
+
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 };
|