mol_tree2 1.0.616 → 1.0.618
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 +124 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +345 -6
- package/node.js.map +1 -1
- package/node.mjs +345 -6
- package/node.test.js +5137 -109
- package/node.test.js.map +1 -1
- package/package.json +8 -1
- package/web.d.ts +124 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +345 -6
- package/web.js.map +1 -1
- package/web.mjs +345 -6
- package/web.test.js +4892 -89
- package/web.test.js.map +1 -1
package/node.js
CHANGED
|
@@ -752,6 +752,341 @@ var $;
|
|
|
752
752
|
$.$mol_view_tree2_normalize = $mol_view_tree2_normalize;
|
|
753
753
|
})($ || ($ = {}));
|
|
754
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
|
+
|
|
755
1090
|
;
|
|
756
1091
|
"use strict";
|
|
757
1092
|
var $;
|
|
@@ -802,11 +1137,12 @@ var $;
|
|
|
802
1137
|
}));
|
|
803
1138
|
const props_inner = {};
|
|
804
1139
|
const add_inner = (prop) => {
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
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}`);
|
|
808
1144
|
}
|
|
809
|
-
props_inner[
|
|
1145
|
+
props_inner[name] = prop;
|
|
810
1146
|
};
|
|
811
1147
|
const upper = (operator, belt, context) => {
|
|
812
1148
|
const prop = this.$mol_view_tree2_child(operator);
|
|
@@ -843,10 +1179,13 @@ var $;
|
|
|
843
1179
|
else if (operator && !context.factory && $mol_view_tree2_class_match(operator)) {
|
|
844
1180
|
context = { factory: left.clone([]) };
|
|
845
1181
|
}
|
|
846
|
-
|
|
1182
|
+
const hacked = left.clone(left.hack(belt, context));
|
|
1183
|
+
return [hacked];
|
|
847
1184
|
}
|
|
848
1185
|
}, { factory: undefined });
|
|
849
|
-
|
|
1186
|
+
for (const prop of props_root)
|
|
1187
|
+
add_inner(prop);
|
|
1188
|
+
return Object.values(props_inner);
|
|
850
1189
|
}
|
|
851
1190
|
$.$mol_view_tree2_class_props = $mol_view_tree2_class_props;
|
|
852
1191
|
})($ || ($ = {}));
|