@valbuild/core 0.13.1 → 0.13.4
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 +7 -4
- package/dist/declarations/src/initSchema.d.ts +1 -1
- package/dist/declarations/src/initVal.d.ts +2 -0
- package/dist/declarations/src/module.d.ts +3 -2
- package/dist/declarations/src/schema/richtext.d.ts +4 -64
- package/dist/declarations/src/selector/index.d.ts +3 -2
- package/dist/declarations/src/source/index.d.ts +3 -2
- package/dist/declarations/src/source/remote.d.ts +2 -2
- package/dist/declarations/src/source/richtext.d.ts +63 -0
- package/dist/declarations/src/val/index.d.ts +1 -0
- package/dist/{index-2f1631cf.cjs.prod.js → index-01a259ae.cjs.prod.js} +4 -0
- package/dist/{index-55916dcd.esm.js → index-3b733a02.esm.js} +4 -1
- package/dist/{index-b49a2c60.cjs.dev.js → index-f0d4530a.cjs.dev.js} +4 -0
- package/dist/valbuild-core.cjs.dev.js +24 -262
- package/dist/valbuild-core.cjs.prod.js +24 -262
- package/dist/valbuild-core.esm.js +26 -263
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +3 -1
- package/src/index.ts +15 -12
- package/src/initVal.ts +5 -1
- package/src/module.ts +2 -5
- package/src/schema/richtext.ts +6 -385
- package/src/selector/index.ts +4 -0
- package/src/source/index.ts +3 -1
- package/src/source/remote.ts +2 -2
- package/src/source/richtext.ts +116 -0
- package/src/val/index.ts +10 -0
- package/README.md +0 -525
package/src/schema/richtext.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
2
|
import { Schema, SerializedSchema } from ".";
|
3
|
-
import {
|
4
|
-
import { VAL_EXTENSION } from "../source";
|
3
|
+
import { RichTextSource } from "../source/richtext";
|
5
4
|
import { SourcePath } from "../val";
|
6
5
|
|
7
6
|
export type SerializedRichTextSchema = {
|
@@ -9,89 +8,9 @@ export type SerializedRichTextSchema = {
|
|
9
8
|
opt: boolean;
|
10
9
|
};
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
type NodeType = Node & {
|
17
|
-
format: FormatType;
|
18
|
-
direction: DirectionType;
|
19
|
-
indent: number;
|
20
|
-
};
|
21
|
-
|
22
|
-
type FormatType =
|
23
|
-
| "left"
|
24
|
-
| "start"
|
25
|
-
| "center"
|
26
|
-
| "right"
|
27
|
-
| "end"
|
28
|
-
| "justify"
|
29
|
-
| "";
|
30
|
-
type DirectionType = "ltr" | "rtl" | null;
|
31
|
-
|
32
|
-
export type TextNode = Node & {
|
33
|
-
format: FormatType | number;
|
34
|
-
detail: number;
|
35
|
-
mode: "normal" | "code" | "quote";
|
36
|
-
style: string;
|
37
|
-
text: string;
|
38
|
-
type: "text";
|
39
|
-
direction?: DirectionType;
|
40
|
-
indent?: number;
|
41
|
-
};
|
42
|
-
|
43
|
-
export type ImageNode = Node & {
|
44
|
-
altText: string;
|
45
|
-
height: number;
|
46
|
-
width: number;
|
47
|
-
maxWidth: number;
|
48
|
-
src: string;
|
49
|
-
type: "image";
|
50
|
-
};
|
51
|
-
|
52
|
-
export type ParagraphNode<VN = TextNode> = NodeType & {
|
53
|
-
children: (TextNode | VN)[];
|
54
|
-
type: "paragraph";
|
55
|
-
};
|
56
|
-
|
57
|
-
export type HeadingNode<HT extends HeadingTags = HeadingTags> = NodeType & {
|
58
|
-
children: TextNode[];
|
59
|
-
type: "heading";
|
60
|
-
tag: HT;
|
61
|
-
};
|
62
|
-
|
63
|
-
export type ListItemNode<VN = TextNode> = NodeType & {
|
64
|
-
children: (TextNode | VN)[];
|
65
|
-
type: "listitem";
|
66
|
-
value: number;
|
67
|
-
checked?: boolean;
|
68
|
-
};
|
69
|
-
|
70
|
-
export type ListNode<VN = TextNode> = NodeType & {
|
71
|
-
children: ListItemNode<VN>[];
|
72
|
-
type: "list";
|
73
|
-
tag: "ol" | "ul";
|
74
|
-
listType: "number" | "bullet" | "check";
|
75
|
-
start?: number;
|
76
|
-
};
|
77
|
-
|
78
|
-
type HeadingTags = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
79
|
-
export type RootNode<HT extends HeadingTags, VN> = Node & {
|
80
|
-
children: (HeadingNode<HT> | ParagraphNode<VN> | ListNode<VN>)[];
|
81
|
-
type: "root";
|
82
|
-
format: FormatType;
|
83
|
-
direction: DirectionType;
|
84
|
-
indent: number;
|
85
|
-
};
|
86
|
-
|
87
|
-
type ValNode = ImageNode;
|
88
|
-
|
89
|
-
export type RichText<
|
90
|
-
HT extends HeadingTags = HeadingTags,
|
91
|
-
VN extends TextNode | ValNode = TextNode
|
92
|
-
> = RootNode<HT, VN>;
|
93
|
-
|
94
|
-
export class RichTextSchema<Src extends RichText | null> extends Schema<Src> {
|
11
|
+
export class RichTextSchema<
|
12
|
+
Src extends RichTextSource | null
|
13
|
+
> extends Schema<Src> {
|
95
14
|
validate(src: Src): false | Record<SourcePath, string[]> {
|
96
15
|
throw new Error("Method not implemented.");
|
97
16
|
}
|
@@ -100,7 +19,7 @@ export class RichTextSchema<Src extends RichText | null> extends Schema<Src> {
|
|
100
19
|
return true;
|
101
20
|
}
|
102
21
|
|
103
|
-
optional(): Schema<
|
22
|
+
optional(): Schema<RichTextSource | null> {
|
104
23
|
return new RichTextSchema(true);
|
105
24
|
}
|
106
25
|
serialize(): SerializedSchema {
|
@@ -114,304 +33,6 @@ export class RichTextSchema<Src extends RichText | null> extends Schema<Src> {
|
|
114
33
|
}
|
115
34
|
}
|
116
35
|
|
117
|
-
export const richtext = (): Schema<
|
36
|
+
export const richtext = (): Schema<RichTextSource> => {
|
118
37
|
return new RichTextSchema();
|
119
38
|
};
|
120
|
-
|
121
|
-
{
|
122
|
-
const a = content("/test/richtext1", richtext(), {
|
123
|
-
children: [
|
124
|
-
{
|
125
|
-
children: [
|
126
|
-
{
|
127
|
-
detail: 0,
|
128
|
-
format: 0,
|
129
|
-
mode: "normal",
|
130
|
-
style: "",
|
131
|
-
text: "Heading 1",
|
132
|
-
type: "text",
|
133
|
-
version: 1,
|
134
|
-
},
|
135
|
-
],
|
136
|
-
direction: "ltr",
|
137
|
-
format: "",
|
138
|
-
indent: 0,
|
139
|
-
type: "heading",
|
140
|
-
version: 1,
|
141
|
-
tag: "h1",
|
142
|
-
},
|
143
|
-
{
|
144
|
-
children: [
|
145
|
-
{
|
146
|
-
detail: 0,
|
147
|
-
format: 0,
|
148
|
-
mode: "normal",
|
149
|
-
style: "",
|
150
|
-
text: "Heading 2",
|
151
|
-
type: "text",
|
152
|
-
version: 1,
|
153
|
-
},
|
154
|
-
],
|
155
|
-
direction: "ltr",
|
156
|
-
format: "",
|
157
|
-
indent: 0,
|
158
|
-
type: "heading",
|
159
|
-
version: 1,
|
160
|
-
tag: "h2",
|
161
|
-
},
|
162
|
-
{
|
163
|
-
children: [],
|
164
|
-
direction: "ltr",
|
165
|
-
format: "",
|
166
|
-
indent: 0,
|
167
|
-
type: "paragraph",
|
168
|
-
version: 1,
|
169
|
-
},
|
170
|
-
{
|
171
|
-
children: [
|
172
|
-
{
|
173
|
-
detail: 0,
|
174
|
-
format: 0,
|
175
|
-
mode: "normal",
|
176
|
-
style: "",
|
177
|
-
text: "Normal",
|
178
|
-
type: "text",
|
179
|
-
version: 1,
|
180
|
-
},
|
181
|
-
],
|
182
|
-
direction: "ltr",
|
183
|
-
format: "",
|
184
|
-
indent: 0,
|
185
|
-
type: "paragraph",
|
186
|
-
version: 1,
|
187
|
-
},
|
188
|
-
{
|
189
|
-
children: [
|
190
|
-
{
|
191
|
-
detail: 0,
|
192
|
-
format: 0,
|
193
|
-
mode: "normal",
|
194
|
-
style: "font-size: 20px;",
|
195
|
-
text: "Normal Font size 20",
|
196
|
-
type: "text",
|
197
|
-
version: 1,
|
198
|
-
},
|
199
|
-
],
|
200
|
-
direction: "ltr",
|
201
|
-
format: "",
|
202
|
-
indent: 0,
|
203
|
-
type: "paragraph",
|
204
|
-
version: 1,
|
205
|
-
},
|
206
|
-
{
|
207
|
-
children: [
|
208
|
-
{
|
209
|
-
detail: 0,
|
210
|
-
format: 0,
|
211
|
-
mode: "normal",
|
212
|
-
style: "font-family: serif;",
|
213
|
-
text: "Normal font type serif",
|
214
|
-
type: "text",
|
215
|
-
version: 1,
|
216
|
-
},
|
217
|
-
],
|
218
|
-
direction: "ltr",
|
219
|
-
format: "",
|
220
|
-
indent: 0,
|
221
|
-
type: "paragraph",
|
222
|
-
version: 1,
|
223
|
-
},
|
224
|
-
{
|
225
|
-
children: [
|
226
|
-
{
|
227
|
-
detail: 0,
|
228
|
-
format: 1,
|
229
|
-
mode: "normal",
|
230
|
-
style: "font-family: serif;",
|
231
|
-
text: "Serif and bold",
|
232
|
-
type: "text",
|
233
|
-
version: 1,
|
234
|
-
},
|
235
|
-
],
|
236
|
-
direction: "ltr",
|
237
|
-
format: "",
|
238
|
-
indent: 0,
|
239
|
-
type: "paragraph",
|
240
|
-
version: 1,
|
241
|
-
},
|
242
|
-
{
|
243
|
-
children: [
|
244
|
-
{
|
245
|
-
detail: 0,
|
246
|
-
format: 2,
|
247
|
-
mode: "normal",
|
248
|
-
style: "",
|
249
|
-
text: "Arial and italic",
|
250
|
-
type: "text",
|
251
|
-
version: 1,
|
252
|
-
},
|
253
|
-
],
|
254
|
-
direction: "ltr",
|
255
|
-
format: "",
|
256
|
-
indent: 0,
|
257
|
-
type: "paragraph",
|
258
|
-
version: 1,
|
259
|
-
},
|
260
|
-
{
|
261
|
-
children: [],
|
262
|
-
direction: null,
|
263
|
-
format: "",
|
264
|
-
indent: 0,
|
265
|
-
type: "paragraph",
|
266
|
-
version: 1,
|
267
|
-
},
|
268
|
-
{
|
269
|
-
children: [
|
270
|
-
{
|
271
|
-
children: [
|
272
|
-
{
|
273
|
-
detail: 0,
|
274
|
-
format: 0,
|
275
|
-
mode: "normal",
|
276
|
-
style: "",
|
277
|
-
text: "Num list 1",
|
278
|
-
type: "text",
|
279
|
-
version: 1,
|
280
|
-
},
|
281
|
-
],
|
282
|
-
direction: "ltr",
|
283
|
-
format: "",
|
284
|
-
indent: 0,
|
285
|
-
type: "listitem",
|
286
|
-
version: 1,
|
287
|
-
value: 1,
|
288
|
-
},
|
289
|
-
{
|
290
|
-
children: [
|
291
|
-
{
|
292
|
-
detail: 0,
|
293
|
-
format: 0,
|
294
|
-
mode: "normal",
|
295
|
-
style: "",
|
296
|
-
text: "Num list 2",
|
297
|
-
type: "text",
|
298
|
-
version: 1,
|
299
|
-
},
|
300
|
-
// TODO: image
|
301
|
-
// {
|
302
|
-
// altText: "",
|
303
|
-
// height: 0,
|
304
|
-
// maxWidth: 0,
|
305
|
-
// src: "https://picsum.photos/id/237/200/300",
|
306
|
-
// type: "image",
|
307
|
-
// version: 1,
|
308
|
-
// width: 0,
|
309
|
-
// },
|
310
|
-
],
|
311
|
-
direction: "ltr",
|
312
|
-
format: "",
|
313
|
-
indent: 0,
|
314
|
-
type: "listitem",
|
315
|
-
version: 1,
|
316
|
-
value: 2,
|
317
|
-
},
|
318
|
-
],
|
319
|
-
direction: "ltr",
|
320
|
-
format: "",
|
321
|
-
indent: 0,
|
322
|
-
type: "list",
|
323
|
-
version: 1,
|
324
|
-
listType: "number",
|
325
|
-
start: 1,
|
326
|
-
tag: "ol",
|
327
|
-
},
|
328
|
-
{
|
329
|
-
children: [],
|
330
|
-
direction: null,
|
331
|
-
format: "",
|
332
|
-
indent: 0,
|
333
|
-
type: "paragraph",
|
334
|
-
version: 1,
|
335
|
-
},
|
336
|
-
{
|
337
|
-
children: [
|
338
|
-
{
|
339
|
-
children: [
|
340
|
-
{
|
341
|
-
detail: 0,
|
342
|
-
format: 0,
|
343
|
-
mode: "normal",
|
344
|
-
style: "",
|
345
|
-
text: "Bullet list 1",
|
346
|
-
type: "text",
|
347
|
-
version: 1,
|
348
|
-
},
|
349
|
-
],
|
350
|
-
direction: "ltr",
|
351
|
-
format: "",
|
352
|
-
indent: 0,
|
353
|
-
type: "listitem",
|
354
|
-
version: 1,
|
355
|
-
value: 1,
|
356
|
-
},
|
357
|
-
{
|
358
|
-
children: [
|
359
|
-
{
|
360
|
-
detail: 0,
|
361
|
-
format: 0,
|
362
|
-
mode: "normal",
|
363
|
-
style: "",
|
364
|
-
text: "Bullet list 2",
|
365
|
-
type: "text",
|
366
|
-
version: 1,
|
367
|
-
},
|
368
|
-
],
|
369
|
-
direction: "ltr",
|
370
|
-
format: "",
|
371
|
-
indent: 0,
|
372
|
-
type: "listitem",
|
373
|
-
version: 1,
|
374
|
-
value: 2,
|
375
|
-
},
|
376
|
-
],
|
377
|
-
direction: "ltr",
|
378
|
-
format: "",
|
379
|
-
indent: 0,
|
380
|
-
type: "list",
|
381
|
-
version: 1,
|
382
|
-
listType: "bullet",
|
383
|
-
start: 1,
|
384
|
-
tag: "ul",
|
385
|
-
},
|
386
|
-
{
|
387
|
-
children: [],
|
388
|
-
direction: null,
|
389
|
-
format: "",
|
390
|
-
indent: 0,
|
391
|
-
type: "paragraph",
|
392
|
-
version: 1,
|
393
|
-
},
|
394
|
-
{
|
395
|
-
children: [],
|
396
|
-
direction: "ltr",
|
397
|
-
format: "",
|
398
|
-
indent: 0,
|
399
|
-
type: "paragraph",
|
400
|
-
version: 1,
|
401
|
-
},
|
402
|
-
{
|
403
|
-
children: [],
|
404
|
-
direction: null,
|
405
|
-
format: "",
|
406
|
-
indent: 0,
|
407
|
-
type: "paragraph",
|
408
|
-
version: 1,
|
409
|
-
},
|
410
|
-
],
|
411
|
-
direction: "ltr",
|
412
|
-
format: "",
|
413
|
-
indent: 0,
|
414
|
-
type: "root",
|
415
|
-
version: 1,
|
416
|
-
});
|
417
|
-
}
|
package/src/selector/index.ts
CHANGED
@@ -16,6 +16,7 @@ import { A } from "ts-toolbelt";
|
|
16
16
|
import { I18nSource, I18nCompatibleSource } from "../source/i18n";
|
17
17
|
import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
18
18
|
import { FileSource } from "../source/file";
|
19
|
+
import { RichText, RichTextSource } from "../source/richtext";
|
19
20
|
|
20
21
|
/**
|
21
22
|
* Selectors can be used to select parts of a Val module.
|
@@ -48,6 +49,8 @@ export type Selector<T extends Source> = Source extends T
|
|
48
49
|
: GenericSelector<Source, "Could not determine remote source">
|
49
50
|
: T extends FileSource
|
50
51
|
? FileSelector
|
52
|
+
: T extends RichTextSource
|
53
|
+
? RichText
|
51
54
|
: T extends SourceObject
|
52
55
|
? ObjectSelector<T>
|
53
56
|
: T extends SourceArray
|
@@ -72,6 +75,7 @@ export type SelectorSource =
|
|
72
75
|
| I18nSource<readonly string[], I18nCompatibleSource>
|
73
76
|
| RemoteSource<RemoteCompatibleSource>
|
74
77
|
| FileSource
|
78
|
+
| RichTextSource
|
75
79
|
| GenericSelector<Source>;
|
76
80
|
|
77
81
|
/**
|
package/src/source/index.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { FileSource } from "./file";
|
2
2
|
import { I18nSource, I18nCompatibleSource } from "./i18n";
|
3
3
|
import { RemoteSource, RemoteCompatibleSource } from "./remote";
|
4
|
+
import { RichTextSource } from "./richtext";
|
4
5
|
|
5
6
|
export type Source =
|
6
7
|
| SourcePrimitive
|
@@ -8,7 +9,8 @@ export type Source =
|
|
8
9
|
| SourceArray
|
9
10
|
| I18nSource<string[], I18nCompatibleSource>
|
10
11
|
| RemoteSource<RemoteCompatibleSource>
|
11
|
-
| FileSource
|
12
|
+
| FileSource
|
13
|
+
| RichTextSource;
|
12
14
|
|
13
15
|
export type SourceObject = { [key in string]: Source } & {
|
14
16
|
// TODO: update these restricted parameters:
|
package/src/source/remote.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { SourcePrimitive, VAL_EXTENSION, PhantomType } from ".";
|
2
|
-
import { RichText } from "../schema/richtext";
|
3
2
|
import { FileSource } from "./file";
|
4
3
|
import { I18nCompatibleSource, I18nSource } from "./i18n";
|
4
|
+
import { RichTextSource } from "./richtext";
|
5
5
|
|
6
6
|
/**
|
7
7
|
* Remote sources cannot include other remote sources.
|
@@ -10,7 +10,7 @@ export type RemoteCompatibleSource =
|
|
10
10
|
| SourcePrimitive
|
11
11
|
| RemoteObject
|
12
12
|
| RemoteArray
|
13
|
-
|
|
13
|
+
| RichTextSource
|
14
14
|
| FileSource
|
15
15
|
| I18nSource<string[], I18nCompatibleSource>;
|
16
16
|
export type RemoteObject = { [key in string]: RemoteCompatibleSource };
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { VAL_EXTENSION } from ".";
|
2
|
+
import { SourcePath } from "../val";
|
3
|
+
|
4
|
+
type Node = {
|
5
|
+
version?: 1;
|
6
|
+
};
|
7
|
+
|
8
|
+
type NodeType = Node & {
|
9
|
+
format?: FormatType;
|
10
|
+
direction?: DirectionType;
|
11
|
+
indent?: number;
|
12
|
+
};
|
13
|
+
|
14
|
+
type FormatType =
|
15
|
+
| "left"
|
16
|
+
| "start"
|
17
|
+
| "center"
|
18
|
+
| "right"
|
19
|
+
| "end"
|
20
|
+
| "justify"
|
21
|
+
| "";
|
22
|
+
type DirectionType = "ltr" | "rtl" | null;
|
23
|
+
|
24
|
+
export type TextNode = Node & {
|
25
|
+
type: "text";
|
26
|
+
format?: FormatType | number;
|
27
|
+
detail?: number;
|
28
|
+
mode?: "normal" | "code" | "quote";
|
29
|
+
style?: string;
|
30
|
+
text: string;
|
31
|
+
direction?: DirectionType;
|
32
|
+
indent?: number;
|
33
|
+
};
|
34
|
+
|
35
|
+
export type ParagraphNode<VN = TextNode> = NodeType & {
|
36
|
+
children: (TextNode | VN)[];
|
37
|
+
type: "paragraph";
|
38
|
+
};
|
39
|
+
|
40
|
+
export type HeadingNode<HT extends HeadingTags = HeadingTags> = NodeType & {
|
41
|
+
children: TextNode[];
|
42
|
+
type: "heading";
|
43
|
+
tag: HT;
|
44
|
+
};
|
45
|
+
|
46
|
+
export type ListItemNode<VN = TextNode> = NodeType & {
|
47
|
+
children: (TextNode | VN)[];
|
48
|
+
type: "listitem";
|
49
|
+
value: number;
|
50
|
+
checked?: boolean;
|
51
|
+
};
|
52
|
+
|
53
|
+
export type ListNode<VN = TextNode> = NodeType & {
|
54
|
+
children: ListItemNode<VN>[];
|
55
|
+
type: "list";
|
56
|
+
tag: "ol" | "ul";
|
57
|
+
listType: "number" | "bullet" | "check";
|
58
|
+
start?: number;
|
59
|
+
};
|
60
|
+
|
61
|
+
type HeadingTags = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
62
|
+
export type RootNode<HT extends HeadingTags, VN> = Node & {
|
63
|
+
children: (HeadingNode<HT> | ParagraphNode<VN> | ListNode<VN>)[];
|
64
|
+
type?: "root";
|
65
|
+
format?: FormatType;
|
66
|
+
direction?: DirectionType;
|
67
|
+
indent?: number;
|
68
|
+
};
|
69
|
+
|
70
|
+
const brand = Symbol("richtext");
|
71
|
+
export type RichText<
|
72
|
+
HT extends HeadingTags = HeadingTags,
|
73
|
+
VN extends TextNode = TextNode
|
74
|
+
> = RootNode<HT, VN> & {
|
75
|
+
[brand]: "richtext";
|
76
|
+
valPath: SourcePath;
|
77
|
+
};
|
78
|
+
|
79
|
+
export type RichTextSource = RichText & {
|
80
|
+
readonly [VAL_EXTENSION]: "richtext";
|
81
|
+
};
|
82
|
+
|
83
|
+
export function richtext(
|
84
|
+
data: RootNode<HeadingTags, TextNode> | string
|
85
|
+
): RichTextSource {
|
86
|
+
if (typeof data === "string") {
|
87
|
+
return {
|
88
|
+
[VAL_EXTENSION]: "richtext",
|
89
|
+
type: "root",
|
90
|
+
children: [
|
91
|
+
{
|
92
|
+
type: "paragraph",
|
93
|
+
children: [
|
94
|
+
{
|
95
|
+
type: "text",
|
96
|
+
text: data,
|
97
|
+
},
|
98
|
+
],
|
99
|
+
},
|
100
|
+
],
|
101
|
+
} as RichTextSource;
|
102
|
+
}
|
103
|
+
return {
|
104
|
+
...data,
|
105
|
+
[VAL_EXTENSION]: "richtext",
|
106
|
+
} as RichTextSource;
|
107
|
+
}
|
108
|
+
|
109
|
+
export function isRichText(obj: unknown): obj is RichTextSource {
|
110
|
+
return (
|
111
|
+
typeof obj === "object" &&
|
112
|
+
obj !== null &&
|
113
|
+
VAL_EXTENSION in obj &&
|
114
|
+
obj[VAL_EXTENSION] === "richtext"
|
115
|
+
);
|
116
|
+
}
|
package/src/val/index.ts
CHANGED
@@ -52,6 +52,16 @@ export type Val<T extends Json> = Json extends T
|
|
52
52
|
? PrimitiveVal<T>
|
53
53
|
: never;
|
54
54
|
|
55
|
+
export function isVal<T extends Json>(val: unknown): val is Val<T> {
|
56
|
+
return (
|
57
|
+
typeof val === "object" &&
|
58
|
+
val !== null &&
|
59
|
+
val !== undefined &&
|
60
|
+
Path in val &&
|
61
|
+
"val" in val
|
62
|
+
);
|
63
|
+
}
|
64
|
+
|
55
65
|
declare const brand: unique symbol;
|
56
66
|
/**
|
57
67
|
* The path of the source value.
|