@valbuild/core 0.20.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/declarations/src/index.d.ts +3 -3
  2. package/dist/declarations/src/initVal.d.ts +2 -0
  3. package/dist/declarations/src/source/link.d.ts +9 -0
  4. package/dist/declarations/src/source/richtext.d.ts +44 -30
  5. package/dist/{index-601a7d73.cjs.prod.js → index-067cff4a.cjs.prod.js} +1 -1
  6. package/dist/{index-a6e642dd.cjs.dev.js → index-31991dd7.cjs.dev.js} +3 -0
  7. package/dist/{index-bccf1907.esm.js → index-4bb14a92.esm.js} +4 -1
  8. package/dist/{index-8706c87e.cjs.prod.js → index-75b79c89.cjs.prod.js} +3 -0
  9. package/dist/{index-5d1ab97c.esm.js → index-870205b5.esm.js} +1 -1
  10. package/dist/{index-486c7fbf.cjs.dev.js → index-d17f9503.cjs.dev.js} +1 -1
  11. package/dist/{ops-b0a33248.cjs.dev.js → ops-0f7617a0.cjs.dev.js} +1 -1
  12. package/dist/{ops-def81fc3.cjs.prod.js → ops-451ffb3f.cjs.prod.js} +1 -1
  13. package/dist/{ops-22b624eb.esm.js → ops-9b396073.esm.js} +1 -1
  14. package/dist/valbuild-core.cjs.dev.js +39 -159
  15. package/dist/valbuild-core.cjs.prod.js +39 -159
  16. package/dist/valbuild-core.esm.js +40 -140
  17. package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
  18. package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
  19. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  20. package/package.json +2 -4
  21. package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -2
  22. package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -2
  23. package/patch/dist/valbuild-core-patch.esm.js +3 -3
  24. package/src/index.ts +4 -4
  25. package/src/initVal.ts +3 -0
  26. package/src/schema/image.ts +5 -0
  27. package/src/source/link.ts +14 -0
  28. package/src/source/richtext.ts +91 -234
  29. package/src/source/richtext.test.ts +0 -178
@@ -1,10 +1,12 @@
1
1
  export { initVal } from "./initVal.js";
2
2
  export type { InitVal } from "./initVal.js";
3
3
  export { Schema, type SerializedSchema } from "./schema/index.js";
4
+ export type { ImageMetadata } from "./schema/image.js";
5
+ export type { LinkSource } from "./source/link.js";
4
6
  export type { ValModule, SerializedModule } from "./module.js";
5
7
  export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
6
8
  export type { FileSource } from "./source/file.js";
