@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.
@@ -1,5 +1,5 @@
1
- import { _ as _inherits, a as _createSuper, S as Schema, g as getValPath, n as newSelectorProxy, b as SourceOrExpr, E as Expr, I as ImageSchema, c as _objectSpread2, d as _defineProperty, V as VAL_EXTENSION, i as image, P as Path, e as createValPathOfItem, f as isSelector, h as isSerializedVal, j as file, k as isFile, F as FILE_REF_PROP, l as convertImageSource, m as getSchema } from './index-55916dcd.esm.js';
2
- export { F as FILE_REF_PROP, G as GenericSelector, S as Schema, V as VAL_EXTENSION, o as expr } from './index-55916dcd.esm.js';
1
+ import { _ as _inherits, a as _createSuper, S as Schema, g as getValPath, n as newSelectorProxy, b as SourceOrExpr, E as Expr, I as ImageSchema, c as _objectSpread2, d as _defineProperty, V as VAL_EXTENSION, i as image, P as Path, e as createValPathOfItem, f as isSelector, h as isSerializedVal, j as file, k as isFile, F as FILE_REF_PROP, l as convertImageSource, m as getSchema, o as isVal } from './index-3b733a02.esm.js';
2
+ export { F as FILE_REF_PROP, G as GenericSelector, S as Schema, V as VAL_EXTENSION, p as expr } from './index-3b733a02.esm.js';
3
3
  import { _ as _classCallCheck, a as _createClass, b as _typeof, c as _slicedToArray, d as _toConsumableArray } from './createClass-012eebbf.esm.js';
4
4
  import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok } from './result-b96df128.esm.js';
5
5
  import { P as PatchError } from './ops-6fae92a1.esm.js';
@@ -294,264 +294,9 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
294
294
  }]);
295
295
  return RichTextSchema;
296
296
  }(Schema);
