@valbuild/core 0.20.1 → 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.
- package/dist/declarations/src/index.d.ts +3 -3
- package/dist/declarations/src/initVal.d.ts +2 -0
- package/dist/declarations/src/source/link.d.ts +9 -0
- package/dist/declarations/src/source/richtext.d.ts +44 -30
- package/dist/{index-601a7d73.cjs.prod.js → index-067cff4a.cjs.prod.js} +1 -1
- package/dist/{index-a6e642dd.cjs.dev.js → index-31991dd7.cjs.dev.js} +3 -0
- package/dist/{index-bccf1907.esm.js → index-4bb14a92.esm.js} +4 -1
- package/dist/{index-8706c87e.cjs.prod.js → index-75b79c89.cjs.prod.js} +3 -0
- package/dist/{index-5d1ab97c.esm.js → index-870205b5.esm.js} +1 -1
- package/dist/{index-486c7fbf.cjs.dev.js → index-d17f9503.cjs.dev.js} +1 -1
- package/dist/{ops-b0a33248.cjs.dev.js → ops-0f7617a0.cjs.dev.js} +1 -1
- package/dist/{ops-def81fc3.cjs.prod.js → ops-451ffb3f.cjs.prod.js} +1 -1
- package/dist/{ops-22b624eb.esm.js → ops-9b396073.esm.js} +1 -1
- package/dist/valbuild-core.cjs.dev.js +39 -159
- package/dist/valbuild-core.cjs.prod.js +39 -159
- package/dist/valbuild-core.esm.js +40 -140
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +2 -4
- package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -2
- package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -2
- package/patch/dist/valbuild-core-patch.esm.js +3 -3
- package/src/index.ts +4 -4
- package/src/initVal.ts +3 -0
- package/src/schema/image.ts +5 -0
- package/src/source/link.ts +14 -0
- package/src/source/richtext.ts +91 -234
- package/src/source/richtext.test.ts +0 -178
@@ -2,32 +2,11 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('./index-
|
6
|
-
var ops = require('./ops-
|
7
|
-
var
|
8
|
-
var expr_dist_valbuildCoreExpr = require('./index-601a7d73.cjs.prod.js');
|
5
|
+
var index = require('./index-75b79c89.cjs.prod.js');
|
6
|
+
var ops = require('./ops-451ffb3f.cjs.prod.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-067cff4a.cjs.prod.js');
|
9
8
|
var result = require('./result-26f67b40.cjs.prod.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
|
-
//
|
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
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
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
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
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
|
-
|
409
|
+
|
410
|
+
function link(text, _ref) {
|
521
411
|
var _ref2;
|
522
|
-
|
523
|
-
|
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,
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, i as image, V as VAL_EXTENSION, f as
|
2
|
-
export { F as FILE_REF_PROP, q as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-
|
3
|
-
import { a as array, o as object, u as union, r as richtext$1, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem, i as isSelector, g as getSource, e as resolvePath, s as splitModuleIdAndModulePath } from './ops-
|
4
|
-
|
5
|
-
export { i as expr } from './index-5d1ab97c.esm.js';
|
1
|
+
import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, i as image, V as VAL_EXTENSION, f as file, h as _objectSpread2, j as _slicedToArray, k as isFile, F as FILE_REF_PROP, P as Path, l as GetSource, m as isSerializedVal, n as convertFileSource, o as getSchema, p as isVal } from './index-4bb14a92.esm.js';
|
2
|
+
export { F as FILE_REF_PROP, q as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-4bb14a92.esm.js';
|
3
|
+
import { a as array, o as object, u as union, r as richtext$1, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem, i as isSelector, g as getSource, e as resolvePath, s as splitModuleIdAndModulePath } from './ops-9b396073.esm.js';
|
4
|
+
export { i as expr } from './index-870205b5.esm.js';
|
6
5
|
import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok, r as result } from './result-b96df128.esm.js';
|
7
6
|
|
8
7
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -371,143 +370,44 @@ function initSchema() {
|
|
371
370
|
};
|
372
371
|
}
|
373
372
|
|
374
|
-
//
|
375
|
-
// O["fontFamily"] extends Record<string, unknown>
|
376
|
-
// ? `font-${keyof O["fontFamily"] & string}`
|
377
|
-
// : never;
|
378
|
-
// export type FontSize<O extends RichTextOptions> = O["fontSize"] extends Record<
|
379
|
-
// string,
|
380
|
-
// unknown
|
381
|
-
// >
|
382
|
-
// ? `text-${keyof O["fontSize"] & string}`
|
383
|
-
// : never;
|
384
|
-
// | FontFamily<O>
|
385
|
-
// | FontSize<O>;
|
386
|
-
// export type AnchorNode<O extends RichTextOptions> = never; // TODO:
|
387
|
-
// O["link"] extends true
|
388
|
-
// ? {
|
389
|
-
// tag: "a";
|
390
|
-
// href: string;
|
391
|
-
// children: [string];
|
392
|
-
// }
|
393
|
-
// : never;
|
394
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
395
|
-
// export type BlockQuoteNode<O extends RichTextOptions> =
|
396
|
-
// O["blockQuote"] extends true
|
397
|
-
// ? { tag: "blockquote"; children: [string] }
|
398
|
-
// : never;
|
399
|
-
// TODO: rename to RichTextSelector?
|
400
|
-
function parseTokens(tokens) {
|
401
|
-
return tokens.flatMap(function (token) {
|
402
|
-
if (token.type === "heading") {
|
403
|
-
return [{
|
404
|
-
tag: "h".concat(token.depth),
|
405
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
406
|
-
}];
|
407
|
-
}
|
408
|
-
if (token.type === "paragraph") {
|
409
|
-
return [{
|
410
|
-
tag: "p",
|
411
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
412
|
-
}];
|
413
|
-
}
|
414
|
-
if (token.type === "strong") {
|
415
|
-
return [{
|
416
|
-
tag: "span",
|
417
|
-
classes: ["bold"],
|
418
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
419
|
-
}];
|
420
|
-
}
|
421
|
-
if (token.type === "em") {
|
422
|
-
return [{
|
423
|
-
tag: "span",
|
424
|
-
classes: ["italic"],
|
425
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
426
|
-
}];
|
427
|
-
}
|
428
|
-
if (token.type === "del") {
|
429
|
-
return [{
|
430
|
-
tag: "span",
|
431
|
-
classes: ["line-through"],
|
432
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
433
|
-
}];
|
434
|
-
}
|
435
|
-
if (token.type === "text") {
|
436
|
-
if ("tokens" in token && Array.isArray(token.tokens)) {
|
437
|
-
return parseTokens(token.tokens);
|
438
|
-
}
|
439
|
-
return [token.text];
|
440
|
-
}
|
441
|
-
if (token.type === "list") {
|
442
|
-
return [{
|
443
|
-
tag: token.ordered ? "ol" : "ul",
|
444
|
-
children: parseTokens(token.items)
|
445
|
-
}];
|
446
|
-
}
|
447
|
-
if (token.type === "list_item") {
|
448
|
-
return [{
|
449
|
-
tag: "li",
|
450
|
-
children: parseTokens(token.tokens ? token.tokens : [])
|
451
|
-
}];
|
452
|
-
}
|
453
|
-
if (token.type === "space") {
|
454
|
-
return [];
|
455
|
-
}
|
456
|
-
if (token.type === "code") {
|
457
|
-
return [{
|
458
|
-
tag: "span",
|
459
|
-
classes: [],
|
460
|
-
children: [token.text]
|
461
|
-
}];
|
462
|
-
}
|
463
|
-
// console.error(
|
464
|
-
// `Could not parse markdown: unsupported token type: ${token.type}. Found: ${token.raw}`
|
465
|
-
// );
|
466
|
-
return [token.raw];
|
467
|
-
});
|
468
|
-
}
|
373
|
+
// Classes
|
469
374
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
375
|
+
/// Paragraph
|
376
|
+
|
377
|
+
/// Break
|
378
|
+
|
379
|
+
/// Span
|
380
|
+
|
381
|
+
/// Image
|
382
|
+
|
383
|
+
/// Link
|
384
|
+
|
385
|
+
/// List
|
386
|
+
|
387
|
+
/// Heading
|
388
|
+
|
389
|
+
/// Root and nodes
|
390
|
+
|
391
|
+
/// Main types
|
392
|
+
/**
|
393
|
+
* RichTextSource is defined in ValModules
|
394
|
+
**/
|
395
|
+
/**
|
396
|
+
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
397
|
+
* Internally it is a Selector
|
398
|
+
**/
|
399
|
+
function richtext(templateStrings) {
|
488
400
|
var _ref;
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
}
|
494
|
-
return source;
|
495
|
-
})), _ref;
|
401
|
+
for (var _len = arguments.length, nodes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
402
|
+
nodes[_key - 1] = arguments[_key];
|
403
|
+
}
|
404
|
+
return _ref = {}, _defineProperty(_ref, VAL_EXTENSION, "richtext"), _defineProperty(_ref, "templateStrings", templateStrings), _defineProperty(_ref, "exprs", nodes), _ref;
|
496
405
|
}
|
497
|
-
|
406
|
+
|
407
|
+
function link(text, _ref) {
|
498
408
|
var _ref2;
|
499
|
-
|
500
|
-
|
501
|
-
}
|
502
|
-
return _ref2 = {}, _defineProperty(_ref2, VAL_EXTENSION, "richtext"), _defineProperty(_ref2, "children", templateStrings.flatMap(function (templateString, i) {
|
503
|
-
var lex = marked.lexer(templateString, {
|
504
|
-
gfm: true
|
505
|
-
});
|
506
|
-
if (expr[i]) {
|
507
|
-
return parseTokens(lex).concat(nodeToTag(expr[i]));
|
508
|
-
}
|
509
|
-
return parseTokens(lex);
|
510
|
-
})), _ref2;
|
409
|
+
var href = _ref.href;
|
410
|
+
return _ref2 = {}, _defineProperty(_ref2, VAL_EXTENSION, "link"), _defineProperty(_ref2, "href", href), _defineProperty(_ref2, "children", [text]), _ref2;
|
511
411
|
}
|
512
412
|
|
513
413
|
// import { i18n, I18n } from "./source/future/i18n";
|
@@ -543,7 +443,8 @@ var initVal = function initVal() {
|
|
543
443
|
// remote,
|
544
444
|
getPath: getValPath,
|
545
445
|
file: file,
|
546
|
-
richtext: richtext
|
446
|
+
richtext: richtext,
|
447
|
+
link: link
|
547
448
|
},
|
548
449
|
s: _objectSpread2({}, s)
|
549
450
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -1281,7 +1182,6 @@ function _parse() {
|
|
1281
1182
|
|
1282
1183
|
var Internal = {
|
1283
1184
|
convertFileSource: convertFileSource,
|
1284
|
-
convertRichTextSource: convertRichTextSource,
|
1285
1185
|
getSchema: getSchema,
|
1286
1186
|
getValPath: getValPath,
|
1287
1187
|
getVal: getVal,
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
6
|
-
var index = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-d17f9503.cjs.dev.js');
|
6
|
+
var index = require('../../dist/index-31991dd7.cjs.dev.js');
|
7
7
|
require('../../dist/result-48320acd.cjs.dev.js');
|
8
8
|
|
9
9
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
6
|
-
var index = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-067cff4a.cjs.prod.js');
|
6
|
+
var index = require('../../dist/index-75b79c89.cjs.prod.js');
|
7
7
|
require('../../dist/result-26f67b40.cjs.prod.js');
|
8
8
|
|
9
9
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { e as evaluate, p as parse } from '../../dist/index-
|
2
|
-
export { C as Call, E as Expr, N as NilSym, s as StringLiteral, t as StringTemplate, r as Sym } from '../../dist/index-
|
1
|
+
export { e as evaluate, p as parse } from '../../dist/index-870205b5.esm.js';
|
2
|
+
export { C as Call, E as Expr, N as NilSym, s as StringLiteral, t as StringTemplate, r as Sym } from '../../dist/index-4bb14a92.esm.js';
|
3
3
|
import '../../dist/result-b96df128.esm.js';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/core",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.21.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Val - supercharged hard-coded content",
|
6
6
|
"scripts": {
|
@@ -42,7 +42,5 @@
|
|
42
42
|
"devDependencies": {
|
43
43
|
"ts-toolbelt": "^9.6.0"
|
44
44
|
},
|
45
|
-
"dependencies": {
|
46
|
-
"marked": "^9.0.3"
|
47
|
-
}
|
45
|
+
"dependencies": {}
|
48
46
|
}
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('../../dist/index-
|
5
|
+
var index = require('../../dist/index-31991dd7.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-48320acd.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
|
-
var ops = require('../../dist/ops-
|
8
|
+
var ops = require('../../dist/ops-0f7617a0.cjs.dev.js');
|
9
9
|
|
10
10
|
function isNotRoot(path) {
|
11
11
|
return result.isNonEmpty(path);
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('../../dist/index-
|
5
|
+
var index = require('../../dist/index-75b79c89.cjs.prod.js');
|
6
6
|
var result = require('../../dist/result-26f67b40.cjs.prod.js');
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
8
|
-
var ops = require('../../dist/ops-
|
8
|
+
var ops = require('../../dist/ops-451ffb3f.cjs.prod.js');
|
9
9
|
|
10
10
|
function isNotRoot(path) {
|
11
11
|
return result.isNonEmpty(path);
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { e as _typeof,
|
1
|
+
import { e as _typeof, j as _slicedToArray, c as _createClass, b as _classCallCheck, u as _toConsumableArray } from '../../dist/index-4bb14a92.esm.js';
|
2
2
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-b96df128.esm.js';
|
3
3
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
4
|
-
import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-
|
5
|
-
export { P as PatchError } from '../../dist/ops-
|
4
|
+
import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-9b396073.esm.js';
|
5
|
+
export { P as PatchError } from '../../dist/ops-9b396073.esm.js';
|
6
6
|
|
7
7
|
function isNotRoot(path) {
|
8
8
|
return isNonEmpty(path);
|
package/src/index.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
export { initVal } from "./initVal";
|
2
2
|
export type { InitVal } from "./initVal";
|
3
3
|
export { Schema, type SerializedSchema } from "./schema";
|
4
|
+
export type { ImageMetadata } from "./schema/image";
|
5
|
+
export type { LinkSource } from "./source/link";
|
4
6
|
export type { ValModule, SerializedModule } from "./module";
|
5
7
|
export type { SourceObject, SourcePrimitive, Source } from "./source";
|
6
8
|
export type { FileSource } from "./source/file";
|
@@ -13,15 +15,15 @@ export type {
|
|
13
15
|
Italic,
|
14
16
|
LineThrough,
|
15
17
|
ListItemNode,
|
18
|
+
LinkNode,
|
16
19
|
OrderedListNode,
|
17
20
|
ParagraphNode,
|
21
|
+
BrNode,
|
18
22
|
RichText,
|
19
23
|
RichTextNode,
|
20
24
|
RichTextOptions,
|
21
25
|
RichTextSource,
|
22
|
-
RichTextSourceNode,
|
23
26
|
RootNode,
|
24
|
-
SourceNode,
|
25
27
|
SpanNode,
|
26
28
|
UnorderedListNode,
|
27
29
|
} from "./source/richtext";
|
@@ -56,7 +58,6 @@ import { createValPathOfItem } from "./selector/SelectorProxy";
|
|
56
58
|
import { getVal } from "./future/fetchVal";
|
57
59
|
import { Json } from "./Json";
|
58
60
|
import { SerializedSchema } from "./schema";
|
59
|
-
import { convertRichTextSource } from "./source/richtext";
|
60
61
|
import { getSHA256Hash } from "./getSha256";
|
61
62
|
export { ValApi } from "./ValApi";
|
62
63
|
|
@@ -82,7 +83,6 @@ export type ApiPatchResponse = Record<ModuleId, string[]>;
|
|
82
83
|
|
83
84
|
const Internal = {
|
84
85
|
convertFileSource,
|
85
|
-
convertRichTextSource,
|
86
86
|
getSchema,
|
87
87
|
getValPath,
|
88
88
|
getVal,
|
package/src/initVal.ts
CHANGED
@@ -5,6 +5,7 @@ import { InitSchema, initSchema } from "./initSchema";
|
|
5
5
|
import { getValPath as getPath } from "./val";
|
6
6
|
import { file } from "./source/file";
|
7
7
|
import { richtext } from "./source/richtext";
|
8
|
+
import { link } from "./source/link";
|
8
9
|
// import { i18n, I18n } from "./source/future/i18n";
|
9
10
|
// import { remote } from "./source/future/remote";
|
10
11
|
|
@@ -13,6 +14,7 @@ type ValConstructor = {
|
|
13
14
|
getPath: typeof getPath;
|
14
15
|
// remote: typeof remote;
|
15
16
|
file: typeof file;
|
17
|
+
link: typeof link;
|
16
18
|
richtext: typeof richtext;
|
17
19
|
};
|
18
20
|
export type InitVal = {
|
@@ -61,6 +63,7 @@ InitVal => {
|
|
61
63
|
getPath,
|
62
64
|
file,
|
63
65
|
richtext,
|
66
|
+
link,
|
64
67
|
},
|
65
68
|
s: {
|
66
69
|
...s,
|
package/src/schema/image.ts
CHANGED
@@ -121,6 +121,11 @@ export const convertFileSource = (
|
|
121
121
|
src: FileSource<ImageMetadata>
|
122
122
|
): { url: string; metadata?: ImageMetadata } => {
|
123
123
|
// TODO: /public should be configurable
|
124
|
+
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
125
|
+
throw Error(
|
126
|
+
`Invalid reference: ${src[FILE_REF_PROP]}. Did not start with /public`
|
127
|
+
);
|
128
|
+
}
|
124
129
|
return {
|
125
130
|
url:
|
126
131
|
src[FILE_REF_PROP].slice("/public".length) +
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { VAL_EXTENSION } from ".";
|
2
|
+
export type LinkSource = {
|
3
|
+
[VAL_EXTENSION]: "link";
|
4
|
+
href: string;
|
5
|
+
children: [string];
|
6
|
+
};
|
7
|
+
|
8
|
+
export function link(text: string, { href }: { href: string }): LinkSource {
|
9
|
+
return {
|
10
|
+
[VAL_EXTENSION]: "link",
|
11
|
+
href,
|
12
|
+
children: [text],
|
13
|
+
};
|
14
|
+
}
|