7
- export type { AnyRichTextOptions, Bold, Classes, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, OrderedListNode, ParagraphNode, RichText, RichTextNode, RichTextOptions, RichTextSource, RichTextSourceNode, RootNode, SourceNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
9
+ 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";
8
10
  export { type Val, type SerializedVal, type ModuleId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
9
11
  export type { Json, JsonPrimitive } from "./Json.js";
10
12
  export type { ValidationErrors, ValidationError, } from "./schema/validation/ValidationError.js";
@@ -21,7 +23,6 @@ import { createValPathOfItem } from "./selector/SelectorProxy.js";
21
23
  import { getVal } from "./future/fetchVal.js";
22
24
  import { Json } from "./Json.js";
23
25
  import { SerializedSchema } from "./schema/index.js";
24
- import { convertRichTextSource } from "./source/richtext.js";
25
26
  export { ValApi } from "./ValApi.js";
26
27
  export type ApiTreeResponse = {
27
28
  git: {
@@ -43,7 +44,6 @@ declare const Internal: {
43
44
  url: string;
44
45
  metadata?: import("./schema/image.js").ImageMetadata;
45
46
  };
46
- convertRichTextSource: typeof convertRichTextSource;
47
47
  getSchema: typeof getSchema;
48
48
  getValPath: typeof getValPath;
49
49
  getVal: typeof getVal;
@@ -3,10 +3,12 @@ import { InitSchema } from "./initSchema.js";
3
3
  import { getValPath as getPath } from "./val/index.js";
4
4
  import { file } from "./source/file.js";
5
5
  import { richtext } from "./source/richtext.js";
6
+ import { link } from "./source/link.js";
6
7
  type ValConstructor = {
7
8
  content: typeof content;
8
9
  getPath: typeof getPath;
9
10
  file: typeof file;
11
+ link: typeof link;
10
12
  richtext: typeof richtext;
11
13
  };
12
14
  export type InitVal = {
@@ -0,0 +1,9 @@
1
+ import { VAL_EXTENSION } from "./index.js";
2
+ export type LinkSource = {
3
+ [VAL_EXTENSION]: "link";
4
+ href: string;
5
+ children: [string];
6
+ };
7
+ export declare function link(text: string, { href }: {
8
+ href: string;
9
+ }): LinkSource;
@@ -1,36 +1,61 @@
1
1
  import { FileSource } from "./file.js";
2
2
  import { VAL_EXTENSION } from "./index.js";
3
+ import { LinkSource } from "./link.js";
4
+ import { ImageMetadata } from "../schema/image.js";
3
5
  export type RichTextOptions = {
4
6
  headings?: ("h1" | "h2" | "h3" | "h4" | "h5" | "h6")[];
5
7
  img?: boolean;
8
+ a?: boolean;
6
9
  ul?: boolean;
7
10
  ol?: boolean;
8
11
  lineThrough?: boolean;
9
12
  bold?: boolean;
10
13
  italic?: boolean;
11
14
  };
12
- export type ParagraphNode<O extends RichTextOptions> = {
13
- tag: "p";
14
- children: (string | SpanNode<O>)[];
15
+ export type AnyRichTextOptions = {
16
+ headings: ("h1" | "h2" | "h3" | "h4" | "h5" | "h6")[];
17
+ img: true;
18
+ a: true;
19
+ ul: true;
20
+ ol: true;
21
+ lineThrough: true;
22
+ bold: true;
23
+ italic: true;
15
24
  };
16
25
  export type LineThrough<O extends RichTextOptions> = O["lineThrough"] extends true ? "line-through" : never;
17
26
  export type Italic<O extends RichTextOptions> = O["italic"] extends true ? "italic" : never;
18
27
  export type Bold<O extends RichTextOptions> = O["bold"] extends true ? "bold" : never;
19
28
  export type Classes<O extends RichTextOptions> = LineThrough<O> | Italic<O> | Bold<O>;
29
+ export type ParagraphNode<O extends RichTextOptions> = {
30
+ tag: "p";
31
+ children: (string | SpanNode<O> | BrNode | LinkNode<O> | ImageNode<O>)[];
32
+ };
33
+ export type BrNode = {
34
+ tag: "br";
35
+ children: [];
36
+ };
20
37
  export type SpanNode<O extends RichTextOptions> = {
21
38
  tag: "span";
22
39
  classes: Classes<O>[];
23
40
  children: [string | SpanNode<O>];
24
41
  };
25
- export type ImageNode<O extends RichTextOptions> = O["img"] extends true ? {
42
+ type ImageTagNode = {
26
43
  tag: "img";
27
44
  src: string;
28
45
  height?: number;
29
46
  width?: number;
30
- } : never;
47
+ children: [];
48
+ };
49
+ export type ImageNode<O extends RichTextOptions> = O["img"] extends true ? ImageTagNode : never;
50
+ type LinkTagNode<O extends RichTextOptions> = {
51
+ tag: "a";
52
+ href: string;
53
+ children: (string | SpanNode<O>)[];
54
+ };
55
+ export type LinkNode<O extends RichTextOptions> = O["a"] extends true ? LinkTagNode<O> : never;
31
56
  export type ListItemNode<O extends RichTextOptions> = {
32
57
  tag: "li";
33
- children: (string | SpanNode<O> | UnorderedListNode<O> | OrderedListNode<O>)[];
58
+ children: (string | SpanNode<O> | LinkNode<O> | BrNode | UnorderedListNode<O> | OrderedListNode<O>)[];
34
59
  };
35
60
  export type UnorderedListNode<O extends RichTextOptions> = O["ul"] extends true ? {
36
61
  tag: "ul";
@@ -42,38 +67,27 @@ export type OrderedListNode<O extends RichTextOptions> = O["ol"] extends true ?
42
67
  dir?: "ltr" | "rtl";
43
68
  children: ListItemNode<O>[];
44
69
  } : never;
45
- export type HeadingNode<O extends RichTextOptions> = O["headings"] extends any[] ? {
70
+ export type HeadingNode<O extends RichTextOptions> = O["headings"] extends ("h1" | "h2" | "h3" | "h4" | "h5" | "h6")[] ? {
46
71
  tag: O["headings"][number];
47
72
  children: (string | SpanNode<O>)[];
48
73
  } : never;
49
- type ImageSource = FileSource<{
50
- width: number;
51
- height: number;
52
- sha256: string;
53
- }>;
54
- export type SourceNode<O extends RichTextOptions> = O["img"] extends true ? ImageSource : never;
55
- export type AnyRichTextOptions = {
56
- headings: ("h1" | "h2" | "h3" | "h4" | "h5" | "h6")[];
57
- img: true;
58
- ul: true;
59
- ol: true;
60
- lineThrough: true;
61
- bold: true;
62
- italic: true;
63
- };
64
- export type RichTextSourceNode<O extends RichTextOptions> = Exclude<RichTextNode<O>, {
65
- tag: "img";
66
- }> | SourceNode<O>;
74
+ export type RichTextNode<O extends RichTextOptions> = string | RootNode<O> | ListItemNode<O> | BrNode | SpanNode<O> | LinkNode<O> | ImageNode<O>;
75
+ export type RootNode<O extends RichTextOptions> = HeadingNode<O> | ParagraphNode<O> | BrNode | UnorderedListNode<O> | OrderedListNode<O>;
76
+ /**
77
+ * RichTextSource is defined in ValModules
78
+ **/
67
79
  export type RichTextSource<O extends RichTextOptions> = {
68
80
  [VAL_EXTENSION]: "richtext";
69
- children: (HeadingNode<O> | ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O> | SourceNode<O>)[];
81
+ templateStrings: string[];
82
+ exprs: ((O["img"] extends true ? FileSource<ImageMetadata> : never) | (O["a"] extends true ? LinkSource : never))[];
70
83
  };
71
- export type RichTextNode<O extends RichTextOptions> = string | HeadingNode<O> | ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O> | ListItemNode<O> | SpanNode<O> | ImageNode<O>;
72
- export type RootNode<O extends RichTextOptions> = HeadingNode<O> | ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O> | ImageNode<O>;
84
+ /**
85
+ * RichText is accessible by users (after conversion via useVal / fetchVal)
86
+ * Internally it is a Selector
87
+ **/
73
88
  export type RichText<O extends RichTextOptions> = {
74
89
  [VAL_EXTENSION]: "richtext";
75
90
  children: RootNode<O>[];
76
91
  };
77
- export declare function convertRichTextSource<O extends RichTextOptions>(src: RichTextSource<O>): RichText<O>;
78
- export declare function richtext<O extends RichTextOptions, Nodes extends never | ImageSource>(templateStrings: TemplateStringsArray, ...expr: Nodes[]): RichTextSource<O>;
92
+ export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (FileSource<ImageMetadata> | LinkSource)[]): RichTextSource<O>;
79
93
  export {};
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-8706c87e.cjs.prod.js');
3
+ var index$1 = require('./index-75b79c89.cjs.prod.js');
4
4
  var result = require('./result-26f67b40.cjs.prod.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -511,6 +511,9 @@ var image = function image(options) {
511
511
  var convertFileSource = function convertFileSource(src) {
512
512
  var _src$metadata;
513
513
  // TODO: /public should be configurable
514
+ if (!src[FILE_REF_PROP].startsWith("/public")) {
515
+ throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
516
+ }
514
517
  return {
515
518
  url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
516
519
  metadata: src.metadata
@@ -509,6 +509,9 @@ var image = function image(options) {
509
509
  var convertFileSource = function convertFileSource(src) {
510
510
  var _src$metadata;
511
511
  // TODO: /public should be configurable
512
+ if (!src[FILE_REF_PROP].startsWith("/public")) {
513
+ throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
514
+ }
512
515
  return {
513
516
  url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
514
517
  metadata: src.metadata
@@ -547,4 +550,4 @@ function getValPath(valOrSelector) {
547
550
  return valOrSelector[Path];
548
551
  }
549
552
 
550
- export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, ImageSchema as I, 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, convertFileSource as f, getValPath as g, file as h, image as i, _objectSpread2 as j, _slicedToArray as k, isFile as l, GetSource as m, isSerializedVal as n, getSchema as o, isVal as p, GenericSelector as q, Sym as r, StringLiteral as s, StringTemplate as t, _toConsumableArray as u };
553
+ export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, ImageSchema as I, 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, _objectSpread2 as h, image as i, _slicedToArray as j, isFile as k, GetSource as l, isSerializedVal as m, convertFileSource as n, getSchema as o, isVal as p, GenericSelector as q, Sym as r, StringLiteral as s, StringTemplate as t, _toConsumableArray as u };
@@ -511,6 +511,9 @@ var image = function image(options) {
511
511
  var convertFileSource = function convertFileSource(src) {
512
512
  var _src$metadata;
513
513
  // TODO: /public should be configurable
514
+ if (!src[FILE_REF_PROP].startsWith("/public")) {
515
+ throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
516
+ }
514
517
  return {
515
518
  url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
516
519
  metadata: src.metadata
@@ -1,4 +1,4 @@
1
- import { j as _objectSpread2, k as _slicedToArray, c as _createClass, b as _classCallCheck, r as Sym, C as Call, s as StringLiteral, t as StringTemplate, e as _typeof, n as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, f as convertFileSource, d as _defineProperty, S as Schema, E as Expr, u as _toConsumableArray, N as NilSym } from './index-bccf1907.esm.js';
1
+ import { h as _objectSpread2, j as _slicedToArray, c as _createClass, b as _classCallCheck, r as Sym, C as Call, s as StringLiteral, t as StringTemplate, e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, S as Schema, E as Expr, u as _toConsumableArray, N as NilSym } from './index-4bb14a92.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", " "];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-a6e642dd.cjs.dev.js');
3
+ var index$1 = require('./index-31991dd7.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-a6e642dd.cjs.dev.js');
3
+ var index = require('./index-31991dd7.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  function hasOwn(obj, prop) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-8706c87e.cjs.prod.js');
3
+ var index = require('./index-75b79c89.cjs.prod.js');
4
4
  var result = require('./result-26f67b40.cjs.prod.js');
5
5
 
6
6
  function hasOwn(obj, prop) {
@@ -1,4 +1,4 @@
1
- import { e as _typeof, n as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, f as convertFileSource, d as _defineProperty, m as GetSource, P as Path, G as GetSchema, S as Schema, E as Expr, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, k as _slicedToArray, j as _objectSpread2, u as _toConsumableArray, I as ImageSchema } from './index-bccf1907.esm.js';
1
+ import { e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, l as GetSource, P as Path, G as GetSchema, S as Schema, E as Expr, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, j as _slicedToArray, h as _objectSpread2, u as _toConsumableArray, I as ImageSchema } from './index-4bb14a92.esm.js';
2
2
  import { _ as _createForOfIteratorHelper } from './result-b96df128.esm.js';
3
3
 
4
4
  function hasOwn(obj, prop) {
@@ -2,32 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-a6e642dd.cjs.dev.js');
6
- var ops = require('./ops-b0a33248.cjs.dev.js');
7
- var marked = require('marked');
8
- var expr_dist_valbuildCoreExpr = require('./index-486c7fbf.cjs.dev.js');
5
+ var index = require('./index-31991dd7.cjs.dev.js');
6
+ var ops = require('./ops-0f7617a0.cjs.dev.js');
7
+ var expr_dist_valbuildCoreExpr = require('./index-d17f9503.cjs.dev.js');
9
8
  var result = require('./result-48320acd.cjs.dev.js');
10
9
 
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var marked__namespace = /*#__PURE__*/_interopNamespace(marked);
30
-
31
10
  var NumberSchema = /*#__PURE__*/function (_Schema) {
32
11
  index._inherits(NumberSchema, _Schema);
33
12
  var _super = index._createSuper(NumberSchema);
@@ -394,143 +373,44 @@ function initSchema() {
394
373
  };
395
374
  }
396
375
 
397
- // export type FontFamily<O extends RichTextOptions> =
398
- // O["fontFamily"] extends Record<string, unknown>
399
- // ? `font-${keyof O["fontFamily"] & string}`
400
- // : never;
401
- // export type FontSize<O extends RichTextOptions> = O["fontSize"] extends Record<
402
- // string,
403
- // unknown
404
- // >
405
- // ? `text-${keyof O["fontSize"] & string}`
406
- // : never;
407
- // | FontFamily<O>
408
- // | FontSize<O>;
409
- // export type AnchorNode<O extends RichTextOptions> = never; // TODO:
410
- // O["link"] extends true
411
- // ? {
412
- // tag: "a";
413
- // href: string;
414
- // children: [string];
415
- // }
416
- // : never;
417
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
418
- // export type BlockQuoteNode<O extends RichTextOptions> =
419
- // O["blockQuote"] extends true
420
- // ? { tag: "blockquote"; children: [string] }
421
- // : never;
422
- // TODO: rename to RichTextSelector?
423
- function parseTokens(tokens) {
424
- return tokens.flatMap(function (token) {
425
- if (token.type === "heading") {
426
- return [{
427
- tag: "h".concat(token.depth),
428
- children: parseTokens(token.tokens ? token.tokens : [])
429
- }];
430
- }
431
- if (token.type === "paragraph") {
432
- return [{
433
- tag: "p",
434
- children: parseTokens(token.tokens ? token.tokens : [])
435
- }];
436
- }
437
- if (token.type === "strong") {
438
- return [{
439
- tag: "span",
440
- classes: ["bold"],
441
- children: parseTokens(token.tokens ? token.tokens : [])
442
- }];
443
- }
444
- if (token.type === "em") {
445
- return [{
446
- tag: "span",
447
- classes: ["italic"],
448
- children: parseTokens(token.tokens ? token.tokens : [])
449
- }];
450
- }
451
- if (token.type === "del") {
452
- return [{
453
- tag: "span",
454
- classes: ["line-through"],
455
- children: parseTokens(token.tokens ? token.tokens : [])
456
- }];
457
- }
458
- if (token.type === "text") {
459
- if ("tokens" in token && Array.isArray(token.tokens)) {
460
- return parseTokens(token.tokens);
461
- }
462
- return [token.text];
463
- }
464
- if (token.type === "list") {
465
- return [{
466
- tag: token.ordered ? "ol" : "ul",
467
- children: parseTokens(token.items)
468
- }];
469
- }
470
- if (token.type === "list_item") {
471
- return [{
472
- tag: "li",
473
- children: parseTokens(token.tokens ? token.tokens : [])
474
- }];
475
- }
476
- if (token.type === "space") {
477
- return [];
478
- }
479
- if (token.type === "code") {
480
- return [{
481
- tag: "span",
482
- classes: [],
483
- children: [token.text]
484
- }];
485
- }
486
- // console.error(
487
- // `Could not parse markdown: unsupported token type: ${token.type}. Found: ${token.raw}`
488
- // );
489
- return [token.raw];
490
- });
491
- }
376
+ // Classes
492
377
 
493
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
494
- function nodeToTag(node) {
495
- if (node[index.VAL_EXTENSION] === "file") {
496
- return node;
497
- }
498
- throw Error("Unexpected node: ".concat(JSON.stringify(node)));
499
- }
500
- function imgSrcToImgTag(imageSrc) {
501
- var _imageSrc$metadata, _imageSrc$metadata2;
502
- var converted = index.convertFileSource(imageSrc);
503
- return {
504
- tag: "img",
505
- src: converted.url,
506
- width: (_imageSrc$metadata = imageSrc.metadata) === null || _imageSrc$metadata === void 0 ? void 0 : _imageSrc$metadata.width,
507
- height: (_imageSrc$metadata2 = imageSrc.metadata) === null || _imageSrc$metadata2 === void 0 ? void 0 : _imageSrc$metadata2.height
508
- };
509
- }
510
- function convertRichTextSource(src) {
378
+ /// Paragraph
379
+
380
+ /// Break
381
+
382
+ /// Span
383
+
384
+ /// Image
385
+
386
+ /// Link
387
+
388
+ /// List
389
+
390
+ /// Heading
391
+
392
+ /// Root and nodes
393
+
394
+ /// Main types
395
+ /**
396
+ * RichTextSource is defined in ValModules
397
+ **/
398
+ /**
399
+ * RichText is accessible by users (after conversion via useVal / fetchVal)
400
+ * Internally it is a Selector
401
+ **/
402
+ function richtext(templateStrings) {
511
403
  var _ref;
512
- return _ref = {}, index._defineProperty(_ref, index.VAL_EXTENSION, "richtext"), index._defineProperty(_ref, "children", src.children.map(function (source) {
513
- if (index.VAL_EXTENSION in source && source[index.VAL_EXTENSION] === "file") {
514
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
515
- return imgSrcToImgTag(source);
516
- }
517
- return source;
518
- })), _ref;
404
+ for (var _len = arguments.length, nodes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
405
+ nodes[_key - 1] = arguments[_key];
406
+ }
407
+ return _ref = {}, index._defineProperty(_ref, index.VAL_EXTENSION, "richtext"), index._defineProperty(_ref, "templateStrings", templateStrings), index._defineProperty(_ref, "exprs", nodes), _ref;
519
408
  }
520
- function richtext(templateStrings) {
409
+
410
+ function link(text, _ref) {
521
411
  var _ref2;
522
- for (var _len = arguments.length, expr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
523
- expr[_key - 1] = arguments[_key];
524
- }
525
- return _ref2 = {}, index._defineProperty(_ref2, index.VAL_EXTENSION, "richtext"), index._defineProperty(_ref2, "children", templateStrings.flatMap(function (templateString, i) {
526
- var lex = marked__namespace.lexer(templateString, {
527
- gfm: true
528
- });
529
- if (expr[i]) {
530
- return parseTokens(lex).concat(nodeToTag(expr[i]));
531
- }
532
- return parseTokens(lex);
533
- })), _ref2;
412
+ var href = _ref.href;
413
+ return _ref2 = {}, index._defineProperty(_ref2, index.VAL_EXTENSION, "link"), index._defineProperty(_ref2, "href", href), index._defineProperty(_ref2, "children", [text]), _ref2;
534
414
  }
535
415
 
536
416
  // import { i18n, I18n } from "./source/future/i18n";
@@ -566,7 +446,8 @@ var initVal = function initVal() {
566
446
  // remote,
567
447
  getPath: index.getValPath,
568
448
  file: index.file,
569
- richtext: richtext
449
+ richtext: richtext,
450
+ link: link
570
451
  },
571
452
  s: index._objectSpread2({}, s)
572
453
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1304,7 +1185,6 @@ function _parse() {
1304
1185
 
1305
1186
  var Internal = {
1306
1187
  convertFileSource: index.convertFileSource,
1307
- convertRichTextSource: convertRichTextSource,
1308
1188
  getSchema: index.getSchema,
1309
1189
  getValPath: index.getValPath,
1310
1190
  getVal: getVal,