297
- var richtext = function richtext() {
297
+ var richtext$1 = function richtext() {
298
298
  return new RichTextSchema();
299
299
  };
300
- {
301
- content("/test/richtext1", richtext(), {
302
- children: [{
303
- children: [{
304
- detail: 0,
305
- format: 0,
306
- mode: "normal",
307
- style: "",
308
- text: "Heading 1",
309
- type: "text",
310
- version: 1
311
- }],
312
- direction: "ltr",
313
- format: "",
314
- indent: 0,
315
- type: "heading",
316
- version: 1,
317
- tag: "h1"
318
- }, {
319
- children: [{
320
- detail: 0,
321
- format: 0,
322
- mode: "normal",
323
- style: "",
324
- text: "Heading 2",
325
- type: "text",
326
- version: 1
327
- }],
328
- direction: "ltr",
329
- format: "",
330
- indent: 0,
331
- type: "heading",
332
- version: 1,
333
- tag: "h2"
334
- }, {
335
- children: [],
336
- direction: "ltr",
337
- format: "",
338
- indent: 0,
339
- type: "paragraph",
340
- version: 1
341
- }, {
342
- children: [{
343
- detail: 0,
344
- format: 0,
345
- mode: "normal",
346
- style: "",
347
- text: "Normal",
348
- type: "text",
349
- version: 1
350
- }],
351
- direction: "ltr",
352
- format: "",
353
- indent: 0,
354
- type: "paragraph",
355
- version: 1
356
- }, {
357
- children: [{
358
- detail: 0,
359
- format: 0,
360
- mode: "normal",
361
- style: "font-size: 20px;",
362
- text: "Normal Font size 20",
363
- type: "text",
364
- version: 1
365
- }],
366
- direction: "ltr",
367
- format: "",
368
- indent: 0,
369
- type: "paragraph",
370
- version: 1
371
- }, {
372
- children: [{
373
- detail: 0,
374
- format: 0,
375
- mode: "normal",
376
- style: "font-family: serif;",
377
- text: "Normal font type serif",
378
- type: "text",
379
- version: 1
380
- }],
381
- direction: "ltr",
382
- format: "",
383
- indent: 0,
384
- type: "paragraph",
385
- version: 1
386
- }, {
387
- children: [{
388
- detail: 0,
389
- format: 1,
390
- mode: "normal",
391
- style: "font-family: serif;",
392
- text: "Serif and bold",
393
- type: "text",
394
- version: 1
395
- }],
396
- direction: "ltr",
397
- format: "",
398
- indent: 0,
399
- type: "paragraph",
400
- version: 1
401
- }, {
402
- children: [{
403
- detail: 0,
404
- format: 2,
405
- mode: "normal",
406
- style: "",
407
- text: "Arial and italic",
408
- type: "text",
409
- version: 1
410
- }],
411
- direction: "ltr",
412
- format: "",
413
- indent: 0,
414
- type: "paragraph",
415
- version: 1
416
- }, {
417
- children: [],
418
- direction: null,
419
- format: "",
420
- indent: 0,
421
- type: "paragraph",
422
- version: 1
423
- }, {
424
- children: [{
425
- children: [{
426
- detail: 0,
427
- format: 0,
428
- mode: "normal",
429
- style: "",
430
- text: "Num list 1",
431
- type: "text",
432
- version: 1
433
- }],
434
- direction: "ltr",
435
- format: "",
436
- indent: 0,
437
- type: "listitem",
438
- version: 1,
439
- value: 1
440
- }, {
441
- children: [{
442
- detail: 0,
443
- format: 0,
444
- mode: "normal",
445
- style: "",
446
- text: "Num list 2",
447
- type: "text",
448
- version: 1
449
- }
450
- // TODO: image
451
- // {
452
- // altText: "",
453
- // height: 0,
454
- // maxWidth: 0,
455
- // src: "https://picsum.photos/id/237/200/300",
456
- // type: "image",
457
- // version: 1,
458
- // width: 0,
459
- // },
460
- ],
461
-
462
- direction: "ltr",
463
- format: "",
464
- indent: 0,
465
- type: "listitem",
466
- version: 1,
467
- value: 2
468
- }],
469
- direction: "ltr",
470
- format: "",
471
- indent: 0,
472
- type: "list",
473
- version: 1,
474
- listType: "number",
475
- start: 1,
476
- tag: "ol"
477
- }, {
478
- children: [],
479
- direction: null,
480
- format: "",
481
- indent: 0,
482
- type: "paragraph",
483
- version: 1
484
- }, {
485
- children: [{
486
- children: [{
487
- detail: 0,
488
- format: 0,
489
- mode: "normal",
490
- style: "",
491
- text: "Bullet list 1",
492
- type: "text",
493
- version: 1
494
- }],
495
- direction: "ltr",
496
- format: "",
497
- indent: 0,
498
- type: "listitem",
499
- version: 1,
500
- value: 1
501
- }, {
502
- children: [{
503
- detail: 0,
504
- format: 0,
505
- mode: "normal",
506
- style: "",
507
- text: "Bullet list 2",
508
- type: "text",
509
- version: 1
510
- }],
511
- direction: "ltr",
512
- format: "",
513
- indent: 0,
514
- type: "listitem",
515
- version: 1,
516
- value: 2
517
- }],
518
- direction: "ltr",
519
- format: "",
520
- indent: 0,
521
- type: "list",
522
- version: 1,
523
- listType: "bullet",
524
- start: 1,
525
- tag: "ul"
526
- }, {
527
- children: [],
528
- direction: null,
529
- format: "",
530
- indent: 0,
531
- type: "paragraph",
532
- version: 1
533
- }, {
534
- children: [],
535
- direction: "ltr",
536
- format: "",
537
- indent: 0,
538
- type: "paragraph",
539
- version: 1
540
- }, {
541
- children: [],
542
- direction: null,
543
- format: "",
544
- indent: 0,
545
- type: "paragraph",
546
- version: 1
547
- }],
548
- direction: "ltr",
549
- format: "",
550
- indent: 0,
551
- type: "root",
552
- version: 1
553
- });
554
- }
555
300
 
556
301
  function content(
557
302
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -938,7 +683,7 @@ function initSchema(locales) {
938
683
  number: number,
939
684
  union: union,
940
685
  oneOf: oneOf,
941
- richtext: richtext,
686
+ richtext: richtext$1,
942
687
  image: image,
943
688
  literal: literal,
944
689
  i18n: i18n$1(locales)
@@ -1105,6 +850,20 @@ function isRemote(obj) {
1105
850
  return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "remote" && REMOTE_REF_PROP in obj && typeof obj[REMOTE_REF_PROP] === "string";
1106
851
  }
1107
852
 
853
+ function richtext(data) {
854
+ if (typeof data === "string") {
855
+ var _ref;
856
+ return _ref = {}, _defineProperty(_ref, VAL_EXTENSION, "richtext"), _defineProperty(_ref, "type", "root"), _defineProperty(_ref, "children", [{
857
+ type: "paragraph",
858
+ children: [{
859
+ type: "text",
860
+ text: data
861
+ }]
862
+ }]), _ref;
863
+ }
864
+ return _objectSpread2(_objectSpread2({}, data), {}, _defineProperty({}, VAL_EXTENSION, "richtext"));
865
+ }
866
+
1108
867
  var initVal = function initVal(options) {
1109
868
  var locales = options === null || options === void 0 ? void 0 : options.locales;
1110
869
  var s = initSchema(locales === null || locales === void 0 ? void 0 : locales.required);
@@ -1117,7 +876,8 @@ var initVal = function initVal(options) {
1117
876
  remote: remote,
1118
877
  getPath: getValPath,
1119
878
  key: getValPath,
1120
- file: file
879
+ file: file,
880
+ richtext: richtext
1121
881
  },
1122
882
  fetchVal: fetchVal,
1123
883
  s: s
@@ -1131,7 +891,8 @@ var initVal = function initVal(options) {
1131
891
  remote: remote,
1132
892
  getPath: getValPath,
1133
893
  key: getValPath,
1134
- file: file
894
+ file: file,
895
+ richtext: richtext
1135
896
  },
1136
897
  fetchVal: fetchVal,
1137
898
  s: _objectSpread2(_objectSpread2({}, s), {}, {
@@ -1259,7 +1020,9 @@ var Internal = {
1259
1020
  getVal: getVal,
1260
1021
  getRawSource: getRawSource,
1261
1022
  resolvePath: resolvePath,
1262
- splitModuleIdAndModulePath: splitModuleIdAndModulePath
1023
+ splitModuleIdAndModulePath: splitModuleIdAndModulePath,
1024
+ fetchVal: fetchVal,
1025
+ isVal: isVal
1263
1026
  };
1264
1027
 
1265
- export { Internal, derefPatch, fetchVal, initVal };
1028
+ export { Internal, derefPatch, initVal };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-b49a2c60.cjs.dev.js');
5
+ var expr_dist_valbuildCoreExpr = require('../../dist/index-f0d4530a.cjs.dev.js');
6
6
  require('../../dist/createClass-a436dbfe.cjs.dev.js');
7
7
  require('../../dist/result-48320acd.cjs.dev.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-2f1631cf.cjs.prod.js');
5
+ var expr_dist_valbuildCoreExpr = require('../../dist/index-01a259ae.cjs.prod.js');
6
6
  require('../../dist/createClass-de7426aa.cjs.prod.js');
7
7
  require('../../dist/result-26f67b40.cjs.prod.js');
8
8
 
@@ -1,3 +1,3 @@
1
- export { C as Call, E as Expr, N as NilSym, q as StringLiteral, r as StringTemplate, s as Sym, t as evaluate, p as parse } from '../../dist/index-55916dcd.esm.js';
1
+ export { C as Call, E as Expr, N as NilSym, r as StringLiteral, s as StringTemplate, t as Sym, u as evaluate, q as parse } from '../../dist/index-3b733a02.esm.js';
2
2
  import '../../dist/createClass-012eebbf.esm.js';
3
3
  import '../../dist/result-b96df128.esm.js';
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.13.1",
3
+ "version": "0.13.4",
4
+ "private": false,
5
+ "description": "Val - supercharged hard-coded content",
4
6
  "scripts": {
5
7
  "typecheck": "tsc --noEmit",
6
8
  "test": "jest",
package/src/index.ts CHANGED
@@ -1,18 +1,28 @@
1
1
  export { initVal } from "./initVal";
2
- export { fetchVal } from "./fetchVal";
3
2
  export type { InitVal } from "./initVal";
4
3
  export { Schema, type SerializedSchema } from "./schema";
5
4
  export type { ValModule, SerializedModule } from "./module";
6
5
  export type { SourceObject, SourcePrimitive, Source } from "./source";
7
6
  export type { FileSource } from "./source/file";
8
7
  export type { RemoteSource } from "./source/remote";
8
+ export type {
9
+ RichTextSource,
10
+ RichText,
11
+ TextNode,
12
+ ParagraphNode,
13
+ HeadingNode,
14
+ ListItemNode,
15
+ ListNode,
16
+ } from "./source/richtext";
9
17
  export {
10
18
  type Val,
11
19
  type SerializedVal,
12
20
  type ModuleId,
13
21
  type ModulePath,
14
22
  type SourcePath,
23
+ type JsonOfSource,
15
24
  } from "./val";
25
+ export { type Json } from "./Json";
16
26
  export * as expr from "./expr/";
17
27
  export { FILE_REF_PROP } from "./source/file";
18
28
  export { VAL_EXTENSION } from "./source";
@@ -29,18 +39,9 @@ import {
29
39
  splitModuleIdAndModulePath,
30
40
  } from "./module";
31
41
  import { getSchema } from "./selector";
32
- import { getValPath } from "./val";
33
- export type {
34
- RichText,
35
- TextNode,
36
- ParagraphNode,
37
- HeadingNode,
38
- ImageNode,
39
- ListItemNode,
40
- ListNode,
41
- RootNode,
42
- } from "./schema/richtext";
42
+ import { getValPath, isVal } from "./val";
43
43
  import { convertImageSource } from "./schema/image";
44
+ import { fetchVal } from "./fetchVal";
44
45
 
45
46
  const Internal = {
46
47
  convertImageSource,
@@ -50,6 +51,8 @@ const Internal = {
50
51
  getRawSource,
51
52
  resolvePath,
52
53
  splitModuleIdAndModulePath,
54
+ fetchVal,
55
+ isVal,
53
56
  };
54
57
 
55
58
  export { Internal };
package/src/initVal.ts CHANGED
@@ -10,13 +10,15 @@ import { JsonOfSource } from "./val";
10
10
  import { fetchVal } from "./fetchVal";
11
11
  import { remote } from "./source/remote";
12
12
  import { file } from "./source/file";
13
+ import { richtext } from "./source/richtext";
13
14
 
14
15
  type ValConstructor = {
15
16
  content: typeof content;
16
- getPath: typeof getPath; // TODO: in the react initVal we should also add a key function here which returns the path for use as react keys
17
+ getPath: typeof getPath;
17
18
  key: typeof getPath;
18
19
  remote: typeof remote;
19
20
  file: typeof file;
21
+ richtext: typeof richtext;
20
22
  };
21
23
  export type InitVal<Locales extends readonly string[] | undefined> = [
22
24
  Locales
@@ -72,6 +74,7 @@ export const initVal = <
72
74
  getPath,
73
75
  key: getPath,
74
76
  file,
77
+ richtext,
75
78
  },
76
79
  fetchVal: fetchVal,
77
80
  s,
@@ -85,6 +88,7 @@ export const initVal = <
85
88
  getPath,
86
89
  key: getPath,
87
90
  file,
91
+ richtext,
88
92
  },
89
93
  fetchVal: fetchVal,
90
94
  s: {
package/src/module.ts CHANGED
@@ -15,17 +15,14 @@ import { I18nSchema, SerializedI18nSchema } from "./schema/i18n";
15
15
  import { UnionSchema, SerializedUnionSchema } from "./schema/union";
16
16
  import { OneOfSchema, SerializedOneOfSchema } from "./schema/oneOf";
17
17
  import { Json } from "./Json";
18
- import {
19
- RichText,
20
- RichTextSchema,
21
- SerializedRichTextSchema,
22
- } from "./schema/richtext";
18
+ import { RichTextSchema, SerializedRichTextSchema } from "./schema/richtext";
23
19
  import {
24
20
  ImageMetadata,
25
21
  ImageSchema,
26
22
  SerializedImageSchema,
27
23
  } from "./schema/image";
28
24
  import { FileSource } from "./source/file";
25
+ import { RichText } from "./source/richtext";
29
26
 
30
27
  const brand = Symbol("ValModule");
31
28
  export type ValModule<T extends SelectorSource> = SelectorOf<T> &