@valbuild/core 0.13.8 → 0.15.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/expr/eval.d.ts +6 -6
- package/dist/declarations/src/expr/index.d.ts +3 -3
- package/dist/declarations/src/expr/parser.d.ts +2 -2
- package/dist/declarations/src/fetchVal.d.ts +2 -2
- package/dist/declarations/src/fp/index.d.ts +3 -3
- package/dist/declarations/src/fp/result.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +23 -22
- package/dist/declarations/src/initSchema.d.ts +25 -25
- package/dist/declarations/src/initVal.d.ts +7 -13
- package/dist/declarations/src/module.d.ts +10 -10
- package/dist/declarations/src/patch/deref.d.ts +3 -3
- package/dist/declarations/src/patch/index.d.ts +6 -6
- package/dist/declarations/src/patch/json.d.ts +2 -2
- package/dist/declarations/src/patch/operation.d.ts +2 -2
- package/dist/declarations/src/patch/ops.d.ts +1 -1
- package/dist/declarations/src/patch/parse.d.ts +3 -3
- package/dist/declarations/src/patch/patch.d.ts +3 -3
- package/dist/declarations/src/patch/util.d.ts +2 -2
- package/dist/declarations/src/schema/array.d.ts +3 -3
- package/dist/declarations/src/schema/boolean.d.ts +2 -2
- package/dist/declarations/src/schema/i18n.d.ts +3 -3
- package/dist/declarations/src/schema/image.d.ts +3 -3
- package/dist/declarations/src/schema/index.d.ts +14 -14
- package/dist/declarations/src/schema/literal.d.ts +2 -2
- package/dist/declarations/src/schema/number.d.ts +2 -2
- package/dist/declarations/src/schema/object.d.ts +3 -3
- package/dist/declarations/src/schema/oneOf.d.ts +5 -5
- package/dist/declarations/src/schema/richtext.d.ts +3 -3
- package/dist/declarations/src/schema/string.d.ts +2 -2
- package/dist/declarations/src/schema/union.d.ts +5 -5
- package/dist/declarations/src/selector/array.d.ts +5 -5
- package/dist/declarations/src/selector/boolean.d.ts +1 -1
- package/dist/declarations/src/selector/file.d.ts +1 -1
- package/dist/declarations/src/selector/i18n.d.ts +3 -3
- package/dist/declarations/src/selector/index.d.ts +17 -17
- package/dist/declarations/src/selector/number.d.ts +1 -1
- package/dist/declarations/src/selector/object.d.ts +2 -2
- package/dist/declarations/src/selector/primitive.d.ts +3 -3
- package/dist/declarations/src/selector/remote.d.ts +2 -2
- package/dist/declarations/src/selector/string.d.ts +1 -1
- package/dist/declarations/src/source/file.d.ts +2 -2
- package/dist/declarations/src/source/i18n.d.ts +2 -2
- package/dist/declarations/src/source/index.d.ts +4 -4
- package/dist/declarations/src/source/remote.d.ts +4 -4
- package/dist/declarations/src/source/richtext.d.ts +2 -2
- package/dist/declarations/src/val/array.d.ts +3 -3
- package/dist/declarations/src/val/index.d.ts +9 -9
- package/dist/declarations/src/val/object.d.ts +3 -3
- package/dist/declarations/src/val/primitive.d.ts +3 -3
- package/dist/{index-296cb2b6.esm.js → index-06df0a5b.esm.js} +1 -1
- package/dist/valbuild-core.cjs.dev.js +140 -144
- package/dist/valbuild-core.cjs.prod.js +140 -144
- package/dist/valbuild-core.esm.js +142 -146
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/src/expr/eval.test.ts +2 -3
- package/src/expr/parser.test.ts +1 -1
- package/src/expr/repl.ts +1 -2
- package/src/index.ts +3 -2
- package/src/initVal.ts +1 -21
- package/src/selector/selector.test.ts +1 -1
- package/dist/declarations/src/expr/tokenizer.d.ts +0 -7
- package/dist/declarations/src/selector/SelectorProxy.d.ts +0 -7
@@ -1,21 +1,21 @@
|
|
1
|
-
import { I18nSelector } from "./i18n";
|
2
|
-
import { Selector as ObjectSelector } from "./object";
|
3
|
-
import { UndistributedSourceArray as ArraySelector } from "./array";
|
4
|
-
import { Selector as NumberSelector } from "./number";
|
5
|
-
import { Selector as StringSelector } from "./string";
|
6
|
-
import { Selector as BooleanSelector } from "./boolean";
|
7
|
-
import { Selector as PrimitiveSelector } from "./primitive";
|
8
|
-
import { FileSelector } from "./file";
|
9
|
-
import { SourcePath } from "../val";
|
10
|
-
import { Source, SourceArray, SourceObject, SourcePrimitive } from "../source";
|
11
|
-
import { Schema } from "../schema";
|
12
|
-
import { Expr } from "../expr/expr";
|
13
|
-
import { RemoteSelector } from "./remote";
|
1
|
+
import { I18nSelector } from "./i18n.js";
|
2
|
+
import { Selector as ObjectSelector } from "./object.js";
|
3
|
+
import { UndistributedSourceArray as ArraySelector } from "./array.js";
|
4
|
+
import { Selector as NumberSelector } from "./number.js";
|
5
|
+
import { Selector as StringSelector } from "./string.js";
|
6
|
+
import { Selector as BooleanSelector } from "./boolean.js";
|
7
|
+
import { Selector as PrimitiveSelector } from "./primitive.js";
|
8
|
+
import { FileSelector } from "./file.js";
|
9
|
+
import { SourcePath } from "../val/index.js";
|
10
|
+
import { Source, SourceArray, SourceObject, SourcePrimitive } from "../source/index.js";
|
11
|
+
import { Schema } from "../schema/index.js";
|
12
|
+
import { Expr } from "../expr/expr.js";
|
13
|
+
import { RemoteSelector } from "./remote.js";
|
14
14
|
import { A } from "ts-toolbelt";
|
15
|
-
import { I18nSource, I18nCompatibleSource } from "../source/i18n";
|
16
|
-
import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
17
|
-
import { FileSource } from "../source/file";
|
18
|
-
import { RichText, RichTextSource } from "../source/richtext";
|
15
|
+
import { I18nSource, I18nCompatibleSource } from "../source/i18n.js";
|
16
|
+
import { RemoteCompatibleSource, RemoteSource } from "../source/remote.js";
|
17
|
+
import { FileSource } from "../source/file.js";
|
18
|
+
import { RichText, RichTextSource } from "../source/richtext.js";
|
19
19
|
/**
|
20
20
|
* Selectors can be used to select parts of a Val module.
|
21
21
|
* Unlike queries, joins, aggregates etc is and will not be supported.
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { Selector as PrimitiveSelector } from "./primitive";
|
1
|
+
import { Selector as PrimitiveSelector } from "./primitive.js";
|
2
2
|
export type Selector<T extends number> = PrimitiveSelector<T>;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from ".";
|
2
|
-
import { SourceObject } from "../source";
|
1
|
+
import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
|
2
|
+
import { SourceObject } from "../source/index.js";
|
3
3
|
export type Selector<T extends SourceObject> = GenericSelector<T> & {
|
4
4
|
fold<Tag extends string>(key: Tag): <U extends SelectorSource>(cases: {
|
5
5
|
[key in T[Tag & keyof T] & string]: (v: UnknownSelector<T>) => U;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from ".";
|
2
|
-
import { Source, SourcePrimitive } from "../source";
|
3
|
-
import { Selector as BooleanSelector } from "./boolean";
|
1
|
+
import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
|
2
|
+
import { Source, SourcePrimitive } from "../source/index.js";
|
3
|
+
import { Selector as BooleanSelector } from "./boolean.js";
|
4
4
|
export type Selector<T extends SourcePrimitive> = GenericSelector<T> & {
|
5
5
|
eq(other: Source): BooleanSelector<boolean>;
|
6
6
|
andThen<U extends SelectorSource>(f: (v: UnknownSelector<NonNullable<T>>) => U): SelectorOf<U | NullableOf<T>>;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Selector as UnknownSelector } from ".";
|
2
|
-
import { RemoteCompatibleSource } from "../source/remote";
|
1
|
+
import { Selector as UnknownSelector } from "./index.js";
|
2
|
+
import { RemoteCompatibleSource } from "../source/remote.js";
|
3
3
|
declare const brand: unique symbol;
|
4
4
|
export type RemoteSelector<T extends RemoteCompatibleSource> = UnknownSelector<T> & {
|
5
5
|
readonly [brand]: "RemoteSelector";
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { Selector as PrimitiveSelector } from "./primitive";
|
1
|
+
import { Selector as PrimitiveSelector } from "./primitive.js";
|
2
2
|
export type Selector<T extends string> = PrimitiveSelector<T>;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { VAL_EXTENSION } from ".";
|
2
|
-
import { JsonPrimitive } from "../Json";
|
1
|
+
import { VAL_EXTENSION } from "./index.js";
|
2
|
+
import { JsonPrimitive } from "../Json.js";
|
3
3
|
export declare const FILE_REF_PROP: "_ref";
|
4
4
|
/**
|
5
5
|
* A file source represents the path to a (local) file.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { F } from "ts-toolbelt";
|
2
|
-
import { SourcePrimitive, VAL_EXTENSION } from ".";
|
3
|
-
import { FileSource } from "./file";
|
2
|
+
import { SourcePrimitive, VAL_EXTENSION } from "./index.js";
|
3
|
+
import { FileSource } from "./file.js";
|
4
4
|
/**
|
5
5
|
* I18n sources cannot have nested remote sources.
|
6
6
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { FileSource } from "./file";
|
2
|
-
import { I18nSource, I18nCompatibleSource } from "./i18n";
|
3
|
-
import { RemoteSource, RemoteCompatibleSource } from "./remote";
|
4
|
-
import { RichTextSource } from "./richtext";
|
1
|
+
import { FileSource } from "./file.js";
|
2
|
+
import { I18nSource, I18nCompatibleSource } from "./i18n.js";
|
3
|
+
import { RemoteSource, RemoteCompatibleSource } from "./remote.js";
|
4
|
+
import { RichTextSource } from "./richtext.js";
|
5
5
|
export type Source = SourcePrimitive | SourceObject | SourceArray | I18nSource<string[], I18nCompatibleSource> | RemoteSource<RemoteCompatibleSource> | FileSource | RichTextSource;
|
6
6
|
export type SourceObject = {
|
7
7
|
[key in string]: Source;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { SourcePrimitive, VAL_EXTENSION, PhantomType } from ".";
|
2
|
-
import { FileSource } from "./file";
|
3
|
-
import { I18nCompatibleSource, I18nSource } from "./i18n";
|
4
|
-
import { RichTextSource } from "./richtext";
|
1
|
+
import { SourcePrimitive, VAL_EXTENSION, PhantomType } from "./index.js";
|
2
|
+
import { FileSource } from "./file.js";
|
3
|
+
import { I18nCompatibleSource, I18nSource } from "./i18n.js";
|
4
|
+
import { RichTextSource } from "./richtext.js";
|
5
5
|
/**
|
6
6
|
* Remote sources cannot include other remote sources.
|
7
7
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { SourcePath, Val as UnknownVal } from ".";
|
2
|
-
import { JsonArray } from "../Json";
|
3
|
-
import { Path } from "../selector";
|
1
|
+
import { SourcePath, Val as UnknownVal } from "./index.js";
|
2
|
+
import { JsonArray } from "../Json.js";
|
3
|
+
import { Path } from "../selector/index.js";
|
4
4
|
export type Val<T extends JsonArray> = {
|
5
5
|
readonly [key in keyof T]: UnknownVal<T[key]>;
|
6
6
|
} & {
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import { Source, SourceArray, SourceObject } from "../source";
|
2
|
-
import { Val as ObjectVal } from "./object";
|
3
|
-
import { Val as ArrayVal } from "./array";
|
4
|
-
import { Val as PrimitiveVal } from "./primitive";
|
5
|
-
import { Json, JsonArray, JsonObject, JsonPrimitive } from "../Json";
|
6
|
-
import { Path, Selector } from "../selector";
|
7
|
-
import { I18nSource } from "../source/i18n";
|
8
|
-
import { RemoteSource } from "../source/remote";
|
9
|
-
import { FileSource } from "../source/file";
|
1
|
+
import { Source, SourceArray, SourceObject } from "../source/index.js";
|
2
|
+
import { Val as ObjectVal } from "./object.js";
|
3
|
+
import { Val as ArrayVal } from "./array.js";
|
4
|
+
import { Val as PrimitiveVal } from "./primitive.js";
|
5
|
+
import { Json, JsonArray, JsonObject, JsonPrimitive } from "../Json.js";
|
6
|
+
import { Path, Selector } from "../selector/index.js";
|
7
|
+
import { I18nSource } from "../source/i18n.js";
|
8
|
+
import { RemoteSource } from "../source/remote.js";
|
9
|
+
import { FileSource } from "../source/file.js";
|
10
10
|
export type SerializedVal = {
|
11
11
|
val: SerializedVal | Json;
|
12
12
|
valPath: SourcePath | undefined;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { SourcePath, Val as UnknownVal } from ".";
|
2
|
-
import { JsonObject } from "../Json";
|
3
|
-
import { Path } from "../selector";
|
1
|
+
import { SourcePath, Val as UnknownVal } from "./index.js";
|
2
|
+
import { JsonObject } from "../Json.js";
|
3
|
+
import { Path } from "../selector/index.js";
|
4
4
|
export type Val<T extends JsonObject> = Omit<{
|
5
5
|
readonly [key in keyof T]: UnknownVal<T[key]>;
|
6
6
|
}, "valPath" | "val"> & {
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { SourcePath } from ".";
|
2
|
-
import { JsonPrimitive } from "../Json";
|
3
|
-
import { Path } from "../selector";
|
1
|
+
import { SourcePath } from "./index.js";
|
2
|
+
import { JsonPrimitive } from "../Json.js";
|
3
|
+
import { Path } from "../selector/index.js";
|
4
4
|
export type Val<T extends JsonPrimitive> = {
|
5
5
|
[Path]: SourcePath | undefined;
|
6
6
|
val: T;
|
@@ -1002,4 +1002,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
1002
1002
|
evaluate: evaluate
|
1003
1003
|
});
|
1004
1004
|
|
1005
|
-
export { Call as C, Expr as E, FILE_REF_PROP as F, GenericSelector as G, ImageSchema as I, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _createSuper as a, SourceOrExpr as b, _objectSpread2 as c, _defineProperty as d,
|
1005
|
+
export { Call as C, Expr as E, FILE_REF_PROP as F, GenericSelector as G, ImageSchema as I, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _createSuper as a, SourceOrExpr as b, _objectSpread2 as c, _defineProperty as d, isFile as e, file as f, getValPath as g, createValPathOfItem as h, image as i, isSelector as j, isSerializedVal as k, convertImageSource as l, getSchema as m, newSelectorProxy as n, isVal as o, index as p, parse as q, StringLiteral as r, StringTemplate as s, Sym as t, evaluate as u };
|
@@ -693,146 +693,6 @@ function initSchema(locales) {
|
|
693
693
|
};
|
694
694
|
}
|
695
695
|
|
696
|
-
function fetchVal(selector, locale) {
|
697
|
-
return Promise.resolve(getVal(selector));
|
698
|
-
}
|
699
|
-
function getVal(selector,
|
700
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
701
|
-
locale) {
|
702
|
-
return newValProxy(serializedValOfSelectorSource(selector));
|
703
|
-
}
|
704
|
-
|
705
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
706
|
-
function isArrayOrArraySelector(child) {
|
707
|
-
if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
708
|
-
return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
|
709
|
-
}
|
710
|
-
return Array.isArray(child);
|
711
|
-
}
|
712
|
-
|
713
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
714
|
-
function isObjectOrObjectSelector(child) {
|
715
|
-
if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
716
|
-
return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && !Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
|
717
|
-
}
|
718
|
-
return createClass._typeof(child) === "object";
|
719
|
-
}
|
720
|
-
function serializedValOfSelectorSource(selector) {
|
721
|
-
var wrappedSelector = expr_dist_valbuildCoreExpr.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
|
722
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
723
|
-
function rec(child) {
|
724
|
-
var isArray = isArrayOrArraySelector(child);
|
725
|
-
var isObject = isObjectOrObjectSelector(child);
|
726
|
-
if (isArray) {
|
727
|
-
var array = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
|
728
|
-
var valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
|
729
|
-
return {
|
730
|
-
val: array.map(function (item, i) {
|
731
|
-
return rec(expr_dist_valbuildCoreExpr.isSelector(item) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
732
|
-
? item : expr_dist_valbuildCoreExpr.newSelectorProxy(item, expr_dist_valbuildCoreExpr.createValPathOfItem(valPath, i)));
|
733
|
-
}),
|
734
|
-
valPath: valPath
|
735
|
-
};
|
736
|
-
} else if (isObject) {
|
737
|
-
var obj = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
|
738
|
-
var _valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
|
739
|
-
return {
|
740
|
-
val: obj !== null && Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
741
|
-
var _ref2 = createClass._slicedToArray(_ref, 2),
|
742
|
-
key = _ref2[0],
|
743
|
-
value = _ref2[1];
|
744
|
-
return [key, rec(expr_dist_valbuildCoreExpr.isSelector(value) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
745
|
-
? value : expr_dist_valbuildCoreExpr.newSelectorProxy(value, expr_dist_valbuildCoreExpr.createValPathOfItem(_valPath, key)))];
|
746
|
-
})),
|
747
|
-
valPath: _valPath
|
748
|
-
};
|
749
|
-
} else if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
750
|
-
return {
|
751
|
-
val: rec(child[expr_dist_valbuildCoreExpr.SourceOrExpr]),
|
752
|
-
valPath: child[expr_dist_valbuildCoreExpr.Path]
|
753
|
-
};
|
754
|
-
} else {
|
755
|
-
return child;
|
756
|
-
}
|
757
|
-
}
|
758
|
-
return rec(wrappedSelector);
|
759
|
-
}
|
760
|
-
function strip(value) {
|
761
|
-
var val = expr_dist_valbuildCoreExpr.isSerializedVal(value) ? value.val : value;
|
762
|
-
switch (createClass._typeof(val)) {
|
763
|
-
case "function":
|
764
|
-
case "symbol":
|
765
|
-
throw Error("Invalid val type: ".concat(createClass._typeof(val)));
|
766
|
-
case "object":
|
767
|
-
if (val === null) {
|
768
|
-
return null;
|
769
|
-
} else if (Array.isArray(val)) {
|
770
|
-
return val.map(strip);
|
771
|
-
} else {
|
772
|
-
return Object.fromEntries(Object.entries(val).map(function (_ref3) {
|
773
|
-
var _ref4 = createClass._slicedToArray(_ref3, 2),
|
774
|
-
key = _ref4[0],
|
775
|
-
value = _ref4[1];
|
776
|
-
return [key, value && strip(value)];
|
777
|
-
}));
|
778
|
-
}
|
779
|
-
// intentional fallthrough
|
780
|
-
// eslint-disable-next-line no-fallthrough
|
781
|
-
default:
|
782
|
-
return val;
|
783
|
-
}
|
784
|
-
}
|
785
|
-
function newValProxy(val) {
|
786
|
-
var _ref5;
|
787
|
-
var source = val.val;
|
788
|
-
switch (createClass._typeof(source)) {
|
789
|
-
case "function":
|
790
|
-
case "symbol":
|
791
|
-
throw Error("Invalid val type: ".concat(createClass._typeof(source)));
|
792
|
-
case "object":
|
793
|
-
if (source !== null) {
|
794
|
-
// Handles both objects and arrays!
|
795
|
-
return new Proxy(source, {
|
796
|
-
has: function has(target, prop) {
|
797
|
-
if (prop === "val") {
|
798
|
-
return true;
|
799
|
-
}
|
800
|
-
if (prop === expr_dist_valbuildCoreExpr.Path) {
|
801
|
-
return true;
|
802
|
-
}
|
803
|
-
return hasOwn(target, prop);
|
804
|
-
},
|
805
|
-
get: function get(target, prop) {
|
806
|
-
if (prop === expr_dist_valbuildCoreExpr.Path) {
|
807
|
-
return val.valPath;
|
808
|
-
}
|
809
|
-
if (prop === "val") {
|
810
|
-
return strip(val);
|
811
|
-
}
|
812
|
-
if (Array.isArray(target) && prop === "length") {
|
813
|
-
return target.length;
|
814
|
-
}
|
815
|
-
if (hasOwn(source, prop)) {
|
816
|
-
var _Reflect$get$valPath, _Reflect$get;
|
817
|
-
return newValProxy({
|
818
|
-
val: Reflect.get(target, prop).val,
|
819
|
-
valPath: (_Reflect$get$valPath = (_Reflect$get = Reflect.get(target, prop)) === null || _Reflect$get === void 0 ? void 0 : _Reflect$get.valPath) !== null && _Reflect$get$valPath !== void 0 ? _Reflect$get$valPath : expr_dist_valbuildCoreExpr.createValPathOfItem(val.valPath, Array.isArray(target) ? Number(prop) : prop)
|
820
|
-
});
|
821
|
-
}
|
822
|
-
return Reflect.get(target, prop);
|
823
|
-
}
|
824
|
-
});
|
825
|
-
}
|
826
|
-
// intentional fallthrough
|
827
|
-
// eslint-disable-next-line no-fallthrough
|
828
|
-
default:
|
829
|
-
return _ref5 = {}, expr_dist_valbuildCoreExpr._defineProperty(_ref5, expr_dist_valbuildCoreExpr.Path, val.valPath), expr_dist_valbuildCoreExpr._defineProperty(_ref5, "val", val.val), _ref5;
|
830
|
-
}
|
831
|
-
}
|
832
|
-
function hasOwn(obj, prop) {
|
833
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
834
|
-
}
|
835
|
-
|
836
696
|
/**
|
837
697
|
* Remote sources cannot include other remote sources.
|
838
698
|
*/
|
@@ -878,11 +738,9 @@ var initVal = function initVal(options) {
|
|
878
738
|
i18n: i18n,
|
879
739
|
remote: remote,
|
880
740
|
getPath: expr_dist_valbuildCoreExpr.getValPath,
|
881
|
-
key: expr_dist_valbuildCoreExpr.getValPath,
|
882
741
|
file: expr_dist_valbuildCoreExpr.file,
|
883
742
|
richtext: richtext
|
884
743
|
},
|
885
|
-
fetchVal: fetchVal,
|
886
744
|
s: s
|
887
745
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
888
746
|
};
|
@@ -893,11 +751,9 @@ var initVal = function initVal(options) {
|
|
893
751
|
content: content,
|
894
752
|
remote: remote,
|
895
753
|
getPath: expr_dist_valbuildCoreExpr.getValPath,
|
896
|
-
key: expr_dist_valbuildCoreExpr.getValPath,
|
897
754
|
file: expr_dist_valbuildCoreExpr.file,
|
898
755
|
richtext: richtext
|
899
756
|
},
|
900
|
-
fetchVal: fetchVal,
|
901
757
|
s: expr_dist_valbuildCoreExpr._objectSpread2(expr_dist_valbuildCoreExpr._objectSpread2({}, s), {}, {
|
902
758
|
i18n: undefined
|
903
759
|
})
|
@@ -1016,6 +872,146 @@ function derefPatch(patch, document, ops$1) {
|
|
1016
872
|
});
|
1017
873
|
}
|
1018
874
|
|
875
|
+
function fetchVal(selector, locale) {
|
876
|
+
return Promise.resolve(getVal(selector));
|
877
|
+
}
|
878
|
+
function getVal(selector,
|
879
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
880
|
+
locale) {
|
881
|
+
return newValProxy(serializedValOfSelectorSource(selector));
|
882
|
+
}
|
883
|
+
|
884
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
885
|
+
function isArrayOrArraySelector(child) {
|
886
|
+
if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
887
|
+
return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
|
888
|
+
}
|
889
|
+
return Array.isArray(child);
|
890
|
+
}
|
891
|
+
|
892
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
893
|
+
function isObjectOrObjectSelector(child) {
|
894
|
+
if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
895
|
+
return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && !Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
|
896
|
+
}
|
897
|
+
return createClass._typeof(child) === "object";
|
898
|
+
}
|
899
|
+
function serializedValOfSelectorSource(selector) {
|
900
|
+
var wrappedSelector = expr_dist_valbuildCoreExpr.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
|
901
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
902
|
+
function rec(child) {
|
903
|
+
var isArray = isArrayOrArraySelector(child);
|
904
|
+
var isObject = isObjectOrObjectSelector(child);
|
905
|
+
if (isArray) {
|
906
|
+
var array = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
|
907
|
+
var valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
|
908
|
+
return {
|
909
|
+
val: array.map(function (item, i) {
|
910
|
+
return rec(expr_dist_valbuildCoreExpr.isSelector(item) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
911
|
+
? item : expr_dist_valbuildCoreExpr.newSelectorProxy(item, expr_dist_valbuildCoreExpr.createValPathOfItem(valPath, i)));
|
912
|
+
}),
|
913
|
+
valPath: valPath
|
914
|
+
};
|
915
|
+
} else if (isObject) {
|
916
|
+
var obj = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
|
917
|
+
var _valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
|
918
|
+
return {
|
919
|
+
val: obj !== null && Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
920
|
+
var _ref2 = createClass._slicedToArray(_ref, 2),
|
921
|
+
key = _ref2[0],
|
922
|
+
value = _ref2[1];
|
923
|
+
return [key, rec(expr_dist_valbuildCoreExpr.isSelector(value) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
924
|
+
? value : expr_dist_valbuildCoreExpr.newSelectorProxy(value, expr_dist_valbuildCoreExpr.createValPathOfItem(_valPath, key)))];
|
925
|
+
})),
|
926
|
+
valPath: _valPath
|
927
|
+
};
|
928
|
+
} else if (expr_dist_valbuildCoreExpr.isSelector(child)) {
|
929
|
+
return {
|
930
|
+
val: rec(child[expr_dist_valbuildCoreExpr.SourceOrExpr]),
|
931
|
+
valPath: child[expr_dist_valbuildCoreExpr.Path]
|
932
|
+
};
|
933
|
+
} else {
|
934
|
+
return child;
|
935
|
+
}
|
936
|
+
}
|
937
|
+
return rec(wrappedSelector);
|
938
|
+
}
|
939
|
+
function strip(value) {
|
940
|
+
var val = expr_dist_valbuildCoreExpr.isSerializedVal(value) ? value.val : value;
|
941
|
+
switch (createClass._typeof(val)) {
|
942
|
+
case "function":
|
943
|
+
case "symbol":
|
944
|
+
throw Error("Invalid val type: ".concat(createClass._typeof(val)));
|
945
|
+
case "object":
|
946
|
+
if (val === null) {
|
947
|
+
return null;
|
948
|
+
} else if (Array.isArray(val)) {
|
949
|
+
return val.map(strip);
|
950
|
+
} else {
|
951
|
+
return Object.fromEntries(Object.entries(val).map(function (_ref3) {
|
952
|
+
var _ref4 = createClass._slicedToArray(_ref3, 2),
|
953
|
+
key = _ref4[0],
|
954
|
+
value = _ref4[1];
|
955
|
+
return [key, value && strip(value)];
|
956
|
+
}));
|
957
|
+
}
|
958
|
+
// intentional fallthrough
|
959
|
+
// eslint-disable-next-line no-fallthrough
|
960
|
+
default:
|
961
|
+
return val;
|
962
|
+
}
|
963
|
+
}
|
964
|
+
function newValProxy(val) {
|
965
|
+
var _ref5;
|
966
|
+
var source = val.val;
|
967
|
+
switch (createClass._typeof(source)) {
|
968
|
+
case "function":
|
969
|
+
case "symbol":
|
970
|
+
throw Error("Invalid val type: ".concat(createClass._typeof(source)));
|
971
|
+
case "object":
|
972
|
+
if (source !== null) {
|
973
|
+
// Handles both objects and arrays!
|
974
|
+
return new Proxy(source, {
|
975
|
+
has: function has(target, prop) {
|
976
|
+
if (prop === "val") {
|
977
|
+
return true;
|
978
|
+
}
|
979
|
+
if (prop === expr_dist_valbuildCoreExpr.Path) {
|
980
|
+
return true;
|
981
|
+
}
|
982
|
+
return hasOwn(target, prop);
|
983
|
+
},
|
984
|
+
get: function get(target, prop) {
|
985
|
+
if (prop === expr_dist_valbuildCoreExpr.Path) {
|
986
|
+
return val.valPath;
|
987
|
+
}
|
988
|
+
if (prop === "val") {
|
989
|
+
return strip(val);
|
990
|
+
}
|
991
|
+
if (Array.isArray(target) && prop === "length") {
|
992
|
+
return target.length;
|
993
|
+
}
|
994
|
+
if (hasOwn(source, prop)) {
|
995
|
+
var _Reflect$get$valPath, _Reflect$get;
|
996
|
+
return newValProxy({
|
997
|
+
val: Reflect.get(target, prop).val,
|
998
|
+
valPath: (_Reflect$get$valPath = (_Reflect$get = Reflect.get(target, prop)) === null || _Reflect$get === void 0 ? void 0 : _Reflect$get.valPath) !== null && _Reflect$get$valPath !== void 0 ? _Reflect$get$valPath : expr_dist_valbuildCoreExpr.createValPathOfItem(val.valPath, Array.isArray(target) ? Number(prop) : prop)
|
999
|
+
});
|
1000
|
+
}
|
1001
|
+
return Reflect.get(target, prop);
|
1002
|
+
}
|
1003
|
+
});
|
1004
|
+
}
|
1005
|
+
// intentional fallthrough
|
1006
|
+
// eslint-disable-next-line no-fallthrough
|
1007
|
+
default:
|
1008
|
+
return _ref5 = {}, expr_dist_valbuildCoreExpr._defineProperty(_ref5, expr_dist_valbuildCoreExpr.Path, val.valPath), expr_dist_valbuildCoreExpr._defineProperty(_ref5, "val", val.val), _ref5;
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
function hasOwn(obj, prop) {
|
1012
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
1013
|
+
}
|
1014
|
+
|
1019
1015
|
var Internal = {
|
1020
1016
|
convertImageSource: expr_dist_valbuildCoreExpr.convertImageSource,
|
1021
1017
|
getSchema: expr_dist_valbuildCoreExpr.getSchema,
|