mol_tree2 1.0.930 → 1.0.932
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/node.d.ts +1 -176
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +3 -603
- package/node.js.map +1 -1
- package/node.meta.tree +0 -2
- package/node.mjs +3 -603
- package/node.test.js +39 -4278
- package/node.test.js.map +1 -1
- package/package.json +3 -12
- package/web.d.ts +1 -176
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +3 -603
- package/web.js.map +1 -1
- package/web.meta.tree +0 -2
- package/web.mjs +3 -603
- package/web.test.js +36 -5043
- package/web.test.js.map +1 -1
package/web.js
CHANGED
|
@@ -656,610 +656,10 @@ var $;
|
|
|
656
656
|
"use strict";
|
|
657
657
|
var $;
|
|
658
658
|
(function ($) {
|
|
659
|
-
|
|
660
|
-
spans;
|
|
661
|
-
constructor(message, spans) {
|
|
662
|
-
super(message);
|
|
663
|
-
this.spans = spans;
|
|
664
|
-
}
|
|
665
|
-
toJSON() {
|
|
666
|
-
return {
|
|
667
|
-
message: this.message,
|
|
668
|
-
spans: this.spans
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
$.$mol_view_tree2_error = $mol_view_tree2_error;
|
|
673
|
-
class $mol_view_tree2_error_suggestions {
|
|
674
|
-
suggestions;
|
|
675
|
-
constructor(suggestions) {
|
|
676
|
-
this.suggestions = suggestions;
|
|
677
|
-
}
|
|
678
|
-
toString() {
|
|
679
|
-
return this.suggestions.map(suggestion => `\`${suggestion}\``).join(', ');
|
|
680
|
-
}
|
|
681
|
-
toJSON() {
|
|
682
|
-
return this.suggestions;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
$.$mol_view_tree2_error_suggestions = $mol_view_tree2_error_suggestions;
|
|
686
|
-
function $mol_view_tree2_error_str(strings, ...parts) {
|
|
687
|
-
const spans = [];
|
|
688
|
-
for (const part of parts) {
|
|
689
|
-
if (part instanceof $mol_span)
|
|
690
|
-
spans.push(part);
|
|
691
|
-
if (Array.isArray(part) && part.length > 0 && part[0] instanceof $mol_span)
|
|
692
|
-
spans.push(...part);
|
|
693
|
-
}
|
|
694
|
-
return new $mol_view_tree2_error(join(strings, parts), spans);
|
|
695
|
-
}
|
|
696
|
-
$.$mol_view_tree2_error_str = $mol_view_tree2_error_str;
|
|
697
|
-
function join(strings, objects) {
|
|
698
|
-
let result = '';
|
|
699
|
-
let obj_pos = 0;
|
|
700
|
-
let obj_len = objects.length;
|
|
701
|
-
for (const str of strings) {
|
|
702
|
-
result += str;
|
|
703
|
-
if (obj_pos < obj_len) {
|
|
704
|
-
const obj = objects[obj_pos++];
|
|
705
|
-
if (Array.isArray(obj))
|
|
706
|
-
result += obj.map(item => `\`${item}\``).join(', ');
|
|
707
|
-
else
|
|
708
|
-
result += `\`${String(obj)}\``;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
return result;
|
|
712
|
-
}
|
|
713
|
-
})($ || ($ = {}));
|
|
714
|
-
|
|
715
|
-
;
|
|
716
|
-
"use strict";
|
|
717
|
-
var $;
|
|
718
|
-
(function ($) {
|
|
719
|
-
function $mol_view_tree2_child(tree) {
|
|
720
|
-
if (tree.kids.length === 0) {
|
|
721
|
-
return this.$mol_fail($mol_view_tree2_error_str `Required one child at ${tree.span}`);
|
|
722
|
-
}
|
|
723
|
-
if (tree.kids.length > 1) {
|
|
724
|
-
return this.$mol_fail($mol_view_tree2_error_str `Should be only one child at ${tree.span}`);
|
|
725
|
-
}
|
|
726
|
-
return tree.kids[0];
|
|
727
|
-
}
|
|
728
|
-
$.$mol_view_tree2_child = $mol_view_tree2_child;
|
|
729
|
-
})($ || ($ = {}));
|
|
730
|
-
|
|
731
|
-
;
|
|
732
|
-
"use strict";
|
|
733
|
-
var $;
|
|
734
|
-
(function ($) {
|
|
735
|
-
function $mol_view_tree2_classes(defs) {
|
|
736
|
-
return defs.clone(defs.hack({
|
|
737
|
-
'-': () => []
|
|
738
|
-
}));
|
|
739
|
-
}
|
|
740
|
-
$.$mol_view_tree2_classes = $mol_view_tree2_classes;
|
|
741
|
-
})($ || ($ = {}));
|
|
742
|
-
|
|
743
|
-
;
|
|
744
|
-
"use strict";
|
|
745
|
-
var $;
|
|
746
|
-
(function ($) {
|
|
747
|
-
function $mol_view_tree2_normalize(defs) {
|
|
748
|
-
return defs.clone($mol_view_tree2_classes(defs).kids.map(cl => cl.clone([
|
|
749
|
-
this.$mol_view_tree2_class_super(cl).clone(this.$mol_view_tree2_class_props(cl))
|
|
750
|
-
])));
|
|
751
|
-
}
|
|
752
|
-
$.$mol_view_tree2_normalize = $mol_view_tree2_normalize;
|
|
753
|
-
})($ || ($ = {}));
|
|
754
|
-
|
|
755
|
-
;
|
|
756
|
-
"use strict";
|
|
757
|
-
|
|
758
|
-
;
|
|
759
|
-
"use strict";
|
|
760
|
-
|
|
761
|
-
;
|
|
762
|
-
"use strict";
|
|
763
|
-
|
|
764
|
-
;
|
|
765
|
-
"use strict";
|
|
766
|
-
|
|
767
|
-
;
|
|
768
|
-
"use strict";
|
|
769
|
-
|
|
770
|
-
;
|
|
771
|
-
"use strict";
|
|
772
|
-
var $;
|
|
773
|
-
(function ($) {
|
|
774
|
-
class $mol_regexp extends RegExp {
|
|
775
|
-
groups;
|
|
776
|
-
constructor(source, flags = 'gsu', groups = []) {
|
|
777
|
-
super(source, flags);
|
|
778
|
-
this.groups = groups;
|
|
779
|
-
}
|
|
780
|
-
*[Symbol.matchAll](str) {
|
|
781
|
-
const index = this.lastIndex;
|
|
782
|
-
this.lastIndex = 0;
|
|
783
|
-
try {
|
|
784
|
-
while (this.lastIndex < str.length) {
|
|
785
|
-
const found = this.exec(str);
|
|
786
|
-
if (!found)
|
|
787
|
-
break;
|
|
788
|
-
yield found;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
finally {
|
|
792
|
-
this.lastIndex = index;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
[Symbol.match](str) {
|
|
796
|
-
const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]);
|
|
797
|
-
if (!res.length)
|
|
798
|
-
return null;
|
|
799
|
-
return res;
|
|
800
|
-
}
|
|
801
|
-
[Symbol.split](str) {
|
|
802
|
-
const res = [];
|
|
803
|
-
let token_last = null;
|
|
804
|
-
for (let token of this[Symbol.matchAll](str)) {
|
|
805
|
-
if (token.groups && (token_last ? token_last.groups : true))
|
|
806
|
-
res.push('');
|
|
807
|
-
res.push(token[0]);
|
|
808
|
-
token_last = token;
|
|
809
|
-
}
|
|
810
|
-
if (!res.length)
|
|
811
|
-
res.push('');
|
|
812
|
-
return res;
|
|
813
|
-
}
|
|
814
|
-
test(str) {
|
|
815
|
-
return Boolean(str.match(this));
|
|
816
|
-
}
|
|
817
|
-
exec(str) {
|
|
818
|
-
const from = this.lastIndex;
|
|
819
|
-
if (from >= str.length)
|
|
820
|
-
return null;
|
|
821
|
-
const res = super.exec(str);
|
|
822
|
-
if (res === null) {
|
|
823
|
-
this.lastIndex = str.length;
|
|
824
|
-
if (!str)
|
|
825
|
-
return null;
|
|
826
|
-
return Object.assign([str.slice(from)], {
|
|
827
|
-
index: from,
|
|
828
|
-
input: str,
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
if (from === this.lastIndex) {
|
|
832
|
-
$mol_fail(new Error('Captured empty substring'));
|
|
833
|
-
}
|
|
834
|
-
const groups = {};
|
|
835
|
-
const skipped = str.slice(from, this.lastIndex - res[0].length);
|
|
836
|
-
if (skipped) {
|
|
837
|
-
this.lastIndex = this.lastIndex - res[0].length;
|
|
838
|
-
return Object.assign([skipped], {
|
|
839
|
-
index: from,
|
|
840
|
-
input: res.input,
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
for (let i = 0; i < this.groups.length; ++i) {
|
|
844
|
-
const group = this.groups[i];
|
|
845
|
-
groups[group] = groups[group] || res[i + 1] || '';
|
|
846
|
-
}
|
|
847
|
-
return Object.assign(res, { groups });
|
|
848
|
-
}
|
|
849
|
-
generate(params) {
|
|
850
|
-
return null;
|
|
851
|
-
}
|
|
852
|
-
get native() {
|
|
853
|
-
return new RegExp(this.source, this.flags);
|
|
854
|
-
}
|
|
855
|
-
static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
856
|
-
const regexp = $mol_regexp.from(source);
|
|
857
|
-
const upper = Number.isFinite(max) ? max : '';
|
|
858
|
-
const str = `(?:${regexp.source}){${min},${upper}}?`;
|
|
859
|
-
const regexp2 = new $mol_regexp(str, regexp.flags, regexp.groups);
|
|
860
|
-
regexp2.generate = params => {
|
|
861
|
-
const res = regexp.generate(params);
|
|
862
|
-
if (res)
|
|
863
|
-
return res;
|
|
864
|
-
if (min > 0)
|
|
865
|
-
return res;
|
|
866
|
-
return '';
|
|
867
|
-
};
|
|
868
|
-
return regexp2;
|
|
869
|
-
}
|
|
870
|
-
static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
871
|
-
const regexp = $mol_regexp.from(source);
|
|
872
|
-
const upper = Number.isFinite(max) ? max : '';
|
|
873
|
-
const str = `(?:${regexp.source}){${min},${upper}}`;
|
|
874
|
-
const regexp2 = new $mol_regexp(str, regexp.flags, regexp.groups);
|
|
875
|
-
regexp2.generate = params => {
|
|
876
|
-
const res = regexp.generate(params);
|
|
877
|
-
if (res)
|
|
878
|
-
return res;
|
|
879
|
-
if (min > 0)
|
|
880
|
-
return res;
|
|
881
|
-
return '';
|
|
882
|
-
};
|
|
883
|
-
return regexp2;
|
|
884
|
-
}
|
|
885
|
-
static vary(sources) {
|
|
886
|
-
const groups = [];
|
|
887
|
-
const chunks = sources.map(source => {
|
|
888
|
-
const regexp = $mol_regexp.from(source);
|
|
889
|
-
groups.push(...regexp.groups);
|
|
890
|
-
return regexp.source;
|
|
891
|
-
});
|
|
892
|
-
return new $mol_regexp(`(?:${chunks.join('|')})`, '', groups);
|
|
893
|
-
}
|
|
894
|
-
static optional(source) {
|
|
895
|
-
return $mol_regexp.repeat_greedy(source, 0, 1);
|
|
896
|
-
}
|
|
897
|
-
static force_after(source) {
|
|
898
|
-
const regexp = $mol_regexp.from(source);
|
|
899
|
-
return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups);
|
|
900
|
-
}
|
|
901
|
-
static forbid_after(source) {
|
|
902
|
-
const regexp = $mol_regexp.from(source);
|
|
903
|
-
return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups);
|
|
904
|
-
}
|
|
905
|
-
static from(source, { ignoreCase, multiline } = {
|
|
906
|
-
ignoreCase: false,
|
|
907
|
-
multiline: false,
|
|
908
|
-
}) {
|
|
909
|
-
let flags = 'gsu';
|
|
910
|
-
if (multiline)
|
|
911
|
-
flags += 'm';
|
|
912
|
-
if (ignoreCase)
|
|
913
|
-
flags += 'i';
|
|
914
|
-
if (typeof source === 'number') {
|
|
915
|
-
const src = `\\u{${source.toString(16)}}`;
|
|
916
|
-
const regexp = new $mol_regexp(src, flags);
|
|
917
|
-
regexp.generate = () => src;
|
|
918
|
-
return regexp;
|
|
919
|
-
}
|
|
920
|
-
if (typeof source === 'string') {
|
|
921
|
-
const src = source.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
922
|
-
const regexp = new $mol_regexp(src, flags);
|
|
923
|
-
regexp.generate = () => source;
|
|
924
|
-
return regexp;
|
|
925
|
-
}
|
|
926
|
-
else if (source instanceof $mol_regexp) {
|
|
927
|
-
const regexp = new $mol_regexp(source.source, flags, source.groups);
|
|
928
|
-
regexp.generate = params => source.generate(params);
|
|
929
|
-
return regexp;
|
|
930
|
-
}
|
|
931
|
-
if (source instanceof RegExp) {
|
|
932
|
-
const test = new RegExp('|' + source.source);
|
|
933
|
-
const groups = Array.from({ length: test.exec('').length - 1 }, (_, i) => String(i + 1));
|
|
934
|
-
const regexp = new $mol_regexp(source.source, source.flags, groups);
|
|
935
|
-
regexp.generate = () => '';
|
|
936
|
-
return regexp;
|
|
937
|
-
}
|
|
938
|
-
if (Array.isArray(source)) {
|
|
939
|
-
const patterns = source.map(src => Array.isArray(src)
|
|
940
|
-
? $mol_regexp.optional(src)
|
|
941
|
-
: $mol_regexp.from(src));
|
|
942
|
-
const chunks = patterns.map(pattern => pattern.source);
|
|
943
|
-
const groups = [];
|
|
944
|
-
let index = 0;
|
|
945
|
-
for (const pattern of patterns) {
|
|
946
|
-
for (let group of pattern.groups) {
|
|
947
|
-
if (Number(group) >= 0) {
|
|
948
|
-
groups.push(String(index++));
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
groups.push(group);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
const regexp = new $mol_regexp(chunks.join(''), flags, groups);
|
|
956
|
-
regexp.generate = params => {
|
|
957
|
-
let res = '';
|
|
958
|
-
for (const pattern of patterns) {
|
|
959
|
-
let sub = pattern.generate(params);
|
|
960
|
-
if (sub === null)
|
|
961
|
-
return '';
|
|
962
|
-
res += sub;
|
|
963
|
-
}
|
|
964
|
-
return res;
|
|
965
|
-
};
|
|
966
|
-
return regexp;
|
|
967
|
-
}
|
|
968
|
-
else {
|
|
969
|
-
const groups = [];
|
|
970
|
-
const chunks = Object.keys(source).map(name => {
|
|
971
|
-
groups.push(name);
|
|
972
|
-
const regexp = $mol_regexp.from(source[name]);
|
|
973
|
-
groups.push(...regexp.groups);
|
|
974
|
-
return `(${regexp.source})`;
|
|
975
|
-
});
|
|
976
|
-
const regexp = new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups);
|
|
977
|
-
const validator = new RegExp('^' + regexp.source + '$', flags);
|
|
978
|
-
regexp.generate = (params) => {
|
|
979
|
-
for (let option in source) {
|
|
980
|
-
if (option in params) {
|
|
981
|
-
if (typeof params[option] === 'boolean') {
|
|
982
|
-
if (!params[option])
|
|
983
|
-
continue;
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
const str = String(params[option]);
|
|
987
|
-
if (str.match(validator))
|
|
988
|
-
return str;
|
|
989
|
-
$mol_fail(new Error(`Wrong param: ${option}=${str}`));
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
else {
|
|
993
|
-
if (typeof source[option] !== 'object')
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
const res = $mol_regexp.from(source[option]).generate(params);
|
|
997
|
-
if (res)
|
|
998
|
-
return res;
|
|
999
|
-
}
|
|
1000
|
-
return null;
|
|
1001
|
-
};
|
|
1002
|
-
return regexp;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
static unicode_only(...category) {
|
|
1006
|
-
return new $mol_regexp(`\\p{${category.join('=')}}`);
|
|
1007
|
-
}
|
|
1008
|
-
static unicode_except(...category) {
|
|
1009
|
-
return new $mol_regexp(`\\P{${category.join('=')}}`);
|
|
1010
|
-
}
|
|
1011
|
-
static char_range(from, to) {
|
|
1012
|
-
return new $mol_regexp(`${$mol_regexp.from(from).source}-${$mol_regexp.from(to).source}`);
|
|
1013
|
-
}
|
|
1014
|
-
static char_only(...allowed) {
|
|
1015
|
-
const regexp = allowed.map(f => $mol_regexp.from(f).source).join('');
|
|
1016
|
-
return new $mol_regexp(`[${regexp}]`);
|
|
1017
|
-
}
|
|
1018
|
-
static char_except(...forbidden) {
|
|
1019
|
-
const regexp = forbidden.map(f => $mol_regexp.from(f).source).join('');
|
|
1020
|
-
return new $mol_regexp(`[^${regexp}]`);
|
|
1021
|
-
}
|
|
1022
|
-
static decimal_only = $mol_regexp.from(/\d/gsu);
|
|
1023
|
-
static decimal_except = $mol_regexp.from(/\D/gsu);
|
|
1024
|
-
static latin_only = $mol_regexp.from(/\w/gsu);
|
|
1025
|
-
static latin_except = $mol_regexp.from(/\W/gsu);
|
|
1026
|
-
static space_only = $mol_regexp.from(/\s/gsu);
|
|
1027
|
-
static space_except = $mol_regexp.from(/\S/gsu);
|
|
1028
|
-
static word_break_only = $mol_regexp.from(/\b/gsu);
|
|
1029
|
-
static word_break_except = $mol_regexp.from(/\B/gsu);
|
|
1030
|
-
static tab = $mol_regexp.from(/\t/gsu);
|
|
1031
|
-
static slash_back = $mol_regexp.from(/\\/gsu);
|
|
1032
|
-
static nul = $mol_regexp.from(/\0/gsu);
|
|
1033
|
-
static char_any = $mol_regexp.from(/./gsu);
|
|
1034
|
-
static begin = $mol_regexp.from(/^/gsu);
|
|
1035
|
-
static end = $mol_regexp.from(/$/gsu);
|
|
1036
|
-
static or = $mol_regexp.from(/|/gsu);
|
|
1037
|
-
static line_end = $mol_regexp.from({
|
|
1038
|
-
win_end: [['\r'], '\n'],
|
|
1039
|
-
mac_end: '\r',
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
$.$mol_regexp = $mol_regexp;
|
|
1043
|
-
})($ || ($ = {}));
|
|
1044
|
-
|
|
1045
|
-
;
|
|
1046
|
-
"use strict";
|
|
1047
|
-
var $;
|
|
1048
|
-
(function ($) {
|
|
1049
|
-
const { begin, end, latin_only, or, optional, repeat_greedy } = $mol_regexp;
|
|
1050
|
-
$.$mol_view_tree2_prop_signature = $mol_regexp.from([
|
|
1051
|
-
begin,
|
|
1052
|
-
{ name: repeat_greedy(latin_only, 1) },
|
|
1053
|
-
{ key: optional(['*', repeat_greedy(latin_only, 0)]) },
|
|
1054
|
-
{ next: optional(['?', repeat_greedy(latin_only, 0)]) },
|
|
1055
|
-
end,
|
|
1056
|
-
]);
|
|
1057
|
-
})($ || ($ = {}));
|
|
1058
|
-
|
|
1059
|
-
;
|
|
1060
|
-
"use strict";
|
|
1061
|
-
var $;
|
|
1062
|
-
(function ($) {
|
|
1063
|
-
function $mol_view_tree2_prop_parts(prop) {
|
|
1064
|
-
const groups = [...prop.type.matchAll($mol_view_tree2_prop_signature)][0]?.groups;
|
|
1065
|
-
if (!groups) {
|
|
1066
|
-
this.$mol_fail($mol_view_tree2_error_str `Required prop like some*? at ${prop.span}`);
|
|
1067
|
-
}
|
|
1068
|
-
return {
|
|
1069
|
-
name: groups.name,
|
|
1070
|
-
key: groups.key,
|
|
1071
|
-
next: groups.next ? '?' : ''
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
$.$mol_view_tree2_prop_parts = $mol_view_tree2_prop_parts;
|
|
1075
|
-
})($ || ($ = {}));
|
|
1076
|
-
|
|
1077
|
-
;
|
|
1078
|
-
"use strict";
|
|
1079
|
-
var $;
|
|
1080
|
-
(function ($) {
|
|
1081
|
-
const regular_regex = /^\w+$/;
|
|
1082
|
-
function $mol_view_tree2_prop_quote(name) {
|
|
1083
|
-
if (regular_regex.test(name.value))
|
|
1084
|
-
return name;
|
|
1085
|
-
return name.data(JSON.stringify(name.value));
|
|
1086
|
-
}
|
|
1087
|
-
$.$mol_view_tree2_prop_quote = $mol_view_tree2_prop_quote;
|
|
1088
|
-
})($ || ($ = {}));
|
|
1089
|
-
|
|
1090
|
-
;
|
|
1091
|
-
"use strict";
|
|
1092
|
-
var $;
|
|
1093
|
-
(function ($) {
|
|
1094
|
-
const class_regex = /^[$A-Z][$\w<>\[\]()"'?|]+$/;
|
|
1095
|
-
function $mol_view_tree2_class_match(klass) {
|
|
1096
|
-
if (!klass?.type)
|
|
1097
|
-
return false;
|
|
1098
|
-
if (klass.type === 'NaN' || klass.type === 'Infinity')
|
|
1099
|
-
return false;
|
|
1100
|
-
return class_regex.test(klass.type);
|
|
1101
|
-
}
|
|
1102
|
-
$.$mol_view_tree2_class_match = $mol_view_tree2_class_match;
|
|
1103
|
-
})($ || ($ = {}));
|
|
1104
|
-
|
|
1105
|
-
;
|
|
1106
|
-
"use strict";
|
|
1107
|
-
var $;
|
|
1108
|
-
(function ($) {
|
|
1109
|
-
const err = $mol_view_tree2_error_str;
|
|
1110
|
-
function $mol_view_tree2_class_super(klass) {
|
|
1111
|
-
if (!$mol_view_tree2_class_match(klass))
|
|
1112
|
-
return this.$mol_fail(err `Wrong class name at ${klass.span}`);
|
|
1113
|
-
const superclass = klass.kids.length === 1 ? klass.kids[0] : undefined;
|
|
1114
|
-
if (!superclass)
|
|
1115
|
-
return this.$mol_fail(err `No super class at ${klass.span}`);
|
|
1116
|
-
if (!$mol_view_tree2_class_match(superclass))
|
|
1117
|
-
return this.$mol_fail(err `Wrong super class name ${JSON.stringify(superclass.type).replace(/(^"|"$)/g, "")} at ${superclass.span}`);
|
|
1118
|
-
return superclass;
|
|
1119
|
-
}
|
|
1120
|
-
$.$mol_view_tree2_class_super = $mol_view_tree2_class_super;
|
|
1121
|
-
})($ || ($ = {}));
|
|
1122
|
-
|
|
1123
|
-
;
|
|
1124
|
-
"use strict";
|
|
1125
|
-
var $;
|
|
1126
|
-
(function ($) {
|
|
1127
|
-
const err = $mol_view_tree2_error_str;
|
|
1128
|
-
function $mol_view_tree2_class_props(klass) {
|
|
1129
|
-
let props = this.$mol_view_tree2_class_super(klass);
|
|
1130
|
-
props = props.clone(props.hack({
|
|
1131
|
-
'': (node, belt) => {
|
|
1132
|
-
const normal = node.type.replace(/!\w+/, '*');
|
|
1133
|
-
if (node.type === normal)
|
|
1134
|
-
return [node.clone(node.hack(belt))];
|
|
1135
|
-
return [node.struct(normal, node.hack(belt))];
|
|
1136
|
-
}
|
|
1137
|
-
}));
|
|
1138
|
-
const props_inner = {};
|
|
1139
|
-
const add_inner = (prop) => {
|
|
1140
|
-
const { name } = this.$mol_view_tree2_prop_parts(prop);
|
|
1141
|
-
const prev = props_inner[name];
|
|
1142
|
-
if (prev && prev.kids[0]?.toString() !== prop.kids[0]?.toString()) {
|
|
1143
|
-
this.$mol_fail(err `Need an equal default values at ${prev.span} vs ${prop.span}`);
|
|
1144
|
-
}
|
|
1145
|
-
props_inner[name] = prop;
|
|
1146
|
-
};
|
|
1147
|
-
const upper = (operator, belt, context) => {
|
|
1148
|
-
const prop = this.$mol_view_tree2_child(operator);
|
|
1149
|
-
const defs = prop.hack(belt, { factory: prop });
|
|
1150
|
-
if (defs.length)
|
|
1151
|
-
add_inner(prop.clone(defs));
|
|
1152
|
-
return [operator.clone([prop.clone([])])];
|
|
1153
|
-
};
|
|
1154
|
-
const props_root = props.hack({
|
|
1155
|
-
'<=': upper,
|
|
1156
|
-
'<=>': upper,
|
|
1157
|
-
'^': (operator, belt, context) => {
|
|
1158
|
-
if (operator.kids.length === 0)
|
|
1159
|
-
return [operator];
|
|
1160
|
-
return upper(operator, belt, context);
|
|
1161
|
-
},
|
|
1162
|
-
'': (left, belt, context) => {
|
|
1163
|
-
let right;
|
|
1164
|
-
const operator = left.kids[0];
|
|
1165
|
-
if (operator?.type === '=>' && context.factory) {
|
|
1166
|
-
right = operator.kids[0];
|
|
1167
|
-
if (!right)
|
|
1168
|
-
this.$mol_fail(err `Need a child ${operator.span}`);
|
|
1169
|
-
if (!context.factory)
|
|
1170
|
-
this.$mol_fail(err `Need a parent ${left.span}`);
|
|
1171
|
-
add_inner(right.clone([
|
|
1172
|
-
right.struct('=', [
|
|
1173
|
-
context.factory.struct(context.factory.type.replace(/\*.*/, '*'), [left.clone([])]),
|
|
1174
|
-
]),
|
|
1175
|
-
]));
|
|
1176
|
-
}
|
|
1177
|
-
if (right)
|
|
1178
|
-
context = { factory: right.clone([]) };
|
|
1179
|
-
else if (operator && !context.factory && $mol_view_tree2_class_match(operator)) {
|
|
1180
|
-
context = { factory: left.clone([]) };
|
|
1181
|
-
}
|
|
1182
|
-
const hacked = left.clone(left.hack(belt, context));
|
|
1183
|
-
return [hacked];
|
|
1184
|
-
}
|
|
1185
|
-
}, { factory: undefined });
|
|
1186
|
-
for (const prop of props_root)
|
|
1187
|
-
add_inner(prop);
|
|
1188
|
-
return Object.values(props_inner);
|
|
1189
|
-
}
|
|
1190
|
-
$.$mol_view_tree2_class_props = $mol_view_tree2_class_props;
|
|
1191
|
-
})($ || ($ = {}));
|
|
1192
|
-
|
|
1193
|
-
;
|
|
1194
|
-
"use strict";
|
|
1195
|
-
var $;
|
|
1196
|
-
(function ($) {
|
|
1197
|
-
const err = $mol_view_tree2_error_str;
|
|
1198
|
-
function $mol_view_tree2_value_type(val) {
|
|
1199
|
-
switch (val.type) {
|
|
1200
|
-
case 'true': return 'bool';
|
|
1201
|
-
case 'false': return 'bool';
|
|
1202
|
-
case 'null': return 'null';
|
|
1203
|
-
case '*': return 'dict';
|
|
1204
|
-
case '@': return 'locale';
|
|
1205
|
-
case '': return 'string';
|
|
1206
|
-
case '<=': return 'get';
|
|
1207
|
-
case '<=>': return 'bind';
|
|
1208
|
-
case '=>': return 'put';
|
|
1209
|
-
}
|
|
1210
|
-
const first_char = val.type && val.type[0];
|
|
1211
|
-
if (first_char === '/')
|
|
1212
|
-
return 'list';
|
|
1213
|
-
if (Number(val.type).toString() == val.type)
|
|
1214
|
-
return 'number';
|
|
1215
|
-
if (/^[$A-Z]/.test(first_char))
|
|
1216
|
-
return 'object';
|
|
1217
|
-
return this.$mol_fail(err `Unknown value type ${val.type} at ${val.span}`);
|
|
1218
|
-
}
|
|
1219
|
-
$.$mol_view_tree2_value_type = $mol_view_tree2_value_type;
|
|
1220
|
-
})($ || ($ = {}));
|
|
1221
|
-
|
|
1222
|
-
;
|
|
1223
|
-
"use strict";
|
|
1224
|
-
var $;
|
|
1225
|
-
(function ($) {
|
|
1226
|
-
const err = $mol_view_tree2_error_str;
|
|
1227
|
-
function $mol_view_tree2_value(value) {
|
|
1228
|
-
const type = value.type;
|
|
1229
|
-
const kids = value.kids;
|
|
1230
|
-
if (type === '') {
|
|
1231
|
-
if (kids.length === 0)
|
|
1232
|
-
return value.data(JSON.stringify(value.value));
|
|
1233
|
-
return value.data(JSON.stringify(kids.map(node => node.value).join('\n')));
|
|
1234
|
-
}
|
|
1235
|
-
if (kids.length !== 0)
|
|
1236
|
-
return this.$mol_fail(err `Kids are not allowed at ${value.span}, use ${example}`);
|
|
1237
|
-
if (type === 'false' || type === 'true')
|
|
1238
|
-
return value.data(type);
|
|
1239
|
-
if (type === 'null')
|
|
1240
|
-
return value.data(type);
|
|
1241
|
-
if (Number(type).toString() === type.replace(/^\+/, ''))
|
|
1242
|
-
return value.data(type);
|
|
1243
|
-
return this.$mol_fail(err `Value ${value.toString()} not allowed at ${value.span}, use ${example}`);
|
|
1244
|
-
}
|
|
1245
|
-
$.$mol_view_tree2_value = $mol_view_tree2_value;
|
|
1246
|
-
const example = new $mol_view_tree2_error_suggestions([
|
|
1247
|
-
'false',
|
|
1248
|
-
'true',
|
|
1249
|
-
'123',
|
|
1250
|
-
'null',
|
|
1251
|
-
'\\some'
|
|
1252
|
-
]);
|
|
1253
|
-
})($ || ($ = {}));
|
|
1254
|
-
|
|
1255
|
-
;
|
|
1256
|
-
"use strict";
|
|
1257
|
-
var $;
|
|
1258
|
-
(function ($) {
|
|
1259
|
-
function $mol_view_tree2_value_number(type) {
|
|
659
|
+
function $mol_tree2_js_is_number(type) {
|
|
1260
660
|
return type.match(/[\+\-]*NaN/) || !Number.isNaN(Number(type));
|
|
1261
661
|
}
|
|
1262
|
-
$.$
|
|
662
|
+
$.$mol_tree2_js_is_number = $mol_tree2_js_is_number;
|
|
1263
663
|
})($ || ($ = {}));
|
|
1264
664
|
|
|
1265
665
|
;
|
|
@@ -1467,7 +867,7 @@ var $;
|
|
|
1467
867
|
return [
|
|
1468
868
|
input.data(input.type),
|
|
1469
869
|
];
|
|
1470
|
-
if ($
|
|
870
|
+
if ($mol_tree2_js_is_number(input.type))
|
|
1471
871
|
return [
|
|
1472
872
|
input.data(input.type)
|
|
1473
873
|
];
|